now that it's being printed in the "call" instruction.
This change also cleans up the output. The previous functions
mostly did similar things (but not always), and were mostly called
from the same stages of packet processing (but not always)
},
};
-/*
- * Debug the packet if requested.
- */
-static void arp_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received)
-{
- if (!packet) return;
- if (!RDEBUG_ENABLED) return;
-
- log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s",
- received ? "Received" : "Sending",
- fr_arp_packet_codes[packet->code]);
-
- 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);
- }
-}
-
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
{
fr_process_state_t const *state;
RETURN_UNLANG_FAIL;
}
- arp_packet_debug(request, request->packet, &request->request_pairs, true);
-
return state->recv(p_result, mctx, request);
}
#include <freeradius-devel/server/process.h>
-/*
- * Debug the packet if requested.
- */
-static void bfd_packet_debug(request_t *request, fr_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);
- }
-}
-
RESUME_FLAG(recv_bfd, UNUSED,)
{
rlm_rcode_t rcode = RESULT_RCODE;
UPDATE_STATE(reply);
- bfd_packet_debug(request, request->reply, &request->reply_pairs, false);
return state->send(p_result, mctx, request);
}
RETURN_UNLANG_FAIL;
}
- bfd_packet_debug(request, request->packet, &request->request_pairs, true);
-
return state->recv(p_result, mctx, request);
}
DICT_AUTOLOAD_TERMINATOR
};
-/*
- * Debug the packet if requested.
- */
-static void dhcpv4_packet_debug(request_t *request, fr_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 XID %08x from %s%pV%s:%i to %s%pV%s:%i "
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
- "%s%s%s"
-#endif
- "",
- received ? "Received" : "Sending",
- dhcp_message_types[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);
- }
-}
-
typedef struct {
uint64_t nothing; // so that the next field isn't at offset 0
RETURN_UNLANG_FAIL;
}
- dhcpv4_packet_debug(request, request->packet, &request->request_pairs, true);
-
if (unlikely(request_is_dynamic_client(request))) {
return new_client(p_result, mctx, request);
}
COMPILE_TERMINATOR
};
-/*
- * Debug the packet if requested.
- */
-static void dhcpv6_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received)
-{
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
- char if_name[IFNAMSIZ];
-#endif
- char const *module;
-
- if (!packet) return;
- if (!RDEBUG_ENABLED) return;
-
- /*
- * Looks better without module prefix
- */
- module = request->module;
- request->module = NULL;
-
- log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s XID %08x from %s%pV%s:%i to %s%pV%s:%i "
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
- "%s%s%s"
-#endif
- "",
- received ? "Received" : "Sending",
- fr_dhcpv6_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);
- }
-
- request->module = module;
-}
-
/** Keep a copy of header fields to prevent them being tampered with
*
*/
if (unlikely(restore_field_list(request, &fields->client_id) < 0)) goto fail;
if (unlikely(restore_field_list(request, &fields->server_id) < 0)) goto fail;
- dhcpv6_packet_debug(request, request->reply, &request->reply_pairs, false);
-
return CALL_RESUME(send_generic);
}
if (unlikely(restore_field(request, &fields->peer_address) < 0)) goto fail;
if (fields->interface_id && unlikely(restore_field(request, &fields->interface_id) < 0)) goto fail;
- dhcpv6_packet_debug(request, request->reply, &request->reply_pairs, false);
-
return CALL_RESUME(send_generic);
}
RETURN_UNLANG_FAIL;
}
- dhcpv6_packet_debug(request, request->packet, &request->request_pairs, true);
-
if (unlikely(request_is_dynamic_client(request))) {
return new_client(p_result, mctx, request);
}
COMPILE_TERMINATOR
};
-/*
- * Debug the packet if requested.
- */
-static void dns_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *list, bool received)
-{
- if (!packet) return;
- if (!RDEBUG_ENABLED) return;
-
- if ((packet->code & 0x0f) >= FR_DNS_CODE_MAX) return;
-
- if (!fr_dns_packet_names[packet->code & 0x0f]) return;
-
- log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s",
- received ? "Received" : "Sending",
- fr_dns_packet_names[packet->code & 0x0f]);
-
- 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);
- }
-}
/** Keep a copy of header fields to prevent them being tampered with
*
*/
dns_fields_restore(request, talloc_get_type_abort(mctx->rctx, process_rctx_t));
- /*
- * Do this last, so we show everything
- * we'll be sending back.
- */
- dns_packet_debug(request, request->reply, &request->reply_pairs, false);
-
/*
* Hack. This is because this stupid framework uses
* packet_type values to represent request and response
RETURN_UNLANG_FAIL;
}
- dns_packet_debug(request, request->packet, &request->request_pairs, true);
-
return state->recv(p_result, mctx, request);
}
DICT_AUTOLOAD_TERMINATOR
};
-static char const *ldap_sync_message_types[FR_LDAP_SYNC_CODE_MAX] = {
- "<INVALID>", //!< 0
- "Present",
- "Add",
- "Modify",
- "Delete",
- "Entry-Response",
- "Cookie-Load",
- "Cookie-Load-Response",
- "Cookie-Load-Fail",
- "Cookie-Store",
- "Cookie-Store-Response",
-};
-
-static void ldap_sync_packet_debug(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, bool received)
-{
-
- if (!packet) return;
- if (!RDEBUG_ENABLED) return;
-
- log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, "%s %s",
- received ? "Received" : "Sending",
- ldap_sync_message_types[packet->code]
- );
-
- if (received) {
- log_request_pair_list(L_DBG_LVL_1, request, NULL, list, NULL);
- } else {
- /*
- * At higher debug levels, log returned data as well.
- */
- log_request_pair_list(L_DBG_LVL_2, request, NULL, list, NULL);
- }
-
-}
-
typedef struct {
uint64_t nothing; // so that the next field isn't at offset 0
UPDATE_STATE(packet);
- ldap_sync_packet_debug(request, request->packet, &request->request_pairs, true);
-
return state->recv(p_result, mctx, request);
}
RETURN_UNLANG_FAIL;
}
- // @todo - debug stuff!
-// tacacs_packet_debug(request, request->packet, &request->request_pairs, true);
-
if (unlikely(request_is_dynamic_client(request))) {
return new_client(p_result, mctx, request);
}
};
-/*
- * Debug the packet if requested.
- */
-static void vmps_packet_debug(request_t *request, fr_packet_t const *packet, fr_pair_list_t const *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 XID %08x from %s%pV%s:%i to %s%pV%s:%i "
-#ifdef WITH_IFINDEX_NAME_RESOLUTION
- "%s%s%s"
-#endif
- "",
- received ? "Received" : "Sending",
- fr_vmps_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);
- }
-}
-
static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
{
fr_process_state_t const *state;
RETURN_UNLANG_FAIL;
}
- vmps_packet_debug(request, request->packet, &request->request_pairs, true);
-
return state->recv(p_result, mctx, request);
}