changeset 20:3dfa5666d2a6 draft

Fix netmask thanks to Marc Duponcheel.
author Roy Marples <roy@marples.name>
date Wed, 06 Dec 2006 10:02:03 +0000
parents d1c15501fd5e
children db0dd444d49f
files ChangeLog interface.c
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Dec 06 09:37:15 2006 +0000
+++ b/ChangeLog	Wed Dec 06 10:02:03 2006 +0000
@@ -1,3 +1,4 @@
+Fix netmask thanks to Marc Duponcheel.
 Send the hostname by default unless null, (none) or localhost.
 This can be overridden by using a an empty option for -h (-h '').
 
--- a/interface.c	Wed Dec 06 09:37:15 2006 +0000
+++ b/interface.c	Wed Dec 06 10:02:03 2006 +0000
@@ -542,11 +542,11 @@
   nlm.ifa.ifa_family = AF_INET;
 
   /* Store the netmask in the prefix */
-  uint32_t mask = netmask.s_addr;
+  uint32_t mask = htonl (netmask.s_addr);
   while (mask)
     {
       nlm.ifa.ifa_prefixlen++;
-      mask >>= 1;
+      mask <<= 1;
     }
 
   add_attr_l (&nlm.hdr, sizeof (nlm), IFA_LOCAL, &address.s_addr,
@@ -610,11 +610,11 @@
     }
 
   /* Store the netmask in the prefix */
-  uint32_t mask = netmask.s_addr;
+  uint32_t mask = htonl (netmask.s_addr);
   while (mask)
     {
       nlm.rt.rtm_dst_len++;
-      mask >>= 1;
+      mask <<= 1;
     }
 
   add_attr_l (&nlm.hdr, sizeof (nlm), RTA_DST, &destination.s_addr,