FreeCalypso > hg > themwi-system-sw
comparison sip-in/bye_out.c @ 94:2c22b40408fb
sip-in BYE UAC: use new libsip function for response ident
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 24 Sep 2022 15:14:50 -0800 |
parents | a9137bdb6047 |
children | 9b87894704eb |
comparison
equal
deleted
inserted
replaced
93:ff5e96162430 | 94:2c22b40408fb |
---|---|
11 #include <stdlib.h> | 11 #include <stdlib.h> |
12 #include <string.h> | 12 #include <string.h> |
13 #include <strings.h> | 13 #include <strings.h> |
14 #include <syslog.h> | 14 #include <syslog.h> |
15 #include "../libsip/parse.h" | 15 #include "../libsip/parse.h" |
16 #include "../libsip/resp_ident.h" | |
16 #include "../libsip/out_msg.h" | 17 #include "../libsip/out_msg.h" |
17 #include "call.h" | 18 #include "call.h" |
18 | 19 |
19 extern char *get_single_header(); | |
20 extern struct call *find_call_by_sip_id(); | 20 extern struct call *find_call_by_sip_id(); |
21 | 21 |
22 extern struct in_addr sip_bind_ip; | 22 extern struct in_addr sip_bind_ip; |
23 extern unsigned sip_bind_port; | 23 extern unsigned sip_bind_port; |
24 extern unsigned max_forwards; | 24 extern unsigned max_forwards; |
81 void | 81 void |
82 process_sip_response(msg, sin) | 82 process_sip_response(msg, sin) |
83 struct sip_pkt_rx *msg; | 83 struct sip_pkt_rx *msg; |
84 struct sockaddr_in *sin; | 84 struct sockaddr_in *sin; |
85 { | 85 { |
86 char *call_id_hdr, *cseq_hdr; | 86 struct sip_resp_ident rid; |
87 struct call *call; | 87 struct call *call; |
88 int rc; | |
88 | 89 |
89 call_id_hdr = get_single_header(msg, "Call-ID", "i", (int *) 0); | 90 rc = sip_resp_extract_ident(msg, &rid); |
90 if (!call_id_hdr) | 91 if (rc < 0) { |
92 syslog(LOG_ERR, "SIP %03u response: bad or missing %s header", | |
93 msg->status_code, rid.error_field); | |
91 return; | 94 return; |
92 call = find_call_by_sip_id(call_id_hdr); | 95 } |
93 if (!call) | 96 call = find_call_by_sip_id(rid.call_id); |
97 if (!call) { | |
98 syslog(LOG_ERR, "SIP %03u response: unmatched Call-ID", | |
99 msg->status_code); | |
94 return; | 100 return; |
95 cseq_hdr = get_single_header(msg, "CSeq", (char *) 0, (int *) 0); | 101 } |
96 if (!cseq_hdr) | 102 if (rid.cseq_num != 1 || strcmp(rid.cseq_method, "BYE")) { |
97 return; | |
98 if (strcmp(cseq_hdr, "1 BYE")) { | |
99 syslog(LOG_ERR, | 103 syslog(LOG_ERR, |
100 "UAC received response with unknown CSeq %.32s", | 104 "UAC received %03u response with unknown CSeq %u %.32s", |
101 cseq_hdr); | 105 msg->status_code, rid.cseq_num, rid.cseq_method); |
102 return; | 106 return; |
103 } | 107 } |
104 if (msg->status_code < 200) | 108 if (msg->status_code < 200) |
105 return; | 109 return; |
106 if (call->sip_state == SIP_STATE_BYE_SENT) | 110 if (call->sip_state == SIP_STATE_BYE_SENT) |