gsm0480: fix USSD OCTET STRING length confusion
According to the GSM 04.80 (version 5.0.0) specification Annex A
"Expanded ASN.1 Module "SS-Protocol", the maximum size of a USSD
OCTET STRING is 160 bytes.
Thus according to ETSI TS 123 038 (version 10.0.0) specification
6.1.2.3 "USSD packing of 7 bit characters", in 160 octets, it's
possible to pack (160 * 8) / 7 = 182.8, that is 182 characters.
The remaining 6 bits are set to zero.
This change defines both mentioned values:
- GSM0480_USSD_OCTET_STRING_LEN 160
- GSM0480_USSD_7BIT_STRING_LEN 182
keeping the old MAX_LEN_USSD_STRING 'as is' due to compatibility
reasons. Now the new value is used for ss_request structure, while
old one is still used for deprecated ussd_request structure.
Change-Id: I6dead74f9ecea079752ff2400cdaf7c30187784e
diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index 672ffe5..0dfd868 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -7,7 +7,27 @@
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/protocol/gsm_04_80.h>
-#define MAX_LEN_USSD_STRING 31
+/**
+ * According to the GSM 04.80 (version 5.0.0) specification Annex A
+ * "Expanded ASN.1 Module "SS-Protocol", the maximum size of a USSD
+ * OCTET STRING field is 160 bytes.
+ */
+#define GSM0480_USSD_OCTET_STRING_LEN 160
+
+/**
+ * Thus according to ETSI TS 123 038 (version 10.0.0) specification
+ * 6.1.2.3 "USSD packing of 7 bit characters", in 160 octets, it's
+ * possible to pack (160 * 8) / 7 = 182.8, that is 182 characters.
+ * The remaining 6 bits are set to zero.
+ */
+#define GSM0480_USSD_7BIT_STRING_LEN 182
+
+/**
+ * DEPRECATED: this definition doesn't follow any specification,
+ * so we only keep it for compatibility reasons. It's strongly
+ * recommended to use correct definitions above.
+ */
+#define MAX_LEN_USSD_STRING 31
/* deprecated */
struct ussd_request {
@@ -23,7 +43,7 @@
struct ss_request {
uint8_t opcode;
uint8_t ss_code;
- uint8_t ussd_text[MAX_LEN_USSD_STRING + 1];
+ uint8_t ussd_text[GSM0480_USSD_OCTET_STRING_LEN];
uint8_t transaction_id;
uint8_t invoke_id;
};