FreeCalypso > hg > themwi-system-sw
annotate sip-manual-out/bye_in.c @ 256:63252528a56c
sip-out: add CDR log line
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 15 Aug 2023 10:11:51 -0800 |
parents | f8a33603288f |
children |
rev | line source |
---|---|
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
147
94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
2 * Here we handle incoming BYE requests in the UAS role. |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <netinet/in.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <string.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <strings.h> |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "../libsip/parse.h" |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "../libsip/uas_basic.h" |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "../libsip/out_msg.h" |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
16 extern char call_id[]; |
192
f8a33603288f
sip-manual-out: generate outgoing RTP stream with PCM silence
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
17 extern int rtp_out_enable; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
18 |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static void |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
20 bye_correct_call(req, ess, sin) |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 struct sip_pkt_rx *req; |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 struct uas_parse_hdrs *ess; |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 struct sockaddr_in *sin; |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
25 struct sip_msg_out resp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
26 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
27 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
28 printf("Received BYE for our call, responding with 200\n"); |
192
f8a33603288f
sip-manual-out: generate outgoing RTP stream with PCM silence
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
29 rtp_out_enable = 0; |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
30 start_response_out_msg(&resp, "200 OK"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
31 rc = add_resp_basic_headers(&resp, ess, req->req_method); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
32 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
33 fprintf(stderr, "sending 200 response: msg length exceeded\n"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
34 return; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
35 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
36 out_msg_finish(&resp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
37 sip_tx_packet(&resp, sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
38 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
39 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
40 static void |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
41 bye_unknown_call(req, ess, sin) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
42 struct sip_pkt_rx *req; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
43 struct uas_parse_hdrs *ess; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
44 struct sockaddr_in *sin; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
45 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
46 struct sip_msg_out resp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
47 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
48 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
49 printf("Received BYE for unknown call, responding with 481\n"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
50 start_response_out_msg(&resp, "481 Call-ID not found"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
51 rc = add_resp_basic_headers(&resp, ess, req->req_method); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
52 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
53 fprintf(stderr, "sending 481 response: msg length exceeded\n"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
54 return; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
55 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
56 out_msg_finish(&resp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
57 sip_tx_packet(&resp, sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
58 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
59 |
147
94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
60 void |
94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
61 handle_bye_req(req, ess, sin) |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
62 struct sip_pkt_rx *req; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
63 struct uas_parse_hdrs *ess; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
64 struct sockaddr_in *sin; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
65 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
66 if (!strcmp(ess->call_id, call_id)) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
67 bye_correct_call(req, ess, sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
68 else |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
69 bye_unknown_call(req, ess, sin); |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 } |