static GTimer *timer = NULL;
+static inline void debug(GDHCPClient *client, const char *format, ...)
+{
+ char str[256];
+ va_list ap;
+
+ if (client->debug_func == NULL)
+ return;
+
+ va_start(ap, format);
+
+ if (vsnprintf(str, sizeof(str), format, ap) > 0)
+ client->debug_func(str, client->debug_data);
+
+ va_end(ap);
+}
+
/* Initialize the packet with the proper defaults */
static void init_packet(GDHCPClient *dhcp_client,
struct dhcp_packet *packet, char type)
{
struct dhcp_packet packet;
+ debug(dhcp_client, "sending DHCP discover request");
+
init_packet(dhcp_client, &packet, DHCPDISCOVER);
packet.xid = dhcp_client->xid;
struct dhcp_packet packet;
struct in_addr addr;
+ debug(dhcp_client, "sending DHCP select request");
+
init_packet(dhcp_client, &packet, DHCPREQUEST);
packet.xid = dhcp_client->xid;
{
struct dhcp_packet packet;
+ debug(dhcp_client, "sending DHCP renew request");
+
init_packet(dhcp_client , &packet, DHCPREQUEST);
packet.xid = dhcp_client->xid;
packet.ciaddr = dhcp_client->requested_ip;
{
struct dhcp_packet packet;
+ debug(dhcp_client, "sending DHCP rebound request");
+
init_packet(dhcp_client , &packet, DHCPREQUEST);
packet.xid = dhcp_client->xid;
packet.ciaddr = dhcp_client->requested_ip;
{
struct dhcp_packet packet;
+ debug(dhcp_client, "sending DHCP release request");
+
init_packet(dhcp_client, &packet, DHCPRELEASE);
packet.xid = rand();
packet.ciaddr = ciaddr;
}
void g_dhcp_client_set_debug(GDHCPClient *dhcp_client,
- GDHCPDebugFunc func, gpointer data)
+ GDHCPDebugFunc func, gpointer user_data)
{
if (dhcp_client == NULL)
return;
dhcp_client->debug_func = func;
- dhcp_client->debug_data = data;
+ dhcp_client->debug_data = user_data;
}