aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-20 07:12:21 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-20 07:12:21 +0100
commit0f62c4d065bc7fa9d3de52a8482bf48ecfd18ecf (patch)
tree40a176b78edf6b6bc02cbca31d82892e1d23fe8e
parenta953987e778e1a89d9371df99b243e7b57b22a07 (diff)
downloadbusybox-w32-0f62c4d065bc7fa9d3de52a8482bf48ecfd18ecf.tar.gz
busybox-w32-0f62c4d065bc7fa9d3de52a8482bf48ecfd18ecf.tar.bz2
busybox-w32-0f62c4d065bc7fa9d3de52a8482bf48ecfd18ecf.zip
udhcpd: remove five more options which do not make sense or not supported
requestip, vendorclass, clientid are client-side variables, they do not make sense as udhcpd opts dhcptype is the packet type (not interesting, it's always 5) userclass needs parser support in order to work function old new delta dhcp_options 68 66 -2 read_opt 865 859 -6 dhcp_option_strings 253 203 -50 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-58) Total: -58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--examples/udhcp/udhcpd.conf50
-rw-r--r--networking/udhcp/files.c3
-rw-r--r--networking/udhcp/options.c34
-rw-r--r--networking/udhcp/options.h14
-rw-r--r--networking/udhcp/script.c2
5 files changed, 58 insertions, 45 deletions
diff --git a/examples/udhcp/udhcpd.conf b/examples/udhcp/udhcpd.conf
index 1e05435d4..7fc37ab00 100644
--- a/examples/udhcp/udhcpd.conf
+++ b/examples/udhcp/udhcpd.conf
@@ -63,27 +63,35 @@ option domain local
63option lease 864000 # 10 days of seconds 63option lease 864000 # 10 days of seconds
64 64
65# Currently supported options (for more info, see options.c): 65# Currently supported options (for more info, see options.c):
66#opt subnet 66#opt lease NUM
67#opt timezone 67#opt subnet IP
68#opt router 68#opt broadcast IP
69#opt timesrv 69#opt router IP_LIST
70#opt namesrv - obsolete, disabled 70#opt ipttl NUM
71#opt dns 71#opt mtu NUM
72#opt logsrv 72#opt hostname STRING - client's hostname
73#opt cookiesrv - rarely (never?) used, disabled 73#opt domain STRING - client's domain name
74#opt lprsrv 74#opt search STRING_LIST - search domains
75#opt bootsize 75#opt nisdomain STRING
76#opt domain 76#opt timezone NUM
77#opt swapsrv 77#opt tftp STRING - TFTP server name
78#opt rootpath 78#opt bootfile STRING - file (kernel image) to load for booting
79#opt ipttl 79#opt bootsize NUM - size of that file
80#opt mtu 80#opt rootpath STRING - (NFS) path to mount as root fs
81#opt broadcast 81#opt wpad STRING
82#opt wins 82#opt serverid IP - by default, server's IP
83#opt lease 83#opt message STRING - error message (udhcpd sends it on success too)
84#opt ntpsrv 84# Options specifying server(s)
85#opt tftp 85#opt dns IP_LIST
86#opt bootfile 86#opt wins IP_LIST
87#opt nissrv IP_LIST
88#opt namesrv IP_LIST - obsolete, disabled
89#opt logsrv IP_LIST
90#opt cookiesrv IP_LIST - rarely (never?) used, disabled
91#opt lprsrv IP_LIST
92#opt swapsrv IP
93#opt timesrv IP_LIST
94#opt ntpsrv IP_LIST
87 95
88# Static leases map 96# Static leases map
89#static_lease 00:60:08:11:CE:4E 192.168.0.54 97#static_lease 00:60:08:11:CE:4E 192.168.0.54
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 1b2cc96f4..40cfe9fd2 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -201,9 +201,8 @@ static int FAST_FUNC read_opt(const char *const_line, void *arg)
201#if ENABLE_FEATURE_UDHCP_RFC3397 201#if ENABLE_FEATURE_UDHCP_RFC3397
202 case OPTION_STR1035: 202 case OPTION_STR1035:
203#endif 203#endif
204 length = strlen(val); 204 length = strnlen(val, 254);
205 if (length > 0) { 205 if (length > 0) {
206 if (length > 254) length = 254;
207 opt = val; 206 opt = val;
208 retval = 1; 207 retval = 1;
209 } 208 }
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 6ab5708e6..c2a230527 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -11,7 +11,9 @@
11#include "options.h" 11#include "options.h"
12 12
13 13
14/* Supported options are easily added here. See RFC2132 */ 14/* Supported options are easily added here.
15 * See RFC2132 for more options.
16 */
15const struct dhcp_option dhcp_options[] = { 17const struct dhcp_option dhcp_options[] = {
16 /* flags code */ 18 /* flags code */
17 { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ 19 { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */
@@ -25,7 +27,7 @@ const struct dhcp_option dhcp_options[] = {
25 { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */ 27 { OPTION_IP | OPTION_LIST , 0x09 }, /* DHCP_LPR_SERVER */
26 { OPTION_STRING | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */ 28 { OPTION_STRING | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME */
27 { OPTION_U16 , 0x0d }, /* DHCP_BOOT_SIZE */ 29 { OPTION_U16 , 0x0d }, /* DHCP_BOOT_SIZE */
28 { OPTION_STRING | OPTION_LIST | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */ 30 { OPTION_STRING | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME */
29 { OPTION_IP , 0x10 }, /* DHCP_SWAP_SERVER */ 31 { OPTION_IP , 0x10 }, /* DHCP_SWAP_SERVER */
30 { OPTION_STRING , 0x11 }, /* DHCP_ROOT_PATH */ 32 { OPTION_STRING , 0x11 }, /* DHCP_ROOT_PATH */
31 { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */ 33 { OPTION_U8 , 0x17 }, /* DHCP_IP_TTL */
@@ -35,16 +37,13 @@ const struct dhcp_option dhcp_options[] = {
35 { OPTION_IP | OPTION_LIST , 0x29 }, /* nissrv */ 37 { OPTION_IP | OPTION_LIST , 0x29 }, /* nissrv */
36 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */ 38 { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER */
37 { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */ 39 { OPTION_IP | OPTION_LIST , 0x2c }, /* DHCP_WINS_SERVER */
38 { OPTION_IP , 0x32 }, /* DHCP_REQUESTED_IP */
39 { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */ 40 { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */
40 { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */
41 { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */ 41 { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */
42 { OPTION_STRING , 0x38 }, /* DHCP_MESSAGE */ 42 { OPTION_STRING , 0x38 }, /* DHCP_MESSAGE */
43 { OPTION_STRING , 0x3C }, /* DHCP_VENDOR */
44 { OPTION_STRING , 0x3D }, /* DHCP_CLIENT_ID */
45 { OPTION_STRING , 0x42 }, /* tftp */ 43 { OPTION_STRING , 0x42 }, /* tftp */
46 { OPTION_STRING , 0x43 }, /* bootfile */ 44 { OPTION_STRING , 0x43 }, /* bootfile */
47 { OPTION_STRING , 0x4D }, /* userclass */ 45//TODO: not a string, but a set of LASCII strings:
46// { OPTION_STRING , 0x4D }, /* userclass */
48#if ENABLE_FEATURE_UDHCP_RFC3397 47#if ENABLE_FEATURE_UDHCP_RFC3397
49 { OPTION_STR1035 | OPTION_LIST , 0x77 }, /* search */ 48 { OPTION_STR1035 | OPTION_LIST , 0x77 }, /* search */
50#endif 49#endif
@@ -54,14 +53,23 @@ const struct dhcp_option dhcp_options[] = {
54 53
55 /* Options below have no match in dhcp_option_strings[], 54 /* Options below have no match in dhcp_option_strings[],
56 * are not passed to dhcpc scripts, and cannot be specified 55 * are not passed to dhcpc scripts, and cannot be specified
57 * with "option XXX YYY" syntax in dhcpd config file. */ 56 * with "option XXX YYY" syntax in dhcpd config file.
57 * These entries are only used internally by udhcp[cd]
58 * to correctly encode options into packets.
59 */
58 60
61 { OPTION_IP , 0x32 }, /* DHCP_REQUESTED_IP */
62 { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */
59 { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */ 63 { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */
64 { OPTION_STRING , 0x3C }, /* DHCP_VENDOR */
65 { OPTION_STRING , 0x3D }, /* DHCP_CLIENT_ID */
60 { 0, 0 } /* zeroed terminating entry */ 66 { 0, 0 } /* zeroed terminating entry */
61}; 67};
62 68
63/* Used for converting options from incoming packets to env variables 69/* Used for converting options from incoming packets to env variables
64 * for udhcpc stript */ 70 * for udhcpc stript, and for setting options for udhcpd via
71 * "opt OPTION_NAME OPTION_VALUE" directives in udhcpd.conf file.
72 */
65/* Must match dhcp_options[] order */ 73/* Must match dhcp_options[] order */
66const char dhcp_option_strings[] ALIGN1 = 74const char dhcp_option_strings[] ALIGN1 =
67 "subnet" "\0" /* DHCP_SUBNET */ 75 "subnet" "\0" /* DHCP_SUBNET */
@@ -85,19 +93,17 @@ const char dhcp_option_strings[] ALIGN1 =
85 "nissrv" "\0" /* */ 93 "nissrv" "\0" /* */
86 "ntpsrv" "\0" /* DHCP_NTP_SERVER */ 94 "ntpsrv" "\0" /* DHCP_NTP_SERVER */
87 "wins" "\0" /* DHCP_WINS_SERVER */ 95 "wins" "\0" /* DHCP_WINS_SERVER */
88 "requestip" "\0" /* DHCP_REQUESTED_IP */
89 "lease" "\0" /* DHCP_LEASE_TIME */ 96 "lease" "\0" /* DHCP_LEASE_TIME */
90 "dhcptype" "\0" /* */
91 "serverid" "\0" /* DHCP_SERVER_ID */ 97 "serverid" "\0" /* DHCP_SERVER_ID */
92 "message" "\0" /* DHCP_MESSAGE */ 98 "message" "\0" /* DHCP_MESSAGE */
93 "vendorclass" "\0" /* DHCP_VENDOR */
94 "clientid" "\0" /* DHCP_CLIENT_ID */
95 "tftp" "\0" 99 "tftp" "\0"
96 "bootfile" "\0" 100 "bootfile" "\0"
97 "userclass" "\0" 101// "userclass" "\0"
98#if ENABLE_FEATURE_UDHCP_RFC3397 102#if ENABLE_FEATURE_UDHCP_RFC3397
99 "search" "\0" 103 "search" "\0"
100#endif 104#endif
105// "staticroutes" is only used to set udhcpc environment, it doesn't work
106// in udhcpd.conf since OPTION_STATIC_ROUTES is not handled yet:
101 "staticroutes" "\0" /* DHCP_STATIC_ROUTES */ 107 "staticroutes" "\0" /* DHCP_STATIC_ROUTES */
102 /* MSIE's "Web Proxy Autodiscovery Protocol" support */ 108 /* MSIE's "Web Proxy Autodiscovery Protocol" support */
103 "wpad" "\0" 109 "wpad" "\0"
diff --git a/networking/udhcp/options.h b/networking/udhcp/options.h
index 8f6ab0f15..2d9c15f8a 100644
--- a/networking/udhcp/options.h
+++ b/networking/udhcp/options.h
@@ -41,10 +41,10 @@ enum {
41#define DHCP_TIME_OFFSET 0x02 41#define DHCP_TIME_OFFSET 0x02
42#define DHCP_ROUTER 0x03 42#define DHCP_ROUTER 0x03
43#define DHCP_TIME_SERVER 0x04 43#define DHCP_TIME_SERVER 0x04
44//#define DHCP_NAME_SERVER 0x05 /* _really_ ancient */ 44//#define DHCP_NAME_SERVER 0x05 /* _really_ ancient kind of NS */
45#define DHCP_DNS_SERVER 0x06 45#define DHCP_DNS_SERVER 0x06
46#define DHCP_LOG_SERVER 0x07 46#define DHCP_LOG_SERVER 0x07
47//#define DHCP_COOKIE_SERVER 0x08 /* "quote of the day" */ 47//#define DHCP_COOKIE_SERVER 0x08 /* "quote of the day" server */
48#define DHCP_LPR_SERVER 0x09 48#define DHCP_LPR_SERVER 0x09
49#define DHCP_HOST_NAME 0x0c 49#define DHCP_HOST_NAME 0x0c
50#define DHCP_BOOT_SIZE 0x0d 50#define DHCP_BOOT_SIZE 0x0d
@@ -56,18 +56,18 @@ enum {
56#define DHCP_BROADCAST 0x1c 56#define DHCP_BROADCAST 0x1c
57#define DHCP_NTP_SERVER 0x2a 57#define DHCP_NTP_SERVER 0x2a
58#define DHCP_WINS_SERVER 0x2c 58#define DHCP_WINS_SERVER 0x2c
59#define DHCP_REQUESTED_IP 0x32 59#define DHCP_REQUESTED_IP 0x32 /* sent by client if specific IP is wanted */
60#define DHCP_LEASE_TIME 0x33 60#define DHCP_LEASE_TIME 0x33
61#define DHCP_OPTION_OVERLOAD 0x34 61#define DHCP_OPTION_OVERLOAD 0x34
62#define DHCP_MESSAGE_TYPE 0x35 62#define DHCP_MESSAGE_TYPE 0x35
63#define DHCP_SERVER_ID 0x36 63#define DHCP_SERVER_ID 0x36 /* by default server's IP */
64#define DHCP_PARAM_REQ 0x37 64#define DHCP_PARAM_REQ 0x37
65#define DHCP_MESSAGE 0x38 65#define DHCP_MESSAGE 0x38 /* error message when sending NAK etc */
66#define DHCP_MAX_SIZE 0x39 66#define DHCP_MAX_SIZE 0x39
67//#define DHCP_T1 0x3a 67//#define DHCP_T1 0x3a
68//#define DHCP_T2 0x3b 68//#define DHCP_T2 0x3b
69#define DHCP_VENDOR 0x3c 69#define DHCP_VENDOR 0x3c /* client's vendor */
70#define DHCP_CLIENT_ID 0x3d 70#define DHCP_CLIENT_ID 0x3d /* by default client's MAC addr */
71#define DHCP_FQDN 0x51 71#define DHCP_FQDN 0x51
72#define DHCP_STATIC_ROUTES 0x79 72#define DHCP_STATIC_ROUTES 0x79
73#define DHCP_END 0xFF 73#define DHCP_END 0xFF
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c
index dc658ada8..321b015e0 100644
--- a/networking/udhcp/script.c
+++ b/networking/udhcp/script.c
@@ -177,7 +177,7 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_
177} 177}
178 178
179 179
180/* put all the parameters into an environment */ 180/* put all the parameters into the environment */
181static char **fill_envp(struct dhcp_packet *packet) 181static char **fill_envp(struct dhcp_packet *packet)
182{ 182{
183 int num_options = 0; 183 int num_options = 0;