The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/udp.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/radius/radius.h>
#include <freeradius-devel/radius/list.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <assert.h>
Go to the source code of this file.
Data Structures | |
struct | radsnmp_conf_t |
Macros | |
#define | DEBUG(fmt, ...) if (fr_debug_lvl >= L_DBG_LVL_1) fr_log(&default_log, L_DBG, __FILE__, __LINE__, "radsnmp (debug): " fmt, ## __VA_ARGS__) |
#define | DEBUG2(fmt, ...) if (fr_debug_lvl >= L_DBG_LVL_2) fr_log(&default_log, L_DBG, __FILE__, __LINE__, "radsnmp (debug): " fmt, ## __VA_ARGS__) |
#define | ERROR(fmt, ...) fr_log(&default_log, L_DBG, __FILE__, __LINE__, "radsnmp (error): " fmt, ## __VA_ARGS__) |
#define | NEXT_LINE(_line, _buffer) |
#define | RESPOND_STATIC(_cmd) |
Enumerations | |
enum | radsnmp_command_t { RADSNMP_UNKNOWN = -1 , RADSNMP_PING = 0 , RADSNMP_GET , RADSNMP_GETNEXT , RADSNMP_SET , RADSNMP_EXIT } |
Functions | |
int | main (int argc, char **argv) |
static fr_packet_t * | radsnmp_alloc (radsnmp_conf_t *conf, int fd) |
Allocate a new request using values from radsnmp config. More... | |
static int | radsnmp_get_response (int fd, fr_dict_attr_t const *root, fr_dict_attr_t const *type, fr_pair_list_t *head) |
Write the result of a get or getnext operation back to net-snmp. More... | |
static ssize_t | radsnmp_pair_from_oid (TALLOC_CTX *ctx, radsnmp_conf_t *conf, fr_dcursor_t *cursor, char const *oid, int type, char const *value) |
Builds attribute representing OID string and adds 'index' attributes where required. More... | |
static int | radsnmp_send_recv (radsnmp_conf_t *conf, int fd) |
static int | radsnmp_set_response (int fd, fr_dict_attr_t const *error, fr_pair_list_t *head) |
Write the result of a set operation back to net-snmp. More... | |
static void | rs_signal_stop (UNUSED int sig) |
static NEVER_RETURNS void | usage (void) |
Variables | |
static fr_dict_attr_t const * | attr_extended_attribute_1 |
static fr_dict_attr_t const * | attr_freeradius_snmp_failure |
static fr_dict_attr_t const * | attr_freeradius_snmp_operation |
static fr_dict_attr_t const * | attr_freeradius_snmp_type |
static fr_dict_attr_t const * | attr_message_authenticator |
static fr_dict_attr_t const * | attr_vendor_specific |
static fr_dict_t const * | dict_freeradius |
static fr_dict_t const * | dict_radius |
static fr_table_num_sorted_t const | radsnmp_command_str [] |
static size_t | radsnmp_command_str_len = NUM_ELEMENTS(radsnmp_command_str) |
fr_dict_autoload_t | radsnmp_dict [] |
fr_dict_attr_autoload_t | radsnmp_dict_attr [] |
static char const * | radsnmp_version = RADIUSD_VERSION_BUILD("radsnmp") |
static bool | stop |
struct radsnmp_conf_t |
Data Fields | ||
---|---|---|
unsigned int | code | Request type. |
fr_dict_t * | dict | Radius protocol dictionary. |
char const * | dict_dir | Dictionary director. |
uint8_t | last_used_id | ID of the last request we sent. |
int | proto | Protocol TCP/UDP. |
char const * | proto_str | Protocol string. |
char const * | raddb_dir | Radius dictionary directory. |
unsigned int | retries | Number of retries. |
char * | secret | Shared secret. |
fr_ipaddr_t | server_ipaddr | Src IP address. |
uint16_t | server_port | Port to send requests to. |
fr_dict_attr_t const * | snmp_failure | SNMP set error attribute. |
fr_dict_attr_t const * | snmp_oid_root | First attribute to include at the start of OID responses. |
fr_dict_attr_t const * | snmp_op | SNMP operation. |
fr_dict_attr_t const * | snmp_root | SNMP protocol root in the FreeRADIUS dictionary. |
fr_dict_attr_t const * | snmp_type | SNMP type attribute. |
fr_time_delta_t | timeout |
#define DEBUG | ( | fmt, | |
... | |||
) | if (fr_debug_lvl >= L_DBG_LVL_1) fr_log(&default_log, L_DBG, __FILE__, __LINE__, "radsnmp (debug): " fmt, ## __VA_ARGS__) |
#define DEBUG2 | ( | fmt, | |
... | |||
) | if (fr_debug_lvl >= L_DBG_LVL_2) fr_log(&default_log, L_DBG, __FILE__, __LINE__, "radsnmp (debug): " fmt, ## __VA_ARGS__) |
#define ERROR | ( | fmt, | |
... | |||
) | fr_log(&default_log, L_DBG, __FILE__, __LINE__, "radsnmp (error): " fmt, ## __VA_ARGS__) |
#define NEXT_LINE | ( | _line, | |
_buffer | |||
) |
#define RESPOND_STATIC | ( | _cmd | ) |
enum radsnmp_command_t |
|
static |
|
static |
Write the result of a get or getnext operation back to net-snmp.
Returns three lines of output per attribute:
Index attributes (num 0) must be in order of depth (shallowest first).
If no attributes were written, will write "NONE\n" to inform net-snmp that no value was available at the specified OID.
fd | to write to. |
root | of the SNMP portion of the main dictionary. |
type | attribute. |
head | of list of attributes to convert and write. |
Definition at line 382 of file radsnmp.c.
|
static |
Builds attribute representing OID string and adds 'index' attributes where required.
Will convert an OID string in the format
.1.2.3.4.5.0
into a pair with a fr_dict_attr_t of the dictionary attribute matching the OID string, as evaluated from the specified parent.
If an OID component does not match a child of a previous OID component, but a child with attribute number 0 exists, and a child with attribute number 1 also exists, the child with attribute number 0 will be used as an 'index' pair, and will be created with the value of the non matching OID component.
Parsing will then resume using the child with attribute number 1.
This allows traversals of SNMP tables to be represented by the sequence of pairs and allows the full range of entry indexes which would not be possible if we represented table index numbers as TLV attributes.
[in] | ctx | to allocate new pairs in. |
[in] | conf | radsnmp config. |
[in] | cursor | to add pairs to. |
[in] | oid | string to evaluate. |
[in] | type | SNMP value type. |
[in] | value | to assign to OID attribute (SET operations only). |
Definition at line 210 of file radsnmp.c.
|
static |
|
static |
Write the result of a set operation back to net-snmp.
Writes "DONE\n" on success, or an error as described in man snmpd.conf on error.
fd | to write to. |
error | attribute. |
head | of list of attributes to convert and write. |
Definition at line 590 of file radsnmp.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
fr_dict_autoload_t radsnmp_dict |
fr_dict_attr_autoload_t radsnmp_dict_attr |
|
static |