summaryrefslogtreecommitdiffstats
path: root/dhcp.h
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2006-12-01 12:50:53 +0000
committerRoy Marples <roy@marples.name>2006-12-01 12:50:53 +0000
commit24c57f1305a0bc39a2771451c992e06332dfb1d0 (patch)
tree349b3b13f3d937110b3d0c3c60c1cd3b3df8b2b3 /dhcp.h
parent05dac403dd3d99a1eecac5fc7c33ea134dbaab97 (diff)
downloaddhcpcd-24c57f1305a0bc39a2771451c992e06332dfb1d0.tar.xz
Set the rfds correctly so we can get a reply after re-sending a request.
Set the seconds elasped and maximum message size correctly in DHCP messages. Now compiles on Linux 2.4 kernels.
Diffstat (limited to 'dhcp.h')
-rw-r--r--dhcp.h45
1 files changed, 31 insertions, 14 deletions
diff --git a/dhcp.h b/dhcp.h
index b5076b38..10104318 100644
--- a/dhcp.h
+++ b/dhcp.h
@@ -31,6 +31,9 @@
#include "dhcpcd.h"
#include "interface.h"
+/* Max MTU - defines dhcp option length */
+#define MTU_MAX 1500
+
/* UDP port numbers for DHCP */
#define DHCP_SERVER_PORT 67
#define DHCP_CLIENT_PORT 68
@@ -51,6 +54,7 @@
#define DHCP_RELEASE 7
#define DHCP_INFORM 8
+
/* DHCP options */
enum DHCP_OPTIONS
{
@@ -150,24 +154,37 @@ typedef struct dhcp_t
char *rootpath;
} dhcp_t;
+/* Sizes for DHCP options */
+#define HWADDR_LEN 16
+#define SERVERNAME_LEN 64
+#define BOOTFILE_LEN 128
+#define DHCP_UDP_LEN (20 + 8)
+#define DHCP_BASE_LEN (4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4)
+#define DHCP_RESERVE_LEN (4 + 4 + 4 + 4 + 2)
+#define DHCP_FIXED_LEN (DHCP_BASE_LEN + HWADDR_LEN + \
+ + SERVERNAME_LEN + BOOTFILE_LEN)
+#define DHCP_OPTION_LEN (MTU_MAX - DHCP_FIXED_LEN - DHCP_UDP_LEN \
+ - DHCP_RESERVE_LEN)
+
+
typedef struct dhcpmessage_t
{
- char op; /* message type */
- char hwtype; /* hardware address type */
- char hwlen; /* hardware address length */
- char hwopcount; /* should be zero in client's message */
- int32_t xid; /* transaction id */
- int16_t secs; /* elapsed time in sec. from trying to boot */
+ unsigned char op; /* message type */
+ unsigned char hwtype; /* hardware address type */
+ unsigned char hwlen; /* hardware address length */
+ unsigned char hwopcount; /* should be zero in client's message */
+ int32_t xid; /* transaction id */
+ int16_t secs; /* elapsed time in sec. from trying to boot */
int16_t flags;
- int32_t ciaddr; /* (previously allocated) client IP address */
- int32_t yiaddr; /* 'your' client IP address */
- int32_t siaddr; /* should be zero in client's messages */
- int32_t giaddr; /* should be zero in client's messages */
- unsigned char hwaddr[16]; /* client's hardware address */
- char servername[64]; /* server host name, null terminated string */
- char bootfile[128]; /* boot file name, null terminated string */
+ int32_t ciaddr; /* (previously allocated) client IP address */
+ int32_t yiaddr; /* 'your' client IP address */
+ int32_t siaddr; /* should be zero in client's messages */
+ int32_t giaddr; /* should be zero in client's messages */
+ unsigned char hwaddr[HWADDR_LEN]; /* client's hardware address */
+ char servername[SERVERNAME_LEN]; /* server host name, null terminated string */
+ char bootfile[BOOTFILE_LEN]; /* boot file name, null terminated string */
uint32_t cookie;
- unsigned char options[308]; /* message options - cookie */
+ unsigned char options[DHCP_OPTION_LEN]; /* message options - cookie */
} dhcpmessage_t;
struct udp_dhcp_packet