35 RCSID(
"$Id: 9357724e28282a14838a0030728127222bbccfff $")
37 #define LOG_PREFIX_ARGS mctx->mi->name
39 #include <osmocom/core/linuxlist.h>
41 #include "libosmo-m3ua/include/bsc_data.h"
42 #include "libosmo-m3ua/include/sctp_m3ua.h"
44 #include <freeradius-devel/server/base.h>
45 #include <freeradius-devel/server/module_rlm.h>
46 #include <freeradius-devel/util/debug.h>
54 #if !defined(PIPE_BUF) && defined(_POSIX_PIPE_BUF)
55 # define PIPE_BUF _POSIX_PIPE_BUF
59 static_assert(
sizeof(
void *) < PIPE_BUF,
"PIPE_BUF must be large enough to accommodate a pointer");
67 {
L(
"broadcast"), 3 },
68 {
L(
"loadshare"), 2 },
219 struct sockaddr_sccp *
out,
225 if (!
conf->ssn_is_set && !
conf->pc_is_set && !
conf->gt.address) {
226 cf_log_err(cs,
"At least one of 'pc', 'ssn', or 'gt', must be set");
231 if (
conf->pc_is_set) {
232 if (
conf->pc > 16777215) {
233 cf_log_err(cs,
"Invalid value \"%d\" for 'pc', must be between 0-"
239 memcpy(&
out->poi, &
conf->pc,
sizeof(
out->poi));
246 if (
conf->gt_is_set ||
conf->gt.address) {
247 int gti_ind = SCCP_TITLE_IND_NONE;
249 size_t len = talloc_array_length(
conf->gt.address) - 1;
251 if (
conf->gt.nai_is_set && (
conf->gt.nai & 0x80)) {
252 cf_log_err(cs,
"Global title 'nai' must be between 0-127");
256 if (
conf->gt.tt_is_set) {
257 if ((
conf->gt.np_is_set && !
conf->gt.es_is_set) ||
258 (!
conf->gt.np_is_set &&
conf->gt.np_is_set)) {
259 cf_log_err(cs,
"Global title 'np' and 'es' must be "
260 "specified together");
265 cf_log_err(cs,
"Global title 'np' must be between 0-15");
269 if (
conf->gt.es > 0x0f) {
270 cf_log_err(cs,
"Global title 'es' must be between 0-15");
274 if (
conf->gt.np_is_set) {
275 gti_ind =
conf->gt.nai_is_set ? SCCP_TITLE_IND_TRANS_NUM_ENC_NATURE :
276 SCCP_TITLE_IND_TRANS_NUM_ENC;
278 gti_ind = SCCP_TITLE_IND_TRANSLATION_ONLY;
280 }
else if (
conf->gt.nai_is_set) {
281 gti_ind = SCCP_TITLE_IND_NATURE_ONLY;
284 for (i = 0; i < len; i++) {
286 cf_log_err(cs,
"Global title address contains invalid digit \"%c\". "
287 "Valid digits are [0-9#*a-c]",
conf->gt.address[i]);
294 out->gti_len = talloc_array_length(
out->gti_data);
295 out->gti_ind = gti_ind;
314 ERROR(
"Failed registering thread with multiplexer");
341 inst->conn_conf.m3ua_traffic_mode_str, -1);
342 if (
inst->conn_conf.m3ua_traffic_mode < 0) {
343 cf_log_err(
conf,
"Invalid 'm3ua_traffic_mode' value \"%s\", expected 'override', "
344 "'loadshare' or 'broadcast'",
inst->conn_conf.m3ua_traffic_mode_str);
348 #define MTP3_PC_CHECK(_x) \
350 if (inst->conn_conf.mtp3_##_x > 16777215) { \
351 cf_log_err(conf, "Invalid value \"%d\" for '#_x', must be between 0-16777215", \
352 inst->conn_conf.mtp3_##_x); \
355 __hack_##_x = inst->conn_conf.mtp3_##_x; \
362 &
inst->conn_conf.sccp_called,
conf) < 0)
return -1;
364 &
inst->conn_conf.sccp_calling,
conf) < 0)
return -1;
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
#define L(_str)
Helper for initialising arrays of string literals.
#define static_assert
For systems with an old version libc, define static_assert.
#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_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _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
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
#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.
A section grouping multiple CONF_PAIR.
#define cf_log_err(_cf, _fmt,...)
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.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
@ FR_TYPE_OCTETS
Raw octets.
module_instance_t const * mi
Instance of the module being instantiated.
void * thread
Thread specific instance data.
fr_event_list_t * el
Event list to register any IO handlers and timers against.
module_instance_t * mi
Module instance to detach.
void * thread
Thread instance data.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for detach calls.
Temporary structure to hold arguments for instantiation calls.
Temporary structure to hold arguments for thread_instantiation calls.
int sigtran_event_start(void)
Start the libosmo event loop.
int sigtran_event_exit(void)
Signal that libosmo should exit.
rlm_rcode_t
Return codes indicating the result of the module call.
static const conf_parser_t m3ua_route[]
static int mod_detach(module_detach_ctx_t const *mctx)
Cleanup internal state.
static const conf_parser_t sccp_config[]
fr_dict_attr_t const * attr_eap_aka_sim_ik
fr_dict_attr_t const * attr_eap_aka_sim_xres
fr_dict_attr_t const * attr_eap_aka_sim_ck
static fr_table_num_sorted_t const m3ua_traffic_mode_table[]
static const conf_parser_t map_config[]
static const conf_parser_t sccp_global_title[]
fr_dict_attr_t const * attr_eap_aka_sim_sres
fr_dict_attr_autoload_t rlm_sigtran_dict_attr[]
fr_dict_attr_t const * attr_eap_aka_sim_kc
static uint32_t sigtran_instances
fr_dict_attr_t const * attr_auth_type
fr_dict_autoload_t rlm_sigtran_dict[]
static const conf_parser_t sccp_address[]
fr_dict_attr_t const * attr_eap_aka_sim_autn
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
fr_dict_t const * dict_eap_aka_sim
static const conf_parser_t sctp_config[]
static int sigtran_sccp_sockaddr_from_conf(TALLOC_CTX *ctx, struct sockaddr_sccp *out, sigtran_sccp_address_t *conf, CONF_SECTION *cs)
Convert our sccp address config structure into sockaddr_sccp.
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
static size_t m3ua_traffic_mode_table_len
static const conf_parser_t m3ua_config[]
static const conf_parser_t mtp3_config[]
static const conf_parser_t module_config[]
#define MTP3_PC_CHECK(_x)
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
static int mod_instantiate(module_inst_ctx_t const *mctx)
fr_dict_attr_t const * attr_eap_aka_sim_rand
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Named methods exported by a module.
int sigtran_sccp_global_title(TALLOC_CTX *ctx, uint8_t **out, int gt_ind, char const *digits, uint8_t tt, uint8_t np, uint8_t es, uint8_t nai)
Convert a global title to wire format for SCCP.
uint8_t const is_char_tbcd[]
Check is a char is valid Telephony Binary Coded Decimal.
Declarations for various sigtran functions.
struct rlm_sigtran rlm_sigtran_t
Structure representing a complete Q.173 SCCP address.
int sigtran_client_thread_register(fr_event_list_t *el)
Called by a new thread to register a new req_pipe.
unlang_action_t sigtran_client_map_send_auth_info(rlm_rcode_t *p_result, rlm_sigtran_t const *inst, request_t *request, sigtran_conn_t const *conn, int fd)
Create a MAP_SEND_AUTH_INFO request.
int sigtran_client_link_up(sigtran_conn_t const **out, sigtran_conn_conf_t const *conn_conf)
Create a new connection.
int sigtran_client_thread_unregister(fr_event_list_t *el, int req_pipe_fd)
Signal that libosmo should unregister the other side of the pipe.
int sigtran_client_link_down(sigtran_conn_t const **conn)
Destroy a connection.
eap_aka_sim_process_conf_t * inst
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
An element in a lexicographically sorted array of name to num mappings.
#define talloc_get_type_abort_const
static size_t char ** out
#define fr_box_octets(_val, _len)