libosmo-sigtran 2.2.1
Osmocom SIGTRAN library
Loading...
Searching...
No Matches
ss7_instance.c File Reference
#include <errno.h>
#include <stdint.h>
#include <unistd.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/talloc.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/sccp_sap.h>
#include "ss7_as.h"
#include "ss7_asp.h"
#include "ss7_internal.h"
#include "ss7_instance.h"
#include "ss7_linkset.h"
#include "ss7_route_table.h"
#include "sccp_internal.h"

Functions

 osmo_static_assert (ARRAY_SIZE(ss7_instance_xua_timer_defaults)==(SS7_INST_XUA_TIMERS_LEN) &&ARRAY_SIZE(ss7_instance_xua_timer_names)==(SS7_INST_XUA_TIMERS_LEN), assert_ss7_instance_xua_timer_count)
static void t8_inaccessible_sp_timer_cb (void *_inst)
struct osmo_ss7_instancess7_instance_alloc (void *ctx, uint32_t id)
void osmo_ss7_instance_destroy (struct osmo_ss7_instance *inst)
 Destroy a SS7 Instance.
uint32_t osmo_ss7_instance_get_id (const struct osmo_ss7_instance *inst)
const char * osmo_ss7_instance_get_name (const struct osmo_ss7_instance *inst)
uint32_t osmo_ss7_instance_get_primary_pc (const struct osmo_ss7_instance *inst)
uint8_t osmo_ss7_instance_get_network_indicator (const struct osmo_ss7_instance *inst)
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.
const struct osmo_ss7_pc_fmtosmo_ss7_instance_get_pc_fmt (const struct osmo_ss7_instance *inst)
struct osmo_sccp_instanceosmo_ss7_ensure_sccp (struct osmo_ss7_instance *inst)
 Allocate an SCCP instance, if not present yet.
struct osmo_sccp_instanceosmo_ss7_get_sccp (const struct osmo_ss7_instance *inst)
 Get the SCCP instance, if present.
bool osmo_ss7_pc_is_local (const struct osmo_ss7_instance *inst, uint32_t pc)
int osmo_ss7_find_free_rctx (struct osmo_ss7_instance *inst)
uint32_t ss7_find_free_l_rk_id (struct osmo_ss7_instance *inst)
struct osmo_ss7_routess7_instance_lookup_route (struct osmo_ss7_instance *inst, const struct osmo_ss7_route_label *rtlabel)
 Find a SS7 route for given destination point code in given SS7.
struct osmo_ss7_asosmo_ss7_as_find_by_name (struct osmo_ss7_instance *inst, const char *name)
 Find Application Server by given name.
struct osmo_ss7_asosmo_ss7_as_find_by_rctx (struct osmo_ss7_instance *inst, uint32_t rctx)
 Find Application Server by given routing context.
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.
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.
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.
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).
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)
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)
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 (const 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 (const struct osmo_ss7_instance *inst, const char *in)
 LLIST_HEAD (sccp_address_book_global)
static struct osmo_sccp_addr_entryaddr_entry_alloc (struct osmo_ss7_instance *inst, const char *name, const struct osmo_sccp_addr *addr)
int osmo_sccp_addr_create (struct osmo_ss7_instance *inst, const char *name, const struct osmo_sccp_addr *dest_addr)
 Add an SCCP address entry to the addressbook.
int osmo_sccp_addr_update (struct osmo_ss7_instance *inst, const char *name, const struct osmo_sccp_addr *dest_addr)
 Update the value of an SCCP address entry already present in the addressbook.
struct osmo_sccp_addr_entryaddr_entry_by_name_local (const char *name, const struct osmo_ss7_instance *inst)
struct osmo_sccp_addr_entryaddr_entry_by_name_global (const char *name)
struct osmo_ss7_instanceosmo_sccp_addr_by_name (struct osmo_sccp_addr *dest_addr, const char *name)
 Lookup an SCCP address from the addressbook by its name.
int osmo_sccp_addr_by_name_local (struct osmo_sccp_addr *dest_addr, const char *name, const struct osmo_ss7_instance *inst)
 Lookup an SCCP address from the addressbook of a specific instance by its name.
const char * osmo_sccp_name_by_addr (const struct osmo_sccp_addr *addr)
 Reverse lookup the lookup-name of a specified SCCP address.
bool ss7_instance_t8_inaccessible_sp_running (const struct osmo_ss7_instance *inst, uint32_t dpc)
void ss7_instance_t8_inaccessible_sp_start (struct osmo_ss7_instance *inst, uint32_t dpc)

Variables

static int32_t next_rctx = 1
static int32_t next_l_rk_id = 1
static const struct osmo_ss7_pc_fmt default_pc_fmt
static const struct rate_ctr_desc ss7_inst_rcd []
static const struct rate_ctr_group_desc ss7_inst_rcgd
const struct osmo_tdef ss7_instance_xua_timer_defaults [SS7_INST_XUA_TIMERS_LEN]
const struct value_string ss7_instance_xua_timer_names []

Function Documentation

◆ addr_entry_alloc()

◆ addr_entry_by_name_global()

struct osmo_sccp_addr_entry * addr_entry_by_name_global ( const char * name)

◆ addr_entry_by_name_local()

◆ gen_pc_fmtstr()

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

◆ get_pc_comp_shift()

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

◆ LLIST_HEAD()

◆ num_pc_comp_exp()

unsigned int num_pc_comp_exp ( const struct osmo_ss7_pc_fmt * pc_fmt)
static

◆ osmo_sccp_addr_by_name()

struct osmo_ss7_instance * osmo_sccp_addr_by_name ( struct osmo_sccp_addr * dest_addr,
const char * name )

Lookup an SCCP address from the addressbook by its name.

Parameters
[out]dest_addrpointer to output the resulting sccp-address; (set to NULL if not interested)
[in]nameof the address to lookup
Returns
SS7 instance; NULL on error

References osmo_sccp_addr_entry::addr, addr_entry_by_name_global(), osmo_sccp_addr_entry::inst, osmo_sccp_addr_entry::name, and NULL.

◆ osmo_sccp_addr_by_name_local()

int osmo_sccp_addr_by_name_local ( struct osmo_sccp_addr * dest_addr,
const char * name,
const struct osmo_ss7_instance * inst )

Lookup an SCCP address from the addressbook of a specific instance by its name.

Parameters
[out]dest_addrpointer to output the resulting sccp-address; (set to NULL if not interested)
[in]nameof the address to lookup
[in]instss7 instance of which the address book will be searched
Returns
0 on success; <0 on error

References osmo_sccp_addr_entry::addr, addr_entry_by_name_local(), osmo_sccp_addr_entry::inst, and osmo_sccp_addr_entry::name.

◆ osmo_sccp_addr_create()

int osmo_sccp_addr_create ( struct osmo_ss7_instance * inst,
const char * name,
const struct osmo_sccp_addr * dest_addr )

Add an SCCP address entry to the addressbook.

Parameters
[int]inst cs7 instance where this address belongs
[in]nameof the address to create
[in]dest_addraddress value to add to the addressbook.
Returns
0 on success, negative error code on error.

Validates that the name is unique among all cs7 instances of the process, and that no such entry already exists.

References addr_entry_alloc(), addr_entry_by_name_global(), osmo_ss7_instance::cfg, osmo_ss7_instance::id, osmo_sccp_addr_entry::inst, LOGSS7, and osmo_sccp_addr_entry::name.

Referenced by DEFUN_ATTR().

◆ osmo_sccp_addr_update()

int osmo_sccp_addr_update ( struct osmo_ss7_instance * inst,
const char * name,
const struct osmo_sccp_addr * dest_addr )

Update the value of an SCCP address entry already present in the addressbook.

Parameters
[int]inst cs7 instance where this address belongs
[in]nameof the address to update
[in]dest_addraddress value to store in the addressbook.
Returns
0 on success, negative error code on error.

References osmo_sccp_addr_entry::addr, addr_entry_by_name_local(), osmo_ss7_instance::cfg, osmo_ss7_instance::id, osmo_sccp_addr_entry::inst, LOGSS7, and osmo_sccp_addr_entry::name.

◆ osmo_sccp_name_by_addr()

const char * osmo_sccp_name_by_addr ( const struct osmo_sccp_addr * addr)

Reverse lookup the lookup-name of a specified SCCP address.

Parameters
[in]nameof the address to lookup
Returns
char pointer to the lookup-name; NULL on error

References osmo_sccp_addr_entry::addr, osmo_sccp_addr_entry::list_global, osmo_sccp_addr_entry::name, NULL, and sccp_address_book_global.

◆ 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, NULL, 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, NULL, and ss7_initialized.

Referenced by DEFUN(), DEFUN(), DEFUN(), DEFUN_ATTR(), ipa_asp_fsm_wait_id_resp(), osmo_ss7_as_find_or_create(), show_as(), 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, NULL, 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, NULL, 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, NULL, 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_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, NULL, 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_get_sccp()

struct osmo_sccp_instance * osmo_ss7_get_sccp ( const struct osmo_ss7_instance * inst)

Get the SCCP instance, if present.

Parameters
[in]instSS7 Instance on which we operate
Returns
inst->sccp, may be NULL if no SCCP instance was created yet (see osmo_ss7_ensure_sccp()).

References osmo_ss7_instance::sccp.

◆ osmo_ss7_instance_destroy()

◆ osmo_ss7_instance_get_id()

uint32_t osmo_ss7_instance_get_id ( const struct osmo_ss7_instance * inst)

◆ osmo_ss7_instance_get_name()

const char * osmo_ss7_instance_get_name ( const struct osmo_ss7_instance * inst)

◆ osmo_ss7_instance_get_network_indicator()

uint8_t osmo_ss7_instance_get_network_indicator ( const struct osmo_ss7_instance * inst)

◆ osmo_ss7_instance_get_pc_fmt()

const struct osmo_ss7_pc_fmt * osmo_ss7_instance_get_pc_fmt ( const struct osmo_ss7_instance * inst)

◆ osmo_ss7_instance_get_primary_pc()

uint32_t osmo_ss7_instance_get_primary_pc ( const struct osmo_ss7_instance * inst)

◆ 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_pc_is_local()

◆ osmo_ss7_pointcode_parse()

◆ osmo_ss7_pointcode_parse_mask_or_len()

int osmo_ss7_pointcode_parse_mask_or_len ( const 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()

◆ osmo_static_assert()

◆ pc_comp_shift_and_mask()

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

◆ ss7_find_free_l_rk_id()

uint32_t ss7_find_free_l_rk_id ( struct osmo_ss7_instance * inst)

◆ ss7_instance_alloc()

◆ ss7_instance_lookup_route()

struct osmo_ss7_route * ss7_instance_lookup_route ( struct osmo_ss7_instance * inst,
const struct osmo_ss7_route_label * rtlabel )

◆ ss7_instance_t8_inaccessible_sp_running()

◆ ss7_instance_t8_inaccessible_sp_start()

◆ strnappendchar()

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

Referenced by gen_pc_fmtstr().

◆ t8_inaccessible_sp_timer_cb()

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().

◆ 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_inst_rcd

const struct rate_ctr_desc ss7_inst_rcd[]
static
Initial value:
= {
[SS7_INST_CTR_PKT_RX_TOTAL] = { "rx:packets:total", "Total number of packets received" },
[SS7_INST_CTR_PKT_RX_UNKNOWN] = { "rx:packets:unknown", "Number of packets received for unknown PPID" },
[SS7_INST_CTR_PKT_RX_NI_MISMATCH] = { "rx:packets:ni_mismatch", "Number of packets received and dropped due to Network Indicator mismatch" },
[SS7_INST_CTR_PKT_TX_TOTAL] = { "tx:packets:total", "Total number of packets transmitted" },
}
@ SS7_INST_CTR_PKT_RX_NI_MISMATCH
Definition ss7_instance.h:36
@ SS7_INST_CTR_PKT_RX_TOTAL
Definition ss7_instance.h:34
@ SS7_INST_CTR_PKT_RX_UNKNOWN
Definition ss7_instance.h:35
@ SS7_INST_CTR_PKT_TX_TOTAL
Definition ss7_instance.h:37

◆ ss7_inst_rcgd

const struct rate_ctr_group_desc ss7_inst_rcgd
static
Initial value:
= {
.group_name_prefix = "s7i",
.group_description = "SS7 Instance",
.num_ctr = ARRAY_SIZE(ss7_inst_rcd),
.ctr_desc = ss7_inst_rcd,
}
static const struct rate_ctr_desc ss7_inst_rcd[]
Definition ss7_instance.c:52

Referenced by ss7_instance_alloc().

◆ ss7_instance_xua_timer_defaults

const struct osmo_tdef ss7_instance_xua_timer_defaults[SS7_INST_XUA_TIMERS_LEN]
Initial value:
= {
{ .T = SS7_INST_XUA_T8, .default_val = SS7_INST_XUA_DEFAULT_T8_MSEC, .unit = OSMO_TDEF_MS,
.desc = "T8 - Transfer prohibited inhibition timer (transient solution) (ms)",
.min_val = 800, .max_val = 1200},
{}
}
#define SS7_INST_XUA_DEFAULT_T8_MSEC
Definition ss7_instance.h:31
@ SS7_INST_XUA_T8
Definition ss7_instance.h:24

Referenced by gen_cs7_timer_xua_cmd_strs(), osmo_static_assert(), and ss7_instance_alloc().

◆ ss7_instance_xua_timer_names

const struct value_string ss7_instance_xua_timer_names[]