libosmo-sigtran 2.1.1
Osmocom SIGTRAN library
Loading...
Searching...
No Matches
osmo_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"

Functions

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)
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_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)

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

Function Documentation

◆ 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

◆ num_pc_comp_exp()

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

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

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

◆ strnappendchar()

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

Referenced by gen_pc_fmtstr().

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