comparison sip-out/uac_resp.c @ 155:2730ccb44549

sip-out: initial UAC response handling
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2022 23:30:00 -0800
parents sip-out/uac_out.c@e54b0a9e322f
children 0bacca1f2f7b
comparison
equal deleted inserted replaced
154:e54b0a9e322f 155:2730ccb44549
1 /*
2 * In this module we implement our handling of SIP responses in the UAC role.
3 */
4
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <sys/time.h>
8 #include <netinet/in.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <strings.h>
14 #include <syslog.h>
15 #include "../include/gsm48_const.h"
16 #include "../include/out_routes.h"
17 #include "../libsip/parse.h"
18 #include "../libsip/resp_ident.h"
19 #include "../libsip/sdp.h"
20 #include "../libsip/out_msg.h"
21 #include "call.h"
22
23 extern struct call *find_call_by_sip_id();
24
25 void
26 process_sip_response(msg, sin)
27 struct sip_pkt_rx *msg;
28 struct sockaddr_in *sin;
29 {
30 struct sip_resp_ident rid;
31 struct call *call;
32 int rc;
33
34 rc = sip_resp_extract_ident(msg, &rid);
35 if (rc < 0) {
36 syslog(LOG_ERR, "SIP %03u response: bad or missing %s header",
37 msg->status_code, rid.error_field);
38 return;
39 }
40 call = find_call_by_sip_id(rid.call_id);
41 if (!call) {
42 syslog(LOG_ERR, "SIP %03u response: unmatched Call-ID",
43 msg->status_code);
44 return;
45 }
46 if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "INVITE"))
47 handle_invite_response(call, msg, sin);
48 else if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "CANCEL"))
49 handle_cancel_response(call, msg, sin);
50 else if (rid.cseq_num == 2 && !strcmp(rid.cseq_method, "BYE"))
51 handle_bye_response(call, msg, sin);
52 else
53 syslog(LOG_ERR,
54 "UAC received %03u response with unknown CSeq %u %.32s",
55 msg->status_code, rid.cseq_num, rid.cseq_method);
56 }