-LRN: Check session target:
authorChristian Grothoff <christian@grothoff.org>
Sat, 23 Jun 2012 22:31:43 +0000 (22:31 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 23 Jun 2012 22:31:43 +0000 (22:31 +0000)
  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.

src/ats/ats_api_scheduling.c
src/transport/plugin_transport_http.h
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_template.c
src/transport/plugin_transport_unix.c
src/transport/plugin_transport_wlan.c

index 88a6423b44f45eb433bdc70b055b592b374439f1..2e97d2ee28c05ccf3e9f87327e76326310dacd94 100644 (file)
@@ -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;
 }
 
index 986d7d7975cabb985cdacabae53e990bce9cbf66..dc0f8bb01a0af6bc0ccd389e07e5dd6305c689c3 100644 (file)
@@ -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
    */
index a426215692e7b74f2d1090872e33ac1dbb4a6264..007e87f936491bf77cfd211bf9cb63127f62a939 100644 (file)
@@ -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.
    */
index d3072627e8e5d22879d61bc84ee425cf07e6999d..10ce0da48a77eae764e75477594436a2d4d164e1 100644 (file)
@@ -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?
    */
index 289fea0b63d357f6fb5734efe860b6100939cbb5..b7e10b7200c4b87f49d7b35d4f23672ca72714da 100644 (file)
@@ -82,9 +82,10 @@ struct UNIXMessage
 
 struct Session
 {
+  struct GNUNET_PeerIdentity target;
+
   void *addr;
   size_t addrlen;
-  struct GNUNET_PeerIdentity target;
 
   /**
    * Session timeout task
index aed4b22861c88bb33ea7d2011468f27174c2731b..c2565a4a8fb9f198de1c3343266d03008b54525a 100644 (file)
@@ -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?
    */