26 #include <freeradius-devel/server/protocol.h>
27 #include <freeradius-devel/util/trie.h>
28 #include <freeradius-devel/io/application.h>
29 #include <freeradius-devel/io/listen.h>
30 #include <freeradius-devel/io/schedule.h>
53 interface), .dflt =
"eth0" },
65 struct pcap_pkthdr *header;
71 ret = pcap_next_ex(thread->
pcap->handle, &header, &
data);
72 if (ret == 0)
return 0;
74 DEBUG(
"Failed getting next PCAP packet");
79 end =
data + header->caplen;
81 len = fr_pcap_link_layer_offset(
data, header->caplen, thread->
pcap->link_layer);
83 DEBUG(
"Failed determining link layer header offset");
89 DEBUG(
"Packet is too small (%d) to be ARP", (
int) (end - p));
115 uint8_t arp_packet[64] = { 0 };
124 if (buffer_len == 1)
return buffer_len;
135 memcpy(arp,
buffer, buffer_len);
151 ret = pcap_inject(thread->
pcap->handle, arp_packet, (end - arp_packet + buffer_len));
174 char *our_filter = NULL;
176 thread->
pcap = fr_pcap_init(thread,
inst->interface, PCAP_INTERFACE_IN);
178 PERROR(
"Failed initializing pcap handle.");
182 if (fr_pcap_open(thread->
pcap) < 0) {
183 PERROR(
"Failed opening interface %s",
inst->interface);
193 MEM(filter = our_filter = talloc_asprintf(li,
"arp and %s",
inst->filter));
196 if (fr_pcap_apply_filter(thread->
pcap, filter) < 0) {
197 PERROR(
"Failed applying pcap filter '%s'", filter);
203 li->
fd = thread->
pcap->fd;
207 thread->
name = talloc_asprintf(thread,
"arp on interface %s",
inst->interface);
231 .name =
"arp_ethernet",
static int const char char buffer[256]
module_t common
Common fields to all loadable modules.
Public structure describing an I/O path for a protocol.
uint8_t tha[ETHER_ADDR_LEN]
Target hardware address.
#define FR_ARP_PACKET_SIZE
#define CONF_PARSER_TERMINATOR
#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
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Defines a CONF_PAIR to C data type mapping.
A section grouping multiple CONF_PAIR.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
uint8_t dst_addr[ETHER_ADDR_LEN]
uint8_t src_addr[ETHER_ADDR_LEN]
void const * app_io_instance
I/O path configuration context.
void * thread_instance
thread / socket context
int fd
file descriptor for this socket - set by open
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
char const * name
socket name
static ssize_t mod_write(fr_listen_t *li, UNUSED void *packet_ctx, UNUSED fr_time_t request_time, uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
char const * filter
Additional PCAP filter.
CONF_SECTION * cs
our configuration
static conf_parser_t const arp_listen_config[]
How to parse an ARP listen section.
static int mod_open(fr_listen_t *li)
Open a pcap file for ARP.
fr_pcap_t * pcap
PCAP handler.
static char const * mod_name(fr_listen_t *li)
char const * interface
Interface to bind to.
static ssize_t mod_read(fr_listen_t *li, UNUSED void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
fr_app_io_t proto_arp_ethernet
static int mod_instantiate(module_inst_ctx_t const *mctx)
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
#define fr_time()
Allow us to arbitrarily manipulate time.
#define talloc_get_type_abort_const
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.