libosmo-sigtran 2.2.1.56-7580 Osmocom SIGTRAN library

Macros | Functions | Variables
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_combined_linkset.h"`
`#include "ss7_linkset.h"`
`#include "ss7_as.h"`
`#include "ss7_asp.h"`
`#include "ss7_route.h"`
`#include "ss7_route_table.h"`
`#include "ss7_internal.h"`

## Macros
#define | APPEND(fmt, args ...)

## Functions
struct osmo_ss7_route * | ss7_route_alloc (struct osmo_ss7_route_table *rtbl, uint32_t pc, uint32_t mask, bool dynamic)
| 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...
int | ss7_route_insert (struct osmo_ss7_route *rt)
| Insert route into its routing table. More...
struct osmo_ss7_route * | ss7_route_create (struct osmo_ss7_route_table *rtbl, uint32_t pc, uint32_t mask, bool dynamic, 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)
const char * | osmo_ss7_route_name (struct osmo_ss7_route *rt, bool list_asps)
| Return human readable representation of the route, in a static buffer. More...
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. More...
struct osmo_ss7_as * | osmo_ss7_route_get_dest_as (struct osmo_ss7_route *rt)
| Get destination AS of route. More...
bool | ss7_route_is_available (const struct osmo_ss7_route *rt)
bool | ss7_route_dest_is_available (const struct osmo_ss7_route *rt)
bool | ss7_route_is_fully_qualified (const struct osmo_ss7_route *rt)
void | ss7_route_update_route_status (struct osmo_ss7_route *rt, enum osmo_ss7_route_status status)

## Variables
const struct value_string | ss7_route_status_names []

## Macro Definition Documentation

## ◆ APPEND

#define APPEND | ( |  | fmt,
|  |  | args ...
| ) |  |

Value:
do { \
l = snprintf(pos, sizeof(buf) - (pos - buf), fmt, ## args); \
pos += l; \
if (pos - buf >= sizeof(buf)) \
goto out; \
} while (0)

## 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] | rt | Route 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.

NOTE: DEPRECATED, use ss7_instance_lookup_route() instead

References dpc, osmo_ss7_route_label::opc, ss7_initialized, and ss7_instance_lookup_route().

## ◆ osmo_ss7_route_name()

const char * osmo_ss7_route_name | ( | struct osmo_ss7_route * | rt,
|  | bool | list_asps
| ) |  |

Return human readable representation of the route, in a static buffer.

This uses both osmo_ss7_pointcode_print() and osmo_ss7_pointcode_print2(), so pairing osmo_ss7_route_name() with osmo_ss7_pointcode_print() in the same printf statement is likely to conflict.

Parameters

  [in] | rt | The route information to print, or NULL.
  [in] | list_asps | If true, append info for all ASPs for the route's AS.

Returns
  A string constant or static buffer.

References APPEND, ss7_as_asp_assoc::as, osmo_ss7_route::as, ss7_as_asp_assoc::as_entry, ss7_as_asp_assoc::asp, osmo_ss7_as::assoc_asp_list, osmo_ss7_as::cfg, osmo_ss7_asp::cfg, osmo_ss7_linkset::cfg, osmo_ss7_route::cfg, osmo_ss7_route::dest, osmo_ss7_route::dyn_allocated, osmo_ss7_route_table::inst, osmo_ss7_route::linkset, osmo_ss7_route::mask, MAX_PC_STR_LEN, osmo_ss7_as::name, osmo_ss7_asp::name, osmo_ss7_linkset::name, osmo_ss7_asp_protocol_name(), osmo_ss7_pointcode_print_buf(), osmo_ss7_route::pc, osmo_ss7_route::priority, osmo_ss7_as::proto, osmo_ss7_route::rtable, and osmo_ss7_asp::sock_name.

Referenced by DEFUN(), mtp3_hmrt_message_for_routing(), ss7_route_destroy(), and ss7_route_set_linkset().

## ◆ osmo_ss7_route_print()

const char * osmo_ss7_route_print | ( | const struct osmo_ss7_route * | rt | ) |

References osmo_ss7_instance::cfg, osmo_ss7_route::cfg, osmo_ss7_route_table::inst, osmo_ss7_route::mask, MAX_PC_STR_LEN, osmo_ss7_pc_width(), osmo_ss7_pointcode_print_buf(), osmo_ss7_route::pc, osmo_ss7_instance::pc_fmt, osmo_ss7_route::rtable, and u32_masklen().

Referenced by vty_dump_rtable().

## ◆ ss7_route_alloc()

struct osmo_ss7_route * ss7_route_alloc | ( | struct osmo_ss7_route_table * | rtbl,
|  | uint32_t | pc,
|  | uint32_t | mask,
|  | bool | dynamic
| ) |  |

Allocate a route entry.

Parameters

  [in] | rtbl | Routing Table where the route belongs
  [in] | pc | Point Code of the destination of the route
  [in] | mask | Mask of the destination Point Code pc
  [in] | dynamic | Whether the route is dynamic

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.

Dynamic routes are not configured by the user (VTY), and hence cannot be removed by the user. Dynamic routes are not stored in the config and hence they don't show up in eg "show running-config"; they can be listed using specific VTY commands like "show cs7 instance 0 route".

References osmo_ss7_instance::cfg, osmo_ss7_route::cfg, osmo_ss7_route::dyn_allocated, osmo_ss7_route_table::inst, osmo_ss7_route::list, osmo_ss7_route::mask, NULL, osmo_ss7_pc_normalize(), OSMO_SS7_ROUTE_PRIO_DEFAULT, OSMO_SS7_ROUTE_STATUS_AVAILABLE, osmo_ss7_route::pc, pc, osmo_ss7_instance::pc_fmt, osmo_ss7_route::priority, osmo_ss7_route::rtable, ss7_initialized, and osmo_ss7_route::status.

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,
|  | bool | dynamic,
|  | const char * | linkset_name
| ) |  |

Create a new route in the given routing table.

Parameters

  [in] | rtbl | Routing Table in which the route is to be created
  [in] | pc | Point Code of the destination of the route
  [in] | mask | Mask of the destination Point Code pc
  [in] | dynamic | Whether the route is dynamic
  [in] | linkset_name | string 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, NULL, pc, ss7_route_alloc(), ss7_route_insert(), ss7_route_set_linkset(), and ss7_route_table_find_route_by_dpc_mask().

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

## ◆ ss7_route_dest_is_available()

bool ss7_route_dest_is_available | ( | const struct osmo_ss7_route * | rt | ) |

References osmo_ss7_route::as, osmo_ss7_route::dest, osmo_ss7_route::linkset, osmo_ss7_as_active(), and ss7_linkset_is_available().

Referenced by ss7_route_is_available(), and vty_dump_rtable().

## ◆ ss7_route_destroy()

void ss7_route_destroy | ( | struct osmo_ss7_route * | rt | ) |

Destroy a given SS7 route.

References LOGPRT, osmo_ss7_route_name(), ss7_combined_linkset_del_route(), ss7_initialized, and ss7_route_inserted().

Referenced by DEFUN_ATTR(), handle_rkey_dereg(), osmo_sccp_simple_client_on_ss7_id(), osmo_sccp_simple_server_add_clnt(), ss7_route_table_del_routes_by_as(), and ss7_route_table_del_routes_by_linkset().

## ◆ ss7_route_insert()

int ss7_route_insert | ( | struct osmo_ss7_route * | rt | ) |

Insert route into its routing table.

Parameters

  [in] | rt | Route 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::clset, osmo_ss7_route::dyn_allocated, osmo_ss7_route::linkset_name, osmo_ss7_route::list, LOGPRT, osmo_ss7_route::mask, osmo_ss7_route::pc, osmo_ss7_route::priority, osmo_ss7_combined_linkset::routes, osmo_ss7_route::rtable, ss7_combined_linkset_add_route(), ss7_combined_linkset_alloc(), ss7_route_inserted(), and ss7_route_table_find_combined_linkset().

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

bool ss7_route_is_available | ( | const struct osmo_ss7_route * | rt | ) |

References OSMO_SS7_ROUTE_STATUS_AVAILABLE, ss7_route_dest_is_available(), and osmo_ss7_route::status.

Referenced by current_rt(), DEFUN(), ss7_combined_linkset_is_available(), ss7_combined_linkset_lookup_route(), ss7_combined_linkset_select_route_roundrobin(), ss7_route_table_dpc_is_accessible_skip_as(), and ss7_route_table_dpc_is_accessible_via_as().

## ◆ ss7_route_is_fully_qualified()

bool ss7_route_is_fully_qualified | ( | const struct osmo_ss7_route * | rt | ) |

References osmo_ss7_instance::cfg, osmo_ss7_route::cfg, osmo_ss7_route_table::inst, osmo_ss7_route::mask, osmo_ss7_instance::pc_fmt, osmo_ss7_route::rtable, and ss7_pc_full_mask().

Referenced by ss7_route_is_summary().

## ◆ ss7_route_set_linkset()

int ss7_route_set_linkset | ( | struct osmo_ss7_route * | rt,
|  | const char * | linkset_name
| ) |  |

Set linkset on route entry.

Parameters

  [in] | rt | Route to be configured
  [in] | linkset_name | string name of the linkset to be used

Returns
  0 on success, negative on error.

References osmo_ss7_route::as, osmo_ss7_route::cfg, osmo_ss7_route::dest, osmo_ss7_route_table::inst, osmo_ss7_route::linkset, osmo_ss7_route::linkset_name, LOGPRT, NULL, osmo_ss7_as_find_by_name(), osmo_ss7_route_name(), osmo_ss7_route::rtable, ss7_linkset_find_by_name(), and ss7_route_inserted().

Referenced by DEFUN_ATTR(), and ss7_route_create().

## ◆ ss7_route_update_route_status()

void ss7_route_update_route_status | ( | struct osmo_ss7_route * | rt,
|  | enum osmo_ss7_route_status | status
| ) |  |

References LOGPRT, ss7_route_status_name(), and osmo_ss7_route::status.

Referenced by ss7_route_table_update_route_status_by_as(), and xua_snm_srm_pc_available_single().

## ◆ u32_masklen()

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

References count_leading_one_bits(), and osmo_ss7_route::mask.

Referenced by osmo_ss7_route_print().

## Variable Documentation

## ◆ ss7_route_status_names

const struct value_string ss7_route_status_names[]

Initial value:
= {
{ OSMO_SS7_ROUTE_STATUS_UNAVAILABLE, "unavailable" },
{ OSMO_SS7_ROUTE_STATUS_AVAILABLE, "available" },
{ OSMO_SS7_ROUTE_STATUS_RESTRICTED, "restricted" },
{}
}
OSMO_SS7_ROUTE_STATUS_AVAILABLE
@ OSMO_SS7_ROUTE_STATUS_AVAILABLE
Definition: ss7_route.h:21
OSMO_SS7_ROUTE_STATUS_UNAVAILABLE
@ OSMO_SS7_ROUTE_STATUS_UNAVAILABLE
Definition: ss7_route.h:20
OSMO_SS7_ROUTE_STATUS_RESTRICTED
@ OSMO_SS7_ROUTE_STATUS_RESTRICTED
Definition: ss7_route.h:22

Referenced by ss7_route_status_name().