diff -ur dhcp-3.0-unaltered/client/dhclient.c dhcp-3.0-new/client/dhclient.c --- dhcp-3.0-unaltered/client/dhclient.c Wed Aug 8 10:46:14 2001 +++ dhcp-3.0-new/client/dhclient.c Sat Oct 20 20:50:29 2001 @@ -1865,7 +1865,7 @@ cons_options ((struct packet *)0, &client -> packet, (struct lease *)0, client, 0, (struct option_state *)0, options, - &global_scope, 0, 0, 0, (struct data_string *)0, + &global_scope, 0, 0, 0, 0, (struct data_string *)0, client -> config -> vendor_space_name); if (client -> packet_length < BOOTP_MIN_LEN) client -> packet_length = BOOTP_MIN_LEN; @@ -1931,7 +1931,7 @@ cons_options ((struct packet *)0, &client -> packet, (struct lease *)0, client, 0, (struct option_state *)0, client -> sent_options, - &global_scope, 0, 0, 0, (struct data_string *)0, + &global_scope, 0, 0, 0, 0, (struct data_string *)0, client -> config -> vendor_space_name); if (client -> packet_length < BOOTP_MIN_LEN) client -> packet_length = BOOTP_MIN_LEN; @@ -2001,7 +2001,7 @@ cons_options ((struct packet *)0, &client -> packet, (struct lease *)0, client, 0, (struct option_state *)0, options, - &global_scope, 0, 0, 0, (struct data_string *)0, + &global_scope, 0, 0, 0, 0, (struct data_string *)0, client -> config -> vendor_space_name); if (client -> packet_length < BOOTP_MIN_LEN) client -> packet_length = BOOTP_MIN_LEN; @@ -2058,7 +2058,7 @@ cons_options ((struct packet *)0, &client -> packet, (struct lease *)0, client, 0, (struct option_state *)0, options, - &global_scope, 0, 0, 0, (struct data_string *)0, + &global_scope, 0, 0, 0, 0, (struct data_string *)0, client -> config -> vendor_space_name); if (client -> packet_length < BOOTP_MIN_LEN) client -> packet_length = BOOTP_MIN_LEN; diff -ur dhcp-3.0-unaltered/common/options.c dhcp-3.0-new/common/options.c --- dhcp-3.0-unaltered/common/options.c Thu Aug 23 12:11:34 2001 +++ dhcp-3.0-new/common/options.c Thu Dec 6 21:56:55 2001 @@ -427,7 +427,7 @@ int cons_options (inpacket, outpacket, lease, client_state, mms, in_options, cfg_options, - scope, overload, terminate, bootpp, prl, vuname) + scope, overload, terminate, bootpp, macncboot, prl, vuname) struct packet *inpacket; struct dhcp_packet *outpacket; struct lease *lease; @@ -439,6 +439,7 @@ int overload; /* Overload flags that may be set. */ int terminate; int bootpp; + int macncboot; struct data_string *prl; const char *vuname; { @@ -474,6 +475,21 @@ data_string_forget (&ds, MDL); } + /* Added for Mac NC to increase max packet size for return + Check to see if above set mms for future if Apple decides + To use industry standards to notify dhcpd of max packet size + Does anyone what the real max is for NetBooting Macs? + I know it is bad to make a guess and make it bigger than it + should be but it works for now. If anyone knows it, let me know! + This only applies to bootp requests and not dhcp requests. */ + if (!mms && inpacket && + (op = lookup_option (&dhcp_universe, inpacket -> options, + DHO_MAC_NC_CLIENT_ID)) && + (!strcmp (op->data.data, "Apple MacNC"))) { + log_info("Received BootP request from Macintosh netboot client"); + mms = 576; + } + /* If the client has provided a maximum DHCP message size, use that; otherwise, if it's BOOTP, only 64 bytes; otherwise use up to the minimum IP MTU size (576 bytes). */ @@ -502,12 +518,30 @@ main_buffer_size = sizeof buffer; /* Preload the option priority list with mandatory options. */ + /* If we are replying to an Apple Mac NetBoot DHCP request + then we MUST set the option list appropriately or the stupid + client will not work. */ priority_len = 0; - priority_list [priority_len++] = DHO_DHCP_MESSAGE_TYPE; - priority_list [priority_len++] = DHO_DHCP_SERVER_IDENTIFIER; - priority_list [priority_len++] = DHO_DHCP_LEASE_TIME; - priority_list [priority_len++] = DHO_DHCP_MESSAGE; - priority_list [priority_len++] = DHO_DHCP_REQUESTED_ADDRESS; + if (macncboot) + { + priority_list [priority_len++] = DHO_SUBNET_MASK; + priority_list [priority_len++] = DHO_ROUTERS; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_VERSION; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_USER_NAME; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_MACHINE_NAME; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_PASSWORD; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_NB_IMG; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_APPS_IMG; + priority_list [priority_len++] = DHO_MAC_NC_SERVER_CLIENT_NB_IMG; + } + else + { + priority_list [priority_len++] = DHO_DHCP_MESSAGE_TYPE; + priority_list [priority_len++] = DHO_DHCP_SERVER_IDENTIFIER; + priority_list [priority_len++] = DHO_DHCP_LEASE_TIME; + priority_list [priority_len++] = DHO_DHCP_MESSAGE; + priority_list [priority_len++] = DHO_DHCP_REQUESTED_ADDRESS; + } if (prl && prl -> len > 0) { if ((op = lookup_option (&dhcp_universe, cfg_options, diff -ur dhcp-3.0-unaltered/common/tables.c dhcp-3.0-new/common/tables.c --- dhcp-3.0-unaltered/common/tables.c Thu Jun 21 19:50:51 2001 +++ dhcp-3.0-new/common/tables.c Sat Oct 20 20:11:18 2001 @@ -318,8 +318,8 @@ { "#217", "X", &dhcp_universe, 217 }, { "#218", "X", &dhcp_universe, 218 }, { "#219", "X", &dhcp_universe, 219 }, - { "#220", "X", &dhcp_universe, 220 }, - { "#221", "X", &dhcp_universe, 221 }, + { "mac-nc-client-unknown", "X", &dhcp_universe, 220 }, + { "mac-nc-client-id", "X", &dhcp_universe, 221 }, { "#222", "X", &dhcp_universe, 222 }, { "#223", "X", &dhcp_universe, 223 }, { "#224", "X", &dhcp_universe, 224 }, @@ -328,15 +328,15 @@ { "#227", "X", &dhcp_universe, 227 }, { "#228", "X", &dhcp_universe, 228 }, { "#229", "X", &dhcp_universe, 229 }, - { "#230", "X", &dhcp_universe, 230 }, + { "mac-version", "X", &dhcp_universe, 230 }, { "#231", "X", &dhcp_universe, 231 }, - { "#232", "X", &dhcp_universe, 232 }, - { "#233", "X", &dhcp_universe, 233 }, - { "#234", "X", &dhcp_universe, 234 }, - { "#235", "X", &dhcp_universe, 235 }, + { "mac-user-name", "X", &dhcp_universe, 232 }, + { "mac-password", "X", &dhcp_universe, 233 }, + { "mac-nb-img", "X", &dhcp_universe, 234 }, + { "mac-apps-img", "X", &dhcp_universe, 235 }, { "#236", "X", &dhcp_universe, 236 }, - { "#237", "X", &dhcp_universe, 237 }, - { "#238", "X", &dhcp_universe, 238 }, + { "mac-machine-name", "X", &dhcp_universe, 237 }, + { "mac-client-nb-img", "X", &dhcp_universe, 238 }, { "#239", "X", &dhcp_universe, 239 }, { "#240", "X", &dhcp_universe, 240 }, { "#241", "X", &dhcp_universe, 241 }, diff -ur dhcp-3.0-unaltered/includes/dhcp.h dhcp-3.0-new/includes/dhcp.h --- dhcp-3.0-unaltered/includes/dhcp.h Thu Oct 4 18:02:01 2001 +++ dhcp-3.0-new/includes/dhcp.h Sat Oct 20 20:15:22 2001 @@ -165,7 +165,15 @@ immediately and shamelessly break this, so don't count on it continuing to work. */ #define DHO_AUTHENTICATE 210 - +#define DHO_MAC_NC_CLIENT_UNKNOWN 220 +#define DHO_MAC_NC_CLIENT_ID 221 +#define DHO_MAC_NC_SERVER_VERSION 230 +#define DHO_MAC_NC_SERVER_USER_NAME 232 +#define DHO_MAC_NC_SERVER_PASSWORD 233 +#define DHO_MAC_NC_SERVER_NB_IMG 234 +#define DHO_MAC_NC_SERVER_APPS_IMG 235 +#define DHO_MAC_NC_SERVER_MACHINE_NAME 237 +#define DHO_MAC_NC_SERVER_CLIENT_NB_IMG 238 #define DHO_END 255 /* DHCP message types. */ diff -ur dhcp-3.0-unaltered/includes/dhcpd.h dhcp-3.0-new/includes/dhcpd.h --- dhcp-3.0-unaltered/includes/dhcpd.h Thu Jun 21 19:57:40 2001 +++ dhcp-3.0-new/includes/dhcpd.h Sat Oct 20 20:38:23 2001 @@ -293,7 +293,7 @@ unsigned char uid_buf [7]; struct hardware hardware_addr; - u_int8_t flags; + u_int16_t flags; # define STATIC_LEASE 1 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE) # define MS_NULL_TERMINATION 8 @@ -302,6 +302,7 @@ # define UNICAST_BROADCAST_HACK 64 # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \ UNICAST_BROADCAST_HACK) +# define MAC_NC_BOOT 256 binding_state_t __attribute__ ((mode (__byte__))) binding_state; binding_state_t __attribute__ ((mode (__byte__))) next_binding_state; @@ -946,7 +947,7 @@ struct client_state *, int, struct option_state *, struct option_state *, struct binding_scope **, - int, int, int, struct data_string *, const char *)); + int, int, int, int, struct data_string *, const char *)); int fqdn_universe_decode (struct option_state *, const unsigned char *, unsigned, struct universe *); int store_options PROTO ((unsigned char *, unsigned, struct packet *, diff -ur dhcp-3.0-unaltered/server/bootp.c dhcp-3.0-new/server/bootp.c --- dhcp-3.0-unaltered/server/bootp.c Thu Jun 21 21:49:49 2001 +++ dhcp-3.0-new/server/bootp.c Sat Oct 20 20:23:51 2001 @@ -257,7 +257,7 @@ (struct client_state *)0, 0, packet -> options, options, &lease -> scope, - 0, 0, 1, (struct data_string *)0, + 0, 0, 1, 0, (struct data_string *)0, (const char *)0); if (outgoing.packet_length < BOOTP_MIN_LEN) outgoing.packet_length = BOOTP_MIN_LEN; diff -ur dhcp-3.0-unaltered/server/dhcp.c dhcp-3.0-new/server/dhcp.c --- dhcp-3.0-unaltered/server/dhcp.c Thu Oct 4 18:21:00 2001 +++ dhcp-3.0-new/server/dhcp.c Sun Oct 21 14:17:12 2001 @@ -1171,7 +1171,7 @@ cons_options (packet, outgoing.raw, (struct lease *)0, (struct client_state *)0, 0, packet -> options, options, &global_scope, - 0, nulltp, 0, + 0, nulltp, 0, 0, prl.len ? &prl : (struct data_string *)0, (char *)0); option_state_dereference (&options, MDL); @@ -1326,7 +1326,7 @@ cons_options (packet, outgoing.raw, (struct lease *)0, (struct client_state *)0, 0, packet -> options, options, &global_scope, - 0, 0, 0, (struct data_string *)0, (char *)0); + 0, 0, 0, 0, (struct data_string *)0, (char *)0); option_state_dereference (&options, MDL); /* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/ @@ -1421,7 +1421,7 @@ struct lease *next; TIME lease_time; TIME offered_lease_time; - struct data_string d1; + struct data_string d1, d2; TIME min_lease_time; TIME max_lease_time; TIME default_lease_time; @@ -2062,6 +2062,21 @@ else lease -> flags &= ~MS_NULL_TERMINATION; + /* Set a flag if this is an Apple Mac NetBoot DHCP request. */ + oc = lookup_option (&dhcp_universe, packet -> options, + DHO_MAC_NC_CLIENT_ID); + if (oc && + evaluate_option_cache (&d2, packet, lease, + (struct client_state *)0, + packet -> options, state -> options, + &lease -> scope, oc, MDL)) + { + if (d2.data && d2.len == 11 && + !strcmp (d2.data, "Apple MacNC")) + lease -> flags |= MAC_NC_BOOT; + } else + lease -> flags &= ~MAC_NC_BOOT; + /* Save any bindings. */ if (lease -> scope) { binding_scope_reference (< -> scope, lease -> scope, MDL); @@ -2600,7 +2615,7 @@ int result; int i; struct lease_state *state = lease -> state; - int nulltp, bootpp, unicastp = 1; + int nulltp, bootpp, macncboot, unicastp = 1; struct option_tag *ot, *not; struct data_string d1; struct option_cache *oc; @@ -2651,6 +2666,12 @@ else nulltp = 0; + /* See if this is an Apple Mac NetBoot DHCP request... */ + if (lease -> flags & MAC_NC_BOOT) + macncboot = 1; + else + macncboot = 0; + /* See if this is a bootp client... */ if (state -> offer) bootpp = 0; @@ -2663,7 +2684,7 @@ state -> max_message_size, state -> packet -> options, state -> options, &global_scope, - bufs, nulltp, bootpp, + bufs, nulltp, bootpp, macncboot, &state -> parameter_request_list, (char *)0);