]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rename fr_packet_log() to fr_radius_packet_log()
authorAlan T. DeKok <aland@freeradius.org>
Tue, 2 Apr 2024 20:12:07 +0000 (16:12 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 2 Apr 2024 20:13:40 +0000 (16:13 -0400)
src/bin/radclient-ng.c
src/bin/radclient.c
src/bin/radsnmp.c
src/protocols/radius/list.c
src/protocols/radius/list.h
src/protocols/radius/packet.c
src/protocols/radius/radius.h

index a2138195cbb205f8bd6bf40cbca18bc7cf5cece6..130891d47bd0f93850ca1eeb945677a3f807dc5b 100644 (file)
@@ -810,7 +810,7 @@ static int send_one_packet(fr_bio_packet_t *client, rc_request_t *request)
                return -1;
        }
 
-       fr_packet_log(&default_log, request->packet, &request->request_pairs, false);
+       fr_radius_packet_log(&default_log, request->packet, &request->request_pairs, false);
 
        return 0;
 }
@@ -857,7 +857,7 @@ static void client_read(fr_event_list_t *el, int fd, UNUSED int flags, void *uct
         */
        if (!rcode) return;
 
-       fr_packet_log(&default_log, reply, &reply_pairs, true);
+       fr_radius_packet_log(&default_log, reply, &reply_pairs, true);
 
        /*
         *      Increment counters...
index 97c710b2d74b87f0916541458ef552cd7a42e760..84408dbf4971950a3ef0025532369442850dd2f2 100644 (file)
@@ -1110,7 +1110,7 @@ static int send_one_packet(rc_request_t *request)
                return -1;
        }
 
-       fr_packet_log(&default_log, request->packet, &request->request_pairs, false);
+       fr_radius_packet_log(&default_log, request->packet, &request->request_pairs, false);
 
        return 0;
 }
@@ -1170,7 +1170,7 @@ static int recv_coa_packet(fr_time_delta_t wait_time)
                return 0;
        }
 
-       fr_packet_log(&default_log, packet, &my.request_pairs, true);
+       fr_radius_packet_log(&default_log, packet, &my.request_pairs, true);
 
        /*
         *      Find a Access-Request which has the same User-Name / etc. as this CoA packet.
@@ -1250,7 +1250,7 @@ static int recv_coa_packet(fr_time_delta_t wait_time)
                return 0;
        }
 
-       fr_packet_log(&default_log, request->reply, &request->reply_pairs, false);
+       fr_radius_packet_log(&default_log, request->reply, &request->reply_pairs, false);
 
 
        /*
@@ -1392,7 +1392,7 @@ retry:
                goto packet_done;
        }
        PAIR_LIST_VERIFY(&request->reply_pairs);
-       fr_packet_log(&default_log, request->reply, &request->reply_pairs, true);
+       fr_radius_packet_log(&default_log, request->reply, &request->reply_pairs, true);
 
        /*
         *      Increment counters...
index a9d40a5e2fc67fc5b98b2a7c1eb069fad4613979..fb5006af72434597e91bb20cee71ca4a459ac396 100644 (file)
@@ -786,7 +786,7 @@ do { \
                        /*
                         *      Print the attributes we're about to send
                         */
-                       fr_packet_log(&default_log, packet, &reply_vps, false);
+                       fr_radius_packet_log(&default_log, packet, &reply_vps, false);
 
                        FD_ZERO(&set); /* clear the set */
                        FD_SET(fd, &set);
@@ -847,7 +847,7 @@ do { \
                        /*
                         *      Print the attributes we received in response
                         */
-                       fr_packet_log(&default_log, reply, &reply_vps, true);
+                       fr_radius_packet_log(&default_log, reply, &reply_vps, true);
 
                        switch (command) {
                        case RADSNMP_GET:
index 258f4007f85fa30e761e5cc7571b1aaa5007eed3..88f29cf4609e07ea86a224e0006ea542a536e2cd 100644 (file)
@@ -723,86 +723,3 @@ uint32_t fr_packet_list_num_outgoing(fr_packet_list_t *pl)
 
        return pl->num_outgoing;
 }
-
-/*
- *     Debug the packet if requested.
- */
-void fr_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool received)
-{
-       char src_ipaddr[FR_IPADDR_STRLEN];
-       char dst_ipaddr[FR_IPADDR_STRLEN];
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
-       char if_name[IFNAMSIZ];
-#endif
-
-       if (!log) return;
-       if (!packet) return;
-
-       /*
-        *      Client-specific debugging re-prints the input
-        *      packet into the client log.
-        *
-        *      This really belongs in a utility library
-        */
-       if (FR_RADIUS_PACKET_CODE_VALID(packet->code)) {
-               fr_log(log, L_DBG, __FILE__, __LINE__,
-                      "%s %s Id %i from %s%s%s:%i to %s%s%s:%i "
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
-                      "%s%s%s"
-#endif
-                      "length %zu\n",
-                       received ? "Received" : "Sent",
-                       fr_radius_packet_name[packet->code],
-                       packet->id,
-                       packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
-                       fr_inet_ntop(src_ipaddr, sizeof(src_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_inet_ntop(dst_ipaddr, sizeof(dst_ipaddr), &packet->socket.inet.dst_ipaddr),
-                       packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
-                       packet->socket.inet.dst_port,
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
-                       received ? "via " : "",
-                       received ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
-                       received ? " " : "",
-#endif
-                       packet->data_len);
-       } else {
-               fr_log(log, L_DBG, __FILE__, __LINE__,
-                      "%s code %u Id %i from %s%s%s:%i to %s%s%s:%i "
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
-                      "%s%s%s"
-#endif
-                      "length %zu\n",
-                       received ? "Received" : "Sent",
-                       packet->code,
-                       packet->id,
-                       packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
-                       fr_inet_ntop(src_ipaddr, sizeof(src_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_inet_ntop(dst_ipaddr, sizeof(dst_ipaddr), &packet->socket.inet.dst_ipaddr),
-                       packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
-                       packet->socket.inet.dst_port,
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
-                       received ? "via " : "",
-                       received ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
-                       received ? " " : "",
-#endif
-                       packet->data_len);
-       }
-}
-
-/*
- *     Debug the packet header and all attributes
- */
-void fr_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
-{
-       fr_packet_header_log(log, packet, received);
-       if (fr_debug_lvl >= L_DBG_LVL_1) fr_pair_list_log(log, 4, list);
-#ifndef NDEBUG
-       if (fr_debug_lvl >= L_DBG_LVL_4) fr_packet_log_hex(log, packet);
-#endif
-}
index 10a3582415d70cbbc43c678375a2838bd6cfa1c9..e7640d9aaa52e8b032d691c9fdb86e15b6598aa7 100644 (file)
@@ -59,6 +59,3 @@ fr_packet_t *fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set, uint32_t max
 
 uint32_t fr_packet_list_num_incoming(fr_packet_list_t *pl);
 uint32_t fr_packet_list_num_outgoing(fr_packet_list_t *pl);
-
-void fr_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool received);
-void fr_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received);
index b9b867dee65cdbd5447b06dfd98b3fba10555783..5cd515f826031b848c452c59416d2d4d60b0d468 100644 (file)
@@ -419,3 +419,86 @@ void _fr_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char con
               fr_log(log, L_DBG, file, line, "      %s%s\n", buffer, truncated);
        }
 }
+
+/*
+ *     Debug the packet if requested.
+ */
+void fr_radius_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool received)
+{
+       char src_ipaddr[FR_IPADDR_STRLEN];
+       char dst_ipaddr[FR_IPADDR_STRLEN];
+#ifdef WITH_IFINDEX_NAME_RESOLUTION
+       char if_name[IFNAMSIZ];
+#endif
+
+       if (!log) return;
+       if (!packet) return;
+
+       /*
+        *      Client-specific debugging re-prints the input
+        *      packet into the client log.
+        *
+        *      This really belongs in a utility library
+        */
+       if (FR_RADIUS_PACKET_CODE_VALID(packet->code)) {
+               fr_log(log, L_DBG, __FILE__, __LINE__,
+                      "%s %s Id %i from %s%s%s:%i to %s%s%s:%i "
+#ifdef WITH_IFINDEX_NAME_RESOLUTION
+                      "%s%s%s"
+#endif
+                      "length %zu\n",
+                       received ? "Received" : "Sent",
+                       fr_radius_packet_name[packet->code],
+                       packet->id,
+                       packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
+                       fr_inet_ntop(src_ipaddr, sizeof(src_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_inet_ntop(dst_ipaddr, sizeof(dst_ipaddr), &packet->socket.inet.dst_ipaddr),
+                       packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
+                       packet->socket.inet.dst_port,
+#ifdef WITH_IFINDEX_NAME_RESOLUTION
+                       received ? "via " : "",
+                       received ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
+                       received ? " " : "",
+#endif
+                       packet->data_len);
+       } else {
+               fr_log(log, L_DBG, __FILE__, __LINE__,
+                      "%s code %u Id %i from %s%s%s:%i to %s%s%s:%i "
+#ifdef WITH_IFINDEX_NAME_RESOLUTION
+                      "%s%s%s"
+#endif
+                      "length %zu\n",
+                       received ? "Received" : "Sent",
+                       packet->code,
+                       packet->id,
+                       packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
+                       fr_inet_ntop(src_ipaddr, sizeof(src_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_inet_ntop(dst_ipaddr, sizeof(dst_ipaddr), &packet->socket.inet.dst_ipaddr),
+                       packet->socket.inet.dst_ipaddr.af == AF_INET6 ? "]" : "",
+                       packet->socket.inet.dst_port,
+#ifdef WITH_IFINDEX_NAME_RESOLUTION
+                       received ? "via " : "",
+                       received ? fr_ifname_from_ifindex(if_name, packet->socket.inet.ifindex) : "",
+                       received ? " " : "",
+#endif
+                       packet->data_len);
+       }
+}
+
+/*
+ *     Debug the packet header and all attributes
+ */
+void fr_radius_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
+{
+       fr_radius_packet_header_log(log, packet, received);
+       if (fr_debug_lvl >= L_DBG_LVL_1) fr_pair_list_log(log, 4, list);
+#ifndef NDEBUG
+       if (fr_debug_lvl >= L_DBG_LVL_4) fr_packet_log_hex(log, packet);
+#endif
+}
index 7a11c757d7aa56cbb5fd42d3726d2bcf74ec4b29..e3f53adf729ad041f6354eb7fe43946333dbd7aa 100644 (file)
@@ -241,3 +241,7 @@ ssize_t             fr_radius_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *list,
 
 ssize_t                fr_radius_decode_foreign(TALLOC_CTX *ctx, fr_pair_list_t *out,
                                         uint8_t const *data, size_t data_len) CC_HINT(nonnull);
+
+void           fr_radius_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool received);
+
+void           fr_radius_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received);