pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/43833?usp=email )
Change subject: mtp_sap.h: Introduce new MTP_SIO helpers and use them internally ......................................................................
mtp_sap.h: Introduce new MTP_SIO helpers and use them internally
Change-Id: I07a7102b8671482f636fe9e6d41f6d4525f39c85 --- M TODO-RELEASE M include/osmocom/sigtran/mtp_sap.h M src/m3ua.c M src/tcap_as_loadshare.c 4 files changed, 14 insertions(+), 8 deletions(-)
Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved laforge: Looks good to me, but someone else must approve
diff --git a/TODO-RELEASE b/TODO-RELEASE index ac06fda..a6d47f9 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -10,3 +10,4 @@ libosmocore >1.14.2 new VTY node L_CS7_QOS_CLASS_NODE added libosmo-sigtran added enum osmo_sccp_reset_reason_*, enum osmo_sccp_release_reason_* libosmo-sigtran added enum osmo_sccp_return_reason +libosmo-sigtran added MTP_SIO_*() diff --git a/include/osmocom/sigtran/mtp_sap.h b/include/osmocom/sigtran/mtp_sap.h index 1816b2d..3be178a 100644 --- a/include/osmocom/sigtran/mtp_sap.h +++ b/include/osmocom/sigtran/mtp_sap.h @@ -37,7 +37,14 @@ }
/* 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)) +#define MTP_SIO_EXT(service, net_ind, mp) \ + ((((net_ind) & 0x3) << 6) | \ + (((mp) & 0x3) << 4) | \ + ((service) & 0xf)) +#define MTP_SIO(service, net_ind) MTP_SIO_EXT(service, net_ind, 0) +#define MTP_SIO_NI(sio) (((sio) >> 6) & 0x3) +#define MTP_SIO_MP(sio) (((sio) >> 4) & 0x3) +#define MTP_SIO_SI(sio) ((sio) & 0xf)
struct osmo_mtp_transfer_param { uint32_t opc; diff --git a/src/m3ua.c b/src/m3ua.c index 973e1cd..39272ee 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -526,9 +526,9 @@ { mdh->opc = htonl(param->opc); mdh->dpc = htonl(param->dpc); - mdh->si = param->sio & 0xF; - mdh->ni = (param->sio >> 6) & 0x3; - mdh->mp = (param->sio >> 4) & 0x3; + mdh->si = MTP_SIO_SI(param->sio); + mdh->ni = MTP_SIO_NI(param->sio); + mdh->mp = MTP_SIO_MP(param->sio); mdh->sls = param->sls; }
@@ -540,9 +540,7 @@ param->dpc = ntohl(mdh->dpc); param->sls = mdh->sls; /* re-construct SIO */ - param->sio = (mdh->si & 0xF) | - ((mdh->mp & 0x3) << 4) | - ((mdh->ni & 0x3) << 6); + param->sio = MTP_SIO_EXT(mdh->si, mdh->ni, mdh->mp); }
struct msgb *m3ua_msgb_alloc(const char *name) diff --git a/src/tcap_as_loadshare.c b/src/tcap_as_loadshare.c index b699281..5e8cbb8 100644 --- a/src/tcap_as_loadshare.c +++ b/src/tcap_as_loadshare.c @@ -736,7 +736,7 @@ /* return 0 and asp is set */ int tcap_as_select_asp_loadshare(struct osmo_ss7_asp **asp, struct osmo_ss7_as *as, const struct xua_msg *xua) { - uint8_t service_ind = xua->mtp.sio & 0xF; + uint8_t service_ind = MTP_SIO_SI(xua->mtp.sio); struct xua_msg_part *m3ua_data_ie; struct msgb *sccp_msg; uint8_t *cur;