]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
debug received packets
authorAlan T. DeKok <aland@freeradius.org>
Wed, 1 Mar 2023 14:47:09 +0000 (09:47 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 1 Mar 2023 15:27:45 +0000 (10:27 -0500)
src/process/bfd/all.mk
src/process/bfd/base.c

index 1d829dd541fad5f1044c8943e268c483ab0103ed..2c41aadd3ebabf11a4cdc3798d9522d9167f0cc5 100644 (file)
@@ -6,5 +6,5 @@ endif
 
 SOURCES                := base.c
 
-TGT_PREREQS    := libfreeradius-util$(L)
+TGT_PREREQS    := libfreeradius-bfd$(L)
 
index 50e1c29406c68db3d0eba91feac8af1c700c4437..5fd24ba11bd6730084438a3bcff774514c33124e 100644 (file)
@@ -69,6 +69,48 @@ typedef struct {
 
 #include <freeradius-devel/server/process.h>
 
+/*
+ *     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);
 }