b37cac61bfca76b8d06eee3d2f5503525d827ab3
[cascardo/ovs.git] / lib / dhcp-client.h
1 /*
2  * Copyright (c) 2008 Nicira Networks.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef DHCP_CLIENT_H
18 #define DHCP_CLIENT_H 1
19
20 #include <stdbool.h>
21 #include <stdint.h>
22
23 struct dhclient;
24 struct dhcp_msg;
25 struct netdev;
26 int dhclient_create(const char *netdev,
27                     void (*modify_request)(struct dhcp_msg *, void *aux),
28                     bool (*validate_offer)(const struct dhcp_msg *, void *aux),
29                     void *aux, struct dhclient **);
30 void dhclient_set_max_timeout(struct dhclient *, unsigned int max_timeout);
31 void dhclient_destroy(struct dhclient *);
32
33 struct netdev *dhclient_get_netdev(struct dhclient *);
34
35 void dhclient_init(struct dhclient *, uint32_t requested_ip);
36 void dhclient_release(struct dhclient *);
37 void dhclient_force_renew(struct dhclient *, int deadline);
38 bool dhclient_is_bound(const struct dhclient *);
39 bool dhclient_changed(struct dhclient *);
40
41 const char *dhclient_get_state(const struct dhclient *);
42 unsigned int dhclient_get_state_elapsed(const struct dhclient *);
43 unsigned int dhclient_get_lease_remaining(const struct dhclient *);
44
45 uint32_t dhclient_get_ip(const struct dhclient *);
46 uint32_t dhclient_get_netmask(const struct dhclient *);
47 uint32_t dhclient_get_router(const struct dhclient *);
48 const struct dhcp_msg *dhclient_get_config(const struct dhclient *);
49
50 int dhclient_configure_netdev(struct dhclient *);
51 int dhclient_update_resolv_conf(struct dhclient *);
52
53 void dhclient_run(struct dhclient *);
54 void dhclient_wait(struct dhclient *);
55
56 #endif /* dhcp-client.h */