From: Alan T. DeKok Date: Wed, 1 Mar 2023 14:47:09 +0000 (-0500) Subject: debug received packets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2ac03db1836131967fed3841dc8e4b2b81a06bd;p=thirdparty%2Ffreeradius-server.git debug received packets --- diff --git a/src/process/bfd/all.mk b/src/process/bfd/all.mk index 1d829dd541f..2c41aadd3eb 100644 --- a/src/process/bfd/all.mk +++ b/src/process/bfd/all.mk @@ -6,5 +6,5 @@ endif SOURCES := base.c -TGT_PREREQS := libfreeradius-util$(L) +TGT_PREREQS := libfreeradius-bfd$(L) diff --git a/src/process/bfd/base.c b/src/process/bfd/base.c index 50e1c29406c..5fd24ba11bd 100644 --- a/src/process/bfd/base.c +++ b/src/process/bfd/base.c @@ -69,6 +69,48 @@ typedef struct { #include +/* + * Debug the packet if requested. + */ +static void bfd_packet_debug(request_t *request, fr_radius_packet_t *packet, fr_pair_list_t *list, bool received) +{ +#ifdef WITH_IFINDEX_NAME_RESOLUTION + char if_name[IFNAMSIZ]; +#endif + + if (!packet) return; + if (!RDEBUG_ENABLED) return; + + log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s ID %d from %s%pV%s:%i to %s%pV%s:%i " +#ifdef WITH_IFINDEX_NAME_RESOLUTION + "%s%s%s" +#endif + "", + received ? "Received" : "Sending", + fr_bfd_packet_names[packet->code], + packet->id, + packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "", + fr_box_ipaddr(packet->socket.inet.src_ipaddr), + packet->socket.inet.src_ipaddr.af == AF_INET6 ? "]" : "", + packet->socket.inet.src_port, + packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "[" : "", + fr_box_ipaddr(packet->socket.inet.dst_ipaddr), + packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "", + packet->socket.inet.dst_port +#ifdef WITH_IFINDEX_NAME_RESOLUTION + , packet->socket.inet.ifindex ? "via " : "", + packet->socket.inet.ifindex ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "", + packet->socket.inet.ifindex ? " " : "" +#endif + ); + + if (received || request->parent) { + log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); + } else { + log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, list, NULL); + } +} + /* * recv FOO */ @@ -154,6 +196,8 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc UPDATE_STATE(packet); + bfd_packet_debug(request, request->packet, &request->request_pairs, true); + return state->recv(p_result, mctx, request); }