diff -Naur dhcp-3.0.1/client/dhclient.c dhcp-3.0.1-macnb/client/dhclient.c --- dhcp-3.0.1/client/dhclient.c 2004-07-10 00:11:16.000000000 +0000 +++ dhcp-3.0.1-macnb/client/dhclient.c 2004-11-26 09:30:26.000000000 +0000 @@ -1891,6 +1891,7 @@ /* overload */ 0, /* terminate */0, /* bootpp */0, + /* macncboot */0, (struct data_string *)0, client -> config -> vendor_space_name); @@ -1965,6 +1966,7 @@ /* overload */ 0, /* terminate */0, /* bootpp */0, + /* macncboot */0, (struct data_string *)0, client -> config -> vendor_space_name); @@ -2037,7 +2039,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); option_state_dereference (&options, MDL); if (client -> packet_length < BOOTP_MIN_LEN) @@ -2101,6 +2103,7 @@ /* overload */ 0, /* terminate */0, /* bootpp */0, + /* macncboot */0, (struct data_string *)0, client -> config -> vendor_space_name); diff -Naur dhcp-3.0.1/common/options.c dhcp-3.0.1-macnb/common/options.c --- dhcp-3.0.1/common/options.c 2004-06-10 17:59:19.000000000 +0000 +++ dhcp-3.0.1-macnb/common/options.c 2004-11-26 09:29:17.000000000 +0000 @@ -446,7 +446,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; @@ -458,6 +458,7 @@ int overload; /* Overload flags that may be set. */ int terminate; int bootpp; + int macncboot; struct data_string *prl; const char *vuname; { @@ -497,6 +498,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). */ @@ -525,13 +541,31 @@ 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; - priority_list [priority_len++] = DHO_FQDN; + 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; + priority_list [priority_len++] = DHO_FQDN; + } if (prl && prl -> len > 0) { if ((op = lookup_option (&dhcp_universe, cfg_options, diff -Naur dhcp-3.0.1/common/tables.c dhcp-3.0.1-macnb/common/tables.c --- dhcp-3.0.1/common/tables.c 2004-06-10 17:59:21.000000000 +0000 +++ dhcp-3.0.1-macnb/common/tables.c 2004-11-26 10:19:00.000000000 +0000 @@ -310,8 +310,8 @@ { "unknown-217", "X", &dhcp_universe, 217 }, { "unknown-218", "X", &dhcp_universe, 218 }, { "unknown-219", "X", &dhcp_universe, 219 }, - { "unknown-220", "X", &dhcp_universe, 220 }, - { "unknown-221", "X", &dhcp_universe, 221 }, + { "mac-nc-client-unknown", "X", &dhcp_universe, 220 }, + { "mac-nc-client-id", "X", &dhcp_universe, 221 }, { "unknown-222", "X", &dhcp_universe, 222 }, { "unknown-223", "X", &dhcp_universe, 223 }, { "unknown-224", "X", &dhcp_universe, 224 }, @@ -320,15 +320,15 @@ { "unknown-227", "X", &dhcp_universe, 227 }, { "unknown-228", "X", &dhcp_universe, 228 }, { "unknown-229", "X", &dhcp_universe, 229 }, - { "unknown-230", "X", &dhcp_universe, 230 }, + { "mac-version", "X", &dhcp_universe, 230 }, { "unknown-231", "X", &dhcp_universe, 231 }, - { "unknown-232", "X", &dhcp_universe, 232 }, - { "unknown-233", "X", &dhcp_universe, 233 }, - { "unknown-234", "X", &dhcp_universe, 234 }, - { "unknown-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 }, { "unknown-236", "X", &dhcp_universe, 236 }, - { "unknown-237", "X", &dhcp_universe, 237 }, - { "unknown-238", "X", &dhcp_universe, 238 }, + { "mac-machine-name", "X", &dhcp_universe, 237 }, + { "mac-client-nb-img", "X", &dhcp_universe, 238 }, { "unknown-239", "X", &dhcp_universe, 239 }, { "unknown-240", "X", &dhcp_universe, 240 }, { "unknown-241", "X", &dhcp_universe, 241 }, diff -Naur dhcp-3.0.1/includes/dhcp.h dhcp-3.0.1-macnb/includes/dhcp.h --- dhcp-3.0.1/includes/dhcp.h 2004-06-10 17:59:29.000000000 +0000 +++ dhcp-3.0.1-macnb/includes/dhcp.h 2004-11-26 09:29:17.000000000 +0000 @@ -156,7 +156,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 -Naur dhcp-3.0.1/includes/dhcpd.h dhcp-3.0.1-macnb/includes/dhcpd.h --- dhcp-3.0.1/includes/dhcpd.h 2004-06-10 17:59:29.000000000 +0000 +++ dhcp-3.0.1-macnb/includes/dhcpd.h 2004-11-26 09:29:17.000000000 +0000 @@ -294,7 +294,7 @@ unsigned char uid_buf [7]; struct hardware hardware_addr; - u_int8_t flags; + u_int16_t flags; # define STATIC_LEASE 1 # define BOOTP_LEASE 2 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE) @@ -305,6 +305,7 @@ # define ON_DEFERRED_QUEUE 128 # 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; @@ -970,7 +971,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 -Naur dhcp-3.0.1/server/bootp.c dhcp-3.0.1-macnb/server/bootp.c --- dhcp-3.0.1/server/bootp.c 2004-06-17 20:54:39.000000000 +0000 +++ dhcp-3.0.1-macnb/server/bootp.c 2004-11-26 09:29:17.000000000 +0000 @@ -251,7 +251,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 -Naur dhcp-3.0.1/server/dhcp.c dhcp-3.0.1-macnb/server/dhcp.c --- dhcp-3.0.1/server/dhcp.c 2004-06-17 20:54:40.000000000 +0000 +++ dhcp-3.0.1-macnb/server/dhcp.c 2004-11-26 09:29:17.000000000 +0000 @@ -1222,7 +1222,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); @@ -1390,7 +1390,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);*/ @@ -1485,7 +1485,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; @@ -2128,6 +2128,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); @@ -2689,7 +2704,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; @@ -2740,6 +2755,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; @@ -2752,7 +2773,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);