osmith has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/38756?usp=email )

Change subject: Use new libosmo-sigtran API osmo_ss7_instance_get_id()
......................................................................

Use new libosmo-sigtran API osmo_ss7_instance_get_id()

Depends: libosmo-sigtran.git Change-Id Id7b6f23a1a223fb232238b624eb4f3295790bcb1
Change-Id: Ic0a468de0e8852ddd1ebd99f25a6400475af9a1f
(cherry picked from commit 676609395ed294252b30ca39d934a9b720d085fc)
---
M TODO-RELEASE
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/lb.c
M src/osmo-bsc/osmo_bsc_sigtran.c
4 files changed, 27 insertions(+), 19 deletions(-)

Approvals:
  osmith: Verified
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved




diff --git a/TODO-RELEASE b/TODO-RELEASE
index c073b60..b5cd5cc 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,4 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library       what                    description / commit summary line
-libosmo-sigtran >2.0.1  Use API osmo_ss7_route_get_dest_as()
\ No newline at end of file
+libosmo-sigtran >2.0.1  Use API osmo_ss7_route_get_dest_as(), 
osmo_ss7_instance_get_id()
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 9558330..38e5782 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -2974,16 +2974,18 @@
        struct bsc_msc_data *msc = bsc_msc_data(vty);
        const char *bsc_addr_name = argv[0];
        struct osmo_ss7_instance *ss7;
+       uint32_t ss7_id;

        ss7 = osmo_sccp_addr_by_name(&msc->a.bsc_addr, bsc_addr_name);
        if (!ss7) {
                vty_out(vty, "Error: No such SCCP addressbook entry: '%s'%s", 
bsc_addr_name, VTY_NEWLINE);
                return CMD_ERR_INCOMPLETE;
        }
+       ss7_id = osmo_ss7_instance_get_id(ss7);

        /* Prevent mixing addresses from different CS7/SS7 instances */
        if (msc->a.cs7_instance_valid) {
-               if (msc->a.cs7_instance != ss7->cfg.id) {
+               if (msc->a.cs7_instance != ss7_id) {
                        vty_out(vty,
                                "Error: SCCP addressbook entry from mismatching 
CS7 instance: '%s'%s",
                                bsc_addr_name, VTY_NEWLINE);
@@ -2991,7 +2993,7 @@
                }
        }

-       msc->a.cs7_instance = ss7->cfg.id;
+       msc->a.cs7_instance = ss7_id;
        msc->a.cs7_instance_valid = true;
        enforce_standard_ssn(vty, &msc->a.bsc_addr);
        msc->a.bsc_addr_name = talloc_strdup(msc, bsc_addr_name);
@@ -3006,16 +3008,18 @@
        struct bsc_msc_data *msc = bsc_msc_data(vty);
        const char *msc_addr_name = argv[0];
        struct osmo_ss7_instance *ss7;
+       uint32_t ss7_id;

        ss7 = osmo_sccp_addr_by_name(&msc->a.msc_addr, msc_addr_name);
        if (!ss7) {
                vty_out(vty, "Error: No such SCCP addressbook entry: '%s'%s", 
msc_addr_name, VTY_NEWLINE);
                return CMD_ERR_INCOMPLETE;
        }
+       ss7_id = osmo_ss7_instance_get_id(ss7);

        /* Prevent mixing addresses from different CS7/SS7 instances */
        if (msc->a.cs7_instance_valid) {
-               if (msc->a.cs7_instance != ss7->cfg.id) {
+               if (msc->a.cs7_instance != ss7_id) {
                        vty_out(vty,
                                "Error: SCCP addressbook entry from mismatching 
CS7 instance: '%s'%s",
                                msc_addr_name, VTY_NEWLINE);
@@ -3023,7 +3027,7 @@
                }
        }

-       msc->a.cs7_instance = ss7->cfg.id;
+       msc->a.cs7_instance = ss7_id;
        msc->a.cs7_instance_valid = true;
        enforce_standard_ssn(vty, &msc->a.msc_addr);
        msc->a.msc_addr_name = talloc_strdup(msc, msc_addr_name);
diff --git a/src/osmo-bsc/lb.c b/src/osmo-bsc/lb.c
index 603b1e1..cac57b4 100644
--- a/src/osmo-bsc/lb.c
+++ b/src/osmo-bsc/lb.c
@@ -619,18 +619,20 @@
 bool smlc_set_cs7_instance(struct vty *vty, const char *from_vty_cmd, const 
char *from_addr,
                           struct osmo_ss7_instance *ss7)
 {
+       uint32_t ss7_id = osmo_ss7_instance_get_id(ss7);
+
        if (bsc_gsmnet->smlc->cs7_instance_valid) {
-               if (bsc_gsmnet->smlc->cs7_instance != ss7->cfg.id) {
+               if (bsc_gsmnet->smlc->cs7_instance != ss7_id) {
                        LOGP(DLCS, LOGL_ERROR,
                             "%s: expecting address from cs7 instance %u, but 
'%s' is from %u\n",
-                            from_vty_cmd, bsc_gsmnet->smlc->cs7_instance, 
from_addr, ss7->cfg.id);
+                            from_vty_cmd, bsc_gsmnet->smlc->cs7_instance, 
from_addr, ss7_id);
                        vty_out(vty, "Error:"
                                " %s: expecting address from cs7 instance %u, 
but '%s' is from %u%s",
-                               from_vty_cmd, bsc_gsmnet->smlc->cs7_instance, 
from_addr, ss7->cfg.id, VTY_NEWLINE);
+                               from_vty_cmd, bsc_gsmnet->smlc->cs7_instance, 
from_addr, ss7_id, VTY_NEWLINE);
                        return false;
                }
        } else {
-               bsc_gsmnet->smlc->cs7_instance = ss7->cfg.id;
+               bsc_gsmnet->smlc->cs7_instance = ss7_id;
                bsc_gsmnet->smlc->cs7_instance_valid = true;
                LOGP(DLCS, LOGL_NOTICE, "Lb interface is using cs7 instance 
%u\n", bsc_gsmnet->smlc->cs7_instance);
        }
diff --git a/src/osmo-bsc/osmo_bsc_sigtran.c b/src/osmo-bsc/osmo_bsc_sigtran.c
index d1d4d18..67827f4 100644
--- a/src/osmo-bsc/osmo_bsc_sigtran.c
+++ b/src/osmo-bsc/osmo_bsc_sigtran.c
@@ -114,8 +114,9 @@
 static struct bsc_msc_data *get_msc_by_pc(struct osmo_ss7_instance *cs7, 
uint32_t pc)
 {
        struct bsc_msc_data *msc;
+       uint32_t cs7_id = osmo_ss7_instance_get_id(cs7);
        llist_for_each_entry(msc, msc_list, entry) {
-               if (msc->a.cs7_instance != cs7->cfg.id)
+               if (msc->a.cs7_instance != cs7_id)
                        continue;
                if ((msc->a.msc_addr.presence & OSMO_SCCP_ADDR_T_PC) == 0)
                        continue;
@@ -619,14 +620,15 @@
                char inst_name[32];
                enum osmo_ss7_asp_protocol used_proto = OSMO_SS7_ASP_PROT_NONE;
                int prev_msc_nr;
+               uint32_t inst_id = osmo_ss7_instance_get_id(inst);

                struct osmo_sccp_instance *sccp;
                struct bsc_sccp_inst *bsc_sccp;

                llist_for_each_entry(msc, msc_list, entry) {
                        /* An MSC with invalid cs7 instance id defaults to cs7 
instance 0 */
-                       if ((inst->cfg.id != msc->a.cs7_instance)
-                           && !(inst->cfg.id == 0 && 
!msc->a.cs7_instance_valid))
+                       if ((inst_id != msc->a.cs7_instance)
+                           && !(inst_id == 0 && !msc->a.cs7_instance_valid))
                                continue;

                        /* This msc runs on this cs7 inst. Check the asp_proto. 
*/
@@ -637,7 +639,7 @@
                                     prev_msc_nr, msc->nr,
                                     osmo_ss7_asp_protocol_name(used_proto),
                                     
osmo_ss7_asp_protocol_name(msc->a.asp_proto),
-                                    inst->cfg.id);
+                                    inst_id);
                                return -EINVAL;
                        }

@@ -648,17 +650,17 @@

                if (used_proto == OSMO_SS7_ASP_PROT_NONE) {
                        /* This instance has no MSC associated with it */
-                       LOGP(DMSC, LOGL_ERROR, "cs7 instance %u has no MSCs 
configured to run on it\n", inst->cfg.id);
+                       LOGP(DMSC, LOGL_ERROR, "cs7 instance %u has no MSCs 
configured to run on it\n", inst_id);
                        continue;
                }

-               snprintf(inst_name, sizeof(inst_name), "A-%u-%s", inst->cfg.id, 
osmo_ss7_asp_protocol_name(used_proto));
+               snprintf(inst_name, sizeof(inst_name), "A-%u-%s", inst_id, 
osmo_ss7_asp_protocol_name(used_proto));
                LOGP(DMSC, LOGL_NOTICE, "Initializing SCCP connection for A/%s 
on cs7 instance %u\n",
-                    osmo_ss7_asp_protocol_name(used_proto), inst->cfg.id);
+                    osmo_ss7_asp_protocol_name(used_proto), inst_id);

                /* SS7 Protocol stack */
                default_pc = osmo_ss7_pointcode_parse(NULL, BSC_DEFAULT_PC);
-               sccp = osmo_sccp_simple_client_on_ss7_id(tall_bsc_ctx, 
inst->cfg.id, inst_name,
+               sccp = osmo_sccp_simple_client_on_ss7_id(tall_bsc_ctx, inst_id, 
inst_name,
                                                         default_pc, used_proto,
                                                         0, 
DEFAULT_ASP_LOCAL_IP,
                                                         0, 
DEFAULT_ASP_REMOTE_IP);
@@ -674,8 +676,8 @@
                        char msc_name[32];

                        /* Skip MSCs that don't run on this cs7 instance */
-                       if ((inst->cfg.id != msc->a.cs7_instance)
-                           && !(inst->cfg.id == 0 && 
!msc->a.cs7_instance_valid))
+                       if ((inst_id != msc->a.cs7_instance)
+                           && !(inst_id == 0 && !msc->a.cs7_instance_valid))
                                continue;

                        snprintf(msc_name, sizeof(msc_name), "msc-%d", msc->nr);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38756?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-bsc
Gerrit-Branch: osmith/1.12.2
Gerrit-Change-Id: Ic0a468de0e8852ddd1ebd99f25a6400475af9a1f
Gerrit-Change-Number: 38756
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-CC: pespin <[email protected]>

Reply via email to