diff -ru dhcp-2.0pl5/common/options.c dhcp-2.0pl5+macdhcp/common/options.c --- dhcp-2.0pl5/common/options.c Sat Jun 24 08:24:02 2000 +++ dhcp-2.0pl5+macdhcp/common/options.c Sat Feb 3 20:44:54 2001 @@ -160,7 +160,8 @@ of vendor options using the same routine. */ int cons_options (inpacket, outpacket, mms, - options, overload, terminate, bootpp, prl, prl_len) + options, overload, terminate, bootpp, macncboot, + prl, prl_len) struct packet *inpacket; struct dhcp_packet *outpacket; int mms; @@ -168,6 +169,7 @@ int overload; /* Overload flags that may be set. */ int terminate; int bootpp; + int macncboot; u_int8_t *prl; int prl_len; { @@ -192,6 +194,22 @@ mms = getUShort (inpacket -> options [DHO_DHCP_MAX_MESSAGE_SIZE].data); + /* 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 && + inpacket -> options [DHO_MAC_NC_CLIENT_ID].data && + (strcmp (inpacket -> options [DHO_MAC_NC_CLIENT_ID].data, + "Apple Mac NC"))) { + note ("Apple Mac NetBoot BootP request"); + 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). */ @@ -208,11 +226,26 @@ 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; + 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; + } /* If the client has provided a list of options that it wishes returned, use it to prioritize. Otherwise, prioritize diff -ru dhcp-2.0pl5/common/tables.c dhcp-2.0pl5+macdhcp/common/tables.c --- dhcp-2.0pl5/common/tables.c Sat Apr 24 17:46:44 1999 +++ dhcp-2.0pl5+macdhcp/common/tables.c Sat Feb 3 16:14:47 2001 @@ -286,8 +286,8 @@ { "option-217", "X", &dhcp_universe, 217 }, { "option-218", "X", &dhcp_universe, 218 }, { "option-219", "X", &dhcp_universe, 219 }, - { "option-220", "X", &dhcp_universe, 220 }, - { "option-221", "X", &dhcp_universe, 221 }, + { "mac-nc-client-unknown", "X", &dhcp_universe, 220 }, + { "mac-nc-client-id", "t", &dhcp_universe, 221 }, { "option-222", "X", &dhcp_universe, 222 }, { "option-223", "X", &dhcp_universe, 223 }, { "option-224", "X", &dhcp_universe, 224 }, @@ -296,15 +296,15 @@ { "option-227", "X", &dhcp_universe, 227 }, { "option-228", "X", &dhcp_universe, 228 }, { "option-229", "X", &dhcp_universe, 229 }, - { "option-230", "X", &dhcp_universe, 230 }, + { "mac-version", "X", &dhcp_universe, 230 }, { "option-231", "X", &dhcp_universe, 231 }, - { "option-232", "X", &dhcp_universe, 232 }, - { "option-233", "X", &dhcp_universe, 233 }, - { "option-234", "X", &dhcp_universe, 234 }, - { "option-235", "X", &dhcp_universe, 235 }, + { "mac-user-name", "t", &dhcp_universe, 232 }, + { "mac-password", "t", &dhcp_universe, 233 }, + { "mac-nb-img", "X", &dhcp_universe, 234 }, + { "mac-apps-img", "X", &dhcp_universe, 235 }, { "option-236", "X", &dhcp_universe, 236 }, - { "option-237", "X", &dhcp_universe, 237 }, - { "option-238", "X", &dhcp_universe, 238 }, + { "mac-machine-name", "t", &dhcp_universe, 237 }, + { "mac-client-nb-img", "X", &dhcp_universe, 238 }, { "option-239", "X", &dhcp_universe, 239 }, { "option-240", "X", &dhcp_universe, 240 }, { "option-241", "X", &dhcp_universe, 241 }, @@ -385,6 +385,15 @@ DHO_FONT_SERVERS, DHO_X_DISPLAY_MANAGER, DHO_DHCP_PARAMETER_REQUEST_LIST, + DHO_MAC_NC_CLIENT_UNKNOWN, + DHO_MAC_NC_CLIENT_ID, + DHO_MAC_NC_SERVER_VERSION, + DHO_MAC_NC_SERVER_USER_NAME, + DHO_MAC_NC_SERVER_PASSWORD, + DHO_MAC_NC_SERVER_NB_IMG, + DHO_MAC_NC_SERVER_APPS_IMG, + DHO_MAC_NC_SERVER_MACHINE_NAME, + DHO_MAC_NC_SERVER_CLIENT_NB_IMG, /* Presently-undefined options... */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, @@ -399,8 +408,8 @@ 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, + 215, 216, 217, 218, 219, 222, 223, 224, 225, 226, + 227, 228, 229, 231, 235, 236, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, }; diff -ru dhcp-2.0pl5/includes/dhcp.h dhcp-2.0pl5+macdhcp/includes/dhcp.h --- dhcp-2.0pl5/includes/dhcp.h Tue Dec 22 22:46:17 1998 +++ dhcp-2.0pl5+macdhcp/includes/dhcp.h Sat Feb 3 16:13:15 2001 @@ -155,6 +155,15 @@ #define DHO_DHCP_CLASS_IDENTIFIER 60 #define DHO_DHCP_CLIENT_IDENTIFIER 61 #define DHO_DHCP_USER_CLASS_ID 77 +#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 -ru dhcp-2.0pl5/includes/dhcpd.h dhcp-2.0pl5+macdhcp/includes/dhcpd.h --- dhcp-2.0pl5/includes/dhcpd.h Thu Jul 20 06:06:47 2000 +++ dhcp-2.0pl5+macdhcp/includes/dhcpd.h Mon Jan 22 22:07:16 2001 @@ -144,6 +144,7 @@ # define EPHEMERAL_FLAGS (BOOTP_LEASE) # define MS_NULL_TERMINATION 8 # define ABANDONED_LEASE 16 +# define MAC_NC_BOOT 32 struct lease_state *state; }; @@ -475,7 +476,7 @@ void parse_options PROTO ((struct packet *)); void parse_option_buffer PROTO ((struct packet *, unsigned char *, int)); int cons_options PROTO ((struct packet *, struct dhcp_packet *, int, - struct tree_cache **, int, int, int, + struct tree_cache **, int, int, int, int, u_int8_t *, int)); int store_options PROTO ((unsigned char *, int, struct tree_cache **, unsigned char *, int, int, int, int)); diff -ru dhcp-2.0pl5/server/bootp.c dhcp-2.0pl5+macdhcp/server/bootp.c --- dhcp-2.0pl5/server/bootp.c Tue Oct 19 18:32:49 1999 +++ dhcp-2.0pl5+macdhcp/server/bootp.c Mon Jan 22 22:20:57 2001 @@ -272,7 +272,8 @@ outgoing.packet_length = cons_options (packet, outgoing.raw, - 0, options, 0, 0, 1, (u_int8_t *)0, 0); + 0, options, 0, 0, 1, 0, + (u_int8_t *)0, 0); if (outgoing.packet_length < BOOTP_MIN_LEN) outgoing.packet_length = BOOTP_MIN_LEN; } diff -ru dhcp-2.0pl5/server/dhcp.c dhcp-2.0pl5+macdhcp/server/dhcp.c --- dhcp-2.0pl5/server/dhcp.c Fri Jun 30 20:04:52 2000 +++ dhcp-2.0pl5+macdhcp/server/dhcp.c Sat Feb 3 16:44:07 2001 @@ -504,7 +504,7 @@ /* Set up the option buffer... */ outgoing.packet_length = cons_options (packet, outgoing.raw, 0, options, 0, 0, 0, - (u_int8_t *)0, 0); + 0, (u_int8_t *)0, 0); /* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/ raw.siaddr = packet -> interface -> primary_address; @@ -841,6 +841,16 @@ else lease -> flags &= ~MS_NULL_TERMINATION; + /* Set a flag if this is an Apple Mac NetBoot DHCP request. */ + if (packet -> options [DHO_MAC_NC_CLIENT_ID].data && + packet -> options [DHO_MAC_NC_CLIENT_ID].len == 11 && + !strcmp (packet->options [DHO_MAC_NC_CLIENT_ID].data, + "Apple MacNC")) { + note ("Apple Mac NetBoot DHCP request"); + lease -> flags |= MAC_NC_BOOT; + } else + lease -> flags &= ~MAC_NC_BOOT; + /* Remember the giaddr, xid, secs, flags and hops. */ state -> giaddr = packet -> raw -> giaddr; state -> ciaddr = packet -> raw -> ciaddr; @@ -1143,7 +1153,7 @@ int result; int i; struct lease_state *state = lease -> state; - int nulltp, bootpp; + int nulltp, bootpp, macncboot; u_int8_t *prl; int prl_len; @@ -1178,6 +1188,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; @@ -1202,7 +1218,8 @@ packet_length = cons_options ((struct packet *)0, &raw, state -> max_message_size, state -> options, - bufs, nulltp, bootpp, prl, prl_len); + bufs, nulltp, bootpp, macncboot, + prl, prl_len); /* Having done the cons_options(), we can release the tree_cache entries. */