Implement dhclient_destroy().
[openvswitch] / lib / dhcp-client.c
index bafa19d00e2a1ffaa0f2f2a049b504e77e0f5d29..1e481cf8fc4edb6c84e38b791114442699e386b9 100644 (file)
@@ -49,7 +49,6 @@
 #include "flow.h"
 #include "netdev.h"
 #include "ofpbuf.h"
-#include "ofp-print.h"
 #include "poll-loop.h"
 #include "sat-math.h"
 #include "timeval.h"
@@ -207,6 +206,19 @@ dhclient_create(const char *netdev_name,
     return 0;
 }
 
+/* Destroys 'cli' and frees all related resources. */
+void
+dhclient_destroy(struct dhclient *cli)
+{
+    if (cli) {
+        dhcp_msg_uninit(cli->binding);
+        free(cli->binding);
+        netdev_close(cli->netdev);
+        ds_destroy(&cli->s);
+        free(cli);
+    }
+}
+
 /* Forces 'cli' into a (re)initialization state, in which no address is bound
  * but the client is advertising to obtain one.  If 'requested_ip' is nonzero,
  * then the client will attempt to re-bind to that IP address; otherwise, it
@@ -914,7 +926,7 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg)
             continue;
         }
 
-        ofpbuf_pull(&b, b.l7 - b.data);
+        ofpbuf_pull(&b, (char *)b.l7 - (char*)b.data);
         error = dhcp_parse(msg, &b);
         if (!error) {
             VLOG_DBG_RL(&rl, "received %s",