summaryrefslogtreecommitdiff
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r--networking/udhcp/options.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 09d31c69b..5bef985bc 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -20,10 +20,10 @@ const struct dhcp_option dhcp_options[] = {
20 { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ 20 { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */
21 { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */ 21 { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */
22 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03 }, /* DHCP_ROUTER */ 22 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03 }, /* DHCP_ROUTER */
23 { OPTION_IP | OPTION_LIST , 0x04 }, /* DHCP_TIME_SERVER */ 23// { OPTION_IP | OPTION_LIST , 0x04 }, /* DHCP_TIME_SERVER */
24// { OPTION_IP | OPTION_LIST , 0x05 }, /* DHCP_NAME_SERVER */ 24// { OPTION_IP | OPTION_LIST , 0x05 }, /* DHCP_NAME_SERVER */
25 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06 }, /* DHCP_DNS_SERVER */ 25 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06 }, /* DHCP_DNS_SERVER */
26 { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */ 26// { OPTION_IP | OPTION_LIST , 0x07 }, /* DHCP_LOG_SERVER */
27// { OPTION_IP | OPTION_LIST , 0x08 }, /* DHCP_COOKIE_SERVER */ 27// { OPTION_IP | OPTION_LIST , 0x08 }, /* DHCP_COOKIE_SERVER */
28 { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */ 28 { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */
29 { OPTION_STRING | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */ 29 { OPTION_STRING | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
@@ -34,23 +34,23 @@ const struct dhcp_option dhcp_options[] = {
34 { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */ 34 { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */
35 { OPTION_U16 , 0x1a }, /* DHCP_MTU */ 35 { OPTION_U16 , 0x1a }, /* DHCP_MTU */
36 { OPTION_IP | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST */ 36 { OPTION_IP | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST */
37 { OPTION_STRING , 0x28 }, /* nisdomain */ 37 { OPTION_STRING , 0x28 }, /* DHCP_NIS_DOMAIN */
38 { OPTION_IP | OPTION_LIST , 0x29 }, /* nissrv */ 38 { OPTION_IP | OPTION_LIST , 0x29 }, /* DHCP_NIS_SERVER */
39 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */ 39 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */
40 { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */ 40 { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */
41 { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */ 41 { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */
42 { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */ 42 { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */
43 { OPTION_STRING , 0x38 }, /* DHCP_MESSAGE */ 43 { OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */
44 { OPTION_STRING , 0x42 }, /* tftp */ 44//TODO: must be combined with 'sname' and 'file' handling:
45 { OPTION_STRING , 0x43 }, /* bootfile */ 45 { OPTION_STRING , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
46 { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
46//TODO: not a string, but a set of LASCII strings: 47//TODO: not a string, but a set of LASCII strings:
47// { OPTION_STRING , 0x4D }, /* userclass */ 48// { OPTION_STRING , 0x4D }, /* DHCP_USER_CLASS */
48#if ENABLE_FEATURE_UDHCP_RFC3397 49#if ENABLE_FEATURE_UDHCP_RFC3397
49 { OPTION_STR1035 | OPTION_LIST , 0x77 }, /* search */ 50 { OPTION_STR1035 | OPTION_LIST , 0x77 }, /* DHCP_DOMAIN_SEARCH */
50#endif 51#endif
51 { OPTION_STATIC_ROUTES , 0x79 }, /* DHCP_STATIC_ROUTES */ 52 { OPTION_STATIC_ROUTES , 0x79 }, /* DHCP_STATIC_ROUTES */
52 /* MSIE's "Web Proxy Autodiscovery Protocol" support */ 53 { OPTION_STRING , 0xfc }, /* DHCP_WPAD */
53 { OPTION_STRING , 0xfc }, /* wpad */
54 54
55 /* Options below have no match in dhcp_option_strings[], 55 /* Options below have no match in dhcp_option_strings[],
56 * are not passed to dhcpc scripts, and cannot be specified 56 * are not passed to dhcpc scripts, and cannot be specified
@@ -62,8 +62,9 @@ const struct dhcp_option dhcp_options[] = {
62 { OPTION_IP , 0x32 }, /* DHCP_REQUESTED_IP */ 62 { OPTION_IP , 0x32 }, /* DHCP_REQUESTED_IP */
63 { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */ 63 { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */
64 { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */ 64 { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */
65 { OPTION_STRING , 0x3C }, /* DHCP_VENDOR */ 65 { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */
66 { OPTION_STRING , 0x3D }, /* DHCP_CLIENT_ID */ 66//FIXME: handling of this option is not exactly correct:
67 { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */
67 { 0, 0 } /* zeroed terminating entry */ 68 { 0, 0 } /* zeroed terminating entry */
68}; 69};
69 70
@@ -76,10 +77,10 @@ const char dhcp_option_strings[] ALIGN1 =
76 "subnet" "\0" /* DHCP_SUBNET */ 77 "subnet" "\0" /* DHCP_SUBNET */
77 "timezone" "\0" /* DHCP_TIME_OFFSET */ 78 "timezone" "\0" /* DHCP_TIME_OFFSET */
78 "router" "\0" /* DHCP_ROUTER */ 79 "router" "\0" /* DHCP_ROUTER */
79 "timesrv" "\0" /* DHCP_TIME_SERVER */ 80// "timesrv" "\0" /* DHCP_TIME_SERVER */
80// "namesrv" "\0" /* DHCP_NAME_SERVER */ 81// "namesrv" "\0" /* DHCP_NAME_SERVER */
81 "dns" "\0" /* DHCP_DNS_SERVER */ 82 "dns" "\0" /* DHCP_DNS_SERVER */
82 "logsrv" "\0" /* DHCP_LOG_SERVER */ 83// "logsrv" "\0" /* DHCP_LOG_SERVER */
83// "cookiesrv" "\0" /* DHCP_COOKIE_SERVER */ 84// "cookiesrv" "\0" /* DHCP_COOKIE_SERVER */
84 "lprsrv" "\0" /* DHCP_LPR_SERVER */ 85 "lprsrv" "\0" /* DHCP_LPR_SERVER */
85 "hostname" "\0" /* DHCP_HOST_NAME */ 86 "hostname" "\0" /* DHCP_HOST_NAME */
@@ -90,24 +91,24 @@ const char dhcp_option_strings[] ALIGN1 =
90 "ipttl" "\0" /* DHCP_IP_TTL */ 91 "ipttl" "\0" /* DHCP_IP_TTL */
91 "mtu" "\0" /* DHCP_MTU */ 92 "mtu" "\0" /* DHCP_MTU */
92 "broadcast" "\0" /* DHCP_BROADCAST */ 93 "broadcast" "\0" /* DHCP_BROADCAST */
93 "nisdomain" "\0" /* */ 94 "nisdomain" "\0" /* DHCP_NIS_DOMAIN */
94 "nissrv" "\0" /* */ 95 "nissrv" "\0" /* DHCP_NIS_SERVER */
95 "ntpsrv" "\0" /* DHCP_NTP_SERVER */ 96 "ntpsrv" "\0" /* DHCP_NTP_SERVER */
96 "wins" "\0" /* DHCP_WINS_SERVER */ 97 "wins" "\0" /* DHCP_WINS_SERVER */
97 "lease" "\0" /* DHCP_LEASE_TIME */ 98 "lease" "\0" /* DHCP_LEASE_TIME */
98 "serverid" "\0" /* DHCP_SERVER_ID */ 99 "serverid" "\0" /* DHCP_SERVER_ID */
99 "message" "\0" /* DHCP_MESSAGE */ 100 "message" "\0" /* DHCP_ERR_MESSAGE */
100 "tftp" "\0" 101 "tftp" "\0" /* DHCP_TFTP_SERVER_NAME */
101 "bootfile" "\0" 102 "bootfile" "\0" /* DHCP_BOOT_FILE */
102// "userclass" "\0" 103// "userclass" "\0" /* DHCP_USER_CLASS */
103#if ENABLE_FEATURE_UDHCP_RFC3397 104#if ENABLE_FEATURE_UDHCP_RFC3397
104 "search" "\0" 105 "search" "\0" /* DHCP_DOMAIN_SEARCH */
105#endif 106#endif
106// "staticroutes" is only used to set udhcpc environment, it doesn't work 107// "staticroutes" is only used to set udhcpc environment, it doesn't work
107// in udhcpd.conf since OPTION_STATIC_ROUTES is not handled yet: 108// in udhcpd.conf since OPTION_STATIC_ROUTES is not handled yet
108 "staticroutes" "\0" /* DHCP_STATIC_ROUTES */ 109// by "string->option" conversion code:
109 /* MSIE's "Web Proxy Autodiscovery Protocol" support */ 110 "staticroutes" "\0"/* DHCP_STATIC_ROUTES */
110 "wpad" "\0" 111 "wpad" "\0" /* DHCP_WPAD */
111 ; 112 ;
112 113
113 114
@@ -225,7 +226,7 @@ int FAST_FUNC end_option(uint8_t *optionptr)
225 226
226/* add an option string to the options */ 227/* add an option string to the options */
227/* option bytes: [code][len][data1][data2]..[dataLEN] */ 228/* option bytes: [code][len][data1][data2]..[dataLEN] */
228int FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string) 229void FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string)
229{ 230{
230 int end = end_option(optionptr); 231 int end = end_option(optionptr);
231 232
@@ -233,17 +234,16 @@ int FAST_FUNC add_option_string(uint8_t *optionptr, uint8_t *string)
233 if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) { 234 if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) {
234 bb_error_msg("option 0x%02x did not fit into the packet", 235 bb_error_msg("option 0x%02x did not fit into the packet",
235 string[OPT_CODE]); 236 string[OPT_CODE]);
236 return 0; 237 return;
237 } 238 }
238 log_option("Adding option", string); 239 log_option("Adding option", string);
239 memcpy(optionptr + end, string, string[OPT_LEN] + 2); 240 memcpy(optionptr + end, string, string[OPT_LEN] + 2);
240 optionptr[end + string[OPT_LEN] + 2] = DHCP_END; 241 optionptr[end + string[OPT_LEN] + 2] = DHCP_END;
241 return string[OPT_LEN] + 2;
242} 242}
243 243
244 244
245/* add a one to four byte option to a packet */ 245/* add a one to four byte option to a packet */
246int FAST_FUNC add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) 246void FAST_FUNC add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
247{ 247{
248 const struct dhcp_option *dh; 248 const struct dhcp_option *dh;
249 249
@@ -258,10 +258,10 @@ int FAST_FUNC add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
258 data <<= 8 * (4 - len); 258 data <<= 8 * (4 - len);
259 /* Assignment is unaligned! */ 259 /* Assignment is unaligned! */
260 move_to_unaligned32(&option[OPT_DATA], data); 260 move_to_unaligned32(&option[OPT_DATA], data);
261 return add_option_string(optionptr, option); 261 add_option_string(optionptr, option);
262 return;
262 } 263 }
263 } 264 }
264 265
265 bb_error_msg("can't add option 0x%02x", code); 266 bb_error_msg("can't add option 0x%02x", code);
266 return 0;
267} 267}