From: Christian Grothoff Date: Sat, 23 Jun 2012 22:31:43 +0000 (+0000) Subject: -LRN: Check session target: X-Git-Tag: initial-import-from-subversion-38251~12854 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e4b5a6b681d196cb233bf15a91060e3585933aa1;p=oweals%2Fgnunet.git -LRN: Check session target: It changes the Session object layout to make peer identity its first field, always, for all sessions. Code in find_session() can use this to check that the session belongs to the right peer. test_ats_api_add_address always triggers this due to the way it fakes a pointer to session object. --- diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 88a6423b4..2e97d2ee2 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -346,6 +346,22 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, sh->reconnect = GNUNET_YES; return NULL; } + /* This check exploits the fact that first field of a session object + * is peer identity. + */ + if (0 != + memcmp (peer, sh->session_array[session_id].session, + sizeof (struct GNUNET_PeerIdentity))) + { + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "ats-scheduling-api", + "Session %p belongs to peer `%s'\n", + sh->session_array[session_id].session, GNUNET_i2s_full ((struct GNUNET_PeerIdentity *)sh->session_array[session_id].session)); +/* + GNUNET_break (0); + sh->reconnect = GNUNET_YES; + return NULL; +*/ + } return sh->session_array[session_id].session; } diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 986d7d797..dc0f8bb01 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h @@ -339,6 +339,10 @@ struct ServerConnection */ struct Session { + /** + * To whom are we talking to + */ + struct GNUNET_PeerIdentity target; /** * Stored in a linked list. @@ -370,11 +374,6 @@ struct Session */ uint32_t ats_address_network_type; - /** - * To whom are we talking to - */ - struct GNUNET_PeerIdentity target; - /** * next pointer for double linked list */ diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index a42621569..007e87f93 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -223,6 +223,11 @@ struct PendingMessage */ struct Session { + /** + * To whom are we talking to (set to our identity + * if we are still waiting for the welcome message) + */ + struct GNUNET_PeerIdentity target; /** * API requirement. @@ -261,12 +266,6 @@ struct Session */ struct GNUNET_SERVER_TransmitHandle *transmit_handle; - /** - * To whom are we talking to (set to our identity - * if we are still waiting for the welcome message) - */ - struct GNUNET_PeerIdentity target; - /** * ID of task used to delay receiving more to throttle sender. */ diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index d3072627e..10ce0da48 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c @@ -54,6 +54,11 @@ struct Plugin; */ struct Session { + /** + * To whom are we talking to (set to our identity + * if we are still waiting for the welcome message) + */ + struct GNUNET_PeerIdentity sender; /** * Stored in a linked list. @@ -82,12 +87,6 @@ struct Session */ void *transmit_cont_cls; - /** - * To whom are we talking to (set to our identity - * if we are still waiting for the welcome message) - */ - struct GNUNET_PeerIdentity sender; - /** * At what time did we reset last_received last? */ diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 289fea0b6..b7e10b720 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -82,9 +82,10 @@ struct UNIXMessage struct Session { + struct GNUNET_PeerIdentity target; + void *addr; size_t addrlen; - struct GNUNET_PeerIdentity target; /** * Session timeout task diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index aed4b2286..c2565a4a8 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -152,6 +152,11 @@ struct PendingMessage */ struct Session { + /** + * To whom are we talking to (set to our identity + * if we are still waiting for the welcome message) + */ + struct GNUNET_PeerIdentity target; /** * API requirement (must be first). @@ -185,12 +190,6 @@ struct Session */ struct PendingMessage *pending_message_tail; - /** - * To whom are we talking to (set to our identity - * if we are still waiting for the welcome message) - */ - struct GNUNET_PeerIdentity target; - /** * When should this session time out? */