![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Capture, filter, and generate statistics for RADIUS traffic. More...
#include <fcntl.h>
#include <time.h>
#include <math.h>
#include <freeradius-devel/autoconf.h>
#include <freeradius-devel/radius/list.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/pcap.h>
#include <freeradius-devel/util/timeval.h>
#include "radsniff.h"
Go to the source code of this file.
Macros | |
#define | RS_ASSERT(_x) if (!(_x) && !fr_cond_assert(_x)) exit(1) |
#define | RS_CLEANUP_NOW(_x, _s) |
Functions | |
static int | _request_free (rs_request_t *request) |
static void | _rs_event (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *ctx) |
static int | _rs_event_status (UNUSED fr_time_t now, fr_time_delta_t wake_t, UNUSED void *uctx) |
static void | _unmark_link (void *request) |
Callback for when the request is removed from the link tree. | |
static void | _unmark_request (void *request) |
Callback for when the request is removed from the request tree. | |
int | main (int argc, char *argv[]) |
static int | rs_build_dict_list (fr_dict_attr_t const **out, size_t len, char *list) |
static int | rs_build_event_flags (int *flags, fr_table_num_sorted_t const *map, size_t map_len, char *list) |
static int | rs_build_filter (fr_pair_list_t *out, char const *filter) |
static int | rs_check_pcap_drop (fr_pcap_t *in) |
Query libpcap to see if it dropped any packets. | |
static void | rs_daemonize (char const *pidfile) |
Fork and kill the parent process, writing out our PID. | |
static int | rs_get_pairs (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_pair_list_t *vps, fr_dict_attr_t const *da[], int num) |
Copy a subset of attributes from one list into the other. | |
static void | rs_got_packet (fr_event_list_t *el, int fd, UNUSED int flags, void *ctx) |
static int | rs_install_stats_processor (rs_stats_t *stats, fr_event_list_t *el, fr_pcap_t *in, struct timeval *now, bool live) |
static void | rs_packet_cleanup (rs_request_t *request) |
static int8_t | rs_packet_cmp (void const *one, void const *two) |
Wrapper around fr_packet_cmp to strip off the outer request struct. | |
static void | rs_packet_print (rs_request_t *request, uint64_t count, rs_status_t status, fr_pcap_t *handle, fr_packet_t *packet, fr_pair_list_t *list, struct timeval *elapsed, struct timeval *latency, bool response, bool body) |
static void | rs_packet_print_csv (uint64_t count, rs_status_t status, fr_pcap_t *handle, fr_packet_t *packet, fr_pair_list_t *list, UNUSED struct timeval *elapsed, struct timeval *latency, UNUSED bool response, bool body) |
static void | rs_packet_print_csv_header (void) |
static void | rs_packet_print_fancy (uint64_t count, rs_status_t status, fr_pcap_t *handle, fr_packet_t *packet, fr_pair_list_t *list, struct timeval *elapsed, struct timeval *latency, bool response, bool body) |
static void | rs_packet_process (uint64_t count, rs_event_t *event, struct pcap_pkthdr const *header, uint8_t const *data) |
static void | rs_packet_save_in_output_dir (uint64_t count, UNUSED rs_status_t status, UNUSED fr_pcap_t *handle, fr_packet_t *packet, fr_pair_list_t *list, UNUSED struct timeval *elapsed, UNUSED struct timeval *latency, bool response, bool body) |
static rs_request_t * | rs_request_alloc (TALLOC_CTX *ctx) |
static int | rs_request_to_pcap (rs_event_t *event, rs_request_t *request, struct pcap_pkthdr const *header, uint8_t const *data) |
static int | rs_response_to_pcap (rs_event_t *event, rs_request_t *request, struct pcap_pkthdr const *header, uint8_t const *data) |
static int8_t | rs_rtx_cmp (void const *one, void const *two) |
Compare requests using packet info and lists of attributes. | |
static void | rs_signal_action (UNUSED fr_event_list_t *list, int fd, int UNUSED flags, UNUSED void *ctx) |
Read the last signal from the signal pipe. | |
static void | rs_signal_self (int sig) |
Write the last signal to the signal pipe. | |
static size_t | rs_snprint_csv (char *out, size_t outlen, char const *in, size_t inlen) |
static ssize_t | rs_stats_print_code_csv (char *out, size_t outlen, rs_latency_t *stats) |
static void | rs_stats_print_code_fancy (rs_latency_t *stats, fr_radius_packet_code_t code) |
static void | rs_stats_print_csv (rs_update_t *this, rs_stats_t *stats, UNUSED struct timeval *now) |
static void | rs_stats_print_csv_header (rs_update_t *this) |
static void | rs_stats_print_fancy (rs_update_t *this, rs_stats_t *stats, struct timeval *now) |
static void | rs_stats_process (fr_timer_list_t *tl, fr_time_t now_t, void *ctx) |
Process stats for a single interval. | |
static void | rs_stats_process_counters (rs_latency_t *stats) |
static void | rs_stats_process_latency (rs_latency_t *stats) |
Update smoothed average. | |
static void | rs_stats_update_latency (rs_latency_t *stats, struct timeval *latency) |
Update latency statistics for request/response and forwarded packets. | |
static void | rs_time_print (char *out, size_t len, struct timeval const *t) |
static void | rs_tv_add_ms (struct timeval const *start, unsigned long interval, struct timeval *result) |
static void | timeout_event (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now_t, void *ctx) |
Exit the event loop after a given timeout. | |
static NEVER_RETURNS void | usage (int status) |
Variables | |
static fr_dict_attr_t const * | attr_packet_type |
static bool | cleanup |
static rs_t * | conf |
static fr_dict_t const * | dict_freeradius |
static fr_dict_t const * | dict_radius |
static fr_event_list_t * | events |
static fr_rb_tree_t * | link_tree = NULL |
static int | packets_count = 1 |
fr_dict_autoload_t | radsniff_dict [] |
fr_dict_attr_autoload_t | radsniff_dict_attr [] |
static char const * | radsniff_version = RADIUSD_VERSION_BUILD("radsniff") |
static fr_rb_tree_t * | request_tree = NULL |
static fr_table_num_sorted_t const | rs_events [] |
static size_t | rs_events_len = NUM_ELEMENTS(rs_events) |
static int | rs_useful_codes [] |
static int | self_pipe [2] = {-1, -1} |
Signals from sig handlers. | |
static struct timeval | start_pcap = {0, 0} |
static char | timestr [50] |
static const uint8_t | zeros [RADIUS_AUTH_VECTOR_LENGTH] = {} |
Capture, filter, and generate statistics for RADIUS traffic.
Definition in file radsniff.c.
#define RS_ASSERT | ( | _x | ) | if (!(_x) && !fr_cond_assert(_x)) exit(1) |
Definition at line 51 of file radsniff.c.
#define RS_CLEANUP_NOW | ( | _x, | |
_s | |||
) |
Definition at line 1240 of file radsniff.c.
|
static |
Definition at line 1030 of file radsniff.c.
|
static |
Definition at line 1134 of file radsniff.c.
|
static |
Definition at line 2022 of file radsniff.c.
|
static |
Callback for when the request is removed from the link tree.
request | being removed. |
Definition at line 2169 of file radsniff.c.
|
static |
Callback for when the request is removed from the request tree.
request | being removed. |
Definition at line 2159 of file radsniff.c.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 2321 of file radsniff.c.
|
static |
Definition at line 2064 of file radsniff.c.
|
static |
Definition at line 2130 of file radsniff.c.
|
static |
Definition at line 2100 of file radsniff.c.
|
static |
Query libpcap to see if it dropped any packets.
We need to check to see if libpcap dropped any packets and if it did, we need to stop stats output for long enough for inaccurate statistics to be cleared out.
in | pcap handle to check. |
Definition at line 552 of file radsniff.c.
|
static |
Fork and kill the parent process, writing out our PID.
pidfile | the PID file to write our PID to |
Definition at line 117 of file radsniff.c.
|
static |
Copy a subset of attributes from one list into the other.
Should be O(n) if all the attributes exist. List must be pre-sorted.
Definition at line 996 of file radsniff.c.
|
static |
Definition at line 1929 of file radsniff.c.
|
static |
Definition at line 940 of file radsniff.c.
|
static |
Definition at line 1063 of file radsniff.c.
|
static |
Wrapper around fr_packet_cmp to strip off the outer request struct.
Definition at line 1144 of file radsniff.c.
|
inlinestatic |
|
static |
Definition at line 309 of file radsniff.c.
|
static |
Definition at line 268 of file radsniff.c.
|
static |
Definition at line 383 of file radsniff.c.
|
static |
Definition at line 1264 of file radsniff.c.
|
static |
Definition at line 478 of file radsniff.c.
|
static |
Definition at line 1248 of file radsniff.c.
|
inlinestatic |
Definition at line 1202 of file radsniff.c.
|
inlinestatic |
|
static |
Compare requests using packet info and lists of attributes.
Definition at line 2042 of file radsniff.c.
|
static |
Read the last signal from the signal pipe.
Definition at line 2223 of file radsniff.c.
|
static |
Write the last signal to the signal pipe.
sig | raised |
Definition at line 2212 of file radsniff.c.
|
static |
Definition at line 774 of file radsniff.c.
|
static |
|
static |
Definition at line 799 of file radsniff.c.
|
static |
|
static |
Definition at line 679 of file radsniff.c.
|
static |
Process stats for a single interval.
Definition at line 844 of file radsniff.c.
|
static |
|
static |
Update smoothed average.
Definition at line 580 of file radsniff.c.
|
static |
Update latency statistics for request/response and forwarded packets.
Definition at line 923 of file radsniff.c.
|
static |
Definition at line 193 of file radsniff.c.
|
static |
|
static |
Exit the event loop after a given timeout.
Definition at line 2178 of file radsniff.c.
|
static |
Definition at line 2266 of file radsniff.c.
|
static |
Definition at line 103 of file radsniff.c.
|
static |
Definition at line 60 of file radsniff.c.
|
static |
Definition at line 53 of file radsniff.c.
|
static |
Definition at line 93 of file radsniff.c.
|
static |
Definition at line 94 of file radsniff.c.
|
static |
Definition at line 59 of file radsniff.c.
|
static |
Definition at line 58 of file radsniff.c.
|
static |
Definition at line 61 of file radsniff.c.
fr_dict_autoload_t radsniff_dict |
Definition at line 97 of file radsniff.c.
fr_dict_attr_autoload_t radsniff_dict_attr |
Definition at line 106 of file radsniff.c.
|
static |
Definition at line 65 of file radsniff.c.
|
static |
Definition at line 57 of file radsniff.c.
|
static |
Definition at line 83 of file radsniff.c.
|
static |
Definition at line 91 of file radsniff.c.
|
static |
Definition at line 67 of file radsniff.c.
|
static |
Signals from sig handlers.
Definition at line 63 of file radsniff.c.
|
static |
Definition at line 54 of file radsniff.c.
|
static |
Definition at line 55 of file radsniff.c.
|
static |
Definition at line 1262 of file radsniff.c.