diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-14 16:06:46 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2016-03-15 14:10:45 +0100 |
commit | 282e90843476989629f8ae7e36e4a59b69da40eb (patch) | |
tree | b34952010bd0aadb8ad6db7ebe8ebddbca5f53aa /include | |
parent | c0d9a6c083aa7e35174093c7a7265319bf993a9d (diff) |
04.08: add inline funcs for pdisc + msg type bitmasks
Add inline functions for both release <= 98 and release >= 99 as well as a
default define. Use the release 98 by default since the current code base uses
the r98 bitmasks.
These inline functions relieve callers of the decision on masking bits of the
protocol discriminator and message type octets.
Also add a define for the protocol discriminator extension to one octet length
(GSM48_PDISC_EXTEND).
Apply new pdisc function in gsm0480.c.
[hfreyther: Make the hdr param const]
Diffstat (limited to 'include')
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_04_08.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index eefaf2bc..23d2077c 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -747,9 +747,65 @@ struct gsm48_rr_status { #define GSM48_PDISC_SM_GPRS 0x0a #define GSM48_PDISC_NC_SS 0x0b #define GSM48_PDISC_LOC 0x0c +#define GSM48_PDISC_EXTEND 0x0e #define GSM48_PDISC_MASK 0x0f #define GSM48_PDISC_USSD 0x11 +static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.1.1 Protocol discriminator + */ + uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK; + if (pdisc == GSM48_PDISC_EXTEND) + return hdr->proto_discr; + return pdisc; +} + +static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.2.1 Message type octet (when accessing Release 98 and older + * networks only) + */ + switch (gsm48_hdr_pdisc(hdr)) { + case GSM48_PDISC_MM: + case GSM48_PDISC_CC: + case GSM48_PDISC_NC_SS: + case GSM48_PDISC_GROUP_CC: + case GSM48_PDISC_BCAST_CC: + case GSM48_PDISC_LOC: + return hdr->msg_type & 0xbf; + default: + return hdr->msg_type; + } +} + +static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer + * networks) + */ + switch (gsm48_hdr_pdisc(hdr)) { + case GSM48_PDISC_MM: + case GSM48_PDISC_CC: + return hdr->msg_type & 0x3f; + case GSM48_PDISC_NC_SS: + case GSM48_PDISC_GROUP_CC: + case GSM48_PDISC_BCAST_CC: + case GSM48_PDISC_LOC: + return hdr->msg_type & 0xbf; + default: + return hdr->msg_type; + } +} + +#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r98 + /* Section 10.4 */ #define GSM48_MT_RR_INIT_REQ 0x3c #define GSM48_MT_RR_ADD_ASS 0x3b |