pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/41402?usp=email )
Change subject: mtp: Improve Network Indicator definitions ......................................................................
mtp: Improve Network Indicator definitions
Change-Id: I0a7e113ac89946e5cf3bec8bec07ad10ee38723d --- M TODO-RELEASE M include/osmocom/sigtran/mtp_sap.h M include/osmocom/sigtran/protocol/mtp.h M src/ss7_instance.h M src/ss7_vty.c 5 files changed, 22 insertions(+), 10 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
diff --git a/TODO-RELEASE b/TODO-RELEASE index 2d94ad1..a89255b 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -8,3 +8,4 @@ # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line libosmo-netif >1.6.0 stream OSMO_STREAM_{CLI,SRV}_TCP_SOCKOPT_KEEP* +libosmo-sigtran add enum mtp_network_indicator, mtp_network_indicator_vals diff --git a/include/osmocom/sigtran/mtp_sap.h b/include/osmocom/sigtran/mtp_sap.h index 0ae8592..05308c2 100644 --- a/include/osmocom/sigtran/mtp_sap.h +++ b/include/osmocom/sigtran/mtp_sap.h @@ -31,6 +31,7 @@ OSMO_MTP_PRIM_STATUS, };
+/* ITU Q.704 14.2 Service information octet. See enum mtp_si_ni00 in mtp.h. */ #define MTP_SIO(service, net_ind) (((net_ind & 0x3) << 6) | (service & 0xF))
struct osmo_mtp_transfer_param { diff --git a/include/osmocom/sigtran/protocol/mtp.h b/include/osmocom/sigtran/protocol/mtp.h index 9654a66..21e3d60 100644 --- a/include/osmocom/sigtran/protocol/mtp.h +++ b/include/osmocom/sigtran/protocol/mtp.h @@ -21,9 +21,17 @@ MTP_SI_BICC = 13, MTP_SI_GCP = 14, }; - extern const struct value_string mtp_si_vals[];
+/* Q.704 14.2.2 Sub-service field (Network Indicator) */ +enum mtp_network_indicator { + MTP_NI_INTERNATIONAL = 0, + MTP_NI_SPARE_INTERNATIONAL = 1, + MTP_NI_NATIONAL = 2, + MTP_NI_RESERVED_NATIONAL = 3 +}; +extern const struct value_string mtp_network_indicator_vals[]; +
/* Q.704 15.17.5 */ enum mtp_unavail_cause { diff --git a/src/ss7_instance.h b/src/ss7_instance.h index bb8815b..e7e25ef 100644 --- a/src/ss7_instance.h +++ b/src/ss7_instance.h @@ -4,6 +4,8 @@ #include <stdbool.h> #include <osmocom/core/linuxlist.h>
+#include <osmocom/sigtran/protocol/mtp.h> + /*********************************************************************** * SS7 Instances ***********************************************************************/ @@ -45,7 +47,7 @@ char *description; uint32_t primary_pc; /* capability PCs */ - uint8_t network_indicator; + enum mtp_network_indicator network_indicator; struct osmo_ss7_pc_fmt pc_fmt; bool permit_dyn_rkm_alloc; struct llist_head sccp_address_book; diff --git a/src/ss7_vty.c b/src/ss7_vty.c index b333c7f..cfc658d 100644 --- a/src/ss7_vty.c +++ b/src/ss7_vty.c @@ -107,11 +107,11 @@ return CMD_SUCCESS; }
-static const struct value_string ss7_network_indicator_vals[] = { - { 0, "international" }, - { 1, "spare" }, - { 2, "national" }, - { 3, "reserved" }, +const struct value_string mtp_network_indicator_vals[] = { + { MTP_NI_INTERNATIONAL, "international" }, + { MTP_NI_SPARE_INTERNATIONAL, "spare" }, + { MTP_NI_NATIONAL, "national" }, + { MTP_NI_RESERVED_NATIONAL, "reserved" }, { 0, NULL } };
@@ -126,7 +126,7 @@ CMD_ATTR_IMMEDIATE) { struct osmo_ss7_instance *inst = vty->index; - int ni = get_string_value(ss7_network_indicator_vals, argv[0]); + int ni = get_string_value(mtp_network_indicator_vals, argv[0]);
inst->cfg.network_indicator = ni; return CMD_SUCCESS; @@ -1286,9 +1286,9 @@ vty_out(vty, "cs7 instance %u%s", inst->cfg.id, VTY_NEWLINE); if (inst->cfg.description) vty_out(vty, " description %s%s", inst->cfg.description, VTY_NEWLINE); - if (inst->cfg.network_indicator) + if (inst->cfg.network_indicator != MTP_NI_INTERNATIONAL) vty_out(vty, " network-indicator %s%s", - get_value_string(ss7_network_indicator_vals, + get_value_string(mtp_network_indicator_vals, inst->cfg.network_indicator), VTY_NEWLINE);