From: Alan T. DeKok Date: Tue, 2 Apr 2024 20:12:07 +0000 (-0400) Subject: rename fr_packet_log() to fr_radius_packet_log() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcdeca8a4436c171b67759d6d392ea6d96e216dc;p=thirdparty%2Ffreeradius-server.git rename fr_packet_log() to fr_radius_packet_log() --- diff --git a/src/bin/radclient-ng.c b/src/bin/radclient-ng.c index a2138195cbb..130891d47bd 100644 --- a/src/bin/radclient-ng.c +++ b/src/bin/radclient-ng.c @@ -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... diff --git a/src/bin/radclient.c b/src/bin/radclient.c index 97c710b2d74..84408dbf497 100644 --- a/src/bin/radclient.c +++ b/src/bin/radclient.c @@ -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... diff --git a/src/bin/radsnmp.c b/src/bin/radsnmp.c index a9d40a5e2fc..fb5006af724 100644 --- a/src/bin/radsnmp.c +++ b/src/bin/radsnmp.c @@ -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: diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index 258f4007f85..88f29cf4609 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -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 -} diff --git a/src/protocols/radius/list.h b/src/protocols/radius/list.h index 10a3582415d..e7640d9aaa5 100644 --- a/src/protocols/radius/list.h +++ b/src/protocols/radius/list.h @@ -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); diff --git a/src/protocols/radius/packet.c b/src/protocols/radius/packet.c index b9b867dee65..5cd515f8260 100644 --- a/src/protocols/radius/packet.c +++ b/src/protocols/radius/packet.c @@ -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 +} diff --git a/src/protocols/radius/radius.h b/src/protocols/radius/radius.h index 7a11c757d7a..e3f53adf729 100644 --- a/src/protocols/radius/radius.h +++ b/src/protocols/radius/radius.h @@ -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);