FreeCalypso > hg > themwi-system-sw
changeset 62:75b7a7b61824
sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 17 Sep 2022 18:43:08 -0800 |
parents | e12036337412 |
children | e5aee661e3b2 |
files | sip-in/Makefile sip-in/call.h sip-in/call_list.c sip-in/call_setup.c sip-in/mgw_ops.c |
diffstat | 5 files changed, 102 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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); + } + } +}
--- /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 <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <syslog.h> +#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; +}
--- 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);