laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-sccp/+/15814 )

Change subject: ipa: VTY config option to explicitly enable/disable SCCP 
patching
......................................................................

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
---
M include/osmocom/sigtran/osmo_ss7.h
M src/ipa.c
M src/osmo_ss7_vty.c
M tests/vty/ss7_asp_test.vty
4 files changed, 41 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



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 @@

 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 @@
                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 @@
        }

        /* 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 @@
        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 @@
        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 @@
        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 @@
   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)# ?
 ...

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/15814
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I535e2170adadfe755d2bcbf5bbf4556bebb77737
Gerrit-Change-Number: 15814
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to