FreeCalypso > hg > themwi-system-sw
comparison sip-in/bye_out.c @ 82:ff4b76a107a1
sip-in: process responses as UAC for BYE
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 20 Sep 2022 20:33:09 -0800 |
parents | 915f0f397fb6 |
children | a9137bdb6047 |
comparison
equal
deleted
inserted
replaced
81:915f0f397fb6 | 82:ff4b76a107a1 |
---|---|
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/out_msg.h" | 16 #include "../libsip/out_msg.h" |
17 #include "call.h" | 17 #include "call.h" |
18 | |
19 extern char *get_single_header(); | |
20 extern struct call *find_call_by_sip_id(); | |
18 | 21 |
19 extern struct in_addr sip_bind_ip; | 22 extern struct in_addr sip_bind_ip; |
20 extern unsigned sip_bind_port; | 23 extern unsigned sip_bind_port; |
21 | 24 |
22 fill_bye_out_msg(msg, call) | 25 fill_bye_out_msg(msg, call) |
70 } | 73 } |
71 sip_tx_packet(&msg, &call->udp_sin); | 74 sip_tx_packet(&msg, &call->udp_sin); |
72 call->sip_state = SIP_STATE_BYE_SENT; | 75 call->sip_state = SIP_STATE_BYE_SENT; |
73 call->sip_tx_count = 1; | 76 call->sip_tx_count = 1; |
74 } | 77 } |
78 | |
79 void | |
80 process_sip_response(msg, sin) | |
81 struct sip_pkt_rx *msg; | |
82 struct sockaddr_in *sin; | |
83 { | |
84 char *call_id_hdr, *cseq_hdr; | |
85 struct call *call; | |
86 | |
87 call_id_hdr = get_single_header(msg, "Call-ID", "i", (int *) 0); | |
88 if (!call_id_hdr) | |
89 return; | |
90 call = find_call_by_sip_id(call_id_hdr); | |
91 if (!call) | |
92 return; | |
93 cseq_hdr = get_single_header(msg, "CSeq", (char *) 0, (int *) 0); | |
94 if (!cseq_hdr) | |
95 return; | |
96 if (strcmp(cseq_hdr, "1 BYE")) { | |
97 syslog(LOG_ERR, | |
98 "UAC received response with unknown CSeq %.32s", | |
99 cseq_hdr); | |
100 return; | |
101 } | |
102 if (msg->status_code < 200) | |
103 return; | |
104 if (call->sip_state == SIP_STATE_BYE_SENT) | |
105 call->sip_state = SIP_STATE_ENDED; | |
106 } |