Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/strings.h"
#include "asterisk/xml.h"
#include "geoloc_private.h"
Go to the source code of this file.
Macros | |
#define | CREATE_NODE_LIST(node) |
#define | DUP_VARS(_dest, _source) |
Functions | |
struct ast_geoloc_eprofile * | ast_geoloc_eprofile_alloc (const char *name) |
Geolocation Effective Profile Functions. More... | |
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. More... | |
struct ast_geoloc_eprofile * | ast_geoloc_eprofile_create_from_profile (struct ast_geoloc_profile *profile) |
Allocate a new effective profile from an existing profile. More... | |
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. More... | |
struct ast_geoloc_eprofile * | ast_geoloc_eprofile_dup (struct ast_geoloc_eprofile *src) |
Duplicate an effective profile. More... | |
int | ast_geoloc_eprofile_refresh_location (struct ast_geoloc_eprofile *eprofile) |
Refresh the effective profile with any changed info. More... | |
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. More... | |
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. More... | |
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. More... | |
static struct ast_geoloc_eprofile * | geoloc_eprofile_create_from_xslt_result (struct ast_xml_doc *result_doc, const char *ref_str) |
static void | geoloc_eprofile_destructor (void *obj) |
int | geoloc_eprofile_load (void) |
int | geoloc_eprofile_reload (void) |
struct ast_variable * | geoloc_eprofile_resolve_varlist (struct ast_variable *source, struct ast_variable *variables, struct ast_channel *chan) |
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) |
int | geoloc_eprofile_unload (void) |
static int | is_pidf_lo (struct ast_xml_doc *result_doc) |
static void | load_tests (void) |
static int | set_loc_src (struct ast_geoloc_eprofile *eprofile, const char *uri, const char *ref_str) |
static void | unload_tests (void) |
static struct ast_variable * | var_list_from_confidence (struct ast_xml_node *confidence, const char *ref_str) |
static struct ast_variable * | var_list_from_loc_info (struct ast_xml_node *locinfo, enum ast_geoloc_format format, const char *ref_str) |
static struct ast_variable * | var_list_from_node (struct ast_xml_node *node, const char *ref_str) |
Variables | |
const uint8_t | _binary_res_geolocation_eprofile_to_pidf_xslt_end [] |
const uint8_t | _binary_res_geolocation_eprofile_to_pidf_xslt_start [] |
const uint8_t | _binary_res_geolocation_pidf_lo_test_xml_end [] |
const uint8_t | _binary_res_geolocation_pidf_lo_test_xml_start [] |
const uint8_t | _binary_res_geolocation_pidf_to_eprofile_xslt_end [] |
const uint8_t | _binary_res_geolocation_pidf_to_eprofile_xslt_start [] |
static struct ast_xslt_doc * | eprofile_to_pidf_xslt |
static size_t | eprofile_to_pidf_xslt_size |
static struct ast_sorcery * | geoloc_sorcery |
static size_t | pidf_lo_test_xml_size |
static struct ast_xslt_doc * | pidf_to_eprofile_xslt |
static size_t | pidf_to_eprofile_xslt_size |
#define CREATE_NODE_LIST | ( | node | ) |
Definition at line 944 of file geoloc_eprofile.c.
#define DUP_VARS | ( | _dest, | |
_source | |||
) |
Definition at line 42 of file geoloc_eprofile.c.
struct ast_geoloc_eprofile * ast_geoloc_eprofile_alloc | ( | const char * | name | ) |
Geolocation Effective Profile Functions.
Allocate a new, empty effective profile.
name | The profile's name |
Definition at line 69 of file geoloc_eprofile.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ast_string_field_init, ast_string_field_set, geoloc_eprofile_destructor(), and name.
Referenced by ast_geoloc_eprofile_create_from_profile(), ast_geoloc_eprofile_create_from_uri(), ast_geoloc_eprofile_dup(), geoloc_eprofile_create_from_xslt_result(), and geoloc_profile_write().
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_pidf | ( | struct ast_xml_doc * | pidf_xmldoc, |
const char * | geoloc_uri, | ||
const char * | reference_string | ||
) |
Allocate a new effective profile from an XML PIDF-LO document.
pidf_xmldoc | The ast_xml_doc to use. |
geoloc_uri | The URI that referenced this document. |
reference_string | An identifying string to use in error messages. |
Definition at line 756 of file geoloc_eprofile.c.
References ast_trace, ast_xml_close(), ast_xml_doc_dump_memory(), ast_xml_free_text(), geoloc_eprofile_create_from_xslt_result(), is_pidf_lo(), NULL, pidf_to_eprofile_xslt, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, set_loc_src(), and TRACE_ATLEAST.
Referenced by handle_incoming_request().
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_profile | ( | struct ast_geoloc_profile * | profile | ) |
Allocate a new effective profile from an existing profile.
profile | The profile to use. |
Definition at line 220 of file geoloc_eprofile.c.
References ast_geoloc_profile::allow_routing_use, ast_geoloc_eprofile::allow_routing_use, ao2_lock, ao2_ref, ao2_unlock, ast_geoloc_eprofile_alloc(), ast_geoloc_eprofile_refresh_location(), ast_sorcery_object_get_id(), ast_string_field_set, ast_geoloc_profile::confidence, ast_geoloc_eprofile::confidence, DUP_VARS, ast_geoloc_profile::format, ast_geoloc_eprofile::format, ast_geoloc_profile::location_info, ast_geoloc_eprofile::location_info, ast_geoloc_profile::location_reference, ast_geoloc_eprofile::location_reference, ast_geoloc_profile::location_refinement, ast_geoloc_eprofile::location_refinement, ast_geoloc_profile::location_source, ast_geoloc_eprofile::location_source, ast_geoloc_profile::location_variables, ast_geoloc_eprofile::location_variables, ast_geoloc_profile::method, method, ast_geoloc_profile::notes, notes, NULL, ast_geoloc_profile::pidf_element, ast_geoloc_eprofile::pidf_element, ast_geoloc_profile::precedence, ast_geoloc_eprofile::precedence, ast_geoloc_profile::suppress_empty_ca_elements, ast_geoloc_eprofile::suppress_empty_ca_elements, ast_geoloc_profile::usage_rules, and ast_geoloc_eprofile::usage_rules.
Referenced by ast_geoloc_datastore_create_from_profile_name(), geoloc_config_show_profiles(), handle_incoming_request(), and handle_outgoing_request().
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_uri | ( | const char * | uri, |
const char * | reference_string | ||
) |
Allocate a new effective profile from a URI.
uri | The URI to use. |
reference_string | An identifying string to use in error messages. |
Definition at line 316 of file geoloc_eprofile.c.
References ast_geoloc_eprofile_alloc(), AST_GEOLOC_FORMAT_URI, ast_strdupa, ast_strip(), ast_strlen_zero(), ast_variable_new, ast_geoloc_eprofile::format, ast_geoloc_eprofile::location_info, NULL, and set_loc_src().
Referenced by handle_incoming_request().
struct ast_geoloc_eprofile * ast_geoloc_eprofile_dup | ( | struct ast_geoloc_eprofile * | src | ) |
Duplicate an effective profile.
src | The eprofile to duplicate. |
Definition at line 159 of file geoloc_eprofile.c.
References ast_geoloc_eprofile::allow_routing_use, ao2_ref, ast_geoloc_eprofile_alloc(), ast_strdupa, ast_string_field_set, ast_geoloc_eprofile::confidence, DUP_VARS, ast_geoloc_eprofile::effective_location, ast_geoloc_eprofile::format, ast_geoloc_eprofile::id, ast_geoloc_eprofile::location_info, ast_geoloc_eprofile::location_reference, ast_geoloc_eprofile::location_refinement, ast_geoloc_eprofile::location_source, ast_geoloc_eprofile::location_variables, ast_geoloc_eprofile::method, method, ast_geoloc_eprofile::notes, notes, NULL, ast_geoloc_eprofile::pidf_element, ast_geoloc_eprofile::precedence, ast_geoloc_eprofile::suppress_empty_ca_elements, and ast_geoloc_eprofile::usage_rules.
Referenced by geoloc_profile_read().
int ast_geoloc_eprofile_refresh_location | ( | struct ast_geoloc_eprofile * | eprofile | ) |
Refresh the effective profile with any changed info.
eprofile | The eprofile to refresh. |
Definition at line 80 of file geoloc_eprofile.c.
References ao2_ref, ast_log, ast_sorcery_retrieve_by_id(), ast_string_field_set, ast_strlen_zero(), ast_variable_list_append, ast_variable_list_replace(), ast_variable_new, ast_variables_destroy(), ast_geoloc_location::confidence, ast_geoloc_eprofile::confidence, DUP_VARS, ast_geoloc_eprofile::effective_location, ast_geoloc_location::format, ast_geoloc_eprofile::format, geoloc_sorcery, ast_geoloc_eprofile::id, ast_geoloc_location::location_info, ast_geoloc_eprofile::location_info, ast_geoloc_eprofile::location_reference, ast_geoloc_eprofile::location_refinement, ast_geoloc_location::location_source, ast_geoloc_eprofile::location_source, LOG_ERROR, ast_geoloc_location::method, ast_geoloc_eprofile::method, method, NULL, RAII_VAR, and var.
Referenced by ast_geoloc_eprofile_create_from_profile(), geoloc_profile_read(), geoloc_profile_write(), and handle_outgoing_request().
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.
eprofile | Effective profile to convert |
chan | Channel to use to resolve variables |
buf | Pointer to ast_str pointer to use for work |
ref_string | An identifying string to use in error messages. |
Definition at line 1061 of file geoloc_eprofile.c.
References AST_GEOLOC_FORMAT_URI, ast_str_buffer(), ast_str_set(), ast_strlen_zero(), ast_trace, ast_xml_add_child(), ast_xml_close(), ast_xml_doc_dump_memory(), ast_xml_free_attr(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_new(), ast_xml_new_node(), ast_xml_set_attribute(), ast_xml_set_root(), buf, eprofile_to_pidf_xslt, ast_geoloc_eprofile::format, geoloc_eprofile_to_intermediate(), ast_geoloc_eprofile::id, LOG_ERROR, NULL, ast_geoloc_eprofile::pidf_element, RAII_VAR, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, ast_geoloc_eprofile::suppress_empty_ca_elements, and TRACE_ATLEAST.
Referenced by add_eprofile_to_tdata().
const char * ast_geoloc_eprofile_to_uri | ( | struct ast_geoloc_eprofile * | eprofile, |
struct ast_channel * | chan, | ||
struct ast_str ** | buf, | ||
const char * | ref_string | ||
) |
Convert a URI eprofile to a URI string.
eprofile | Effective profile to convert |
chan | Channel to use to resolve variables |
buf | Pointer to ast_str pointer to use for work |
ref_string | An identifying string to use in error messages. |
Definition at line 400 of file geoloc_eprofile.c.
References ast_free, AST_GEOLOC_FORMAT_URI, ast_log, ast_str_append(), ast_str_buffer(), ast_str_create, ast_strdupa, ast_strlen_zero(), ast_variable_find_in_list(), ast_variables_destroy(), buf, ast_geoloc_eprofile::effective_location, ast_geoloc_eprofile::format, geoloc_eprofile_resolve_varlist(), ast_geoloc_eprofile::id, ast_geoloc_eprofile::location_variables, LOG_ERROR, NULL, and result.
Referenced by handle_outgoing_request().
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.
ds | Datastore containing effective profiles to convert |
chan | Channel to use to resolve variables |
buf | Pointer to ast_str pointer to use for work |
ref_string | An identifying string to use in error messages. |
Definition at line 954 of file geoloc_eprofile.c.
References ast_geoloc_datastore_get_eprofile(), ast_geoloc_datastore_size(), AST_GEOLOC_FORMAT_URI, AST_PIDF_ELEMENT_LAST, ast_str_buffer(), ast_str_set(), ast_strlen_zero(), ast_trace, ast_xml_add_child(), ast_xml_add_child_list(), ast_xml_close(), ast_xml_copy_node_list(), ast_xml_doc_dump_memory(), ast_xml_find_child_element, ast_xml_free_attr(), ast_xml_free_node(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_new(), ast_xml_new_node(), ast_xml_node_get_children(), ast_xml_set_attribute(), ast_xml_set_root(), buf, eprofile_to_pidf_xslt, ast_geoloc_eprofile::format, geoloc_eprofile_to_intermediate(), ast_geoloc_eprofile::id, LOG_ERROR, NULL, ast_geoloc_eprofile::pidf_element, RAII_VAR, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, and TRACE_ATLEAST.
|
static |
Definition at line 592 of file geoloc_eprofile.c.
References ao2_ref, ast_geoloc_eprofile_alloc(), AST_GEOLOC_FORMAT_CIVIC_ADDRESS, AST_GEOLOC_FORMAT_GML, AST_GEOLOC_FORMAT_NONE, ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_trace, ast_xml_doc_dump_memory(), ast_xml_find_child_element, ast_xml_free_attr(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_get_root(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_geoloc_eprofile::confidence, ast_geoloc_eprofile::format, ast_geoloc_eprofile::location_info, LOG_ERROR, method, notes, NULL, ast_geoloc_eprofile::pidf_element, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, TRACE_ATLEAST, ast_geoloc_eprofile::usage_rules, var_list_from_confidence(), var_list_from_loc_info(), and var_list_from_node().
Referenced by ast_geoloc_eprofile_create_from_pidf().
|
static |
Definition at line 56 of file geoloc_eprofile.c.
References ast_string_field_free_memory, ast_variables_destroy(), ast_geoloc_eprofile::confidence, ast_geoloc_eprofile::effective_location, ast_geoloc_eprofile::location_info, ast_geoloc_eprofile::location_refinement, ast_geoloc_eprofile::location_variables, and ast_geoloc_eprofile::usage_rules.
Referenced by ast_geoloc_eprofile_alloc().
int geoloc_eprofile_load | ( | void | ) |
Definition at line 1178 of file geoloc_eprofile.c.
References _binary_res_geolocation_eprofile_to_pidf_xslt_end, _binary_res_geolocation_eprofile_to_pidf_xslt_start, _binary_res_geolocation_pidf_lo_test_xml_end, _binary_res_geolocation_pidf_lo_test_xml_start, _binary_res_geolocation_pidf_to_eprofile_xslt_end, _binary_res_geolocation_pidf_to_eprofile_xslt_start, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, eprofile_to_pidf_xslt, eprofile_to_pidf_xslt_size, geoloc_get_sorcery(), geoloc_sorcery, load_tests(), LOG_ERROR, pidf_lo_test_xml_size, pidf_to_eprofile_xslt, and pidf_to_eprofile_xslt_size.
Referenced by load_module().
int geoloc_eprofile_reload | ( | void | ) |
Definition at line 1211 of file geoloc_eprofile.c.
References AST_MODULE_LOAD_SUCCESS.
Referenced by reload_module().
struct ast_variable * geoloc_eprofile_resolve_varlist | ( | struct ast_variable * | source, |
struct ast_variable * | variables, | ||
struct ast_channel * | chan | ||
) |
Definition at line 351 of file geoloc_eprofile.c.
References ast_str_alloca, ast_str_buffer(), ast_str_reset(), ast_str_substitute_variables_full2(), ast_var_assign, ast_var_list_create(), ast_var_list_destroy(), AST_VAR_LIST_INSERT_TAIL(), ast_variable_list_append, ast_variable_new, ast_variables_destroy(), buf, NULL, and var.
Referenced by ast_geoloc_eprofile_to_uri(), and geoloc_eprofile_to_intermediate().
|
static |
Definition at line 821 of file geoloc_eprofile.c.
References AST_GEOLOC_FORMAT_CIVIC_ADDRESS, ast_strlen_zero(), ast_tvnow(), ast_variable_find_in_list(), ast_variables_destroy(), ast_xml_add_child(), ast_xml_free_node(), ast_xml_new_child(), ast_xml_new_node(), ast_xml_set_attribute(), ast_xml_set_text(), ast_geoloc_eprofile::confidence, ast_geoloc_eprofile::effective_location, ast_geoloc_eprofile::format, geoloc_civicaddr_list_to_xml(), geoloc_eprofile_resolve_varlist(), geoloc_gml_list_to_xml(), ast_geoloc_eprofile::location_variables, LOG_ERROR, ast_geoloc_eprofile::method, ast_geoloc_eprofile::notes, NULL, RAII_VAR, S_OR, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, ast_geoloc_eprofile::usage_rules, value, and var.
Referenced by ast_geoloc_eprofile_to_pidf(), and ast_geoloc_eprofiles_to_pidf().
int geoloc_eprofile_unload | ( | void | ) |
Definition at line 1160 of file geoloc_eprofile.c.
References AST_MODULE_LOAD_SUCCESS, ast_sorcery_unref, eprofile_to_pidf_xslt, geoloc_sorcery, pidf_to_eprofile_xslt, and unload_tests().
Referenced by unload_module().
|
static |
Definition at line 722 of file geoloc_eprofile.c.
References ast_strings_equal(), ast_xml_find_child_element, ast_xml_get_root(), ast_xml_node_get_children(), ast_xml_node_get_name(), and NULL.
Referenced by ast_geoloc_eprofile_create_from_pidf().
|
static |
|
static |
Definition at line 286 of file geoloc_eprofile.c.
References ast_begins_with(), ast_log, ast_sockaddr_parse(), ast_strdupa, ast_string_field_set, ast_strlen_zero(), LOG_WARNING, NULL, and PARSE_PORT_FORBID.
Referenced by ast_geoloc_eprofile_create_from_pidf(), and ast_geoloc_eprofile_create_from_uri().
|
static |
|
static |
Definition at line 552 of file geoloc_eprofile.c.
References ast_free, ast_str_buffer(), ast_trace, ast_variable_list_append, ast_variable_list_join(), ast_variable_new, ast_variables_destroy(), ast_xml_free_attr(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_get_text(), buf, NULL, S_OR, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, TRACE_ATLEAST, value, and var.
Referenced by geoloc_eprofile_create_from_xslt_result().
|
static |
Definition at line 497 of file geoloc_eprofile.c.
References ast_free, AST_GEOLOC_FORMAT_CIVIC_ADDRESS, ast_log, ast_str_buffer(), ast_trace, ast_variable_list_append, ast_variable_list_join(), ast_variable_new, ast_variables_destroy(), ast_xml_free_attr(), ast_xml_get_attribute(), ast_xml_node_get_children(), ast_xml_node_get_name(), buf, container, LOG_WARNING, NULL, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, TRACE_ATLEAST, var, and var_list_from_node().
Referenced by geoloc_eprofile_create_from_xslt_result().
|
static |
Definition at line 453 of file geoloc_eprofile.c.
References ast_free, ast_str_buffer(), ast_trace, ast_variable_list_append, ast_variable_list_join(), ast_variable_new, ast_variables_destroy(), ast_xml_free_attr(), ast_xml_free_text(), ast_xml_get_attribute(), ast_xml_get_text(), ast_xml_node_get_children(), ast_xml_node_get_name(), ast_xml_node_get_next(), buf, container, name, NULL, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, TRACE_ATLEAST, value, and var.
Referenced by geoloc_eprofile_create_from_xslt_result(), and var_list_from_loc_info().
|
extern |
Referenced by geoloc_eprofile_load().
|
extern |
Referenced by geoloc_eprofile_load().
|
extern |
Referenced by geoloc_eprofile_load().
|
extern |
Referenced by geoloc_eprofile_load().
|
extern |
Referenced by geoloc_eprofile_load().
|
extern |
Referenced by geoloc_eprofile_load().
|
static |
Definition at line 37 of file geoloc_eprofile.c.
Referenced by ast_geoloc_eprofile_to_pidf(), ast_geoloc_eprofiles_to_pidf(), geoloc_eprofile_load(), and geoloc_eprofile_unload().
|
static |
Definition at line 35 of file geoloc_eprofile.c.
Referenced by geoloc_eprofile_load().
|
static |
Definition at line 40 of file geoloc_eprofile.c.
Referenced by ast_geoloc_eprofile_refresh_location(), geoloc_eprofile_load(), and geoloc_eprofile_unload().
|
static |
Definition at line 31 of file geoloc_eprofile.c.
Referenced by geoloc_eprofile_load().
|
static |
Definition at line 38 of file geoloc_eprofile.c.
Referenced by ast_geoloc_eprofile_create_from_pidf(), geoloc_eprofile_load(), and geoloc_eprofile_unload().
|
static |
Definition at line 27 of file geoloc_eprofile.c.
Referenced by geoloc_eprofile_load().