137 ast_log(
LOG_ERROR,
"Geolocation location '%s' format is set to '%s' but no 'URI' was found in location parameter '%s'\n",
154 ast_log(
LOG_ERROR,
"Geolocation location '%s' location_source '%s' must be a FQDN."
155 " RFC8787 expressly forbids IP addresses.\n",
156 id, location_source);
172 ast_log(
LOG_ERROR,
"Location '%s' is missing required element 'location_info'",
202 ast_log(
LOG_ERROR,
"Profile '%s' can't have location_reference and location_info or format at the same time",
226 ast_log(
LOG_ERROR,
"Profile '%s' has a location_reference '%s' that doesn't exist",
263 e->
command =
"geoloc list locations";
264 e->
usage =
"Usage: geoloc list locations [ like <pattern> ]\n"
265 " List Geolocation Location Objects\n";
271 if (
a->argc != 3 &&
a->argc != 5) {
276 if (strcasecmp(
a->argv[3],
"like")) {
284 if (!sorted_container) {
285 ast_cli(
a->fd,
"Geolocation Location Objects: Unable to allocate temporary container\n");
298 ao2_ref(unsorted_container, -1);
301 ast_cli(
a->fd,
"Geolocation Location Objects: Unable to sort temporary container\n");
305 ast_cli(
a->fd,
"Geolocation Location Objects:\n\n");
308 "<Object ID...................................> <Format.....> <Details.............>\n"
309 "===================================================================================\n");
320 ast_cli(
a->fd,
"Geolocation Location Objects: Unable to allocate temp string for '%s'\n",
326 ast_cli(
a->fd,
"%-46.46s %-13s %-s\n",
336 ast_cli(
a->fd,
"\nTotal Location Objects: %d\n\n", count);
354 e->
command =
"geoloc list profiles";
355 e->
usage =
"Usage: geoloc list profiles [ like <pattern> ]\n"
356 " List Geolocation Profile Objects\n";
362 if (
a->argc != 3 &&
a->argc != 5) {
367 if (strcasecmp(
a->argv[3],
"like")) {
375 if (!sorted_container) {
376 ast_cli(
a->fd,
"Geolocation Profile Objects: Unable to allocate temporary container\n");
389 ao2_ref(unsorted_container, -1);
392 ast_cli(
a->fd,
"Geolocation Profile Objects: Unable to sort temporary container\n");
396 ast_cli(
a->fd,
"Geolocation Profile Objects:\n\n");
399 "<Object ID...................................> <Profile Action> <Location Reference> \n"
400 "=====================================================================================\n");
406 ast_cli(
a->fd,
"%-46.46s %-16s %-s\n",
415 ast_cli(
a->fd,
"\nTotal Profile Objects: %d\n\n", count);
433 e->
command =
"geoloc show profiles";
434 e->
usage =
"Usage: geoloc show profiles [ like <pattern> ]\n"
435 " List Geolocation Profile Objects\n";
441 if (
a->argc != 3 &&
a->argc != 5) {
446 if (strcasecmp(
a->argv[3],
"like")) {
455 if (!sorted_container) {
456 ast_cli(
a->fd,
"Geolocation Profile Objects: Unable to allocate temporary container\n");
470 ao2_ref(unsorted_container, -1);
473 ast_cli(
a->fd,
"Geolocation Profile Objects: Unable to sort temporary container\n");
477 ast_cli(
a->fd,
"Geolocation Profile Objects:\n");
500 "profile_precedence: %-s\n"
501 "pidf_element: %-s\n"
502 "location_reference: %-s\n"
503 "location_format: %-s\n"
504 "location_info: %-s\n"
505 "location_method: %-s\n"
506 "location_source: %-s\n"
507 "location_confidence: %-s\n"
508 "location_refinement: %-s\n"
509 "location_variables: %-s\n"
510 "allow_routing_use: %-s\n"
511 "suppress_empty_elements: %-s\n"
512 "effective_location: %-s\n"
544 ast_cli(
a->fd,
"\nTotal Profile Objects: %d\n\n", count);
556 e->
usage =
"Usage: geoloc reload\n"
557 " Reload Geolocation Configuration\n";
568 ast_cli(
a->fd,
"Geolocation Configuration reloaded.\n");
627 sprintf(
id,
"<%s>",
name);
641 return rc == 0 ? 1 : 0;
672 ast_log(
LOG_ERROR,
"Failed to apply defaults for geoloc location object with sorcery\n");
678 ast_log(
LOG_ERROR,
"Failed to register geoloc location object with sorcery\n");
684 location_format_handler, location_format_to_str,
NULL, 0, 0);
686 location_location_info_handler, location_location_info_to_str, location_location_info_dup, 0, 0);
688 location_confidence_handler, location_confidence_to_str, location_confidence_dup, 0, 0);
701 ast_log(
LOG_ERROR,
"Failed to add memory wizard mapping to geoloc profile object\n");
706 "geolocation.conf,criteria=type=profile", 0);
708 ast_log(
LOG_ERROR,
"Failed to add memory wizard mapping to geoloc profile object\n");
713 ast_log(
LOG_ERROR,
"Failed to register geoloc profile object with sorcery\n");
723 profile_precedence_handler, profile_precedence_to_str,
NULL, 0, 0);
725 profile_usage_rules_handler, profile_usage_rules_to_str, profile_usage_rules_dup, 0, 0);
727 profile_location_refinement_handler, profile_location_refinement_to_str, profile_location_refinement_dup, 0, 0);
729 profile_location_variables_handler, profile_location_variables_to_str, profile_location_variables_dup, 0, 0);
738 profile_format_handler, profile_format_to_str,
NULL, 0, 0);
740 profile_location_info_handler, profile_location_info_to_str, profile_location_info_dup, 0, 0);
742 profile_confidence_handler, profile_confidence_to_str, profile_confidence_dup, 0, 0);
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy all object references in the src container into the dest container.
#define ao2_iterator_next(iter)
@ AO2_ALLOC_OPT_LOCK_NOLOCK
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a red-black tree container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
@ OPT_NOOP_T
Type for a default handler that should do nothing.
@ OPT_BOOL_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
static char * geoloc_config_list_locations(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void * geoloc_location_alloc(const char *name)
static char * geoloc_config_list_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_geoloc_location *AST_OPTIONAL_API_NAME() ast_geoloc_get_location(const char *id)
Retrieve a geolocation location object by id.
static const char * precedence_names[]
static struct ast_sorcery * geoloc_sorcery
static void geoloc_profile_destructor(void *obj)
int AST_OPTIONAL_API_NAME() ast_geoloc_is_loaded(void)
Check if res_geolocation is available.
int geoloc_config_reload(void)
static void * geoloc_profile_alloc(const char *name)
int geoloc_config_unload(void)
static int validate_location_source(const char *id, const char *location_source)
static const char * format_names[]
static int geoloc_location_apply_handler(const struct ast_sorcery *sorcery, void *obj)
static const char * pidf_element_names[]
int geoloc_config_load(void)
static enum ast_geoloc_validate_result validate_location_info(const char *id, enum ast_geoloc_format format, struct ast_variable *location_info)
static void geoloc_location_destructor(void *obj)
static char * geoloc_config_show_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * geoloc_config_cli_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int geoloc_profile_apply_handler(const struct ast_sorcery *sorcery, void *obj)
struct ast_sorcery * geoloc_get_sorcery(void)
static int geoloc_load_default_profiles(void)
struct ast_geoloc_profile *AST_OPTIONAL_API_NAME() ast_geoloc_get_profile(const char *id)
Retrieve a geolocation profile by id.
static int default_profile_create(const char *name)
static struct ast_cli_entry geoloc_location_cli_commands[]
#define CONFIG_ENUM_HANDLER(_object, _stem)
#define CONFIG_VAR_LIST(_object, _stem)
#define CONFIG_ENUM_TO_STR(_object, _stem)
#define CONFIG_ENUM(_object, _stem)
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.
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.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Asterisk module definitions.
@ 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.
#define AST_OPTIONAL_API_NAME(name)
Expands to the name of the implementation function.
const char * ast_geoloc_validate_result_to_str(enum ast_geoloc_validate_result result)
ast_geoloc_validate_result
@ AST_GEOLOC_VALIDATE_SUCCESS
@ AST_GEOLOC_VALIDATE_NOT_ENOUGH_VARNAMES
enum ast_geoloc_validate_result ast_geoloc_civicaddr_validate_varlist(const struct ast_variable *varlist, const char **result)
Validate that the names of the variables in the list are valid codes or synonyms.
@ AST_PIDF_ELEMENT_DEVICE
@ AST_GEOLOC_FORMAT_CIVIC_ADDRESS
struct ast_geoloc_eprofile * ast_geoloc_eprofile_create_from_profile(struct ast_geoloc_profile *profile)
Allocate a new effective profile from an existing profile.
enum ast_geoloc_validate_result ast_geoloc_gml_validate_varlist(const struct ast_variable *varlist, const char **result)
Validate that the variables in the list represent a valid GML shape.
static struct ast_sorcery * sorcery
#define ast_sorcery_apply_wizard_mapping(sorcery, type, name, data, caching)
Apply additional object wizard mappings.
#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.
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
void ast_sorcery_load(const struct ast_sorcery *sorcery)
Inform any wizards to load persistent objects.
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
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_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
void ast_sorcery_reload(const struct ast_sorcery *sorcery)
Inform any wizards to reload persistent objects.
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
int ast_sorcery_object_unregister(struct ast_sorcery *sorcery, const char *type)
Unregister an object type.
void ast_sorcery_ref(struct ast_sorcery *sorcery)
Increase the reference count of a sorcery structure.
#define ast_sorcery_apply_config(sorcery, name)
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
int ast_sorcery_object_id_sort(const void *obj, const void *arg, int flags)
ao2 object sorter based on sorcery id.
#define ast_sorcery_apply_default(sorcery, type, name, data)
#define ast_sorcery_open()
Open a new sorcery structure.
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
@ AST_SORCERY_APPLY_SUCCESS
#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
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
descriptor for a cli entry.
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
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
struct ast_variable * location_refinement
enum ast_geoloc_precedence precedence
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.
#define ast_assert_return(a,...)