Browse code

smsops: fix parsing of validity period

- Validity period is present only for SUBMIT
msg type and it is an optional parameter.
For now supports only Relative VP format.

(cherry picked from commit c4b1d0ab700ea03869114d08daa78ab6a6a56b96)
(cherry picked from commit 5d47465d6791f6213994ae77089d1569a2ea0bf4)

Aleksandar Yosifov authored on 17/03/2021 10:45:20 • Henning Westerholt committed on 22/10/2021 11:29:25
Showing 1 changed files
... ...
@@ -173,6 +173,10 @@ void freeRP_DATA(sms_rp_data_t * rpdata) {
173 173
 #define BITMASK_HIGH_4BITS 0xF0
174 174
 #define BITMASK_LOW_4BITS 0x0F
175 175
 #define BITMASK_TP_UDHI 0x40
176
+#define BITMASK_TP_VPF 0x18
177
+#define BITMASK_TP_VPF_RELATIVE 0x10 
178
+#define BITMASK_TP_VPF_ENHANCED 0x08
179
+#define BITMASK_TP_VPF_ABSOLUTE 0x18
176 180
 
177 181
 // Encode SMS-Message by merging 7 bit ASCII characters into 8 bit octets.
178 182
 static int ascii_to_gsm(str sms, char * output_buffer, int buffer_size) {
... ...
@@ -525,7 +529,27 @@ int decode_3gpp_sms(struct sip_msg *msg) {
525 529
 				}
526 530
 				rp_data->pdu.pid = (unsigned char)body.s[p++];
527 531
 				rp_data->pdu.coding = (unsigned char)body.s[p++];
528
-				rp_data->pdu.validity = (unsigned char)body.s[p++];
532
+
533
+				// 3GPP TS 03.40 9.2.2.2 SMS SUBMIT type
534
+				// https://en.wikipedia.org/wiki/GSM_03.40
535
+				if(rp_data->pdu.msg_type == SUBMIT){
536
+					// 3GPP TS 03.40 9.2.3.3 TP Validity Period Format (TP VPF)
537
+					switch (rp_data->pdu.flags & BITMASK_TP_VPF){
538
+						case BITMASK_TP_VPF_RELATIVE:	// 3GPP TS 03.40 9.2.3.12.1 TP-VP (Relative format)
539
+							rp_data->pdu.validity = (unsigned char)body.s[p++];
540
+							break;
541
+						case BITMASK_TP_VPF_ENHANCED:	// 3GPP TS 03.40 9.2.3.12.2 TP-VP (Absolute format)
542
+							p += 7;
543
+							LM_WARN("3GPP TS 03.40 9.2.3.12.2 TP-VP (Absolute format) is not supported\n");
544
+							break;
545
+						case BITMASK_TP_VPF_ABSOLUTE:	// 3GPP TS 03.40 9.2.3.12.3 TP-VP (Enhanced format)
546
+							p += 7;
547
+							LM_WARN("3GPP TS 03.40 9.2.3.12.3 TP-VP (Enhanced format) is not supported\n");
548
+							break;
549
+						default:
550
+							break;
551
+					}
552
+				}
529 553
 
530 554
 				//TP-User-Data-Length and TP-User-Data
531 555
 				len = (unsigned char)body.s[p++];