- multiple fixes
authorBart Polot <bart@net.in.tum.de>
Thu, 17 Oct 2013 13:05:52 +0000 (13:05 +0000)
committerBart Polot <bart@net.in.tum.de>
Thu, 17 Oct 2013 13:05:52 +0000 (13:05 +0000)
src/mesh/Makefile.am
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_connection.h
src/mesh/gnunet-service-mesh_peer.c
src/mesh/gnunet-service-mesh_tunnel.c
src/mesh/mesh_common.c
src/mesh/test_mesh.conf

index df1c74c8784774b20a2a7fc8a9877b92bc7cbc8b..3c71f47927ca5bdb88ca8013cb3b316fad03eccc 100644 (file)
@@ -102,15 +102,15 @@ if LINUX
 endif
 
 gnunet_service_mesh_enc_SOURCES = \
- gnunet-service-mesh-enc.c \
  gnunet-service-mesh_tunnel.c \
- gnunet-service-mesh_channel.c \
  gnunet-service-mesh_connection.c \
+ gnunet-service-mesh_channel.c \
+ gnunet-service-mesh_local.c \
  gnunet-service-mesh_peer.c \
  gnunet-service-mesh_dht.c \
- gnunet-service-mesh_local.c \
  mesh_path.c \
- mesh_common.c
+ mesh_common.c \
+ gnunet-service-mesh-enc.c
 gnunet_service_mesh_enc_CFLAGS = $(AM_CFLAGS)
 gnunet_service_mesh_enc_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
index 5ca287cb157215b19863ee9333036807c9276e15..3197255efb5008baacfcd27b5df9c14e335392f9 100644 (file)
@@ -409,8 +409,7 @@ message_sent (void *cls,
   /* Send ACK if needed, after accounting for sent ID in fc->queue_n */
   switch (type)
   {
-    case GNUNET_MESSAGE_TYPE_MESH_FWD:
-    case GNUNET_MESSAGE_TYPE_MESH_BCK:
+    case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
       fc->last_pid_sent++;
       LOG (GNUNET_ERROR_TYPE_DEBUG, "!   accounting pid %u\n", fc->last_pid_sent);
 //       send_ack (c, ch, fwd);
@@ -1309,23 +1308,23 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
  *
  * @param peer Peer identity this notification is about.
  * @param message Encrypted message.
- * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
  *
  * @return GNUNET_OK to keep the connection open,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
 static int
 handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer,
-                       const struct GNUNET_MESH_Encrypted *msg,
-                       int fwd)
+                       const struct GNUNET_MESH_Encrypted *msg)
 {
   struct MeshConnection *c;
   struct MeshPeer *neighbor;
   struct MeshFlowControl *fc;
+  GNUNET_PEER_Id peer_id;
   uint32_t pid;
   uint32_t ttl;
   uint16_t type;
   size_t size;
+  int fwd;
 
   /* Check size */
   size = ntohs (msg->header.size);
@@ -1350,15 +1349,27 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer,
     return GNUNET_OK;
   }
 
-  fc = fwd ? &c->bck_fc : &c->fwd_fc;
-
   /* Check if origin is as expected */
-  neighbor = get_hop (c, !fwd);
-  if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor))
+  neighbor = get_prev_hop (c);
+  peer_id = GNUNET_PEER_search (peer);
+  if (peer_id == GMP_get_short_id (neighbor))
   {
-    GNUNET_break_op (0);
-    return GNUNET_OK;
+    fwd = GNUNET_YES;
+  }
+  else
+  {
+    neighbor = get_next_hop (c);
+    if (peer_id == GMP_get_short_id (neighbor))
+    {
+      fwd = GNUNET_NO;
+    }
+    else
+    {
+      GNUNET_break_op (0);
+      return GNUNET_OK;
+    }
   }
+  fc = fwd ? &c->bck_fc : &c->fwd_fc;
 
   /* Check PID */
   pid = ntohl (msg->pid);
@@ -1421,7 +1432,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer,
 
 
 /**
- * Core handler for mesh network traffic going orig->dest.
+ * Core handler for encrypted mesh network traffic (channel mgmt, data).
  *
  * @param cls Closure (unused).
  * @param message Message received.
@@ -1431,31 +1442,11 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
 int
-GMC_handle_fwd (void *cls, const struct GNUNET_PeerIdentity *peer,
-                const struct GNUNET_MessageHeader *message)
-{
-  return handle_mesh_encrypted (peer,
-                                (struct GNUNET_MESH_Encrypted *)message,
-                                GNUNET_YES);
-}
-
-/**
- * Core handler for mesh network traffic going dest->orig.
- *
- * @param cls Closure (unused).
- * @param message Message received.
- * @param peer Peer who sent the message.
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
- */
-int
-GMC_handle_bck (void *cls, const struct GNUNET_PeerIdentity *peer,
-                const struct GNUNET_MessageHeader *message)
+GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
+                      const struct GNUNET_MessageHeader *message)
 {
   return handle_mesh_encrypted (peer,
-                                (struct GNUNET_MESH_Encrypted *)message,
-                                GNUNET_NO);
+                                (struct GNUNET_MESH_Encrypted *)message);
 }
 
 
@@ -2118,8 +2109,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
     struct GNUNET_MESH_ConnectionBroken  *bmsg;
     uint32_t ttl;
 
-    case GNUNET_MESSAGE_TYPE_MESH_FWD:
-    case GNUNET_MESSAGE_TYPE_MESH_BCK:
+    case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
       emsg = (struct GNUNET_MESH_Encrypted *) data;
       ttl = ntohl (emsg->ttl);
       if (0 == ttl)
index bdfaaf98830a7bceb149a1ee2cdb8f54f208ac4f..3fecf3b63276a24445dbeb885ddcbde7e4f4b4a7 100644 (file)
@@ -136,7 +136,7 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
                     const struct GNUNET_MessageHeader *message);
 
 /**
- * Core handler for mesh network traffic going orig->dest.
+ * Core handler for encrypted mesh network traffic (channel mgmt, data).
  *
  * @param cls Closure (unused).
  * @param message Message received.
@@ -146,23 +146,8 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
 int
-GMC_handle_fwd (void *cls, const struct GNUNET_PeerIdentity *peer,
-                const struct GNUNET_MessageHeader *message);
-
-
-/**
- * Core handler for mesh network traffic going dest->orig.
- *
- * @param cls Closure (unused).
- * @param message Message received.
- * @param peer Peer who sent the message.
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
- */
-int
-GMC_handle_bck (void *cls, const struct GNUNET_PeerIdentity *peer,
-                const struct GNUNET_MessageHeader *message);
+GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
+                      const struct GNUNET_MessageHeader *message);
 
 /**
  * Core handler for mesh network traffic point-to-point acks.
index ff0d43813cd02e2814711c7246e44fccd23da0b4..515c4b4f0fdae87e218465702fca5530893d6019 100644 (file)
@@ -332,8 +332,7 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = {
     sizeof (struct GNUNET_MESH_ACK)},
   {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_MESH_POLL,
     sizeof (struct GNUNET_MESH_Poll)},
-  {&GMC_handle_fwd, GNUNET_MESSAGE_TYPE_MESH_FWD, 0},
-  {&GMC_handle_bck, GNUNET_MESSAGE_TYPE_MESH_BCK, 0},
+  {&GMC_handle_encrypted, GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED, 0},
   {NULL, 0, 0}
 };
 
@@ -774,8 +773,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
       case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
         LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n");
         /* fall through */
-      case GNUNET_MESSAGE_TYPE_MESH_FWD:
-      case GNUNET_MESSAGE_TYPE_MESH_BCK:
+      case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
       case GNUNET_MESSAGE_TYPE_MESH_ACK:
       case GNUNET_MESSAGE_TYPE_MESH_POLL:
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
@@ -872,8 +870,7 @@ queue_send (void *cls, size_t size, void *buf)
     case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
-    case GNUNET_MESSAGE_TYPE_MESH_FWD:
-    case GNUNET_MESSAGE_TYPE_MESH_BCK:
+    case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
     case GNUNET_MESSAGE_TYPE_MESH_ACK:
     case GNUNET_MESSAGE_TYPE_MESH_POLL:
       LOG (GNUNET_ERROR_TYPE_DEBUG,
index a5220a04f58036a398506129bc562a5bc19fb5a7..e2cf7db17d26cf61f89c2b7abc92685097c91d30 100644 (file)
@@ -1199,10 +1199,10 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
   type = ntohs (message->type);
   switch (type)
   {
-    case GNUNET_MESSAGE_TYPE_MESH_FWD:
-    case GNUNET_MESSAGE_TYPE_MESH_BCK:
+    case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
+    case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
       msg->cid = *GMC_get_id (c);
       msg->ttl = htonl (default_ttl);
       break;
index 1089e8edc347973e690a44a5c764185a46372e81..90f2e5299974158873e64b1594aff173d73324dd 100644 (file)
@@ -146,19 +146,14 @@ GNUNET_MESH_DEBUG_M2S (uint16_t m)
     case 274: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY";
 
       /**
-       * Confirm the creation of a channel
+       * Confirm the creation of a channel.
        */
     case 275: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK";
 
       /**
-       * Ask the mesh service to create a new tunnel
-       */
-    case 280: return "GNUNET_MESSAGE_TYPE_MESH_FWD";
-
-      /**
-       * Ask the mesh service to destroy a tunnel
+       * Encrypted payload.
        */
-    case 281: return "GNUNET_MESSAGE_TYPE_MESH_BCK";
+    case 280: return "GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED";
 
       /**
        * Local payload traffic
index 7d04cd97de69836013b7e4e2e7c789d4fc27d10e..e7d265bea04e10bce0c4121c1a42478e0ab26e16 100644 (file)
@@ -79,3 +79,11 @@ AUTOSTART = NO
 
 [consensus]
 AUTOSTART = NO
+
+[nat]
+# Allow running on systems with only loopback?
+RETURN_LOCAL_ADDRESSES = YES
+# Disable redundant addresses...
+DISABLEV6 = YES
+USE_LOCALADDR = YES
+