diff options
-rw-r--r-- | networking/udhcp/README.udhcpc | 3 | ||||
-rw-r--r-- | networking/udhcp/clientpacket.c | 1 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 24 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 1 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.h | 1 | ||||
-rw-r--r-- | networking/udhcp/options.c | 4 |
6 files changed, 30 insertions, 4 deletions
diff --git a/networking/udhcp/README.udhcpc b/networking/udhcp/README.udhcpc index d720a37cf..e19bf3750 100644 --- a/networking/udhcp/README.udhcpc +++ b/networking/udhcp/README.udhcpc | |||
@@ -12,7 +12,8 @@ The command line options for the udhcp client are: | |||
12 | 12 | ||
13 | -c, --clientid=CLIENTID Client identifier | 13 | -c, --clientid=CLIENTID Client identifier |
14 | -H, --hostname=HOSTNAME Client hostname | 14 | -H, --hostname=HOSTNAME Client hostname |
15 | -h, Alias for -H | 15 | -h, Alias for -H |
16 | -F, --fqdn=FQDN Client fully qualified domain name | ||
16 | -f, --foreground Do not fork after getting lease | 17 | -f, --foreground Do not fork after getting lease |
17 | -b, --background Fork to background if lease cannot be | 18 | -b, --background Fork to background if lease cannot be |
18 | immediately negotiated. | 19 | immediately negotiated. |
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c index ec96601cb..c5e1c210b 100644 --- a/networking/udhcp/clientpacket.c +++ b/networking/udhcp/clientpacket.c | |||
@@ -78,6 +78,7 @@ static void init_packet(struct dhcpMessage *packet, char type) | |||
78 | memcpy(packet->chaddr, client_config.arp, 6); | 78 | memcpy(packet->chaddr, client_config.arp, 6); |
79 | add_option_string(packet->options, client_config.clientid); | 79 | add_option_string(packet->options, client_config.clientid); |
80 | if (client_config.hostname) add_option_string(packet->options, client_config.hostname); | 80 | if (client_config.hostname) add_option_string(packet->options, client_config.hostname); |
81 | if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn); | ||
81 | add_option_string(packet->options, (uint8_t *) &vendor_id); | 82 | add_option_string(packet->options, (uint8_t *) &vendor_id); |
82 | } | 83 | } |
83 | 84 | ||
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 449b51763..95fa8150d 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -67,6 +67,7 @@ struct client_config_t client_config = { | |||
67 | script: DEFAULT_SCRIPT, | 67 | script: DEFAULT_SCRIPT, |
68 | clientid: NULL, | 68 | clientid: NULL, |
69 | hostname: NULL, | 69 | hostname: NULL, |
70 | fqdn: NULL, | ||
70 | ifindex: 0, | 71 | ifindex: 0, |
71 | arp: "\0\0\0\0\0\0", /* appease gcc-3.0 */ | 72 | arp: "\0\0\0\0\0\0", /* appease gcc-3.0 */ |
72 | }; | 73 | }; |
@@ -79,6 +80,7 @@ static void __attribute__ ((noreturn)) show_usage(void) | |||
79 | " -c, --clientid=CLIENTID Client identifier\n" | 80 | " -c, --clientid=CLIENTID Client identifier\n" |
80 | " -H, --hostname=HOSTNAME Client hostname\n" | 81 | " -H, --hostname=HOSTNAME Client hostname\n" |
81 | " -h Alias for -H\n" | 82 | " -h Alias for -H\n" |
83 | " -F, --fqdn=FQDN Client fully qualified domain name\n" | ||
82 | " -f, --foreground Do not fork after getting lease\n" | 84 | " -f, --foreground Do not fork after getting lease\n" |
83 | " -b, --background Fork to background if lease cannot be\n" | 85 | " -b, --background Fork to background if lease cannot be\n" |
84 | " immediately negotiated.\n" | 86 | " immediately negotiated.\n" |
@@ -197,7 +199,8 @@ int main(int argc, char *argv[]) | |||
197 | {"foreground", no_argument, 0, 'f'}, | 199 | {"foreground", no_argument, 0, 'f'}, |
198 | {"background", no_argument, 0, 'b'}, | 200 | {"background", no_argument, 0, 'b'}, |
199 | {"hostname", required_argument, 0, 'H'}, | 201 | {"hostname", required_argument, 0, 'H'}, |
200 | {"hostname", required_argument, 0, 'h'}, | 202 | {"hostname", required_argument, 0, 'h'}, |
203 | {"fqdn", required_argument, 0, 'F'}, | ||
201 | {"interface", required_argument, 0, 'i'}, | 204 | {"interface", required_argument, 0, 'i'}, |
202 | {"now", no_argument, 0, 'n'}, | 205 | {"now", no_argument, 0, 'n'}, |
203 | {"pidfile", required_argument, 0, 'p'}, | 206 | {"pidfile", required_argument, 0, 'p'}, |
@@ -211,7 +214,7 @@ int main(int argc, char *argv[]) | |||
211 | /* get options */ | 214 | /* get options */ |
212 | while (1) { | 215 | while (1) { |
213 | int option_index = 0; | 216 | int option_index = 0; |
214 | c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index); | 217 | c = getopt_long(argc, argv, "c:fbH:h:F:i:np:qr:s:v", arg_options, &option_index); |
215 | if (c == -1) break; | 218 | if (c == -1) break; |
216 | 219 | ||
217 | switch (c) { | 220 | switch (c) { |
@@ -239,6 +242,23 @@ int main(int argc, char *argv[]) | |||
239 | client_config.hostname[OPT_LEN] = len; | 242 | client_config.hostname[OPT_LEN] = len; |
240 | strncpy(client_config.hostname + 2, optarg, len); | 243 | strncpy(client_config.hostname + 2, optarg, len); |
241 | break; | 244 | break; |
245 | case 'F': | ||
246 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | ||
247 | if (client_config.fqdn) free(client_config.fqdn); | ||
248 | client_config.fqdn = xmalloc(len + 5); | ||
249 | client_config.fqdn[OPT_CODE] = DHCP_FQDN; | ||
250 | client_config.fqdn[OPT_LEN] = len + 3; | ||
251 | /* Flags: 0000NEOS | ||
252 | S: 1 => Client requests Server to update A RR in DNS as well as PTR | ||
253 | O: 1 => Server indicates to client that DNS has been updated regardless | ||
254 | E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com" | ||
255 | N: 1 => Client requests Server to not update DNS | ||
256 | */ | ||
257 | client_config.fqdn[OPT_LEN + 1] = 0x1; | ||
258 | client_config.fqdn[OPT_LEN + 2] = 0; | ||
259 | client_config.fqdn[OPT_LEN + 3] = 0; | ||
260 | strncpy(client_config.fqdn + 5, optarg, len); | ||
261 | break; | ||
242 | case 'i': | 262 | case 'i': |
243 | client_config.interface = optarg; | 263 | client_config.interface = optarg; |
244 | break; | 264 | break; |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 9c4aa95f7..77c180944 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
@@ -27,6 +27,7 @@ struct client_config_t { | |||
27 | char *script; /* User script to run at dhcp events */ | 27 | char *script; /* User script to run at dhcp events */ |
28 | uint8_t *clientid; /* Optional client id to use */ | 28 | uint8_t *clientid; /* Optional client id to use */ |
29 | uint8_t *hostname; /* Optional hostname to use */ | 29 | uint8_t *hostname; /* Optional hostname to use */ |
30 | uint8_t *fqdn; /* Optional fully qualified domain name to use */ | ||
30 | int ifindex; /* Index number of the interface to use */ | 31 | int ifindex; /* Index number of the interface to use */ |
31 | uint8_t arp[6]; /* Our arp address */ | 32 | uint8_t arp[6]; /* Our arp address */ |
32 | }; | 33 | }; |
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h index c47f6aa3f..65c8348bf 100644 --- a/networking/udhcp/dhcpd.h +++ b/networking/udhcp/dhcpd.h | |||
@@ -63,6 +63,7 @@ | |||
63 | #define DHCP_T2 0x3b | 63 | #define DHCP_T2 0x3b |
64 | #define DHCP_VENDOR 0x3c | 64 | #define DHCP_VENDOR 0x3c |
65 | #define DHCP_CLIENT_ID 0x3d | 65 | #define DHCP_CLIENT_ID 0x3d |
66 | #define DHCP_FQDN 0x51 | ||
66 | 67 | ||
67 | #define DHCP_END 0xFF | 68 | #define DHCP_END 0xFF |
68 | 69 | ||
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index d75bc5aff..ae9819413 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -32,7 +32,9 @@ struct dhcp_option dhcp_options[] = { | |||
32 | {"ipttl", OPTION_U8, 0x17}, | 32 | {"ipttl", OPTION_U8, 0x17}, |
33 | {"mtu", OPTION_U16, 0x1a}, | 33 | {"mtu", OPTION_U16, 0x1a}, |
34 | {"broadcast", OPTION_IP | OPTION_REQ, 0x1c}, | 34 | {"broadcast", OPTION_IP | OPTION_REQ, 0x1c}, |
35 | {"ntpsrv", OPTION_IP | OPTION_LIST, 0x2a}, | 35 | {"nisdomain", OPTION_STRING | OPTION_REQ, 0x28}, |
36 | {"nissrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x29}, | ||
37 | {"ntpsrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a}, | ||
36 | {"wins", OPTION_IP | OPTION_LIST, 0x2c}, | 38 | {"wins", OPTION_IP | OPTION_LIST, 0x2c}, |
37 | {"requestip", OPTION_IP, 0x32}, | 39 | {"requestip", OPTION_IP, 0x32}, |
38 | {"lease", OPTION_U32, 0x33}, | 40 | {"lease", OPTION_U32, 0x33}, |