diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport_3way.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/transport/gnunet-service-transport_3way.c b/src/transport/gnunet-service-transport_3way.c index 5d8b5ccd0..ef9068c9b 100644 --- a/src/transport/gnunet-service-transport_3way.c +++ b/src/transport/gnunet-service-transport_3way.c | |||
@@ -136,7 +136,8 @@ process_payload (const struct GNUNET_PeerIdentity *peer, | |||
136 | struct GNUNET_TIME_Relative ret; | 136 | struct GNUNET_TIME_Relative ret; |
137 | int do_forward; | 137 | int do_forward; |
138 | struct InboundMessage *im; | 138 | struct InboundMessage *im; |
139 | size_t size = sizeof (struct InboundMessage) + ntohs (message->size) + sizeof (struct GNUNET_ATS_Information) * ats_count; | 139 | size_t msg_size = ntohs (message->size); |
140 | size_t size = sizeof (struct InboundMessage) + msg_size + sizeof (struct GNUNET_ATS_Information) * ats_count; | ||
140 | char buf[size]; | 141 | char buf[size]; |
141 | struct GNUNET_ATS_Information *ap; | 142 | struct GNUNET_ATS_Information *ap; |
142 | 143 | ||
@@ -146,9 +147,26 @@ process_payload (const struct GNUNET_PeerIdentity *peer, | |||
146 | GST_neighbours_calculate_receive_delay (peer, | 147 | GST_neighbours_calculate_receive_delay (peer, |
147 | (message == | 148 | (message == |
148 | NULL) ? 0 : | 149 | NULL) ? 0 : |
149 | ntohs (message->size), | 150 | msg_size, |
150 | &do_forward); | 151 | &do_forward); |
151 | 152 | ||
153 | if (!GST_neighbours_test_connected (peer)) | ||
154 | { | ||
155 | |||
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Discarded %u bytes type %u payload from peer `%s'\n", | ||
157 | msg_size, | ||
158 | ntohs (message->type), | ||
159 | GNUNET_i2s (peer)); | ||
160 | |||
161 | GNUNET_STATISTICS_update (GST_stats, | ||
162 | gettext_noop ("# bytes payload discarded due to not connected peer "), | ||
163 | msg_size, | ||
164 | GNUNET_NO); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | if (do_forward != GNUNET_YES) | ||
169 | return ret; | ||
152 | im = (struct InboundMessage*) buf; | 170 | im = (struct InboundMessage*) buf; |
153 | im->header.size = htons (size); | 171 | im->header.size = htons (size); |
154 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); | 172 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); |
@@ -158,30 +176,8 @@ process_payload (const struct GNUNET_PeerIdentity *peer, | |||
158 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | 176 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
159 | memcpy (&ap[ats_count], message, ntohs (message->size)); | 177 | memcpy (&ap[ats_count], message, ntohs (message->size)); |
160 | 178 | ||
161 | switch (do_forward) | 179 | GST_clients_broadcast (&im->header, GNUNET_YES); |
162 | { | 180 | |
163 | case GNUNET_YES: | ||
164 | GST_clients_broadcast (&im->header, GNUNET_YES); | ||
165 | break; | ||
166 | case GNUNET_NO: | ||
167 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
168 | _("Discarded %u bytes of type %u from %s: quota violated or no neighbour record!\n"), | ||
169 | ntohs (message->size), | ||
170 | ntohs (message->type), | ||
171 | GNUNET_i2s (peer)); | ||
172 | break; | ||
173 | case GNUNET_SYSERR: | ||
174 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
175 | _("Discarded %u bytes of type %u from %s: connection is down!\n"), | ||
176 | ntohs (message->size), | ||
177 | ntohs (message->type), | ||
178 | GNUNET_i2s (peer)); | ||
179 | /* FIXME: store until connection is up? This is virtually always a SETKEY and a PING... */ | ||
180 | break; | ||
181 | default: | ||
182 | GNUNET_break (0); | ||
183 | break; | ||
184 | } | ||
185 | return ret; | 181 | return ret; |
186 | } | 182 | } |
187 | 183 | ||