FreeCalypso > hg > sipout-test-utils
comparison test-voice/reinvite.c @ 0:35c0d9f03c0a
beginning with sipout-test-voice,
a copy of sip-manual-out from themwi-system-sw
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Mar 2024 23:20:19 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:35c0d9f03c0a |
---|---|
1 /* | |
2 * Here we handle incoming INVITE requests in the UAS role: even though | |
3 * we are strictly outbound, BulkVS servers will send us periodic | |
4 * re-INVITEs as keepalives, and we have to play along. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include <sys/socket.h> | |
9 #include <netinet/in.h> | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <string.h> | |
13 #include <strings.h> | |
14 #include "../libsip/parse.h" | |
15 #include "../libsip/uas_basic.h" | |
16 #include "../libsip/out_msg.h" | |
17 | |
18 extern char call_id[]; | |
19 | |
20 static void | |
21 invite_correct_call(req, ess, sin) | |
22 struct sip_pkt_rx *req; | |
23 struct uas_parse_hdrs *ess; | |
24 struct sockaddr_in *sin; | |
25 { | |
26 struct sip_msg_out resp; | |
27 int rc; | |
28 | |
29 printf("Received re-INVITE for our call, responding with 200\n"); | |
30 start_response_out_msg(&resp, "200 OK"); | |
31 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
32 if (rc < 0) { | |
33 fprintf(stderr, "sending 200 response: msg length exceeded\n"); | |
34 return; | |
35 } | |
36 out_msg_finish(&resp); | |
37 sip_tx_packet(&resp, sin); | |
38 } | |
39 | |
40 static void | |
41 invite_unknown_call(req, ess, sin) | |
42 struct sip_pkt_rx *req; | |
43 struct uas_parse_hdrs *ess; | |
44 struct sockaddr_in *sin; | |
45 { | |
46 struct sip_msg_out resp; | |
47 int rc; | |
48 | |
49 printf("Received INVITE for unknown call, responding with 405\n"); | |
50 start_response_out_msg(&resp, "405 This gateway is outbound only"); | |
51 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
52 if (rc < 0) { | |
53 fprintf(stderr, "sending 405 response: msg length exceeded\n"); | |
54 return; | |
55 } | |
56 out_msg_finish(&resp); | |
57 sip_tx_packet(&resp, sin); | |
58 } | |
59 | |
60 void | |
61 handle_invite_req(req, ess, sin) | |
62 struct sip_pkt_rx *req; | |
63 struct uas_parse_hdrs *ess; | |
64 struct sockaddr_in *sin; | |
65 { | |
66 if (!strcmp(ess->call_id, call_id)) | |
67 invite_correct_call(req, ess, sin); | |
68 else | |
69 invite_unknown_call(req, ess, sin); | |
70 } |