mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
merge from udhcp module
This commit is contained in:
parent
dcc286607c
commit
d824853de3
@ -12,7 +12,8 @@ The command line options for the udhcp client are:
|
||||
|
||||
-c, --clientid=CLIENTID Client identifier
|
||||
-H, --hostname=HOSTNAME Client hostname
|
||||
-h, Alias for -H
|
||||
-h, Alias for -H
|
||||
-F, --fqdn=FQDN Client fully qualified domain name
|
||||
-f, --foreground Do not fork after getting lease
|
||||
-b, --background Fork to background if lease cannot be
|
||||
immediately negotiated.
|
||||
|
@ -78,6 +78,7 @@ static void init_packet(struct dhcpMessage *packet, char type)
|
||||
memcpy(packet->chaddr, client_config.arp, 6);
|
||||
add_option_string(packet->options, client_config.clientid);
|
||||
if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
|
||||
if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn);
|
||||
add_option_string(packet->options, (uint8_t *) &vendor_id);
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ struct client_config_t client_config = {
|
||||
script: DEFAULT_SCRIPT,
|
||||
clientid: NULL,
|
||||
hostname: NULL,
|
||||
fqdn: NULL,
|
||||
ifindex: 0,
|
||||
arp: "\0\0\0\0\0\0", /* appease gcc-3.0 */
|
||||
};
|
||||
@ -79,6 +80,7 @@ static void __attribute__ ((noreturn)) show_usage(void)
|
||||
" -c, --clientid=CLIENTID Client identifier\n"
|
||||
" -H, --hostname=HOSTNAME Client hostname\n"
|
||||
" -h Alias for -H\n"
|
||||
" -F, --fqdn=FQDN Client fully qualified domain name\n"
|
||||
" -f, --foreground Do not fork after getting lease\n"
|
||||
" -b, --background Fork to background if lease cannot be\n"
|
||||
" immediately negotiated.\n"
|
||||
@ -197,7 +199,8 @@ int main(int argc, char *argv[])
|
||||
{"foreground", no_argument, 0, 'f'},
|
||||
{"background", no_argument, 0, 'b'},
|
||||
{"hostname", required_argument, 0, 'H'},
|
||||
{"hostname", required_argument, 0, 'h'},
|
||||
{"hostname", required_argument, 0, 'h'},
|
||||
{"fqdn", required_argument, 0, 'F'},
|
||||
{"interface", required_argument, 0, 'i'},
|
||||
{"now", no_argument, 0, 'n'},
|
||||
{"pidfile", required_argument, 0, 'p'},
|
||||
@ -211,7 +214,7 @@ int main(int argc, char *argv[])
|
||||
/* get options */
|
||||
while (1) {
|
||||
int option_index = 0;
|
||||
c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
|
||||
c = getopt_long(argc, argv, "c:fbH:h:F:i:np:qr:s:v", arg_options, &option_index);
|
||||
if (c == -1) break;
|
||||
|
||||
switch (c) {
|
||||
@ -239,6 +242,23 @@ int main(int argc, char *argv[])
|
||||
client_config.hostname[OPT_LEN] = len;
|
||||
strncpy(client_config.hostname + 2, optarg, len);
|
||||
break;
|
||||
case 'F':
|
||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
||||
if (client_config.fqdn) free(client_config.fqdn);
|
||||
client_config.fqdn = xmalloc(len + 5);
|
||||
client_config.fqdn[OPT_CODE] = DHCP_FQDN;
|
||||
client_config.fqdn[OPT_LEN] = len + 3;
|
||||
/* Flags: 0000NEOS
|
||||
S: 1 => Client requests Server to update A RR in DNS as well as PTR
|
||||
O: 1 => Server indicates to client that DNS has been updated regardless
|
||||
E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
|
||||
N: 1 => Client requests Server to not update DNS
|
||||
*/
|
||||
client_config.fqdn[OPT_LEN + 1] = 0x1;
|
||||
client_config.fqdn[OPT_LEN + 2] = 0;
|
||||
client_config.fqdn[OPT_LEN + 3] = 0;
|
||||
strncpy(client_config.fqdn + 5, optarg, len);
|
||||
break;
|
||||
case 'i':
|
||||
client_config.interface = optarg;
|
||||
break;
|
||||
|
@ -27,6 +27,7 @@ struct client_config_t {
|
||||
char *script; /* User script to run at dhcp events */
|
||||
uint8_t *clientid; /* Optional client id to use */
|
||||
uint8_t *hostname; /* Optional hostname to use */
|
||||
uint8_t *fqdn; /* Optional fully qualified domain name to use */
|
||||
int ifindex; /* Index number of the interface to use */
|
||||
uint8_t arp[6]; /* Our arp address */
|
||||
};
|
||||
|
@ -63,6 +63,7 @@
|
||||
#define DHCP_T2 0x3b
|
||||
#define DHCP_VENDOR 0x3c
|
||||
#define DHCP_CLIENT_ID 0x3d
|
||||
#define DHCP_FQDN 0x51
|
||||
|
||||
#define DHCP_END 0xFF
|
||||
|
||||
|
@ -32,7 +32,9 @@ struct dhcp_option dhcp_options[] = {
|
||||
{"ipttl", OPTION_U8, 0x17},
|
||||
{"mtu", OPTION_U16, 0x1a},
|
||||
{"broadcast", OPTION_IP | OPTION_REQ, 0x1c},
|
||||
{"ntpsrv", OPTION_IP | OPTION_LIST, 0x2a},
|
||||
{"nisdomain", OPTION_STRING | OPTION_REQ, 0x28},
|
||||
{"nissrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x29},
|
||||
{"ntpsrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a},
|
||||
{"wins", OPTION_IP | OPTION_LIST, 0x2c},
|
||||
{"requestip", OPTION_IP, 0x32},
|
||||
{"lease", OPTION_U32, 0x33},
|
||||
|
Loading…
Reference in New Issue
Block a user