allow suppression of default client-id. fixes bug 000037. allows
busybox to match kernel and u-boot behavior with respect to client-id.
This commit is contained in:
parent
9d6e0833bc
commit
a39bba33c8
@ -2931,9 +2931,10 @@
|
|||||||
"Adjust filesystem options on ext[23] filesystems.\n\n"
|
"Adjust filesystem options on ext[23] filesystems.\n\n"
|
||||||
|
|
||||||
#define udhcpc_trivial_usage \
|
#define udhcpc_trivial_usage \
|
||||||
"[-fbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
|
"[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
|
||||||
#define udhcpc_full_usage \
|
#define udhcpc_full_usage \
|
||||||
"\t-c,\t--clientid=CLIENTID\tClient identifier\n" \
|
"\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
|
||||||
|
"\t-C,\t--clientid-none\tSuppress default client identifier\n" \
|
||||||
"\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
|
"\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
|
||||||
"\t-h,\t \tAlias for -H\n" \
|
"\t-h,\t \tAlias for -H\n" \
|
||||||
"\t-f,\t--foreground\tDo not fork after getting lease\n" \
|
"\t-f,\t--foreground\tDo not fork after getting lease\n" \
|
||||||
|
@ -76,7 +76,8 @@ static void init_packet(struct dhcpMessage *packet, char type)
|
|||||||
|
|
||||||
init_header(packet, type);
|
init_header(packet, type);
|
||||||
memcpy(packet->chaddr, client_config.arp, 6);
|
memcpy(packet->chaddr, client_config.arp, 6);
|
||||||
add_option_string(packet->options, client_config.clientid);
|
if (client_config.clientid)
|
||||||
|
add_option_string(packet->options, client_config.clientid);
|
||||||
if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
|
if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
|
||||||
if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn);
|
if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn);
|
||||||
add_option_string(packet->options, (uint8_t *) &vendor_id);
|
add_option_string(packet->options, (uint8_t *) &vendor_id);
|
||||||
|
@ -77,7 +77,8 @@ static void __attribute__ ((noreturn)) show_usage(void)
|
|||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"Usage: udhcpc [OPTIONS]\n\n"
|
"Usage: udhcpc [OPTIONS]\n\n"
|
||||||
" -c, --clientid=CLIENTID Client identifier\n"
|
" -c, --clientid=CLIENTID Set client identifier\n"
|
||||||
|
" -C, --clientid-none Suppress default client identifier\n"
|
||||||
" -H, --hostname=HOSTNAME Client hostname\n"
|
" -H, --hostname=HOSTNAME Client hostname\n"
|
||||||
" -h Alias for -H\n"
|
" -h Alias for -H\n"
|
||||||
" -F, --fqdn=FQDN Client fully qualified domain name\n"
|
" -F, --fqdn=FQDN Client fully qualified domain name\n"
|
||||||
@ -193,9 +194,11 @@ int main(int argc, char *argv[])
|
|||||||
long now;
|
long now;
|
||||||
int max_fd;
|
int max_fd;
|
||||||
int sig;
|
int sig;
|
||||||
|
int no_clientid = 0;
|
||||||
|
|
||||||
static const struct option arg_options[] = {
|
static const struct option arg_options[] = {
|
||||||
{"clientid", required_argument, 0, 'c'},
|
{"clientid", required_argument, 0, 'c'},
|
||||||
|
{"clientid-none", no_argument, 0, 'C'},
|
||||||
{"foreground", no_argument, 0, 'f'},
|
{"foreground", no_argument, 0, 'f'},
|
||||||
{"background", no_argument, 0, 'b'},
|
{"background", no_argument, 0, 'b'},
|
||||||
{"hostname", required_argument, 0, 'H'},
|
{"hostname", required_argument, 0, 'H'},
|
||||||
@ -214,11 +217,12 @@ int main(int argc, char *argv[])
|
|||||||
/* get options */
|
/* get options */
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "c:fbH:h:F:i:np:qr:s:v", arg_options, &option_index);
|
c = getopt_long(argc, argv, "c:CfbH:h:F:i:np:qr:s:v", arg_options, &option_index);
|
||||||
if (c == -1) break;
|
if (c == -1) break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
|
if (no_clientid) show_usage();
|
||||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
||||||
if (client_config.clientid) free(client_config.clientid);
|
if (client_config.clientid) free(client_config.clientid);
|
||||||
client_config.clientid = xmalloc(len + 2);
|
client_config.clientid = xmalloc(len + 2);
|
||||||
@ -227,6 +231,10 @@ int main(int argc, char *argv[])
|
|||||||
client_config.clientid[OPT_DATA] = '\0';
|
client_config.clientid[OPT_DATA] = '\0';
|
||||||
strncpy(client_config.clientid + OPT_DATA, optarg, len);
|
strncpy(client_config.clientid + OPT_DATA, optarg, len);
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
if (client_config.clientid) show_usage();
|
||||||
|
no_clientid = 1;
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
client_config.foreground = 1;
|
client_config.foreground = 1;
|
||||||
break;
|
break;
|
||||||
@ -293,7 +301,8 @@ int main(int argc, char *argv[])
|
|||||||
NULL, client_config.arp) < 0)
|
NULL, client_config.arp) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!client_config.clientid) {
|
/* if not set, and not suppressed, setup the default client ID */
|
||||||
|
if (!client_config.clientid && !no_clientid) {
|
||||||
client_config.clientid = xmalloc(6 + 3);
|
client_config.clientid = xmalloc(6 + 3);
|
||||||
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
|
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
|
||||||
client_config.clientid[OPT_LEN] = 7;
|
client_config.clientid[OPT_LEN] = 7;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user