#include <freeradius-devel/util/conf.h> #include <freeradius-devel/util/base.h> #include <freeradius-devel/util/udp.h> #include <freeradius-devel/radius/list.h> #include <ctype.h> #include <fcntl.h> #include <sys/uio.h> #ifdef HAVE_GETOPT_H # include <getopt.h> #endif #include <assert.h> static char const *radsnmp_version = RADIUSD_VERSION_STRING_BUILD("radsnmp"); static bool stop; #undef DEBUG #define DEBUG(fmt, ...) if (fr_log_fp && (fr_debug_lvl > 0)) fprintf(fr_log_fp, "radsnmp (debug): " fmt "\n", ## __VA_ARGS__) #undef DEBUG2 #define DEBUG2(fmt, ...) if (fr_log_fp && (fr_debug_lvl > 1)) fprintf(fr_log_fp, "radsnmp (debug): " fmt "\n", ## __VA_ARGS__) #define ERROR(fmt, ...) if (fr_log_fp) fprintf(fr_log_fp, "radsnmp (error): " fmt "\n", ## __VA_ARGS__) typedef enum { RADSNMP_UNKNOWN = -1, //!< Unknown command. RADSNMP_PING = 0, //!< Check server is alive. RADSNMP_GET, //!< Get an SNMP leaf value. RADSNMP_GETNEXT, //!< Get next OID.
#endif /* HAVE_READLINE_HISTORY */ #endif /* HAVE_LIBREADLINE */ #define LOG_PREFIX "radmin - " #include <freeradius-devel/server/base.h> #include <freeradius-devel/util/md5.h> #include <freeradius-devel/server/cf_parse.h> #include <freeradius-devel/server/radmin.h> #include "conduit.h" /* * For configuration file stuff. */ static char const *progname = "radmin"; static char const *radmin_version = RADIUSD_VERSION_STRING_BUILD("radmin"); typedef enum { RADMIN_CONN_NONE = 0, //!< Don't know, never connected. RADMIN_CONN_UNIX, //!< Connect via unix socket. RADMIN_CONN_TCP //!< Connect via TCP. } radmin_conn_type_t; /** A connection to a server * */ typedef struct radmin_conn { fr_event_list_t *event_list; //!< Event list this fd is serviced by. int fd; //!< Control socket descriptor. char *last_command; //!< Last command we executed on this connection.
static int sockfd; #ifdef HAVE_LIBPCAP static fr_pcap_t *pcap; #endif static char *iface = NULL; static int iface_ind = -1; #ifdef HAVE_LINUX_IF_PACKET_H static struct sockaddr_ll ll; /* Socket address structure */ #endif static bool raw_mode = false; static bool reply_expected = true; static char const *dhcpclient_version = RADIUSD_VERSION_STRING_BUILD("dhcpclient"); /* structure to keep track of offered IP addresses */ typedef struct { uint32_t server_addr; uint32_t offered_addr; } dc_offer_t; static fr_dict_t *dict_freeradius; static fr_dict_t *dict_radius; static fr_dict_t *dict_dhcpv4; extern fr_dict_autoload_t dhcpclient_dict[]; fr_dict_autoload_t dhcpclient_dict[] = { { .out = &dict_freeradius, .proto = "freeradius" }, { .out = &dict_radius, .proto = "radius" },