Package: dhcp3-client Version: 3.1.0-4 Severity: wishlist
Hi maintainer [Note: I've submitted this wishlist and patches to the ISC maintainers, but got no response, so thought I might try through you guys]. The current implementation of the DHCP client supports only Ethernet, FDDI (and some others) hardware devices. Networking devices that have no hardware header (or IP only devices) are not. The included patches add support to recognize ARPHRD_NONE devices, so dhclient can work over them. There is only two patche (ignore the 1_3 and 2_3 tags in the filenames). Thanks, -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.24-1-686 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages dhcp3-client depends on: ii debconf [debconf-2.0] 1.5.19 Debian configuration management sy ii debianutils 2.28.4 Miscellaneous utilities specific t ii dhcp3-common 3.1.0-4 common files used by all the dhcp3 ii libc6 2.7-10 GNU C Library: Shared libraries dhcp3-client recommends no packages. -- debconf information: dhcp3-client/dhclient-needs-restarting: dhcp3-client/dhclient-script_moved:
# HG changeset patch # User Inaky Perez-Gonzalez <[EMAIL PROTECTED]> # Date 1212012744 25200 # Node ID c797fa7b439eddfdc00b8faa4847e1ad2a7f79c0 # Parent 57933cfa0655aca219307017ddc9f7d9e7abbd07 dhcp: use struct hardware->htype instead of hbuf[0] for the hardware type struct hardware->hbuf[0] is a byte, and thus, it can't contain a longer ARPHRD_ / HTYPE value than 255 (as for example, Linux dummy entries for non-ARP hardware). Many different hardware types, as well as network technologies that have no hardware header rely on these values. To solve it, create struct hardware->htype with a bigger type and use that to storee type/arphdr types instead of hbuf[0]. In order not to change a huge amount of code, let hbuf[] be one based, just ignoring hbuf[0]. diff -r 57933cfa0655 -r c797fa7b439e client/dhclient.c --- a/client/dhclient.c Wed May 28 15:04:59 2008 -0700 +++ b/client/dhclient.c Wed May 28 15:12:24 2008 -0700 @@ -1972,7 +1972,7 @@ void make_discover (client, lease) client -> packet_length = BOOTP_MIN_LEN; client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; + client -> packet.htype = client -> interface -> hw_address.htype; client -> packet.hlen = client -> interface -> hw_address.hlen - 1; client -> packet.hops = 0; client -> packet.xid = random (); @@ -2048,7 +2048,7 @@ void make_request (client, lease) client -> packet_length = BOOTP_MIN_LEN; client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; + client -> packet.htype = client -> interface -> hw_address.htype; client -> packet.hlen = client -> interface -> hw_address.hlen - 1; client -> packet.hops = 0; client -> packet.xid = client -> xid; @@ -2120,7 +2120,7 @@ void make_decline (client, lease) option_state_dereference (&options, MDL); client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; + client -> packet.htype = client -> interface -> hw_address.htype; client -> packet.hlen = client -> interface -> hw_address.hlen - 1; client -> packet.hops = 0; client -> packet.xid = client -> xid; @@ -2184,7 +2184,7 @@ void make_release (client, lease) option_state_dereference (&options, MDL); client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; + client -> packet.htype = client -> interface -> hw_address.htype; client -> packet.hlen = client -> interface -> hw_address.hlen - 1; client -> packet.hops = 0; client -> packet.xid = random (); diff -r 57933cfa0655 -r c797fa7b439e common/bpf.c --- a/common/bpf.c Wed May 28 15:04:59 2008 -0700 +++ b/common/bpf.c Wed May 28 15:12:24 2008 -0700 @@ -132,7 +132,7 @@ void if_register_send (info) if (!quiet_interface_discovery) log_info ("Sending on BPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -153,7 +153,7 @@ void if_deregister_send (info) if (!quiet_interface_discovery) log_info ("Disabling output on BPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -311,7 +311,7 @@ void if_register_receive (info) if (!quiet_interface_discovery) log_info ("Listening on BPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -328,7 +328,7 @@ void if_deregister_receive (info) if (!quiet_interface_discovery) log_info ("Disabling input on BPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), diff -r 57933cfa0655 -r c797fa7b439e common/ctrace.c --- a/common/ctrace.c Wed May 28 15:04:59 2008 -0700 +++ b/common/ctrace.c Wed May 28 15:12:24 2008 -0700 @@ -113,7 +113,7 @@ void trace_interface_input (trace_type_t if (!quiet_interface_discovery) { log_info ("Listening on Trace/%s/%s%s%s", ip -> name, - print_hw_addr (ip -> hw_address.hbuf [0], + print_hw_addr (ip -> hw_address.htype, ip -> hw_address.hlen - 1, &ip -> hw_address.hbuf [1]), (ip -> shared_network ? "/" : ""), @@ -122,7 +122,7 @@ void trace_interface_input (trace_type_t if (strcmp (ip -> name, "fallback")) { log_info ("Sending on Trace/%s/%s%s%s", ip -> name, - print_hw_addr (ip -> hw_address.hbuf [0], + print_hw_addr (ip -> hw_address.htype, ip -> hw_address.hlen - 1, &ip -> hw_address.hbuf [1]), (ip -> shared_network ? "/" : ""), diff -r 57933cfa0655 -r c797fa7b439e common/discover.c --- a/common/discover.c Wed May 28 15:04:59 2008 -0700 +++ b/common/discover.c Wed May 28 15:12:24 2008 -0700 @@ -289,7 +289,7 @@ void discover_interfaces (state) #else tmp -> hw_address.hlen = 6; /* XXX!!! */ #endif - tmp -> hw_address.hbuf [0] = HTYPE_ETHER; /* XXX */ + tmp -> hw_address.htype = HTYPE_ETHER; /* XXX */ memcpy (&tmp -> hw_address.hbuf [1], LLADDR (foo), tmp -> hw_address.hlen); tmp -> hw_address.hlen++; /* for type. */ @@ -483,7 +483,7 @@ void discover_interfaces (state) case ARPHRD_ETHER: tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_ETHER; + tmp -> hw_address.htype = ARPHRD_ETHER; memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); break; @@ -495,7 +495,7 @@ void discover_interfaces (state) #endif case ARPHRD_IEEE802: tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_IEEE802; + tmp -> hw_address.htype = ARPHRD_IEEE802; memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); break; @@ -504,22 +504,22 @@ void discover_interfaces (state) #endif case ARPHRD_FDDI: tmp -> hw_address.hlen = 17; - tmp -> hw_address.hbuf [0] = HTYPE_FDDI; /* XXX */ + tmp -> hw_address.htype = HTYPE_FDDI; /* XXX */ memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 16); break; #ifdef HAVE_ARPHRD_METRICOM case ARPHRD_METRICOM: tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_METRICOM; - memcpy (&tmp -> hw_address.hbuf [0], sa.sa_data, 6); + tmp -> hw_address.htype = ARPHRD_METRICOM; + memcpy (&tmp -> hw_address.htype, sa.sa_data, 6); break; #endif #ifdef HAVE_ARPHRD_AX25 case ARPHRD_AX25: tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_AX25; + tmp -> hw_address.htype = ARPHRD_AX25; memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); break; #endif @@ -527,7 +527,7 @@ void discover_interfaces (state) #ifdef HAVE_ARPHRD_NETROM case ARPHRD_NETROM: tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_NETROM; + tmp -> hw_address.htype = ARPHRD_NETROM; memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); break; #endif diff -r 57933cfa0655 -r c797fa7b439e common/dlpi.c --- a/common/dlpi.c Wed May 28 15:04:59 2008 -0700 +++ b/common/dlpi.c Wed May 28 15:12:24 2008 -0700 @@ -209,14 +209,14 @@ int if_register_dlpi (info) switch (dlp -> info_ack.dl_mac_type) { case DL_CSMACD: /* IEEE 802.3 */ case DL_ETHER: - info -> hw_address.hbuf [0] = HTYPE_ETHER; + info -> hw_address.htype = HTYPE_ETHER; break; /* adding token ring 5/1999 - [EMAIL PROTECTED] */ case DL_TPR: - info -> hw_address.hbuf [0] = HTYPE_IEEE802; + info -> hw_address.htype = HTYPE_IEEE802; break; case DL_FDDI: - info -> hw_address.hbuf [0] = HTYPE_FDDI; + info -> hw_address.htype = HTYPE_FDDI; break; default: log_fatal ("%s: unsupported DLPI MAC type %ld", @@ -349,7 +349,7 @@ void if_register_send (info) if (!quiet_interface_discovery) log_info ("Sending on DLPI/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -379,7 +379,7 @@ void if_deregister_send (info) if (!quiet_interface_discovery) log_info ("Disabling output on DLPI/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -464,7 +464,7 @@ void if_register_receive (info) if (!quiet_interface_discovery) log_info ("Listening on DLPI/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -494,7 +494,7 @@ void if_deregister_receive (info) if (!quiet_interface_discovery) log_info ("Disabling input on DLPI/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -646,7 +646,7 @@ ssize_t receive_packet (interface, buf, int phys_len = interface -> hw_address.hlen - 1; if (hfrom && (srcaddrlen == ABS (sap_len) + phys_len )) { - hfrom -> hbuf [0] = interface -> hw_address.hbuf [0]; + hfrom -> htype = interface -> hw_address.htype; hfrom -> hlen = interface -> hw_address.hlen; if (sap_len < 0) { diff -r 57933cfa0655 -r c797fa7b439e common/ethernet.c --- a/common/ethernet.c Wed May 28 15:04:59 2008 -0700 +++ b/common/ethernet.c Wed May 28 15:12:24 2008 -0700 @@ -90,7 +90,7 @@ ssize_t decode_ethernet_header (interfac return -1; #endif memcpy (&from -> hbuf [1], eh.ether_shost, sizeof (eh.ether_shost)); - from -> hbuf [0] = ARPHRD_ETHER; + from -> htype = ARPHRD_ETHER; from -> hlen = (sizeof eh.ether_shost) + 1; return ETHER_HEADER_SIZE; diff -r 57933cfa0655 -r c797fa7b439e common/fddi.c --- a/common/fddi.c Wed May 28 15:04:59 2008 -0700 +++ b/common/fddi.c Wed May 28 15:12:24 2008 -0700 @@ -89,7 +89,7 @@ ssize_t decode_fddi_header (interface, b struct fddi_header fh; struct llc lh; - from -> hbuf [0] = HTYPE_FDDI; + from -> htype = HTYPE_FDDI; memcpy (&from -> hbuf [1], fh.fddi_shost, sizeof fh.fddi_shost); return FDDI_HEADER_SIZE + LLC_SNAP_LEN; } diff -r 57933cfa0655 -r c797fa7b439e common/lpf.c --- a/common/lpf.c Wed May 28 15:04:59 2008 -0700 +++ b/common/lpf.c Wed May 28 15:12:24 2008 -0700 @@ -125,7 +125,7 @@ void if_register_send (info) if (!quiet_interface_discovery) log_info ("Sending on LPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -147,7 +147,7 @@ void if_deregister_send (info) if (!quiet_interface_discovery) log_info ("Disabling output on LPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -177,7 +177,7 @@ void if_register_receive (info) info -> rfdesc = if_register_lpf (info); #if defined (HAVE_TR_SUPPORT) - if (info -> hw_address.hbuf [0] == HTYPE_IEEE802) + if (info -> hw_address.htype == HTYPE_IEEE802) lpf_tr_filter_setup (info); else #endif @@ -186,7 +186,7 @@ void if_register_receive (info) if (!quiet_interface_discovery) log_info ("Listening on LPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -204,7 +204,7 @@ void if_deregister_receive (info) if (!quiet_interface_discovery) log_info ("Disabling input on LPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), diff -r 57933cfa0655 -r c797fa7b439e common/nit.c --- a/common/nit.c Wed May 28 15:04:59 2008 -0700 +++ b/common/nit.c Wed May 28 15:12:24 2008 -0700 @@ -110,7 +110,7 @@ int if_register_nit (info) /* XXX code below assumes ethernet interface! */ info -> hw_address.hlen = 7; - info -> hw_address.hbuf [0] = ARPHRD_ETHER; + info -> hw_address.htype = ARPHRD_ETHER; memcpy (&info -> hw_address.hbuf [1], ifr.ifr_ifru.ifru_addr.sa_data, 6); @@ -150,7 +150,7 @@ void if_register_send (info) #endif if (!quiet_interface_discovery) log_info ("Sending on NIT/%s%s%s", - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -169,7 +169,7 @@ void if_deregister_send (info) info -> wfdesc = -1; if (!quiet_interface_discovery) log_info ("Disabling output on NIT/%s%s%s", - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -253,7 +253,7 @@ void if_register_receive (info) if (!quiet_interface_discovery) log_info ("Listening on NIT/%s%s%s", - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -271,7 +271,7 @@ void if_deregister_receive (info) if (!quiet_interface_discovery) log_info ("Disabling input on NIT/%s%s%s", - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), diff -r 57933cfa0655 -r c797fa7b439e common/packet.c --- a/common/packet.c Wed May 28 15:04:59 2008 -0700 +++ b/common/packet.c Wed May 28 15:12:24 2008 -0700 @@ -111,12 +111,12 @@ void assemble_hw_header (interface, buf, struct hardware *to; { #if defined (HAVE_TR_SUPPORT) - if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802) + if (interface -> hw_address.htype == HTYPE_IEEE802) assemble_tr_header (interface, buf, bufix, to); else #endif #if defined (DEC_FDDI) - if (interface -> hw_address.hbuf [0] == HTYPE_FDDI) + if (interface -> hw_address.htype == HTYPE_FDDI) assemble_fddi_header (interface, buf, bufix, to); else #endif @@ -196,12 +196,12 @@ ssize_t decode_hw_header (interface, buf struct hardware *from; { #if defined (HAVE_TR_SUPPORT) - if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802) + if (interface -> hw_address.htype == HTYPE_IEEE802) return decode_tr_header (interface, buf, bufix, from); else #endif #if defined (DEC_FDDI) - if (interface -> hw_address.hbuf [0] == HTYPE_FDDI) + if (interface -> hw_address.htype == HTYPE_FDDI) return decode_fddi_header (interface, buf, bufix, from); else #endif diff -r 57933cfa0655 -r c797fa7b439e common/parse.c --- a/common/parse.c Wed May 28 15:04:59 2008 -0700 +++ b/common/parse.c Wed May 28 15:12:24 2008 -0700 @@ -430,17 +430,17 @@ void parse_hardware_param (cfile, hardwa token = next_token (&val, (unsigned *)0, cfile); switch (token) { case ETHERNET: - hardware -> hbuf [0] = HTYPE_ETHER; + hardware -> htype = HTYPE_ETHER; break; case TOKEN_RING: - hardware -> hbuf [0] = HTYPE_IEEE802; + hardware -> htype = HTYPE_IEEE802; break; case FDDI: - hardware -> hbuf [0] = HTYPE_FDDI; + hardware -> htype = HTYPE_FDDI; break; default: if (!strncmp (val, "unknown-", 8)) { - hardware -> hbuf [0] = atoi (&val [8]); + hardware -> htype = atoi (&val [8]); } else { parse_warn (cfile, "expecting a network hardware type"); diff -r 57933cfa0655 -r c797fa7b439e common/print.c --- a/common/print.c Wed May 28 15:04:59 2008 -0700 +++ b/common/print.c Wed May 28 15:12:24 2008 -0700 @@ -209,7 +209,7 @@ void print_lease (lease) if (lease -> hardware_addr.hlen) log_debug (" hardware addr = %s", - print_hw_addr (lease -> hardware_addr.hbuf [0], + print_hw_addr (lease -> hardware_addr.htype, lease -> hardware_addr.hlen - 1, &lease -> hardware_addr.hbuf [1])); log_debug (" host %s ", diff -r 57933cfa0655 -r c797fa7b439e common/upf.c --- a/common/upf.c Wed May 28 15:04:59 2008 -0700 +++ b/common/upf.c Wed May 28 15:12:24 2008 -0700 @@ -114,7 +114,7 @@ int if_register_upf (info) info -> name, param.end_addr_len); info -> hw_address.hlen = 7; - info -> hw_address.hbuf [0] = ARPHRD_ETHER; + info -> hw_address.htype = ARPHRD_ETHER; memcpy (&info -> hw_address.hbuf [1], param.end_addr, 6); return sock; @@ -135,7 +135,7 @@ void if_register_send (info) if (!quiet_interface_discovery) log_info ("Sending on UPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -153,7 +153,7 @@ void if_deregister_send (info) if (!quiet_interface_discovery) log_info ("Disabling output on UPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -219,7 +219,7 @@ void if_register_receive (info) if (!quiet_interface_discovery) log_info ("Listening on UPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), @@ -235,7 +235,7 @@ void if_deregister_receive (info) if (!quiet_interface_discovery) log_info ("Disabling input on UPF/%s/%s%s%s", info -> name, - print_hw_addr (info -> hw_address.hbuf [0], + print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen - 1, &info -> hw_address.hbuf [1]), (info -> shared_network ? "/" : ""), diff -r 57933cfa0655 -r c797fa7b439e includes/dhcpd.h --- a/includes/dhcpd.h Wed May 28 15:04:59 2008 -0700 +++ b/includes/dhcpd.h Wed May 28 15:12:24 2008 -0700 @@ -355,11 +355,15 @@ struct packet { isc_boolean_t agent_options_stashed; }; -/* A network interface's MAC address. */ - +/* A network interface's MAC address. + * + * + * NOTE: hbuf is one based (before it was the htype) + */ struct hardware { u_int8_t hlen; - u_int8_t hbuf [17]; + u_int16_t htype; + u_int8_t hbuf [17]; /* 1 based!! */ }; typedef enum { diff -r 57933cfa0655 -r c797fa7b439e relay/dhcrelay.c --- a/relay/dhcrelay.c Wed May 28 15:04:59 2008 -0700 +++ b/relay/dhcrelay.c Wed May 28 15:12:24 2008 -0700 @@ -381,7 +381,7 @@ void relay (ip, packet, length, from_por #endif memcpy (&hto.hbuf [1], packet -> chaddr, packet -> hlen); - hto.hbuf [0] = packet -> htype; + hto.htype = packet -> htype; hto.hlen = packet -> hlen + 1; /* Wipe out the agent relay options and, if possible, figure diff -r 57933cfa0655 -r c797fa7b439e server/bootp.c --- a/server/bootp.c Wed May 28 15:04:59 2008 -0700 +++ b/server/bootp.c Wed May 28 15:12:24 2008 -0700 @@ -322,7 +322,7 @@ void bootp (packet) option_state_dereference (&options, MDL); /* Set up the hardware destination address... */ - hto.hbuf [0] = packet -> raw -> htype; + hto.htype = packet -> raw -> htype; hto.hlen = packet -> raw -> hlen + 1; memcpy (&hto.hbuf [1], packet -> raw -> chaddr, packet -> raw -> hlen); diff -r 57933cfa0655 -r c797fa7b439e server/db.c --- a/server/db.c Wed May 28 15:04:59 2008 -0700 +++ b/server/db.c Wed May 28 15:12:24 2008 -0700 @@ -140,8 +140,8 @@ int write_lease (lease) if (lease -> hardware_addr.hlen) { errno = 0; fprintf (db_file, "\n hardware %s %s;", - hardware_types [lease -> hardware_addr.hbuf [0]], - print_hw_addr (lease -> hardware_addr.hbuf [0], + hardware_types [lease -> hardware_addr.htype], + print_hw_addr (lease -> hardware_addr.htype, lease -> hardware_addr.hlen - 1, &lease -> hardware_addr.hbuf [1])); if (errno) @@ -308,8 +308,8 @@ int write_host (host) if (host -> interface.hlen) { errno = 0; fprintf (db_file, "\n hardware %s %s;", - hardware_types [host -> interface.hbuf [0]], - print_hw_addr (host -> interface.hbuf [0], + hardware_types [host -> interface.htype], + print_hw_addr (host -> interface.htype, host -> interface.hlen - 1, &host -> interface.hbuf [1])); if (errno) diff -r 57933cfa0655 -r c797fa7b439e server/dhcp.c --- a/server/dhcp.c Wed May 28 15:04:59 2008 -0700 +++ b/server/dhcp.c Wed May 28 15:12:24 2008 -0700 @@ -170,7 +170,7 @@ void dhcp (packet) } data_string_forget (&data, MDL); } else - if ((lease -> hardware_addr.hbuf [0] != + if ((lease -> hardware_addr.htype != packet -> raw -> htype) || (lease -> hardware_addr.hlen - 1 != packet -> raw -> hlen) || @@ -726,7 +726,7 @@ void dhcprelease (packet, ms_nulltp) /* If the hardware address doesn't match, don't do the release. */ if (lease && (lease -> hardware_addr.hlen != packet -> raw -> hlen + 1 || - lease -> hardware_addr.hbuf [0] != packet -> raw -> htype || + lease -> hardware_addr.htype != packet -> raw -> htype || memcmp (&lease -> hardware_addr.hbuf [1], packet -> raw -> chaddr, packet -> raw -> hlen))) lease_dereference (&lease, MDL); @@ -1389,7 +1389,7 @@ void nak_lease (packet, cip) #endif #if 0 - hto.hbuf [0] = packet -> raw -> htype; + hto.htype = packet -> raw -> htype; hto.hlen = packet -> raw -> hlen; memcpy (&hto.hbuf [1], packet -> raw -> chaddr, hto.hlen); hto.hlen++; @@ -2313,7 +2313,7 @@ void ack_lease (packet, lease, offer, wh /* Record the hardware address, if given... */ lt -> hardware_addr.hlen = packet -> raw -> hlen + 1; - lt -> hardware_addr.hbuf [0] = packet -> raw -> htype; + lt -> hardware_addr.htype = packet -> raw -> htype; memcpy (< -> hardware_addr.hbuf [1], packet -> raw -> chaddr, sizeof packet -> raw -> chaddr); @@ -2351,7 +2351,7 @@ void ack_lease (packet, lease, offer, wh /* Copy the hardware address into the static lease structure. */ lease -> hardware_addr.hlen = packet -> raw -> hlen + 1; - lease -> hardware_addr.hbuf [0] = packet -> raw -> htype; + lease -> hardware_addr.htype = packet -> raw -> htype; memcpy (&lease -> hardware_addr.hbuf [1], packet -> raw -> chaddr, sizeof packet -> raw -> chaddr); /* XXX */ @@ -2813,7 +2813,7 @@ void dhcp_reply (lease) memcpy (raw.chaddr, &lease -> hardware_addr.hbuf [1], sizeof raw.chaddr); raw.hlen = lease -> hardware_addr.hlen - 1; - raw.htype = lease -> hardware_addr.hbuf [0]; + raw.htype = lease -> hardware_addr.htype; /* See if this is a Microsoft client that NUL-terminates its strings and expects us to do likewise... */ @@ -2865,7 +2865,7 @@ void dhcp_reply (lease) : "BOOTREPLY"), piaddr (lease -> ip_addr), (lease -> hardware_addr.hlen - ? print_hw_addr (lease -> hardware_addr.hbuf [0], + ? print_hw_addr (lease -> hardware_addr.htype, lease -> hardware_addr.hlen - 1, &lease -> hardware_addr.hbuf [1]) : print_hex_1(lease->uid_len, lease->uid, 60)), @@ -3188,7 +3188,7 @@ int find_lease (struct lease **lp, * the first one found is the best one. */ h.hlen = packet -> raw -> hlen + 1; - h.hbuf [0] = packet -> raw -> htype; + h.htype = packet -> raw -> htype; memcpy (&h.hbuf [1], packet -> raw -> chaddr, packet -> raw -> hlen); find_lease_by_hw_addr (&hw_lease, h.hbuf, h.hlen, MDL); while (hw_lease) { @@ -3304,7 +3304,7 @@ int find_lease (struct lease **lp, ip_lease -> uid_len != client_identifier.len || memcmp (ip_lease -> uid, client_identifier.data, ip_lease -> uid_len)) : - (ip_lease -> hardware_addr.hbuf [0] != packet -> raw -> htype || + (ip_lease -> hardware_addr.htype != packet -> raw -> htype || ip_lease -> hardware_addr.hlen != packet -> raw -> hlen + 1 || memcmp (&ip_lease -> hardware_addr.hbuf [1], packet -> raw -> chaddr, diff -r 57933cfa0655 -r c797fa7b439e server/dhcpleasequery.c --- a/server/dhcpleasequery.c Wed May 28 15:04:59 2008 -0700 +++ b/server/dhcpleasequery.c Wed May 28 15:12:24 2008 -0700 @@ -314,7 +314,7 @@ dhcpleasequery(struct packet *packet, in } h.hlen = packet->raw->hlen + 1; - h.hbuf[0] = packet->raw->htype; + h.htype = packet->raw->htype; memcpy(&h.hbuf[1], packet->raw->chaddr, packet->raw->hlen); @@ -322,7 +322,7 @@ dhcpleasequery(struct packet *packet, in snprintf(dbg_info, sizeof(dbg_info), "MAC address %s", - print_hw_addr(h.hbuf[0], + print_hw_addr(h.htype, h.hlen - 1, &h.hbuf[1])); @@ -391,7 +391,7 @@ dhcpleasequery(struct packet *packet, in */ packet->raw->hlen = lease->hardware_addr.hlen - 1; - packet->raw->htype = lease->hardware_addr.hbuf[0]; + packet->raw->htype = lease->hardware_addr.htype; memcpy(packet->raw->chaddr, &lease->hardware_addr.hbuf[1], sizeof(packet->raw->chaddr)); diff -r 57933cfa0655 -r c797fa7b439e server/mdb.c --- a/server/mdb.c Wed May 28 15:04:59 2008 -0700 +++ b/server/mdb.c Wed May 28 15:12:24 2008 -0700 @@ -456,7 +456,7 @@ int find_hosts_by_haddr (struct host_dec struct hardware h; h.hlen = hlen + 1; - h.hbuf [0] = htype; + h.htype = htype; memcpy (&h.hbuf [1], haddr, hlen); return host_hash_lookup (hp, host_hw_addr_hash, diff -r 57933cfa0655 -r c797fa7b439e server/omapi.c --- a/server/omapi.c Wed May 28 15:04:59 2008 -0700 +++ b/server/omapi.c Wed May 28 15:12:24 2008 -0700 @@ -377,7 +377,7 @@ isc_result_t dhcp_lease_get_value (omapi } else if (!omapi_ds_strcmp (name, "hardware-type")) { if (lease -> hardware_addr.hlen) return omapi_make_int_value - (value, name, lease -> hardware_addr.hbuf [0], + (value, name, lease -> hardware_addr.htype, MDL); return ISC_R_NOTFOUND; } else if (lease -> scope) { @@ -619,7 +619,7 @@ isc_result_t dhcp_lease_stuff_values (om if (status != ISC_R_SUCCESS) return status; status = omapi_connection_put_uint32 - (c, lease -> hardware_addr.hbuf [0]); + (c, lease -> hardware_addr.htype); if (status != ISC_R_SUCCESS) return status; } @@ -994,7 +994,7 @@ isc_result_t dhcp_host_set_value (omapi type = value -> u.integer; else return ISC_R_INVALIDARG; - host -> interface.hbuf [0] = type; + host -> interface.htype = type; return ISC_R_SUCCESS; } @@ -1156,7 +1156,7 @@ isc_result_t dhcp_host_get_value (omapi_ if (!host -> interface.hlen) return ISC_R_NOTFOUND; return omapi_make_int_value (value, name, - host -> interface.hbuf [0], MDL); + host -> interface.htype, MDL); } /* Try to find some inner object that can take the value. */ @@ -1332,7 +1332,7 @@ isc_result_t dhcp_host_stuff_values (oma if (status != ISC_R_SUCCESS) return status; status = (omapi_connection_put_uint32 - (c, host -> interface.hbuf [0])); + (c, host -> interface.htype)); if (status != ISC_R_SUCCESS) return status; }
# HG changeset patch # User Inaky Perez-Gonzalez <[EMAIL PROTECTED]> # Date 1212037710 25200 # Node ID c8f228cabdf30436397f89245bad437a2ed3ead6 # Parent c797fa7b439eddfdc00b8faa4847e1ad2a7f79c0 dhcp: recognize pure IP devices (ARPHRD_NONE) This patch modifies the common code to recognize devices that present no hardware header (pure IP devices). For that, we need to: - When using the BPF or LPF code for receiving, patch the BPF program to ignore the check for a hw header and then patch the byte offsets to account for the missing 14 missing from the defaultly assumed ethernet header. - In discover.c, we set by default the default mac address len for this interfaces to 6. To be done how to automatically guess it. - In packet.c, teach {decode,assemble}_hw_header() to not do anything for ARPHRD_NONE, as there is nothing to encode/decode. Signed-off-by: Inaky Perez-Gonzalez <[EMAIL PROTECTED]> diff -r c797fa7b439e -r c8f228cabdf3 common/bpf.c --- a/common/bpf.c Wed May 28 15:12:24 2008 -0700 +++ b/common/bpf.c Wed May 28 22:08:30 2008 -0700 @@ -165,7 +165,13 @@ void if_deregister_send (info) #if defined (USE_BPF_RECEIVE) || defined (USE_LPF_RECEIVE) /* Packet filter program... XXX Changes to the filter program may require changes to the constant - offsets used in if_register_send to patch the BPF program! XXX */ + offsets used in if_register_send to patch the BPF program! XXX + + APRHRD_NONE devices require (as other hw types which have different + sizes) patching to this program. We'll just patch the second + instructions to jump always to the same place (thus ignoring the hw + header check) and then adjusting the offsets. + */ struct bpf_insn dhcp_bpf_filter [] = { /* Make sure this is an IP packet... */ @@ -299,7 +305,26 @@ void if_register_receive (info) p.bf_insns = bpf_fddi_filter; } else #endif /* DEC_FDDI */ - p.bf_insns = dhcp_bpf_filter; + if (info -> hw_address.htype == ARPHRD_NONE) { + /* Patch the BPF program to account for the lack + of hw-specific headers (-14). + If the device has no ARP headers, don't assume there + is an ethernet header on the front; we just patch + the BPF program to ignore the hw header (don't + really jump) and adjust the offsets to account for + the lack of the hw header. + XXX changes to filter program may require changes to + XXX the insn number(s) used below! */ + dhcp_bpf_filter [1].jf = 0; + dhcp_bpf_filter [2].k -= 14; + dhcp_bpf_filter [4].k -= 14; + dhcp_bpf_filter [6].k -= 14; + dhcp_bpf_filter [7].k -= 14; + + p.bf_insns = dhcp_bpf_filter; + } + else + p.bf_insns = dhcp_bpf_filter; /* Patch the server port into the BPF program... XXX changes to filter program may require changes diff -r c797fa7b439e -r c8f228cabdf3 common/discover.c --- a/common/discover.c Wed May 28 15:12:24 2008 -0700 +++ b/common/discover.c Wed May 28 22:08:30 2008 -0700 @@ -531,6 +531,13 @@ void discover_interfaces (state) memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); break; #endif + + case ARPHRD_NONE: + /* XXX: is there a way to find HLEN instead of hardcoding 6? */ + tmp -> hw_address.hlen = 7; + tmp -> hw_address.htype = ARPHRD_NONE; + memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); + break; default: log_error ("%s: unknown hardware address type %d", diff -r c797fa7b439e -r c8f228cabdf3 common/lpf.c --- a/common/lpf.c Wed May 28 15:12:24 2008 -0700 +++ b/common/lpf.c Wed May 28 22:08:30 2008 -0700 @@ -226,6 +226,22 @@ static void lpf_gen_filter_setup (info) XXX changes to filter program may require changes to the insn number(s) used below! XXX */ dhcp_bpf_filter [8].k = ntohs ((short)local_port); + /* Patch the BPF program to account for the lack + of hw-specific headers (-14). + If the device has no ARP headers, don't assume there + is an ethernet header on the front; we just patch + the BPF program to ignore the hw header (don't + really jump) and adjust the offsets to account for + the lack of the hw header. + XXX changes to filter program may require changes to + XXX the insn number(s) used below! */ + if (info -> hw_address.htype == ARPHRD_NONE) { + dhcp_bpf_filter [1].jf = 0; + dhcp_bpf_filter [2].k -= 14; + dhcp_bpf_filter [4].k -= 14; + dhcp_bpf_filter [6].k -= 14; + dhcp_bpf_filter [7].k -= 14; + } if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p, sizeof p) < 0) { diff -r c797fa7b439e -r c8f228cabdf3 common/packet.c --- a/common/packet.c Wed May 28 15:12:24 2008 -0700 +++ b/common/packet.c Wed May 28 22:08:30 2008 -0700 @@ -120,6 +120,9 @@ void assemble_hw_header (interface, buf, assemble_fddi_header (interface, buf, bufix, to); else #endif + if (interface -> hw_address.htype == ARPHRD_NONE) + do {} while(0); /* Pure IP, no hw header needed */ + else assemble_ethernet_header (interface, buf, bufix, to); } @@ -205,6 +208,9 @@ ssize_t decode_hw_header (interface, buf return decode_fddi_header (interface, buf, bufix, from); else #endif + if (interface -> hw_address.htype == ARPHRD_NONE) + return 0; /* Pure IP device, no hw header */ + else return decode_ethernet_header (interface, buf, bufix, from); }