25 #include <freeradius-devel/io/listen.h>
26 #include <freeradius-devel/server/module_rlm.h>
27 #include <freeradius-devel/internal/internal.h>
131 cf_log_err(ci,
"Invalid value for 'auth_type'");
151 bfd_packet_t
const *bfd = (bfd_packet_t
const *) wrapper->
packet;
165 request->packet->code = bfd->state;
167 request->reply->id = request->packet->id;
169 request->packet->data = talloc_memdup(request->packet,
data, data_len);
170 request->packet->data_len = data_len;
177 request->packet->socket = address->
socket;
187 (
uint8_t const *) bfd, bfd->length,
188 client->
secret, talloc_array_length(client->
secret) - 1) < 0) {
193 request->reply->code = bfd->state;
198 if (
fr_bfd_decode(request->request_ctx, &request->request_pairs,
199 (
uint8_t const *) bfd, bfd->length,
200 client->
secret, talloc_array_length(client->
secret) - 1) < 0) {
220 your->vp_uint32 =
my->vp_uint32;
225 RPEDEBUG(
"Failed decoding 'Net.*' packet");
239 bfd_packet_t
const *bfd = (bfd_packet_t
const *) wrapper->
packet;
276 PERROR(
"Failed creating new client");
281 memcpy(
buffer, &new_client,
sizeof(new_client));
282 return sizeof(new_client);
285 fr_assert((wrapper->
packet + bfd->length) == (request->packet->data + request->packet->data_len));
290 memcpy(
buffer, bfd, bfd->length);
295 if (!
vp)
return bfd->length;
299 if (slen <= 0)
return bfd->length;
301 return bfd->length + slen;
318 inst->io.app_instance = instance;
324 inst->max_packet_size,
inst->num_messages);
348 if (!
inst->io.submodule)
return 0;
360 server =
inst->io.server_cs;
367 if (!
inst->peers)
return -1;
383 if (c->
proto != IPPROTO_UDP) {
401 cf_log_err(cs,
"Invalid IP prefix - cannot use ip/mask for BFD");
410 cf_log_err(cs,
"Secret cannot be an empty string");
426 cf_log_err(cs,
"A 'secret' must be specified when using 'auth_type = simple'");
430 if (strlen(c->
secret) > 16) {
431 cf_log_err(cs,
"Length of 'secret' must be no more than 16 octets for 'auth_type = simple'");
439 cf_log_err(cs,
"A 'secret' must be specified when using 'auth_type = ...'");
443 if (strlen(c->
secret) > 20) {
444 cf_log_err(cs,
"Length of 'secret' must be no more than 16 octets for 'auth_type = simple'");
466 if (!
inst->max_packet_size &&
inst->io.app_io)
inst->max_packet_size =
inst->io.app_io->default_message_size;
468 if (!
inst->num_messages)
inst->num_messages = 256;
491 PERROR(
"Failed initialising protocol library");
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.
module_t common
Common fields provided by all modules.
Describes a new application (protocol)
@ BFD_AUTH_MET_KEYED_SHA1
ssize_t fr_bfd_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len, char const *secret, size_t secret_len)
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#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
#define cf_section_rules_push(_cs, _rule)
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _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.
Common header for all CONF_* types.
A section grouping multiple CONF_PAIR.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
#define cf_log_err(_cf, _fmt,...)
#define cf_data_add(_cf, _data, _name, _free)
#define cf_data_find(_cf, _type, _name)
#define cf_log_warn(_cf, _fmt,...)
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
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.
int8_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
uint8_t prefix
Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.
fr_socket_t socket
src/dst ip and port.
fr_client_t const * radclient
old-style client definition
fr_ipaddr_t ipaddr
IPv4/IPv6 address of the host.
char const * secret
Secret PSK.
bool active
for dynamic clients
int proto
Protocol number.
bool dynamic
Whether the client was dynamically defined.
Describes a host allowed to send packets to the server.
#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.
size_t secret_len
doesn't change while we're running
fr_time_delta_t required_min_rx_interval
intervals between receives
@ BFD_WRAPPER_STATE_CHANGE
@ BFD_WRAPPER_SEND_PACKET
@ BFD_WRAPPER_RECV_PACKET
bfd_auth_type_t auth_type
what kind of authentication is used
fr_time_delta_t desired_min_tx_interval
intervals between transmits
fr_app_io_t fr_master_app_io
int fr_master_io_listen(fr_io_instance_t *inst, fr_schedule_t *sc, size_t default_message_size, size_t num_messages)
fr_io_address_t const * address
of this packet.. shared between multiple packets
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_GROUP
A grouping of other attributes.
#define MODULE_INST_CTX(_mi)
Wrapper to create a module_inst_ctx_t as a compound literal.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
static uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
static int mod_load(void)
static fr_dict_attr_t const * attr_packet_type
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
static int8_t client_cmp(void const *one, void const *two)
static fr_dict_attr_t const * attr_bfd_packet
static conf_parser_t const proto_bfd_config[]
How to parse a BFD listen section.
static fr_dict_attr_t const * attr_my_discriminator
static fr_dict_attr_t const * attr_additional_data
fr_dict_attr_autoload_t proto_bfd_dict_attr[]
static void mod_unload(void)
static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet.
fr_dict_autoload_t proto_bfd_dict[]
static fr_dict_attr_t const * attr_your_discriminator
static int auth_type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static const conf_parser_t peer_config[]
static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static fr_dict_t const * dict_bfd
static int mod_instantiate(module_inst_ctx_t const *mctx)
Bootstrap the application.
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
An instance of a proto_radius listen section.
int fr_bfd_global_init(void)
void fr_bfd_global_free(void)
fr_table_num_ordered_t const bfd_auth_type_table[]
bool fr_bfd_packet_ok(char const **err, uint8_t const *packet, size_t packet_len)
ssize_t fr_internal_encode_list(fr_dbuff_t *dbuff, fr_pair_list_t const *list, void *encode_ctx)
Encode a list of pairs using the internal encoder.
#define fr_rb_inline_talloc_alloc(_ctx, _type, _field, _data_cmp, _data_free)
Allocs a red black that verifies elements are of a specific talloc type.
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
The main red black tree structure.
#define REQUEST_VERIFY(_x)
static int instantiate(module_inst_ctx_t const *mctx)
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
module_instantiate_t instantiate
Callback to allow the module to register any per-instance resources like sockets and file handles.
module_t * exported
Public module structure.
static const uchar sc[16]
fr_client_t * client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, CONF_SECTION *server_cs, size_t extra)
Allocate a new client from a config section.
fr_client_t * client_afrom_request(TALLOC_CTX *ctx, request_t *request)
Create a new client, consuming all attributes in the control list of the request.
int module_instantiate(module_instance_t *instance)
Manually complete module setup by calling its instantiate function.
eap_aka_sim_process_conf_t * inst
Stores an attribute, a value and various bits of other data.
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define talloc_get_type_abort_const
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
static fr_time_delta_t fr_time_delta_from_usec(int64_t usec)
static void fr_socket_addr_swap(fr_socket_t *dst, fr_socket_t const *src)
Swap src/dst information of a fr_socket_t.
static size_t char ** out
int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.