aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-23 12:57:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-23 12:57:49 +0000
commitc90c3f30a899b5f0aae58e54839109aa9b3eaee6 (patch)
tree190c1a90f38aa4ddbfdddf52ea89978d42536606 /networking/udhcp/options.c
parent48237b0c88343154d58854020c3a9c8b07c61b10 (diff)
downloadbusybox-w32-c90c3f30a899b5f0aae58e54839109aa9b3eaee6.tar.gz
busybox-w32-c90c3f30a899b5f0aae58e54839109aa9b3eaee6.tar.bz2
busybox-w32-c90c3f30a899b5f0aae58e54839109aa9b3eaee6.zip
add "wpad" DHCP option. Spotted some optimization opportunities: -80 bytes
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r--networking/udhcp/options.c88
1 files changed, 45 insertions, 43 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 9fcbc8474..4a46da579 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -10,53 +10,55 @@
10 10
11 11
12/* supported options are easily added here */ 12/* supported options are easily added here */
13struct dhcp_option dhcp_options[] = { 13const struct dhcp_option dhcp_options[] = {
14 /* name[10] flags code */ 14 /* name[10] flags code */
15 {"subnet", OPTION_IP | OPTION_REQ, 0x01}, 15 {"subnet", OPTION_IP | OPTION_REQ, 0x01},
16 {"timezone", OPTION_S32, 0x02}, 16 {"timezone", OPTION_S32, 0x02},
17 {"router", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03}, 17 {"router", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03},
18 {"timesvr", OPTION_IP | OPTION_LIST, 0x04}, 18 {"timesvr", OPTION_IP | OPTION_LIST, 0x04},
19 {"namesvr", OPTION_IP | OPTION_LIST, 0x05}, 19 {"namesvr", OPTION_IP | OPTION_LIST, 0x05},
20 {"dns", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06}, 20 {"dns", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06},
21 {"logsvr", OPTION_IP | OPTION_LIST, 0x07}, 21 {"logsvr", OPTION_IP | OPTION_LIST, 0x07},
22 {"cookiesvr", OPTION_IP | OPTION_LIST, 0x08}, 22 {"cookiesvr", OPTION_IP | OPTION_LIST, 0x08},
23 {"lprsvr", OPTION_IP | OPTION_LIST, 0x09}, 23 {"lprsvr", OPTION_IP | OPTION_LIST, 0x09},
24 {"hostname", OPTION_STRING | OPTION_REQ, 0x0c}, 24 {"hostname", OPTION_STRING | OPTION_REQ, 0x0c},
25 {"bootsize", OPTION_U16, 0x0d}, 25 {"bootsize", OPTION_U16, 0x0d},
26 {"domain", OPTION_STRING | OPTION_REQ, 0x0f}, 26 {"domain", OPTION_STRING | OPTION_REQ, 0x0f},
27 {"swapsvr", OPTION_IP, 0x10}, 27 {"swapsvr", OPTION_IP, 0x10},
28 {"rootpath", OPTION_STRING, 0x11}, 28 {"rootpath", OPTION_STRING, 0x11},
29 {"ipttl", OPTION_U8, 0x17}, 29 {"ipttl", OPTION_U8, 0x17},
30 {"mtu", OPTION_U16, 0x1a}, 30 {"mtu", OPTION_U16, 0x1a},
31 {"broadcast", OPTION_IP | OPTION_REQ, 0x1c}, 31 {"broadcast", OPTION_IP | OPTION_REQ, 0x1c},
32 {"nisdomain", OPTION_STRING | OPTION_REQ, 0x28}, 32 {"nisdomain", OPTION_STRING | OPTION_REQ, 0x28},
33 {"nissrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x29}, 33 {"nissrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x29},
34 {"ntpsrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a}, 34 {"ntpsrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a},
35 {"wins", OPTION_IP | OPTION_LIST, 0x2c}, 35 {"wins", OPTION_IP | OPTION_LIST, 0x2c},
36 {"requestip", OPTION_IP, 0x32}, 36 {"requestip", OPTION_IP, 0x32},
37 {"lease", OPTION_U32, 0x33}, 37 {"lease", OPTION_U32, 0x33},
38 {"dhcptype", OPTION_U8, 0x35}, 38 {"dhcptype", OPTION_U8, 0x35},
39 {"serverid", OPTION_IP, 0x36}, 39 {"serverid", OPTION_IP, 0x36},
40 {"message", OPTION_STRING, 0x38}, 40 {"message", OPTION_STRING, 0x38},
41 {"vendorclass", OPTION_STRING, 0x3C}, 41 {"vendorclass", OPTION_STRING, 0x3C},
42 {"clientid", OPTION_STRING, 0x3D}, 42 {"clientid", OPTION_STRING, 0x3D},
43 {"tftp", OPTION_STRING, 0x42}, 43 {"tftp", OPTION_STRING, 0x42},
44 {"bootfile", OPTION_STRING, 0x43}, 44 {"bootfile", OPTION_STRING, 0x43},
45 {"userclass", OPTION_STRING, 0x4D}, 45 {"userclass", OPTION_STRING, 0x4D},
46 {"", 0x00, 0x00} 46 /* MSIE's "Web Proxy Autodiscovery Protocol" support */
47 {"wpad", OPTION_STRING, 0xfc},
48 {"", 0x00, 0x00}
47}; 49};
48 50
49/* Lengths of the different option types */ 51/* Lengths of the different option types */
50int option_lengths[] = { 52const unsigned char option_lengths[] = {
51 [OPTION_IP] = 4, 53 [OPTION_IP] = 4,
52 [OPTION_IP_PAIR] = 8, 54 [OPTION_IP_PAIR] = 8,
53 [OPTION_BOOLEAN] = 1, 55 [OPTION_BOOLEAN] = 1,
54 [OPTION_STRING] = 1, 56 [OPTION_STRING] = 1,
55 [OPTION_U8] = 1, 57 [OPTION_U8] = 1,
56 [OPTION_U16] = 2, 58 [OPTION_U16] = 2,
57 [OPTION_S16] = 2, 59 [OPTION_S16] = 2,
58 [OPTION_U32] = 4, 60 [OPTION_U32] = 4,
59 [OPTION_S32] = 4 61 [OPTION_S32] = 4
60}; 62};
61 63
62 64
@@ -150,9 +152,9 @@ int add_option_string(uint8_t *optionptr, uint8_t *string)
150/* add a one to four byte option to a packet */ 152/* add a one to four byte option to a packet */
151int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) 153int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
152{ 154{
153 struct dhcp_option *dh; 155 const struct dhcp_option *dh;
154 156
155 for (dh=dhcp_options; dh->code; dh++) { 157 for (dh = dhcp_options; dh->code; dh++) {
156 if (dh->code == code) { 158 if (dh->code == code) {
157 uint8_t option[6], len; 159 uint8_t option[6], len;
158 160