aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c78
1 files changed, 64 insertions, 14 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index d96a284c7..6b62c17fe 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -124,7 +124,6 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
124} 124}
125 125
126 126
127
128/** 127/**
129 * We received some payload. Prepare to pass it on to our clients. 128 * We received some payload. Prepare to pass it on to our clients.
130 * 129 *
@@ -178,14 +177,36 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
178 177
179 178
180/** 179/**
180 * Force plugin to terminate session due to communication
181 * issue.
182 *
183 * @param plugin_name name of the plugin
184 * @param session session to termiante
185 */
186static void
187kill_session (const char *plugin_name,
188 struct Session *session)
189{
190 struct GNUNET_TRANSPORT_PluginFunctions *plugin;
191
192 plugin = GST_plugins_find (plugin_name);
193 if (NULL == plugin)
194 {
195 GNUNET_break (0);
196 return;
197 }
198 plugin->disconnect_session (plugin->cls,
199 session);
200}
201
202
203/**
181 * Function called by the transport for each received message. 204 * Function called by the transport for each received message.
182 * This function should also be called with "NULL" for the
183 * message to signal that the other peer disconnected.
184 * 205 *
185 * @param cls closure, const char* with the name of the plugin we received the message from 206 * @param cls closure, const char* with the name of the plugin we received the message from
186 * @param peer (claimed) identity of the other peer 207 * @param peer (claimed) identity of the other peer
187 * @param message the message, NULL if we only care about 208 * @param message the message, NULL if we only care about
188 * learning about the delay until we should receive again -- FIXME! 209 * learning about the delay until we should receive again
189 * @param session identifier used for this session (NULL for plugins 210 * @param session identifier used for this session (NULL for plugins
190 * that do not offer bi-directional communication to the sender 211 * that do not offer bi-directional communication to the sender
191 * using the same "connection") 212 * using the same "connection")
@@ -236,30 +257,57 @@ GST_receive_callback (void *cls,
236 /* Legacy HELLO message, discard */ 257 /* Legacy HELLO message, discard */
237 return ret; 258 return ret;
238 case GNUNET_MESSAGE_TYPE_HELLO: 259 case GNUNET_MESSAGE_TYPE_HELLO:
239 GST_validation_handle_hello (message); 260 if (GNUNET_OK !=
261 GST_validation_handle_hello (message))
262 {
263 GNUNET_break_op (0);
264 kill_session (plugin_name, session);
265 }
240 return ret; 266 return ret;
241 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: 267 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
243 "Processing `%s' from `%s'\n", "PING", 269 "Processing `%s' from `%s'\n", "PING",
244 (sender_address != 270 (sender_address !=
245 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING); 271 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING);
246 GST_validation_handle_ping (peer, message, &address, session); 272 if (GNUNET_OK !=
273 GST_validation_handle_ping (peer, message, &address, session))
274 kill_session (plugin_name, session);
247 break; 275 break;
248 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: 276 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
250 "Processing `%s' from `%s'\n", "PONG", 278 "Processing `%s' from `%s'\n", "PONG",
251 (sender_address != 279 (sender_address !=
252 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING); 280 NULL) ? GST_plugins_a2s (&address) : TRANSPORT_SESSION_INBOUND_STRING);
253 GST_validation_handle_pong (peer, message); 281 if (GNUNET_OK !=
282 GST_validation_handle_pong (peer, message))
283 {
284 GNUNET_break_op (0);
285 kill_session (plugin_name, session);
286 }
254 break; 287 break;
255 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: 288 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
256 GST_neighbours_handle_connect (message, peer, &address, session); 289 if (GNUNET_OK !=
290 GST_neighbours_handle_connect (message, peer, &address, session))
291 {
292 GNUNET_break_op (0);
293 kill_session (plugin_name, session);
294 }
257 break; 295 break;
258 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: 296 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
259 GST_neighbours_handle_connect_ack (message, peer, &address, session); 297 if (GNUNET_OK !=
298 GST_neighbours_handle_connect_ack (message, peer, &address, session))
299 {
300 GNUNET_break_op (0);
301 kill_session (plugin_name, session);
302 }
260 break; 303 break;
261 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: 304 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
262 GST_neighbours_handle_session_ack (message, peer, &address, session); 305 if (GNUNET_OK !=
306 GST_neighbours_handle_session_ack (message, peer, &address, session))
307 {
308 GNUNET_break_op (0);
309 kill_session (plugin_name, session);
310 }
263 break; 311 break;
264 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: 312 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
265 GST_neighbours_handle_disconnect_message (peer, message); 313 GST_neighbours_handle_disconnect_message (peer, message);
@@ -370,6 +418,7 @@ plugin_env_address_to_type (void *cls,
370 size_t addrlen) 418 size_t addrlen)
371{ 419{
372 struct GNUNET_ATS_Information ats; 420 struct GNUNET_ATS_Information ats;
421
373 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 422 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
374 ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED); 423 ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED);
375 if (GST_ats == NULL) 424 if (GST_ats == NULL)
@@ -381,9 +430,10 @@ plugin_env_address_to_type (void *cls,
381 ((addr->sa_family != AF_INET6) && (addrlen != sizeof (struct sockaddr_in6))) && 430 ((addr->sa_family != AF_INET6) && (addrlen != sizeof (struct sockaddr_in6))) &&
382 (addr->sa_family != AF_UNIX)) 431 (addr->sa_family != AF_UNIX))
383 { 432 {
384 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed address with length %u `%s'\n", 433 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
434 "Malformed address with length %u `%s'\n",
385 addrlen, 435 addrlen,
386 GNUNET_a2s(addr, addrlen)); 436 GNUNET_a2s (addr, addrlen));
387 GNUNET_break (0); 437 GNUNET_break (0);
388 return ats; 438 return ats;
389 } 439 }
@@ -621,8 +671,8 @@ ats_request_address_change (void *cls,
621 return; 671 return;
622 } 672 }
623 GST_neighbours_switch_to_address (&address->peer, address, session, ats, 673 GST_neighbours_switch_to_address (&address->peer, address, session, ats,
624 ats_count, bandwidth_in, 674 ats_count, bandwidth_in,
625 bandwidth_out); 675 bandwidth_out);
626} 676}
627 677
628 678