From ecb2cf1a312230def1b2b4ed4b9bd4ea499cf48a Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 19 Oct 2019 17:40:22 +0200 Subject: ipa: VTY config option to explicitly enable/disable SCCP patching When receiving SCCP messages from an IPA peer/ASP, osmo-stp so far unconditionally inserted origin/destination point codes int the SCCP called / calling party addresses. This behaviro is now made optional with the introduction of the following per-AS configuration: "point-code override patch-sccp (disabled|both)" The default behavior is switched from 'both' to 'disabled' at the same time. Change-Id: I535e2170adadfe755d2bcbf5bbf4556bebb77737 Closes: OS#4219 --- include/osmocom/sigtran/osmo_ss7.h | 6 ++++++ src/ipa.c | 10 ++++++---- src/osmo_ss7_vty.c | 28 ++++++++++++++++++++++++++++ tests/vty/ss7_asp_test.vty | 1 + 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 14e2b7c..d6ae1d4 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -290,6 +290,11 @@ osmo_ss7_asp_protocol_name(enum osmo_ss7_asp_protocol mode) int osmo_ss7_asp_protocol_port(enum osmo_ss7_asp_protocol prot); +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 */ +}; + struct osmo_ss7_as { /*! entry in 'ref osmo_ss7_instance.as_list */ struct llist_head list; @@ -314,6 +319,7 @@ struct osmo_ss7_as { uint8_t qos_class; struct { uint32_t dpc; + enum osmo_ss7_as_patch_sccp_mode sccp_mode; } pc_override; struct osmo_ss7_asp *asps[16]; diff --git a/src/ipa.c b/src/ipa.c index eeefbe8..d7a929d 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -260,10 +260,12 @@ static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg) } /* Second, patch this into the SCCP message */ - msg = patch_sccp_with_pc(asp, msg, opc, dpc); - if (!msg) { - LOGPASP(asp, DLSS7, LOGL_ERROR, "Unable to patch PC into SCCP message; dropping\n"); - return -1; + if (as->cfg.pc_override.sccp_mode == OSMO_SS7_PATCH_BOTH) { + msg = patch_sccp_with_pc(asp, msg, opc, dpc); + if (!msg) { + LOGPASP(asp, DLSS7, LOGL_ERROR, "Unable to patch PC into SCCP message; dropping\n"); + return -1; + } } /* Third, create a MTP3/M3UA label with those point codes */ diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index cc53b05..35ee5cd 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -932,6 +932,30 @@ DEFUN(as_pc_override, as_pc_override_cmd, return CMD_SUCCESS; } +DEFUN(as_pc_patch_sccp, as_pc_patch_sccp_cmd, + "point-code override patch-sccp (disabled|both)", + "Point Code Specific Features\n" + "Override (force) a point-code to hard-coded value\n" + "Patch point code values into SCCP called/calling address\n" + "Don't patch any point codes into SCCP called/calling address\n" + "Patch both origin and destination point codes into SCCP called/calling address\n") +{ + struct osmo_ss7_as *as = vty->index; + + if (as->cfg.proto != OSMO_SS7_ASP_PROT_IPA) { + vty_out(vty, "Only IPA type AS support point-code patch-into-sccp. " + "Be happy that you don't need it!%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (!strcmp(argv[0], "disabled")) + as->cfg.pc_override.sccp_mode = OSMO_SS7_PATCH_NONE; + else + as->cfg.pc_override.sccp_mode = OSMO_SS7_PATCH_BOTH; + + return CMD_SUCCESS; +} + static void write_one_as(struct vty *vty, struct osmo_ss7_as *as) { struct osmo_ss7_routing_key *rkey; @@ -973,6 +997,9 @@ static void write_one_as(struct vty *vty, struct osmo_ss7_as *as) 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); + + if (as->cfg.pc_override.sccp_mode) + vty_out(vty, " point-code override patch-sccp both%s", VTY_NEWLINE); } DEFUN(show_cs7_as, show_cs7_as_cmd, @@ -1807,6 +1834,7 @@ static void vty_init_shared(void *ctx) install_element(L_CS7_AS_NODE, &as_rout_key_ssn_cmd); install_element(L_CS7_AS_NODE, &as_rout_key_si_ssn_cmd); install_element(L_CS7_AS_NODE, &as_pc_override_cmd); + install_element(L_CS7_AS_NODE, &as_pc_patch_sccp_cmd); vty_init_addr(); } diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index cb8dc85..1aa954a 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -250,6 +250,7 @@ ss7_asp_vty_test(config-cs7-as)# list routing-key RCONTEXT DPC ssn SSN routing-key RCONTEXT DPC si (aal2|bicc|b-isup|h248|isup|sat-isup|sccp|tup) ssn SSN point-code override dpc PC + point-code override patch-sccp (disabled|both) ss7_asp_vty_test(config-cs7-as)# ? ... -- cgit v1.2.3