Make sending/receiving debug messages consistent, and use a slightly compacted form
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 Apr 2014 15:36:54 +0000 (16:36 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 2 May 2014 13:57:53 +0000 (14:57 +0100)
src/lib/radius.c
src/lib/tcp.c
src/modules/proto_dhcp/dhcp.c

index ed42521..44753ab 100644 (file)
@@ -1722,7 +1722,7 @@ int rad_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                what = "Reply";
        }
 
-       DEBUG("Sending %s of id %d from %s port %u to %s port %u\n",
+       DEBUG("Sending %s Id %d from %s:%u to %s:%u\n",
              what, packet->id,
              inet_ntop(packet->src_ipaddr.af,
                        &packet->src_ipaddr.ipaddr,
@@ -2054,7 +2054,7 @@ int rad_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                 *      the VP list again only for debugging.
                 */
        } else if (fr_debug_flag) {
-               DEBUG("Sending %s of id %d from %s port %u to %s port %u\n", what,
+               DEBUG("Sending %s Id %d from %s:%u to %s:%u\n", what,
                      packet->id,
                      inet_ntop(packet->src_ipaddr.af, &packet->src_ipaddr.ipaddr,
                                ip_src_buffer, sizeof(ip_src_buffer)),
@@ -2694,25 +2694,36 @@ RADIUS_PACKET *rad_recv(int fd, int flags)
        packet->vps = NULL;
 
        if (fr_debug_flag) {
-               char host_ipaddr[128];
+               char src_ipaddr[128];
+               char dst_ipaddr[128];
 
                if (is_radius_code(packet->code)) {
-                       DEBUG("rad_recv: %s packet from host %s port %d",
+                       DEBUG("Received %s Id %d from %s:%d to %s:%d length %d\n",
                              fr_packet_codes[packet->code],
+                             packet->id,
                              inet_ntop(packet->src_ipaddr.af,
                                        &packet->src_ipaddr.ipaddr,
-                                       host_ipaddr, sizeof(host_ipaddr)),
-                             packet->src_port);
+                                       src_ipaddr, sizeof(src_ipaddr)),
+                             packet->src_port,
+                             inet_ntop(packet->dst_ipaddr.af,
+                                       &packet->dst_ipaddr.ipaddr,
+                                       dst_ipaddr, sizeof(dst_ipaddr)),
+                             packet->dst_port,
+                             (int) packet->data_len);
                } else {
-                       DEBUG("rad_recv: Packet from host %s port %d code=%d",
+                       DEBUG("Received code %d Id %d from %s:%d to %s:%d length %d\n",
+                             packet->code,
+                             packet->id,
                              inet_ntop(packet->src_ipaddr.af,
                                        &packet->src_ipaddr.ipaddr,
-                                       host_ipaddr, sizeof(host_ipaddr)),
+                                       src_ipaddr, sizeof(src_ipaddr)),
                              packet->src_port,
-                             packet->code);
+                             inet_ntop(packet->dst_ipaddr.af,
+                                       &packet->dst_ipaddr.ipaddr,
+                                       dst_ipaddr, sizeof(dst_ipaddr)),
+                             packet->dst_port,
+                             (int) packet->data_len);
                }
-               DEBUG(", id=%d, length=%d\n",
-                     packet->id, (int) packet->data_len);
        }
 
 #ifndef NDEBUG
index 426d92a..7f36207 100644 (file)
@@ -251,10 +251,10 @@ int fr_tcp_read_packet(RADIUS_PACKET *packet, int flags)
 
 
                if (is_radius_code(packet->code)) {
-                       DEBUG("rad_recv: %s packet from %s",
+                       DEBUG("Received %s packet from %s",
                              fr_packet_codes[packet->code], buffer);
                } else {
-                       DEBUG("rad_recv: Packet from %s code=%d",
+                       DEBUG("Received packet from %s code %d",
                              buffer, packet->code);
                }
                DEBUG(", id=%d, length=%zu\n", packet->id, packet->data_len);
index 89d171c..e3fa2f5 100644 (file)
@@ -375,7 +375,7 @@ RADIUS_PACKET *fr_dhcp_recv(int sockfd)
                                 packet->code - PW_DHCP_OFFSET);
                }
 
-               DEBUG("Received %s of id %08x from %s:%d to %s:%d\n",
+               DEBUG("Received %s of Id %08x from %s:%d to %s:%d\n",
                       name, (unsigned int) packet->id,
                       inet_ntop(packet->src_ipaddr.af,
                                 &packet->src_ipaddr.ipaddr,
@@ -432,9 +432,9 @@ int fr_dhcp_send(RADIUS_PACKET *packet)
 
                DEBUG(
 #ifdef WITH_UDPFROMTO
-               "Sending %s of id %08x from %s:%d to %s:%d\n",
+               "Sending %s Id %08x from %s:%d to %s:%d\n",
 #else
-               "Sending %s of id %08x to %s:%d\n",
+               "Sending %s Id %08x to %s:%d\n",
 #endif
                   name, (unsigned int) packet->id,
 #ifdef WITH_UDPFROMTO