3 * DHCP library with GLib integration
5 * Copyright (C) 2009-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 typedef struct _GDHCPClient GDHCPClient;
39 G_DHCP_CLIENT_ERROR_NONE,
40 G_DHCP_CLIENT_ERROR_INTERFACE_UNAVAILABLE,
41 G_DHCP_CLIENT_ERROR_INTERFACE_IN_USE,
42 G_DHCP_CLIENT_ERROR_INTERFACE_DOWN,
43 G_DHCP_CLIENT_ERROR_NOMEM,
44 G_DHCP_CLIENT_ERROR_INVALID_INDEX,
45 G_DHCP_CLIENT_ERROR_INVALID_OPTION
49 G_DHCP_CLIENT_EVENT_LEASE_AVAILABLE,
50 G_DHCP_CLIENT_EVENT_IPV4LL_AVAILABLE,
51 G_DHCP_CLIENT_EVENT_NO_LEASE,
52 G_DHCP_CLIENT_EVENT_LEASE_LOST,
53 G_DHCP_CLIENT_EVENT_IPV4LL_LOST,
54 G_DHCP_CLIENT_EVENT_ADDRESS_CONFLICT,
55 G_DHCP_CLIENT_EVENT_INFORMATION_REQ,
64 #define G_DHCP_SUBNET 0x01
65 #define G_DHCP_ROUTER 0x03
66 #define G_DHCP_TIME_SERVER 0x04
67 #define G_DHCP_DNS_SERVER 0x06
68 #define G_DHCP_DOMAIN_NAME 0x0f
69 #define G_DHCP_HOST_NAME 0x0c
70 #define G_DHCP_NTP_SERVER 0x2a
72 #define G_DHCPV6_CLIENTID 1
73 #define G_DHCPV6_SERVERID 2
74 #define G_DHCPV6_ORO 6
75 #define G_DHCPV6_STATUS_CODE 13
76 #define G_DHCPV6_DNS_SERVERS 23
77 #define G_DHCPV6_SNTP_SERVERS 31
80 G_DHCPV6_DUID_LLT = 1,
85 typedef void (*GDHCPClientEventFunc) (GDHCPClient *client, gpointer user_data);
87 typedef void (*GDHCPDebugFunc)(const char *str, gpointer user_data);
89 GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
90 GDHCPClientError *error);
92 int g_dhcp_client_start(GDHCPClient *client, const char *last_address);
93 void g_dhcp_client_stop(GDHCPClient *client);
95 GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
96 void g_dhcp_client_unref(GDHCPClient *client);
98 void g_dhcp_client_register_event(GDHCPClient *client,
99 GDHCPClientEvent event,
100 GDHCPClientEventFunc func,
103 GDHCPClientError g_dhcp_client_set_request(GDHCPClient *client,
104 unsigned int option_code);
105 GDHCPClientError g_dhcp_client_set_send(GDHCPClient *client,
106 unsigned char option_code,
107 const char *option_value);
109 char *g_dhcp_client_get_address(GDHCPClient *client);
110 char *g_dhcp_client_get_netmask(GDHCPClient *client);
111 GList *g_dhcp_client_get_option(GDHCPClient *client,
112 unsigned char option_code);
113 int g_dhcp_client_get_index(GDHCPClient *client);
115 void g_dhcp_client_set_debug(GDHCPClient *client,
116 GDHCPDebugFunc func, gpointer user_data);
117 int g_dhcpv6_create_duid(GDHCPDuidType duid_type, int index, int type,
118 unsigned char **duid, int *duid_len);
119 int g_dhcpv6_client_set_duid(GDHCPClient *dhcp_client, unsigned char *duid,
121 void g_dhcpv6_client_set_send(GDHCPClient *dhcp_client, uint16_t option_code,
122 uint8_t *option_value, uint16_t option_len);
123 uint16_t g_dhcpv6_client_get_status(GDHCPClient *dhcp_client);
124 int g_dhcpv6_client_set_oro(GDHCPClient *dhcp_client, int args, ...);
128 G_DHCP_SERVER_ERROR_NONE,
129 G_DHCP_SERVER_ERROR_INTERFACE_UNAVAILABLE,
130 G_DHCP_SERVER_ERROR_INTERFACE_IN_USE,
131 G_DHCP_SERVER_ERROR_INTERFACE_DOWN,
132 G_DHCP_SERVER_ERROR_NOMEM,
133 G_DHCP_SERVER_ERROR_INVALID_INDEX,
134 G_DHCP_SERVER_ERROR_INVALID_OPTION,
135 G_DHCP_SERVER_ERROR_IP_ADDRESS_INVALID
138 typedef void (*GDHCPSaveLeaseFunc) (unsigned char *mac,
139 unsigned int nip, unsigned int expire);
142 typedef struct _GDHCPServer GDHCPServer;
144 GDHCPServer *g_dhcp_server_new(GDHCPType type,
145 int ifindex, GDHCPServerError *error);
146 int g_dhcp_server_start(GDHCPServer *server);
147 void g_dhcp_server_stop(GDHCPServer *server);
149 GDHCPServer *g_dhcp_server_ref(GDHCPServer *server);
150 void g_dhcp_server_unref(GDHCPServer *server);
152 int g_dhcp_server_set_option(GDHCPServer *server,
153 unsigned char option_code, const char *option_value);
154 int g_dhcp_server_set_ip_range(GDHCPServer *server,
155 const char *start_ip, const char *end_ip);
156 void g_dhcp_server_load_lease(GDHCPServer *dhcp_server, unsigned int expire,
157 unsigned char *mac, unsigned int lease_ip);
158 void g_dhcp_server_set_debug(GDHCPServer *server,
159 GDHCPDebugFunc func, gpointer user_data);
160 void g_dhcp_server_set_lease_time(GDHCPServer *dhcp_server,
161 unsigned int lease_time);
162 void g_dhcp_server_set_save_lease(GDHCPServer *dhcp_server,
163 GDHCPSaveLeaseFunc func, gpointer user_data);
168 #endif /* __G_DHCP_H */