diff options
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index cfa23a115d18..6fb2c1c6c32e 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -524,6 +524,9 @@ static void kvp_get_ipconfig_info(char *if_name, | |||
524 | struct hv_kvp_ipaddr_value *buffer) | 524 | struct hv_kvp_ipaddr_value *buffer) |
525 | { | 525 | { |
526 | char cmd[512]; | 526 | char cmd[512]; |
527 | char dhcp_info[128]; | ||
528 | char *p; | ||
529 | FILE *file; | ||
527 | 530 | ||
528 | /* | 531 | /* |
529 | * Get the address of default gateway (ipv4). | 532 | * Get the address of default gateway (ipv4). |
@@ -572,6 +575,34 @@ static void kvp_get_ipconfig_info(char *if_name, | |||
572 | */ | 575 | */ |
573 | kvp_process_ipconfig_file(cmd, (char *)buffer->dns_addr, | 576 | kvp_process_ipconfig_file(cmd, (char *)buffer->dns_addr, |
574 | (MAX_IP_ADDR_SIZE * 2), INET_ADDRSTRLEN, 0); | 577 | (MAX_IP_ADDR_SIZE * 2), INET_ADDRSTRLEN, 0); |
578 | |||
579 | /* | ||
580 | * Gather the DHCP state. | ||
581 | * We will gather this state by invoking an external script. | ||
582 | * The parameter to the script is the interface name. | ||
583 | * Here is the expected output: | ||
584 | * | ||
585 | * Enabled: DHCP enabled. | ||
586 | */ | ||
587 | |||
588 | sprintf(cmd, "%s %s", "hv_get_dhcp_info", if_name); | ||
589 | |||
590 | file = popen(cmd, "r"); | ||
591 | if (file == NULL) | ||
592 | return; | ||
593 | |||
594 | p = fgets(dhcp_info, sizeof(dhcp_info), file); | ||
595 | if (p == NULL) { | ||
596 | pclose(file); | ||
597 | return; | ||
598 | } | ||
599 | |||
600 | if (!strncmp(p, "Enabled", 7)) | ||
601 | buffer->dhcp_enabled = 1; | ||
602 | else | ||
603 | buffer->dhcp_enabled = 0; | ||
604 | |||
605 | pclose(file); | ||
575 | } | 606 | } |
576 | 607 | ||
577 | 608 | ||