From: Roy Marples Date: Mon, 4 Dec 2006 21:13:04 +0000 (+0000) Subject: Send hostname/fqdn in DISCOVER and INFORM messages too. X-Git-Tag: v3.2.3~359 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a742ad844faa24ea33b1dc1b132be4ed9701d64;p=thirdparty%2Fdhcpcd.git Send hostname/fqdn in DISCOVER and INFORM messages too. --- diff --git a/ChangeLog b/ChangeLog index 53be0849..c952b2e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/Makefile b/Makefile index da641030..822485d5 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/arp.c b/arp.c index f5c0830b..5afa3aed 100644 --- a/arp.c +++ b/arp.c @@ -70,7 +70,7 @@ int arp_check (interface_t *iface, struct in_addr address) 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 @@ int arp_check (interface_t *iface, struct in_addr address) 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; diff --git a/configure.c b/configure.c index f2fe2233..98a16756 100644 --- a/configure.c +++ b/configure.c @@ -356,7 +356,7 @@ int configure (options_t *options, interface_t *iface, dhcp_t *dhcp) 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 @@ int configure (options_t *options, interface_t *iface, dhcp_t *dhcp) || 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); } diff --git a/dhcp.c b/dhcp.c index 5f85947a..599d8136 100644 --- a/dhcp.c +++ b/dhcp.c @@ -185,10 +185,7 @@ size_t send_message (interface_t *iface, dhcp_t *dhcp, } *n_params = p - n_params - 1; - } - if (type == DHCP_REQUEST) - { if (options->hostname) { if (options->fqdn == FQDN_DISABLE) @@ -220,7 +217,7 @@ size_t send_message (interface_t *iface, dhcp_t *dhcp, if (type != DHCP_DECLINE && type != DHCP_RELEASE) { - if (options->userclass) + if (options->userclass_len > 0) { *p++ = DHCP_USERCLASS; *p++ = options->userclass_len; diff --git a/interface.c b/interface.c index 75b088d2..20aa2278 100644 --- a/interface.c +++ b/interface.c @@ -127,7 +127,7 @@ interface_t *read_interface (const char *ifname, int metric) 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 @@ interface_t *read_interface (const char *ifname, int metric) 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 @@ interface_t *read_interface (const char *ifname, int metric) 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 @@ static int send_netlink(struct nlmsghdr *hdr) } char buffer[16384]; - memset (&buffer, 0, sizeof (buffer)); + memset (buffer, 0, sizeof (buffer)); iov.iov_base = buffer; struct nlmsghdr *h; @@ -542,11 +542,11 @@ static int do_address(const char *ifname, 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, diff --git a/logger.c b/logger.c index aea56fd3..e2760e10 100644 --- a/logger.c +++ b/logger.c @@ -100,7 +100,7 @@ void logger(int level, const char *fmt, ...) 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);