Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 1 | Index: include/usage.h |
| 2 | =================================================================== |
| 3 | RCS file: /var/cvs/busybox/include/usage.h,v |
| 4 | retrieving revision 1.191 |
| 5 | diff -u -r1.191 usage.h |
| 6 | --- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191 |
| 7 | +++ b/include/usage.h 5 Mar 2004 14:32:45 -0000 |
| 8 | @@ -2606,6 +2606,7 @@ |
| 9 | "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \ |
| 10 | "\t-q,\t--quit\tQuit after obtaining lease\n" \ |
| 11 | "\t-r,\t--request=IP\tIP address to request (default: none)\n" \ |
| 12 | + "\t-R,\t--require=NAME\tAdd NAME to request\n" \ |
| 13 | "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ |
| 14 | "\t-v,\t--version\tDisplay version" |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 15 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 16 | Index: networking/udhcp/README.udhcpc |
| 17 | =================================================================== |
| 18 | RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpc,v |
| 19 | retrieving revision 1.3 |
| 20 | diff -u -r1.3 README.udhcpc |
| 21 | --- a/networking/udhcp/README.udhcpc 11 Dec 2002 21:12:44 -0000 1.3 |
| 22 | +++ b/networking/udhcp/README.udhcpc 5 Mar 2004 14:32:46 -0000 |
| 23 | @@ -22,6 +22,7 @@ |
| 24 | -p, --pidfile=file Store process ID of daemon in file |
| 25 | -q, --quit Quit after obtaining lease |
| 26 | -r, --request=IP IP address to request (default: none) |
| 27 | +-R, --require=NAME Add NAME to request |
| 28 | -s, --script=file Run file at dhcp events (default: |
| 29 | /usr/share/udhcpc/default.script) |
| 30 | -v, --version Display version |
| 31 | @@ -101,6 +102,8 @@ |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 32 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 33 | additional options are easily added in options.c. |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 34 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 35 | +By default, only a few basic items are requested. To request additional |
| 36 | +items use the -R option. Example: "-R rootpath" |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 37 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 38 | note on udhcpc's random seed |
| 39 | --------------------------- |
| 40 | Index: networking/udhcp/dhcpc.c |
| 41 | =================================================================== |
| 42 | RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.c,v |
| 43 | retrieving revision 1.16 |
| 44 | diff -u -r1.16 dhcpc.c |
| 45 | --- a/networking/udhcp/dhcpc.c 30 Jan 2004 23:45:12 -0000 1.16 |
| 46 | +++ b/networking/udhcp/dhcpc.c 5 Mar 2004 14:32:46 -0000 |
| 47 | @@ -88,6 +88,7 @@ |
| 48 | " -p, --pidfile=file Store process ID of daemon in file\n" |
| 49 | " -q, --quit Quit after obtaining lease\n" |
| 50 | " -r, --request=IP IP address to request (default: none)\n" |
| 51 | +" -R, --require=NAME Add NAME to the request\n" |
| 52 | " -s, --script=file Run file at dhcp events (default:\n" |
| 53 | " " DEFAULT_SCRIPT ")\n" |
| 54 | " -v, --version Display version\n" |
| 55 | @@ -203,6 +204,7 @@ |
| 56 | {"pidfile", required_argument, 0, 'p'}, |
| 57 | {"quit", no_argument, 0, 'q'}, |
| 58 | {"request", required_argument, 0, 'r'}, |
| 59 | + {"require", required_argument, 0, 'R'}, |
| 60 | {"script", required_argument, 0, 's'}, |
| 61 | {"version", no_argument, 0, 'v'}, |
| 62 | {0, 0, 0, 0} |
| 63 | @@ -211,7 +213,7 @@ |
| 64 | /* get options */ |
| 65 | while (1) { |
| 66 | int option_index = 0; |
| 67 | - c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index); |
| 68 | + c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:R:s:v", arg_options, &option_index); |
| 69 | if (c == -1) break; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 70 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 71 | switch (c) { |
| 72 | @@ -254,6 +256,11 @@ |
| 73 | case 'r': |
| 74 | requested_ip = inet_addr(optarg); |
| 75 | break; |
| 76 | + case 'R': |
| 77 | + if (require_option(optarg)) { |
| 78 | + fprintf(stderr,"WARNING: %s unknown/not-supported (Ignored)\n", optarg ); |
| 79 | + } |
| 80 | + break; |
| 81 | case 's': |
| 82 | client_config.script = optarg; |
| 83 | break; |
| 84 | Index: networking/udhcp/options.c |
| 85 | =================================================================== |
| 86 | RCS file: /var/cvs/busybox/networking/udhcp/options.c,v |
| 87 | retrieving revision 1.7 |
| 88 | diff -u -r1.7 options.c |
| 89 | --- a/networking/udhcp/options.c 30 Jan 2004 23:45:12 -0000 1.7 |
| 90 | +++ b/networking/udhcp/options.c 5 Mar 2004 14:32:46 -0000 |
| 91 | @@ -57,7 +57,19 @@ |
| 92 | [OPTION_S32] = 4 |
| 93 | }; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 94 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 95 | - |
| 96 | +/* find and mark requested item as required */ |
| 97 | +int require_option(char *name) |
| 98 | +{ |
| 99 | + int i; |
| 100 | + for (i = 0; dhcp_options[i].code; i++) { |
| 101 | + if (strcmp(name, dhcp_options[i].name) == 0 ){ |
| 102 | + dhcp_options[i].flags |= OPTION_REQ; |
| 103 | + return 0; |
| 104 | + } |
| 105 | + } |
| 106 | + return 1; |
| 107 | +} |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 108 | + |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 109 | /* get an option with bounds checking (warning, not aligned). */ |
| 110 | uint8_t *get_option(struct dhcpMessage *packet, int code) |
| 111 | { |
| 112 | Index: networking/udhcp/options.h |
| 113 | =================================================================== |
| 114 | RCS file: /var/cvs/busybox/networking/udhcp/options.h,v |
| 115 | retrieving revision 1.5 |
| 116 | diff -u -r1.5 options.h |
| 117 | --- a/networking/udhcp/options.h 30 Jan 2004 23:45:12 -0000 1.5 |
| 118 | +++ b/networking/udhcp/options.h 5 Mar 2004 14:32:46 -0000 |
| 119 | @@ -30,6 +30,7 @@ |
| 120 | extern struct dhcp_option dhcp_options[]; |
| 121 | extern int option_lengths[]; |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 122 | |
Glenn L McGrath | ec58bce | 2004-03-05 14:35:00 +0000 | [diff] [blame] | 123 | +int require_option(char *name); |
| 124 | uint8_t *get_option(struct dhcpMessage *packet, int code); |
| 125 | int end_option(uint8_t *optionptr); |
| 126 | int add_option_string(uint8_t *optionptr, uint8_t *string); |