FreeCalypso > hg > themwi-system-sw
view sip-in/call_setup.c @ 118:a4450ae8fd09
sip-manual-out UAC: use the new CSeq parsing function
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Sep 2022 13:03:27 -0800 |
parents | 1bbe57df74f6 |
children |
line wrap: on
line source
/* * In this module we implement incoming call setup toward GSM. */ #include <sys/types.h> #include <sys/socket.h> #include <sys/time.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; call->mncc_state = MNCC_STATE_STARTED; syslog(LOG_DEBUG, "Call in%06u mapped to socket callref 0x%x", call->in_tag_num, call->mncc_callref); }