From ba5a9b922477ff939cdffc4dbb785a8c8e1e5657 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 4 Nov 2019 15:41:32 +0100 Subject: gsm: gsm_04_08.h: Allow accessing classmark2 as struct instead of uint32_t New fields are put inside a union to keep backward compatibility with potential older users of the struct. Change-Id: I235635800c0de47b1e2b9ec9c7191418f6003554 --- include/osmocom/gsm/protocol/gsm_04_08.h | 33 +++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 68ec4e3e..8370eca1 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -889,13 +889,25 @@ struct gsm48_pag_resp { #if OSMO_IS_LITTLE_ENDIAN uint8_t spare:4, key_seq:4; - uint32_t classmark2; + union { + uint32_t classmark2; /* Backward compatibility */ + struct { + uint8_t cm2_len; + struct gsm48_classmark2 cm2; + }; + }; uint8_t mi_len; uint8_t mi[0]; #elif OSMO_IS_BIG_ENDIAN /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ uint8_t key_seq:4, spare:4; - uint32_t classmark2; + union { + uint32_t classmark2; /* Backward compatibility */ + struct { + uint8_t cm2_len; + struct gsm48_classmark2 cm2; + }; + }; uint8_t mi_len; uint8_t mi[0]; #endif @@ -1027,15 +1039,26 @@ struct gsm48_service_request { #if OSMO_IS_LITTLE_ENDIAN uint8_t cm_service_type : 4, cipher_key_seq : 4; - /* length + 3 bytes */ - uint32_t classmark; + union { + uint32_t classmark; /* Backward compatibility */ + struct { + uint8_t cm2_len; + struct gsm48_classmark2 classmark2; + }; + }; uint8_t mi_len; uint8_t mi[0]; /* optional priority level */ #elif OSMO_IS_BIG_ENDIAN /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ uint8_t cipher_key_seq:4, cm_service_type:4; - uint32_t classmark; + union { + uint32_t classmark; /* Backward compatibility */ + struct { + uint8_t cm2_len; + struct gsm48_classmark2 classmark2; + }; + }; uint8_t mi_len; uint8_t mi[0]; #endif -- cgit v1.2.3