pespin has uploaded this change for review.

View Change

asp: Rework s/get_all_rctx_for_asp/ss7_asp_get_all_rctx_be/g

This function will gain other users in other files in follow-up patches.
While at it, constify and reorder params.

Change-Id: Ic3a1c0bd663fe33ab14828e30e057a8beaa84c3f
---
M src/osmo_ss7_asp.c
M src/ss7_asp.h
M src/xua_snm.c
3 files changed, 30 insertions(+), 27 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/13/40013/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index bb3c2dd..c054369 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -1300,3 +1300,25 @@

osmo_ss7_asp_restart(asp);
}
+
+/* Obtain all routing contexts (in network byte order) that exist within the given ASP */
+unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
+ const struct osmo_ss7_as *excl_as)
+{
+ unsigned int count = 0;
+ struct osmo_ss7_as *as;
+
+ llist_for_each_entry(as, &asp->inst->as_list, list) {
+ if (as == excl_as)
+ continue;
+ if (!osmo_ss7_as_has_asp(as, asp))
+ continue;
+ if (as->cfg.routing_key.context == 0)
+ continue;
+ if (count >= rctx_size)
+ break;
+ rctx[count] = htonl(as->cfg.routing_key.context);
+ count++;
+ }
+ return count;
+}
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index 7a001e0..bdde5bd 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -128,5 +128,8 @@
void ss7_asp_restart_after_reconfigure(struct osmo_ss7_asp *asp);
void osmo_ss7_asp_remove_default_lm(struct osmo_ss7_asp *asp);

+unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
+ const struct osmo_ss7_as *excl_as);
+
#define LOGPASP(asp, subsys, level, fmt, args ...) \
_LOGSS7((asp)->inst, subsys, level, "ASP(%s) " fmt, (asp)->cfg.name, ## args)
diff --git a/src/xua_snm.c b/src/xua_snm.c
index edb1210..3dd988f 100644
--- a/src/xua_snm.c
+++ b/src/xua_snm.c
@@ -66,28 +66,6 @@
return out;
}

-/* obtain all routing contexts (in network byte order) that exist within the given ASP */
-static unsigned int get_all_rctx_for_asp(uint32_t *rctx, unsigned int rctx_size,
- struct osmo_ss7_asp *asp, struct osmo_ss7_as *excl_as)
-{
- unsigned int count = 0;
- struct osmo_ss7_as *as;
-
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (as == excl_as)
- continue;
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
- if (as->cfg.routing_key.context == 0)
- continue;
- if (count >= rctx_size)
- break;
- rctx[count] = htonl(as->cfg.routing_key.context);
- count++;
- }
- return count;
-}
-
static void xua_tx_snm_available(struct osmo_ss7_asp *asp, const uint32_t *rctx, unsigned int num_rctx,
const uint32_t *aff_pc, unsigned int num_aff_pc,
const char *info_str, bool available)
@@ -192,7 +170,7 @@
if (asp->cfg.role != OSMO_SS7_ASP_ROLE_SG)
continue;

- num_rctx = get_all_rctx_for_asp(rctx, ARRAY_SIZE(rctx), asp, as);
+ num_rctx = ss7_asp_get_all_rctx_be(asp, rctx, ARRAY_SIZE(rctx), as);
/* this can happen if the given ASP is only in the AS that reports the change,
* which shall be excluded */
if (num_rctx == 0)
@@ -238,7 +216,7 @@
if (asp->cfg.proto != OSMO_SS7_ASP_PROT_SUA)
continue;

- num_rctx = get_all_rctx_for_asp(rctx, ARRAY_SIZE(rctx), asp, as);
+ num_rctx = ss7_asp_get_all_rctx_be(asp, rctx, ARRAY_SIZE(rctx), as);
/* this can happen if the given ASP is only in the AS that reports the change,
* which shall be excluded */
if (num_rctx == 0)
@@ -269,7 +247,7 @@
if (asp->cfg.role != OSMO_SS7_ASP_ROLE_SG)
continue;

- num_rctx = get_all_rctx_for_asp(rctx, ARRAY_SIZE(rctx), asp, as);
+ num_rctx = ss7_asp_get_all_rctx_be(asp, rctx, ARRAY_SIZE(rctx), as);
/* this can happen if the given ASP is only in the AS that reports the change,
* which shall be excluded */
if (num_rctx == 0)
@@ -299,7 +277,7 @@
if (asp->cfg.role != OSMO_SS7_ASP_ROLE_SG)
continue;

- num_rctx = get_all_rctx_for_asp(rctx, ARRAY_SIZE(rctx), asp, as);
+ num_rctx = ss7_asp_get_all_rctx_be(asp, rctx, ARRAY_SIZE(rctx), as);
/* this can happen if the given ASP is only in the AS that reports the change,
* which shall be excluded */
if (num_rctx == 0)
@@ -326,7 +304,7 @@
aff_pc = (const uint32_t *) ie_aff_pc->dat;
num_aff_pc = ie_aff_pc->len / sizeof(uint32_t);

- num_rctx = get_all_rctx_for_asp(rctx, ARRAY_SIZE(rctx), asp, NULL);
+ num_rctx = ss7_asp_get_all_rctx_be(asp, rctx, ARRAY_SIZE(rctx), NULL);

LOGPASP(asp, log_ss, LOGL_INFO, "Rx DAUD(%s) for %s\n", info_str ? info_str : "",
format_affected_pcs_c(xua, asp->inst, ie_aff_pc));

To view, visit change 40013. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ic3a1c0bd663fe33ab14828e30e057a8beaa84c3f
Gerrit-Change-Number: 40013
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>