Revision: 534
          http://vde.svn.sourceforge.net/vde/?rev=534&view=rev
Author:   danielel
Date:     2012-01-19 15:56:37 +0000 (Thu, 19 Jan 2012)
Log Message:
-----------
ver router / olsr: Fixed MID message. Still todo: TC + message parsing

Modified Paths:
--------------
    branches/vde-router/vde-2/src/vde_router/vder_olsr.c
    branches/vde-router/vde-2/src/vde_router/vder_olsr.h

Modified: branches/vde-router/vde-2/src/vde_router/vder_olsr.c
===================================================================
--- branches/vde-router/vde-2/src/vde_router/vder_olsr.c        2012-01-19 
06:47:13 UTC (rev 533)
+++ branches/vde-router/vde-2/src/vde_router/vder_olsr.c        2012-01-19 
15:56:37 UTC (rev 534)
@@ -70,7 +70,7 @@
                        e->iface = iface;
                        e->metric = 1;
                        e->next = Routes[1];
-                       Routes[1]->next = e;
+                       Routes[1] = e;
                }
        }
 }
@@ -122,9 +122,10 @@
                                e->iface = icur;
                                e->metric = 0;
                                e->next = Routes[0];
-                               Routes[0]->next = e;
+                               Routes[0] = e;
                        }
                        refresh_neighbors(icur);
+                       addr = addr->next;
                }
        }
 
@@ -151,16 +152,13 @@
 
 static void olsr_make_dgram(struct vder_iface *vif)
 {
-       uint32_t orig, dest;
        uint8_t dgram[2000];
        int size = 0;
        struct vder_ip4address *ep;
-       struct olsr_mid_entry *mlist, *mp;
        struct olsrhdr *ohdr;
        uint32_t netmask, bcast;
        struct olsrmsg *msg_hello, *msg_mid;
        struct olsr_hmsg_hello *hello;
-       struct olsr_hmsg_mid *mid;
 
        struct olsr_link *hlink;
        struct olsr_route_entry *entry;
@@ -230,28 +228,31 @@
        msg_mid->ttl = 0xFF;
        msg_mid->hop = 0;
 
-       mid = (struct olsr_hmsg_mid *)(dgram + size);
-       size += sizeof(struct olsr_hmsg_mid);
        while(entry) {
+               uint32_t mid_address;
                if (entry->iface != vif) {
-                       memcpy(dgram + size, entry->destination, 
sizeof(uint32_t));
+                       mid_address = entry->destination;
+                       memcpy(dgram + size, &mid_address, sizeof(uint32_t));
                        size += sizeof(uint32_t);
                        mid_count++;
                }
                entry = entry->next;
        }
        if (mid_count == 0) {
-               size -= (sizeof(struct olsrmsg) + sizeof(struct olsr_hmsg_mid));
+               size -= (sizeof(struct olsrmsg));
        } else {
-               mid->seq = htons(mid_counter++);
-               msg_mid->size = htons(sizeof(struct olsrmsg) + sizeof(struct 
olsr_hmsg_mid) + sizeof(uint32_t) * mid_count);
+               msg_mid->seq = htons(mid_counter++);
+               msg_mid->size = htons(sizeof(struct olsrmsg) + sizeof(uint32_t) 
* mid_count);
        }
 
        /* TODO: Add TC msg */
 
+
+       /* Finalize olsr packet */
        ohdr->len = htons(size);
        ohdr->seq = htons(pkt_counter++);
 
+       /* Send the thing out */
        if ( 0 > vder_udpsocket_sendto_broadcast(udpsock, dgram, size, vif, 
bcast, OLSR_PORT) ) {
                perror("olsr send");
        }
@@ -264,7 +265,6 @@
                /* Invalid packet size, silently discard */
                return;
        }
-       //printf ("Received olsr msg, size: %d (%d)\n", len, ntohs(oh->len));
        /* TODO: Implement parser. */
 }
 
@@ -301,6 +301,7 @@
                sleep(1);
                gettimeofday(&now, NULL);
                if ((now.tv_sec - last_out.tv_sec) >= (OLSR_MSG_INTERVAL / 
1000)) {
+                       refresh_routes();
                        for (i = 0; i < settings->n_ifaces; i++)
                                olsr_make_dgram(settings->ifaces[i]);
                        last_out = now;

Modified: branches/vde-router/vde-2/src/vde_router/vder_olsr.h
===================================================================
--- branches/vde-router/vde-2/src/vde_router/vder_olsr.h        2012-01-19 
06:47:13 UTC (rev 533)
+++ branches/vde-router/vde-2/src/vde_router/vder_olsr.h        2012-01-19 
15:56:37 UTC (rev 534)
@@ -44,10 +44,6 @@
        uint16_t reserved;
 };
 
-struct __attribute__((packed)) olsr_hmsg_mid
-{
-       uint16_t seq;
-};
 
 struct __attribute__((packed)) olsrmsg
 {
@@ -58,7 +54,6 @@
        uint8_t ttl;
        uint8_t hop;
        uint16_t seq;
-       uint8_t data[0];
 };
 
 struct __attribute__((packed)) olsrhdr

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to