Destroy timer of DHCP test program
[framework/connectivity/connman.git] / tools / dhcp-test.c
index 325123d..cf4ff71 100644 (file)
 #include <net/ethernet.h>
 #include <linux/if_arp.h>
 
-#include <gdhcp.h>
+#include <gdhcp/gdhcp.h>
 
 static GTimer *timer;
 
-static GMainLoop *main_loop = NULL;
+static GMainLoop *main_loop;
 
 static void sig_term(int sig)
 {
@@ -68,7 +68,7 @@ static void handle_error(GDHCPClientError error)
        case G_DHCP_CLIENT_ERROR_NONE:
                printf("dhcp client ok\n");
                break;
-       case G_DHCP_CLIENT_ERROR_INERFACE_UNAVAILABLE:
+       case G_DHCP_CLIENT_ERROR_INTERFACE_UNAVAILABLE:
                printf("Interface unavailable\n");
                break;
        case G_DHCP_CLIENT_ERROR_INTERFACE_IN_USE:
@@ -120,6 +120,10 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
        for (list = option_value; list; list = list->next)
                printf("routers %s\n", (char *) list->data);
 
+       option_value = g_dhcp_client_get_option(dhcp_client, G_DHCP_HOST_NAME);
+       for (list = option_value; list; list = list->next)
+               printf("hostname %s\n", (char *) list->data);
+
        print_timestamp();
 }
 
@@ -181,5 +185,7 @@ int main(int argc, char *argv[])
 
        g_main_loop_unref(main_loop);
 
+       g_timer_destroy(timer);
+
        return 0;
 }