osmo_ss7: Allocate local routing key ID and use it as lookup key for AS
In M3UA RKM we need a "Local Routing Key ID" which uniquely identifies a given routing key locally at the node. Allocate this value and store it in each osmo_ss7_as, as well as add a lookup function for it. Change-Id: I89a0abcf66228ce092126a497cc7971df3a6af71
This commit is contained in:
parent
282d1c2ffa
commit
47d05fae4f
|
@ -225,6 +225,7 @@ void osmo_ss7_route_destroy(struct osmo_ss7_route *rt);
|
|||
|
||||
struct osmo_ss7_routing_key {
|
||||
uint32_t context;
|
||||
uint32_t l_rk_id;
|
||||
|
||||
uint32_t pc;
|
||||
uint8_t si;
|
||||
|
@ -291,6 +292,8 @@ osmo_ss7_as_find_by_name(struct osmo_ss7_instance *inst, const char *name);
|
|||
struct osmo_ss7_as *
|
||||
osmo_ss7_as_find_by_rctx(struct osmo_ss7_instance *inst, uint32_t rctx);
|
||||
struct osmo_ss7_as *
|
||||
osmo_ss7_as_find_by_l_rk_id(struct osmo_ss7_instance *inst, uint32_t l_rk_id);
|
||||
struct osmo_ss7_as *
|
||||
osmo_ss7_as_find_or_create(struct osmo_ss7_instance *inst, const char *name,
|
||||
enum osmo_ss7_asp_protocol proto);
|
||||
int osmo_ss7_as_add_asp(struct osmo_ss7_as *as, const char *asp_name);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <osmocom/core/prim.h>
|
||||
#include <osmocom/sigtran/osmo_ss7.h>
|
||||
|
||||
|
||||
enum osmo_sigtran_sap {
|
||||
|
@ -46,6 +47,16 @@ struct osmo_xlm_prim_error {
|
|||
uint32_t code;
|
||||
};
|
||||
|
||||
struct osmo_xlm_prim_rk_reg {
|
||||
/* routing key */
|
||||
struct osmo_ss7_routing_key key;
|
||||
enum osmo_ss7_as_traffic_mode traf_mode;
|
||||
};
|
||||
|
||||
struct osmo_xlm_prim_rk_dereg {
|
||||
uint32_t route_ctx;
|
||||
};
|
||||
|
||||
struct osmo_xlm_prim {
|
||||
struct osmo_prim_hdr oph;
|
||||
union {
|
||||
|
|
|
@ -54,6 +54,7 @@ static bool ss7_initialized = false;
|
|||
static LLIST_HEAD(ss7_instances);
|
||||
static LLIST_HEAD(ss7_xua_servers);
|
||||
static int32_t next_rctx = 1;
|
||||
static int32_t next_l_rk_id = 1;
|
||||
|
||||
struct value_string osmo_ss7_as_traffic_mode_vals[] = {
|
||||
{ OSMO_SS7_AS_TMOD_BCAST, "broadcast" },
|
||||
|
@ -84,6 +85,18 @@ int osmo_ss7_find_free_rctx(struct osmo_ss7_instance *inst)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static uint32_t find_free_l_rk_id(struct osmo_ss7_instance *inst)
|
||||
{
|
||||
uint32_t l_rk_id;
|
||||
|
||||
for (l_rk_id = next_l_rk_id; next_l_rk_id; l_rk_id = ++next_l_rk_id) {
|
||||
if (!osmo_ss7_as_find_by_l_rk_id(inst, next_l_rk_id))
|
||||
return l_rk_id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SS7 Point Code Parsing / Printing
|
||||
***********************************************************************/
|
||||
|
@ -765,6 +778,23 @@ osmo_ss7_as_find_by_rctx(struct osmo_ss7_instance *inst, uint32_t rctx)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*! \brief Find Application Server by given local routing key ID
|
||||
* \param[in] inst SS7 Instance on which we operate
|
||||
* \param[in] l_rk_id Local Routing Key ID
|
||||
* \returns pointer to Application Server on success; NULL otherwise */
|
||||
struct osmo_ss7_as *
|
||||
osmo_ss7_as_find_by_l_rk_id(struct osmo_ss7_instance *inst, uint32_t l_rk_id)
|
||||
{
|
||||
struct osmo_ss7_as *as;
|
||||
|
||||
OSMO_ASSERT(ss7_initialized);
|
||||
llist_for_each_entry(as, &inst->as_list, list) {
|
||||
if (as->cfg.routing_key.l_rk_id == l_rk_id)
|
||||
return as;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*! \brief Find or Create Application Server
|
||||
* \param[in] inst SS7 Instance on which we operate
|
||||
* \param[in] name Name of Application Server
|
||||
|
@ -792,6 +822,7 @@ osmo_ss7_as_find_or_create(struct osmo_ss7_instance *inst, const char *name,
|
|||
as->cfg.proto = proto;
|
||||
as->cfg.mode = OSMO_SS7_AS_TMOD_LOADSHARE;
|
||||
as->cfg.recovery_timeout_msec = 2000;
|
||||
as->cfg.routing_key.l_rk_id = find_free_l_rk_id(inst);
|
||||
as->fi = xua_as_fsm_start(as, LOGL_DEBUG);
|
||||
llist_add_tail(&as->list, &inst->as_list);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue