libosmo-sigtran 2.2.1
Osmocom SIGTRAN library
Loading...
Searching...
No Matches
tcap_as_loadshare.c File Reference
#include <errno.h>
#include <osmocom/core/bit32gen.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/talloc.h>
#include <osmocom/netif/ipa.h>
#include <osmocom/sccp/sccp_types.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/protocol/m3ua.h>
#include <osmocom/sigtran/protocol/sua.h>
#include <osmocom/sigtran/protocol/mtp.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/tcap/OCTET_STRING.h>
#include <osmocom/tcap/TCAP_TCMessage.h>
#include <osmocom/tcap/tcap.h>
#include "mtp3_hmrt.h"
#include "ss7_as.h"
#include "sccp_internal.h"
#include "ss7_asp.h"
#include "ss7_internal.h"
#include "ss7_vty.h"
#include "tcap_as_loadshare.h"
#include "tcap_trans_tracking.h"
#include "xua_internal.h"

Data Structures

struct  tcap_parsed
struct  ipa_tcap_routing_hdr
struct  ipa_tcap_routing_add_range
struct  ipa_tcap_routing_nack

Macros

#define OTID_SET   1 << 0
#define DTID_SET   1 << 1

Enumerations

enum  ipa_tcap_routing_msg_types { MT_TID_ADD_RANGE = 0x01 , MT_TID_ACK = 0x02 , MT_TID_NACK = 0x03 }
enum  ipa_tcap_routing_nack_error { NACK_ERR_SYS_FAILURE = 0x01 , NACK_ERR_EALREADY = 0x72 }

Functions

static int tcap_id_from_octet_str (uint32_t *tid, const OCTET_STRING_t *src)
static int parse_tcap (struct osmo_ss7_as *as, const uint8_t *data, size_t len, struct tcap_parsed *ids)
static uint32_t tcap_gen_hash (uint32_t pc, uint8_t ssn)
static uint64_t tcap_gen_hash_addr (const struct osmo_sccp_addr *addr)
static struct osmo_ss7_asp * tcap_hlist_get (const struct osmo_ss7_as *as, uint32_t pc, uint8_t ssn, uint32_t tid)
struct osmo_ss7_asp * tcap_as_asp_find_by_tcap_id (struct osmo_ss7_as *as, struct osmo_sccp_addr *calling_addr, struct osmo_sccp_addr *called_addr, uint32_t otid)
static struct tcap_range * tcap_overlap_tid (struct osmo_ss7_as *as, uint32_t pc, uint8_t ssn, uint32_t tid_start, uint32_t tid_end)
static struct osmo_ss7_asp * select_asp_tcap_enabled_rr (struct osmo_ss7_as *as)
static bool ssn_contains_tcap (uint8_t ssn)
int tcap_as_rx_sccp_asp (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp, uint32_t opc, uint32_t dpc, struct msgb *sccp_msg)
 Traffic from the TCAP ASP -> AS -> osmo-stp, only used to update transaction tracking.
static int send_back_udts (struct osmo_ss7_as *as, const struct osmo_mtp_transfer_param *orig_mtp, const struct xua_msg *orig_sua, uint8_t cause_code)
 Send UDTS to indicate that the originating UDT could not be delivered to its destination.
static int asp_loadshare_tcap_route_fallback (struct osmo_ss7_as *as, const struct osmo_mtp_transfer_param *orig_mtp, const struct msgb *sccp_msg)
 When a TCAP message can't be routed by TID or session cache and unroutable_tcap_msg == SS7_AS_TCPA_UNROUTABLE_ROUTE_FALLBACK, route to a different DPC.
static int asp_loadshare_tcap_handle_unroutable (struct osmo_ss7_asp **rasp, struct osmo_ss7_as *as, const struct osmo_mtp_transfer_param *mtp, const struct msgb *sccp_msg)
 When a TCAP MSU from an ongoing session (TCAP != Begin) could not be routed either by the TCAP session tracking or by the TID range, such messages will be passed to this function.
static int asp_loadshare_tcap_sccp (struct osmo_ss7_asp **rasp, struct osmo_ss7_as *as, const struct osmo_mtp_transfer_param *mtp, struct msgb *sccp_msg)
 Traffic STP -> AS -> ASP (Tx path) Loadshare towards the TCAP routing AS.
int tcap_as_select_asp_loadshare (struct osmo_ss7_asp **asp, struct osmo_ss7_as *as, const struct xua_msg *xua)
 Entrypoint for M3UA messages towards the TCAP nodes.
struct ipa_tcap_routing_hdr __attribute__ ((packed))
static struct msgb * ipa_tcap_routing_alloc (uint32_t seq_nr, uint8_t mt)
static int ipa_tx_tcap_routing_ack (struct osmo_ss7_asp *asp, uint32_t seq_nr)
static int ipa_tx_tcap_routing_nack (struct osmo_ss7_asp *asp, uint32_t seq_nr, uint8_t err_code)
int ipa_rx_msg_osmo_ext_tcap_routing (struct osmo_ss7_asp *asp, struct msgb *msg)
 Entrypoint for IPA TCAP Routing messages, parses and handles those.
static void tcap_range_as_update_pc_ssn (struct osmo_ss7_as *as)
struct tcap_range * tcap_range_alloc (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp, uint32_t tid_start, uint32_t tid_end, uint32_t pc, uint8_t ssn)
 Create and alloc a new TCAP range entry.
void tcap_range_free (struct tcap_range *tcrng)
 Remove and free a single TCAP range entry.
bool tcap_range_matches (const struct tcap_range *tcrng, uint32_t tid)
 Checks if a tid matches to a specific range.
bool tcap_range_overlaps (const struct tcap_range *a, uint32_t tid_start, uint32_t tid_end)
 Checks if a tid rnage overlaps with another range.
static void _tcap_range_asp_down (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
void tcap_as_del_asp (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
void tcap_enable (struct osmo_ss7_as *as)
void tcap_disable (struct osmo_ss7_as *as)

Variables

uint8_t mt
uint32_t seq
uint8_t data [0]
uint32_t tid_start
uint32_t tid_end
uint32_t pc
uint8_t ssn
uint8_t err

Macro Definition Documentation

◆ DTID_SET

#define DTID_SET   1 << 1

◆ OTID_SET

#define OTID_SET   1 << 0

Enumeration Type Documentation

◆ ipa_tcap_routing_msg_types

Enumerator
MT_TID_ADD_RANGE 
MT_TID_ACK 
MT_TID_NACK 

◆ ipa_tcap_routing_nack_error

Enumerator
NACK_ERR_SYS_FAILURE 
NACK_ERR_EALREADY 

Function Documentation

◆ __attribute__()

◆ _tcap_range_asp_down()

void _tcap_range_asp_down ( struct osmo_ss7_as * as,
struct osmo_ss7_asp * asp )
static

◆ asp_loadshare_tcap_handle_unroutable()

int asp_loadshare_tcap_handle_unroutable ( struct osmo_ss7_asp ** rasp,
struct osmo_ss7_as * as,
const struct osmo_mtp_transfer_param * mtp,
const struct msgb * sccp_msg )
static

When a TCAP MSU from an ongoing session (TCAP != Begin) could not be routed either by the TCAP session tracking or by the TID range, such messages will be passed to this function.

Parameters
[out]raspthe new ASP where the TCAP MSU should be send out (can be NULL)
[in]asthe AS to which this MSU was routed to
[in]mtp
[in]sccp_msg
Returns
0 on success and asp is set, < 0 on error, > 0 when message is routed elsewhere

References asp_loadshare_tcap_route_fallback(), osmo_ss7_as::cfg, osmo_ss7_as::loadshare, NULL, select_asp_tcap_enabled_rr(), SS7_AS_TCAP_UNROUTABLE_LOAD_SHARE_AS, SS7_AS_TCAP_UNROUTABLE_REJECT_UDTS, and SS7_AS_TCAP_UNROUTABLE_ROUTE_FALLBACK.

Referenced by asp_loadshare_tcap_sccp().

◆ asp_loadshare_tcap_route_fallback()

int asp_loadshare_tcap_route_fallback ( struct osmo_ss7_as * as,
const struct osmo_mtp_transfer_param * orig_mtp,
const struct msgb * sccp_msg )
static

When a TCAP message can't be routed by TID or session cache and unroutable_tcap_msg == SS7_AS_TCPA_UNROUTABLE_ROUTE_FALLBACK, route to a different DPC.

Parameters
[in]as
[in]mtpMTP routing information
[in]sccp_msgthe SCCP message.
Returns
0 on success or -ENOKEY

References osmo_ss7_as::cfg, osmo_mtp_transfer_param::dpc, osmo_ss7_as::inst, osmo_ss7_as::loadshare, and mtp3_hmrt_mtp_xfer_request_l4_to_l3().

Referenced by asp_loadshare_tcap_handle_unroutable().

◆ asp_loadshare_tcap_sccp()

int asp_loadshare_tcap_sccp ( struct osmo_ss7_asp ** rasp,
struct osmo_ss7_as * as,
const struct osmo_mtp_transfer_param * mtp,
struct msgb * sccp_msg )
static

Traffic STP -> AS -> ASP (Tx path) Loadshare towards the TCAP routing AS.

Parameters
[out]raspthe selected ASP if any, can be NULL
[in]as
[in]opcthe OPC from MTP
[in]dpcthe DPC from MTP
[in]mtpMTP routing information
[in]sccp_msgthe SCCP message. Callee takes ownership.
Returns
0: on succcess (msg handled by the callee), -EPROTONOSUPPORT: let caller (regular loadsharing) handle those.

References tcap_trans_track_entry::asp, asp_loadshare_tcap_handle_unroutable(), osmo_ss7_as::ctrg, xua_msg_part::dat, tcap_parsed::dtid, DTID_SET, xua_msg::hdr, xua_msg_part::len, LOGPAS, xua_common_hdr::msg_class, xua_common_hdr::msg_type, NULL, OSMO_SCCP_ADDR_T_SSN, osmo_sccp_to_xua(), tcap_parsed::otid, OTID_SET, parse_tcap(), osmo_sccp_addr::presence, tcap_parsed::present, select_asp_tcap_enabled_rr(), send_back_udts(), osmo_sccp_addr::ssn, ssn_contains_tcap(), sua_addr_parse(), SUA_CL_CLDR, SUA_IEI_DATA, SUA_IEI_DEST_ADDR, SUA_IEI_SRC_ADDR, SUA_MSGC_CL, tcap_as_asp_find_by_tcap_id(), tcap_trans_track_begin(), tcap_trans_track_continue(), tcap_trans_track_end(), tcap_trans_track_entry_create(), tcap_trans_track_entry_find(), xua_msg_find_tag(), and xua_msg_free().

Referenced by __attribute__().

◆ ipa_rx_msg_osmo_ext_tcap_routing()

◆ ipa_tcap_routing_alloc()

struct msgb * ipa_tcap_routing_alloc ( uint32_t seq_nr,
uint8_t mt )
static

References mt, and NULL.

Referenced by ipa_tx_tcap_routing_ack(), and ipa_tx_tcap_routing_nack().

◆ ipa_tx_tcap_routing_ack()

int ipa_tx_tcap_routing_ack ( struct osmo_ss7_asp * asp,
uint32_t seq_nr )
static

◆ ipa_tx_tcap_routing_nack()

int ipa_tx_tcap_routing_nack ( struct osmo_ss7_asp * asp,
uint32_t seq_nr,
uint8_t err_code )
static

◆ parse_tcap()

int parse_tcap ( struct osmo_ss7_as * as,
const uint8_t * data,
size_t len,
struct tcap_parsed * ids )
static

◆ select_asp_tcap_enabled_rr()

◆ send_back_udts()

int send_back_udts ( struct osmo_ss7_as * as,
const struct osmo_mtp_transfer_param * orig_mtp,
const struct xua_msg * orig_sua,
uint8_t cause_code )
static

Send UDTS to indicate that the originating UDT could not be delivered to its destination.

Parameters
as
orig_mtpMTP routing information of the originating message (message that could not be delivered)
orig_suaOriginating message that could not be delivered
cause_codethe return cause of the UDTS
Returns
0 on success, negative on error

References osmo_mtp_transfer_param::dpc, osmo_ss7_as::inst, LOGPAS, mtp3_hmrt_mtp_xfer_request_l4_to_l3(), osmo_mtp_transfer_param::opc, osmo_sua_to_sccp(), sua_gen_cldr(), SUA_IEI_PROTO_CLASS, SUA_IEI_ROUTE_CTX, xua_dialect_sua, xua_msg_dump(), xua_msg_find_tag(), xua_msg_free(), xua_msg_get_u32p(), and xua_msg_part_get_u32().

Referenced by asp_loadshare_tcap_sccp().

◆ ssn_contains_tcap()

◆ tcap_as_asp_find_by_tcap_id()

struct osmo_ss7_asp * tcap_as_asp_find_by_tcap_id ( struct osmo_ss7_as * as,
struct osmo_sccp_addr * calling_addr,
struct osmo_sccp_addr * called_addr,
uint32_t otid )

◆ tcap_as_del_asp()

◆ tcap_as_rx_sccp_asp()

int tcap_as_rx_sccp_asp ( struct osmo_ss7_as * as,
struct osmo_ss7_asp * asp,
uint32_t opc,
uint32_t dpc,
struct msgb * sccp_msg )

Traffic from the TCAP ASP -> AS -> osmo-stp, only used to update transaction tracking.

Parameters
as
aspasp sent the sccp_msg message towards osmo-stp
opcM3UA opc
dpcM3UA DPC
sccp_msgpointer to a msg.
Returns
0 on successful handling (TCAP fully processed, non-TCAP ignored), < 0 on error cases (missing IE, decoding errors)

References xua_msg_part::dat, dpc, tcap_parsed::dtid, DTID_SET, xua_msg::hdr, xua_msg_part::len, LOGPAS, xua_common_hdr::msg_class, NULL, opc, osmo_sccp_to_xua(), tcap_parsed::otid, OTID_SET, parse_tcap(), tcap_parsed::present, osmo_sccp_addr::ssn, ssn_contains_tcap(), sua_addr_parse(), SUA_CL_CLDT, SUA_IEI_DATA, SUA_IEI_DEST_ADDR, SUA_IEI_SRC_ADDR, SUA_MSGC_CL, tcap_trans_track_begin(), tcap_trans_track_continue(), tcap_trans_track_end(), xua_msg_find_tag(), and xua_msg_free().

Referenced by ipa_rx_msg_up().

◆ tcap_as_select_asp_loadshare()

int tcap_as_select_asp_loadshare ( struct osmo_ss7_asp ** asp,
struct osmo_ss7_as * as,
const struct xua_msg * xua )

Entrypoint for M3UA messages towards the TCAP nodes.

Parameters
[out]aspResult pointer of the selected asp. Set to NULL if return code is != 0
[in]as
[in]xua
Returns
0: on succcess (msg handled by the callee), -EPROTONOSUPPORT: let caller (regular loadsharing) handle those.

Referenced by ss7_as_select_asp().

◆ tcap_disable()

◆ tcap_enable()

◆ tcap_gen_hash()

uint32_t tcap_gen_hash ( uint32_t pc,
uint8_t ssn )
inlinestatic

◆ tcap_gen_hash_addr()

uint64_t tcap_gen_hash_addr ( const struct osmo_sccp_addr * addr)
inlinestatic

◆ tcap_hlist_get()

struct osmo_ss7_asp * tcap_hlist_get ( const struct osmo_ss7_as * as,
uint32_t pc,
uint8_t ssn,
uint32_t tid )
static

◆ tcap_id_from_octet_str()

int tcap_id_from_octet_str ( uint32_t * tid,
const OCTET_STRING_t * src )
static

References load_24be().

Referenced by parse_tcap().

◆ tcap_overlap_tid()

struct tcap_range * tcap_overlap_tid ( struct osmo_ss7_as * as,
uint32_t pc,
uint8_t ssn,
uint32_t tid_start,
uint32_t tid_end )
static

◆ tcap_range_alloc()

struct tcap_range * tcap_range_alloc ( struct osmo_ss7_as * as,
struct osmo_ss7_asp * asp,
uint32_t tid_start,
uint32_t tid_end,
uint32_t pc,
uint8_t ssn )

Create and alloc a new TCAP range entry.

Parameters
[in]as
[in]asp
[in]tid_start
[in]tid_end
[in]pc
[in]ssn
Returns
the TCAP range entry or NULL

References tcap_range::asp, tcap_range::list, NULL, pc, tcap_range::pc, ssn, tcap_range::ssn, tcap_gen_hash(), tcap_range::tid_end, tid_end, tcap_range::tid_start, and tid_start.

Referenced by ipa_rx_msg_osmo_ext_tcap_routing().

◆ tcap_range_as_update_pc_ssn()

void tcap_range_as_update_pc_ssn ( struct osmo_ss7_as * as)
static

◆ tcap_range_free()

void tcap_range_free ( struct tcap_range * tcrng)

Remove and free a single TCAP range entry.

Parameters
[in]tcrng

References tcap_range::list.

Referenced by _tcap_range_asp_down().

◆ tcap_range_matches()

bool tcap_range_matches ( const struct tcap_range * tcrng,
uint32_t tid )

Checks if a tid matches to a specific range.

Parameters
tcrng
tid
Returns
true if tid is included in the range

References tcap_range::tid_end, and tcap_range::tid_start.

Referenced by tcap_hlist_get(), and tcap_range_overlaps().

◆ tcap_range_overlaps()

bool tcap_range_overlaps ( const struct tcap_range * a,
uint32_t tid_start,
uint32_t tid_end )

Checks if a tid rnage overlaps with another range.

Parameters
a
tid_start
tid_end
Returns

References tcap_range_matches(), tcap_range::tid_end, tid_end, tcap_range::tid_start, and tid_start.

Referenced by tcap_overlap_tid().

Variable Documentation

◆ data

◆ err

◆ mt

uint8_t mt

Referenced by ipa_tcap_routing_alloc().

◆ pc

◆ seq

uint32_t seq

◆ ssn

◆ tid_end

uint32_t tid_end

◆ tid_start

uint32_t tid_start