--- udhcp-0.9.8cvs20050303.orig/samples/sample.script +++ udhcp-0.9.8cvs20050303/samples/sample.script @@ -4,4 +4,4 @@ # common initialization first, especially if more dhcp event notifications # are added. -exec /usr/share/udhcpc/sample.$1 +exec /etc/udhcpc/default.$1 --- udhcp-0.9.8cvs20050303.orig/samples/sample.renew +++ udhcp-0.9.8cvs20050303/samples/sample.renew @@ -1,13 +1,25 @@ #!/bin/sh -# Sample udhcpc bound script +# Sample udhcpc bound/renew script -RESOLV_CONF="/etc/udhcpc/resolv.conf" +# Uncomment this to allow dhcpcd to set hostname of the host to the +# hostname option supplied by DHCP server. +#SET_HOSTNAME='yes' + +RESOLV_CONF="/etc/resolv.conf" [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" [ -n "$subnet" ] && NETMASK="netmask $subnet" /sbin/ifconfig $interface $ip $BROADCAST $NETMASK +if [ -n "$hostname" -a -n "$SET_HOSTNAME" ] +then + local current_hostname=$(hostname) + if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then + hostname "$hostname" + fi +fi + if [ -n "$router" ] then echo "deleting routers" @@ -21,10 +33,20 @@ done fi -echo -n > $RESOLV_CONF -[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF +# Update resolver configuration file +R="" +[ -n "$domain" ] && R="domain $domain +" for i in $dns do echo adding dns $i - echo nameserver $i >> $RESOLV_CONF -done \ No newline at end of file + R="${R}nameserver $i +" +done + +if [ -x /sbin/resolvconf ] ; then + echo -n "$R" | resolvconf -a "${interface}.udhcpc" +else + echo -n "$R" > "$RESOLV_CONF" +fi + --- udhcp-0.9.8cvs20050303.orig/samples/sample.bound +++ udhcp-0.9.8cvs20050303/samples/sample.bound @@ -1,18 +1,31 @@ #!/bin/sh -# Sample udhcpc renew script +# Sample udhcpc bound/renew script -RESOLV_CONF="/etc/udhcpc/resolv.conf" +# Uncomment this to allow dhcpcd to set hostname of the host to the +# hostname option supplied by DHCP server. +#SET_HOSTNAME='yes' + +RESOLV_CONF="/etc/resolv.conf" [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" [ -n "$subnet" ] && NETMASK="netmask $subnet" /sbin/ifconfig $interface $ip $BROADCAST $NETMASK +if [ -n "$hostname" -a -n "$SET_HOSTNAME" ] +then + local current_hostname=$(hostname) + if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then + hostname "$hostname" + fi +fi + if [ -n "$router" ] then - echo "deleting routers" - while /sbin/route del default gw 0.0.0.0 dev $interface - do : + echo "Resetting default routes" + for i in `/sbin/route -n | grep ^default.*$interface` + do + route del default gw 0.0.0.0 dev $interface done for i in $router @@ -21,10 +34,20 @@ done fi -echo -n > $RESOLV_CONF -[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF +# Update resolver configuration file +R="" +[ -n "$domain" ] && R="domain $domain +" for i in $dns do echo adding dns $i - echo nameserver $i >> $RESOLV_CONF -done \ No newline at end of file + R="${R}nameserver $i +" +done + +if [ -x /sbin/resolvconf ] ; then + echo -n "$R" | resolvconf -a "${interface}.udhcpc" +else + echo -n "$R" > "$RESOLV_CONF" +fi + --- udhcp-0.9.8cvs20050303.orig/samples/udhcpd.conf +++ udhcp-0.9.8cvs20050303/samples/udhcpd.conf @@ -114,3 +114,4 @@ #opt ntpsrv #opt tftp #opt bootfile +#opt wpad --- udhcp-0.9.8cvs20050303.orig/samples/sample.deconfig +++ udhcp-0.9.8cvs20050303/samples/sample.deconfig @@ -1,4 +1,7 @@ #!/bin/sh # Sample udhcpc deconfig script +if [ -x /sbin/resolvconf ] ; then + resolvconf -d "${interface}.udhcpc" +fi /sbin/ifconfig $interface 0.0.0.0 --- udhcp-0.9.8cvs20050303.orig/samples/udhcpd.conf~ +++ udhcp-0.9.8cvs20050303/samples/udhcpd.conf~ @@ -0,0 +1,116 @@ +# Sample udhcpd configuration file (/etc/udhcpd.conf) + +# The start and end of the IP lease block + +start 192.168.0.20 #default: 192.168.0.20 +end 192.168.0.254 #default: 192.168.0.254 + + +# The interface that udhcpd will use + +interface eth0 #default: eth0 + + +# The maximim number of leases (includes addressesd reserved +# by OFFER's, DECLINE's, and ARP conficts + +#max_leases 254 #default: 254 + + +# If remaining is true (default), udhcpd will store the time +# remaining for each lease in the udhcpd leases file. This is +# for embedded systems that cannot keep time between reboots. +# If you set remaining to no, the absolute time that the lease +# expires at will be stored in the dhcpd.leases file. + +#remaining yes #default: yes + + +# The time period at which udhcpd will write out a dhcpd.leases +# file. If this is 0, udhcpd will never automatically write a +# lease file. (specified in seconds) + +#auto_time 7200 #default: 7200 (2 hours) + + +# The amount of time that an IP will be reserved (leased) for if a +# DHCP decline message is received (seconds). + +#decline_time 3600 #default: 3600 (1 hour) + + +# The amount of time that an IP will be reserved (leased) for if an +# ARP conflct occurs. (seconds + +#conflict_time 3600 #default: 3600 (1 hour) + + +# How long an offered address is reserved (leased) in seconds + +#offer_time 60 #default: 60 (1 minute) + +# If a lease to be given is below this value, the full lease time is +# instead used (seconds). + +#min_lease 60 #defult: 60 + + +# The location of the leases file + +#lease_file /var/lib/misc/udhcpd.leases #defualt: /var/lib/misc/udhcpd.leases + +# The location of the pid file +#pidfile /var/run/udhcpd.pid #default: /var/run/udhcpd.pid + +# Everytime udhcpd writes a leases file, the below script will be called. +# Useful for writing the lease file to flash every few hours. + +#notify_file #default: (no script) + +#notify_file dumpleases # <--- usefull for debugging + +# The following are bootp specific options, setable by udhcpd. + +#siaddr 192.168.0.22 #default: 0.0.0.0 + +#sname zorak #default: (none) + +#boot_file /var/nfs_root #default: (none) + +# The remainer of options are DHCP options and can be specifed with the +# keyword 'opt' or 'option'. If an option can take multiple items, such +# as the dns option, they can be listed on the same line, or multiple +# lines. The only option with a default is 'lease'. + +#Examles +opt dns 192.168.10.2 192.168.10.10 +option subnet 255.255.255.0 +opt router 192.168.10.2 +opt wins 192.168.10.10 +option dns 129.219.13.81 # appened to above DNS servers for a total of 3 +option domain local +option lease 864000 # 10 days of seconds + + +# Currently supported options, for more info, see options.c +#opt subnet +#opt timezone +#opt router +#opt timesvr +#opt namesvr +#opt dns +#opt logsvr +#opt cookiesvr +#opt lprsvr +#opt bootsize +#opt domain +#opt swapsvr +#opt rootpath +#opt ipttl +#opt mtu +#opt broadcast +#opt wins +#opt lease +#opt ntpsrv +#opt tftp +#opt bootfile --- udhcp-0.9.8cvs20050303.orig/samples/sample.leasefail +++ udhcp-0.9.8cvs20050303/samples/sample.leasefail @@ -0,0 +1,4 @@ +#!/bin/sh +# Sample udhcpc leasefail script + +echo Lease failed: $message --- udhcp-0.9.8cvs20050303.orig/samples/sample.bound~ +++ udhcp-0.9.8cvs20050303/samples/sample.bound~ @@ -0,0 +1,52 @@ +#!/bin/sh +# Sample udhcpc bound/renew script + +# Uncomment this to allow dhcpcd to set hostname of the host to the +# hostname option supplied by DHCP server. +#SET_HOSTNAME='yes' + +RESOLV_CONF="/etc/resolv.conf" + +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +/sbin/ifconfig $interface $ip $BROADCAST $NETMASK + +if [ -n "$hostname" -a -n "$SET_HOSTNAME" ] +then + local current_hostname=$(hostname) + if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then + hostname "$hostname" + fi +fi + +if [ -n "$router" ] +then + echo "deleting routers" + while /sbin/route del default gw 0.0.0.0 dev $interface + do : + done + + for i in $router + do + /sbin/route add default gw $i dev $interface + done +fi + +# Update resolver configuration file +R="" +[ -n "$domain" ] && R="domain $domain +" +for i in $dns +do + echo adding dns $i + R="${R}nameserver $i +" +done + +if [ -x /sbin/resolvconf ] ; then + echo -n "$R" | resolvconf -a "${interface}.udhcpc" +else + echo -n "$R" > "$RESOLV_CONF" +fi + --- udhcp-0.9.8cvs20050303.orig/samples/sample.deconfig~ +++ udhcp-0.9.8cvs20050303/samples/sample.deconfig~ @@ -0,0 +1,8 @@ +#!/bin/sh +# Sample udhcpc deconfig script + +if [ -x /sbin/resolvconf ] ; then + resolvconf -d "${interface}.udhcpc" +else + /sbin/ifconfig $interface 0.0.0.0 +fi --- udhcp-0.9.8cvs20050303.orig/samples/sample.renew~ +++ udhcp-0.9.8cvs20050303/samples/sample.renew~ @@ -0,0 +1,44 @@ +#!/bin/sh +# Sample udhcpc bound script + +RESOLV_CONF="/etc/resolv.conf" + +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +/sbin/ifconfig $interface $ip $BROADCAST $NETMASK + +if [ -n "$router" ] +then + echo "deleting routers" + while /sbin/route del default gw 0.0.0.0 dev $interface + do : + done + + for i in $router + do + /sbin/route add default gw $i dev $interface + done +fi + +if [ -x /sbin/resolvconf ] ; then + R="" + [ -n "$domain" ] && R="domain $domain +" + for i in $dns + do + echo adding dns $i + R="${R}nameserver $i +" + done + echo -n "$R" | resolvconf -a "${interface}.udhcpc" +else + echo -n > $RESOLV_CONF + [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF + for i in $dns + do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF + done +fi + --- udhcp-0.9.8cvs20050303.orig/samples/sample.leasefail~ +++ udhcp-0.9.8cvs20050303/samples/sample.leasefail~ @@ -0,0 +1,4 @@ +#!/bin/sh +# Sample udhcpc leasefailed script + +echo Lease failed: $message --- udhcp-0.9.8cvs20050303.orig/arpping.c +++ udhcp-0.9.8cvs20050303/arpping.c @@ -73,7 +73,9 @@ memcpy(arp.tInaddr, &yiaddr, sizeof(yiaddr)); /* target IP address */ memset(&addr, 0, sizeof(addr)); - strcpy(addr.sa_data, interface); + //closes http://bugs.debian.org/283582 + //strcpy(addr.sa_data, interface); + strncpy(addr.sa_data, interface, sizeof(addr.sa_data)-1); if (sendto(s, &arp, sizeof(arp), 0, &addr, sizeof(addr)) < 0) rv = 0; --- udhcp-0.9.8cvs20050303.orig/packet.c +++ udhcp-0.9.8cvs20050303/packet.c @@ -178,7 +178,10 @@ return -1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) + { + close(fd); return -1; + } memset(&client, 0, sizeof(client)); client.sin_family = AF_INET; @@ -186,7 +189,10 @@ client.sin_addr.s_addr = source_ip; if (bind(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) + { + close(fd); return -1; + } memset(&client, 0, sizeof(client)); client.sin_family = AF_INET; @@ -194,7 +200,10 @@ client.sin_addr.s_addr = dest_ip; if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) + { + close(fd); return -1; + } result = write(fd, payload, sizeof(struct dhcpMessage)); close(fd); --- udhcp-0.9.8cvs20050303.orig/dhcpd.c +++ udhcp-0.9.8cvs20050303/dhcpd.c @@ -88,7 +88,9 @@ else server_config.lease = LEASE_TIME; /* Sanity check */ - num_ips = ntohl(server_config.end) - ntohl(server_config.start); + // Let's try to fix http://bugs.debian.org/341139 (ericvb@debian.org - 16/12/05) + //num_ips = ntohl(server_config.end) - ntohl(server_config.start); + num_ips = ntohl(server_config.end) - ntohl(server_config.start) + 1; if (server_config.max_leases > num_ips) { LOG(LOG_ERR, "max_leases value (%lu) not sane, " "setting to %lu instead", --- udhcp-0.9.8cvs20050303.orig/dhcpc.h +++ udhcp-0.9.8cvs20050303/dhcpc.h @@ -2,7 +2,7 @@ #ifndef _DHCPC_H #define _DHCPC_H -#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script" +#define DEFAULT_SCRIPT "/etc/udhcpc/default.script" /* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */ #include "libbb_udhcp.h" --- udhcp-0.9.8cvs20050303.orig/Makefile +++ udhcp-0.9.8cvs20050303/Makefile @@ -9,13 +9,13 @@ # Uncomment this to get a shared binary. Call as udhcpd for the server, # and udhcpc for the client -COMBINED_BINARY=1 +#COMBINED_BINARY=1 # Uncomment this for extra output and to compile with debugging symbols #UDHCP_DEBUG=1 # Uncomment this to output messages to syslog, otherwise, messages go to stdout -#CFLAGS += -DUDHCP_SYSLOG +CFLAGS += -DUDHCP_SYSLOG #CROSS_COMPILE=arm-uclibc- CC = $(CROSS_COMPILE)gcc --- udhcp-0.9.8cvs20050303.orig/udhcpd.conf.5 +++ udhcp-0.9.8cvs20050303/udhcpd.conf.5 @@ -153,6 +153,8 @@ .TP .BI tftp\ FILE .TP +.BI wpad\ URL +.TP .BI bootfile\ FILE The default for .B lease --- udhcp-0.9.8cvs20050303.orig/README.udhcpc +++ udhcp-0.9.8cvs20050303/README.udhcpc @@ -24,7 +24,7 @@ -q, --quit Quit after obtaining lease -r, --request=IP IP address to request (default: none) -s, --script=file Run file at dhcp events (default: - /usr/share/udhcpc/default.script) + /etc/udhcpc/default.script) -v, --version Display version @@ -38,7 +38,7 @@ When an event occurs, udhcpc calls the action script. udhcpc never does any configuration of the network interface itself, but instead relies on a set of scripts. The script by default is -/usr/share/udhcpc/default.script but this can be changed via the command +/etc/udhcpc/default.script but this can be changed via the command line arguments. The three possible arguments to the script are: deconfig: This argument is used when udhcpc starts, and --- udhcp-0.9.8cvs20050303.orig/socket.c +++ udhcp-0.9.8cvs20050303/socket.c @@ -53,7 +53,9 @@ memset(&ifr, 0, sizeof(struct ifreq)); if((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) >= 0) { ifr.ifr_addr.sa_family = AF_INET; - strcpy(ifr.ifr_name, interface); + //closes http://bugs.debian.org/283582 + //strcpy(ifr.ifr_name, interface); + strncpy(ifr.ifr_name, interface, IFNAMSIZ-1); if (addr) { if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { @@ -62,6 +64,7 @@ DEBUG(LOG_INFO, "%s (our ip) = %s", ifr.ifr_name, inet_ntoa(our_ip->sin_addr)); } else { LOG(LOG_ERR, "SIOCGIFADDR failed, is the interface up and configured?: %m"); + close(fd); return -1; } } @@ -71,6 +74,7 @@ *ifindex = ifr.ifr_ifindex; } else { LOG(LOG_ERR, "SIOCGIFINDEX failed!: %m"); + close(fd); return -1; } if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) { @@ -79,6 +83,7 @@ arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]); } else { LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %m"); + close(fd); return -1; } } else { --- udhcp-0.9.8cvs20050303.orig/options.c +++ udhcp-0.9.8cvs20050303/options.c @@ -28,7 +28,10 @@ {"bootsize", OPTION_U16, 0x0d}, {"domain", OPTION_STRING | OPTION_REQ, 0x0f}, {"swapsvr", OPTION_IP, 0x10}, - {"rootpath", OPTION_STRING, 0x11}, + //We had the possibility for the client to ask for a rootpath + //closes http://bugs.debian.org/279110 (ericvb@debian.org) + //{"rootpath", OPTION_STRING, 0x11}, + {"rootpath", OPTION_STRING | OPTION_REQ, 0x11}, {"ipttl", OPTION_U8, 0x17}, {"mtu", OPTION_U16, 0x1a}, {"broadcast", OPTION_IP | OPTION_REQ, 0x1c}, @@ -43,6 +46,7 @@ {"message", OPTION_STRING, 0x38}, {"tftp", OPTION_STRING, 0x42}, {"bootfile", OPTION_STRING, 0x43}, + {"wpad", OPTION_STRING, 0xfc}, {"", 0x00, 0x00} }; --- udhcp-0.9.8cvs20050303.orig/udhcpc.8 +++ udhcp-0.9.8cvs20050303/udhcpc.8 @@ -190,7 +190,7 @@ The bootfile name. .SH FILES .TP -.I /usr/share/udhcpc/default.script +.I /etc/udhcpc/default.script Script run when leases are obtained or lost. .SH NOTES .B udhcpc --- udhcp-0.9.8cvs20050303.orig/packet.c~ +++ udhcp-0.9.8cvs20050303/packet.c~ @@ -0,0 +1,202 @@ +#include +#include +#include +#include +#include +#include +#if __GLIBC__ >=2 && __GLIBC_MINOR >= 1 +#include +#include +#else +#include +#include +#include +#endif +#include + +#include "packet.h" +#include "dhcpd.h" +#include "options.h" +#include "common.h" + + +void init_header(struct dhcpMessage *packet, char type) +{ + memset(packet, 0, sizeof(struct dhcpMessage)); + switch (type) { + case DHCPDISCOVER: + case DHCPREQUEST: + case DHCPRELEASE: + case DHCPINFORM: + packet->op = BOOTREQUEST; + break; + case DHCPOFFER: + case DHCPACK: + case DHCPNAK: + packet->op = BOOTREPLY; + } + packet->htype = ETH_10MB; + packet->hlen = ETH_10MB_LEN; + packet->cookie = htonl(DHCP_MAGIC); + packet->options[0] = DHCP_END; + add_simple_option(packet->options, DHCP_MESSAGE_TYPE, type); +} + + +/* read a packet from socket fd, return -1 on read error, -2 on packet error */ +int get_packet(struct dhcpMessage *packet, int fd) +{ + int bytes; + int i; + const char broken_vendors[][8] = { + "MSFT 98", + "" + }; + char unsigned *vendor; + + memset(packet, 0, sizeof(struct dhcpMessage)); + bytes = read(fd, packet, sizeof(struct dhcpMessage)); + if (bytes < 0) { + DEBUG(LOG_INFO, "couldn't read on listening socket, ignoring"); + return -1; + } + + if (ntohl(packet->cookie) != DHCP_MAGIC) { + LOG(LOG_ERR, "received bogus message, ignoring"); + return -2; + } + DEBUG(LOG_INFO, "Received a packet"); + + if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { + for (i = 0; broken_vendors[i][0]; i++) { + if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && + !strncmp(vendor, broken_vendors[i], vendor[OPT_LEN - 2])) { + DEBUG(LOG_INFO, "broken client (%s), forcing broadcast", + broken_vendors[i]); + packet->flags |= htons(BROADCAST_FLAG); + } + } + } + + + return bytes; +} + + +uint16_t checksum(void *addr, int count) +{ + /* Compute Internet Checksum for "count" bytes + * beginning at location "addr". + */ + register int32_t sum = 0; + uint16_t *source = (uint16_t *) addr; + + while (count > 1) { + /* This is the inner loop */ + sum += *source++; + count -= 2; + } + + /* Add left-over byte, if any */ + if (count > 0) { + /* Make sure that the left-over byte is added correctly both + * with little and big endian hosts */ + uint16_t tmp = 0; + *(uint8_t *) (&tmp) = * (uint8_t *) source; + sum += tmp; + } + /* Fold 32-bit sum to 16 bits */ + while (sum >> 16) + sum = (sum & 0xffff) + (sum >> 16); + + return ~sum; +} + + +/* Construct a ip/udp header for a packet, and specify the source and dest hardware address */ +int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, + uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex) +{ + int fd; + int result; + struct sockaddr_ll dest; + struct udp_dhcp_packet packet; + + if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { + DEBUG(LOG_ERR, "socket call failed: %m"); + return -1; + } + + memset(&dest, 0, sizeof(dest)); + memset(&packet, 0, sizeof(packet)); + + dest.sll_family = AF_PACKET; + dest.sll_protocol = htons(ETH_P_IP); + dest.sll_ifindex = ifindex; + dest.sll_halen = 6; + memcpy(dest.sll_addr, dest_arp, 6); + if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) { + DEBUG(LOG_ERR, "bind call failed: %m"); + close(fd); + return -1; + } + + packet.ip.protocol = IPPROTO_UDP; + packet.ip.saddr = source_ip; + packet.ip.daddr = dest_ip; + packet.udp.source = htons(source_port); + packet.udp.dest = htons(dest_port); + packet.udp.len = htons(sizeof(packet.udp) + sizeof(struct dhcpMessage)); /* cheat on the psuedo-header */ + packet.ip.tot_len = packet.udp.len; + memcpy(&(packet.data), payload, sizeof(struct dhcpMessage)); + packet.udp.check = checksum(&packet, sizeof(struct udp_dhcp_packet)); + + packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet)); + packet.ip.ihl = sizeof(packet.ip) >> 2; + packet.ip.version = IPVERSION; + packet.ip.ttl = IPDEFTTL; + packet.ip.check = checksum(&(packet.ip), sizeof(packet.ip)); + + result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest)); + if (result <= 0) { + DEBUG(LOG_ERR, "write on socket failed: %m"); + } + close(fd); + return result; +} + + +/* Let the kernel do all the work for packet generation */ +int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, + uint32_t dest_ip, int dest_port) +{ + int n = 1; + int fd, result; + struct sockaddr_in client; + + if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) + return -1; + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) + return -1; + + memset(&client, 0, sizeof(client)); + client.sin_family = AF_INET; + client.sin_port = htons(source_port); + client.sin_addr.s_addr = source_ip; + + if (bind(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) + return -1; + + memset(&client, 0, sizeof(client)); + client.sin_family = AF_INET; + client.sin_port = htons(dest_port); + client.sin_addr.s_addr = dest_ip; + + if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) + return -1; + + result = write(fd, payload, sizeof(struct dhcpMessage)); + close(fd); + return result; +} --- udhcp-0.9.8cvs20050303.orig/options.c~ +++ udhcp-0.9.8cvs20050303/options.c~ @@ -0,0 +1,234 @@ +/* + * options.c -- DHCP server option packet tools + * Rewrite by Russ Dill July 2001 + */ + +#include +#include + +#include "dhcpd.h" +#include "files.h" +#include "options.h" +#include "common.h" + + +/* supported options are easily added here */ +struct dhcp_option dhcp_options[] = { + /* name[10] flags code */ + {"subnet", OPTION_IP | OPTION_REQ, 0x01}, + {"timezone", OPTION_S32, 0x02}, + {"router", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03}, + {"timesvr", OPTION_IP | OPTION_LIST, 0x04}, + {"namesvr", OPTION_IP | OPTION_LIST, 0x05}, + {"dns", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06}, + {"logsvr", OPTION_IP | OPTION_LIST, 0x07}, + {"cookiesvr", OPTION_IP | OPTION_LIST, 0x08}, + {"lprsvr", OPTION_IP | OPTION_LIST, 0x09}, + {"hostname", OPTION_STRING | OPTION_REQ, 0x0c}, + {"bootsize", OPTION_U16, 0x0d}, + {"domain", OPTION_STRING | OPTION_REQ, 0x0f}, + {"swapsvr", OPTION_IP, 0x10}, + //We had the possibility for the client to ask for a rootpath + //closes http://bugs.debian.org/279110 (ericvb@debian.org + //{"rootpath", OPTION_STRING, 0x11}, + {"rootpath", OPTION_STRING | OPTION_REQ, 0x11}, + {"ipttl", OPTION_U8, 0x17}, + {"mtu", OPTION_U16, 0x1a}, + {"broadcast", OPTION_IP | OPTION_REQ, 0x1c}, + {"nisdomain", OPTION_STRING | OPTION_REQ, 0x28}, + {"nissrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x29}, + {"ntpsrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a}, + {"wins", OPTION_IP | OPTION_LIST, 0x2c}, + {"requestip", OPTION_IP, 0x32}, + {"lease", OPTION_U32, 0x33}, + {"dhcptype", OPTION_U8, 0x35}, + {"serverid", OPTION_IP, 0x36}, + {"message", OPTION_STRING, 0x38}, + {"tftp", OPTION_STRING, 0x42}, + {"bootfile", OPTION_STRING, 0x43}, + {"wpad", OPTION_STRING, 0xfc}, + {"", 0x00, 0x00} +}; + +/* Lengths of the different option types */ +int option_lengths[] = { + [OPTION_IP] = 4, + [OPTION_IP_PAIR] = 8, + [OPTION_BOOLEAN] = 1, + [OPTION_STRING] = 1, + [OPTION_U8] = 1, + [OPTION_U16] = 2, + [OPTION_S16] = 2, + [OPTION_U32] = 4, + [OPTION_S32] = 4 +}; + + +/* get an option with bounds checking (warning, not aligned). */ +uint8_t *get_option(struct dhcpMessage *packet, int code) +{ + int i, length; + uint8_t *optionptr; + int over = 0, done = 0, curr = OPTION_FIELD; + + optionptr = packet->options; + i = 0; + length = 308; + while (!done) { + if (i >= length) { + LOG(LOG_WARNING, "bogus packet, option fields too long."); + return NULL; + } + if (optionptr[i + OPT_CODE] == code) { + if (i + 1 + optionptr[i + OPT_LEN] >= length) { + LOG(LOG_WARNING, "bogus packet, option fields too long."); + return NULL; + } + return optionptr + i + 2; + } + switch (optionptr[i + OPT_CODE]) { + case DHCP_PADDING: + i++; + break; + case DHCP_OPTION_OVER: + if (i + 1 + optionptr[i + OPT_LEN] >= length) { + LOG(LOG_WARNING, "bogus packet, option fields too long."); + return NULL; + } + over = optionptr[i + 3]; + i += optionptr[OPT_LEN] + 2; + break; + case DHCP_END: + if (curr == OPTION_FIELD && over & FILE_FIELD) { + optionptr = packet->file; + i = 0; + length = 128; + curr = FILE_FIELD; + } else if (curr == FILE_FIELD && over & SNAME_FIELD) { + optionptr = packet->sname; + i = 0; + length = 64; + curr = SNAME_FIELD; + } else done = 1; + break; + default: + i += optionptr[OPT_LEN + i] + 2; + } + } + return NULL; +} + + +/* return the position of the 'end' option (no bounds checking) */ +int end_option(uint8_t *optionptr) +{ + int i = 0; + + while (optionptr[i] != DHCP_END) { + if (optionptr[i] == DHCP_PADDING) i++; + else i += optionptr[i + OPT_LEN] + 2; + } + return i; +} + + +/* add an option string to the options (an option string contains an option code, + * length, then data) */ +int add_option_string(uint8_t *optionptr, uint8_t *string) +{ + int end = end_option(optionptr); + + /* end position + string length + option code/length + end option */ + if (end + string[OPT_LEN] + 2 + 1 >= 308) { + LOG(LOG_ERR, "Option 0x%02x did not fit into the packet!", string[OPT_CODE]); + return 0; + } + DEBUG(LOG_INFO, "adding option 0x%02x", string[OPT_CODE]); + memcpy(optionptr + end, string, string[OPT_LEN] + 2); + optionptr[end + string[OPT_LEN] + 2] = DHCP_END; + return string[OPT_LEN] + 2; +} + + +/* add a one to four byte option to a packet */ +int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) +{ + char length = 0; + int i; + uint8_t option[2 + 4]; + uint8_t *u8; + uint16_t *u16; + uint32_t *u32; + uint32_t aligned; + u8 = (uint8_t *) &aligned; + u16 = (uint16_t *) &aligned; + u32 = &aligned; + + for (i = 0; dhcp_options[i].code; i++) + if (dhcp_options[i].code == code) { + length = option_lengths[dhcp_options[i].flags & TYPE_MASK]; + } + + if (!length) { + DEBUG(LOG_ERR, "Could not add option 0x%02x", code); + return 0; + } + + option[OPT_CODE] = code; + option[OPT_LEN] = length; + + switch (length) { + case 1: *u8 = data; break; + case 2: *u16 = data; break; + case 4: *u32 = data; break; + } + memcpy(option + 2, &aligned, length); + return add_option_string(optionptr, option); +} + + +/* find option 'code' in opt_list */ +struct option_set *find_option(struct option_set *opt_list, char code) +{ + while (opt_list && opt_list->data[OPT_CODE] < code) + opt_list = opt_list->next; + + if (opt_list && opt_list->data[OPT_CODE] == code) return opt_list; + else return NULL; +} + + +/* add an option to the opt_list */ +void attach_option(struct option_set **opt_list, struct dhcp_option *option, char *buffer, int length) +{ + struct option_set *existing, *new, **curr; + + /* add it to an existing option */ + if ((existing = find_option(*opt_list, option->code))) { + DEBUG(LOG_INFO, "Attaching option %s to existing member of list", option->name); + if (option->flags & OPTION_LIST) { + if (existing->data[OPT_LEN] + length <= 255) { + existing->data = realloc(existing->data, + existing->data[OPT_LEN] + length + 2); + memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); + existing->data[OPT_LEN] += length; + } /* else, ignore the data, we could put this in a second option in the future */ + } /* else, ignore the new data */ + } else { + DEBUG(LOG_INFO, "Attaching option %s to list", option->name); + + /* make a new option */ + new = xmalloc(sizeof(struct option_set)); + new->data = xmalloc(length + 2); + new->data[OPT_CODE] = option->code; + new->data[OPT_LEN] = length; + memcpy(new->data + 2, buffer, length); + + curr = opt_list; + while (*curr && (*curr)->data[OPT_CODE] < option->code) + curr = &(*curr)->next; + + new->next = *curr; + *curr = new; + } +} --- udhcp-0.9.8cvs20050303.orig/udhcpd.conf.5~ +++ udhcp-0.9.8cvs20050303/udhcpd.conf.5~ @@ -0,0 +1,164 @@ +.TH UDHCPD.CONF 5 2001-09-26 GNU/Linux "GNU/Linux Administrator's Manual" +.SH NAME +udhcpd.conf \- udhcp server configuration file +.SH DESCRIPTION +The file +.I /etc/udhcpd.conf +contains configuration information specific to the udhcp server. +It should contain one configuration keyword per line, followed by +appropriate configuration information. +.SH OPTIONS +.TP +.BI start\ ADDRESS +The starting address of the IP lease block is +.IR ADDRESS . +The default is +.BR 192.168.0.20 . +.TP +.BI end\ ADDRESS +The ending address of the IP lease block is +.IR ADDRESS . +The default is +.BR 192.168.0.254 . +.TP +.BI interface\ INTERFACE +The udhcp server should listen on +.IR INTERFACE . +The default is +.BR eth0 . +.TP +.BI max_leases\ LEASES +Offer at most +.I LEASES +leases (including those reserved by OFFERs, DECLINEs, and ARP +conflicts). The default is +.BR 254 . +.TP +.BI remaining\ REMAINING +If +.I REMAINING +is +.BR yes , +store the time remaining for each lease. If it is +.BR no , +store the expiration time for each lease. The default is +.BR yes . +.TP +.BI auto_time\ SECONDS +Write the lease information to a file every +.I SECONDS +seconds. The default is +.BR 7200 . +.TP +.BI decline_time\ SECONDS +Reserve an IP for +.I SECONDS +seconds if a DHCP decline message is received. The default is +.BR 3600 . +.TP +.BI conflict_time\ SECONDS +Reserve an IP for +.I SECONDS +seconds if an ARP conflict occurs. The default is +.BR 3600 . +.TP +.BI offer_time\ SECONDS +Reserve an IP for +.I SECONDS +seconds if it is offered. The default is +.BR 60 . +.TP +.BI min_lease\ SECONDS +Reserve an IP for the full lease time if the lease to be given is less than +.I SECONDS +seconds. The default is +.BR 60 . +.TP +.BI lease_file\ FILE +Write the lease information to +.IR FILE . +The default is +.BR /var/lib/misc/udhcpd.leases . +.TP +.BI pidfile\ FILE +Write the process ID to +.IR FILE . +The default is +.BR /var/run/udhcpd.pid . +.TP +.BI notify_file\ FILE +Execute +.I FILE +after the lease information is written. By default, no file is executed. +.TP +.BI siaddr\ ADDRESS +BOOTP specific option. The default is +.BR 0.0.0.0 . +.TP +.BI sname\ NAME +BOOTP specific option. There is no default. +.TP +.BI boot_file\ FILE +BOOTP specific option. There is no default. +.TP +.BI option\ OPTION +DHCP specific option. +.RS +.TP +.BI subnet\ ADDRESS +.TP +.BI timezone\ OFFSET +.TP +.BI router\ ADDRESS... +.TP +.BI timesvr\ ADDRESS... +.TP +.BI namesvr\ ADDRESS... +.TP +.BI dns\ ADDRESS... +.TP +.BI logsvr\ ADDRESS... +.TP +.BI cookiesvr\ ADDRESS... +.TP +.BI lprsvr\ ADDRESS... +.TP +.BI hostname\ HOSTNAME +.TP +.BI bootsize\ SIZE +.TP +.BI domain\ DOMAIN +.TP +.BI swapsvr\ ADDRESS +.TP +.BI rootpath\ PATH +.TP +.BI ipttl\ TTL +.TP +.BI mtu\ MTU +.TP +.BI broadcast\ ADDRESS +.TP +.BI ntpsrv\ ADDRESS... +.TP +.BI wins\ ADDRESS... +.TP +.BI requestip\ ADDRESS +.TP +.BI lease\ SECONDS +.TP +.BI dhcptype\ TYPE +.TP +.BI serverid\ ADDRESS +.TP +.BI tftp\ FILE +.TP +.BI bootfile\ FILE +The default for +.B lease +is +.BR 864000 . +There are no defaults for the other options. +.RE +.SH SEE ALSO +.BR udhcpd (8). --- udhcp-0.9.8cvs20050303.orig/dhcpc.h~ +++ udhcp-0.9.8cvs20050303/dhcpc.h~ @@ -0,0 +1,37 @@ +/* dhcpc.h */ +#ifndef _DHCPC_H +#define _DHCPC_H + +#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script" + +/* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */ +#include "libbb_udhcp.h" + +#define INIT_SELECTING 0 +#define REQUESTING 1 +#define BOUND 2 +#define RENEWING 3 +#define REBINDING 4 +#define INIT_REBOOT 5 +#define RENEW_REQUESTED 6 +#define RELEASED 7 + + +struct client_config_t { + char foreground; /* Do not fork */ + char quit_after_lease; /* Quit after obtaining lease */ + char abort_if_no_lease; /* Abort if no lease */ + char background_if_no_lease; /* Fork to background if no lease */ + char *interface; /* The name of the interface to use */ + char *pidfile; /* Optionally store the process ID */ + char *script; /* User script to run at dhcp events */ + uint8_t *clientid; /* Optional client id to use */ + uint8_t *hostname; /* Optional hostname to use */ + int ifindex; /* Index number of the interface to use */ + uint8_t arp[6]; /* Our arp address */ +}; + +extern struct client_config_t client_config; + + +#endif --- udhcp-0.9.8cvs20050303.orig/debian/changelog +++ udhcp-0.9.8cvs20050303/debian/changelog @@ -0,0 +1,207 @@ +udhcp (0.9.8cvs20050303-2) unstable; urgency=low + + * Fix correct number of leases (closes: #341139 - thanks to Ferenc Wagner) + * Make sure we close unbound sockets (closes: #336507 - thanks to Neil + Turton) + + -- Eric Van Buggenhaut Fri, 16 Dec 2005 20:31:09 +0100 + +udhcp (0.9.8cvs20050303-1) unstable; urgency=low + + * New upstream release + + -- Eric Van Buggenhaut Tue, 20 Sep 2005 18:48:02 +0200 + +udhcp (0.9.8cvs20050124-6) unstable; urgency=low + + * Avoid spurious calls in /etc/default.bound (closes:#312332) + * Bring up the interface, whether resolvconf is installed or not + (closes:#302658) + + -- Eric Van Buggenhaut Sun, 18 Sep 2005 21:25:37 +0200 + +udhcp (0.9.8cvs20050124-5) unstable; urgency=low + + * Allow udhcpc to set up hostname (closes: #234182) + * Added /etc/udhcpc/default.leasefail (closes: #302655) + + -- Eric Van Buggenhaut Tue, 7 Jun 2005 13:40:10 +0200 + +udhcp (0.9.8cvs20050124-4) unstable; urgency=low + + * Simplify default.bound and default.renew (closes: #302656) + + -- Eric Van Buggenhaut Sat, 2 Apr 2005 21:22:05 +0200 + +udhcp (0.9.8cvs20050124-3) unstable; urgency=low + + * Avoid calling resolvconf several times. + + -- Eric Van Buggenhaut Fri, 1 Apr 2005 23:04:55 +0200 + +udhcp (0.9.8cvs20050124-2) unstable; urgency=low + + * Added /etc/udhcpc/default.nak script + * Let udhcpc use resolvconf (closes: #302019) + + -- Eric Van Buggenhaut Thu, 31 Mar 2005 22:38:26 +0200 + +udhcp (0.9.8cvs20050124-1) unstable; urgency=low + + * New upstream release + * Replace all strcpy by strncpy (closes: #283582) + + -- Eric Van Buggenhaut Mon, 14 Mar 2005 22:51:51 +0100 + +udhcp (0.9.8cvs20040708-4) unstable; urgency=low + + * Let udhcpc to ask for a rootpath (closes: #279110) + + -- Eric Van Buggenhaut Tue, 2 Nov 2004 16:34:38 +0100 + +udhcp (0.9.8cvs20040708-3) unstable; urgency=high + + * Keep removal script from choking when udhcpd isn't running. + We now use prerm to stop the daemon, which is the Good Way(c) to do it. + (closes: #268955) thanks to Oliver Kurth. + * Urgency raised to high because if fixes a serious bug and 2 policy + violations. + + -- Eric Van Buggenhaut Tue, 31 Aug 2004 00:59:37 +0200 + +udhcp (0.9.8cvs20040708-2) unstable; urgency=low + + * Make sure udhcpd is stopped when removing or purging the package + (closes: #263562) + + -- Eric Van Buggenhaut Sun, 15 Aug 2004 19:49:33 +0200 + +udhcp (0.9.8cvs20040708-1) unstable; urgency=low + + * CVS snapshot as from 2004/07/08. Since 0.9.9 is still pending and 0.9.8 + was released more than 2 years ago, this update could be useful. + * included wpad option (closes: #235969) + * closes: #257122. + * now sends log messages to syslog instead of stdout + + -- Eric Van Buggenhaut Thu, 8 Jul 2004 21:45:54 +0200 + +udhcp (0.9.8-6) unstable; urgency=low + + * Better package description in debian/control (closes: #209591,#209694) + * Cosmetic changes in debian/copyright + * Updated Standards version + + -- Eric Van Buggenhaut Tue, 9 Sep 2003 23:31:02 +0200 + +udhcp (0.9.8-5) unstable; urgency=low + + * Removed the obsolete udhcpc-udeb (closes: #191232) + + -- Eric Van Buggenhaut Wed, 30 Apr 2003 00:41:31 +0200 + +udhcp (0.9.8-4) unstable; urgency=low + + * New maitainer (closes: #188106). + * Stop forking when failing to obtain a release (closes: #188056). + + -- Eric Van Buggenhaut Wed, 9 Apr 2003 03:24:03 +0200 + +udhcp (0.9.8-3) unstable; urgency=low + + * Do not log to stderr (closes: #173044). + * Provide dhcp-client (closes: #179165). + + -- Matt Kraai Mon, 10 Feb 2003 10:36:36 -0800 + +udhcp (0.9.8-2) unstable; urgency=low + + * Make udhcpc scripts conffiles (closes: #172150). + + -- Matt Kraai Mon, 9 Dec 2002 10:51:00 -0800 + +udhcp (0.9.8-1) unstable; urgency=low + + * Package new release (trick or treat). + * Remove /usr/doc handling from postinsts and prerms. + * Update Debian copyright file. + * Update Standards-Version. + + -- Matt Kraai Thu, 31 Oct 2002 15:19:48 -0800 + +udhcp (0.9.7-4) unstable; urgency=low + + * Create udhcpc-udeb. + + -- Matt Kraai Tue, 17 Sep 2002 08:21:41 -0700 + +udhcp (0.9.7-3) unstable; urgency=low + + * Fix parsing of one-character configuration values (closes: #148468). + + -- Matt Kraai Wed, 17 Jul 2002 10:01:24 -0700 + +udhcp (0.9.7-2) unstable; urgency=low + + * Fix resolv.conf path in samples/sample.bound (closes: #147737). + + -- Matt Kraai Mon, 3 Jun 2002 07:12:30 -0700 + +udhcp (0.9.7-1) unstable; urgency=low + + * New upstream release. + + -- Matt Kraai Tue, 28 May 2002 07:42:58 -0700 + +udhcp (0.9.6-6) unstable; urgency=low + + * Move lease information into /var/lib/misc. + + -- Matt Kraai Wed, 22 May 2002 09:55:48 -0700 + +udhcp (0.9.6-5) unstable; urgency=low + + * Move lease information into /var/lib (closes: #147737). + + -- Matt Kraai Wed, 22 May 2002 09:40:26 -0700 + +udhcp (0.9.6-4) unstable; urgency=low + + * Do not reject the packet if read returns extra or if the UDP checksum is + zero (closes: #145350). + + -- Matt Kraai Wed, 1 May 2002 08:39:10 -0700 + +udhcp (0.9.6-3) unstable; urgency=low + + * Fix resolv.conf path in renew script. + + -- Matt Kraai Sun, 17 Feb 2002 11:20:48 -0800 + +udhcp (0.9.6-2) unstable; urgency=low + + * Document script in udhcpc manual page. + + -- Matt Kraai Wed, 24 Oct 2001 19:25:15 -0700 + +udhcp (0.9.6-1) unstable; urgency=low + + * New upstream release. + + -- Matt Kraai Mon, 1 Oct 2001 19:49:09 -0700 + +udhcp (0.9.5-1) unstable; urgency=low + + * New upstream release. + * Fix misspelling of `Moreton' in package description. + * Install udhcpd.conf example. + * Include manual pages. + * Update debian/rules clean target. + + -- Matt Kraai Thu, 27 Sep 2001 18:18:22 -0700 + +udhcp (0.9.4-1) unstable; urgency=low + + * Initial release. + + -- Matt Kraai Tue, 11 Sep 2001 04:18:00 -0700 --- udhcp-0.9.8cvs20050303.orig/debian/control~ +++ udhcp-0.9.8cvs20050303/debian/control~ @@ -0,0 +1,34 @@ +Source: udhcp +Section: net +Priority: optional +Maintainer: Eric Van Buggenhaut +Standards-Version: 3.6.1 + +Package: udhcpc +Section: net +Architecture: any +Provides: dhcp-client +Depends: ${shlibs:Depends} +Suggests: resolvconf +Description: very small DHCP client + DHCP is a protocol like BOOTP (actually dhcpd includes much of + the functionality of BOOTPD!). It assigns IP addresses to clients + based on lease times. + This package is primarily geared towards embedded systems. It does however, + strive to be fully functional, and RFC compliant. + . + This is the client-side application. + +Package: udhcpd +Section: net +Architecture: any +Provides: dhcp3-server +Depends: ${shlibs:Depends} +Description: very small DHCP server + DHCP is a protocol like BOOTP (actually dhcpd includes much of + the functionality of BOOTPD!). It assigns IP addresses to clients + based on lease times. + This package is primarily geared towards embedded systems. It does however, + strive to be fully functional, and RFC compliant. + . + This is the server-side application. --- udhcp-0.9.8cvs20050303.orig/debian/control +++ udhcp-0.9.8cvs20050303/debian/control @@ -0,0 +1,34 @@ +Source: udhcp +Section: net +Priority: optional +Maintainer: Eric Van Buggenhaut +Standards-Version: 3.6.2 + +Package: udhcpc +Section: net +Architecture: any +Provides: dhcp-client +Depends: ${shlibs:Depends} +Suggests: resolvconf +Description: very small DHCP client + DHCP is a protocol like BOOTP (actually dhcpd includes much of + the functionality of BOOTPD!). It assigns IP addresses to clients + based on lease times. + This package is primarily geared towards embedded systems. It does however, + strive to be fully functional, and RFC compliant. + . + This is the client-side application. + +Package: udhcpd +Section: net +Architecture: any +Provides: dhcp3-server +Depends: ${shlibs:Depends} +Description: very small DHCP server + DHCP is a protocol like BOOTP (actually dhcpd includes much of + the functionality of BOOTPD!). It assigns IP addresses to clients + based on lease times. + This package is primarily geared towards embedded systems. It does however, + strive to be fully functional, and RFC compliant. + . + This is the server-side application. --- udhcp-0.9.8cvs20050303.orig/debian/conffiles.udhcpc +++ udhcp-0.9.8cvs20050303/debian/conffiles.udhcpc @@ -0,0 +1,6 @@ +/etc/udhcpc/default.bound +/etc/udhcpc/default.deconfig +/etc/udhcpc/default.leasefail +/etc/udhcpc/default.renew +/etc/udhcpc/default.script +/etc/udhcpc/default.nak --- udhcp-0.9.8cvs20050303.orig/debian/changelog~ +++ udhcp-0.9.8cvs20050303/debian/changelog~ @@ -0,0 +1,191 @@ +udhcp (0.9.8cvs20050124-6) unstable; urgency=low + + * Avoid spurious calls in /etc/default.bound (closes:#312332) + + -- Eric Van Buggenhaut Sun, 18 Sep 2005 21:25:37 +0200 + +udhcp (0.9.8cvs20050124-5) unstable; urgency=low + + * Allow udhcpc to set up hostname (closes: #234182) + * Added /etc/udhcpc/default.leasefail (closes: #302655) + + -- Eric Van Buggenhaut Tue, 7 Jun 2005 13:40:10 +0200 + +udhcp (0.9.8cvs20050124-4) unstable; urgency=low + + * Simplify default.bound and default.renew (closes: #302656) + + -- Eric Van Buggenhaut Sat, 2 Apr 2005 21:22:05 +0200 + +udhcp (0.9.8cvs20050124-3) unstable; urgency=low + + * Avoid calling resolvconf several times. + + -- Eric Van Buggenhaut Fri, 1 Apr 2005 23:04:55 +0200 + +udhcp (0.9.8cvs20050124-2) unstable; urgency=low + + * Added /etc/udhcpc/default.nak script + * Let udhcpc use resolvconf (closes: #302019) + + -- Eric Van Buggenhaut Thu, 31 Mar 2005 22:38:26 +0200 + +udhcp (0.9.8cvs20050124-1) unstable; urgency=low + + * New upstream release + * Replace all strcpy by strncpy (closes: #283582) + + -- Eric Van Buggenhaut Mon, 14 Mar 2005 22:51:51 +0100 + +udhcp (0.9.8cvs20040708-4) unstable; urgency=low + + * Let udhcpc to ask for a rootpath (closes: #279110) + + -- Eric Van Buggenhaut Tue, 2 Nov 2004 16:34:38 +0100 + +udhcp (0.9.8cvs20040708-3) unstable; urgency=high + + * Keep removal script from choking when udhcpd isn't running. + We now use prerm to stop the daemon, which is the Good Way(c) to do it. + (closes: #268955) thanks to Oliver Kurth. + * Urgency raised to high because if fixes a serious bug and 2 policy + violations. + + -- Eric Van Buggenhaut Tue, 31 Aug 2004 00:59:37 +0200 + +udhcp (0.9.8cvs20040708-2) unstable; urgency=low + + * Make sure udhcpd is stopped when removing or purging the package + (closes: #263562) + + -- Eric Van Buggenhaut Sun, 15 Aug 2004 19:49:33 +0200 + +udhcp (0.9.8cvs20040708-1) unstable; urgency=low + + * CVS snapshot as from 2004/07/08. Since 0.9.9 is still pending and 0.9.8 + was released more than 2 years ago, this update could be useful. + * included wpad option (closes: #235969) + * closes: #257122. + * now sends log messages to syslog instead of stdout + + -- Eric Van Buggenhaut Thu, 8 Jul 2004 21:45:54 +0200 + +udhcp (0.9.8-6) unstable; urgency=low + + * Better package description in debian/control (closes: #209591,#209694) + * Cosmetic changes in debian/copyright + * Updated Standards version + + -- Eric Van Buggenhaut Tue, 9 Sep 2003 23:31:02 +0200 + +udhcp (0.9.8-5) unstable; urgency=low + + * Removed the obsolete udhcpc-udeb (closes: #191232) + + -- Eric Van Buggenhaut Wed, 30 Apr 2003 00:41:31 +0200 + +udhcp (0.9.8-4) unstable; urgency=low + + * New maitainer (closes: #188106). + * Stop forking when failing to obtain a release (closes: #188056). + + -- Eric Van Buggenhaut Wed, 9 Apr 2003 03:24:03 +0200 + +udhcp (0.9.8-3) unstable; urgency=low + + * Do not log to stderr (closes: #173044). + * Provide dhcp-client (closes: #179165). + + -- Matt Kraai Mon, 10 Feb 2003 10:36:36 -0800 + +udhcp (0.9.8-2) unstable; urgency=low + + * Make udhcpc scripts conffiles (closes: #172150). + + -- Matt Kraai Mon, 9 Dec 2002 10:51:00 -0800 + +udhcp (0.9.8-1) unstable; urgency=low + + * Package new release (trick or treat). + * Remove /usr/doc handling from postinsts and prerms. + * Update Debian copyright file. + * Update Standards-Version. + + -- Matt Kraai Thu, 31 Oct 2002 15:19:48 -0800 + +udhcp (0.9.7-4) unstable; urgency=low + + * Create udhcpc-udeb. + + -- Matt Kraai Tue, 17 Sep 2002 08:21:41 -0700 + +udhcp (0.9.7-3) unstable; urgency=low + + * Fix parsing of one-character configuration values (closes: #148468). + + -- Matt Kraai Wed, 17 Jul 2002 10:01:24 -0700 + +udhcp (0.9.7-2) unstable; urgency=low + + * Fix resolv.conf path in samples/sample.bound (closes: #147737). + + -- Matt Kraai Mon, 3 Jun 2002 07:12:30 -0700 + +udhcp (0.9.7-1) unstable; urgency=low + + * New upstream release. + + -- Matt Kraai Tue, 28 May 2002 07:42:58 -0700 + +udhcp (0.9.6-6) unstable; urgency=low + + * Move lease information into /var/lib/misc. + + -- Matt Kraai Wed, 22 May 2002 09:55:48 -0700 + +udhcp (0.9.6-5) unstable; urgency=low + + * Move lease information into /var/lib (closes: #147737). + + -- Matt Kraai Wed, 22 May 2002 09:40:26 -0700 + +udhcp (0.9.6-4) unstable; urgency=low + + * Do not reject the packet if read returns extra or if the UDP checksum is + zero (closes: #145350). + + -- Matt Kraai Wed, 1 May 2002 08:39:10 -0700 + +udhcp (0.9.6-3) unstable; urgency=low + + * Fix resolv.conf path in renew script. + + -- Matt Kraai Sun, 17 Feb 2002 11:20:48 -0800 + +udhcp (0.9.6-2) unstable; urgency=low + + * Document script in udhcpc manual page. + + -- Matt Kraai Wed, 24 Oct 2001 19:25:15 -0700 + +udhcp (0.9.6-1) unstable; urgency=low + + * New upstream release. + + -- Matt Kraai Mon, 1 Oct 2001 19:49:09 -0700 + +udhcp (0.9.5-1) unstable; urgency=low + + * New upstream release. + * Fix misspelling of `Moreton' in package description. + * Install udhcpd.conf example. + * Include manual pages. + * Update debian/rules clean target. + + -- Matt Kraai Thu, 27 Sep 2001 18:18:22 -0700 + +udhcp (0.9.4-1) unstable; urgency=low + + * Initial release. + + -- Matt Kraai Tue, 11 Sep 2001 04:18:00 -0700 --- udhcp-0.9.8cvs20050303.orig/debian/rules~ +++ udhcp-0.9.8cvs20050303/debian/rules~ @@ -0,0 +1,118 @@ +#!/usr/bin/make -f + +version=$(shell dpkg-parsechangelog | grep ^Version:.* | cut -d ' ' -f 2) +architecture=$(shell dpkg --print-architecture) + +build: + $(checkdir) + $(MAKE) + touch build + +clean: + $(checkdir) + -$(MAKE) -i clean + -rm -rf build debian/tmp debian/files debian/substvars + +binary-indep: checkroot build + $(checkdir) + +binary-arch: checkroot build + $(checkdir) + rm -fr debian/tmp + + # Build udhcpc package. + install -d -m 755 debian/tmp/DEBIAN + install -m 644 debian/conffiles.udhcpc debian/tmp/DEBIAN/conffiles + + install -d -m 755 debian/tmp/usr/share/doc/udhcpc + #install -m 644 README debian/tmp/usr/share/doc/udhcpc + install -m 644 README.udhcpc debian/tmp/usr/share/doc/udhcpc/README + install -m 644 ChangeLog debian/tmp/usr/share/doc/udhcpc/changelog + install -m 644 debian/changelog debian/tmp/usr/share/doc/udhcpc/changelog.Debian + gzip -9v debian/tmp/usr/share/doc/udhcpc/* + install -m 644 debian/copyright debian/tmp/usr/share/doc/udhcpc + + install -d -m 755 debian/tmp/usr/share/man/man8 + install -m 644 udhcpc.8 debian/tmp/usr/share/man/man8 + gzip -9v debian/tmp/usr/share/man/man8/udhcpc.8 + + install -d -m 755 debian/tmp/sbin + install -m 755 udhcpc debian/tmp/sbin/udhcpc + strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/sbin/udhcpc + + install -d -m 755 debian/tmp/etc/udhcpc + for name in bound deconfig renew script nak; do \ + install -m 755 samples/sample.$$name debian/tmp/etc/udhcpc/default.$$name ; \ + done + + dpkg-shlibdeps udhcpc + dpkg-gencontrol -isp -pudhcpc + chown -R root.root debian/tmp + chmod -R go=rX debian/tmp + dpkg --build debian/tmp .. + + rm -fr debian/tmp + + # Build udhcpd package. + install -d -m 755 debian/tmp/DEBIAN + install -m 755 debian/postinst.udhcpd debian/tmp/DEBIAN/postinst + install -m 755 debian/postrm.udhcpd debian/tmp/DEBIAN/postrm + install -m 755 debian/prerm.udhcpd debian/tmp/DEBIAN/prerm + install -m 644 debian/conffiles.udhcpd debian/tmp/DEBIAN/conffiles + + install -d -m 755 debian/tmp/usr/share/doc/udhcpd + #install -m 644 README debian/tmp/usr/share/doc/udhcpd + install -m 644 README.udhcpd debian/tmp/usr/share/doc/udhcpd/README + install -m 644 ChangeLog debian/tmp/usr/share/doc/udhcpd/changelog + install -m 644 debian/changelog debian/tmp/usr/share/doc/udhcpd/changelog.Debian + gzip -9v debian/tmp/usr/share/doc/udhcpd/* + install -m 644 debian/copyright debian/tmp/usr/share/doc/udhcpd + + install -d -m 755 debian/tmp/usr/share/doc/udhcpd/examples + install -m 644 samples/udhcpd.conf debian/tmp/usr/share/doc/udhcpd/examples + + install -d -m 755 debian/tmp/usr/share/man/man1 + install -m 644 dumpleases.1 debian/tmp/usr/share/man/man1 + gzip -9v debian/tmp/usr/share/man/man1/dumpleases.1 + + install -d -m 755 debian/tmp/usr/share/man/man5 + install -m 644 udhcpd.conf.5 debian/tmp/usr/share/man/man5 + gzip -9v debian/tmp/usr/share/man/man5/udhcpd.conf.5 + + install -d -m 755 debian/tmp/usr/share/man/man8 + install -m 644 udhcpd.8 debian/tmp/usr/share/man/man8 + gzip -9v debian/tmp/usr/share/man/man8/udhcpd.8 + + install -d -m 755 debian/tmp/usr/sbin + install -m 755 udhcpd debian/tmp/usr/sbin/udhcpd + strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/usr/sbin/udhcpd + + install -d -m 755 debian/tmp/usr/bin + install -m 755 dumpleases debian/tmp/usr/bin/dumpleases + strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/usr/bin/dumpleases + + install -d -m 755 debian/tmp/etc/init.d + install -m 755 debian/udhcpd debian/tmp/etc/init.d + + mkdir -p debian/tmp/var/lib/misc + touch debian/tmp/var/lib/misc/udhcpd.leases + + dpkg-shlibdeps udhcpd + dpkg-gencontrol -isp -pudhcpd + chown -R root.root debian/tmp + chmod -R go=rX debian/tmp + dpkg --build debian/tmp .. + + rm -fr debian/tmp + +define checkdir + test -f dhcpc.c -a -f debian/rules +endef + +binary: binary-indep binary-arch + +checkroot: + $(checkdir) + test root = "`whoami`" + +.PHONY: binary binary-arch binary-indep clean checkroot --- udhcp-0.9.8cvs20050303.orig/debian/rules +++ udhcp-0.9.8cvs20050303/debian/rules @@ -0,0 +1,118 @@ +#!/usr/bin/make -f + +version=$(shell dpkg-parsechangelog | grep ^Version:.* | cut -d ' ' -f 2) +architecture=$(shell dpkg --print-architecture) + +build: + $(checkdir) + $(MAKE) + touch build + +clean: + $(checkdir) + -$(MAKE) -i clean + -rm -rf build debian/tmp debian/files debian/substvars + +binary-indep: checkroot build + $(checkdir) + +binary-arch: checkroot build + $(checkdir) + rm -fr debian/tmp + + # Build udhcpc package. + install -d -m 755 debian/tmp/DEBIAN + install -m 644 debian/conffiles.udhcpc debian/tmp/DEBIAN/conffiles + + install -d -m 755 debian/tmp/usr/share/doc/udhcpc + #install -m 644 README debian/tmp/usr/share/doc/udhcpc + install -m 644 README.udhcpc debian/tmp/usr/share/doc/udhcpc/README + install -m 644 ChangeLog debian/tmp/usr/share/doc/udhcpc/changelog + install -m 644 debian/changelog debian/tmp/usr/share/doc/udhcpc/changelog.Debian + gzip -9v debian/tmp/usr/share/doc/udhcpc/* + install -m 644 debian/copyright debian/tmp/usr/share/doc/udhcpc + + install -d -m 755 debian/tmp/usr/share/man/man8 + install -m 644 udhcpc.8 debian/tmp/usr/share/man/man8 + gzip -9v debian/tmp/usr/share/man/man8/udhcpc.8 + + install -d -m 755 debian/tmp/sbin + install -m 755 udhcpc debian/tmp/sbin/udhcpc + strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/sbin/udhcpc + + install -d -m 755 debian/tmp/etc/udhcpc + for name in leasefail bound deconfig renew script nak; do \ + install -m 755 samples/sample.$$name debian/tmp/etc/udhcpc/default.$$name ; \ + done + + dpkg-shlibdeps udhcpc + dpkg-gencontrol -isp -pudhcpc + chown -R root.root debian/tmp + chmod -R go=rX debian/tmp + dpkg --build debian/tmp .. + + rm -fr debian/tmp + + # Build udhcpd package. + install -d -m 755 debian/tmp/DEBIAN + install -m 755 debian/postinst.udhcpd debian/tmp/DEBIAN/postinst + install -m 755 debian/postrm.udhcpd debian/tmp/DEBIAN/postrm + install -m 755 debian/prerm.udhcpd debian/tmp/DEBIAN/prerm + install -m 644 debian/conffiles.udhcpd debian/tmp/DEBIAN/conffiles + + install -d -m 755 debian/tmp/usr/share/doc/udhcpd + #install -m 644 README debian/tmp/usr/share/doc/udhcpd + install -m 644 README.udhcpd debian/tmp/usr/share/doc/udhcpd/README + install -m 644 ChangeLog debian/tmp/usr/share/doc/udhcpd/changelog + install -m 644 debian/changelog debian/tmp/usr/share/doc/udhcpd/changelog.Debian + gzip -9v debian/tmp/usr/share/doc/udhcpd/* + install -m 644 debian/copyright debian/tmp/usr/share/doc/udhcpd + + install -d -m 755 debian/tmp/usr/share/doc/udhcpd/examples + install -m 644 samples/udhcpd.conf debian/tmp/usr/share/doc/udhcpd/examples + + install -d -m 755 debian/tmp/usr/share/man/man1 + install -m 644 dumpleases.1 debian/tmp/usr/share/man/man1 + gzip -9v debian/tmp/usr/share/man/man1/dumpleases.1 + + install -d -m 755 debian/tmp/usr/share/man/man5 + install -m 644 udhcpd.conf.5 debian/tmp/usr/share/man/man5 + gzip -9v debian/tmp/usr/share/man/man5/udhcpd.conf.5 + + install -d -m 755 debian/tmp/usr/share/man/man8 + install -m 644 udhcpd.8 debian/tmp/usr/share/man/man8 + gzip -9v debian/tmp/usr/share/man/man8/udhcpd.8 + + install -d -m 755 debian/tmp/usr/sbin + install -m 755 udhcpd debian/tmp/usr/sbin/udhcpd + strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/usr/sbin/udhcpd + + install -d -m 755 debian/tmp/usr/bin + install -m 755 dumpleases debian/tmp/usr/bin/dumpleases + strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/usr/bin/dumpleases + + install -d -m 755 debian/tmp/etc/init.d + install -m 755 debian/udhcpd debian/tmp/etc/init.d + + mkdir -p debian/tmp/var/lib/misc + touch debian/tmp/var/lib/misc/udhcpd.leases + + dpkg-shlibdeps udhcpd + dpkg-gencontrol -isp -pudhcpd + chown -R root.root debian/tmp + chmod -R go=rX debian/tmp + dpkg --build debian/tmp .. + + rm -fr debian/tmp + +define checkdir + test -f dhcpc.c -a -f debian/rules +endef + +binary: binary-indep binary-arch + +checkroot: + $(checkdir) + test root = "`whoami`" + +.PHONY: binary binary-arch binary-indep clean checkroot --- udhcp-0.9.8cvs20050303.orig/debian/copyright~ +++ udhcp-0.9.8cvs20050303/debian/copyright~ @@ -0,0 +1,23 @@ +This is Debian GNU's prepackaged version of udhcp, a program which +provides a DHCP client and server. + +This package was originally put together by Matt Kraai , +from the sources obtained from http://udhcp.busybox.net/. + +Program Copyright (C) 2001 Russ Dill +Modifications for Debian Copyright (C) 2001, 2002 Matt Kraai +Modifications for Debian Copyright (C) 2003 Eric Van Buggenhaut + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +On Debian systems, a copy of the GPL version 2 can be found in + +/usr/share/common-licenses/GPL-2 --- udhcp-0.9.8cvs20050303.orig/debian/copyright +++ udhcp-0.9.8cvs20050303/debian/copyright @@ -0,0 +1,18 @@ +This is Debian GNU's prepackaged version of udhcp, a program which +provides a DHCP client and server. + +This package was originally put together by Matt Kraai , +from the sources obtained from http://udhcp.busybox.net/. + +Program Copyright (C) 2001 Russ Dill +Modifications for Debian Copyright (C) 2001, 2002 Matt Kraai +Modifications for Debian Copyright (C) 2003 Eric Van Buggenhaut + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +On Debian systems, a copy of the GPL version 2 can be found in + +/usr/share/common-licenses/GPL-2 --- udhcp-0.9.8cvs20050303.orig/debian/conffiles.udhcpd +++ udhcp-0.9.8cvs20050303/debian/conffiles.udhcpd @@ -0,0 +1 @@ +/etc/init.d/udhcpd --- udhcp-0.9.8cvs20050303.orig/debian/udhcpc.docs~ +++ udhcp-0.9.8cvs20050303/debian/udhcpc.docs~ @@ -0,0 +1,3 @@ + +README +README.udhcpc --- udhcp-0.9.8cvs20050303.orig/debian/udhcpd.docs~ +++ udhcp-0.9.8cvs20050303/debian/udhcpd.docs~ @@ -0,0 +1,3 @@ + +arpping.c +README.udhcpd --- udhcp-0.9.8cvs20050303.orig/debian/postinst.udhcpd +++ udhcp-0.9.8cvs20050303/debian/postinst.udhcpd @@ -0,0 +1,3 @@ +#! /bin/sh -e + +update-rc.d udhcpd defaults >/dev/null --- udhcp-0.9.8cvs20050303.orig/debian/postrm.udhcpd +++ udhcp-0.9.8cvs20050303/debian/postrm.udhcpd @@ -0,0 +1,8 @@ +#!/bin/sh -e + +#killall udhcpd || true Really we do that better in prerm + +if [ "$1" = purge ]; then + update-rc.d udhcpd remove >/dev/null + rm -rf /etc/udhcpd.conf || true +fi --- udhcp-0.9.8cvs20050303.orig/debian/udhcpd +++ udhcp-0.9.8cvs20050303/debian/udhcpd @@ -0,0 +1,69 @@ +#! /bin/sh +# +# skeleton example file to build /etc/init.d/ scripts. +# This file should be used to construct scripts for /etc/init.d. +# +# Written by Miquel van Smoorenburg . +# Modified for Debian GNU/Linux +# by Ian Murdock . +# +# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl +# + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/sbin/udhcpd +NAME=udhcpd +DESC="very small DHCP server" + +test -x $DAEMON || exit 0 + +set -e + +case "$1" in + start) + echo -n "Starting $DESC: " + start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ + --exec $DAEMON + echo "$NAME." + ;; + stop) + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ + --exec $DAEMON + echo "$NAME." + ;; + #reload) + # + # If the daemon can reload its config files on the fly + # for example by sending it SIGHUP, do it here. + # + # If the daemon responds to changes in its config file + # directly anyway, make this a do-nothing entry. + # + # echo "Reloading $DESC configuration files." + # start-stop-daemon --stop --signal 1 --quiet --pidfile \ + # /var/run/$NAME.pid --exec $DAEMON + #;; + restart|force-reload) + # + # If the "reload" option is implemented, move the "force-reload" + # option to the "reload" entry above. If not, "force-reload" is + # just the same as "restart". + # + echo -n "Restarting $DESC: " + start-stop-daemon --stop --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON + sleep 1 + start-stop-daemon --start --quiet --pidfile \ + /var/run/$NAME.pid --exec $DAEMON + echo "$NAME." + ;; + *) + N=/etc/init.d/$NAME + # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 --- udhcp-0.9.8cvs20050303.orig/debian/prerm.udhcpd +++ udhcp-0.9.8cvs20050303/debian/prerm.udhcpd @@ -0,0 +1,9 @@ +#!/bin/sh -e + +if [ "$1" = remove ]; then + if command -v invoke-rc.d >/dev/null 2>&1; then + invoke-rc.d udhcpd stop || true + else + /etc/init.d/udhcpd stop + fi +fi --- udhcp-0.9.8cvs20050303.orig/debian/postrm.udhcpd~ +++ udhcp-0.9.8cvs20050303/debian/postrm.udhcpd~ @@ -0,0 +1,7 @@ +#!/bin/sh -e + +#killall udhcpd || true Really we do that better in prerm + +if [ "$1" = purge ]; then + update-rc.d udhcpd remove >/dev/null +fi --- udhcp-0.9.8cvs20050303.orig/debian/conffiles.udhcpd~ +++ udhcp-0.9.8cvs20050303/debian/conffiles.udhcpd~ @@ -0,0 +1,2 @@ +/etc/init.d/udhcpd +/etc/udhcpd.conf --- udhcp-0.9.8cvs20050303.orig/debian/prerm.udhcpd~ +++ udhcp-0.9.8cvs20050303/debian/prerm.udhcpd~ @@ -0,0 +1,10 @@ +#!/bin/sh -e + +if [ "$1" = remove ]; then + if command -v invoke-rc.d >/dev/null 2>&1; then + invoke-rc.d udhcpd stop + else + /etc/init.d/udhcpd stop + fi + /etc/init.d/udhcpd stop +fi --- udhcp-0.9.8cvs20050303.orig/debian/postinst.udhcpd~ +++ udhcp-0.9.8cvs20050303/debian/postinst.udhcpd~ @@ -0,0 +1,3 @@ +#! /bin/sh -e + +update-rc.d udhcpd defaults >/dev/null --- udhcp-0.9.8cvs20050303.orig/debian/conffiles.udhcpc~ +++ udhcp-0.9.8cvs20050303/debian/conffiles.udhcpc~ @@ -0,0 +1,5 @@ +/etc/udhcpc/default.bound +/etc/udhcpc/default.deconfig +/etc/udhcpc/default.renew +/etc/udhcpc/default.script +/etc/udhcpc/default.nak --- udhcp-0.9.8cvs20050303.orig/Makefile~ +++ udhcp-0.9.8cvs20050303/Makefile~ @@ -0,0 +1,103 @@ +# udhcp makefile + +prefix=/usr +SBINDIR=/sbin +USRSBINDIR=${prefix}/sbin +USRBINDIR=${prefix}/bin +USRSHAREDIR=${prefix}/share + +# Uncomment this to get a shared binary. Call as udhcpd for the server, +# and udhcpc for the client +#COMBINED_BINARY=1 + +# Uncomment this for extra output and to compile with debugging symbols +#UDHCP_DEBUG=1 + +# Uncomment this to output messages to syslog, otherwise, messages go to stdout +#CFLAGS += -DUDHCP_SYSLOG + +#CROSS_COMPILE=arm-uclibc- +CC = $(CROSS_COMPILE)gcc +LD = $(CROSS_COMPILE)gcc +INSTALL = install + +OBJS_SHARED = common.o options.o packet.o pidfile.o signalpipe.o socket.o +DHCPD_OBJS = dhcpd.o arpping.o files.o leases.o serverpacket.o +DHCPC_OBJS = dhcpc.o clientpacket.o clientsocket.o script.o + +ifdef COMBINED_BINARY +EXEC1 = udhcpd +OBJS1 = $(DHCPD_OBJS) $(DHCPC_OBJS) $(OBJS_SHARED) frontend.o +CFLAGS += -DCOMBINED_BINARY +else +EXEC1 = udhcpd +OBJS1 = $(DHCPD_OBJS) $(OBJS_SHARED) + +EXEC2 = udhcpc +OBJS2 = $(DHCPC_OBJS) $(OBJS_SHARED) +endif + +EXEC3 = dumpleases +OBJS3 = dumpleases.o + +BOOT_PROGRAMS = udhcpc +DAEMONS = udhcpd +COMMANDS = dumpleases + +ifdef UDHCP_SYSLOG +CFLAGS += -DUDHCP_SYSLOG +endif + +CFLAGS += -W -Wall -Wstrict-prototypes -D_GNU_SOURCE + +ifdef UDHCP_DEBUG +CFLAGS += -g -DUDHCP_DEBUG +STRIP=true +else +CFLAGS += -Os -fomit-frame-pointer +STRIP=$(CROSS_COMPILE)strip +endif + +all: $(EXEC1) $(EXEC2) $(EXEC3) + $(STRIP) --remove-section=.note --remove-section=.comment $(EXEC1) $(EXEC2) $(EXEC3) + +$(OBJS1) $(OBJS2) $(OBJS3): *.h Makefile +$(EXEC1) $(EXEC2) $(EXEC3): Makefile + +.c.o: + $(CC) -c $(CFLAGS) $< + +$(EXEC1): $(OBJS1) + $(LD) $(LDFLAGS) $(OBJS1) -o $(EXEC1) + +$(EXEC2): $(OBJS2) + $(LD) $(LDFLAGS) $(OBJS2) -o $(EXEC2) + +$(EXEC3): $(OBJS3) + $(LD) $(LDFLAGS) $(OBJS3) -o $(EXEC3) + + +install: all + + $(INSTALL) $(DAEMONS) $(USRSBINDIR) + $(INSTALL) $(COMMANDS) $(USRBINDIR) +ifdef COMBINED_BINARY + ln -sf $(USRSBINDIR)/$(DAEMONS) $(SBINDIR)/$(BOOT_PROGRAMS) +else + $(INSTALL) $(BOOT_PROGRAMS) $(SBINDIR) +endif + mkdir -p $(USRSHAREDIR)/udhcpc + for name in bound deconfig renew script ; do \ + $(INSTALL) samples/sample.$$name \ + $(USRSHAREDIR)/udhcpc/default.$$name ; \ + done + mkdir -p $(USRSHAREDIR)/man/man1 + $(INSTALL) dumpleases.1 $(USRSHAREDIR)/man/man1 + mkdir -p $(USRSHAREDIR)/man/man5 + $(INSTALL) udhcpd.conf.5 $(USRSHAREDIR)/man/man5 + mkdir -p $(USRSHAREDIR)/man/man8 + $(INSTALL) udhcpc.8 udhcpd.8 $(USRSHAREDIR)/man/man8 + +clean: + -rm -f udhcpd udhcpc dumpleases *.o core + --- udhcp-0.9.8cvs20050303.orig/arpping.c~ +++ udhcp-0.9.8cvs20050303/arpping.c~ @@ -0,0 +1,106 @@ +/* + * arpping.c + * + * Mostly stolen from: dhcpcd - DHCP client daemon + * by Yoichi Hariguchi + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dhcpd.h" +#include "arpping.h" +#include "common.h" + +/* args: yiaddr - what IP to ping + * ip - our ip + * mac - our arp address + * interface - interface to use + * retn: 1 addr free + * 0 addr used + * -1 error + */ + +/* FIXME: match response against chaddr */ +int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) +{ + + int timeout = 2; + int optval = 1; + int s; /* socket */ + int rv = 1; /* return value */ + struct sockaddr addr; /* for interface name */ + struct arpMsg arp; + fd_set fdset; + struct timeval tm; + time_t prevTime; + + + if ((s = socket (PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP))) == -1) { +#ifdef IN_BUSYBOX + LOG(LOG_ERR, bb_msg_can_not_create_raw_socket); +#else + LOG(LOG_ERR, "Could not open raw socket"); +#endif + return -1; + } + + if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { + LOG(LOG_ERR, "Could not setsocketopt on raw socket"); + close(s); + return -1; + } + + /* send arp request */ + memset(&arp, 0, sizeof(arp)); + memcpy(arp.h_dest, MAC_BCAST_ADDR, 6); /* MAC DA */ + memcpy(arp.h_source, mac, 6); /* MAC SA */ + arp.h_proto = htons(ETH_P_ARP); /* protocol type (Ethernet) */ + arp.htype = htons(ARPHRD_ETHER); /* hardware type */ + arp.ptype = htons(ETH_P_IP); /* protocol type (ARP message) */ + arp.hlen = 6; /* hardware address length */ + arp.plen = 4; /* protocol address length */ + arp.operation = htons(ARPOP_REQUEST); /* ARP op code */ + memcpy(arp.sInaddr, &ip, sizeof(ip)); /* source IP address */ + memcpy(arp.sHaddr, mac, 6); /* source hardware address */ + memcpy(arp.tInaddr, &yiaddr, sizeof(yiaddr)); /* target IP address */ + + memset(&addr, 0, sizeof(addr)); + strcpy(addr.sa_data, interface); + if (sendto(s, &arp, sizeof(arp), 0, &addr, sizeof(addr)) < 0) + rv = 0; + + /* wait arp reply, and check it */ + tm.tv_usec = 0; + prevTime = uptime(); + while (timeout > 0) { + FD_ZERO(&fdset); + FD_SET(s, &fdset); + tm.tv_sec = timeout; + if (select(s + 1, &fdset, (fd_set *) NULL, (fd_set *) NULL, &tm) < 0) { + DEBUG(LOG_ERR, "Error on ARPING request: %m"); + if (errno != EINTR) rv = 0; + } else if (FD_ISSET(s, &fdset)) { + if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0; + if (arp.operation == htons(ARPOP_REPLY) && + bcmp(arp.tHaddr, mac, 6) == 0 && + *((uint32_t *) arp.sInaddr) == yiaddr) { + DEBUG(LOG_INFO, "Valid arp reply receved for this address"); + rv = 0; + break; + } + } + timeout -= uptime() - prevTime; + prevTime = uptime(); + } + close(s); + DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); + return rv; +} --- udhcp-0.9.8cvs20050303.orig/socket.c~ +++ udhcp-0.9.8cvs20050303/socket.c~ @@ -0,0 +1,134 @@ +/* + * socket.c -- DHCP server client/server socket creation + * + * udhcp client/server + * Copyright (C) 1999 Matthew Ramsay + * Chris Trew + * + * Rewrite by Russ Dill July 2001 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if __GLIBC__ >=2 && __GLIBC_MINOR >= 1 +#include +#include +#else +#include +#include +#include +#endif + +#include "socket.h" +#include "common.h" + +int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) +{ + int fd; + struct ifreq ifr; + struct sockaddr_in *our_ip; + + memset(&ifr, 0, sizeof(struct ifreq)); + if((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) >= 0) { + ifr.ifr_addr.sa_family = AF_INET; + //closes http://bugs.debian.org/283582 + //strcpy(ifr.ifr_name, interface); + strncpy(ifr.ifr_name, interface, IFNAMSIZ-1); + + if (addr) { + if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { + our_ip = (struct sockaddr_in *) &ifr.ifr_addr; + *addr = our_ip->sin_addr.s_addr; + DEBUG(LOG_INFO, "%s (our ip) = %s", ifr.ifr_name, inet_ntoa(our_ip->sin_addr)); + } else { + LOG(LOG_ERR, "SIOCGIFADDR failed, is the interface up and configured?: %m"); + return -1; + } + } + + if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) { + DEBUG(LOG_INFO, "adapter index %d", ifr.ifr_ifindex); + *ifindex = ifr.ifr_ifindex; + } else { + LOG(LOG_ERR, "SIOCGIFINDEX failed!: %m"); + return -1; + } + if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) { + memcpy(arp, ifr.ifr_hwaddr.sa_data, 6); + DEBUG(LOG_INFO, "adapter hardware address %02x:%02x:%02x:%02x:%02x:%02x", + arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]); + } else { + LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %m"); + return -1; + } + } else { + LOG(LOG_ERR, "socket failed!: %m"); + return -1; + } + close(fd); + return 0; +} + + +int listen_socket(uint32_t ip, int port, char *inf) +{ + struct ifreq interface; + int fd; + struct sockaddr_in addr; + int n = 1; + + DEBUG(LOG_INFO, "Opening listen socket on 0x%08x:%d %s", ip, port, inf); + if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + DEBUG(LOG_ERR, "socket call failed: %m"); + return -1; + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(port); + addr.sin_addr.s_addr = ip; + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) { + close(fd); + return -1; + } + if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char *) &n, sizeof(n)) == -1) { + close(fd); + return -1; + } + + strncpy(interface.ifr_ifrn.ifrn_name, inf, IFNAMSIZ); + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,(char *)&interface, sizeof(interface)) < 0) { + close(fd); + return -1; + } + + if (bind(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1) { + close(fd); + return -1; + } + + return fd; +}