comparison test-fsk/bye_in.c @ 2:26383ed8b79f

test-fsk: starting as a copy of test-voice
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 04 Mar 2024 21:03:19 -0800
parents test-voice/bye_in.c@35c0d9f03c0a
children
comparison
equal deleted inserted replaced
1:38c4d09882f6 2:26383ed8b79f
1 /*
2 * Here we handle incoming BYE requests in the UAS role.
3 */
4
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <netinet/in.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <strings.h>
12 #include "../libsip/parse.h"
13 #include "../libsip/uas_basic.h"
14 #include "../libsip/out_msg.h"
15
16 extern char call_id[];
17 extern int rtp_out_enable;
18
19 static void
20 bye_correct_call(req, ess, sin)
21 struct sip_pkt_rx *req;
22 struct uas_parse_hdrs *ess;
23 struct sockaddr_in *sin;
24 {
25 struct sip_msg_out resp;
26 int rc;
27
28 printf("Received BYE for our call, responding with 200\n");
29 rtp_out_enable = 0;
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 bye_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 BYE for unknown call, responding with 481\n");
50 start_response_out_msg(&resp, "481 Call-ID not found");
51 rc = add_resp_basic_headers(&resp, ess, req->req_method);
52 if (rc < 0) {
53 fprintf(stderr, "sending 481 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_bye_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 bye_correct_call(req, ess, sin);
68 else
69 bye_unknown_call(req, ess, sin);
70 }