comparison sip-in/invite.c @ 50:daf1c26d7ae2

sip-in: check INVITE Content-Type header
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 06 Sep 2022 23:50:16 -0800
parents dec31b1a8b96
children 36a30349b490
comparison
equal deleted inserted replaced
49:dec31b1a8b96 50:daf1c26d7ae2
16 #include "../libsip/req_supp.h" 16 #include "../libsip/req_supp.h"
17 #include "../libsip/out_msg.h" 17 #include "../libsip/out_msg.h"
18 18
19 extern int cfg_use_100rel; 19 extern int cfg_use_100rel;
20 20
21 extern char *get_single_header();
22
21 void 23 void
22 handle_sip_invite(req, ess, sin) 24 handle_sip_invite(req, ess, sin)
23 struct sip_pkt_rx *req; 25 struct sip_pkt_rx *req;
24 struct uas_parse_hdrs *ess; 26 struct uas_parse_hdrs *ess;
25 struct sockaddr_in *sin; 27 struct sockaddr_in *sin;
26 { 28 {
27 char uri_user[13], *called_nanp; 29 char uri_user[13], *called_nanp;
28 struct sip_msg_out resp; 30 struct sip_msg_out resp;
29 struct supported_ext supp_ext; 31 struct supported_ext supp_ext;
30 char *unsup_ext; 32 char *hval, *unsup_ext;
31 int ext_100rel_req, ext_100rel_sup, use_100rel; 33 int ext_100rel_req, ext_100rel_sup, use_100rel;
32 int rc; 34 int rc;
33 35
34 /* check for existing Call-ID will go here */ 36 /* check for existing Call-ID will go here */
35 /* extract called number from Request-URI */ 37 /* extract called number from Request-URI */
90 use_100rel = 1; 92 use_100rel = 1;
91 else if (ext_100rel_sup) 93 else if (ext_100rel_sup)
92 use_100rel = cfg_use_100rel; 94 use_100rel = cfg_use_100rel;
93 else 95 else
94 use_100rel = 0; 96 use_100rel = 0;
97 /* did the caller send an SDP message body? */
98 if (!req->msg_body_len) {
99 start_response_out_msg(&resp, "415 Missing SDP body");
100 error_415: rc = out_msg_add_header(&resp, "Accept", "application/sdp");
101 if (rc < 0)
102 goto error_resp_toolong;
103 goto error_resp;
104 }
105 hval = get_single_header(req, "Content-Type", "c", (int *) 0);
106 if (!hval) {
107 start_response_out_msg(&resp,
108 "415 Missing Content-Type header");
109 goto error_415;
110 }
111 if (strcasecmp(hval, "application/sdp")) {
112 start_response_out_msg(&resp, "415 Unsupported Content-Type");
113 goto error_415;
114 }
95 /* 115 /*
96 * Remaining checks to be implemented: 116 * Remaining checks to be implemented:
97 * SDP message body 117 * SDP message body
98 */ 118 */
99 } 119 }