25 #include <freeradius-devel/server/module_rlm.h>
26 #include <freeradius-devel/server/virtual_servers.h>
27 #include <freeradius-devel/server/packet.h>
28 #include <freeradius-devel/util/debug.h>
77 if (
fr_arp_decode(request->request_ctx, &request->request_pairs,
data, data_len) < 0) {
86 request->packet->data = talloc_memdup(request->packet,
data, data_len);
87 request->packet->data_len = data_len;
90 RPEDEBUG(
"Failed decoding 'Net.*' packet");
97 RDEBUG(
"Received ARP %s via socket %s",
99 request->async->listen->name);
118 if ((buffer_len == 1) || !
inst->active ||
120 (request->reply->code == 0) || (request->reply->code >=
FR_ARP_CODE_MAX)) {
135 if (memcmp(arp->
sha,
zeros,
sizeof(arp->
sha)) == 0) {
136 RDEBUG(
"WARNING: Sender-Hardware-Address of zeros will likely cause problems");
142 RDEBUG(
"Sending %d via socket %s",
143 request->reply->code,
144 request->async->listen->name);
235 if (!
inst->num_messages)
inst->num_messages = 256;
246 PERROR(
"Failed initialising protocol library");
static int const char char buffer[256]
fr_io_open_t open
Open a new socket for listening, or accept/connect a new connection.
module_t common
Common fields to all loadable modules.
fr_io_name_t get_name
get the socket name
Public structure describing an I/O path for a protocol.
module_t common
Common fields provided by all modules.
Describes a new application (protocol)
uint8_t op[2]
1 - Request, 2 - Reply.
void fr_arp_global_free(void)
int fr_arp_global_init(void)
ssize_t fr_arp_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len)
Decode a raw ARP packet into VPs.
#define FR_ARP_PACKET_SIZE
char const * fr_arp_packet_codes[FR_ARP_CODE_MAX]
ssize_t fr_arp_encode(fr_dbuff_t *dbuff, uint8_t const *original, fr_pair_list_t *vps)
Encode VPS into a raw ARP packet.
uint8_t sha[ETHER_ADDR_LEN]
sender hardware address.
#define CONF_PARSER_TERMINATOR
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Defines a CONF_PAIR to C data type mapping.
A section grouping multiple CONF_PAIR.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
static fr_dict_attr_t const * attr_packet_type
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
size_t num_messages
for the message ring buffer
char const * name
printable name for this socket - set by open
void const * app_instance
size_t default_message_size
copied from app_io, but may be changed
void const * app_io_instance
I/O path configuration context.
int fr_io_listen_free(fr_listen_t *li)
CONF_SECTION * server_cs
CONF_SECTION of the server.
void * thread_instance
thread / socket context
int fd
file descriptor for this socket - set by open
fr_app_io_t const * app_io
I/O path functions.
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
#define RPEDEBUG(fmt,...)
int fr_packet_pairs_from_packet(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_packet_t const *packet)
Allocate a "Net." struct with src/dst host and port.
void fr_packet_net_from_pairs(fr_packet_t *packet, fr_pair_list_t const *list)
Convert pairs to information in a packet.
@ L_DBG_LVL_1
Highest priority debug messages (-x).
@ FR_TYPE_UINT32
32 Bit unsigned integer.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
static int mod_load(void)
static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
static void mod_unload(void)
static conf_parser_t const proto_arp_config[]
How to parse an ARP listen section.
static fr_dict_t const * dict_arp
static uint8_t const zeros[6]
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
fr_dict_autoload_t proto_arp_dict[]
#define REQUEST_VERIFY(_x)
static int instantiate(module_inst_ctx_t const *mctx)
fr_network_t * fr_schedule_listen_add(fr_schedule_t *sc, fr_listen_t *li)
Add a fr_listen_t to a scheduler.
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
size_t thread_inst_size
Size of the module's thread-specific instance data.
static const uchar sc[16]
eap_aka_sim_process_conf_t * inst
#define talloc_get_type_abort_const