This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1810 to look at the new patch set (#3). sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions They stringify a global title or SCCP address for human consumption Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 74 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/10/1810/3 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 3384630..968c500 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -37,3 +37,6 @@ int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt); +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index c6248de..1fc257c 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -20,6 +20,11 @@ */ #include <string.h> +#include <stdbool.h> + +#include <sys/socket.h> +#include <arpa/inet.h> +#include <netinet/in.h> #include <osmocom/sigtran/sccp_sap.h> #include <osmocom/sigtran/sua.h> @@ -149,3 +154,69 @@ return rc; } + +static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (*comma == true) { + strcat(buf, ","); + } else + *comma = true; + vsprintf(buf+strlen(buf), fmt, ap); + va_end(ap); +} + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + if (gt->gti == OSMO_SCCP_GTI_NO_GT) { + strcat(buf, "NONE"); + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_NAI_ONLY) { + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_TT_ONLY || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "TT=%u", gt->tt); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NPL=%u", gt->npi); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NAI=%u", gt->nai); + + append_to_buf(buf, &comma, "DIG=%s", gt->digits); + + return buf; +} + +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + append_to_buf(buf, &comma, "RI=7"); + + if (addr->presence & OSMO_SCCP_ADDR_T_PC) + append_to_buf(buf, &comma, "PC=%u", addr->pc); + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) + append_to_buf(buf, &comma, "SSN=%u", addr->ssn); + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) + append_to_buf(buf, &comma, "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, &comma, "GTI=%u", addr->gt.gti); + if (addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); + + return buf; +} -- To view, visit https://gerrit.osmocom.org/1810 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder