FreeCalypso > hg > themwi-system-sw
comparison sip-in/invite_dup.c @ 145:4b685a5d9bd4
sip-in code: split invite.c into 3 separate C modules
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 08 Oct 2022 19:31:05 -0800 |
parents | sip-in/invite.c@c93c339271a7 |
children | 54c2f271380d |
comparison
equal
deleted
inserted
replaced
144:4e16aeafbfbf | 145:4b685a5d9bd4 |
---|---|
1 /* | |
2 * Here we process SIP INVITE retransmissions and/or re-INVITEs | |
3 * for existing calls. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <sys/socket.h> | |
8 #include <sys/time.h> | |
9 #include <netinet/in.h> | |
10 #include <stdio.h> | |
11 #include <stdint.h> | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 #include <strings.h> | |
15 #include <syslog.h> | |
16 #include "../libsip/parse.h" | |
17 #include "../libsip/uas_basic.h" | |
18 #include "../libsip/sdp.h" | |
19 #include "../libsip/out_msg.h" | |
20 #include "call.h" | |
21 | |
22 void | |
23 invite_existing_call(req, ess, sin, call) | |
24 struct sip_pkt_rx *req; | |
25 struct uas_parse_hdrs *ess; | |
26 struct sockaddr_in *sin; | |
27 struct call *call; | |
28 { | |
29 struct sip_msg_out resp; | |
30 int rc; | |
31 | |
32 if (ess->cseq_num != call->invite_cseq) { | |
33 start_response_out_msg(&resp, "501 Re-INVITE not supported"); | |
34 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
35 if (rc < 0) { | |
36 syslog(LOG_ERR, | |
37 "sending 501 Re-INVITE error: response length exceeded"); | |
38 return; | |
39 } | |
40 out_msg_finish(&resp); | |
41 sip_tx_packet(&resp, sin); | |
42 return; | |
43 } | |
44 /* it's a retransmission, not a re-INVITE */ | |
45 switch (call->sip_state) { | |
46 case SIP_STATE_INVITE_PROC: | |
47 start_response_out_msg(&resp, "100 Proceeding"); | |
48 fill_invite_resp_from_call(&resp, call); | |
49 out_msg_finish(&resp); | |
50 sip_tx_packet(&resp, sin); | |
51 return; | |
52 case SIP_STATE_RINGING: | |
53 start_response_out_msg(&resp, "180 Ringing"); | |
54 fill_invite_resp_from_call(&resp, call); | |
55 out_msg_finish(&resp); | |
56 sip_tx_packet(&resp, sin); | |
57 return; | |
58 case SIP_STATE_RINGING_REL: | |
59 start_response_out_msg(&resp, "180 Ringing"); | |
60 fill_invite_resp_from_call(&resp, call); | |
61 out_msg_add_header(&resp, "Require", "100rel"); | |
62 out_msg_add_header(&resp, "RSeq", "1"); | |
63 out_msg_finish(&resp); | |
64 sip_tx_packet(&resp, sin); | |
65 return; | |
66 case SIP_STATE_INVITE_200: | |
67 case SIP_STATE_CONNECTED: | |
68 fill_invite_200_resp(&resp, call); | |
69 sip_tx_packet(&resp, sin); | |
70 return; | |
71 case SIP_STATE_INVITE_ERR: | |
72 start_response_out_msg(&resp, call->invite_fail); | |
73 fill_invite_resp_from_call(&resp, call); | |
74 out_msg_finish(&resp); | |
75 sip_tx_packet(&resp, sin); | |
76 return; | |
77 default: | |
78 /* silently discard */ | |
79 return; | |
80 } | |
81 } |