From 57d0449d4ed5d82050c52551c8ad6195db38fdf1 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 15 Apr 2017 23:25:02 +0200 Subject: IPA: Override/Set point codes As an IPA SCCPlite message arrives without any MTP routing label, we simply construct one artificially for all inbound IPA/SCCPlite packets: * we set the SPC to the point-code of the routing key of the AS (as this is the PC we route to this IPA/SCCPlite client anyway) * we set the DPC to a point-code from a new vty config command "point-code override dpc" Change-Id: Id556398e1ded3e613cfde7ea8b71aff7a414ff90 --- include/osmocom/sigtran/osmo_ss7.h | 3 +++ src/ipa.c | 36 ++++++++++++++++++++++++++++++++++-- src/osmo_ss7_vty.c | 27 +++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 2ae4c1e..7b0a607 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -291,6 +291,9 @@ struct osmo_ss7_as { enum osmo_ss7_as_traffic_mode mode; uint32_t recovery_timeout_msec; uint8_t qos_class; + struct { + uint32_t dpc; + } pc_override;; struct osmo_ss7_asp *asps[16]; } cfg; diff --git a/src/ipa.c b/src/ipa.c index 1668f0f..df3dbd1 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -116,10 +116,33 @@ static int ipa_rx_msg_ccm(struct osmo_ss7_asp *asp, struct msgb *msg) return 0; } +static struct osmo_ss7_as *find_as_for_asp(struct osmo_ss7_asp *asp) +{ + struct osmo_ss7_as *as; + + /* in the IPA case, weassume there is a 1:1 mapping between the + * ASP and the AS. An AS without ASP means there is no + * connection, and an ASP without AS means that we don't (yet?) + * know the identity of the peer */ + + llist_for_each_entry(as, &asp->inst->as_list, list) { + if (osmo_ss7_as_has_asp(as, asp)) + return as; + } + return NULL; +} + static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg) { struct m3ua_data_hdr data_hdr; struct xua_msg *xua = xua_msg_alloc(); + struct osmo_ss7_as *as = find_as_for_asp(asp); + + if (!as) { + LOGPASP(asp, DLSS7, LOGL_ERROR, "Rx message for IPA ASP without AS?!\n"); + msgb_free(msg); + return -1; + } /* pull the IPA header */ msgb_pull_to_l2(msg); @@ -142,9 +165,18 @@ static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg) */ memset(&data_hdr, 0, sizeof(data_hdr)); - data_hdr.opc = 0;//FIXME; - data_hdr.dpc = 0;//FIXME; data_hdr.si = MTP_SI_SCCP; + if (asp->cfg.is_server) { + /* Source: the PC of the routing key */ + data_hdr.opc = as->cfg.routing_key.pc; + /* Destination: Based on VTY config */ + data_hdr.dpc = as->cfg.pc_override.dpc; + } else { + /* Source: Based on VTY config */ + data_hdr.opc = as->cfg.pc_override.dpc; + /* Destination: PC of the routing key */ + data_hdr.dpc = as->cfg.routing_key.pc; + } xua = m3ua_xfer_from_data(&data_hdr, msgb_l2(msg), msgb_l2len(msg)); return m3ua_hmdc_rx_from_l2(asp->inst, xua); diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index a6a0f5b..0ff9e76 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -789,6 +789,28 @@ DEFUN(as_rout_key, as_rout_key_cmd, return CMD_SUCCESS; } +DEFUN(as_pc_override, as_pc_override_cmd, + "point-code override dpc PC", + "Point Code Specific Features\n" + "Override (force) a point-code to hard-coded value\n" + "Override Source Point Code\n" + "Override Destination Point Code\n" + "New Point Code\n") +{ + struct osmo_ss7_as *as = vty->index; + uint32_t pc = osmo_ss7_pointcode_parse(as->inst, argv[0]); + + if (as->cfg.proto != OSMO_SS7_ASP_PROT_IPA) { + vty_out(vty, "Only IPA type AS support point-code override. " + "Be happy that you don't need it!%s", VTY_NEWLINE); + return CMD_WARNING; + } + + as->cfg.pc_override.dpc = pc; + + return CMD_SUCCESS; +} + static void write_one_as(struct vty *vty, struct osmo_ss7_as *as) { struct osmo_ss7_routing_key *rkey; @@ -826,6 +848,10 @@ static void write_one_as(struct vty *vty, struct osmo_ss7_as *as) if (rkey->ssn) vty_out(vty, " ssn %u", rkey->ssn); vty_out(vty, "%s", VTY_NEWLINE); + + if (as->cfg.pc_override.dpc) + vty_out(vty, " point-code override dpc %s%s", + osmo_ss7_pointcode_print(as->inst, as->cfg.pc_override.dpc), VTY_NEWLINE); } DEFUN(show_cs7_as, show_cs7_as_cmd, @@ -1012,6 +1038,7 @@ static void vty_init_shared(void) install_element(L_CS7_AS_NODE, &as_recov_tout_cmd); install_element(L_CS7_AS_NODE, &as_qos_class_cmd); install_element(L_CS7_AS_NODE, &as_rout_key_cmd); + install_element(L_CS7_AS_NODE, &as_pc_override_cmd); } void osmo_ss7_vty_init_asp(void) -- cgit v1.2.3