42#define DUP_VARS(_dest, _source) \ 
   46        struct ast_variable *_vars = ast_variables_dup(_source); \ 
 
   99            ast_log(
LOG_ERROR, 
"Profile '%s' referenced location '%s' does not exist!", eprofile->
id,
 
  116        format = eprofile->
format;
 
  128    rc = 
DUP_VARS(temp_effloc, temp_locinfo);
 
  145    eprofile->
format = format;
 
 
  162    const char *profile_id;
 
 
  223    const char *profile_id;
 
 
  289    char *loc_src = 
NULL;
 
  291    loc_src = strchr(local_uri, 
';');
 
  305                    " RFC8787 states that IP addresses MUST be dropped.\n",
 
 
  328    if (local_uri[0] == 
'<') {
 
  331    ra = strchr(local_uri, 
'>');
 
 
  359    if (!source || !chan) {
 
 
  403    const char *uri = 
NULL;
 
  406    int we_created_buf = 0;
 
  408    if (!eprofile || !
buf || !chan) {
 
  414            ref_str, eprofile->
id, ast_geoloc_format_to_name(eprofile->
format));
 
  429        ast_log(
LOG_ERROR, 
"%s: '%s' is a URI profile but had no, or an empty, 'URI' entry in location_info\n",
 
  430            ref_str, eprofile->
id);
 
  443        if (we_created_buf) {
 
 
  458    struct ast_xml_node *child;
 
  470            char newval[strlen(
value) + 1 + strlen(uom) + 1];
 
  471            sprintf(newval, 
"%s %s", 
value, uom);
 
 
  536    if (locinfo_list == 
NULL) {
 
 
  593    struct ast_xml_doc *result_doc, 
const char *ref_str)
 
  600    struct ast_xml_node *presence = 
NULL;
 
  601    struct ast_xml_node *pidf_element = 
NULL;
 
  602    struct ast_xml_node *location_info = 
NULL;
 
  603    struct ast_xml_node *confidence = 
NULL;
 
  604    struct ast_xml_node *usage_rules = 
NULL;
 
  606    struct ast_xml_node *note_well = 
NULL;
 
  611    const char *pidf_element_str;
 
  616    const char *
id = 
NULL;
 
  617    const char *format_str = 
NULL;
 
  618    const char *method_str = 
NULL;
 
  619    const char *note_well_str = 
NULL;
 
  628        char *doc_str = 
NULL;
 
  632        ast_trace(5, 
"xslt result doc len: %d\n%s\n", doc_len, doc_len ? doc_str : 
"<empty>");
 
  665    if (!location_info) {
 
  676    if (strcasecmp(format_str, 
"gml") == 0) {
 
  678    } 
else if (strcasecmp(format_str, 
"civicAddress") == 0) {
 
  691    eprofile->
pidf_element = ast_geoloc_pidf_element_str_to_enum(pidf_element_str);
 
  697            "%s: Unable to create location variables\n", ref_str);
 
 
  724    struct ast_xml_node *presence;
 
  725    struct ast_xml_node *pidf_element;
 
  726    struct ast_xml_node *location_info;
 
  727    const char *pidf_element_name;
 
  749    if (!location_info) {
 
 
  757    struct ast_xml_doc *pidf_xmldoc, 
const char *geoloc_uri, 
const char *ref_str)
 
  759    struct ast_xml_doc *result_doc = 
NULL;
 
  787        char *doc_str = 
NULL;
 
  791        ast_trace(5, 
"Intermediate doc len: %d\n%s\n", doc_len, doc_len ? doc_str : 
"<empty>");
 
  800    if (eprofile && geoloc_uri) {
 
 
  828    struct ast_xml_node *rtn_pidf_node;
 
  829    struct ast_xml_node *loc_node;
 
  830    struct ast_xml_node *confidence_node;
 
  831    struct ast_xml_node *info_node;
 
  832    struct ast_xml_node *rules_node;
 
  833    struct ast_xml_node *method_node;
 
  834    struct ast_xml_node *notes_node;
 
  835    struct ast_xml_node *timestamp_node;
 
  837    struct tm tm = { 0, };
 
  838    char timestr[32] = { 0, };
 
  843    if (!eprofile || !chan) {
 
  850            ref_string, element_name);
 
  874            ref_string, ast_geoloc_format_to_name(eprofile->
format));
 
  879            ref_string, ast_geoloc_format_to_name(eprofile->
format));
 
  887        if (!confidence_node) {
 
  930    gmtime_r(&tv.tv_sec, &tm);
 
  931    strftime(timestr, 
sizeof(timestr), 
"%FT%TZ", &tm);
 
  933    if (!timestamp_node) {
 
  939    rtn_pidf_node = pidf_node;
 
 
  944#define CREATE_NODE_LIST(node) \ 
  946        node = ast_xml_new_child(root_node, \ 
  947            geoloc_pidf_element_to_name(eprofile->pidf_element)); \ 
  948        if (!pidfs[eprofile->pidf_element]) { \ 
  949            SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create pidf '%s' XML node\n", \ 
  950                ref_string, geoloc_pidf_element_to_name(eprofile->pidf_element)); \ 
 
  959    struct ast_xml_node *root_node;
 
  962    int eprofile_count = 0;
 
  964    char *doc_str = 
NULL;
 
  985    for (i = 0; i < eprofile_count; i++) {
 
  986        struct ast_xml_node *temp_node = 
NULL;
 
  987        struct ast_xml_node *curr_loc = 
NULL;
 
  988        struct ast_xml_node *new_loc = 
NULL;
 
  989        struct ast_xml_node *new_loc_child = 
NULL;
 
  990        struct ast_xml_node *new_loc_child_dup = 
NULL;
 
  991        const char *entity = 
NULL;
 
  992        int has_no_entity = 0;
 
 1001        if (has_no_entity) {
 
 1009            eprofile, chan, ref_string);
 
 1031        ast_trace(5, 
"Intermediate doc len: %d\n%s\n", doc_len, doc_len ? doc_str : 
"<empty>");
 
 1044    if (doc_len == 0 || !doc_str) {
 
 
 1066    struct ast_xml_node *root_node;
 
 1067    char *doc_str = 
NULL;
 
 1070    struct ast_xml_node *temp_node = 
NULL;
 
 1071    const char *entity = 
NULL;
 
 1072    int has_no_entity = 0;
 
 1073    const char *params[] = { 
"suppress_empty_ca_elements", 
"false()", 
NULL };
 
 1084            ref_string, eprofile->
id);
 
 1088    if (!intermediate) {
 
 1100    if (has_no_entity) {
 
 1108        ast_geoloc_pidf_element_to_name(eprofile->
pidf_element), eprofile, chan, ref_string);
 
 1111            ref_string, eprofile->
id);
 
 1118        ast_trace(5, 
"Intermediate doc len: %d\n%s\n", doc_len, doc_len ? doc_str : 
"<empty>");
 
 1125        params[1] = 
"true()";
 
 1134    if (doc_len == 0 || !doc_str) {
 
 
 1151#ifdef TEST_FRAMEWORK 
 1217#ifdef TEST_FRAMEWORK 
 1224    const char *uri = 
NULL;
 
 1229        info->name = 
"create_from_uri";
 
 1230        info->category = 
"/geoloc/";
 
 1231        info->summary = 
"Test create from uri";
 
 1239    ast_test_validate(
test, eprofile != 
NULL);
 
 1241    ast_test_validate(
test, eprofile->location_info != 
NULL);
 
 1243    ast_test_validate(
test, uri != 
NULL);
 
 1244    ast_test_validate(
test, strcmp(uri, 
"http://some_uri&a=b") == 0);
 
 1250    struct ast_xml_doc * pidf_xmldoc,
 
 1256    const char *location,
 
 1273    ast_test_validate(
test, eprofile != 
NULL);
 
 1275        ast_geoloc_pidf_element_to_name(eprofile->pidf_element),
 
 1276        ast_geoloc_format_to_name(eprofile->format),
 
 1280    ast_test_validate(
test, eprofile->pidf_element == pidf_element);
 
 1281    ast_test_validate(
test, eprofile->format == format);
 
 1308        info->name = 
"create_from_pidf";
 
 1309        info->category = 
"/geoloc/";
 
 1310        info->summary = 
"Test create from pidf scenarios";
 
 1318    ast_test_validate(
test, pidf_xmldoc != 
NULL);
 
 1320    res = validate_eprofile(
test, pidf_xmldoc,
 
 1326        "shape=Point,crs=2d,pos=-34.410649 150.87651",
 
 1327        "retransmission-allowed='no',retention-expiry='2010-11-14T20:00:00Z'" 
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
void ast_var_list_destroy(struct varshead *head)
static void AST_VAR_LIST_INSERT_TAIL(struct varshead *head, struct ast_var_t *var)
#define ast_var_assign(name, value)
struct varshead * ast_var_list_create(void)
struct ast_xml_node * geoloc_civicaddr_list_to_xml(const struct ast_variable *resolved_location, const char *ref_string)
struct ast_sorcery * geoloc_get_sorcery(void)
const uint8_t _binary_res_geolocation_eprofile_to_pidf_xslt_start[]
struct ast_variable * geoloc_eprofile_resolve_varlist(struct ast_variable *source, struct ast_variable *variables, struct ast_channel *chan)
static size_t pidf_lo_test_xml_size
static void geoloc_eprofile_destructor(void *obj)
int ast_geoloc_eprofile_refresh_location(struct ast_geoloc_eprofile *eprofile)
Refresh the effective profile with any changed info.
struct ast_geoloc_eprofile * ast_geoloc_eprofile_dup(struct ast_geoloc_eprofile *src)
Duplicate an effective profile.
static struct ast_xslt_doc * pidf_to_eprofile_xslt
int geoloc_eprofile_reload(void)
int geoloc_eprofile_unload(void)
static struct ast_variable * var_list_from_node(struct ast_xml_node *node, const char *ref_str)
static struct ast_sorcery * geoloc_sorcery
const char * ast_geoloc_eprofiles_to_pidf(struct ast_datastore *ds, struct ast_channel *chan, struct ast_str **buf, const char *ref_string)
Convert a datastore containing eprofiles to a PIDF-LO document.
static struct ast_variable * var_list_from_confidence(struct ast_xml_node *confidence, const char *ref_str)
const char * ast_geoloc_eprofile_to_uri(struct ast_geoloc_eprofile *eprofile, struct ast_channel *chan, struct ast_str **buf, const char *ref_str)
Convert a URI eprofile to a URI string.
const uint8_t _binary_res_geolocation_eprofile_to_pidf_xslt_end[]
const uint8_t _binary_res_geolocation_pidf_to_eprofile_xslt_end[]
static size_t eprofile_to_pidf_xslt_size
const uint8_t _binary_res_geolocation_pidf_lo_test_xml_end[]
static int set_loc_src(struct ast_geoloc_eprofile *eprofile, const char *uri, const char *ref_str)
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_uri(const char *uri, const char *ref_str)
Allocate a new effective profile from a URI.
const uint8_t _binary_res_geolocation_pidf_to_eprofile_xslt_start[]
static int is_pidf_lo(struct ast_xml_doc *result_doc)
static void unload_tests(void)
struct ast_geoloc_eprofile * ast_geoloc_eprofile_alloc(const char *name)
Geolocation Effective Profile Functions.
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_pidf(struct ast_xml_doc *pidf_xmldoc, const char *geoloc_uri, const char *ref_str)
Allocate a new effective profile from an XML PIDF-LO document.
int geoloc_eprofile_load(void)
static struct ast_geoloc_eprofile * geoloc_eprofile_create_from_xslt_result(struct ast_xml_doc *result_doc, const char *ref_str)
const uint8_t _binary_res_geolocation_pidf_lo_test_xml_start[]
static size_t pidf_to_eprofile_xslt_size
static struct ast_xslt_doc * eprofile_to_pidf_xslt
static struct ast_xml_node * geoloc_eprofile_to_intermediate(const char *element_name, struct ast_geoloc_eprofile *eprofile, struct ast_channel *chan, const char *ref_string)
const char * ast_geoloc_eprofile_to_pidf(struct ast_geoloc_eprofile *eprofile, struct ast_channel *chan, struct ast_str **buf, const char *ref_string)
Convert a single eprofile to a PIDF-LO document.
static void load_tests(void)
static struct ast_variable * var_list_from_loc_info(struct ast_xml_node *locinfo, enum ast_geoloc_format format, const char *ref_str)
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_profile(struct ast_geoloc_profile *profile)
Allocate a new effective profile from an existing profile.
#define DUP_VARS(_dest, _source)
struct ast_xml_node * geoloc_gml_list_to_xml(const struct ast_variable *resolved_location, const char *ref_string)
#define TRACE_ATLEAST(level)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
#define ast_trace(level,...)
const char * ast_variable_find_in_list(const struct ast_variable *list, const char *variable)
Gets the value of a variable from a variable list by name.
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
struct ast_str * ast_variable_list_join(const struct ast_variable *head, const char *item_separator, const char *name_value_separator, const char *quote_char, struct ast_str **str)
Join an ast_variable list with specified separators and quoted values.
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Core PBX routines and definitions.
void ast_str_substitute_variables_full2(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used, int use_both)
Perform variable/function/expression substitution on an ast_str.
struct ao2_container * container
struct ast_geoloc_eprofile * ast_geoloc_datastore_get_eprofile(struct ast_datastore *ds, int ix)
Retrieve a specific eprofile from a datastore by index.
@ AST_GEOLOC_FORMAT_CIVIC_ADDRESS
int ast_geoloc_datastore_size(struct ast_datastore *ds)
Retrieves the number of eprofiles in the datastore.
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
String manipulation functions.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_alloca(init_len)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Main Channel structure associated with a channel.
Structure for a data store object.
struct ast_variable * effective_location
const ast_string_field location_reference
enum ast_geoloc_format format
enum ast_geoloc_pidf_element pidf_element
const ast_string_field method
struct ast_variable * location_refinement
enum ast_geoloc_precedence precedence
const ast_string_field notes
const ast_string_field id
int suppress_empty_ca_elements
struct ast_variable * location_variables
struct ast_variable * confidence
struct ast_variable * usage_rules
const ast_string_field location_source
struct ast_variable * location_info
enum ast_geoloc_format format
const ast_string_field method
struct ast_variable * confidence
const ast_string_field location_source
struct ast_variable * location_info
const ast_string_field location_reference
enum ast_geoloc_format format
enum ast_geoloc_pidf_element pidf_element
const ast_string_field method
struct ast_variable * location_refinement
enum ast_geoloc_precedence precedence
const ast_string_field notes
int suppress_empty_ca_elements
struct ast_variable * location_variables
struct ast_variable * confidence
struct ast_variable * usage_rules
const ast_string_field location_source
struct ast_variable * location_info
Socket address structure.
Full structure for sorcery.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Asterisk XML abstraction layer.
#define ast_xml_find_child_element(_parent_node, _name, _attrname, _attrvalue)
Find a direct child element by name.
struct ast_xml_node * ast_xml_copy_node_list(struct ast_xml_node *list)
Create a copy of a n ode list.
struct ast_xml_node * ast_xml_add_child(struct ast_xml_node *parent, struct ast_xml_node *child)
Add a child node, to a specified parent node.
struct ast_xml_node * ast_xml_node_get_children(struct ast_xml_node *node)
Get the node's children.
const char * ast_xml_get_attribute(struct ast_xml_node *node, const char *attrname)
Get a node attribute by name.
const char * ast_xml_get_text(struct ast_xml_node *node)
Get an element content string.
struct ast_xml_node * ast_xml_new_child(struct ast_xml_node *parent, const char *child_name)
Add a child node inside a passed parent node.
struct ast_xml_node * ast_xml_new_node(const char *name)
Create a XML node.
void ast_xml_close(struct ast_xml_doc *doc)
Close an already open document and free the used structure.
void ast_xml_doc_dump_memory(struct ast_xml_doc *doc, char **buffer, int *length)
Dump the specified document to a buffer.
const char * ast_xml_node_get_name(struct ast_xml_node *node)
Get the name of a node.
void ast_xml_free_attr(const char *attribute)
Free an attribute returned by ast_xml_get_attribute()
struct ast_xml_node * ast_xml_node_get_next(struct ast_xml_node *node)
Get the next node in the same level.
struct ast_xml_doc * ast_xml_new(void)
Create a XML document.
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value)
Set an attribute to a node.
void ast_xml_set_text(struct ast_xml_node *node, const char *content)
Set an element content string.
struct ast_xml_node * ast_xml_add_child_list(struct ast_xml_node *parent, struct ast_xml_node *child)
Add a list of child nodes, to a specified parent node.
void ast_xml_free_text(const char *text)
Free a content element that was returned by ast_xml_get_text()
void ast_xml_set_root(struct ast_xml_doc *doc, struct ast_xml_node *node)
Specify the root node of a XML document.
struct ast_xml_doc * ast_xml_read_memory(char *buffer, size_t size)
Open an XML document that resides in memory.
void ast_xml_free_node(struct ast_xml_node *node)
Free node.
struct ast_xml_node * ast_xml_get_root(struct ast_xml_doc *doc)
Get the document root node.