FreeCalypso > hg > themwi-system-sw
view sip-in/call_setup.c @ 104:ce3b1db7d1d7
sip-in: force-pcma-codec config option to use PCMA when both are offered
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 27 Sep 2022 21:52:07 -0800 |
parents | e5aee661e3b2 |
children | 9b87894704eb |
line wrap: on
line source
/* * 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; call->mncc_state = MNCC_STATE_STARTED; }