pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39608?usp=email )
Change subject: Move osmo_ss7_route_name() to osmo_ss7_route.c
......................................................................
Move osmo_ss7_route_name() to osmo_ss7_route.c
Change-Id: I6889a9b6c86453044a6cf6728e7e61264d594a4e
---
M src/osmo_ss7_hmrt.c
M src/osmo_ss7_route.c
2 files changed, 60 insertions(+), 59 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
osmith: Looks good to me, approved
diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c
index 5fca2d8..839b8ad 100644
--- a/src/osmo_ss7_hmrt.c
+++ b/src/osmo_ss7_hmrt.c
@@ -146,65 +146,6 @@
}
}
-/*! Return human readable representation of the route, in a static buffer.
- * This uses both osmo_ss7_pointcode_print() and osmo_ss7_pointcode_print2(), so pairing
- * osmo_ss7_route_name() with osmo_ss7_pointcode_print() in the same printf statement is
likely to
- * conflict.
- * \param[in] rt The route information to print, or NULL.
- * \param[in] list_asps If true, append info for all ASPs for the route's AS.
- * \returns A string constant or static buffer. */
-const char *osmo_ss7_route_name(struct osmo_ss7_route *rt, bool list_asps)
-{
- static char buf[256];
- char *pos = buf;
- struct osmo_ss7_instance *inst;
- size_t l;
-
- if (!rt)
- return "no route";
-
- inst = rt->rtable->inst;
-
-#define APPEND(fmt, args ...) \
- do { \
- l = snprintf(pos, sizeof(buf) - (pos - buf), fmt, ## args); \
- pos += l; \
- if (pos - buf >= sizeof(buf) ) \
- goto out; \
- } while (0)
-
- APPEND("pc=%u=%s mask=0x%x=%s",
- rt->cfg.pc, osmo_ss7_pointcode_print(inst, rt->cfg.pc),
- rt->cfg.mask, osmo_ss7_pointcode_print2(inst, rt->cfg.mask));
-
- if (rt->dest.as) {
- struct osmo_ss7_as *as = rt->dest.as;
- int i;
- APPEND(" via AS %s proto=%s", as->cfg.name,
osmo_ss7_asp_protocol_name(as->cfg.proto));
-
- if (list_asps) {
- for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
- struct osmo_ss7_asp *asp = as->cfg.asps[i];
- if (!asp)
- continue;
- APPEND(" ASP");
- if (asp->cfg.name)
- APPEND(" %s", asp->cfg.name);
- if (asp->sock_name)
- APPEND(" %s", asp->sock_name);
- }
- }
- } else if (rt->dest.linkset)
- APPEND(" via linkset %s", rt->dest.linkset->cfg.name);
- else
- APPEND(" has no route set");
-#undef APPEND
-
-out:
- buf[sizeof(buf)-1] = '\0';
- return buf;
-}
-
/* HMDC->HMRT Msg For Routing; Figure 26/Q.704 */
/* local message was receive d from L4, SRM, SLM, STM or SLTC, or
* remote message received from L2 and HMDC determined msg for routing */
diff --git a/src/osmo_ss7_route.c b/src/osmo_ss7_route.c
index 1afc75c..8a1592f 100644
--- a/src/osmo_ss7_route.c
+++ b/src/osmo_ss7_route.c
@@ -28,6 +28,7 @@
#include "ss7_linkset.h"
#include "ss7_as.h"
+#include "ss7_asp.h"
#include "ss7_route.h"
#include "ss7_route_table.h"
#include "ss7_internal.h"
@@ -295,6 +296,65 @@
return buf;
}
+/*! Return human readable representation of the route, in a static buffer.
+ * This uses both osmo_ss7_pointcode_print() and osmo_ss7_pointcode_print2(), so pairing
+ * osmo_ss7_route_name() with osmo_ss7_pointcode_print() in the same printf statement is
likely to
+ * conflict.
+ * \param[in] rt The route information to print, or NULL.
+ * \param[in] list_asps If true, append info for all ASPs for the route's AS.
+ * \returns A string constant or static buffer. */
+const char *osmo_ss7_route_name(struct osmo_ss7_route *rt, bool list_asps)
+{
+ static char buf[256];
+ char *pos = buf;
+ struct osmo_ss7_instance *inst;
+ size_t l;
+
+ if (!rt)
+ return "no route";
+
+ inst = rt->rtable->inst;
+
+#define APPEND(fmt, args ...) \
+ do { \
+ l = snprintf(pos, sizeof(buf) - (pos - buf), fmt, ## args); \
+ pos += l; \
+ if (pos - buf >= sizeof(buf)) \
+ goto out; \
+ } while (0)
+
+ APPEND("pc=%u=%s mask=0x%x=%s",
+ rt->cfg.pc, osmo_ss7_pointcode_print(inst, rt->cfg.pc),
+ rt->cfg.mask, osmo_ss7_pointcode_print2(inst, rt->cfg.mask));
+
+ if (rt->dest.as) {
+ struct osmo_ss7_as *as = rt->dest.as;
+ int i;
+ APPEND(" via AS %s proto=%s", as->cfg.name,
osmo_ss7_asp_protocol_name(as->cfg.proto));
+
+ if (list_asps) {
+ for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+ struct osmo_ss7_asp *asp = as->cfg.asps[i];
+ if (!asp)
+ continue;
+ APPEND(" ASP");
+ if (asp->cfg.name)
+ APPEND(" %s", asp->cfg.name);
+ if (asp->sock_name)
+ APPEND(" %s", asp->sock_name);
+ }
+ }
+ } else if (rt->dest.linkset)
+ APPEND(" via linkset %s", rt->dest.linkset->cfg.name);
+ else
+ APPEND(" has no route set");
+#undef APPEND
+
+out:
+ buf[sizeof(buf)-1] = '\0';
+ return buf;
+}
+
/*! \brief Find a SS7 route for given destination point code in given SS7 */
struct osmo_ss7_route *
osmo_ss7_route_lookup(struct osmo_ss7_instance *inst, uint32_t dpc)
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39608?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: I6889a9b6c86453044a6cf6728e7e61264d594a4e
Gerrit-Change-Number: 39608
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>