aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/common.h')
-rw-r--r--networking/udhcp/common.h75
1 files changed, 73 insertions, 2 deletions
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index d7c874e5b..cf3e0cd39 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -21,11 +21,17 @@ extern const uint8_t MAC_BCAST_ADDR[6]; /* six all-ones */
21 21
22/*** packet.h ***/ 22/*** packet.h ***/
23 23
24#define DHCP_OPTIONS_BUFSIZE 308 24/* DHCP protocol. See RFC 2131 */
25#define DHCP_MAGIC 0x63825363
26
27#define DHCP_OPTIONS_BUFSIZE 308
28
29#define BOOTREQUEST 1
30#define BOOTREPLY 2
25 31
26//TODO: rename ciaddr/yiaddr/chaddr 32//TODO: rename ciaddr/yiaddr/chaddr
27struct dhcp_packet { 33struct dhcp_packet {
28 uint8_t op; /* 1 = BOOTREQUEST, 2 = BOOTREPLY */ 34 uint8_t op; /* BOOTREQUEST or BOOTREPLY */
29 uint8_t htype; /* hardware address type. 1 = 10mb ethernet */ 35 uint8_t htype; /* hardware address type. 1 = 10mb ethernet */
30 uint8_t hlen; /* hardware address length */ 36 uint8_t hlen; /* hardware address length */
31 uint8_t hops; /* used by relay agents only */ 37 uint8_t hops; /* used by relay agents only */
@@ -61,6 +67,71 @@ struct BUG_bad_sizeof_struct_ip_udp_dhcp_packet {
61 [(sizeof(struct ip_udp_dhcp_packet) != 576 + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS) ? -1 : 1]; 67 [(sizeof(struct ip_udp_dhcp_packet) != 576 + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS) ? -1 : 1];
62}; 68};
63 69
70// RFC 2131 Table 5: Fields and options used by DHCP clients
71//
72// Field DHCPDISCOVER DHCPREQUEST DHCPDECLINE,
73// DHCPINFORM DHCPRELEASE
74// ----- ------------ ----------- -----------
75// 'op' BOOTREQUEST BOOTREQUEST BOOTREQUEST
76// 'hops' 0 0 0
77// 'xid' selected by client 'xid' from server selected by
78// DHCPOFFER message client
79// 'secs' 0 or seconds since 0 or seconds since 0
80// DHCP process started DHCP process started
81// 'flags' Set 'BROADCAST' Set 'BROADCAST' 0
82// flag if client flag if client
83// requires broadcast requires broadcast
84// reply reply
85// 'ciaddr' 0 (DHCPDISCOVER) 0 or client's 0 (DHCPDECLINE)
86// client's network address client's network
87// network address (BOUND/RENEW/REBIND) address
88// (DHCPINFORM) (DHCPRELEASE)
89// 'yiaddr' 0 0 0
90// 'siaddr' 0 0 0
91// 'giaddr' 0 0 0
92// 'chaddr' client's hardware client's hardware client's hardware
93// address address address
94// 'sname' options, if options, if (unused)
95// indicated in indicated in
96// 'sname/file' 'sname/file'
97// option; otherwise option; otherwise
98// unused unused
99// 'file' options, if options, if (unused)
100// indicated in indicated in
101// 'sname/file' 'sname/file'
102// option; otherwise option; otherwise
103// unused unused
104// 'options' options options (unused)
105//
106// Option DHCPDISCOVER DHCPREQUEST DHCPDECLINE,
107// DHCPINFORM DHCPRELEASE
108// ------ ------------ ----------- -----------
109// Requested IP address MAY MUST (in MUST
110// (DISCOVER) SELECTING or (DHCPDECLINE),
111// MUST NOT INIT-REBOOT) MUST NOT
112// (INFORM) MUST NOT (in (DHCPRELEASE)
113// BOUND or
114// RENEWING)
115// IP address lease time MAY MAY MUST NOT
116// (DISCOVER)
117// MUST NOT
118// (INFORM)
119// Use 'file'/'sname' fields MAY MAY MAY
120// Client identifier MAY MAY MAY
121// Vendor class identifier MAY MAY MUST NOT
122// Server identifier MUST NOT MUST (after MUST
123// SELECTING)
124// MUST NOT (after
125// INIT-REBOOT,
126// BOUND, RENEWING
127// or REBINDING)
128// Parameter request list MAY MAY MUST NOT
129// Maximum message size MAY MAY MUST NOT
130// Message SHOULD NOT SHOULD NOT SHOULD
131// Site-specific MAY MAY MUST NOT
132// All others MAY MAY MUST NOT
133
134
64uint16_t udhcp_checksum(void *addr, int count) FAST_FUNC; 135uint16_t udhcp_checksum(void *addr, int count) FAST_FUNC;
65 136
66void udhcp_init_header(struct dhcp_packet *packet, char type) FAST_FUNC; 137void udhcp_init_header(struct dhcp_packet *packet, char type) FAST_FUNC;