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
34 typedef struct _GDHCPClient GDHCPClient;
37 G_DHCP_CLIENT_ERROR_NONE,
38 G_DHCP_CLIENT_ERROR_INTERFACE_UNAVAILABLE,
39 G_DHCP_CLIENT_ERROR_INTERFACE_IN_USE,
40 G_DHCP_CLIENT_ERROR_INTERFACE_DOWN,
41 G_DHCP_CLIENT_ERROR_NOMEM,
42 G_DHCP_CLIENT_ERROR_INVALID_INDEX,
43 G_DHCP_CLIENT_ERROR_INVALID_OPTION
47 G_DHCP_CLIENT_EVENT_LEASE_AVAILABLE,
48 G_DHCP_CLIENT_EVENT_IPV4LL_AVAILABLE,
49 G_DHCP_CLIENT_EVENT_NO_LEASE,
50 G_DHCP_CLIENT_EVENT_LEASE_LOST,
51 G_DHCP_CLIENT_EVENT_IPV4LL_LOST,
52 G_DHCP_CLIENT_EVENT_ADDRESS_CONFLICT,
61 #define G_DHCP_SUBNET 0x01
62 #define G_DHCP_ROUTER 0x03
63 #define G_DHCP_TIME_SERVER 0x04
64 #define G_DHCP_DNS_SERVER 0x06
65 #define G_DHCP_DOMAIN_NAME 0x0f
66 #define G_DHCP_HOST_NAME 0x0c
67 #define G_DHCP_NTP_SERVER 0x2a
69 typedef void (*GDHCPClientEventFunc) (GDHCPClient *client, gpointer user_data);
71 typedef void (*GDHCPDebugFunc)(const char *str, gpointer user_data);
73 GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
74 GDHCPClientError *error);
76 int g_dhcp_client_start(GDHCPClient *client, const char *last_address);
77 void g_dhcp_client_stop(GDHCPClient *client);
79 GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
80 void g_dhcp_client_unref(GDHCPClient *client);
82 void g_dhcp_client_register_event(GDHCPClient *client,
83 GDHCPClientEvent event,
84 GDHCPClientEventFunc func,
87 GDHCPClientError g_dhcp_client_set_request(GDHCPClient *client,
88 unsigned char option_code);
89 GDHCPClientError g_dhcp_client_set_send(GDHCPClient *client,
90 unsigned char option_code,
91 const char *option_value);
93 char *g_dhcp_client_get_address(GDHCPClient *client);
94 char *g_dhcp_client_get_netmask(GDHCPClient *client);
95 GList *g_dhcp_client_get_option(GDHCPClient *client,
96 unsigned char option_code);
97 int g_dhcp_client_get_index(GDHCPClient *client);
99 void g_dhcp_client_set_debug(GDHCPClient *client,
100 GDHCPDebugFunc func, gpointer user_data);
101 #if defined TIZEN_EXT
102 void g_dhcp_client_set_address_known(GDHCPClient *client, gboolean known);
107 G_DHCP_SERVER_ERROR_NONE,
108 G_DHCP_SERVER_ERROR_INTERFACE_UNAVAILABLE,
109 G_DHCP_SERVER_ERROR_INTERFACE_IN_USE,
110 G_DHCP_SERVER_ERROR_INTERFACE_DOWN,
111 G_DHCP_SERVER_ERROR_NOMEM,
112 G_DHCP_SERVER_ERROR_INVALID_INDEX,
113 G_DHCP_SERVER_ERROR_INVALID_OPTION,
114 G_DHCP_SERVER_ERROR_IP_ADDRESS_INVALID
117 typedef void (*GDHCPSaveLeaseFunc) (unsigned char *mac,
118 unsigned int nip, unsigned int expire);
121 typedef struct _GDHCPServer GDHCPServer;
123 GDHCPServer *g_dhcp_server_new(GDHCPType type,
124 int ifindex, GDHCPServerError *error);
125 int g_dhcp_server_start(GDHCPServer *server);
126 void g_dhcp_server_stop(GDHCPServer *server);
128 GDHCPServer *g_dhcp_server_ref(GDHCPServer *server);
129 void g_dhcp_server_unref(GDHCPServer *server);
131 int g_dhcp_server_set_option(GDHCPServer *server,
132 unsigned char option_code, const char *option_value);
133 int g_dhcp_server_set_ip_range(GDHCPServer *server,
134 const char *start_ip, const char *end_ip);
135 void g_dhcp_server_load_lease(GDHCPServer *dhcp_server, unsigned int expire,
136 unsigned char *mac, unsigned int lease_ip);
137 void g_dhcp_server_set_debug(GDHCPServer *server,
138 GDHCPDebugFunc func, gpointer user_data);
139 void g_dhcp_server_set_lease_time(GDHCPServer *dhcp_server,
140 unsigned int lease_time);
141 void g_dhcp_server_set_save_lease(GDHCPServer *dhcp_server,
142 GDHCPSaveLeaseFunc func, gpointer user_data);
147 #endif /* __G_DHCP_H */