FreeCalypso > hg > themwi-system-sw
changeset 243:59a166c50d0e
themwi-mncc: convert to libnumdb2
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 14 Aug 2023 19:13:26 -0800 |
parents | f86ec96cea6f |
children | db366c3b35f7 |
files | mncc/Makefile mncc/call_setup.c |
diffstat | 2 files changed, 51 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mncc/Makefile Mon Aug 14 15:44:33 2023 -0800 +++ b/mncc/Makefile Mon Aug 14 19:13:26 2023 -0800 @@ -3,7 +3,7 @@ PROG= themwi-mncc OBJS= call_setup.o extsock.o gsm_call.o intswitch.o main.o mncc_recv.o \ mncc_sock.o mtsock.o outcall.o -LIBS= ../libnumdb/libnumdb.a ../libutil/libutil.a +LIBS= ../libnumdb2/libnumdb.a ../libutil/libutil.a INSTBIN=/usr/local/bin all: ${PROG}
--- a/mncc/call_setup.c Mon Aug 14 15:44:33 2023 -0800 +++ b/mncc/call_setup.c Mon Aug 14 19:13:26 2023 -0800 @@ -13,6 +13,8 @@ #include <syslog.h> #include "../include/mncc.h" #include "../include/gsm48_const.h" +#include "../include/number_db_v2.h" +#include "../libnumdb2/lookup_func.h" #include "struct.h" #include "gsm_call.h" @@ -58,8 +60,9 @@ struct gsm_mncc *msg; { struct gsm_call *call; - char nanp[11]; - int res, is_nanp, is_itn, is_local; + struct owned_number_rec *own; + struct short_number_rec *snum; + int is_nanp, is_itn, is_local; if (preen_msc_provided_number(&msg->calling)) msg->fields |= MNCC_F_CALLING; @@ -93,26 +96,46 @@ msg->called.plan != GSM48_NPI_ISDN_E164 && msg->called.plan != GSM48_NPI_PRIVATE) break; - res = lookup_short_dial_number(msg->called.number, nanp); - if (!res) { + snum = numdb_lookup_short(msg->called.number); + if (!snum) { syslog(LOG_ERR, - "rejecting MO call 0x%x: invalid short number", + "rejecting MO call 0x%x: unassigned short number", msg->callref); reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, GSM48_CC_CAUSE_UNASSIGNED_NR); call->gc_flag = 1; return; } - if (nanp[0]) { + switch (snum->short_num_type) { + case SHORT_NUM_TYPE_ABBREV: is_nanp = 1; msg->called.type = GSM48_TON_INTERNATIONAL; msg->called.plan = GSM48_NPI_ISDN_E164; - msg->called.number[0] = '1'; - strcpy(msg->called.number+1, nanp); - } else { + sprintf(msg->called.number, "1%03u%03u%04u", + snum->fullnum_prefix[0], + snum->fullnum_prefix[1], snum->short_num); + break; + case SHORT_NUM_TYPE_ITN: is_itn = 1; msg->called.type = GSM48_TON_NET_SPEC; msg->called.plan = GSM48_NPI_PRIVATE; + break; + case SHORT_NUM_TYPE_TEST_SINK: + syslog(LOG_ERR, + "rejecting MO call 0x%x: test sink not implemented", + msg->callref); + reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_DEST_OOO); + call->gc_flag = 1; + return; + default: + syslog(LOG_ERR, + "rejecting MO call 0x%x: unknown short number type 0x%02X", + msg->callref, snum->short_num_type); + reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_DEST_OOO); + call->gc_flag = 1; + return; } break; case 10: @@ -164,8 +187,25 @@ break; } is_local = is_itn; - if (is_nanp && is_nanp_locally_owned(msg->called.number+1)) + if (is_nanp && (own = numdb_lookup_nanp(msg->called.number+1))) { is_local = 1; + switch (own->usage & NUMBER_USAGE_MASK) { + case NUMBER_USAGE_TYPE_GSM_SUB: + break; + case NUMBER_USAGE_TYPE_ALIAS: + sprintf(msg->called.number, "1%03u%03u%04u", + own->remap[0], own->remap[1], own->remap[2]); + break; + default: + syslog(LOG_ERR, + "rejecting MO call 0x%x: unassigned owned NANP", + msg->callref); + reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_UNASSIGNED_NR); + call->gc_flag = 1; + return; + } + } /* weed out attempts to call yourself */ if (is_local && !strcmp(msg->calling.number, msg->called.number)) { syslog(LOG_ERR, "rejecting MO call 0x%x: call to self",