FreeCalypso > hg > themwi-system-sw
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 61:e12036337412 | 62:75b7a7b61824 |
|---|---|
| 1 /* | |
| 2 * In this module we implement incoming call setup toward GSM. | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include <sys/socket.h> | |
| 7 #include <netinet/in.h> | |
| 8 #include <stdio.h> | |
| 9 #include <stdint.h> | |
| 10 #include <stdlib.h> | |
| 11 #include <string.h> | |
| 12 #include <strings.h> | |
| 13 #include <syslog.h> | |
| 14 #include "../include/mncc.h" | |
| 15 #include "../include/gsm48_const.h" | |
| 16 #include "call.h" | |
| 17 | |
| 18 static void | |
| 19 fill_calling_number(from, caller) | |
| 20 char *from; | |
| 21 struct gsm_mncc_number *caller; | |
| 22 { | |
| 23 char *num; | |
| 24 int cc; | |
| 25 | |
| 26 if (!strcasecmp(from, "Restricted")) { | |
| 27 caller->present = GSM48_PRES_RESTR; | |
| 28 return; | |
| 29 } | |
| 30 if (*from == '+') | |
| 31 num = from + 1; | |
| 32 else | |
| 33 num = from; | |
| 34 cc = grok_number_string(num, 0); | |
| 35 if (cc < 1 || cc > 32) { | |
| 36 /* not a valid number */ | |
| 37 caller->present = GSM48_PRES_UNAVAIL; | |
| 38 return; | |
| 39 } | |
| 40 /* accept "From" user as a valid number */ | |
| 41 strcpy(caller->number, num); | |
| 42 caller->plan = GSM48_NPI_ISDN_E164; | |
| 43 if (*from == '+') | |
| 44 caller->type = GSM48_TON_INTERNATIONAL; | |
| 45 } | |
| 46 | |
| 47 void | |
| 48 proceed_with_call_setup(call) | |
| 49 struct call *call; | |
| 50 { | |
| 51 struct gsm_mncc setup_msg; | |
| 52 | |
| 53 allocate_mncc_callref(call); | |
| 54 bzero(&setup_msg, sizeof setup_msg); | |
| 55 setup_msg.msg_type = MNCC_SETUP_REQ; | |
| 56 setup_msg.callref = call->mncc_callref; | |
| 57 /* fill called number */ | |
| 58 setup_msg.called.type = GSM48_TON_INTERNATIONAL; | |
| 59 setup_msg.called.plan = GSM48_NPI_ISDN_E164; | |
| 60 setup_msg.called.number[0] = '1'; | |
| 61 strcpy(setup_msg.called.number+1, call->called_nanp); | |
| 62 setup_msg.fields |= MNCC_F_CALLED; | |
| 63 /* fill calling number */ | |
| 64 call->from_user[call->from_user_len] = '\0'; | |
| 65 fill_calling_number(call->from_user, &setup_msg.calling); | |
| 66 call->from_user[call->from_user_len] = '@'; | |
| 67 setup_msg.fields |= MNCC_F_CALLING; | |
| 68 send_mncc_to_gsm(&setup_msg, sizeof(struct gsm_mncc)); | |
| 69 call->overall_state = OVERALL_STATE_CALL_GSM; | |
| 70 } |
