pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40585?usp=email )

Change subject: Make helper function available as internal ss7_as API
......................................................................

Make helper function available as internal ss7_as API

This API will be used in more places starting with follow-up commit.

Change-Id: I818efd9e864fe0bd624a2ff1cba5ccd1d49939c5
---
M src/ss7_as.c
M src/ss7_as.h
M src/xua_as_fsm.c
3 files changed, 23 insertions(+), 21 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved




diff --git a/src/ss7_as.c b/src/ss7_as.c
index 16da09f..b4eb439 100644
--- a/src/ss7_as.c
+++ b/src/ss7_as.c
@@ -274,6 +274,27 @@
        return cnt;
 }

+/* Determine which role (SG/ASP/IPSP) we operate in.
+ * return enum osmo_ss7_asp_role on success, negative otherwise. */
+int ss7_as_get_local_role(const struct osmo_ss7_as *as)
+{
+       unsigned int i;
+
+       /* this is a bit tricky. "osmo_ss7_as" has no configuration of a role,
+        * only the ASPs have.  As they all must be of the same role, let's 
simply
+        * find the first one and return its role */
+       for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+               struct osmo_ss7_asp *asp = as->cfg.asps[i];
+
+               if (!asp)
+                       continue;
+
+               return asp->cfg.role;
+       }
+       /* No ASPs associated to this AS yet? */
+       return -1;
+}
+
 /*! Determine if given AS is in the active state.
  *  \param[in] as Application Server.
  *  \returns true in case as is active; false otherwise. */
diff --git a/src/ss7_as.h b/src/ss7_as.h
index fe1d86b..be10f48 100644
--- a/src/ss7_as.h
+++ b/src/ss7_as.h
@@ -133,6 +133,7 @@

 unsigned int osmo_ss7_as_count_asp(const struct osmo_ss7_as *as);
 int ss7_as_add_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
+int ss7_as_get_local_role(const struct osmo_ss7_as *as);
 void ss7_as_loadshare_binding_table_reset(struct osmo_ss7_as *as);

 #define LOGPAS(as, subsys, level, fmt, args ...) \
diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c
index 7d8e302..7afcb6d 100644
--- a/src/xua_as_fsm.c
+++ b/src/xua_as_fsm.c
@@ -150,26 +150,6 @@
        return sent;
 }

-/* determine which role (SG/ASP/IPSP) we operate in */
-static int get_local_role(struct osmo_ss7_as *as)
-{
-       unsigned int i;
-
-       /* this is a bit tricky. "osmo_ss7_as" has no configuration of a role,
-        * only the ASPs have.  As they all must be of the same role, let's 
simply
-        * find the first one and return its role */
-       for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
-               struct osmo_ss7_asp *asp = as->cfg.asps[i];
-
-               if (!asp)
-                       continue;
-
-               return asp->cfg.role;
-       }
-       /* we don't have any ASPs in this AS? Strange */
-       return -1;
-}
-
 static struct msgb *xua_as_encode_msg(const struct osmo_ss7_as *as, struct 
xua_msg *xua)
 {
        switch (as->cfg.proto) {
@@ -537,7 +517,7 @@

        bool became_available = (old_state != XUA_AS_S_ACTIVE && fi->state == 
XUA_AS_S_ACTIVE);
        bool became_unavailable = (old_state == XUA_AS_S_ACTIVE && fi->state != 
XUA_AS_S_ACTIVE);
-       int role = get_local_role(xafp->as);
+       int role = ss7_as_get_local_role(xafp->as);

        switch (role) {
        case OSMO_SS7_ASP_ROLE_ASP:

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

Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I818efd9e864fe0bd624a2ff1cba5ccd1d49939c5
Gerrit-Change-Number: 40585
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>

Reply via email to