FreeCalypso > hg > sms-coding-utils
changeset 18:590b0b5bcbbb
sms-gen-tpdu: support setting VP for MO
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 Aug 2023 07:55:13 +0000 |
parents | dc1cc851025c |
children | 6a1a436747e9 |
files | gen-pdu/input.c gen-pdu/main.c gen-pdu/message.c gen-pdu/settings.c |
diffstat | 4 files changed, 54 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/gen-pdu/input.c Sun Aug 27 07:39:14 2023 +0000 +++ b/gen-pdu/input.c Sun Aug 27 07:55:13 2023 +0000 @@ -18,6 +18,8 @@ extern void set_pid_byte(); extern void set_dcs(); extern void set_scts(); +extern void set_vp_abs(); +extern void set_vp_rel(); extern void set_flag_rp(); extern void set_flag_sr(); extern void set_flag_lp(); @@ -38,6 +40,8 @@ {"pid", 1, 1, set_pid_byte}, {"dcs", 2, 2, set_dcs}, {"sc-ts", 1, 1, set_scts}, + {"vp-abs", 1, 1, set_vp_abs}, + {"vp-rel", 1, 1, set_vp_rel}, {"rp", 0, 0, set_flag_rp}, {"sr", 0, 0, set_flag_sr}, {"lp", 0, 0, set_flag_lp},
--- a/gen-pdu/main.c Sun Aug 27 07:39:14 2023 +0000 +++ b/gen-pdu/main.c Sun Aug 27 07:55:13 2023 +0000 @@ -12,6 +12,7 @@ u_char sc_addr[12], user_addr[12]; u_char mr_byte, pid_byte, dcs_byte; u_char scts_buf[7]; +u_char vp_format, vp_buf[7]; int is_septet, scts_is_set; int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd;
--- a/gen-pdu/message.c Sun Aug 27 07:39:14 2023 +0000 +++ b/gen-pdu/message.c Sun Aug 27 07:55:13 2023 +0000 @@ -15,6 +15,7 @@ extern u_char sc_addr[12], user_addr[12]; extern u_char mr_byte, pid_byte, dcs_byte; extern u_char scts_buf[7]; +extern u_char vp_format, vp_buf[7]; extern int is_septet, scts_is_set; extern int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd; @@ -25,9 +26,10 @@ { u_char fo; - if (dir_mo) + if (dir_mo) { fo = flag_rd ? 5 : 1; - else { + fo |= vp_format; + } else { fo = flag_mms ? 0 : 4; if (flag_lp) fo |= 0x08; @@ -58,7 +60,10 @@ if (!scts_is_set) set_auto_scts(); emit_hex_out(scts_buf, 7, stdout); - } + } else if (vp_format == 0x10) + printf("%02X", vp_buf[0]); + else if (vp_format) + emit_hex_out(vp_buf, 7, stdout); printf("%02X", udl); emit_hex_out(ud_buf, ud_octets, stdout); putchar('\n');
--- a/gen-pdu/settings.c Sun Aug 27 07:39:14 2023 +0000 +++ b/gen-pdu/settings.c Sun Aug 27 07:55:13 2023 +0000 @@ -14,6 +14,7 @@ extern u_char sc_addr[12], user_addr[12]; extern u_char mr_byte, pid_byte, dcs_byte; extern u_char scts_buf[7]; +extern u_char vp_format, vp_buf[7]; extern int is_septet, scts_is_set; extern int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd; @@ -137,6 +138,46 @@ } void +set_vp_abs(argc, argv) + char **argv; +{ + int rc; + + if (!dir_mo) { + fprintf(stderr, ERR_PREFIX "vp-abs is not allowed in MT mode\n", + input_lineno); + exit(1); + } + rc = encode_gsm_sms_abstime(argv[1], vp_buf); + if (rc < 0) { + fprintf(stderr, ERR_PREFIX "invalid timestamp argument\n", + input_lineno); + exit(1); + } + vp_format = 0x18; +} + +void +set_vp_rel(argc, argv) + char **argv; +{ + char *endp; + + if (!dir_mo) { + fprintf(stderr, ERR_PREFIX "vp-rel is not allowed in MT mode\n", + input_lineno); + exit(1); + } + vp_buf[0] = strtoul(argv[1], &endp, 0); + if (*endp) { + fprintf(stderr, ERR_PREFIX "invalid byte value argument\n", + input_lineno); + exit(1); + } + vp_format = 0x10; +} + +void set_flag_rp() { flag_rp = 1;