gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29241 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r29241 - gnunet/src/transport
Date: Fri, 13 Sep 2013 14:53:00 +0200

Author: wachs
Date: 2013-09-13 14:53:00 +0200 (Fri, 13 Sep 2013)
New Revision: 29241

Modified:
   gnunet/src/transport/plugin_transport_wlan.c
Log:
plugin returns inbound session if outbound session is requiered


Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2013-09-13 12:37:20 UTC 
(rev 29240)
+++ gnunet/src/transport/plugin_transport_wlan.c        2013-09-13 12:53:00 UTC 
(rev 29241)
@@ -212,6 +212,8 @@
    */
   GNUNET_SCHEDULER_TaskIdentifier timeout_task;
 
+  int inbound;
+
 };
 
 
@@ -352,6 +354,11 @@
   struct WlanAddress addr;
 
   /**
+   * Inbound or outbound session
+   */
+  int inbound;
+
+  /**
    * Message delay for fragmentation context
    */
   struct GNUNET_TIME_Relative msg_delay;
@@ -718,13 +725,14 @@
  */
 static struct Session *
 lookup_session (struct MacEndpoint *endpoint,
-                const struct GNUNET_PeerIdentity *peer)
+                const struct GNUNET_PeerIdentity *peer,
+                int inbound)
 {
   struct Session *session;
 
   for (session = endpoint->sessions_head; NULL != session; session = 
session->next)
-    if (0 == memcmp (peer, &session->target,
-                    sizeof (struct GNUNET_PeerIdentity)))
+    if (0 == memcmp (peer, &session->target, sizeof (struct 
GNUNET_PeerIdentity)) &&
+               (session->inbound == inbound))
     {
       session->timeout = GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
       return session;
@@ -741,7 +749,7 @@
  */
 static struct Session *
 create_session (struct MacEndpoint *endpoint,
-                const struct GNUNET_PeerIdentity *peer)
+                const struct GNUNET_PeerIdentity *peer, int inbound)
 {
   struct Session *session;
 
@@ -751,15 +759,19 @@
   GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head,
                                     endpoint->sessions_tail,
                                    session);
+  session->inbound = inbound;
   session->mac = endpoint;
   session->target = *peer;
   session->timeout = GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
   session->timeout_task =
       GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 
&session_timeout, session);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Created new session for peer `%s' with endpoint %s\n",
+       "Created new %s session %p for peer `%s' with endpoint %s\n",
+       (GNUNET_YES == inbound) ? "inbound" : "outbound",
+       session,
        GNUNET_i2s (peer),
        mac_to_string (&endpoint->addr.mac));
+
   return session;
 }
 
@@ -773,12 +785,13 @@
  */
 static struct Session *
 get_session (struct MacEndpoint *endpoint,
-                const struct GNUNET_PeerIdentity *peer)
+                const struct GNUNET_PeerIdentity *peer,
+                int inbound)
 {
   struct Session *session;
-  if (NULL != (session = lookup_session (endpoint, peer)))
+  if (NULL != (session = lookup_session (endpoint, peer, inbound)))
        return session;
-  return create_session (endpoint, peer);
+  return create_session (endpoint, peer, inbound);
 }
 
 
@@ -1113,7 +1126,7 @@
        GNUNET_i2s (&address->peer),
        wlan_plugin_address_to_string(NULL, address->address, 
address->address_length));
   endpoint = create_macendpoint (plugin, address->address);
-  return get_session (endpoint, &address->peer);
+  return get_session (endpoint, &address->peer, GNUNET_NO);
 }
 
 
@@ -1354,9 +1367,9 @@
       break;
     }
     xmas.endpoint = mas->endpoint;
-    if (NULL == (xmas.session =  lookup_session (mas->endpoint, 
&wlanheader->sender)))
+    if (NULL == (xmas.session =  lookup_session (mas->endpoint, 
&wlanheader->sender, GNUNET_YES)))
     {
-       xmas.session = create_session (mas->endpoint, &wlanheader->sender);
+       xmas.session = create_session (mas->endpoint, &wlanheader->sender, 
GNUNET_YES);
        plugin->env->session_start (NULL, &wlanheader->sender,
                        PLUGIN_NAME, NULL, 0, xmas.session, NULL, 0);
       LOG (GNUNET_ERROR_TYPE_DEBUG,




reply via email to

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