From 9f1f8cacfac8a15f44d2cece08427cb93b7c3c4c Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Fri, 26 Apr 2013 09:51:28 +0300 Subject: gdhcp: Add debug print for transaction id Print transaction id of sent and received messages so that it is easier to match the packets. --- gdhcp/client.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'gdhcp') diff --git a/gdhcp/client.c b/gdhcp/client.c index e8fa5d52..34e773f0 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -797,14 +797,15 @@ static int send_dhcpv6_msg(GDHCPClient *dhcp_client, int type, char *msg) packet = (struct dhcpv6_packet *)&buf[0]; ptr = buf + sizeof(struct dhcpv6_packet); - debug(dhcp_client, "sending DHCPv6 %s message", msg); - init_packet(dhcp_client, packet, type); dhcp_client->xid = packet->transaction_id[0] << 16 | packet->transaction_id[1] << 8 | packet->transaction_id[2]; + debug(dhcp_client, "sending DHCPv6 %s message xid 0x%04x", msg, + dhcp_client->xid); + max_buf = MAX_DHCPV6_PKT_SIZE - sizeof(struct dhcpv6_packet); add_dhcpv6_request_options(dhcp_client, packet, buf, max_buf, &ptr); @@ -1823,6 +1824,7 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, uint8_t *message_type = NULL, *client_id = NULL, *option, *server_id = NULL; uint16_t option_len = 0, status = 0; + uint32_t xid = 0; gpointer pkt; unsigned char buf[MAX_DHCPV6_PKT_SIZE]; uint16_t pkt_len = 0; @@ -1848,9 +1850,14 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, dhcp_client->listener_sockfd); pkt_len = re; pkt = packet6; - } else + xid = packet6->transaction_id[0] << 16 | + packet6->transaction_id[1] << 8 | + packet6->transaction_id[2]; + } else { re = dhcp_recv_l3_packet(&packet, dhcp_client->listener_sockfd); + xid = packet.xid; + } } else if (dhcp_client->listen_mode == L_ARP) { ipv4ll_recv_arp_packet(dhcp_client); return TRUE; @@ -1910,8 +1917,8 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition, /* No message type / client id option, ignore package */ return TRUE; - debug(dhcp_client, "received DHCP packet (current state %d)", - dhcp_client->state); + debug(dhcp_client, "received DHCP packet xid 0x%04x " + "(current state %d)", xid, dhcp_client->state); switch (dhcp_client->state) { case INIT_SELECTING: -- cgit v1.2.3