gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22243 - in gnunet/src: ats transport


From: gnunet
Subject: [GNUnet-SVN] r22243 - in gnunet/src: ats transport
Date: Sun, 24 Jun 2012 00:31:43 +0200

Author: grothoff
Date: 2012-06-24 00:31:43 +0200 (Sun, 24 Jun 2012)
New Revision: 22243

Modified:
   gnunet/src/ats/ats_api_scheduling.c
   gnunet/src/transport/plugin_transport_http.h
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_template.c
   gnunet/src/transport/plugin_transport_unix.c
   gnunet/src/transport/plugin_transport_wlan.c
Log:
-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.



Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2012-06-23 22:30:43 UTC (rev 22242)
+++ gnunet/src/ats/ats_api_scheduling.c 2012-06-23 22:31:43 UTC (rev 22243)
@@ -346,6 +346,22 @@
     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;
 }
 

Modified: gnunet/src/transport/plugin_transport_http.h
===================================================================
--- gnunet/src/transport/plugin_transport_http.h        2012-06-23 22:30:43 UTC 
(rev 22242)
+++ gnunet/src/transport/plugin_transport_http.h        2012-06-23 22:31:43 UTC 
(rev 22243)
@@ -339,6 +339,10 @@
  */
 struct Session
 {
+  /**
+   * To whom are we talking to
+   */
+  struct GNUNET_PeerIdentity target;
 
   /**
    * Stored in a linked list.
@@ -371,11 +375,6 @@
   uint32_t ats_address_network_type;
 
   /**
-   * To whom are we talking to
-   */
-  struct GNUNET_PeerIdentity target;
-
-  /**
    * next pointer for double linked list
    */
   struct HTTP_Message *msg_head;

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2012-06-23 22:30:43 UTC (rev 
22242)
+++ gnunet/src/transport/plugin_transport_tcp.c 2012-06-23 22:31:43 UTC (rev 
22243)
@@ -223,6 +223,11 @@
  */
 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.
@@ -262,12 +267,6 @@
   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.
    */
   GNUNET_SCHEDULER_TaskIdentifier receive_delay_task;

Modified: gnunet/src/transport/plugin_transport_template.c
===================================================================
--- gnunet/src/transport/plugin_transport_template.c    2012-06-23 22:30:43 UTC 
(rev 22242)
+++ gnunet/src/transport/plugin_transport_template.c    2012-06-23 22:31:43 UTC 
(rev 22243)
@@ -54,6 +54,11 @@
  */
 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.
@@ -83,12 +88,6 @@
   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?
    */
   struct GNUNET_TIME_Absolute last_quota_update;

Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c        2012-06-23 22:30:43 UTC 
(rev 22242)
+++ gnunet/src/transport/plugin_transport_unix.c        2012-06-23 22:31:43 UTC 
(rev 22243)
@@ -82,9 +82,10 @@
 
 struct Session
 {
+  struct GNUNET_PeerIdentity target;
+
   void *addr;
   size_t addrlen;
-  struct GNUNET_PeerIdentity target;
 
   /**
    * Session timeout task

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2012-06-23 22:30:43 UTC 
(rev 22242)
+++ gnunet/src/transport/plugin_transport_wlan.c        2012-06-23 22:31:43 UTC 
(rev 22243)
@@ -152,6 +152,11 @@
  */
 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).
@@ -186,12 +191,6 @@
   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?
    */
   struct GNUNET_TIME_Absolute timeout;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]