comparison sip-in/invite.c @ 51:36a30349b490

sip-in: parse INVITE From header
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 07 Sep 2022 17:53:10 -0800
parents daf1c26d7ae2
children f1d59210f7b2
comparison
equal deleted inserted replaced
50:daf1c26d7ae2 51:36a30349b490
11 #include <strings.h> 11 #include <strings.h>
12 #include <syslog.h> 12 #include <syslog.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 #include "../libsip/parse.h" 14 #include "../libsip/parse.h"
15 #include "../libsip/uas_basic.h" 15 #include "../libsip/uas_basic.h"
16 #include "../libsip/grok_from.h"
16 #include "../libsip/req_supp.h" 17 #include "../libsip/req_supp.h"
17 #include "../libsip/out_msg.h" 18 #include "../libsip/out_msg.h"
18 19
19 extern int cfg_use_100rel; 20 extern int cfg_use_100rel;
20 21
26 struct uas_parse_hdrs *ess; 27 struct uas_parse_hdrs *ess;
27 struct sockaddr_in *sin; 28 struct sockaddr_in *sin;
28 { 29 {
29 char uri_user[13], *called_nanp; 30 char uri_user[13], *called_nanp;
30 struct sip_msg_out resp; 31 struct sip_msg_out resp;
32 struct grok_from gfrom;
31 struct supported_ext supp_ext; 33 struct supported_ext supp_ext;
32 char *hval, *unsup_ext; 34 char *hval, *unsup_ext;
33 int ext_100rel_req, ext_100rel_sup, use_100rel; 35 int ext_100rel_req, ext_100rel_sup, use_100rel;
34 int rc; 36 int rc;
35 37
73 if (!is_nanp_locally_owned(called_nanp)) { 75 if (!is_nanp_locally_owned(called_nanp)) {
74 start_response_out_msg(&resp, 76 start_response_out_msg(&resp,
75 "404 Called number does not belong here"); 77 "404 Called number does not belong here");
76 goto error_resp; 78 goto error_resp;
77 } 79 }
80 /* parse and validate From header */
81 rc = grok_from_header(ess->from, &gfrom);
82 if (rc < 0) {
83 start_response_out_msg(&resp, "400 Malformed From header");
84 goto error_resp;
85 }
78 /* check 100rel and catch any unsupported requirements */ 86 /* check 100rel and catch any unsupported requirements */
79 supp_ext.name = "100rel"; 87 supp_ext.name = "100rel";
80 supp_ext.req_flag = &ext_100rel_req; 88 supp_ext.req_flag = &ext_100rel_req;
81 supp_ext.sup_flag = &ext_100rel_sup; 89 supp_ext.sup_flag = &ext_100rel_sup;
82 ext_100rel_req = ext_100rel_sup = 0; 90 ext_100rel_req = ext_100rel_sup = 0;