FreeCalypso > hg > themwi-system-sw
comparison sip-manual-out/bye_in.c @ 147:94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 08 Oct 2022 23:01:32 -0800 |
parents | sip-manual-out/uas.c@dd845c4933e1 |
children | f8a33603288f |
comparison
equal
deleted
inserted
replaced
146:54c2f271380d | 147:94b5831c017f |
---|---|
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 | |
18 static void | |
19 bye_correct_call(req, ess, sin) | |
20 struct sip_pkt_rx *req; | |
21 struct uas_parse_hdrs *ess; | |
22 struct sockaddr_in *sin; | |
23 { | |
24 struct sip_msg_out resp; | |
25 int rc; | |
26 | |
27 printf("Received BYE for our call, responding with 200\n"); | |
28 start_response_out_msg(&resp, "200 OK"); | |
29 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
30 if (rc < 0) { | |
31 fprintf(stderr, "sending 200 response: msg length exceeded\n"); | |
32 return; | |
33 } | |
34 out_msg_finish(&resp); | |
35 sip_tx_packet(&resp, sin); | |
36 } | |
37 | |
38 static void | |
39 bye_unknown_call(req, ess, sin) | |
40 struct sip_pkt_rx *req; | |
41 struct uas_parse_hdrs *ess; | |
42 struct sockaddr_in *sin; | |
43 { | |
44 struct sip_msg_out resp; | |
45 int rc; | |
46 | |
47 printf("Received BYE for unknown call, responding with 481\n"); | |
48 start_response_out_msg(&resp, "481 Call-ID not found"); | |
49 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
50 if (rc < 0) { | |
51 fprintf(stderr, "sending 481 response: msg length exceeded\n"); | |
52 return; | |
53 } | |
54 out_msg_finish(&resp); | |
55 sip_tx_packet(&resp, sin); | |
56 } | |
57 | |
58 void | |
59 handle_bye_req(req, ess, sin) | |
60 struct sip_pkt_rx *req; | |
61 struct uas_parse_hdrs *ess; | |
62 struct sockaddr_in *sin; | |
63 { | |
64 if (!strcmp(ess->call_id, call_id)) | |
65 bye_correct_call(req, ess, sin); | |
66 else | |
67 bye_unknown_call(req, ess, sin); | |
68 } |