FreeCalypso > hg > osmo-playpen
diff smsc-sendmt/smsc_addr.c @ 12:7543aa173634
proto-smsc-sendmt program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 Aug 2023 16:36:28 -0800 |
parents | 18b7f75fed9b |
children |
line wrap: on
line diff
--- a/smsc-sendmt/smsc_addr.c Sun Aug 27 13:39:51 2023 -0800 +++ b/smsc-sendmt/smsc_addr.c Sun Aug 27 16:36:28 2023 -0800 @@ -1,21 +1,25 @@ /* - * This C module is being stashed here temporarily until we figure out - * where this function ultimately needs to go. The parsing of the SMSC - * address is being moved out of proto-smsc-daemon to proto-smsc-sendmt, - * but we haven't started putting together the latter program yet. + * This module handles the parsing and GSUP encoding of our SMSC address, + * which we need to send to the MSC and ultimately to the MS as SM-RP-OA. */ #include <ctype.h> #include <string.h> #include <stdio.h> +#include <stdint.h> #include <stdlib.h> -char smsc_addr_num[21]; /* maximum of 20 digits per GSM 04.11 */ -uint8_t smsc_addr_ton_npi; +#include <osmocom/gsm/gsm48_ie.h> +#include <osmocom/gsm/gsup.h> -void parse_smsc_addr_arg(char *arg) +static char smsc_addr_num[21]; /* maximum of 20 digits per GSM 04.11 */ +static uint8_t smsc_addr_ton_npi; +static uint8_t smsc_addr_bcd[12]; + +void parse_smsc_addr_arg(const char *arg) { - char *cp, *dp, *endp; + const char *cp; + char *dp, *endp; unsigned ndig; cp = arg; @@ -49,3 +53,11 @@ if (*endp) goto invalid; } + +void encode_smsc_addr(struct osmo_gsup_message *gmsg) +{ + gsm48_encode_bcd_number(smsc_addr_bcd, 11, 1, smsc_addr_num); + smsc_addr_bcd[1] = smsc_addr_ton_npi; + gmsg->sm_rp_oa = smsc_addr_bcd + 1; + gmsg->sm_rp_oa_len = smsc_addr_bcd[0]; +}