]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add optional hexdump of packet read and write
authorNick Porter <nick@portercomputing.co.uk>
Mon, 3 Nov 2025 11:51:25 +0000 (11:51 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 3 Nov 2025 11:51:25 +0000 (11:51 +0000)
For when really low level debugging is needed

src/lib/io/listen.h
src/lib/io/network.c

index d5441c9d83d4f1a139e7c8ede08dc3a905d3464f..e873803854d60bad3e42c32386a417f0edf56f84 100644 (file)
@@ -49,6 +49,9 @@ struct fr_listen {
                                                        ///< populated when event_list_set callback is run which doesn't
                                                        ///< happen if the short cut is taken.
 
+       bool                    read_hexdump;           //!< Do we debug hexdump packets as they're read.
+       bool                    write_hexdump;          //!< Do we debug hexdump packets as they're written.
+
        size_t                  default_message_size;   //!< copied from app_io, but may be changed
        size_t                  num_messages;           //!< for the message ring buffer
 };
index f09290682d7c751b5ab38526b93b51dabe47ad5c..45092bbfcb0f486a09d3fd621818913cb99e6deb 100644 (file)
@@ -955,6 +955,7 @@ next_message:
        s->cd = NULL;
 
        DEBUG3("Read %zd byte(s) from FD %u", data_size, sockfd);
+       if (s->listen->read_hexdump) HEXDUMP2(cd->m.data, data_size, "%s read ", s->listen->name);
        nr->stats.in++;
        s->stats.in++;
 
@@ -1178,6 +1179,7 @@ static void fr_network_write(UNUSED fr_event_list_t *el, UNUSED int sockfd, UNUS
                int rcode;
 
                fr_assert(li == cd->listen);
+               if (li->write_hexdump) HEXDUMP2(cd->m.data, cd->m.data_size, "%s writing ", li->name);
                rcode = li->app_io->write(li, cd->packet_ctx,
                                          cd->reply.request_time,
                                          cd->m.data, cd->m.data_size, s->written);