libosmo-sigtran 2.0.0.50-b59d
Osmocom SIGTRAN library
osmo_ss7_route.c File Reference
#include <errno.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/sigtran/mtp_sap.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include "ss7_linkset.h"
#include "ss7_as.h"
#include "ss7_route.h"
#include "ss7_route_table.h"
#include "ss7_internal.h"

Functions

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...
 
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_routess7_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 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_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...
 
struct osmo_ss7_asosmo_ss7_route_get_dest_as (struct osmo_ss7_route *rt)
 Get destination AS of route. More...
 

Function Documentation

◆ count_leading_one_bits()

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

Referenced by u32_masklen().

◆ osmo_ss7_route_get_dest_as()

struct osmo_ss7_as * osmo_ss7_route_get_dest_as ( struct osmo_ss7_route rt)

Get destination AS of route.

Parameters
[in]rtRoute entry holding the AS destination
Returns
pointer to Application Server on success; NULL if rt doesn't route to an AS (i.e. routes to a linkset).

References osmo_ss7_route::as, and osmo_ss7_route::dest.

◆ 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_instance::rtable_system, ss7_initialized, and ss7_route_table_find_route_by_dpc().

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

◆ osmo_ss7_route_print()

◆ route_insert_sorted()

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

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

◆ ss7_route_create()

struct osmo_ss7_route * 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::linkset_name, osmo_ss7_route::mask, osmo_ss7_route::pc, ss7_route_alloc(), ss7_route_insert(), ss7_route_set_linkset(), and ss7_route_table_find_route_by_dpc_mask().

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

◆ ss7_route_destroy()

◆ 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::pc, route_insert_sorted(), osmo_ss7_route::rtable, ss7_route_inserted(), and ss7_route_table_find_route_by_dpc_mask().

Referenced by DEFUN_ATTR(), and 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 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 
)

◆ u32_masklen()

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