annotate sip-manual-out/reinvite.c @ 203:e89619893c1e

sip-out: require minimum of 7 digits for E.164 numbers
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 04 Apr 2023 21:09:50 -0800
parents b51247739897
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
2 * Here we handle incoming INVITE requests in the UAS role: even though
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
3 * we are strictly outbound, BulkVS servers will send us periodic
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
4 * re-INVITEs as keepalives, and we have to play along.
47
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/socket.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <netinet/in.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdio.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <string.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <strings.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "../libsip/parse.h"
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "../libsip/uas_basic.h"
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include "../libsip/out_msg.h"
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
71
d74b545a3c2a sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
18 extern char call_id[];
d74b545a3c2a sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
19
47
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 static void
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
21 invite_correct_call(req, ess, sin)
47
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 struct sip_pkt_rx *req;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 struct uas_parse_hdrs *ess;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct sockaddr_in *sin;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 {
71
d74b545a3c2a sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
26 struct sip_msg_out resp;
d74b545a3c2a sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
27 int rc;
d74b545a3c2a sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
28
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
29 printf("Received re-INVITE for our call, responding with 200\n");
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
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
41 invite_unknown_call(req, ess, sin)
71
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
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
49 printf("Received INVITE for unknown call, responding with 405\n");
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
50 start_response_out_msg(&resp, "405 This gateway is outbound only");
71
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) {
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
53 fprintf(stderr, "sending 405 response: msg length exceeded\n");
71
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
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
61 handle_invite_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))
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
67 invite_correct_call(req, ess, sin);
71
d74b545a3c2a sip-manual-out: new test program
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
68 else
148
b51247739897 sip-manual-out: attempt to play along with re-INVITEs
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
69 invite_unknown_call(req, ess, sin);
47
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }