src/modules/lost/utilities.h
73207ad1
 /*
  * lost module utility functions
  *
d4fe0a9a
  * Copyright (C) 2020 Wolfgang Kampichler
73207ad1
  * DEC112, FREQUENTIS AG
  *
  * This file is part of Kamailio, a free SIP server.
  *
  * Kamailio is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
  * Kamailio is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
 /*!
  * \file
  * \brief Kamailio lost :: functions
  * \ingroup lost
  * Module: \ref lost
  */
 
 #ifndef LOST_UTILITIES_H
 #define LOST_UTILITIES_H
 
 #define LOST_GEOLOC_HEADER "Geolocation: "
 #define LOST_GEOLOC_HEADER_SIZE strlen(LOST_GEOLOC_HEADER)
 #define LOST_PAI_HEADER "P-Asserted-Identity: "
 #define LOST_PAI_HEADER_SIZE strlen(LOST_PAI_HEADER)
 
d4fe0a9a
 #define LOST_RECURSION_TRUE 1
 #define LOST_RECURSION_FALSE 0
 #define LOST_XPATH_DPTH 3
 #define LOST_XPATH_GP "//gp:location-info/*"
 
 #define XPATH_NS                                         \
 	"gp=urn:ietf:params:xml:ns:pidf:geopriv10"           \
 	" "                                                  \
 	"xmlns=urn:ietf:params:xml:ns:pidf"                  \
 	" "                                                  \
 	"ca=urn:ietf:params:xml:ns:pidf:geopriv10:civicAddr" \
 	" "                                                  \
 	"gm=http://www.opengis.net/gml"
 
 #define LOST_PRO_GEO2D "geodetic-2d"
 #define LOST_PRO_CIVIC "civic"
 
 #define LOST_PNT "Point"
 #define LOST_CIR "Circle"
 #define LOST_CIV "civicAddress"
 
d5b2c1df
 #define HELD_TYPE_ANY "any"
 #define HELD_TYPE_CIV "civic"
 #define HELD_TYPE_GEO "geodetic"
 #define HELD_TYPE_URI "locationURI"
 #define HELD_TYPE_SEP " "
 
d4fe0a9a
 #define HELD_EXACT_TRUE 1
 #define HELD_EXACT_FALSE 0
 
73207ad1
 #define BUFSIZE 128	/* temporary buffer to hold geolocation */
 #define RANDSTRSIZE 16 /* temporary id in a findService request */
 
d4fe0a9a
 typedef struct LOC
73207ad1
 {
d4fe0a9a
 	char *identity;		/* location idendity (findServiceRequest) */
 	char *urn;			/* service URN (findServiceRequest) */ 
340bb1ef
 	char *xpath;		/* civic address (findServiceRequest) */
d4fe0a9a
 	char *geodetic;		/* geodetic location (findServiceRequest) */
 	char *longitude;	/* geo longitude */
 	char *latitude;		/* geo latitude */
 	char *profile;		/* location profile (findServiceRequest) */
 	int radius;			/* geo radius (findServiceRequest) */
 	int recursive;		/* recursion true|false (findServiceRequest)*/
 	int boundary;       /* boundary ref|value (findServiceRequest)*/
73207ad1
 } s_loc_t, *p_loc_t;
 
d4fe0a9a
 typedef struct HELD
 {
 	char *identity;		/* location idendity (locationRequest) */
 	char *type;			/* location type (locationRequest) */ 
d5b2c1df
 	int time;			/* response time (locationRequest) */
d4fe0a9a
 	int exact;			/* exact true|false (locationRequest)*/
 } s_held_t, *p_held_t;
 
73207ad1
 void lost_rand_str(char *, size_t);
 void lost_free_loc(p_loc_t);
d4fe0a9a
 void lost_free_held(p_held_t);
73207ad1
 void lost_free_string(str *);
 
d4fe0a9a
 int lost_parse_location_info(xmlNodePtr, p_loc_t);
 int lost_xpath_location(xmlDocPtr, char *, p_loc_t);
 int lost_parse_geo(xmlNodePtr, p_loc_t);
73207ad1
 
 char *lost_find_service_request(p_loc_t, int *);
d4fe0a9a
 char *lost_held_location_request(p_held_t, int *);
73207ad1
 char *lost_get_content(xmlNodePtr, const char *, int *);
 char *lost_get_property(xmlNodePtr, const char *, int *);
 char *lost_get_geolocation_header(struct sip_msg *, int *);
 char *lost_get_from_header(struct sip_msg *, int *);
 char *lost_get_pai_header(struct sip_msg *, int *);
 char *lost_get_childname(xmlNodePtr, const char *, int *);
 char *lost_trim_content(char *, int *);
 
 p_loc_t lost_new_loc(str);
d5b2c1df
 p_held_t lost_new_held(str, str, int, int);
73207ad1
 
 #endif