]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add read / write hexdump options to RADIUS app_io
authorNick Porter <nick@portercomputing.co.uk>
Mon, 3 Nov 2025 11:55:47 +0000 (11:55 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 3 Nov 2025 11:56:10 +0000 (11:56 +0000)
src/listen/radius/proto_radius_tcp.c
src/listen/radius/proto_radius_udp.c

index 599d54de7270475f3ddb9e46f43f082f90e34335..a11ae376da1bba7fb065af4280c032ef84eab1a7 100644 (file)
@@ -61,11 +61,14 @@ typedef struct {
        bool                            recv_buff_is_set;       //!< Whether we were provided with a recv_buff
        bool                            dynamic_clients;        //!< whether we have dynamic clients
 
-       fr_client_list_t                        *clients;               //!< local clients
+       fr_client_list_t                *clients;               //!< local clients
 
        fr_trie_t                       *trie;                  //!< for parsed networks
        fr_ipaddr_t                     *allow;                 //!< allowed networks for dynamic clients
        fr_ipaddr_t                     *deny;                  //!< denied networks for dynamic clients
+
+       bool                            read_hexdump;           //!< Do we debug hexdump read packets.
+       bool                            write_hexdump;          //!< Do we debug hexdump write packets.
 } proto_radius_tcp_t;
 
 
@@ -94,6 +97,9 @@ static const conf_parser_t tcp_listen_config[] = {
        { FR_CONF_OFFSET("max_packet_size", proto_radius_tcp_t, max_packet_size), .dflt = "4096" } ,
                { FR_CONF_OFFSET("max_attributes", proto_radius_tcp_t, max_attributes), .dflt = STRINGIFY(RADIUS_MAX_ATTRIBUTES) } ,
 
+       { FR_CONF_OFFSET("read_hexdump", proto_radius_tcp_t, read_hexdump) },
+       { FR_CONF_OFFSET("write_hexdump", proto_radius_tcp_t, write_hexdump) },
+
        CONF_PARSER_TERMINATOR
 };
 
@@ -418,6 +424,13 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
+static void mod_hexdump_set(fr_listen_t *li, void *data)
+{
+       proto_radius_tcp_t      *inst = talloc_get_type_abort(data, proto_radius_tcp_t);
+       li->read_hexdump = inst->read_hexdump;
+       li->write_hexdump = inst->write_hexdump;
+}
+
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_radius_tcp_t      *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_tcp_t);
@@ -667,4 +680,5 @@ fr_app_io_t proto_radius_tcp = {
        .network_get            = mod_network_get,
        .client_find            = mod_client_find,
        .get_name               = mod_name,
+       .hexdump_set            = mod_hexdump_set,
 };
index 58b5421633ea57bad23b6b715952feef19250aa5..f543323fa4cbb0cc6a9133ea2c6178348b6ea8b8 100644 (file)
@@ -74,6 +74,9 @@ typedef struct {
        fr_trie_t                       *trie;                  //!< for parsed networks
        fr_ipaddr_t                     *allow;                 //!< allowed networks for dynamic clients
        fr_ipaddr_t                     *deny;                  //!< denied networks for dynamic clients
+
+       bool                            read_hexdump;           //!< Do we debug hexdump read packets.
+       bool                            write_hexdump;          //!< Do we debug hexdump write packets.
 } proto_radius_udp_t;
 
 
@@ -106,6 +109,9 @@ static const conf_parser_t udp_listen_config[] = {
        { FR_CONF_OFFSET("max_packet_size", proto_radius_udp_t, max_packet_size), .dflt = "4096" } ,
                { FR_CONF_OFFSET("max_attributes", proto_radius_udp_t, max_attributes), .dflt = STRINGIFY(RADIUS_MAX_ATTRIBUTES) } ,
 
+       { FR_CONF_OFFSET("read_hexdump", proto_radius_udp_t, read_hexdump) },
+       { FR_CONF_OFFSET("write_hexdump", proto_radius_udp_t, write_hexdump) },
+
        CONF_PARSER_TERMINATOR
 };
 
@@ -421,6 +427,12 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
+static void mod_hexdump_set(fr_listen_t *li, void *data)
+{
+       proto_radius_udp_t      *inst = talloc_get_type_abort(data, proto_radius_udp_t);
+       li->read_hexdump = inst->read_hexdump;
+       li->write_hexdump = inst->write_hexdump;
+}
 
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
@@ -550,4 +562,5 @@ fr_app_io_t proto_radius_udp = {
        .network_get            = mod_network_get,
        .client_find            = mod_client_find,
        .get_name               = mod_name,
+       .hexdump_set            = mod_hexdump_set,
 };