# HG changeset patch # User Mychaela Falconia # Date 1663468988 28800 # Node ID 75b7a7b61824a52a86006066f2f053c573f26223 # Parent e120363374125f6952220a84ae1235255d1c538f sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc diff -r e12036337412 -r 75b7a7b61824 sip-in/Makefile --- a/sip-in/Makefile Sat Sep 17 16:43:30 2022 -0800 +++ b/sip-in/Makefile Sat Sep 17 18:43:08 2022 -0800 @@ -1,8 +1,8 @@ CC= gcc CFLAGS= -O2 PROG= themwi-sip-in -OBJS= call_list.o invite.o main.o mgw_ops.o mgw_sock.o mncc_sock.o readconf.o\ - sip_log.o sip_uas.o sip_udp.o +OBJS= call_list.o call_setup.o invite.o main.o mgw_ops.o mgw_sock.o \ + mncc_sock.o readconf.o sip_log.o sip_uas.o sip_udp.o LIBS= ../libnumdb/libnumdb.a ../libsip/libsip.a ../libutil/libutil.a INSTBIN=/usr/local/bin diff -r e12036337412 -r 75b7a7b61824 sip-in/call.h --- a/sip-in/call.h Sat Sep 17 16:43:30 2022 -0800 +++ b/sip-in/call.h Sat Sep 17 18:43:08 2022 -0800 @@ -38,6 +38,8 @@ uint32_t sdp_addend; char invite_fail[80]; unsigned sip_tx_count; + int mncc_active; + uint32_t mncc_callref; }; #define OVERALL_STATE_CRCX 1 diff -r e12036337412 -r 75b7a7b61824 sip-in/call_list.c --- a/sip-in/call_list.c Sat Sep 17 16:43:30 2022 -0800 +++ b/sip-in/call_list.c Sat Sep 17 18:43:08 2022 -0800 @@ -26,3 +26,30 @@ return call; return 0; } + +struct call * +find_call_by_mncc_callref(callref) + uint32_t callref; +{ + struct call *call; + + for (call = call_list; call; call = call->next) + if (call->mncc_active && call->mncc_callref == callref) + return call; + return 0; +} + +allocate_mncc_callref(call) + struct call *call; +{ + static uint32_t next_callref; + + for (;;) { + next_callref++; + if (!find_call_by_mncc_callref(next_callref)) { + call->mncc_active = 1; + call->mncc_callref = next_callref; + return(0); + } + } +} diff -r e12036337412 -r 75b7a7b61824 sip-in/call_setup.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sip-in/call_setup.c Sat Sep 17 18:43:08 2022 -0800 @@ -0,0 +1,70 @@ +/* + * In this module we implement incoming call setup toward GSM. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/mncc.h" +#include "../include/gsm48_const.h" +#include "call.h" + +static void +fill_calling_number(from, caller) + char *from; + struct gsm_mncc_number *caller; +{ + char *num; + int cc; + + if (!strcasecmp(from, "Restricted")) { + caller->present = GSM48_PRES_RESTR; + return; + } + if (*from == '+') + num = from + 1; + else + num = from; + cc = grok_number_string(num, 0); + if (cc < 1 || cc > 32) { + /* not a valid number */ + caller->present = GSM48_PRES_UNAVAIL; + return; + } + /* accept "From" user as a valid number */ + strcpy(caller->number, num); + caller->plan = GSM48_NPI_ISDN_E164; + if (*from == '+') + caller->type = GSM48_TON_INTERNATIONAL; +} + +void +proceed_with_call_setup(call) + struct call *call; +{ + struct gsm_mncc setup_msg; + + allocate_mncc_callref(call); + bzero(&setup_msg, sizeof setup_msg); + setup_msg.msg_type = MNCC_SETUP_REQ; + setup_msg.callref = call->mncc_callref; + /* fill called number */ + setup_msg.called.type = GSM48_TON_INTERNATIONAL; + setup_msg.called.plan = GSM48_NPI_ISDN_E164; + setup_msg.called.number[0] = '1'; + strcpy(setup_msg.called.number+1, call->called_nanp); + setup_msg.fields |= MNCC_F_CALLED; + /* fill calling number */ + call->from_user[call->from_user_len] = '\0'; + fill_calling_number(call->from_user, &setup_msg.calling); + call->from_user[call->from_user_len] = '@'; + setup_msg.fields |= MNCC_F_CALLING; + send_mncc_to_gsm(&setup_msg, sizeof(struct gsm_mncc)); + call->overall_state = OVERALL_STATE_CALL_GSM; +} diff -r e12036337412 -r 75b7a7b61824 sip-in/mgw_ops.c --- a/sip-in/mgw_ops.c Sat Sep 17 16:43:30 2022 -0800 +++ b/sip-in/mgw_ops.c Sat Sep 17 18:43:08 2022 -0800 @@ -123,7 +123,7 @@ sizeof(struct sockaddr_in)); switch (call->overall_state) { case OVERALL_STATE_CRCX: - /* proceed_with_call_setup(call); */ + proceed_with_call_setup(call); return; case OVERALL_STATE_TEARDOWN: tmgw_send_dlcx(call);