libosmo-sigtran  1.3.0.24-e7c8
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 "sccp_internal.h"
#include "xua_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)
 
static int asp_proto_to_ip_proto (enum osmo_ss7_asp_protocol proto)
 
int osmo_ss7_find_free_rctx (struct osmo_ss7_instance *inst)
 
static uint32_t 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)
 
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 (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)
 
int osmo_ss7_asp_protocol_port (enum osmo_ss7_asp_protocol prot)
 
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)
 Destryo 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_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)
 
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...
 
int osmo_ss7_as_add_asp (struct osmo_ss7_as *as, const char *asp_name)
 Add given ASP to given AS. More...
 
int osmo_ss7_as_del_asp (struct osmo_ss7_as *as, const char *asp_name)
 Delete given ASP from given AS. More...
 
void osmo_ss7_as_destroy (struct osmo_ss7_as *as)
 Destroy given Application Server. More...
 
bool osmo_ss7_as_has_asp (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
 Determine if given AS contains ASP. More...
 
bool osmo_ss7_as_active (const struct osmo_ss7_as *as)
 Determine if given AS is in the active state. More...
 
int osmo_ss7_asp_peer_snprintf (char *buf, size_t buf_len, struct osmo_ss7_asp_peer *peer)
 
int osmo_ss7_asp_peer_set_hosts (struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *const *hosts, size_t host_cnt)
 Set (copy) addresses for a given ASP peer. More...
 
static bool host_is_ip_anyaddr (const char *host, bool is_v6)
 
int osmo_ss7_asp_peer_add_host (struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host)
 Append (copy) address to a given ASP peer. More...
 
struct osmo_ss7_asposmo_ss7_asp_find_by_name (struct osmo_ss7_instance *inst, const char *name)
 
static uint16_t get_in_port (struct sockaddr *sa)
 
static void chop_v4_mapped_on_v6_prefix (char *buf)
 
static struct osmo_ss7_asposmo_ss7_asp_find_by_socket_addr (int fd)
 Find an ASP definition matching the local+remote IP/PORT of given fd. More...
 
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 protocol. More...
 
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_create (struct osmo_ss7_instance *inst, const char *name, uint16_t remote_port, uint16_t local_port, enum osmo_ss7_asp_protocol proto)
 
void osmo_ss7_asp_destroy (struct osmo_ss7_asp *asp)
 
static int xua_cli_read_cb (struct osmo_stream_cli *conn)
 
static int ipa_cli_read_cb (struct osmo_stream_cli *conn)
 
static int xua_cli_connect_cb (struct osmo_stream_cli *cli)
 
int osmo_ss7_asp_restart (struct osmo_ss7_asp *asp)
 
bool osmo_ss7_asp_active (const struct osmo_ss7_asp *asp)
 
static int get_logevel_by_sn_type (int sn_type)
 
static void log_sctp_notification (struct osmo_ss7_asp *asp, const char *pfx, union sctp_notification *notif)
 
static int ipa_srv_conn_cb (struct osmo_stream_srv *conn)
 
static int xua_srv_conn_cb (struct osmo_stream_srv *conn)
 
static void xua_cli_close (struct osmo_stream_cli *cli)
 
static void xua_cli_close_and_reconnect (struct osmo_stream_cli *cli)
 
static int xua_srv_conn_closed_cb (struct osmo_stream_srv *srv)
 
static int xua_accept_cb (struct osmo_stream_srv_link *link, int fd)
 
int osmo_ss7_asp_send (struct osmo_ss7_asp *asp, struct msgb *msg)
 send a fully encoded msgb via a given ASP More...
 
void osmo_ss7_asp_disconnect (struct osmo_ss7_asp *asp)
 
struct osmo_xua_serverosmo_ss7_xua_server_find (struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, uint16_t local_port)
 
struct osmo_xua_serverosmo_ss7_xua_server_create (struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto, uint16_t local_port, const char *local_host)
 create a new xUA server configured with given ip/port More...
 
int osmo_ss7_xua_server_bind (struct osmo_xua_server *xs)
 Set the xUA server to bind/listen to the currently configured ip/port. More...
 
int osmo_ss7_xua_server_set_local_host (struct osmo_xua_server *xs, const char *local_host)
 
int osmo_ss7_xua_server_set_local_hosts (struct osmo_xua_server *xs, const char **local_hosts, size_t local_host_cnt)
 
int osmo_ss7_xua_server_add_local_host (struct osmo_xua_server *xs, const char *local_host)
 
void osmo_ss7_xua_server_destroy (struct osmo_xua_server *xs)
 
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)
 
int ss7_asp_rx_unknown (struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg)
 
void osmo_ss7_register_rx_unknown_cb (osmo_ss7_asp_rx_unknown_cb *cb)
 Register a call-back function for unknown SCTP PPID / IPA Stream ID. More...
 

Variables

static bool ss7_initialized = false
 
static int32_t next_rctx = 1
 
static int32_t next_l_rk_id = 1
 
struct value_string osmo_ss7_as_traffic_mode_vals []
 
struct value_string osmo_ss7_asp_protocol_vals []
 
const struct value_string osmo_ss7_asp_role_names []
 
static const struct osmo_ss7_pc_fmt default_pc_fmt
 
static const uint16_t prot2port []
 
static const struct value_string sctp_assoc_chg_vals []
 
static const struct value_string sctp_sn_type_vals []
 
static osmo_ss7_asp_rx_unknown_cbg_osmo_ss7_asp_rx_unknown_cb
 

Macro Definition Documentation

#define MAX_PC_STR_LEN   32

Function Documentation

const char* _osmo_ss7_pointcode_print ( char *  buf,
size_t  len,
const struct osmo_ss7_instance inst,
uint32_t  pc 
)
static int asp_proto_to_ip_proto ( enum osmo_ss7_asp_protocol  proto)
static
static void chop_v4_mapped_on_v6_prefix ( char *  buf)
static

References len.

Referenced by osmo_ss7_asp_find_by_socket_addr().

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

Referenced by u32_masklen().

static uint32_t find_free_l_rk_id ( struct osmo_ss7_instance inst)
static
static const char* gen_pc_fmtstr ( const struct osmo_ss7_pc_fmt pc_fmt,
unsigned int *  num_comp_exp 
)
static
static uint16_t get_in_port ( struct sockaddr *  sa)
static
static int get_logevel_by_sn_type ( int  sn_type)
static

Referenced by log_sctp_notification().

static unsigned int get_pc_comp_shift ( const struct osmo_ss7_pc_fmt pc_fmt,
unsigned int  comp_num 
)
static
static bool host_is_ip_anyaddr ( const char *  host,
bool  is_v6 
)
inlinestatic
static int ipa_cli_read_cb ( struct osmo_stream_cli *  conn)
static
static int ipa_srv_conn_cb ( struct osmo_stream_srv *  conn)
static
LLIST_HEAD ( osmo_ss7_instances  )
static void log_sctp_notification ( struct osmo_ss7_asp asp,
const char *  pfx,
union sctp_notification *  notif 
)
static
static unsigned int num_pc_comp_exp ( const struct osmo_ss7_pc_fmt pc_fmt)
static
bool osmo_ss7_as_active ( const struct osmo_ss7_as as)

Determine if given AS is in the active state.

Parameters
[in]asApplication Server.
Returns
true in case as is active; false otherwise.

References osmo_ss7_as::fi, and XUA_AS_S_ACTIVE.

Referenced by DEFUN().

int osmo_ss7_as_add_asp ( struct osmo_ss7_as as,
const char *  asp_name 
)

Add given ASP to given AS.

Parameters
[in]asApplication Server to which asp is added
[in]aspApplication Server Process to be added to as
Returns
0 on success; negative in case of error

References osmo_ss7_as::asps, osmo_ss7_as::cfg, osmo_ss7_asp::cfg, osmo_ss7_as::inst, LOGPAS, osmo_ss7_asp::name, osmo_ss7_as_has_asp(), osmo_ss7_asp_find_by_name(), and ss7_initialized.

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

int osmo_ss7_as_del_asp ( struct osmo_ss7_as as,
const char *  asp_name 
)

Delete given ASP from given AS.

Parameters
[in]asApplication Server from which asp is deleted
[in]aspApplication Server Process to delete from as
Returns
0 on success; negative in case of error

References osmo_ss7_as::asps, osmo_ss7_as::cfg, osmo_ss7_asp::cfg, osmo_ss7_as::inst, LOGPAS, osmo_ss7_asp::name, osmo_ss7_asp_find_by_name(), and ss7_initialized.

Referenced by DEFUN_ATTR(), and handle_rkey_dereg().

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_routing_key::l_rk_id, osmo_ss7_as::list, osmo_ss7_as::routing_key, and ss7_initialized.

Referenced by find_free_l_rk_id(), and handle_reg_conf().

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

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::list, osmo_ss7_asp_find_by_proto(), osmo_ss7_as::proto, and ss7_initialized.

Referenced by osmo_sccp_simple_client_on_ss7_id().

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::list, osmo_ss7_as::routing_key, and ss7_initialized.

Referenced by handle_rkey_dereg(), handle_rkey_reg(), ipa_asp_fsm_del_route(), ipa_asp_fsm_wait_id_ack2(), m3ua_rx_xfer(), osmo_ss7_find_free_rctx(), and xua_asp_fsm_inactive().

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 suuccess; NULL otherwise

References osmo_ss7_instance::as_list, osmo_ss7_as::cfg, osmo_ss7_as::fi, find_free_l_rk_id(), osmo_ss7_as::inst, osmo_ss7_routing_key::l_rk_id, osmo_ss7_as::list, LOGPAS, osmo_ss7_as::mode, osmo_ss7_as::name, osmo_ss7_as_find_by_name(), OSMO_SS7_AS_TMOD_OVERRIDE, osmo_ss7_as::proto, osmo_ss7_as::recovery_timeout_msec, osmo_ss7_as::routing_key, ss7_initialized, and xua_as_fsm_start().

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

bool osmo_ss7_as_has_asp ( struct osmo_ss7_as as,
struct osmo_ss7_asp asp 
)

Determine if given AS contains ASP.

Parameters
[in]asApplication Server in which to look for asp
[in]aspApplication Server Process to look for in as
Returns
true in case asp is part of as; false otherwise

References osmo_ss7_as::asps, osmo_ss7_as::cfg, and ss7_initialized.

Referenced by determine_traf_mode(), dispatch_to_all_as(), find_as_for_asp(), find_single_as_for_asp(), handle_rkey_dereg(), m3ua_rx_xfer(), osmo_sccp_simple_client_on_ss7_id(), osmo_ss7_as_add_asp(), xua_asp_fsm_inactive(), xua_msg_add_asp_rctx(), and xua_rkm_cleanup_dyn_as_for_asp().

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

Parameters
[in]asApplication Server in which to look for asp
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().

static struct osmo_ss7_asp* osmo_ss7_asp_find_by_socket_addr ( int  fd)
static

Find an ASP definition matching the local+remote IP/PORT of given fd.

Parameters
[in]fdsocket descriptor of given socket
Returns
SS7 ASP in case a matching one is found; NULL otherwise

References osmo_ss7_instance::asp_list, osmo_ss7_asp::cfg, chop_v4_mapped_on_v6_prefix(), get_in_port(), osmo_ss7_asp_peer::host, osmo_ss7_asp_peer::host_cnt, host_is_ip_anyaddr(), osmo_ss7_asp::list, osmo_ss7_asp::local, osmo_ss7_instances, osmo_ss7_asp_peer::port, osmo_ss7_asp::remote, and ss7_initialized.

Referenced by xua_accept_cb().

int osmo_ss7_asp_peer_add_host ( struct osmo_ss7_asp_peer peer,
void *  talloc_ctx,
const char *  host 
)

Append (copy) address to a given ASP peer.

Previous addresses are kept.

Parameters
[in]peerApplication Server Process peer the address is appened to.
[in]talloc_ctxtalloc context used to allocate new address.
[in]hoststring containing an IP addresses.
Returns
0 on success; negtive otherwise

References osmo_ss7_asp_peer::host, osmo_ss7_asp_peer::host_cnt, and host_is_ip_anyaddr().

Referenced by DEFUN_ATTR(), osmo_sccp_simple_server_add_clnt(), osmo_ss7_vty_go_parent(), and osmo_ss7_xua_server_add_local_host().

int osmo_ss7_asp_peer_set_hosts ( struct osmo_ss7_asp_peer peer,
void *  talloc_ctx,
const char *const *  hosts,
size_t  host_cnt 
)

Set (copy) addresses for a given ASP peer.

Previous addresses are freed.

Parameters
[in]peerApplication Server Process peer whose addresses are to be set.
[in]talloc_ctxtalloc context used to allocate new addresses.
[in]hostsArray of strings containing IP addresses.
[in]host_cntNumber of strings in hosts
Returns
0 on success; negtive otherwise

References osmo_ss7_asp_peer::host, and osmo_ss7_asp_peer::host_cnt.

Referenced by osmo_sccp_simple_client_on_ss7_id(), osmo_sccp_simple_server_add_clnt(), osmo_ss7_xua_server_set_local_hosts(), and xua_accept_cb().

int osmo_ss7_asp_peer_snprintf ( char *  buf,
size_t  buf_len,
struct osmo_ss7_asp_peer peer 
)
int osmo_ss7_asp_send ( struct osmo_ss7_asp asp,
struct msgb *  msg 
)
struct osmo_sccp_instance* osmo_ss7_ensure_sccp ( struct osmo_ss7_instance inst)
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().

int osmo_ss7_init ( void  )
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(), and osmo_ss7_instance_find_or_create().

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, LOGSS7, and osmo_ss7_instance::pc_fmt.

void osmo_ss7_link_destroy ( struct osmo_ss7_link link)
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.

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_instance::linksets, osmo_ss7_linkset::list, osmo_ss7_linkset::name, and ss7_initialized.

Referenced by osmo_ss7_linkset_find_or_create(), and osmo_ss7_route_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.

uint8_t osmo_ss7_pc_width ( const struct osmo_ss7_pc_fmt pc_fmt)
int osmo_ss7_pointcode_parse_mask_or_len ( struct osmo_ss7_instance inst,
const char *  in 
)
const char* osmo_ss7_pointcode_print2 ( const struct osmo_ss7_instance inst,
uint32_t  pc 
)
void osmo_ss7_register_rx_unknown_cb ( osmo_ss7_asp_rx_unknown_cb cb)

Register a call-back function for unknown SCTP PPID / IPA Stream ID.

References g_osmo_ss7_asp_rx_unknown_cb.

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
caller-allocated + initialized route, NULL on error

References osmo_ss7_route::as, osmo_ss7_linkset::cfg, osmo_ss7_route::cfg, osmo_ss7_as::cfg, osmo_ss7_route::dest, osmo_ss7_route_table::inst, osmo_ss7_route::linkset, osmo_ss7_route::linkset_name, LOGSS7, osmo_ss7_route::mask, osmo_ss7_linkset::name, osmo_ss7_as::name, osmo_ss7_as_find_by_name(), osmo_ss7_linkset_find_by_name(), osmo_ss7_pointcode_print(), osmo_ss7_route::pc, route_insert_sorted(), osmo_ss7_route::rtable, and ss7_initialized.

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

struct osmo_ss7_route* osmo_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.

References osmo_ss7_route::cfg, osmo_ss7_route::list, osmo_ss7_route::mask, osmo_ss7_route::pc, osmo_ss7_route_table::routes, and ss7_initialized.

Referenced by handle_rkey_dereg(), and osmo_ss7_route_lookup().

struct osmo_ss7_route* osmo_ss7_route_find_dpc_mask ( struct osmo_ss7_route_table rtbl,
uint32_t  dpc,
uint32_t  mask 
)
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 osmo_ss7_route_find_dpc(), osmo_ss7_instance::rtable_system, and ss7_initialized.

Referenced by gen_mtp_transfer_req_xua(), and hmrt_message_for_routing().

void osmo_ss7_route_table_destroy ( struct osmo_ss7_route_table rtbl)
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().

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

int osmo_ss7_xua_server_add_local_host ( struct osmo_xua_server xs,
const char *  local_host 
)
int osmo_ss7_xua_server_bind ( struct osmo_xua_server xs)

Set the xUA server to bind/listen to the currently configured ip/port.

Parameters
[in]xsxUA server to operate
Returns
0 on success, negative value on error.

References osmo_xua_server::cfg, osmo_xua_server::local, osmo_ss7_asp_peer_snprintf(), osmo_ss7_asp_protocol_vals, osmo_xua_server::proto, and osmo_xua_server::server.

Referenced by osmo_sccp_simple_server_on_ss7_id(), and osmo_ss7_vty_go_parent().

struct osmo_xua_server* osmo_ss7_xua_server_create ( struct osmo_ss7_instance inst,
enum osmo_ss7_asp_protocol  proto,
uint16_t  local_port,
const char *  local_host 
)

create a new xUA server configured with given ip/port

Parameters
[in]ctxtalloc allocation context
[in]protoprotocol (xUA variant) to use
[in]local_portlocal SCTP port to bind/listen to
[in]local_hostlocal IP address to bind/listen to (optional)
Returns
callee-allocated osmo_xua_server in case of success

References osmo_xua_server::asp_list, asp_proto_to_ip_proto(), osmo_xua_server::cfg, osmo_xua_server::inst, osmo_xua_server::list, osmo_xua_server::local, OSMO_SS7_ASP_PROT_SUA, osmo_ss7_asp_protocol_vals, osmo_ss7_ensure_sccp(), osmo_ss7_xua_server_set_local_host(), osmo_ss7_asp_peer::port, osmo_xua_server::proto, osmo_xua_server::server, ss7_initialized, xua_accept_cb(), and osmo_ss7_instance::xua_servers.

Referenced by DEFUN_ATTR(), and osmo_sccp_simple_server_on_ss7_id().

int osmo_ss7_xua_server_set_local_host ( struct osmo_xua_server xs,
const char *  local_host 
)
int osmo_ss7_xua_server_set_local_hosts ( struct osmo_xua_server xs,
const char **  local_hosts,
size_t  local_host_cnt 
)
static uint32_t pc_comp_shift_and_mask ( const struct osmo_ss7_pc_fmt pc_fmt,
unsigned int  comp_num,
uint32_t  pc 
)
static
static void route_insert_sorted ( struct osmo_ss7_route_table rtbl,
struct osmo_ss7_route cmp 
)
static
int ss7_asp_rx_unknown ( struct osmo_ss7_asp asp,
int  ppid_mux,
struct msgb *  msg 
)
static int strnappendchar ( char *  str,
char  c,
size_t  n 
)
static

Referenced by gen_pc_fmtstr().

static int u32_masklen ( uint32_t  mask,
unsigned int  nbits 
)
static
static void xua_cli_close ( struct osmo_stream_cli *  cli)
static
static void xua_cli_close_and_reconnect ( struct osmo_stream_cli *  cli)
static

Variable Documentation

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

Referenced by _osmo_ss7_pointcode_print(), and osmo_ss7_pointcode_parse().

osmo_ss7_asp_rx_unknown_cb* g_osmo_ss7_asp_rx_unknown_cb
static
int32_t next_l_rk_id = 1
static

Referenced by find_free_l_rk_id().

int32_t next_rctx = 1
static

Referenced by osmo_ss7_find_free_rctx().

struct value_string osmo_ss7_as_traffic_mode_vals[]
Initial value:
= {
{ OSMO_SS7_AS_TMOD_BCAST, "broadcast" },
{ OSMO_SS7_AS_TMOD_LOADSHARE, "loadshare" },
{ OSMO_SS7_AS_TMOD_ROUNDROBIN, "round-robin" },
{ OSMO_SS7_AS_TMOD_OVERRIDE, "override" },
{ 0, NULL }
}
Definition: osmo_ss7.h:260
Definition: osmo_ss7.h:259
Definition: osmo_ss7.h:261
Definition: osmo_ss7.h:262

Referenced by DEFUN_USRATTR(), and osmo_ss7_as_traffic_mode_name().

struct value_string osmo_ss7_asp_protocol_vals[]
Initial value:
= {
{ 0, NULL }
}
Definition: osmo_ss7.h:278
Definition: osmo_ss7.h:277
Definition: osmo_ss7.h:276
Definition: osmo_ss7.h:275

Referenced by DEFUN(), osmo_ss7_asp_protocol_name(), osmo_ss7_xua_server_bind(), osmo_ss7_xua_server_create(), parse_asp_proto(), vty_dump_xua_server(), write_one_xua(), and xua_accept_cb().

const struct value_string osmo_ss7_asp_role_names[]
Initial value:
= {
{ 0, NULL }
}
Definition: osmo_ss7.h:375
Definition: osmo_ss7.h:374
Definition: osmo_ss7.h:376

Referenced by write_one_asp().

const uint16_t prot2port[]
static
Initial value:
= {
}
Definition: osmo_ss7.h:278
Definition: osmo_ss7.h:277
#define M3UA_PORT
Definition: m3ua.h:26
Definition: osmo_ss7.h:276
#define SUA_PORT
Definition: sua.h:28
Definition: osmo_ss7.h:275

Referenced by osmo_ss7_asp_protocol_port().

const struct value_string sctp_assoc_chg_vals[]
static
Initial value:
= {
{ SCTP_COMM_UP, "COMM_UP" },
{ SCTP_COMM_LOST, "COMM_LOST" },
{ SCTP_RESTART, "RESTART" },
{ SCTP_SHUTDOWN_COMP, "SHUTDOWN_COMP" },
{ SCTP_CANT_STR_ASSOC, "CANT_STR_ASSOC" },
{ 0, NULL }
}

Referenced by log_sctp_notification().

const struct value_string sctp_sn_type_vals[]
static
Initial value:
= {
{ SCTP_ASSOC_CHANGE, "ASSOC_CHANGE" },
{ SCTP_PEER_ADDR_CHANGE, "PEER_ADDR_CHANGE" },
{ SCTP_SHUTDOWN_EVENT, "SHUTDOWN_EVENT" },
{ SCTP_SEND_FAILED, "SEND_FAILED" },
{ SCTP_REMOTE_ERROR, "REMOTE_ERROR" },
{ SCTP_PARTIAL_DELIVERY_EVENT, "PARTIAL_DELIVERY_EVENT" },
{ SCTP_ADAPTATION_INDICATION, "ADAPTATION_INDICATION" },
{ 0, NULL }
}

Referenced by log_sctp_notification().