changeset 16:d9d722033ff1

sms-gen-tpdu: add support for first octet flags
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 27 Aug 2023 07:32:46 +0000
parents 5854e48d0ef7
children dc1cc851025c
files gen-pdu/input.c gen-pdu/main.c gen-pdu/message.c gen-pdu/settings.c
diffstat 4 files changed, 68 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gen-pdu/input.c	Sun Aug 27 06:43:23 2023 +0000
+++ b/gen-pdu/input.c	Sun Aug 27 07:32:46 2023 +0000
@@ -18,6 +18,11 @@
 extern void set_pid_byte();
 extern void set_dcs();
 extern void set_scts();
+extern void set_flag_rp();
+extern void set_flag_sr();
+extern void set_flag_lp();
+extern void set_flag_mms();
+extern void set_flag_rd();
 extern void cmd_msg_plain();
 extern void cmd_msg_udh();
 
@@ -33,6 +38,11 @@
 	{"pid", 1, 1, set_pid_byte},
 	{"dcs", 2, 2, set_dcs},
 	{"sc-ts", 1, 1, set_scts},
+	{"rp", 0, 0, set_flag_rp},
+	{"sr", 0, 0, set_flag_sr},
+	{"lp", 0, 0, set_flag_lp},
+	{"mms", 0, 0, set_flag_mms},
+	{"rd", 0, 0, set_flag_rd},
 	{"msg", 1, 1, cmd_msg_plain},
 	{"msg-udh", 1, 1, cmd_msg_udh},
 	/* table search terminator */
--- a/gen-pdu/main.c	Sun Aug 27 06:43:23 2023 +0000
+++ b/gen-pdu/main.c	Sun Aug 27 07:32:46 2023 +0000
@@ -13,6 +13,7 @@
 u_char mr_byte, pid_byte, dcs_byte;
 u_char scts_buf[7];
 int is_septet, scts_is_set;
+int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd;
 
 char input_line[512];
 int input_lineno;
--- a/gen-pdu/message.c	Sun Aug 27 06:43:23 2023 +0000
+++ b/gen-pdu/message.c	Sun Aug 27 07:32:46 2023 +0000
@@ -16,6 +16,7 @@
 extern u_char mr_byte, pid_byte, dcs_byte;
 extern u_char scts_buf[7];
 extern int is_septet, scts_is_set;
+extern int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd;
 
 extern int input_lineno;
 
@@ -25,11 +26,18 @@
 	u_char fo;
 
 	if (dir_mo)
-		fo = 1;
-	else
-		fo = 0;
+		fo = flag_rd ? 5 : 1;
+	else {
+		fo = flag_mms ? 0 : 4;
+		if (flag_lp)
+			fo |= 0x08;
+	}
+	if (flag_sr)
+		fo |= 0x20;
 	if (udhi)
 		fo |= 0x40;
+	if (flag_rp)
+		fo |= 0x80;
 	printf("%02X", fo);
 }
 
--- a/gen-pdu/settings.c	Sun Aug 27 06:43:23 2023 +0000
+++ b/gen-pdu/settings.c	Sun Aug 27 07:32:46 2023 +0000
@@ -15,6 +15,7 @@
 extern u_char mr_byte, pid_byte, dcs_byte;
 extern u_char scts_buf[7];
 extern int is_septet, scts_is_set;
+extern int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd;
 
 extern int input_lineno;
 
@@ -134,3 +135,48 @@
 	}
 	scts_is_set = 1;
 }
+
+void
+set_flag_rp()
+{
+	flag_rp = 1;
+}
+
+void
+set_flag_sr()
+{
+	flag_sr = 1;
+}
+
+void
+set_flag_lp()
+{
+	if (dir_mo) {
+		fprintf(stderr, ERR_PREFIX "lp is not allowed in MO mode\n",
+			input_lineno);
+		exit(1);
+	}
+	flag_lp = 1;
+}
+
+void
+set_flag_mms()
+{
+	if (dir_mo) {
+		fprintf(stderr, ERR_PREFIX "mms is not allowed in MO mode\n",
+			input_lineno);
+		exit(1);
+	}
+	flag_mms = 1;
+}
+
+void
+set_flag_rd()
+{
+	if (!dir_mo) {
+		fprintf(stderr, ERR_PREFIX "rd is not allowed in MT mode\n",
+			input_lineno);
+		exit(1);
+	}
+	flag_rd = 1;
+}