2017-04-03 15:37:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
|
|
|
#include <osmocom/core/utils.h>
|
|
|
|
#include <osmocom/core/fsm.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
|
|
#include <osmocom/core/prim.h>
|
2019-10-11 15:58:07 +00:00
|
|
|
#include <osmocom/core/socket.h>
|
2021-11-14 19:32:56 +00:00
|
|
|
#include <osmocom/core/rate_ctr.h>
|
2017-04-03 15:37:10 +00:00
|
|
|
|
2017-04-14 11:09:17 +00:00
|
|
|
extern struct llist_head osmo_ss7_instances;
|
2017-04-05 09:14:24 +00:00
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_instance;
|
|
|
|
struct osmo_ss7_user;
|
|
|
|
struct osmo_sccp_instance;
|
|
|
|
struct osmo_mtp_prim;
|
2017-04-07 12:48:08 +00:00
|
|
|
struct osmo_xua_layer_manager;
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
int osmo_ss7_init(void);
|
2017-04-05 15:33:00 +00:00
|
|
|
int osmo_ss7_find_free_rctx(struct osmo_ss7_instance *inst);
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc);
|
|
|
|
int osmo_ss7_pointcode_parse(struct osmo_ss7_instance *inst, const char *str);
|
|
|
|
int osmo_ss7_pointcode_parse_mask_or_len(struct osmo_ss7_instance *inst, const char *in);
|
2021-02-07 11:48:51 +00:00
|
|
|
const char *osmo_ss7_pointcode_print_buf(char *buf, size_t buf_len, const struct osmo_ss7_instance *inst, uint32_t pc);
|
2017-07-27 11:50:31 +00:00
|
|
|
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);
|
2017-04-03 15:37:10 +00:00
|
|
|
|
2017-07-26 15:31:53 +00:00
|
|
|
/* All known point-code formats have a length of or below 24 bit.
|
|
|
|
* A point-code value exceeding that is used to indicate an unset PC. */
|
|
|
|
#define OSMO_SS7_PC_INVALID 0xffffffff
|
|
|
|
static inline bool osmo_ss7_pc_is_valid(uint32_t pc)
|
|
|
|
{
|
|
|
|
return pc <= 0x00ffffff;
|
|
|
|
}
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Routing Tables
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct osmo_ss7_route_table {
|
|
|
|
/*! member in list of routing tables */
|
|
|
|
struct llist_head list;
|
|
|
|
/*! \ref osmo_ss7_instance to which we belong */
|
|
|
|
struct osmo_ss7_instance *inst;
|
|
|
|
/*! list of \ref osmo_ss7_route */
|
|
|
|
struct llist_head routes;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osmo_ss7_route_table *
|
|
|
|
osmo_ss7_route_table_find(struct osmo_ss7_instance *inst, const char *name);
|
|
|
|
struct osmo_ss7_route_table *
|
|
|
|
osmo_ss7_route_table_find_or_create(struct osmo_ss7_instance *inst, const char *name);
|
|
|
|
void osmo_ss7_route_table_destroy(struct osmo_ss7_route_table *rtbl);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Instances
|
|
|
|
***********************************************************************/
|
|
|
|
|
2017-04-09 09:51:58 +00:00
|
|
|
struct osmo_ss7_pc_fmt {
|
|
|
|
char delimiter;
|
|
|
|
uint8_t component_len[3];
|
|
|
|
};
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_instance {
|
|
|
|
/*! member of global list of instances */
|
|
|
|
struct llist_head list;
|
|
|
|
/*! list of \ref osmo_ss7_linkset */
|
|
|
|
struct llist_head linksets;
|
|
|
|
/*! list of \ref osmo_ss7_as */
|
|
|
|
struct llist_head as_list;
|
|
|
|
/*! list of \ref osmo_ss7_asp */
|
|
|
|
struct llist_head asp_list;
|
|
|
|
/*! list of \ref osmo_ss7_route_table */
|
|
|
|
struct llist_head rtable_list;
|
2017-04-14 20:16:53 +00:00
|
|
|
/*! list of \ref osmo_xua_servers */
|
|
|
|
struct llist_head xua_servers;
|
2017-04-03 15:37:10 +00:00
|
|
|
/* array for faster lookup of user (indexed by service
|
|
|
|
* indicator) */
|
|
|
|
const struct osmo_ss7_user *user[16];
|
|
|
|
|
|
|
|
struct osmo_ss7_route_table *rtable_system;
|
|
|
|
|
|
|
|
struct osmo_sccp_instance *sccp;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t id;
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
uint32_t primary_pc;
|
|
|
|
/* secondary PCs */
|
|
|
|
/* capability PCs */
|
|
|
|
uint8_t network_indicator;
|
2017-04-09 09:51:58 +00:00
|
|
|
struct osmo_ss7_pc_fmt pc_fmt;
|
2017-04-11 16:51:58 +00:00
|
|
|
bool permit_dyn_rkm_alloc;
|
2017-06-14 16:08:59 +00:00
|
|
|
struct llist_head sccp_address_book;
|
2017-04-03 15:37:10 +00:00
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osmo_ss7_instance *osmo_ss7_instance_find(uint32_t id);
|
|
|
|
struct osmo_ss7_instance *
|
|
|
|
osmo_ss7_instance_find_or_create(void *ctx, uint32_t id);
|
|
|
|
void osmo_ss7_instance_destroy(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);
|
|
|
|
|
2018-09-26 23:21:45 +00:00
|
|
|
struct osmo_sccp_instance *osmo_ss7_ensure_sccp(struct osmo_ss7_instance *inst);
|
|
|
|
|
2018-11-09 14:41:35 +00:00
|
|
|
uint8_t osmo_ss7_pc_width(const struct osmo_ss7_pc_fmt *pc_fmt);
|
2021-04-29 17:30:58 +00:00
|
|
|
uint32_t osmo_ss7_pc_normalize(const struct osmo_ss7_pc_fmt *pc_fmt, uint32_t pc);
|
2018-11-09 14:41:35 +00:00
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* MTP Users (Users of MTP, such as SCCP or ISUP)
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct osmo_ss7_user {
|
|
|
|
/* pointer back to SS7 instance */
|
|
|
|
struct osmo_ss7_instance *inst;
|
|
|
|
/* name of the user */
|
|
|
|
const char *name;
|
|
|
|
/* primitive call-back for incoming MTP primitives */
|
|
|
|
osmo_prim_cb prim_cb;
|
|
|
|
/* private data */
|
|
|
|
void *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
int osmo_ss7_user_register(struct osmo_ss7_instance *inst, uint8_t service_ind,
|
|
|
|
struct osmo_ss7_user *user);
|
|
|
|
|
|
|
|
int osmo_ss7_user_unregister(struct osmo_ss7_instance *inst, uint8_t service_ind,
|
|
|
|
struct osmo_ss7_user *user);
|
|
|
|
|
|
|
|
int osmo_ss7_mtp_to_user(struct osmo_ss7_instance *inst, struct osmo_mtp_prim *omp);
|
|
|
|
|
|
|
|
/* SS7 User wants to issue MTP-TRANSFER.req */
|
|
|
|
int osmo_ss7_user_mtp_xfer_req(struct osmo_ss7_instance *inst,
|
|
|
|
struct osmo_mtp_prim *omp);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Links
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
enum osmo_ss7_link_adm_state {
|
|
|
|
OSMO_SS7_LS_SHUTDOWN,
|
|
|
|
OSMO_SS7_LS_INHIBITED,
|
|
|
|
OSMO_SS7_LS_ENABLED,
|
|
|
|
_NUM_OSMO_SS7_LS
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osmo_ss7_linkset;
|
|
|
|
struct osmo_ss7_link;
|
|
|
|
|
|
|
|
struct osmo_ss7_link {
|
|
|
|
/*! \ref osmo_ss7_linkset to which we belong */
|
|
|
|
struct osmo_ss7_linkset *linkset;
|
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
uint32_t id;
|
|
|
|
|
|
|
|
enum osmo_ss7_link_adm_state adm_state;
|
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
void osmo_ss7_link_destroy(struct osmo_ss7_link *link);
|
|
|
|
struct osmo_ss7_link *
|
|
|
|
osmo_ss7_link_find_or_create(struct osmo_ss7_linkset *lset, uint32_t id);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Linksets
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct osmo_ss7_linkset {
|
|
|
|
struct llist_head list;
|
|
|
|
/*! \ref osmo_ss7_instance to which we belong */
|
|
|
|
struct osmo_ss7_instance *inst;
|
|
|
|
/*! array of \ref osmo_ss7_link */
|
|
|
|
struct osmo_ss7_link *links[16];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
uint32_t adjacent_pc;
|
|
|
|
uint32_t local_pc;
|
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
void osmo_ss7_linkset_destroy(struct osmo_ss7_linkset *lset);
|
|
|
|
struct osmo_ss7_linkset *
|
|
|
|
osmo_ss7_linkset_find_by_name(struct osmo_ss7_instance *inst, const char *name);
|
|
|
|
struct osmo_ss7_linkset *
|
|
|
|
osmo_ss7_linkset_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint32_t pc);
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Routes
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct osmo_ss7_route {
|
|
|
|
/*! member in \ref osmo_ss7_route_table.routes */
|
|
|
|
struct llist_head list;
|
|
|
|
/*! \ref osmo_ss7_route_table to which we belong */
|
|
|
|
struct osmo_ss7_route_table *rtable;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
/*! pointer to linkset (destination) of route */
|
|
|
|
struct osmo_ss7_linkset *linkset;
|
|
|
|
/*! pointer to Application Server */
|
|
|
|
struct osmo_ss7_as *as;
|
|
|
|
} dest;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
/* FIXME: presence? */
|
|
|
|
uint32_t pc;
|
|
|
|
uint32_t mask;
|
|
|
|
/*! human-specified linkset name */
|
|
|
|
char *linkset_name;
|
|
|
|
/*! lower priority is higher */
|
|
|
|
uint32_t priority;
|
|
|
|
uint8_t qos_class;
|
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osmo_ss7_route *
|
|
|
|
osmo_ss7_route_find_dpc(struct osmo_ss7_route_table *rtbl, uint32_t dpc);
|
|
|
|
struct osmo_ss7_route *
|
|
|
|
osmo_ss7_route_find_dpc_mask(struct osmo_ss7_route_table *rtbl, uint32_t dpc,
|
|
|
|
uint32_t mask);
|
|
|
|
struct osmo_ss7_route *
|
|
|
|
osmo_ss7_route_lookup(struct osmo_ss7_instance *inst, uint32_t dpc);
|
|
|
|
struct osmo_ss7_route *
|
|
|
|
osmo_ss7_route_create(struct osmo_ss7_route_table *rtbl, uint32_t dpc,
|
|
|
|
uint32_t mask, const char *linkset_name);
|
|
|
|
void osmo_ss7_route_destroy(struct osmo_ss7_route *rt);
|
2019-03-12 23:33:06 +00:00
|
|
|
const char *osmo_ss7_route_print(const struct osmo_ss7_route *rt);
|
2017-12-24 18:27:55 +00:00
|
|
|
const char *osmo_ss7_route_name(struct osmo_ss7_route *rt, bool list_asps);
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Application Servers
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct osmo_ss7_routing_key {
|
|
|
|
uint32_t context;
|
2017-04-10 20:34:20 +00:00
|
|
|
uint32_t l_rk_id;
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
uint32_t pc;
|
|
|
|
uint8_t si;
|
|
|
|
uint32_t ssn;
|
|
|
|
/* FIXME: more complex routing keys */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum osmo_ss7_as_traffic_mode {
|
2017-04-05 20:31:50 +00:00
|
|
|
OSMO_SS7_AS_TMOD_OVERRIDE = 0, /* default */
|
2017-04-03 15:37:10 +00:00
|
|
|
OSMO_SS7_AS_TMOD_BCAST,
|
|
|
|
OSMO_SS7_AS_TMOD_LOADSHARE,
|
|
|
|
OSMO_SS7_AS_TMOD_ROUNDROBIN,
|
|
|
|
_NUM_OSMO_SS7_ASP_TMOD
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct value_string osmo_ss7_as_traffic_mode_vals[];
|
|
|
|
|
|
|
|
static inline const char *
|
|
|
|
osmo_ss7_as_traffic_mode_name(enum osmo_ss7_as_traffic_mode mode)
|
|
|
|
{
|
|
|
|
return get_value_string(osmo_ss7_as_traffic_mode_vals, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
enum osmo_ss7_asp_protocol {
|
|
|
|
OSMO_SS7_ASP_PROT_NONE,
|
|
|
|
OSMO_SS7_ASP_PROT_SUA,
|
|
|
|
OSMO_SS7_ASP_PROT_M3UA,
|
2017-04-02 09:58:17 +00:00
|
|
|
OSMO_SS7_ASP_PROT_IPA,
|
2017-04-03 15:37:10 +00:00
|
|
|
_NUM_OSMO_SS7_ASP_PROT
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct value_string osmo_ss7_asp_protocol_vals[];
|
|
|
|
|
|
|
|
static inline const char *
|
|
|
|
osmo_ss7_asp_protocol_name(enum osmo_ss7_asp_protocol mode)
|
|
|
|
{
|
|
|
|
return get_value_string(osmo_ss7_asp_protocol_vals, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
int osmo_ss7_asp_protocol_port(enum osmo_ss7_asp_protocol prot);
|
|
|
|
|
2019-10-19 15:40:22 +00:00
|
|
|
enum osmo_ss7_as_patch_sccp_mode {
|
|
|
|
OSMO_SS7_PATCH_NONE, /* no patching of SCCP */
|
|
|
|
OSMO_SS7_PATCH_BOTH, /* patch both OPC and DPC into SCCP addresses */
|
|
|
|
};
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_as {
|
|
|
|
/*! entry in 'ref osmo_ss7_instance.as_list */
|
|
|
|
struct llist_head list;
|
|
|
|
struct osmo_ss7_instance *inst;
|
|
|
|
|
|
|
|
/*! AS FSM */
|
|
|
|
struct osmo_fsm_inst *fi;
|
|
|
|
|
2017-04-11 16:51:58 +00:00
|
|
|
/*! Were we dynamically allocated by RKM? */
|
|
|
|
bool rkm_dyn_allocated;
|
|
|
|
|
2018-10-29 18:25:34 +00:00
|
|
|
/*! Were we allocated by "simple client" support? */
|
|
|
|
bool simple_client_allocated;
|
|
|
|
|
2021-11-14 19:32:56 +00:00
|
|
|
/*! Rate Counter Group */
|
|
|
|
struct rate_ctr_group *ctrg;
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
enum osmo_ss7_asp_protocol proto;
|
|
|
|
struct osmo_ss7_routing_key routing_key;
|
|
|
|
enum osmo_ss7_as_traffic_mode mode;
|
2019-11-05 17:24:29 +00:00
|
|
|
/* traffic mode was configured by VTY / config file */
|
2019-10-16 14:27:16 +00:00
|
|
|
bool mode_set_by_vty;
|
2019-10-22 18:24:14 +00:00
|
|
|
/* traffic mode was configured by RKM (routing key management) or first ASPAC */
|
2019-11-05 17:24:29 +00:00
|
|
|
bool mode_set_by_peer;
|
2017-04-03 15:37:10 +00:00
|
|
|
uint32_t recovery_timeout_msec;
|
|
|
|
uint8_t qos_class;
|
2017-04-15 21:25:02 +00:00
|
|
|
struct {
|
|
|
|
uint32_t dpc;
|
2019-10-19 15:40:22 +00:00
|
|
|
enum osmo_ss7_as_patch_sccp_mode sccp_mode;
|
2017-06-22 18:56:52 +00:00
|
|
|
} pc_override;
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
struct osmo_ss7_asp *asps[16];
|
2019-10-16 12:50:06 +00:00
|
|
|
uint8_t last_asp_idx_sent; /* used for load-sharing traffic mode (round robin implementation) */
|
2017-04-03 15:37:10 +00:00
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osmo_ss7_as *
|
|
|
|
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 *
|
2017-04-10 20:34:20 +00:00
|
|
|
osmo_ss7_as_find_by_l_rk_id(struct osmo_ss7_instance *inst, uint32_t l_rk_id);
|
sccp: make simple client configurable via VTY
The osmo_sccp_simple_client_on_ss7_id and osmo_sccp_simple_client
are not entirely configurable via VTY commands. The relation to
the VTY is implicit. The user may set up instance objects via
VTY (cs7/ss7, AS, ASP), which are then automatically created on
startup.
Each cs7 instance gets its own ID via the VTY configuration. When
osmo_sccp_simple_client_on_ss7_id() is called with the cs7 instance
id. (for osmo_sccp_simple_client() the ID will be hardcoded to 1),
the function automatically checks if the CS7 instance is present,
if not it will create one automatically using the caller supplied
parameters as a defult. If a CS7 instance is present, the function
checks for the presence of an AS and an ASP. These objects are
present, they will be used. If not, new objects will be created.
Both functions must not be called if an SCCP instance is already
present. Since there can only be one SCCP instance per CS7 instance,
this is an error condition.
Add additional logic that checks to detect an already existing, valid
configuration. If no or an insufficient configuration is detected,
use the caller supplied parameters as default configuration.
Change-Id: I293f3526ce6182dca74a169a23449dbc7af57c7c
2017-07-19 16:41:09 +00:00
|
|
|
struct osmo_ss7_as *osmo_ss7_as_find_by_proto(struct osmo_ss7_instance *inst,
|
|
|
|
enum osmo_ss7_asp_protocol proto);
|
2017-04-10 20:34:20 +00:00
|
|
|
struct osmo_ss7_as *
|
2017-04-03 15:37:10 +00:00
|
|
|
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);
|
|
|
|
int osmo_ss7_as_del_asp(struct osmo_ss7_as *as, const char *asp_name);
|
|
|
|
void osmo_ss7_as_destroy(struct osmo_ss7_as *as);
|
2021-02-07 11:31:34 +00:00
|
|
|
bool osmo_ss7_as_has_asp(const struct osmo_ss7_as *as,
|
|
|
|
const struct osmo_ss7_asp *asp);
|
2023-02-11 12:32:50 +00:00
|
|
|
bool osmo_ss7_as_down(const struct osmo_ss7_as *as);
|
2019-11-06 19:52:29 +00:00
|
|
|
bool osmo_ss7_as_active(const struct osmo_ss7_as *as);
|
2019-10-22 18:24:14 +00:00
|
|
|
bool osmo_ss7_as_tmode_compatible_xua(struct osmo_ss7_as *as, uint32_t m3ua_tmt);
|
2017-04-15 20:39:05 +00:00
|
|
|
void osmo_ss7_asp_disconnect(struct osmo_ss7_asp *asp);
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SS7 Application Server Processes
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct osmo_ss7_asp_peer {
|
2019-10-11 15:58:07 +00:00
|
|
|
char *host[OSMO_SOCK_MAX_ADDRS];
|
|
|
|
size_t host_cnt;
|
2017-04-03 15:37:10 +00:00
|
|
|
uint16_t port;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum osmo_ss7_asp_admin_state {
|
|
|
|
/*! no SCTP association with peer */
|
|
|
|
OSMO_SS7_ASP_ADM_S_SHUTDOWN,
|
|
|
|
/*! SCP association, but reject ASP-ACTIVE */
|
|
|
|
OSMO_SS7_ASP_ADM_S_BLOCKED,
|
|
|
|
/*! in normal operation */
|
|
|
|
OSMO_SS7_ASP_ADM_S_ENABLED,
|
|
|
|
};
|
|
|
|
|
2019-10-29 20:48:35 +00:00
|
|
|
enum osmo_ss7_asp_role {
|
|
|
|
OSMO_SS7_ASP_ROLE_ASP,
|
|
|
|
OSMO_SS7_ASP_ROLE_SG,
|
|
|
|
OSMO_SS7_ASP_ROLE_IPSP,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct value_string osmo_ss7_asp_role_names[];
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_asp {
|
|
|
|
/*! entry in \ref osmo_ss7_instance.asp_list */
|
|
|
|
struct llist_head list;
|
|
|
|
struct osmo_ss7_instance *inst;
|
|
|
|
|
|
|
|
/*! ASP FSM */
|
|
|
|
struct osmo_fsm_inst *fi;
|
|
|
|
|
|
|
|
/*! \ref osmo_xua_server over which we were established */
|
|
|
|
struct osmo_xua_server *xua_server;
|
2017-04-14 20:24:15 +00:00
|
|
|
struct llist_head siblings;
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
/*! osmo_stream / libosmo-netif handles */
|
|
|
|
struct osmo_stream_cli *client;
|
|
|
|
struct osmo_stream_srv *server;
|
|
|
|
/*! pre-formatted human readable local/remote socket name */
|
|
|
|
char *sock_name;
|
|
|
|
|
|
|
|
/* ASP Identifier for ASP-UP + NTFY */
|
|
|
|
uint32_t asp_id;
|
|
|
|
bool asp_id_present;
|
|
|
|
|
2017-04-07 12:48:08 +00:00
|
|
|
/* Layer Manager to which we talk */
|
2017-04-07 15:14:54 +00:00
|
|
|
const struct osmo_xua_layer_manager *lm;
|
|
|
|
void *lm_priv;
|
2017-04-07 12:48:08 +00:00
|
|
|
|
2017-04-11 18:43:51 +00:00
|
|
|
/*! Were we dynamically allocated */
|
|
|
|
bool dyn_allocated;
|
|
|
|
|
2018-10-29 18:25:34 +00:00
|
|
|
/*! Were we allocated by "simple client" support? */
|
|
|
|
bool simple_client_allocated;
|
|
|
|
|
2021-11-14 19:32:56 +00:00
|
|
|
/*! Rate Counter Group */
|
|
|
|
struct rate_ctr_group *ctrg;
|
|
|
|
|
2017-04-02 09:58:17 +00:00
|
|
|
/*! Pending message for non-blocking IPA read */
|
|
|
|
struct msgb *pending_msg;
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
enum osmo_ss7_asp_protocol proto;
|
|
|
|
enum osmo_ss7_asp_admin_state adm_state;
|
|
|
|
bool is_server;
|
2019-10-29 20:55:49 +00:00
|
|
|
enum osmo_ss7_asp_role role;
|
|
|
|
bool role_set_by_vty;
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
struct osmo_ss7_asp_peer local;
|
|
|
|
struct osmo_ss7_asp_peer remote;
|
|
|
|
uint8_t qos_class;
|
2021-05-11 14:25:21 +00:00
|
|
|
uint32_t quirks;
|
2017-04-03 15:37:10 +00:00
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
2021-05-11 14:25:21 +00:00
|
|
|
/*! Peer SG doesn't send NTFY(AS-INACTIVE) after ASP-UP procedure */
|
2021-05-11 16:38:37 +00:00
|
|
|
#define OSMO_SS7_ASP_QUIRK_NO_NOTIFY 0x00000001
|
2021-05-11 14:33:07 +00:00
|
|
|
/*! Accept DAUD in ASP role (RFC states only permitted in ASP->SG role) */
|
2021-05-11 16:38:37 +00:00
|
|
|
#define OSMO_SS7_ASP_QUIRK_DAUD_IN_ASP 0x00000002
|
|
|
|
/*! Accept SSNM even if ASP is in AS-INACTIVE state */
|
|
|
|
#define OSMO_SS7_ASP_QUIRK_SNM_INACTIVE 0x00000004
|
2021-05-11 14:25:21 +00:00
|
|
|
|
2019-10-11 15:58:07 +00:00
|
|
|
int osmo_ss7_asp_peer_snprintf(char* buf, size_t buf_len, struct osmo_ss7_asp_peer *peer);
|
2020-01-10 13:14:41 +00:00
|
|
|
int osmo_ss7_asp_peer_set_hosts(struct osmo_ss7_asp_peer *peer, void *talloc_ctx,
|
|
|
|
const char* const* hosts, size_t host_cnt);
|
|
|
|
int osmo_ss7_asp_peer_add_host(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host);
|
2019-10-11 15:58:07 +00:00
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_asp *
|
|
|
|
osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name);
|
sccp: make simple client configurable via VTY
The osmo_sccp_simple_client_on_ss7_id and osmo_sccp_simple_client
are not entirely configurable via VTY commands. The relation to
the VTY is implicit. The user may set up instance objects via
VTY (cs7/ss7, AS, ASP), which are then automatically created on
startup.
Each cs7 instance gets its own ID via the VTY configuration. When
osmo_sccp_simple_client_on_ss7_id() is called with the cs7 instance
id. (for osmo_sccp_simple_client() the ID will be hardcoded to 1),
the function automatically checks if the CS7 instance is present,
if not it will create one automatically using the caller supplied
parameters as a defult. If a CS7 instance is present, the function
checks for the presence of an AS and an ASP. These objects are
present, they will be used. If not, new objects will be created.
Both functions must not be called if an SCCP instance is already
present. Since there can only be one SCCP instance per CS7 instance,
this is an error condition.
Add additional logic that checks to detect an already existing, valid
configuration. If no or an insufficient configuration is detected,
use the caller supplied parameters as default configuration.
Change-Id: I293f3526ce6182dca74a169a23449dbc7af57c7c
2017-07-19 16:41:09 +00:00
|
|
|
struct osmo_ss7_asp
|
|
|
|
*osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as,
|
|
|
|
enum osmo_ss7_asp_protocol proto);
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_asp *
|
2019-11-19 00:24:44 +00:00
|
|
|
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 *
|
2017-04-03 15:37:10 +00:00
|
|
|
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);
|
|
|
|
void osmo_ss7_asp_destroy(struct osmo_ss7_asp *asp);
|
|
|
|
int osmo_ss7_asp_send(struct osmo_ss7_asp *asp, struct msgb *msg);
|
|
|
|
int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp);
|
2017-04-07 15:14:54 +00:00
|
|
|
int osmo_ss7_asp_use_default_lm(struct osmo_ss7_asp *asp, int log_level);
|
2019-11-05 18:11:16 +00:00
|
|
|
bool osmo_ss7_asp_active(const struct osmo_ss7_asp *asp);
|
2021-02-07 12:15:34 +00:00
|
|
|
int osmo_ss7_asp_get_log_subsys(const struct osmo_ss7_asp *asp);
|
2017-04-03 15:37:10 +00:00
|
|
|
|
2018-05-26 09:32:50 +00:00
|
|
|
/*! Weak function to handle payload for unknown/unsupported PPID or IPA StreamID.
|
|
|
|
* This function can be overridden by application code to implement whatever handling
|
|
|
|
* it wants for such additional payloads/streams.
|
|
|
|
* \param[in] asp Application Server Process through which data was received
|
|
|
|
* \param[in] ppid_sid SCTP PPID (in sigtran case) or IPA Stream ID
|
|
|
|
* \param[in] msg Message buffer containing received data. Continues to be owned by caller!
|
|
|
|
* \return 0 on success; negative on error */
|
|
|
|
typedef int osmo_ss7_asp_rx_unknown_cb(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg);
|
|
|
|
|
|
|
|
void osmo_ss7_register_rx_unknown_cb(osmo_ss7_asp_rx_unknown_cb *cb);
|
|
|
|
|
2019-10-19 10:19:15 +00:00
|
|
|
#define _LOGSS7(inst, subsys, level, fmt, args ...) \
|
|
|
|
LOGP(subsys, level, "%u: " fmt, inst ? (inst)->cfg.id : 0, ## args)
|
|
|
|
#define LOGSS7(inst, level, fmt, args ...) _LOGSS7(inst, DLSS7, level, fmt, ## args)
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
#define LOGPASP(asp, subsys, level, fmt, args ...) \
|
2019-10-19 10:19:15 +00:00
|
|
|
_LOGSS7((asp)->inst, subsys, level, "asp-%s: " fmt, (asp)->cfg.name, ## args)
|
|
|
|
#define LOGPAS(as, subsys, level, fmt, args ...) \
|
|
|
|
_LOGSS7((as)->inst, subsys, level, "as-%s: " fmt, (as)->cfg.name, ## args)
|
2017-04-03 15:37:10 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* xUA Servers
|
|
|
|
***********************************************************************/
|
|
|
|
|
2017-04-07 12:48:08 +00:00
|
|
|
struct osmo_xua_layer_manager {
|
|
|
|
osmo_prim_cb prim_cb;
|
|
|
|
};
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_xua_server {
|
|
|
|
struct llist_head list;
|
|
|
|
struct osmo_ss7_instance *inst;
|
|
|
|
|
2017-04-14 20:24:15 +00:00
|
|
|
/* list of ASPs established via this server */
|
|
|
|
struct llist_head asp_list;
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_stream_srv_link *server;
|
|
|
|
|
|
|
|
struct {
|
2017-04-05 23:41:03 +00:00
|
|
|
bool accept_dyn_reg;
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_ss7_asp_peer local;
|
|
|
|
enum osmo_ss7_asp_protocol proto;
|
|
|
|
} cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osmo_xua_server *
|
|
|
|
osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto,
|
|
|
|
uint16_t local_port);
|
|
|
|
|
|
|
|
struct osmo_xua_server *
|
|
|
|
osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst, enum osmo_ss7_asp_protocol proto,
|
|
|
|
uint16_t local_port, const char *local_host);
|
|
|
|
|
ss7: Re-bind xUA server socket after setting new IP
In osmo-stp, cmd "local-ip" inside node "listen m3ua 2905" was actually
not being applied, because the server was created + bound at "listen" command
time using NULL as IP, and at "local-ip" time the IP was changed but the
server was not re-bound using the new IP, so it kept listening at
0.0.0.0.
With this patch, we defer binding the socket to "local-ip" cmd time,
after the IP has been applied.
As a result, if no "local-ip" command is provided, then the bind never
happens, which means it is now mandatory that users of osmo_ss7_xua_server_create
API not using osmo_ss7_xua_server_set_local_host call new provided API
osmo_ss7_xua_server_bind. Another new API osmo_ss7_bind_all_instances is
provided to easily make sure all servers are bound after configuration
process. This is specially important for servers which doesn't contain
the "local-ip" parameter.
Users of osmo_sccp_simple_server API are not affected by this change,
and they not requrie to call any new API.
Furthermore, using osmo_ss7_xua_server_bind in VTY code ensures the xUA
server is automatically bound to the new address if the operator changes
the "local-ip" cmd at runtime.
Related: OS#2647
Change-Id: I79738963d633bec70705ff159c5b2127cd498aa2
2017-11-17 11:57:25 +00:00
|
|
|
int
|
|
|
|
osmo_ss7_xua_server_bind(struct osmo_xua_server *xs);
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
int
|
|
|
|
osmo_ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host);
|
2019-10-11 15:58:07 +00:00
|
|
|
int
|
|
|
|
osmo_ss7_xua_server_set_local_hosts(struct osmo_xua_server *xs, const char **local_hosts, size_t local_host_cnt);
|
|
|
|
int osmo_ss7_xua_server_add_local_host(struct osmo_xua_server *xs, const char *local_host);
|
2017-04-03 15:37:10 +00:00
|
|
|
void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs);
|
|
|
|
|
|
|
|
struct osmo_sccp_instance *
|
2017-08-10 15:57:08 +00:00
|
|
|
osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
|
|
|
|
enum osmo_ss7_asp_protocol prot, int default_local_port,
|
|
|
|
const char *default_local_ip, int default_remote_port,
|
|
|
|
const char *default_remote_ip);
|
2017-04-03 15:37:10 +00:00
|
|
|
|
2017-07-03 13:26:22 +00:00
|
|
|
struct osmo_sccp_instance *
|
|
|
|
osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
|
2017-08-10 15:57:08 +00:00
|
|
|
uint32_t default_pc,
|
|
|
|
enum osmo_ss7_asp_protocol prot,
|
|
|
|
int default_local_port,
|
|
|
|
const char *default_local_ip,
|
|
|
|
int default_remote_port,
|
|
|
|
const char *default_remote_ip);
|
2017-07-03 13:26:22 +00:00
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_sccp_instance *
|
|
|
|
osmo_sccp_simple_server(void *ctx, uint32_t pc,
|
|
|
|
enum osmo_ss7_asp_protocol prot, int local_port,
|
|
|
|
const char *local_ip);
|
|
|
|
|
2017-07-03 13:26:22 +00:00
|
|
|
struct osmo_sccp_instance *
|
|
|
|
osmo_sccp_simple_server_on_ss7_id(void *ctx, uint32_t ss7_id, uint32_t pc,
|
|
|
|
enum osmo_ss7_asp_protocol prot,
|
|
|
|
int local_port, const char *local_ip);
|
|
|
|
|
2017-04-03 15:37:10 +00:00
|
|
|
struct osmo_sccp_instance *
|
|
|
|
osmo_sccp_simple_server_add_clnt(struct osmo_sccp_instance *inst,
|
|
|
|
enum osmo_ss7_asp_protocol prot,
|
|
|
|
const char *name, uint32_t pc,
|
|
|
|
int local_port, int remote_port,
|
|
|
|
const char *remote_ip);
|
2017-04-05 20:32:13 +00:00
|
|
|
|
|
|
|
enum osmo_ss7_as_traffic_mode osmo_ss7_tmode_from_xua(uint32_t in);
|
|
|
|
int osmo_ss7_tmode_to_xua(enum osmo_ss7_as_traffic_mode tmod);
|
2017-04-14 12:00:52 +00:00
|
|
|
|
|
|
|
/* VTY related */
|
|
|
|
struct vty;
|
2017-07-27 12:33:46 +00:00
|
|
|
void osmo_ss7_vty_init_asp(void *ctx);
|
|
|
|
void osmo_ss7_vty_init_sg(void *ctx);
|
2017-04-14 12:00:52 +00:00
|
|
|
int osmo_ss7_vty_go_parent(struct vty *vty);
|
|
|
|
int osmo_ss7_is_config_node(struct vty *vty, int node);
|