changeset 15:89fd24932c4d draft

Send hostname/fqdn in DISCOVER and INFORM messages too.
author Roy Marples <roy@marples.name>
date Mon, 04 Dec 2006 21:13:04 +0000
parents 69389473e116
children 3c6d27bf2646
files ChangeLog Makefile arp.c configure.c dhcp.c interface.c logger.c
diffstat 7 files changed, 15 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Dec 04 16:09:18 2006 +0000
+++ b/ChangeLog	Mon Dec 04 21:13:04 2006 +0000
@@ -1,3 +1,4 @@
+Send hostname/fqdn in DISCOVER and INFORM messages too.
 Add more debug messages.
 Fix writing to resolv.conf when resolvconf not present.
 Include linux/if_addr.h for 2.6.19+ kernels, thanks to AlexExtreme.
--- a/Makefile	Mon Dec 04 16:09:18 2006 +0000
+++ b/Makefile	Mon Dec 04 21:13:04 2006 +0000
@@ -1,6 +1,6 @@
 # Should work for both GNU make and BSD mke
 
-VERSION = 3.0.3_pre1
+VERSION = 3.0.3_pre2
 
 INSTALL ?= install
 CFLAGS ?= -Wall -O2 -pedantic -std=gnu99
--- a/arp.c	Mon Dec 04 16:09:18 2006 +0000
+++ b/arp.c	Mon Dec 04 21:13:04 2006 +0000
@@ -70,7 +70,7 @@
   unsigned char buf[256];
   struct arphdr *ah = (struct arphdr *) buf;
 
-  memset (&buf, 0, sizeof (buf));
+  memset (buf, 0, sizeof (buf));
 
   ah->ar_hrd = htons (ARPHRD_ETHER);
   ah->ar_pro = htons (ETHERTYPE_IP);
@@ -118,7 +118,7 @@
 
       while (bufpos != 0)
 	{
-	  memset (&reply, 0, sizeof (reply));
+	  memset (reply, 0, sizeof (reply));
 	  if ((bytes = get_packet (iface, (unsigned char *) &reply, buffer,
 				   &buflen, &bufpos)) < 0)
 	    break;
--- a/configure.c	Mon Dec 04 16:09:18 2006 +0000
+++ b/configure.c	Mon Dec 04 21:13:04 2006 +0000
@@ -356,7 +356,7 @@
   route_t *new_route = NULL;
   route_t *old_route = NULL;
   struct hostent *he = NULL;
-  char *newhostname[HOSTNAME_MAX_LEN] = {0};
+  char newhostname[HOSTNAME_MAX_LEN] = {0};
   char curhostname[HOSTNAME_MAX_LEN] = {0};
   char *dname = NULL;
   int dnamel = 0;
@@ -522,9 +522,9 @@
       || strcmp (curhostname, "localhost") == 0)
     {
       if (dhcp->hostname)
-	strcpy ((char *) newhostname, dhcp->hostname); 
+	strcpy (newhostname, dhcp->hostname); 
 
-      sethostname ((char *) newhostname, strlen ((char *) newhostname));
+      sethostname (newhostname, strlen (newhostname));
       logger (LOG_INFO, "setting hostname to `%s'", newhostname);
     }
 
--- a/dhcp.c	Mon Dec 04 16:09:18 2006 +0000
+++ b/dhcp.c	Mon Dec 04 21:13:04 2006 +0000
@@ -185,10 +185,7 @@
 	}
 
       *n_params = p - n_params - 1;
-    }
 
-  if (type == DHCP_REQUEST)
-    {
       if (options->hostname) 
 	{
 	  if (options->fqdn == FQDN_DISABLE)
@@ -220,7 +217,7 @@
 
   if (type != DHCP_DECLINE && type != DHCP_RELEASE)
     {
-      if (options->userclass)
+      if (options->userclass_len > 0)
 	{
 	  *p++ = DHCP_USERCLASS;
 	  *p++ = options->userclass_len;
--- a/interface.c	Mon Dec 04 16:09:18 2006 +0000
+++ b/interface.c	Mon Dec 04 21:13:04 2006 +0000
@@ -127,7 +127,7 @@
 	  return NULL;
 	}
 
-      memcpy (&hwaddr, sdl->sdl_data + sdl->sdl_nlen, ETHER_ADDR_LEN);
+      memcpy (hwaddr, sdl->sdl_data + sdl->sdl_nlen, ETHER_ADDR_LEN);
       break;
     }
   freeifaddrs (ifap);
@@ -160,7 +160,7 @@
       close (s);
       return NULL;
     }
-  memcpy (&hwaddr, &ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
+  memcpy (hwaddr, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
 #else
   ifr.ifr_metric = metric;
   if (ioctl (s, SIOCSIFMETRIC, &ifr) < 0)
@@ -192,7 +192,7 @@
   memset (iface, 0, sizeof (interface_t));
   strncpy (iface->name, ifname, IF_NAMESIZE);
   snprintf (iface->infofile, PATH_MAX, INFOFILE, ifname);
-  memcpy (&iface->ethernet_address, &hwaddr, ETHER_ADDR_LEN);
+  memcpy (&iface->ethernet_address, hwaddr, ETHER_ADDR_LEN);
 
   iface->arpable = ! (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK));
 
@@ -380,7 +380,7 @@
     }
 
   char buffer[16384];
-  memset (&buffer, 0, sizeof (buffer));
+  memset (buffer, 0, sizeof (buffer));
   iov.iov_base = buffer;
 
   struct nlmsghdr *h;
@@ -542,11 +542,11 @@
   nlm.ifa.ifa_family = AF_INET;
 
   /* Store the netmask in the prefix */
-  uint32_t mask = htonl (netmask.s_addr);
+  uint32_t mask = 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,
--- a/logger.c	Mon Dec 04 16:09:18 2006 +0000
+++ b/logger.c	Mon Dec 04 21:13:04 2006 +0000
@@ -100,7 +100,7 @@
       int len = strlen (logprefix);
       char *fmt2 = xmalloc (strlen (fmt) + len + 1);
       char *p = fmt2;
-      memcpy (p, &logprefix, len);
+      memcpy (p, logprefix, len);
       p += len;
       strcpy (p, fmt);
       vsyslog (level, fmt2, p2);