Debian Codegraph @

src/modules/lost/utilities.h

raw symbols SCIP
1 /*
2 * lost module utility functions
3 *
4 * Copyright (C) 2023 Wolfgang Kampichler
5 * DEC112, FREQUENTIS AG
6 *
7 * This file is part of Kamailio, a free SIP server.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 *
11 * Kamailio is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version
15 *
16 * Kamailio is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 */
26
27 /*!
28 * \file
29 * \brief Kamailio lost :: functions
30 * \ingroup lost
31 * Module: \ref lost
32 */
33
34 #ifndef LOST_UTILITIES_H
35 #define LOST_UTILITIES_H
36
37 #include "response.h"
38
39 #define LAQUOT '<'
40 #define COLON ':'
41
42 #define LOST_GEOLOC_HEADER "Geolocation: "
43 #define LOST_GEOLOC_HEADER_SIZE strlen(LOST_GEOLOC_HEADER)
44 #define LOST_PAI_HEADER "P-Asserted-Identity: "
45 #define LOST_PAI_HEADER_SIZE strlen(LOST_PAI_HEADER)
46
47 #define LOST_BOUNDARY_TRUE 1
48 #define LOST_BOUNDARY_FALSE 0
49 #define LOST_XPATH_DPTH 3
50 #define LOST_XPATH_GP "//gp:location-info/*"
51
52 #define XPATH_NS \
53 "gp=urn:ietf:params:xml:ns:pidf:geopriv10" \
54 " " \
55 "xmlns=urn:ietf:params:xml:ns:pidf" \
56 " " \
57 "ca=urn:ietf:params:xml:ns:pidf:geopriv10:civicAddr" \
58 " " \
59 "gm=http://www.opengis.net/gml"
60
61 #define LOST_PRO_GEO2D "geodetic-2d"
62 #define LOST_PRO_GEO3D "geodetic-3d"
63 #define LOST_PRO_CIVIC "civic"
64
65 /* shape representation RFC 5491 */
66 #define LOST_PNT "Point"
67 #define LOST_POL "Polygon"
68 #define LOST_CIR "Circle"
69 #define LOST_ELL "Ellipse"
70 #define LOST_ARC "ArcBand"
71 #define LOST_SPH "Sphere"
72 #define LOST_OID "Ellipsoid"
73 #define LOST_PSM "Prism"
74 #define LOST_CIV "civicAddress"
75
76 #define HELD_TYPE_ANY "any"
77 #define HELD_TYPE_CIV "civic"
78 #define HELD_TYPE_GEO "geodetic"
79 #define HELD_TYPE_URI "locationURI"
80 #define HELD_TYPE_SEP " "
81
82 #define HELD_LR "locationRequest"
83 #define HELD_LT "locationType"
84 #define HELD_RT "responseTime"
85 #define HELD_ED "emergencyDispatch"
86 #define HELD_ER "emergencyRouting"
87
88 #define HELD_EXACT_TRUE 1
89 #define HELD_EXACT_FALSE 0
90
91 #define BUFSIZE 128 /* temporary buffer to hold geolocation */
92 #define RANDSTRSIZE 16 /* temporary id in a findService request */
93
94 typedef struct lost_loc
95 {
96 char *identity; /* location idendity (findServiceRequest) */
97 char *urn; /* service URN (findServiceRequest) */
98 char *xpath; /* civic address (findServiceRequest) */
99 char *geodetic; /* geodetic location (findServiceRequest) */
100 char *longitude; /* geo longitude */
101 char *latitude; /* geo latitude */
102 char *altitude; /* geo altitude */
103 char *profile; /* location profile (findServiceRequest) */
104 int radius; /* geo radius (findServiceRequest) */
105 int recursive; /* recursion true|false (findServiceRequest)*/
106 int boundary; /* boundary ref|value (findServiceRequest)*/
107 } s_lost_loc_t, *p_lost_loc_t;
108
109 typedef struct lost_held
110 {
111 char *identity; /* location idendity (locationRequest) */
112 char *type; /* location type (locationRequest) */
113 int time; /* response time (locationRequest) */
114 int exact; /* exact true|false (locationRequest)*/
115 } s_lost_held_t, *p_lost_held_t;
116
117 typedef enum lost_geotype
118 {
119 ANY, /* any type */
120 CID, /* content-indirection */
121 HTTP, /* http uri */
122 HTTPS, /* https uri */
123 UNKNOWN = -1 /* unknown */
124 } lost_geotype_t;
125
126 typedef struct lost_geolist
127 {
128 char *value; /* geolocation header value */
129 char *param; /* value parameter */
130 lost_geotype_t type; /* type */
131 struct lost_geolist *next;
132 } s_lost_geolist_t, *p_lost_geolist_t;
133
134 void lost_rand_str(char *, size_t);
135 void lost_free_loc(p_lost_loc_t *);
136 void lost_free_held(p_lost_held_t *);
137 void lost_free_string(str *);
138 void lost_free_geoheader_list(p_lost_geolist_t *);
139 void lost_reverse_geoheader_list(p_lost_geolist_t *);
140
141 int lost_parse_location_info(xmlNodePtr, p_lost_loc_t);
142 int lost_xpath_location(xmlDocPtr, char *, p_lost_loc_t);
143 int lost_parse_geo(xmlNodePtr, p_lost_loc_t);
144 int lost_parse_host(const char *, str *, int *);
145 int lost_new_geoheader_list(p_lost_geolist_t *, str);
146 int lost_get_nameinfo(char *, str *, int);
147
148 char *lost_find_service_request(p_lost_loc_t, p_lost_list_t, int *);
149 char *lost_held_location_request(p_lost_held_t, int *);
150 char *lost_held_post_request(int *, long, char *);
151 char *lost_get_content(xmlNodePtr, const char *, int *);
152 char *lost_get_property(xmlNodePtr, const char *, int *);
153 char *lost_get_from_header(struct sip_msg *, int *);
154 char *lost_get_pai_header(struct sip_msg *, int *);
155 char *lost_get_childname(xmlNodePtr, const char *, int *);
156 char *lost_trim_content(char *, int *);
157 char *lost_copy_geoheader_value(char *, int);
158 char *lost_get_geoheader_value(p_lost_geolist_t, lost_geotype_t, int *);
159 char *lost_copy_string(str, int *);
160
161 p_lost_loc_t lost_new_loc(str);
162 p_lost_loc_t lost_parse_pidf(str, str);
163 p_lost_held_t lost_new_held(str, str, int, int);
164 p_lost_geolist_t lost_get_geolocation_header(struct sip_msg *, int *);
165
166 #endif