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_instance * | ss7_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_fmt * | osmo_ss7_instance_get_pc_fmt (const struct osmo_ss7_instance *inst)
struct osmo_sccp_instance * | osmo_ss7_ensure_sccp (struct osmo_ss7_instance *inst)
| Allocate an SCCP instance, if not present yet.
struct osmo_sccp_instance * | osmo_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_as * | osmo_ss7_as_find_by_name (struct osmo_ss7_instance *inst, const char *name)
| Find Application Server by given name.
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.
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.
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.
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.
struct osmo_ss7_asp * | osmo_ss7_asp_find_by_name (struct osmo_ss7_instance *inst, const char *name)
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).
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)
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_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_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)
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

References osmo_ss7_pc_fmt::component_len, osmo_ss7_pc_fmt::delimiter, MAX_PC_STR_LEN, and strnappendchar().

Referenced by osmo_ss7_pointcode_parse(), and osmo_ss7_pointcode_print_buf().

## get_pc_comp_shift()

unsigned int get_pc_comp_shift | ( | const struct osmo_ss7_pc_fmt * | pc_fmt,
|  | unsigned int | comp_num )

static

References osmo_ss7_pc_fmt::component_len, and osmo_ss7_pc_width().

Referenced by osmo_ss7_pointcode_parse(), and pc_comp_shift_and_mask().

## num_pc_comp_exp()

unsigned int num_pc_comp_exp | ( | const struct osmo_ss7_pc_fmt * | pc_fmt | ) |

static

References osmo_ss7_pc_fmt::component_len.

Referenced by osmo_ss7_pointcode_parse(), and osmo_ss7_pointcode_print_buf().

## 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] | inst | SS7 Instance on which we operate
  [in] | l_rk_id | Local 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] | inst | SS7 Instance on which we operate
  [in] | name | Name 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] | inst | SS7 Instance on which we operate
  [in] | proto | Protocol 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] | inst | SS7 Instance on which we operate
  [in] | rctx | Routing 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] | inst | SS7 Instance on which we operate
  [in] | name | Name of Application Server
  [in] | proto | Protocol 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 )

References osmo_ss7_asp::inst, osmo_ss7_asp::name, osmo_ss7_asp_find2(), osmo_ss7_asp::proto, ss7_default_trans_proto_for_asp_proto(), and osmo_ss7_asp::trans_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 )

References osmo_ss7_asp::cfg, osmo_ss7_asp::inst, osmo_ss7_asp::local, osmo_ss7_asp::name, osmo_ss7_asp_find_by_name(), osmo_ss7_asp_peer::port, osmo_ss7_asp::proto, osmo_ss7_asp::remote, ss7_initialized, and osmo_ss7_asp::trans_proto.

Referenced by DEFUN_ATTR(), and osmo_ss7_asp_find().

## osmo_ss7_asp_find_by_name()

struct osmo_ss7_asp * osmo_ss7_asp_find_by_name | ( | struct osmo_ss7_instance * | inst,
|  | const char * | name )

References osmo_ss7_instance::asp_list, osmo_ss7_asp::cfg, osmo_ss7_asp::inst, osmo_ss7_asp::list, osmo_ss7_asp::name, and ss7_initialized.

Referenced by DEFUN(), DEFUN_ATTR(), osmo_ss7_as_add_asp(), osmo_ss7_as_del_asp(), osmo_ss7_asp_find2(), osmo_ss7_asp_find_or_create2(), show_asp(), show_asp_assoc_status(), and show_asp_remaddr().

## 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] | as | Application Server in which to look for asp
  [in] | proto | ASP 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 )

References osmo_ss7_asp::inst, osmo_ss7_asp::name, osmo_ss7_asp_find_or_create2(), osmo_ss7_asp::proto, ss7_default_trans_proto_for_asp_proto(), and osmo_ss7_asp::trans_proto.

## osmo_ss7_asp_find_or_create2()

struct osmo_ss7_asp * osmo_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 )

References osmo_ss7_asp::cfg, osmo_ss7_asp::inst, osmo_ss7_asp::local, osmo_ss7_asp::name, osmo_ss7_asp_find_by_name(), osmo_ss7_asp_peer::port, osmo_ss7_asp::proto, osmo_ss7_asp::remote, ss7_asp_alloc(), ss7_initialized, and osmo_ss7_asp::trans_proto.

Referenced by DEFUN_ATTR(), osmo_sccp_simple_client_on_ss7_id(), osmo_sccp_simple_server_add_clnt(), osmo_ss7_asp_find_or_create(), and xua_accept_cb().

## osmo_ss7_ensure_sccp()

struct osmo_sccp_instance * osmo_ss7_ensure_sccp | ( | struct osmo_ss7_instance * | inst | ) |

Allocate an SCCP instance, if not present yet.

Returns
  inst->sccp.

References LOGSS7, osmo_sccp_instance_create(), and osmo_ss7_instance::sccp.

Referenced by DEFUN_ATTR(), DEFUN_ATTR(), osmo_sccp_simple_client_on_ss7_id(), osmo_sccp_simple_server_on_ss7_id(), ss7_asp_alloc(), and ss7_xua_server_create2().

## 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] | inst | SS7 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()

void osmo_ss7_instance_destroy | ( | struct osmo_ss7_instance * | inst | ) |

Destroy a SS7 Instance.

Parameters

  [in] | inst | SS7 Instance to be destroyed

References osmo_ss7_instance::as_list, osmo_ss7_instance::asp_list, osmo_ss7_asp::inst, osmo_ss7_instance::linksets, osmo_ss7_asp::list, osmo_ss7_instance::list, LOGSS7, osmo_ss7_as_destroy(), osmo_ss7_asp_destroy(), ss7_initialized, and ss7_linkset_destroy().

Referenced by osmo_sccp_simple_client_on_ss7_id(), and osmo_sccp_simple_server_on_ss7_id().

## osmo_ss7_instance_get_id()

uint32_t osmo_ss7_instance_get_id | ( | const struct osmo_ss7_instance * | inst | ) |

References osmo_ss7_instance::cfg, osmo_ss7_instance::id, and osmo_ss7_asp::inst.

## osmo_ss7_instance_get_name()

const char * osmo_ss7_instance_get_name | ( | const struct osmo_ss7_instance * | inst | ) |

References osmo_ss7_instance::cfg, osmo_ss7_asp::inst, and osmo_ss7_instance::name.

## osmo_ss7_instance_get_pc_fmt()

const struct osmo_ss7_pc_fmt * osmo_ss7_instance_get_pc_fmt | ( | const struct osmo_ss7_instance * | inst | ) |

References osmo_ss7_instance::cfg, and osmo_ss7_instance::pc_fmt.

## osmo_ss7_instance_get_primary_pc()

uint32_t osmo_ss7_instance_get_primary_pc | ( | const struct osmo_ss7_instance * | inst | ) |

References osmo_ss7_instance::cfg, osmo_ss7_asp::inst, and osmo_ss7_instance::primary_pc.

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

bool osmo_ss7_pc_is_local | ( | const struct osmo_ss7_instance * | inst,
|  | uint32_t | pc )

References osmo_ss7_instance::cfg, osmo_ss7_pc_is_valid(), osmo_ss7_instance::primary_pc, osmo_ss7_instance::secondary_pc, and ss7_initialized.

Referenced by m3ua_hmdc_rx_from_l2(), sccp_sclc_rx_scrc_rout_fail(), scrc_local_out_common(), and scrc_translate_node_9().

## osmo_ss7_pointcode_parse()

int osmo_ss7_pointcode_parse | ( | const struct osmo_ss7_instance * | inst,
|  | const char * | str )

References osmo_ss7_instance::cfg, osmo_ss7_pc_fmt::component_len, default_pc_fmt, gen_pc_fmtstr(), get_pc_comp_shift(), LOGSS7, num_pc_comp_exp(), and osmo_ss7_instance::pc_fmt.

Referenced by _rout_key(), DEFUN_ATTR(), DEFUN_ATTR(), DEFUN_ATTR(), DEFUN_ATTR(), DEFUN_ATTR(), DEFUN_ATTR(), and osmo_ss7_pointcode_parse_mask_or_len().

## osmo_ss7_pointcode_parse_mask_or_len()

int osmo_ss7_pointcode_parse_mask_or_len | ( | const struct osmo_ss7_instance * | inst,
|  | const char * | in )

References osmo_ss7_instance::cfg, default_pc_fmt, osmo_ss7_pc_width(), osmo_ss7_pointcode_parse(), and osmo_ss7_instance::pc_fmt.

Referenced by DEFUN_ATTR(), and DEFUN_ATTR().

## osmo_ss7_pointcode_print()

const char * osmo_ss7_pointcode_print | ( | const struct osmo_ss7_instance * | inst,
|  | uint32_t | pc )

References MAX_PC_STR_LEN, and osmo_ss7_pointcode_print_buf().

Referenced by DEFUN(), DEFUN(), format_affected_pcs_c(), handle_rkey_dereg(), handle_rkey_reg(), hmrt_message_for_routing(), ipa_del_route(), m3ua_hmdc_rx_from_l2(), m3ua_rx_xfer(), osmo_sccp_simple_client_on_ss7_id(), osmo_sccp_user_unbind(), osmo_ss7_route_name(), osmo_ss7_route_print(), sccp_addr_to_str_buf(), sccp_scoc_rx_inval_opc(), sccp_user_bind_pc(), scrc_node_6(), show_user(), ss7_route_destroy(), ss7_route_insert(), ss7_route_set_linkset(), vty_show_connection(), write_one_as(), write_one_cs7(), write_one_rtable(), write_sccp_addressbook(), and xua_snm_rx_dupu().

## osmo_ss7_pointcode_print2()

const char * osmo_ss7_pointcode_print2 | ( | const struct osmo_ss7_instance * | inst,
|  | uint32_t | pc )

References MAX_PC_STR_LEN, and osmo_ss7_pointcode_print_buf().

Referenced by m3ua_rx_xfer(), osmo_ss7_route_name(), osmo_ss7_route_print(), sccp_scoc_rx_inval_opc(), and write_one_rtable().

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

References osmo_ss7_instance::cfg, default_pc_fmt, gen_pc_fmtstr(), len, num_pc_comp_exp(), osmo_ss7_pc_is_valid(), pc_comp_shift_and_mask(), and osmo_ss7_instance::pc_fmt.

Referenced by osmo_ss7_pointcode_print(), and osmo_ss7_pointcode_print2().

## 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

References osmo_ss7_pc_fmt::component_len, and get_pc_comp_shift().

Referenced by osmo_ss7_pointcode_print_buf().

## ss7_find_free_l_rk_id()

uint32_t ss7_find_free_l_rk_id | ( | struct osmo_ss7_instance * | inst | ) |

References next_l_rk_id, and osmo_ss7_as_find_by_l_rk_id().

Referenced by ss7_as_alloc().

## ss7_instance_alloc()

struct osmo_ss7_instance * ss7_instance_alloc | ( | void * | ctx,
|  | uint32_t | id )

References osmo_ss7_instance::as_list, osmo_ss7_instance::asp_list, osmo_ss7_instance::cfg, osmo_ss7_pc_fmt::component_len, osmo_ss7_pc_fmt::delimiter, osmo_ss7_instance::id, osmo_ss7_instance::linksets, osmo_ss7_instance::list, LOGSS7, osmo_ss7_instances, OSMO_SS7_PC_INVALID, osmo_ss7_instance::pc_fmt, osmo_ss7_instance::primary_pc, osmo_ss7_instance::rtable_list, osmo_ss7_instance::rtable_system, osmo_ss7_instance::sccp_address_book, osmo_ss7_instance::secondary_pc, ss7_route_table_find_or_create(), and osmo_ss7_instance::xua_servers.

Referenced by osmo_ss7_instance_find_or_create().

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