FreeCalypso > hg > themwi-system-sw
annotate sip-manual-out/bye_in.c @ 181:9ebd89257ae1
top Makefile: add rtp-mgr
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Mar 2023 20:43:18 -0800 |
parents | 94b5831c017f |
children | f8a33603288f |
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[]; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
17 |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static void |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
19 bye_correct_call(req, ess, sin) |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 struct sip_pkt_rx *req; |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 struct uas_parse_hdrs *ess; |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 struct sockaddr_in *sin; |
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 { |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
24 struct sip_msg_out resp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
25 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
26 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
27 printf("Received BYE for our call, responding with 200\n"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
28 start_response_out_msg(&resp, "200 OK"); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
29 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
|
30 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
31 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
|
32 return; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
33 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
34 out_msg_finish(&resp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
35 sip_tx_packet(&resp, sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
36 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
37 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
38 static void |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
39 bye_unknown_call(req, ess, sin) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
40 struct sip_pkt_rx *req; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
41 struct uas_parse_hdrs *ess; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
42 struct sockaddr_in *sin; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
43 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
44 struct sip_msg_out resp; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
45 int rc; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
46 |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 if (rc < 0) { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
51 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
|
52 return; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
53 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
54 out_msg_finish(&resp); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
55 sip_tx_packet(&resp, sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
56 } |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
57 |
147
94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
58 void |
94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
59 handle_bye_req(req, ess, sin) |
71
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
60 struct sip_pkt_rx *req; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
61 struct uas_parse_hdrs *ess; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
62 struct sockaddr_in *sin; |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
63 { |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
64 if (!strcmp(ess->call_id, call_id)) |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
65 bye_correct_call(req, ess, sin); |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
66 else |
d74b545a3c2a
sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
67 bye_unknown_call(req, ess, sin); |
47
62f39c7cee15
themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |