FreeCalypso > hg > themwi-system-sw
diff sip-in/call_setup.c @ 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 | |
children | e5aee661e3b2 |
line wrap: on
line diff
--- /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; +}