libosmo-sigtran 2.0.0.17-24bf
Osmocom SIGTRAN library
osmo_ss7.c File Reference
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/mtp_sap.h>
#include <osmocom/sigtran/protocol/mtp.h>
#include <osmocom/sigtran/protocol/sua.h>
#include <osmocom/sigtran/protocol/m3ua.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/select.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/netif/stream.h>
#include <osmocom/netif/ipa.h>
#include <osmocom/netif/sctp.h>
#include "sccp_internal.h"
#include "xua_internal.h"
#include "ss7_internal.h"
#include "xua_asp_fsm.h"
#include "xua_as_fsm.h"

Macros

#define MAX_PC_STR_LEN   32
 

Functions

 LLIST_HEAD (osmo_ss7_instances)
 
int osmo_ss7_find_free_rctx (struct osmo_ss7_instance *inst)
 
uint32_t ss7_find_free_l_rk_id (struct osmo_ss7_instance *inst)
 
static int strnappendchar (char *str, char c, size_t n)
 
static const char * gen_pc_fmtstr (const struct osmo_ss7_pc_fmt *pc_fmt, unsigned int *num_comp_exp)
 
static unsigned int num_pc_comp_exp (const struct osmo_ss7_pc_fmt *pc_fmt)
 
uint8_t osmo_ss7_pc_width (const struct osmo_ss7_pc_fmt *pc_fmt)
 
uint32_t osmo_ss7_pc_normalize (const struct osmo_ss7_pc_fmt *pc_fmt, uint32_t pc)
 
static unsigned int get_pc_comp_shift (const struct osmo_ss7_pc_fmt *pc_fmt, unsigned int comp_num)
 
static uint32_t pc_comp_shift_and_mask (const struct osmo_ss7_pc_fmt *pc_fmt, unsigned int comp_num, uint32_t pc)
 
int osmo_ss7_pointcode_parse (struct osmo_ss7_instance *inst, const char *str)
 
const char * osmo_ss7_pointcode_print_buf (char *buf, size_t len, const struct osmo_ss7_instance *inst, uint32_t pc)
 
const char * osmo_ss7_pointcode_print (const struct osmo_ss7_instance *inst, uint32_t pc)
 
const char * osmo_ss7_pointcode_print2 (const struct osmo_ss7_instance *inst, uint32_t pc)
 
int osmo_ss7_pointcode_parse_mask_or_len (struct osmo_ss7_instance *inst, const char *in)
 
struct osmo_ss7_instanceosmo_ss7_instance_find (uint32_t id)
 Find a SS7 Instance with given ID. More...
 
struct osmo_ss7_instanceosmo_ss7_instance_find_or_create (void *ctx, uint32_t id)
 Find or create a SS7 Instance. More...
 
void osmo_ss7_instance_destroy (struct osmo_ss7_instance *inst)
 Destroy a SS7 Instance. More...
 
int osmo_ss7_instance_set_pc_fmt (struct osmo_ss7_instance *inst, uint8_t c0, uint8_t c1, uint8_t c2)
 Set the point code format used in given SS7 instance. More...
 
struct osmo_sccp_instanceosmo_ss7_ensure_sccp (struct osmo_ss7_instance *inst)
 Allocate an SCCP instance, if not present yet. More...
 
int osmo_ss7_user_register (struct osmo_ss7_instance *inst, uint8_t service_ind, struct osmo_ss7_user *user)
 Register a MTP user for a given service indicator. More...
 
int osmo_ss7_user_unregister (struct osmo_ss7_instance *inst, uint8_t service_ind, struct osmo_ss7_user *user)
 Unregister a MTP user for a given service indicator. More...
 
int osmo_ss7_mtp_to_user (struct osmo_ss7_instance *inst, struct osmo_mtp_prim *omp)
 
void osmo_ss7_linkset_destroy (struct osmo_ss7_linkset *lset)
 Destroy a SS7 Linkset. More...
 
struct osmo_ss7_linksetosmo_ss7_linkset_find_by_name (struct osmo_ss7_instance *inst, const char *name)
 Find SS7 Linkset by given name. More...
 
struct osmo_ss7_linksetosmo_ss7_linkset_find_or_create (struct osmo_ss7_instance *inst, const char *name, uint32_t pc)
 Find or allocate SS7 Linkset. More...
 
void osmo_ss7_link_destroy (struct osmo_ss7_link *link)
 Destroy SS7 Link. More...
 
struct osmo_ss7_linkosmo_ss7_link_find_or_create (struct osmo_ss7_linkset *lset, uint32_t id)
 Find or create SS7 Link with given ID in given Linkset. More...
 
struct osmo_ss7_route_tableosmo_ss7_route_table_find (struct osmo_ss7_instance *inst, const char *name)
 
struct osmo_ss7_route_tableosmo_ss7_route_table_find_or_create (struct osmo_ss7_instance *inst, const char *name)
 
void osmo_ss7_route_table_destroy (struct osmo_ss7_route_table *rtbl)
 
struct osmo_ss7_routess7_route_alloc (struct osmo_ss7_route_table *rtbl, uint32_t pc, uint32_t mask)
 Allocate a route entry. More...
 
static bool ss7_route_inserted (const struct osmo_ss7_route *rt)
 Check whether route has already been inserted into its routing table. More...
 
int ss7_route_set_linkset (struct osmo_ss7_route *rt, const char *linkset_name)
 Set linkset on route entry. More...
 
struct osmo_ss7_routeosmo_ss7_route_find_dpc (struct osmo_ss7_route_table *rtbl, uint32_t dpc)
 Find a SS7 route for given destination point code in given table. More...
 
struct osmo_ss7_routeosmo_ss7_route_find_dpc_mask (struct osmo_ss7_route_table *rtbl, uint32_t dpc, uint32_t mask)
 Find a SS7 route for given destination point code + mask in given table. More...
 
struct osmo_ss7_routeosmo_ss7_route_lookup (struct osmo_ss7_instance *inst, uint32_t dpc)
 Find a SS7 route for given destination point code in given SS7. More...
 
static void route_insert_sorted (struct osmo_ss7_route_table *rtbl, struct osmo_ss7_route *cmp)
 
int ss7_route_insert (struct osmo_ss7_route *rt)
 Insert route into its routing table. More...
 
struct osmo_ss7_routeosmo_ss7_route_create (struct osmo_ss7_route_table *rtbl, uint32_t pc, uint32_t mask, const char *linkset_name)
 Create a new route in the given routing table. More...
 
void osmo_ss7_route_destroy (struct osmo_ss7_route *rt)
 Destroy a given SS7 route. More...
 
static unsigned int count_leading_one_bits (uint32_t inp, unsigned int nbits)
 
static int u32_masklen (uint32_t mask, unsigned int nbits)
 
const char * osmo_ss7_route_print (const struct osmo_ss7_route *rt)
 
struct osmo_ss7_asosmo_ss7_as_find_by_name (struct osmo_ss7_instance *inst, const char *name)
 Find Application Server by given name. More...
 
struct osmo_ss7_asosmo_ss7_as_find_by_rctx (struct osmo_ss7_instance *inst, uint32_t rctx)
 Find Application Server by given routing context. More...
 
struct osmo_ss7_asosmo_ss7_as_find_by_l_rk_id (struct osmo_ss7_instance *inst, uint32_t l_rk_id)
 Find Application Server by given local routing key ID. More...
 
struct osmo_ss7_asosmo_ss7_as_find_by_proto (struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto)
 Find Application Server (AS) by given protocol. More...
 
struct osmo_ss7_asosmo_ss7_as_find_or_create (struct osmo_ss7_instance *inst, const char *name, enum osmo_ss7_asp_protocol proto)
 Find or Create Application Server. More...
 
bool ss7_ipv6_sctp_supported (const char *host, bool bind)
 
struct osmo_ss7_asposmo_ss7_asp_find_by_name (struct osmo_ss7_instance *inst, const char *name)
 
struct osmo_ss7_asposmo_ss7_asp_find_by_proto (struct osmo_ss7_as *as, enum osmo_ss7_asp_protocol proto)
 Find an ASP that matches the given ASP protocol (xUA variant). More...
 
struct osmo_ss7_asposmo_ss7_asp_find2 (struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, int trans_proto, enum osmo_ss7_asp_protocol proto)
 
struct osmo_ss7_asposmo_ss7_asp_find (struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, enum osmo_ss7_asp_protocol proto)
 
struct osmo_ss7_asposmo_ss7_asp_find_or_create2 (struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, int trans_proto, enum osmo_ss7_asp_protocol proto)
 
struct osmo_ss7_asposmo_ss7_asp_find_or_create (struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, enum osmo_ss7_asp_protocol proto)
 
struct osmo_xua_serverosmo_ss7_xua_server_find2 (struct osmo_ss7_instance *inst, int trans_proto, enum osmo_ss7_asp_protocol proto, uint16_t local_port)
 find an xUA server with the given parameters More...
 
struct osmo_xua_serverosmo_ss7_xua_server_find (struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, uint16_t local_port)
 find an xUA server with the given parameters More...
 
bool osmo_ss7_pc_is_local (struct osmo_ss7_instance *inst, uint32_t pc)
 
int osmo_ss7_init (void)
 
int osmo_ss7_tmode_to_xua (enum osmo_ss7_as_traffic_mode tmod)
 
enum osmo_ss7_as_traffic_mode osmo_ss7_tmode_from_xua (uint32_t in)
 
bool osmo_ss7_as_tmode_compatible_xua (struct osmo_ss7_as *as, uint32_t m3ua_tmt)
 

Variables

bool ss7_initialized = false
 
static int32_t next_rctx = 1
 
static int32_t next_l_rk_id = 1
 
const struct value_string mtp_unavail_cause_vals []
 
static const struct osmo_ss7_pc_fmt default_pc_fmt
 

Macro Definition Documentation

◆ MAX_PC_STR_LEN

#define MAX_PC_STR_LEN   32

Function Documentation

◆ count_leading_one_bits()

static unsigned int count_leading_one_bits ( uint32_t  inp,
unsigned int  nbits 
)
static

Referenced by u32_masklen().

◆ gen_pc_fmtstr()

static const char * gen_pc_fmtstr ( const struct osmo_ss7_pc_fmt pc_fmt,
unsigned int *  num_comp_exp 
)
static

◆ get_pc_comp_shift()

static unsigned int get_pc_comp_shift ( const struct osmo_ss7_pc_fmt pc_fmt,
unsigned int  comp_num 
)
static

◆ LLIST_HEAD()

LLIST_HEAD ( osmo_ss7_instances  )

◆ num_pc_comp_exp()

static unsigned int num_pc_comp_exp ( const struct osmo_ss7_pc_fmt pc_fmt)
static

◆ osmo_ss7_as_find_by_l_rk_id()

struct osmo_ss7_as * osmo_ss7_as_find_by_l_rk_id ( struct osmo_ss7_instance inst,
uint32_t  l_rk_id 
)

Find Application Server by given local routing key ID.

Parameters
[in]instSS7 Instance on which we operate
[in]l_rk_idLocal Routing Key ID
Returns
pointer to Application Server on success; NULL otherwise

References osmo_ss7_instance::as_list, osmo_ss7_as::cfg, osmo_ss7_as::inst, osmo_ss7_routing_key::l_rk_id, osmo_ss7_as::list, osmo_ss7_as::routing_key, and ss7_initialized.

Referenced by handle_reg_conf(), and ss7_find_free_l_rk_id().

◆ osmo_ss7_as_find_by_name()

struct osmo_ss7_as * osmo_ss7_as_find_by_name ( struct osmo_ss7_instance inst,
const char *  name 
)

Find Application Server by given name.

Parameters
[in]instSS7 Instance on which we operate
[in]nameName of AS
Returns
pointer to Application Server on success; NULL otherwise

References osmo_ss7_instance::as_list, osmo_ss7_as::cfg, osmo_ss7_as::inst, osmo_ss7_as::list, osmo_ss7_as::name, and ss7_initialized.

Referenced by DEFUN_ATTR(), ipa_asp_fsm_wait_id_resp(), osmo_ss7_as_find_or_create(), and ss7_route_set_linkset().

◆ osmo_ss7_as_find_by_proto()

struct osmo_ss7_as * osmo_ss7_as_find_by_proto ( struct osmo_ss7_instance inst,
enum osmo_ss7_asp_protocol  proto 
)

Find Application Server (AS) by given protocol.

Parameters
[in]instSS7 Instance on which we operate
[in]protoProtocol identifier that must match
Returns
pointer to AS on success; NULL otherwise If an AS has an ASP also matching the given protocol, that AS is preferred. If there are multiple matches, return the first matching AS.

References osmo_ss7_instance::as_list, osmo_ss7_as::cfg, osmo_ss7_as::inst, osmo_ss7_as::list, osmo_ss7_asp_find_by_proto(), osmo_ss7_as::proto, and ss7_initialized.

Referenced by osmo_sccp_simple_client_on_ss7_id().

◆ osmo_ss7_as_find_by_rctx()

struct osmo_ss7_as * osmo_ss7_as_find_by_rctx ( struct osmo_ss7_instance inst,
uint32_t  rctx 
)

Find Application Server by given routing context.

Parameters
[in]instSS7 Instance on which we operate
[in]rctxRouting Context
Returns
pointer to Application Server on success; NULL otherwise

References osmo_ss7_instance::as_list, osmo_ss7_as::cfg, osmo_ss7_routing_key::context, osmo_ss7_as::inst, osmo_ss7_as::list, osmo_ss7_as::routing_key, and ss7_initialized.

Referenced by handle_rkey_dereg(), handle_rkey_reg(), osmo_ss7_find_free_rctx(), xua_asp_fsm_inactive(), and xua_find_as_for_asp().

◆ osmo_ss7_as_find_or_create()

struct osmo_ss7_as * osmo_ss7_as_find_or_create ( struct osmo_ss7_instance inst,
const char *  name,
enum osmo_ss7_asp_protocol  proto 
)

Find or Create Application Server.

Parameters
[in]instSS7 Instance on which we operate
[in]nameName of Application Server
[in]protoProtocol of Application Server
Returns
pointer to Application Server on success; NULL otherwise

References osmo_ss7_as::cfg, osmo_ss7_as::inst, LOGPAS, osmo_ss7_as::name, osmo_ss7_as_find_by_name(), osmo_ss7_as::proto, ss7_as_alloc(), and ss7_initialized.

Referenced by DEFUN_ATTR(), handle_rkey_reg(), osmo_sccp_simple_client_on_ss7_id(), and osmo_sccp_simple_server_add_clnt().

◆ osmo_ss7_as_tmode_compatible_xua()

◆ osmo_ss7_asp_find()

struct osmo_ss7_asp * osmo_ss7_asp_find ( struct osmo_ss7_instance inst,
const char *  name,
uint16_t  remote_port,
uint16_t  local_port,
enum osmo_ss7_asp_protocol  proto 
)

◆ osmo_ss7_asp_find2()

struct osmo_ss7_asp * osmo_ss7_asp_find2 ( struct osmo_ss7_instance inst,
const char *  name,
uint16_t  remote_port,
uint16_t  local_port,
int  trans_proto,
enum osmo_ss7_asp_protocol  proto 
)

◆ osmo_ss7_asp_find_by_name()

◆ osmo_ss7_asp_find_by_proto()

struct osmo_ss7_asp * osmo_ss7_asp_find_by_proto ( struct osmo_ss7_as as,
enum osmo_ss7_asp_protocol  proto 
)

Find an ASP that matches the given ASP protocol (xUA variant).

Parameters
[in]asApplication Server in which to look for asp
[in]protoASP protocol (xUA variant) to match
Returns
SS7 ASP in case a matching one is found; NULL otherwise

References osmo_ss7_as::asps, osmo_ss7_as::cfg, osmo_ss7_asp::cfg, and osmo_ss7_asp::proto.

Referenced by osmo_sccp_simple_client_on_ss7_id(), and osmo_ss7_as_find_by_proto().

◆ osmo_ss7_asp_find_or_create()

struct osmo_ss7_asp * osmo_ss7_asp_find_or_create ( struct osmo_ss7_instance inst,
const char *  name,
uint16_t  remote_port,
uint16_t  local_port,
enum osmo_ss7_asp_protocol  proto 
)

◆ osmo_ss7_asp_find_or_create2()

◆ osmo_ss7_ensure_sccp()

struct osmo_sccp_instance * osmo_ss7_ensure_sccp ( struct osmo_ss7_instance inst)

◆ osmo_ss7_find_free_rctx()

int osmo_ss7_find_free_rctx ( struct osmo_ss7_instance inst)

References next_rctx, and osmo_ss7_as_find_by_rctx().

Referenced by handle_rkey_reg().

◆ osmo_ss7_init()

int osmo_ss7_init ( void  )

◆ osmo_ss7_instance_destroy()

◆ osmo_ss7_instance_find()

struct osmo_ss7_instance * osmo_ss7_instance_find ( uint32_t  id)

Find a SS7 Instance with given ID.

Parameters
[in]idID for which to search
Returns
osmo_ss7_instance on success; NULL on error

References osmo_ss7_instance::cfg, osmo_ss7_instance::id, osmo_ss7_instance::list, osmo_ss7_instances, and ss7_initialized.

Referenced by DEFUN(), osmo_sccp_simple_client_on_ss7_id(), osmo_ss7_instance_find_or_create(), show_asp(), show_asp_assoc_status(), and show_asp_remaddr().

◆ osmo_ss7_instance_find_or_create()

◆ osmo_ss7_instance_set_pc_fmt()

int osmo_ss7_instance_set_pc_fmt ( struct osmo_ss7_instance inst,
uint8_t  c0,
uint8_t  c1,
uint8_t  c2 
)

Set the point code format used in given SS7 instance.

References osmo_ss7_instance::cfg, osmo_ss7_pc_fmt::component_len, osmo_ss7_asp::inst, LOGSS7, and osmo_ss7_instance::pc_fmt.

◆ osmo_ss7_link_destroy()

void osmo_ss7_link_destroy ( struct osmo_ss7_link link)

◆ osmo_ss7_link_find_or_create()

struct osmo_ss7_link * osmo_ss7_link_find_or_create ( struct osmo_ss7_linkset lset,
uint32_t  id 
)

Find or create SS7 Link with given ID in given Linkset.

Parameters
[in]lsetSS7 Linkset on which we operate
[in]idLink number within Linkset
Returns
pointer to SS7 Link on success; NULL on error

References osmo_ss7_link::cfg, osmo_ss7_linkset::cfg, osmo_ss7_link::id, osmo_ss7_linkset::inst, osmo_ss7_linkset::links, osmo_ss7_link::linkset, LOGSS7, osmo_ss7_linkset::name, and ss7_initialized.

◆ osmo_ss7_linkset_destroy()

◆ osmo_ss7_linkset_find_by_name()

struct osmo_ss7_linkset * osmo_ss7_linkset_find_by_name ( struct osmo_ss7_instance inst,
const char *  name 
)

Find SS7 Linkset by given name.

Parameters
[in]instSS7 Instance in which to look
[in]nameName of SS7 Linkset
Returns
pointer to linkset on success; NULL on error

References osmo_ss7_linkset::cfg, osmo_ss7_linkset::inst, osmo_ss7_instance::linksets, osmo_ss7_linkset::list, osmo_ss7_linkset::name, and ss7_initialized.

Referenced by osmo_ss7_linkset_find_or_create(), and ss7_route_set_linkset().

◆ osmo_ss7_linkset_find_or_create()

struct osmo_ss7_linkset * osmo_ss7_linkset_find_or_create ( struct osmo_ss7_instance inst,
const char *  name,
uint32_t  pc 
)

Find or allocate SS7 Linkset.

Parameters
[in]instSS7 Instance in which we operate
[in]nameName of SS7 Linkset
[in]pcAdjacent Pointcode
Returns
pointer to Linkset on success; NULL on error

References osmo_ss7_linkset::adjacent_pc, osmo_ss7_linkset::cfg, osmo_ss7_linkset::inst, osmo_ss7_instance::linksets, osmo_ss7_linkset::list, LOGSS7, osmo_ss7_linkset::name, osmo_ss7_linkset_find_by_name(), and ss7_initialized.

◆ osmo_ss7_mtp_to_user()

◆ osmo_ss7_pc_is_local()

◆ osmo_ss7_pc_normalize()

uint32_t osmo_ss7_pc_normalize ( const struct osmo_ss7_pc_fmt pc_fmt,
uint32_t  pc 
)

◆ osmo_ss7_pc_width()

◆ osmo_ss7_pointcode_parse()

◆ osmo_ss7_pointcode_parse_mask_or_len()

int osmo_ss7_pointcode_parse_mask_or_len ( struct osmo_ss7_instance inst,
const char *  in 
)

◆ osmo_ss7_pointcode_print()

◆ osmo_ss7_pointcode_print2()

const char * osmo_ss7_pointcode_print2 ( const struct osmo_ss7_instance inst,
uint32_t  pc 
)

◆ osmo_ss7_pointcode_print_buf()

const char * osmo_ss7_pointcode_print_buf ( char *  buf,
size_t  len,
const struct osmo_ss7_instance inst,
uint32_t  pc 
)

◆ osmo_ss7_route_create()

struct osmo_ss7_route * osmo_ss7_route_create ( struct osmo_ss7_route_table rtbl,
uint32_t  pc,
uint32_t  mask,
const char *  linkset_name 
)

Create a new route in the given routing table.

Parameters
[in]rtblRouting Table in which the route is to be created
[in]pcPoint Code of the destination of the route
[in]maskMask of the destination Point Code pc
[in]linkset_namestring name of the linkset to be used
Returns
callee-allocated + initialized route, NULL on error

The route allocated and returned by this API is already inserted into the routing table, with priority and qos-class set to 0. If you plan to use different values for priority and qos-class, avoid using this API and use ss7_route_alloc() + ss7_route_set_linkset() + ss7_route_insert() instead.

References osmo_ss7_route::cfg, osmo_ss7_route::linkset_name, osmo_ss7_route::mask, osmo_ss7_route_find_dpc_mask(), osmo_ss7_route::pc, ss7_route_alloc(), ss7_route_insert(), and ss7_route_set_linkset().

Referenced by _rout_key(), handle_rkey_reg(), ipa_add_route(), osmo_sccp_simple_client_on_ss7_id(), and osmo_sccp_simple_server_add_clnt().

◆ osmo_ss7_route_destroy()

◆ osmo_ss7_route_find_dpc()

struct osmo_ss7_route * osmo_ss7_route_find_dpc ( struct osmo_ss7_route_table rtbl,
uint32_t  dpc 
)

◆ osmo_ss7_route_find_dpc_mask()

◆ osmo_ss7_route_lookup()

struct osmo_ss7_route * osmo_ss7_route_lookup ( struct osmo_ss7_instance inst,
uint32_t  dpc 
)

Find a SS7 route for given destination point code in given SS7.

References dpc, osmo_ss7_route_find_dpc(), osmo_ss7_instance::rtable_system, and ss7_initialized.

Referenced by gen_mtp_transfer_req_xua(), hmrt_message_for_routing(), and xua_snm_rx_daud().

◆ osmo_ss7_route_print()

◆ osmo_ss7_route_table_destroy()

void osmo_ss7_route_table_destroy ( struct osmo_ss7_route_table rtbl)

◆ osmo_ss7_route_table_find()

◆ osmo_ss7_route_table_find_or_create()

◆ osmo_ss7_tmode_from_xua()

◆ osmo_ss7_tmode_to_xua()

◆ osmo_ss7_user_register()

int osmo_ss7_user_register ( struct osmo_ss7_instance inst,
uint8_t  service_ind,
struct osmo_ss7_user user 
)

Register a MTP user for a given service indicator.

Parameters
[in]instSS7 instance for which we register the user
[in]service_indService (ISUP, SCCP, ...)
[in]userSS7 user (including primitive call-back)
Returns
0 on success; negative on error

References osmo_ss7_user::inst, osmo_ss7_user::name, osmo_ss7_user::priv, and osmo_ss7_instance::user.

Referenced by osmo_sccp_instance_create().

◆ osmo_ss7_user_unregister()

int osmo_ss7_user_unregister ( struct osmo_ss7_instance inst,
uint8_t  service_ind,
struct osmo_ss7_user user 
)

Unregister a MTP user for a given service indicator.

Parameters
[in]instSS7 instance for which we register the user
[in]service_indService (ISUP, SCCP, ...)
[in]user(optional) SS7 user. If present, we will not unregister other users
Returns
0 on success; negative on error

References osmo_ss7_user::inst, and osmo_ss7_instance::user.

Referenced by osmo_sccp_instance_destroy().

◆ osmo_ss7_xua_server_find()

struct osmo_xua_server * osmo_ss7_xua_server_find ( struct osmo_ss7_instance inst,
enum osmo_ss7_asp_protocol  proto,
uint16_t  local_port 
)

find an xUA server with the given parameters

Parameters
[in]instSS7 Instance on which we operate
[in]protoprotocol (xUA variant) in use
[in]local_portlocal port of the server
Returns
osmo_xua_server or NULL (not found)

References osmo_xua_server::inst, osmo_ss7_xua_server_find2(), osmo_xua_server::proto, ss7_default_trans_proto_for_asp_proto(), and osmo_xua_server::trans_proto.

◆ osmo_ss7_xua_server_find2()

struct osmo_xua_server * osmo_ss7_xua_server_find2 ( struct osmo_ss7_instance inst,
int  trans_proto,
enum osmo_ss7_asp_protocol  proto,
uint16_t  local_port 
)

find an xUA server with the given parameters

Parameters
[in]instSS7 Instance on which we operate
[in]trans_prototransport protocol in use (one of IPPROTO_*)
[in]protoprotocol (xUA variant) in use
[in]local_portlocal port of the server
Returns
osmo_xua_server or NULL (not found)

References osmo_xua_server::cfg, osmo_xua_server::inst, osmo_xua_server::list, osmo_xua_server::local, osmo_ss7_asp_peer::port, osmo_xua_server::proto, ss7_initialized, osmo_xua_server::trans_proto, and osmo_ss7_instance::xua_servers.

Referenced by DEFUN_ATTR(), osmo_sccp_simple_client_on_ss7_id(), osmo_sccp_simple_server_add_clnt(), and osmo_ss7_xua_server_find().

◆ pc_comp_shift_and_mask()

static uint32_t pc_comp_shift_and_mask ( const struct osmo_ss7_pc_fmt pc_fmt,
unsigned int  comp_num,
uint32_t  pc 
)
static

◆ route_insert_sorted()

static void route_insert_sorted ( struct osmo_ss7_route_table rtbl,
struct osmo_ss7_route cmp 
)
static

◆ ss7_find_free_l_rk_id()

uint32_t ss7_find_free_l_rk_id ( struct osmo_ss7_instance inst)

◆ ss7_ipv6_sctp_supported()

bool ss7_ipv6_sctp_supported ( const char *  host,
bool  bind 
)

◆ ss7_route_alloc()

struct osmo_ss7_route * ss7_route_alloc ( struct osmo_ss7_route_table rtbl,
uint32_t  pc,
uint32_t  mask 
)

Allocate a route entry.

Parameters
[in]rtblRouting Table where the route belongs
[in]pcPoint Code of the destination of the route
[in]maskMask of the destination Point Code pc
Returns
Allocated route (not yet inserted into its rtbl), NULL on error

The returned route has no linkset associated yet, user must associate it using API ss7_route_set_linkset() before inserting the route into its routing table.

Fields priority and qos_class may be set before inserting the route into its routing table:

  • A default priority of 0 is configured on the route.
  • A default qos-class of 0 is configured on the route.

Use API ss7_route_insert() to insert the route into its routing table.

The route entry allocated with this API can be destroyed/freed at any point using API osmo_ss7_route_destroy(), regardless of it being already inserted or not in its routing table.

References osmo_ss7_instance::cfg, osmo_ss7_route::cfg, osmo_ss7_route_table::inst, osmo_ss7_route::list, osmo_ss7_route::mask, osmo_ss7_pc_normalize(), OSMO_SS7_ROUTE_PRIO_DEFAULT, osmo_ss7_route::pc, osmo_ss7_instance::pc_fmt, osmo_ss7_route::priority, osmo_ss7_route::rtable, and ss7_initialized.

Referenced by DEFUN_ATTR(), and osmo_ss7_route_create().

◆ ss7_route_insert()

int ss7_route_insert ( struct osmo_ss7_route rt)

Insert route into its routing table.

Parameters
[in]rtRoute to be inserted into its routing table
Returns
0 on success, negative on error

A route is only really used once it has been inserted into its routing table.

References osmo_ss7_route::cfg, osmo_ss7_route_table::inst, osmo_ss7_route::linkset_name, LOGSS7, osmo_ss7_route::mask, osmo_ss7_pointcode_print(), osmo_ss7_route_find_dpc_mask(), osmo_ss7_route::pc, route_insert_sorted(), osmo_ss7_route::rtable, and ss7_route_inserted().

Referenced by DEFUN_ATTR(), and osmo_ss7_route_create().

◆ ss7_route_inserted()

static bool ss7_route_inserted ( const struct osmo_ss7_route rt)
static

Check whether route has already been inserted into its routing table.

Returns
true if already inserted, false if not.

References osmo_ss7_route::list.

Referenced by osmo_ss7_route_destroy(), ss7_route_insert(), and ss7_route_set_linkset().

◆ ss7_route_set_linkset()

int ss7_route_set_linkset ( struct osmo_ss7_route rt,
const char *  linkset_name 
)

◆ strnappendchar()

static int strnappendchar ( char *  str,
char  c,
size_t  n 
)
static

Referenced by gen_pc_fmtstr().

◆ u32_masklen()

static int u32_masklen ( uint32_t  mask,
unsigned int  nbits 
)
static

Variable Documentation

◆ default_pc_fmt

const struct osmo_ss7_pc_fmt default_pc_fmt
static
Initial value:
= {
.delimiter = '.',
.component_len = { 3, 8, 3},
}

Referenced by osmo_ss7_pointcode_parse(), osmo_ss7_pointcode_parse_mask_or_len(), and osmo_ss7_pointcode_print_buf().

◆ mtp_unavail_cause_vals

const struct value_string mtp_unavail_cause_vals[]
Initial value:
= {
{ MTP_UNAVAIL_C_UNKNOWN, "unknown" },
{ MTP_UNAVAIL_C_UNEQUIP_REM_USER, "unequipped-remote-user" },
{ MTP_UNAVAIL_C_INACC_REM_USER, "inaccessible-remote-user" },
{ 0, NULL }
}
@ MTP_UNAVAIL_C_UNEQUIP_REM_USER
Definition: mtp.h:30
@ MTP_UNAVAIL_C_UNKNOWN
Definition: mtp.h:29
@ MTP_UNAVAIL_C_INACC_REM_USER
Definition: mtp.h:31

Referenced by mtp_unavail_cause_str().

◆ next_l_rk_id

int32_t next_l_rk_id = 1
static

Referenced by ss7_find_free_l_rk_id().

◆ next_rctx

int32_t next_rctx = 1
static

Referenced by osmo_ss7_find_free_rctx().

◆ ss7_initialized