Fix --hostname option.
This commit is contained in:
parent
d96cb14711
commit
121e4d1510
@ -42,8 +42,8 @@ struct client_config_t {
|
|||||||
char abort_if_no_lease; /* Abort if no lease */
|
char abort_if_no_lease; /* Abort if no lease */
|
||||||
char background_if_no_lease; /* Fork to background if no lease */
|
char background_if_no_lease; /* Fork to background if no lease */
|
||||||
char *interface; /* The name of the interface to use */
|
char *interface; /* The name of the interface to use */
|
||||||
unsigned char *clientid; /* Optional client id to use */
|
unsigned char *clientid; /* Optional client id to use (unterminated) */
|
||||||
unsigned char *hostname; /* Optional hostname to use */
|
unsigned char *hostname; /* Optional hostname to use (unterminated) */
|
||||||
int ifindex; /* Index number of the interface to use */
|
int ifindex; /* Index number of the interface to use */
|
||||||
unsigned char arp[6]; /* Our arp address */
|
unsigned char arp[6]; /* Our arp address */
|
||||||
};
|
};
|
||||||
|
@ -326,14 +326,13 @@ int main(int argc, char **argv)
|
|||||||
len = strlen(optarg) > 64 ? 64 : strlen(optarg);
|
len = strlen(optarg) > 64 ? 64 : strlen(optarg);
|
||||||
if (client_config.hostname)
|
if (client_config.hostname)
|
||||||
free(client_config.hostname);
|
free(client_config.hostname);
|
||||||
client_config.hostname = xmalloc(len + 1);
|
client_config.hostname = xmalloc(len + 3);
|
||||||
client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
|
client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
|
||||||
client_config.hostname[OPT_LEN] = len;
|
client_config.hostname[OPT_LEN] = len + 1;
|
||||||
strlcpy((char*)client_config.hostname + OPT_DATA, optarg,
|
memcpy(client_config.hostname + 3, optarg, len);
|
||||||
len + 1 - (OPT_DATA - OPT_CODE));
|
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
client_config.interface = optarg;
|
client_config.interface = optarg;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
client_config.abort_if_no_lease = 1;
|
client_config.abort_if_no_lease = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user