comparison sip-in/invite.c @ 109:9b87894704eb

sip-in: first step toward final call clearing
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 28 Sep 2022 16:32:13 -0800
parents 0d6435808bcd
children c1c94b7fc2e2
comparison
equal deleted inserted replaced
108:0d6435808bcd 109:9b87894704eb
2 * Here we implement our handling of SIP INVITE method. 2 * Here we implement our handling of SIP INVITE method.
3 */ 3 */
4 4
5 #include <sys/types.h> 5 #include <sys/types.h>
6 #include <sys/socket.h> 6 #include <sys/socket.h>
7 #include <sys/time.h>
7 #include <netinet/in.h> 8 #include <netinet/in.h>
8 #include <arpa/inet.h> 9 #include <arpa/inet.h>
9 #include <stdio.h> 10 #include <stdio.h>
10 #include <stdint.h> 11 #include <stdint.h>
11 #include <stdlib.h> 12 #include <stdlib.h>
24 extern struct in_addr sip_bind_ip; 25 extern struct in_addr sip_bind_ip;
25 extern unsigned sip_bind_port; 26 extern unsigned sip_bind_port;
26 extern int cfg_use_100rel; 27 extern int cfg_use_100rel;
27 extern int cfg_force_pcma; 28 extern int cfg_force_pcma;
28 extern struct call *call_list; 29 extern struct call *call_list;
30 extern unsigned sip_linger_error;
29 31
30 extern struct call *find_call_by_sip_id(); 32 extern struct call *find_call_by_sip_id();
31 extern char *get_single_header(); 33 extern char *get_single_header();
32 34
33 fill_invite_resp_from_call(msg, call) 35 fill_invite_resp_from_call(msg, call)
406 call->sip_state = SIP_STATE_MSG_SIZE_ERR; 408 call->sip_state = SIP_STATE_MSG_SIZE_ERR;
407 call->overall_state = OVERALL_STATE_TEARDOWN; 409 call->overall_state = OVERALL_STATE_TEARDOWN;
408 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, 410 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
409 GSM48_CC_CAUSE_INTERWORKING); 411 GSM48_CC_CAUSE_INTERWORKING);
410 disconnect_tmgw(call); 412 disconnect_tmgw(call);
413 sip_mark_end_time(call, sip_linger_error);
411 /* TODO: transition from TEARDOWN to DEAD_SIP */ 414 /* TODO: transition from TEARDOWN to DEAD_SIP */
412 return; 415 return;
413 } 416 }
414 if (call->use_100rel) { 417 if (call->use_100rel) {
415 rc = out_msg_add_header(&resp, "Require", "100rel"); 418 rc = out_msg_add_header(&resp, "Require", "100rel");
441 call->sip_state = SIP_STATE_MSG_SIZE_ERR; 444 call->sip_state = SIP_STATE_MSG_SIZE_ERR;
442 call->overall_state = OVERALL_STATE_TEARDOWN; 445 call->overall_state = OVERALL_STATE_TEARDOWN;
443 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, 446 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
444 GSM48_CC_CAUSE_INTERWORKING); 447 GSM48_CC_CAUSE_INTERWORKING);
445 disconnect_tmgw(call); 448 disconnect_tmgw(call);
449 sip_mark_end_time(call, sip_linger_error);
446 /* TODO: transition from TEARDOWN to DEAD_SIP */ 450 /* TODO: transition from TEARDOWN to DEAD_SIP */
447 return; 451 return;
448 } 452 }
449 sip_tx_packet(&resp, &call->udp_sin); 453 sip_tx_packet(&resp, &call->udp_sin);
450 call->sip_state = SIP_STATE_INVITE_200; 454 call->sip_state = SIP_STATE_INVITE_200;
461 start_response_out_msg(&resp, call->invite_fail); 465 start_response_out_msg(&resp, call->invite_fail);
462 rc = fill_invite_resp_from_call(&resp, call); 466 rc = fill_invite_resp_from_call(&resp, call);
463 if (rc < 0) { 467 if (rc < 0) {
464 syslog(LOG_ERR, "INVITE late error response length exceeded"); 468 syslog(LOG_ERR, "INVITE late error response length exceeded");
465 call->sip_state = SIP_STATE_MSG_SIZE_ERR; 469 call->sip_state = SIP_STATE_MSG_SIZE_ERR;
470 sip_mark_end_time(call, sip_linger_error);
466 /* TODO: transition from TEARDOWN to DEAD_SIP */ 471 /* TODO: transition from TEARDOWN to DEAD_SIP */
467 return; 472 return;
468 } 473 }
469 out_msg_finish(&resp); 474 out_msg_finish(&resp);
470 sip_tx_packet(&resp, &call->udp_sin); 475 sip_tx_packet(&resp, &call->udp_sin);