aboutsummaryrefslogtreecommitdiffstats
path: root/tools/hv/hv_kvp_daemon.c
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2012-09-05 16:50:11 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-10 19:42:32 -0400
commitc050372591bed4488a32e8bf271ae471af5098eb (patch)
treef1f9ec129758fc120e761bae7888042deacb2865 /tools/hv/hv_kvp_daemon.c
parent2aea3c712826824dbbbaa7b9c0b70936819304b4 (diff)
Tools: hv: Gather DHCP information
Collect information on dhcp setting for the specified interface. We invoke an external (Distro specific) script to get this information. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv/hv_kvp_daemon.c')
-rw-r--r--tools/hv/hv_kvp_daemon.c31
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