ensure valid primary_pc in osmo_ss7_instance
Initialize osmo_ss7_instance.cfg.primary_pc = OSMO_SS7_PC_INVALID. Adjust all code paths using primary_pc to ensure it is indeed valid. Rationale: It looks like we are going to use the primary point-code of an SS7 instance to derive a local SCCP address, e.g. for osmo-bsc and osmo-hnbgw. cs7-instance 1 point-code 1.2.3 ! sets osmo_ss7_instance.primary_pc = 1.2.3 sccp-address msc point-code 0.0.1 routing-indicator PC hnb iucs remote-addr msc ! derives cs7 instance 1 and local pc 1.2.3 If 'point-code 1.2.3' is omitted, this becomes '0.0.0' without the user noticing, and this happens for each client that omits it. I would like to barf when no local PC is set. Change-Id: I7f0f0c89b7335d9da24161bfac8234be214ca00c
This commit is contained in:
parent
b711e14504
commit
b352ca030d
|
@ -354,6 +354,8 @@ osmo_ss7_instance_find_or_create(void *ctx, uint32_t id)
|
|||
if (!inst)
|
||||
return NULL;
|
||||
|
||||
inst->cfg.primary_pc = OSMO_SS7_PC_INVALID;
|
||||
|
||||
inst->cfg.id = id;
|
||||
LOGSS7(inst, LOGL_INFO, "Creating SS7 Instance\n");
|
||||
|
||||
|
@ -1825,7 +1827,7 @@ void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs)
|
|||
bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc)
|
||||
{
|
||||
OSMO_ASSERT(ss7_initialized);
|
||||
if (pc == inst->cfg.primary_pc)
|
||||
if (osmo_ss7_pc_is_valid(inst->cfg.primary_pc) && pc == inst->cfg.primary_pc)
|
||||
return true;
|
||||
/* FIXME: Secondary and Capability Point Codes */
|
||||
return false;
|
||||
|
|
|
@ -166,7 +166,7 @@ DEFUN(cs7_point_code, cs7_point_code_cmd,
|
|||
{
|
||||
struct osmo_ss7_instance *inst = vty->index;
|
||||
int pc = osmo_ss7_pointcode_parse(inst, argv[0]);
|
||||
if (pc < 0) {
|
||||
if (pc < 0 || !osmo_ss7_pc_is_valid((uint32_t)pc)) {
|
||||
vty_out(vty, "Invalid point code (%s)%s", argv[0], VTY_NEWLINE);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
@ -1536,7 +1536,7 @@ static void write_one_cs7(struct vty *vty, struct osmo_ss7_instance *inst)
|
|||
if (inst->cfg.pc_fmt.delimiter != '.')
|
||||
vty_out(vty, " point-code delimiter dash%s", VTY_NEWLINE);
|
||||
|
||||
if (inst->cfg.primary_pc)
|
||||
if (osmo_ss7_pc_is_valid(inst->cfg.primary_pc))
|
||||
vty_out(vty, " point-code %s%s",
|
||||
osmo_ss7_pointcode_print(inst, inst->cfg.primary_pc),
|
||||
VTY_NEWLINE);
|
||||
|
|
|
@ -1670,11 +1670,11 @@ static void vty_show_connection(struct vty *vty, struct sccp_connection *conn)
|
|||
{
|
||||
struct osmo_ss7_instance *s7i = conn->inst->ss7;
|
||||
struct osmo_sccp_addr *remote_addr;
|
||||
uint32_t local_pc;
|
||||
uint32_t local_pc = OSMO_SS7_PC_INVALID;
|
||||
|
||||
if (conn->user->pc_valid)
|
||||
local_pc = conn->user->pc;
|
||||
else
|
||||
else if (osmo_ss7_pc_is_valid(s7i->cfg.primary_pc))
|
||||
local_pc = s7i->cfg.primary_pc;
|
||||
|
||||
if (conn->incoming)
|
||||
|
|
|
@ -91,8 +91,14 @@ static int sua2sccp_tx_m3ua(struct osmo_sccp_instance *inst,
|
|||
param = &omp->u.transfer;
|
||||
if (sua->mtp.opc)
|
||||
param->opc = sua->mtp.opc;
|
||||
else
|
||||
else {
|
||||
if (!osmo_ss7_pc_is_valid(s7i->cfg.primary_pc)) {
|
||||
LOGP(DLSCCP, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n",
|
||||
s7i->cfg.id);
|
||||
return -1;
|
||||
}
|
||||
param->opc = s7i->cfg.primary_pc;
|
||||
}
|
||||
param->dpc = remote_pc;
|
||||
param->sls = sua->mtp.sls;
|
||||
param->sio = MTP_SIO(MTP_SI_SCCP, s7i->cfg.network_indicator);
|
||||
|
|
|
@ -366,6 +366,11 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
|
|||
goto out_ss7;
|
||||
as_created = true;
|
||||
|
||||
if (!osmo_ss7_pc_is_valid(ss7->cfg.primary_pc)) {
|
||||
LOGP(DLSCCP, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n",
|
||||
ss7->cfg.id);
|
||||
goto out_ss7;
|
||||
}
|
||||
as->cfg.routing_key.pc = ss7->cfg.primary_pc;
|
||||
|
||||
/* install default route */
|
||||
|
|
Loading…
Reference in New Issue