applied
authorBernd Petrovitsch <bernd@firmix.at>
Sun, 19 Aug 2007 20:37:41 +0000 (20:37 +0000)
committerBernd Petrovitsch <bernd@firmix.at>
Sun, 19 Aug 2007 20:37:41 +0000 (20:37 +0000)
  110-olsrd-double-wlancard-neigh-hack.patch,
  111-olsrd-complainpluginvers-nosleep.patch,
  112-olsrd-nameservice-fixemptyname.patch,
  113-olsrd-dyngwplain-pluginvers5.patch and
  140-olsrd-arprefreshed.patch
from http://download-master.berlin.freifunk.net/sven-ola/nylon/packages/olsrd/files/

lib/arprefresh/.cvsignore [new file with mode: 0644]
lib/arprefresh/Makefile [new file with mode: 0644]
lib/arprefresh/README_ARPREFRESH [new file with mode: 0644]
lib/arprefresh/src/.cvsignore [new file with mode: 0644]
lib/arprefresh/src/olsrd_arprefresh.c [new file with mode: 0644]
lib/arprefresh/src/olsrd_arprefresh.h [new file with mode: 0644]
lib/arprefresh/version-script.txt [new file with mode: 0644]
lib/dyn_gw_plain/src/olsrd_dyn_gw_plain.c
src/link_set.c
src/lq_packet.c

diff --git a/lib/arprefresh/.cvsignore b/lib/arprefresh/.cvsignore
new file mode 100644 (file)
index 0000000..e720ffc
--- /dev/null
@@ -0,0 +1 @@
+olsrd_arprefresh.so.*
diff --git a/lib/arprefresh/Makefile b/lib/arprefresh/Makefile
new file mode 100644 (file)
index 0000000..87c9fe0
--- /dev/null
@@ -0,0 +1,58 @@
+# The olsr.org Optimized Link-State Routing daemon(olsrd)
+# Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org)
+# Arprefresh plugin Copyright (c) 2007, Sven-Ola-aet-gmx.de
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# * Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright 
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+# * Neither the name of olsr.org, olsrd nor the names of its 
+#   contributors may be used to endorse or promote products derived 
+#   from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Visit http://www.olsr.org for more information.
+#
+# If you find this software useful feel free to make a donation
+# to the project. For more information see the website or contact
+# the copyright holders.
+#
+# $Id: Makefile,v 1.1 2007/08/19 20:37:41 bernd67 Exp $
+
+OLSRD_PLUGIN = true
+PLUGIN_NAME =  olsrd_arprefresh
+PLUGIN_VER =   0.1
+
+TOPDIR = ../..
+include $(TOPDIR)/Makefile.inc
+
+default_target: $(PLUGIN_FULLNAME)
+
+$(PLUGIN_FULLNAME): $(OBJS) version-script.txt
+               $(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
+
+install:       $(PLUGIN_FULLNAME)
+               $(STRIP) $(PLUGIN_FULLNAME)
+               $(INSTALL_LIB)
+
+clean:
+               rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
diff --git a/lib/arprefresh/README_ARPREFRESH b/lib/arprefresh/README_ARPREFRESH
new file mode 100644 (file)
index 0000000..8308d51
--- /dev/null
@@ -0,0 +1,31 @@
+---------------------------------------------------------------------
+ARP REFRESH PLUGIN FOR OLSRD
+by Sven-Ola Tuecke <sven-ola-aet-gmx.de>
+---------------------------------------------------------------------
+
+This plugin listens to all recevice UDP packets and maintains an
+internal list of MAC addresses extracted from these. By hitchhiking
+the set-route-function, the kernel ARP cache will be refreshed from
+this list if a direct-neighbour host route is configured. Result:
+no more ARP lookups if you use a larger routing chain - e.g. fetch
+a web site 8 olsr-hops away does not show the typcial 8-nodes-need
+to ARP first delay.
+
+---------------------------------------------------------------------
+PLUGIN PARAMETERS (PlParam)
+---------------------------------------------------------------------
+
+None.
+
+---------------------------------------------------------------------
+SAMPLE CONFIG
+---------------------------------------------------------------------
+
+add in /etc/olsrd.conf:
+
+LoadPlugin "arprefresh.so.0.1"
+{
+}
+
+---------------------------------------------------------------------
+EOF / 2007-AUG-02
diff --git a/lib/arprefresh/src/.cvsignore b/lib/arprefresh/src/.cvsignore
new file mode 100644 (file)
index 0000000..a438335
--- /dev/null
@@ -0,0 +1 @@
+*.d
diff --git a/lib/arprefresh/src/olsrd_arprefresh.c b/lib/arprefresh/src/olsrd_arprefresh.c
new file mode 100644 (file)
index 0000000..b233474
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2007, Sven-Ola Tuecke <sven-ola-aet-gmx.de>
+ * Copyright (c) 2004, Andreas Tønnesen(andreto-at-olsr.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
+ *   this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, 
+ *   this list of conditions and the following disclaimer in the documentation 
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the UniK olsr daemon nor the names of its contributors 
+ *   may be used to endorse or promote products derived from this software 
+ *   without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/* $Id: olsrd_arprefresh.c,v 1.1 2007/08/19 20:37:41 bernd67 Exp $ */
+
+/*
+ * Plugin to refresh the local ARP cache from received OLSR broadcasts
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/ethernet.h>
+#include <netinet/ip.h>
+#include <netinet/udp.h>
+#include <netpacket/packet.h>
+#include <linux/types.h>
+#include <linux/filter.h>
+
+#include "olsrd_arprefresh.h"
+#include "kernel_routes.h"
+#include "scheduler.h"
+
+#undef ARPREFRESH_DEBUG
+#define PLUGIN_INTERFACE_VERSION 5
+
+/****************************************************************************
+ *                Functions that the plugin MUST provide                    *
+ ****************************************************************************/
+/**
+ * Plugin interface version
+ * Used by main olsrd to check plugin interface version
+ */
+int olsrd_plugin_interface_version(void)
+{
+       return PLUGIN_INTERFACE_VERSION;
+}
+
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
+{
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
+}
+
+typedef struct
+{
+       struct ethhdr eth;
+       struct iphdr ip;
+       struct udphdr udp;
+} __attribute__((packed)) arprefresh_buf;
+
+static int arprefresh_sockfd = -1;
+static const int arprefresh_portnum = 698;
+
+/**
+ * Scheduled event to fetch gathered packets and update the ARP cache
+ * called from olsrd main thread
+ */
+static void olsr_arp_event(void* foo __attribute__((unused)))
+{
+       if (0 <= arprefresh_sockfd)
+       {
+               arprefresh_buf buf;
+               struct sockaddr_ll from;
+               socklen_t fromlen = sizeof(from);
+               
+               /*
+                * Grab a single snapshot on the packet socket. This only works
+                * if not too much IP traffic is currently flowing through.
+                */
+               ssize_t size = recvfrom(arprefresh_sockfd, &buf, sizeof(buf),
+                       MSG_TRUNC, (struct sockaddr *)&from, &fromlen);
+
+               if (0 <= size &&
+                   size >= (ssize_t)sizeof(buf) /*** &&
+                   ETH_P_IP == ntohs(buf.eth.h_proto) &&
+                   IPPROTO_UDP == buf.ip.protocol &&
+                   arprefresh_portnum == ntohs(buf.udp.source) &&
+                   arprefresh_portnum == ntohs(buf.udp.dest) ***/)
+               {
+                       union
+                       {
+                               struct arpreq arp;
+                               struct sockaddr_in in_pa;
+                               struct sockaddr_in6 in_pa6;
+                       } req;
+
+                       memset(&req, 0, sizeof(req));
+                       req.in_pa.sin_family = AF_INET;
+                       memcpy(&req.in_pa.sin_addr, &buf.ip.saddr, sizeof(buf.ip.saddr));
+                       req.arp.arp_ha.sa_family = AF_LOCAL;
+                       memcpy(&req.arp.arp_ha.sa_data, &buf.eth.h_source, sizeof(buf.eth.h_source));
+                       req.arp.arp_flags = ATF_COM;
+                       if_indextoname(from.sll_ifindex, req.arp.arp_dev);
+#ifdef ARPREFRESH_DEBUG
+                       {
+                               int i;
+                               OLSR_PRINTF(0, "Refresh on %s, %s=", req.arp.arp_dev,
+                                       inet_ntoa(*((struct in_addr*)&buf.ip.saddr)));
+                               for(i = 0; i < (ssize_t)sizeof(buf.eth.h_source); i++)
+                               {
+                                       OLSR_PRINTF(0, "%02x%s", ((unsigned char *)&buf.eth.h_source)[i], i < (ssize_t)sizeof(buf.eth.h_source) -1 ? ":" : "\n");
+                               }
+                       }
+#endif
+                       if (ioctl(arprefresh_sockfd, SIOCSARP, &req) < 0) {
+                               OLSR_PRINTF(1, "*** ARPREFRESH: SIOCSARP: %s\n", strerror(errno));
+                               close(arprefresh_sockfd);
+                               arprefresh_sockfd = -1;
+                               return;
+                       }
+               }
+       }
+}
+
+/**
+ * Initialize plugin
+ * Called after all parameters are passed
+ */
+int olsrd_plugin_init(void)
+{
+       int ret = 0;
+       if (AF_INET == olsr_cnf->ip_version)
+       {
+               int flags;
+               struct sock_fprog filter;
+               struct sock_filter BPF_code[]=
+               {
+                       /* tcpdump -s [sizeof(arprefresh_buf)] -ni lo udp and dst port [arprefresh_portnum] -dd */
+                       { 0x28, 0, 0, 0x0000000c },
+                       { 0x15, 0, 4, 0x000086dd },
+                       { 0x30, 0, 0, 0x00000014 },
+                       { 0x15, 0, 11, 0x00000011 },
+                       { 0x28, 0, 0, 0x00000038 },
+                       { 0x15, 8, 9, arprefresh_portnum },
+                       { 0x15, 0, 8, 0x00000800 },
+                       { 0x30, 0, 0, 0x00000017 },
+                       { 0x15, 0, 6, 0x00000011 },
+                       { 0x28, 0, 0, 0x00000014 },
+                       { 0x45, 4, 0, 0x00001fff },
+                       { 0xb1, 0, 0, 0x0000000e },
+                       { 0x48, 0, 0, 0x00000010 },
+                       { 0x15, 0, 1, arprefresh_portnum },
+                       { 0x6, 0, 0, sizeof(arprefresh_buf) },
+                       { 0x6, 0, 0, 0x00000000 }
+               };
+               filter.len = sizeof(BPF_code) / sizeof(BPF_code[0]);
+               filter.filter = BPF_code;
+               if (0 <= (arprefresh_sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP))) &&
+                   0 <= (flags = fcntl(arprefresh_sockfd, F_GETFL)) &&
+                   0 <= fcntl(arprefresh_sockfd, F_SETFL, flags | O_NONBLOCK) &&
+                   0 <= setsockopt(arprefresh_sockfd, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
+               {
+                       /* Register the ARP refresh event */
+                       olsr_register_scheduler_event(&olsr_arp_event, NULL, 2, 0, NULL);
+                       ret = 1;
+               }
+               else
+               {
+                       OLSR_PRINTF(1, "*** ARPREFRESH: Cannot create non-blocking filtering packet socket: %s\n", strerror(errno));
+               }
+       }
+       else
+       {
+               OLSR_PRINTF(1, "*** ARPREFRESH: IPv6 not supported\n");
+       }
+       return ret;
+}
+
+/****************************************************************************
+ *       Optional private constructor and destructor functions              *
+ ****************************************************************************/
+
+static void __attribute__ ((constructor)) my_init(void);
+static void __attribute__ ((destructor)) my_fini(void);
+
+static void my_init(void)
+{
+       printf("OLSRD arprefresh plugin by Sven-Ola\n");
+}
+
+/**
+ * Optional Private Destructor
+ */
+static void my_fini(void)
+{
+       if (0 <= arprefresh_sockfd)
+       {
+               close(arprefresh_sockfd);
+               arprefresh_sockfd = -1;
+       }
+}
diff --git a/lib/arprefresh/src/olsrd_arprefresh.h b/lib/arprefresh/src/olsrd_arprefresh.h
new file mode 100644 (file)
index 0000000..916bb8e
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, Sven-Ola Tuecke <sven-ola-aet-gmx.de>
+ * Copyright (c) 2004, Andreas Tønnesen(andreto-at-olsr.org)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, 
+ *   this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, 
+ *   this list of conditions and the following disclaimer in the documentation 
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the UniK olsr daemon nor the names of its contributors 
+ *   may be used to endorse or promote products derived from this software 
+ *   without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/* $Id: olsrd_arprefresh.h,v 1.1 2007/08/19 20:37:41 bernd67 Exp $ */
+
+#ifndef _OLSRD_ARPREFRESH
+#define _OLSRD_ARPREFRESH
+
+#include "olsr_types.h"
+#include "olsrd_plugin.h"
+#include "plugin_util.h"
+
+int olsrd_plugin_init(void);
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size);
+int olsrd_plugin_interface_version(void);
+
+#endif
diff --git a/lib/arprefresh/version-script.txt b/lib/arprefresh/version-script.txt
new file mode 100644 (file)
index 0000000..3d09da3
--- /dev/null
@@ -0,0 +1,10 @@
+VERS_1.0
+{
+  global:
+    olsrd_plugin_interface_version;
+    olsrd_plugin_register_param;
+    olsrd_plugin_init;
+
+  local:
+    *;
+};
index 2816f7f..21364be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * The olsr.org Optimized Link-State Routing daemon(olsrd)
+ * Copyright (c) 2006, Sven-Ola Tuecke <sven-ola-aet-gmx.de>
  * Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org)
  * All rights reserved.
  *
@@ -51,7 +51,7 @@
 
 #define DEBUGLEV 1
 
-#define PLUGIN_INTERFACE_VERSION 4
+#define PLUGIN_INTERFACE_VERSION 5
 
 static int has_inet_gateway;
 
@@ -65,14 +65,13 @@ olsrd_plugin_interface_version(void)
   return PLUGIN_INTERFACE_VERSION;
 }
 
-/**
- * Register parameters from config file
- * Called for all plugin parameters
- */
-int
-olsrd_plugin_register_param(char *key __attribute__((unused)), char *value __attribute__((unused)))
+static const struct olsrd_plugin_parameters plugin_parameters[] = {
+};
+
+void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
 {
-  return 1;
+    *params = plugin_parameters;
+    *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
 }
 
 /**
@@ -82,6 +81,8 @@ olsrd_plugin_register_param(char *key __attribute__((unused)), char *value __att
 int
 olsrd_plugin_init(void)
 {
+  printf("OLSRD dyn_gw_plain plugin by Sven-Ola\n");
+  
   gw_net.v4 = INET_NET;
   gw_netmask.v4 = INET_PREFIX;
 
index 88a4fc5..bdf4003 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: link_set.c,v 1.69 2007/08/02 22:07:19 bernd67 Exp $
+ * $Id: link_set.c,v 1.70 2007/08/19 20:37:41 bernd67 Exp $
  */
 
 
@@ -794,23 +794,29 @@ replace_neighbor_link_set(struct neighbor_entry *old,
 static int
 check_link_status(struct hello_message *message, struct interface *in_if)
 {
+  int ret = UNSPEC_LINK;
   struct hello_neighbor  *neighbors;
 
   neighbors = message->neighbors;
   
   while(neighbors!=NULL)
     {
+      /*
+       * Note: If a neigh has 2 cards we can reach, the neigh
+       * will send a Hello with the same IP mentined twice
+       */
       if(COMP_IP(&neighbors->address, &in_if->ip_addr))
         {
          //printf("ok");
-         return neighbors->link;
+         ret = neighbors->link;
+         if (SYM_LINK == ret) break;
        }
 
       neighbors = neighbors->next; 
     }
 
 
-  return UNSPEC_LINK;
+  return ret;
 }
 
 
index f466162..ed22508 100644 (file)
@@ -38,7 +38,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: lq_packet.c,v 1.24 2007/08/02 22:07:19 bernd67 Exp $
+ * $Id: lq_packet.c,v 1.25 2007/08/19 20:37:41 bernd67 Exp $
  */
 
 #include "olsr_protocol.h"
@@ -311,7 +311,7 @@ serialize_lq_hello(struct lq_hello_message *lq_hello, struct interface *outif)
   struct lq_hello_neighbor *neigh;
   unsigned char *buff;
   int is_first;
-  int i, j;
+  int i;
 
   if (lq_hello == NULL || outif == NULL)
     return;
@@ -360,18 +360,17 @@ serialize_lq_hello(struct lq_hello_message *lq_hello, struct interface *outif)
 
   for (i = 0; i <= MAX_NEIGH; i++) 
     {
-      for(j = 0; j <= MAX_LINK; j++)
+      static const int LINK_ORDER[] = {SYM_LINK, UNSPEC_LINK, ASYM_LINK, LOST_LINK};
+      unsigned int j;
+      for(j = 0; j < sizeof(LINK_ORDER) / sizeof(LINK_ORDER[0]); j++)
         {
-          if(j == HIDE_LINK)
-            continue;
-
           is_first = 1;
 
           // loop through neighbors
 
           for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next)
             {  
-              if (neigh->neigh_type != i || neigh->link_type != j)
+              if (neigh->neigh_type != i || neigh->link_type != LINK_ORDER[j])
                 continue;
 
               // we need space for an IP address plus link quality
@@ -426,7 +425,7 @@ serialize_lq_hello(struct lq_hello_message *lq_hello, struct interface *outif)
                   size += sizeof (struct lq_hello_info_header);
 
                   info_head->reserved = 0;
-                  info_head->link_code = CREATE_LINK_CODE(i, j);
+                  info_head->link_code = CREATE_LINK_CODE(i, LINK_ORDER[j]);
                 }
 
               // add the current neighbor's IP address