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_event_list_t *el, 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. More... | |
static void | _unmark_request (void *request) |
Callback for when the request is removed from the request tree. More... | |
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. More... | |
static void | rs_daemonize (char const *pidfile) |
Fork and kill the parent process, writing out our PID. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static void | rs_signal_self (int sig) |
Write the last signal to the signal pipe. More... | |
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_event_list_t *el, fr_time_t now_t, void *ctx) |
Process stats for a single interval. More... | |
static void | rs_stats_process_counters (rs_latency_t *stats) |
static void | rs_stats_process_latency (rs_latency_t *stats) |
Update smoothed average. More... | |
static void | rs_stats_update_latency (rs_latency_t *stats, struct timeval *latency) |
Update latency statistics for request/response and forwarded packets. More... | |
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 (fr_event_list_t *el, UNUSED fr_time_t now_t, UNUSED void *ctx) |
Exit the event loop after a given timeout. More... | |
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. More... | |
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 1239 of file radsniff.c.
|
static |
Definition at line 1028 of file radsniff.c.
|
static |
Definition at line 1132 of file radsniff.c.
|
static |
Definition at line 2019 of file radsniff.c.
|
static |
Callback for when the request is removed from the link tree.
request | being removed. |
Definition at line 2166 of file radsniff.c.
|
static |
Callback for when the request is removed from the request tree.
request | being removed. |
Definition at line 2156 of file radsniff.c.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 2318 of file radsniff.c.
|
static |
Definition at line 2061 of file radsniff.c.
|
static |
Definition at line 2127 of file radsniff.c.
|
static |
Definition at line 2097 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 994 of file radsniff.c.
|
static |
Definition at line 1926 of file radsniff.c.
|
static |
Definition at line 939 of file radsniff.c.
|
static |
Definition at line 1061 of file radsniff.c.
|
static |
Wrapper around fr_packet_cmp to strip off the outer request struct.
Definition at line 1143 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 1263 of file radsniff.c.
|
static |
Definition at line 478 of file radsniff.c.
|
static |
Definition at line 1247 of file radsniff.c.
|
inlinestatic |
Definition at line 1201 of file radsniff.c.
|
inlinestatic |
|
static |
Compare requests using packet info and lists of attributes.
Definition at line 2039 of file radsniff.c.
|
static |
Read the last signal from the signal pipe.
Definition at line 2220 of file radsniff.c.
|
static |
Write the last signal to the signal pipe.
sig | raised |
Definition at line 2209 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 922 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 2175 of file radsniff.c.
|
static |
|
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 53 of file radsniff.c.
|
static |
Definition at line 55 of file radsniff.c.
|
static |
Definition at line 1261 of file radsniff.c.