Bill,
Can you apply this patch to current CVS copy of NM? It changes
dhcpcd/buildmsg.c only. It now pads the message to over 300 bytes and ensures
that the message is always an even number of bytes long.
Thanks,
Dan
On Fri, 11 Feb 2005, Bill Moss wrote:
I think older hardware may reject messages that are too short. The UDP
part of the message contains a BOOTP section of options and there was a
time when BOOTP messages had a minimize size of 300 bytes. If this is
what the SMC is doing, the a message with a UDP part of 297 bytes will
not pass muster. This is just a guess. I suppose you can pad the message
one byte at a time and see where the boundary is. I am betting on 300 or
312.
--
Bill Moss
Professor, Mathematical Sciences
Clemson University
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list
Index: dhcpcd/buildmsg.c
===
RCS file: /cvs/gnome/NetworkManager/dhcpcd/buildmsg.c,v
retrieving revision 1.5
diff -u -r1.5 buildmsg.c
--- dhcpcd/buildmsg.c 10 Feb 2005 20:54:04 - 1.5
+++ dhcpcd/buildmsg.c 12 Feb 2005 03:36:02 -
@@ -138,7 +138,8 @@
/*/
unsigned char *fill_message_type (unsigned char request, unsigned char *p)
{
- const unsigned short dhcpMsgSize = htons (sizeof (dhcpMessage));
+#define MAX_DHCP_MSG_SIZE 576
+ const unsigned short dhcpMsgSize = htons (MAX_DHCP_MSG_SIZE);
*p++ = dhcpMessageType;
*p++ = 1;
@@ -150,6 +151,15 @@
return p;
}
/*/
+unsigned char *fill_padding (dhcpMessage *start, unsigned char *p)
+{
+#define PAD_STOP 324 /* Completely arbitrary even number */
+
+ while ((char *)p - (char *)start PAD_STOP)
+ *p++ = 0;
+ return p;
+}
+/*/
udpipMessage *build_dhcp_discover (dhcp_interface *iface, int *msg_len)
{
udpipMessage*udp_msg = calloc (1, sizeof
(udpipMessage));
@@ -171,9 +181,9 @@
p = fill_param_request (p);
p = fill_host_and_class_id (iface, p);
*p++ = endOption;
+ p = fill_padding (dhcp_msg, p);
/* build UDP/IP header */
- p++;
dhcp_msg_len = (char *)p - (char *)dhcp_msg;
udpipgen ((udpiphdr *)(udp_msg-udpipmsg), 0, INADDR_BROADCAST,
iface-ip_id, dhcp_msg_len);
*msg_len = (char *)p - (char *)udp_msg;
@@ -198,10 +208,10 @@
p = fill_lease_time
(iface-dhcp_options.val[dhcpIPaddrLeaseTime], p);
p = fill_param_request (p);
p = fill_host_and_class_id (iface, p);
- *p = endOption;
+ *p++ = endOption;
+ p = fill_padding (dhcp_msg, p);
/* build UDP/IP header */
- p++;
dhcp_msg_len = (char *)p - (char *)dhcp_msg;
udpipgen ((udpiphdr *)(udp_msg-udpipmsg), 0, INADDR_BROADCAST,
iface-ip_id, dhcp_msg_len);
*msg_len = (char *)(p++) - (char *)udp_msg;
@@ -224,9 +234,10 @@
#endif
p = fill_param_request (p);
p = fill_host_and_class_id (iface, p);
- *p = endOption;
+ *p++ = endOption;
+ p = fill_padding (dhcp_msg, p);
- p++;
+ /* build UDP/IP header */
dhcp_msg_len = (char *)p - (char *)dhcp_msg;
udpipgen ((udpiphdr *)(udp_msg-udpipmsg), iface-ciaddr,
iface-siaddr, iface-ip_id, dhcp_msg_len);
*msg_len = (char *)(p++) - (char *)udp_msg;
@@ -247,10 +258,10 @@
p = fill_lease_time
(iface-dhcp_options.val[dhcpIPaddrLeaseTime], p);
p = fill_param_request (p);
p = fill_host_and_class_id (iface, p);
- *p = endOption;
+ *p++ = endOption;
+ p = fill_padding (dhcp_msg, p);
/* build UDP/IP header */
- p++;
dhcp_msg_len = (char *)p - (char *)dhcp_msg;
udpipgen ((udpiphdr *)(udp_msg-udpipmsg), iface-ciaddr,
INADDR_BROADCAST, iface-ip_id, dhcp_msg_len);
*msg_len = (char *)(p++) - (char *)udp_msg;
@@ -274,10 +285,10 @@
p = fill_lease_time (lease_time, p);
p = fill_param_request (p);
p = fill_host_and_class_id (iface, p);
- *p = endOption;
+ *p++ = endOption;
+ p = fill_padding (dhcp_msg, p);
/* build UDP/IP header */
- p++;
dhcp_msg_len = (char *)p - (char *)dhcp_msg;
udpipgen ((udpiphdr *)(udp_msg-udpipmsg), 0, INADDR_BROADCAST,
iface-ip_id, dhcp_msg_len);
*msg_len = (char *)(p++) - (char *)udp_msg;
@@ -299,10 +310,10 @@
p = fill_server_id (iface-dhcp_options.val[dhcpServerIdentifier], p);
memcpy(p, iface-cli_id, iface-cli_id_len);
p += iface-cli_id_len;
- *p = endOption;
+ *p++ = endOption;
+ p