Asterisk - The Open Source Telephony Project GIT-master-4f2b068
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
geoloc_dialplan.c File Reference
#include "asterisk.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/strings.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "geoloc_private.h"
Include dependency graph for geoloc_dialplan.c:

Go to the source code of this file.

Macros

#define RESOLVE_FOR_READ(_param)
 
#define RESOLVE_FOR_WRITE(_param)
 
#define RESOLVE_STRINGFIELD_FOR_READ(_param)
 
#define RESOLVE_STRINGFIELD_FOR_WRITE(_param, _value)
 
#define TEST_ENUM_VALUE(_chan_name, _ep, _field, _value)
 
#define TEST_VARLIST(_chan_name, _ep, _field, _value)
 
#define VAR_LIST_REPLACE(_old, _new)
 

Enumerations

enum  my_app_option_flags { OPT_GEOLOC_RESOLVE = (1 << 0) , OPT_GEOLOC_APPEND = (1 << 1) }
 

Functions

int geoloc_dialplan_load (void)
 
int geoloc_dialplan_reload (void)
 
int geoloc_dialplan_unload (void)
 
static int geoloc_profile_read (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
 
static int geoloc_profile_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static void varlist_to_str (struct ast_variable *list, struct ast_str **buf, size_t len)
 

Variables

static const struct ast_app_option action_options [128] = { [ 'r' ] = { .flag = OPT_GEOLOC_RESOLVE }, [ 'a' ] = { .flag = OPT_GEOLOC_APPEND }, }
 
static struct ast_custom_function geoloc_function
 

Macro Definition Documentation

◆ RESOLVE_FOR_READ

#define RESOLVE_FOR_READ (   _param)

Definition at line 39 of file geoloc_dialplan.c.

40 { \
41 if (ast_test_flag(&opts, OPT_GEOLOC_RESOLVE)) { \
43 eprofile->_param, eprofile->location_variables, chan); \
44 if (!resolved) { \
45 ast_log(LOG_ERROR, "%s: Unable to resolve " #_param "\n", chan_name); \
46 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \
47 return 0; \
48 } \
49 varlist_to_str(resolved, buf, len); \
50 ast_variables_destroy(resolved); \
51 } else { \
52 varlist_to_str(eprofile->_param, buf, len); \
53 } \
54})
char buf[BUFSIZE]
Definition eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
@ OPT_GEOLOC_RESOLVE
struct ast_variable * geoloc_eprofile_resolve_varlist(struct ast_variable *source, struct ast_variable *variables, struct ast_channel *chan)
#define LOG_ERROR
Structure for variables, used for configurations and for channel variables.
#define ast_test_flag(p, flag)
Definition utils.h:64

◆ RESOLVE_FOR_WRITE

#define RESOLVE_FOR_WRITE (   _param)

Definition at line 229 of file geoloc_dialplan.c.

230 { \
231if (ast_test_flag(&opts, OPT_GEOLOC_RESOLVE)) { \
233 eprofile->_param, eprofile->location_variables, chan); \
234 if (!resolved) { \
235 ast_log(LOG_ERROR, "%s: Unable to resolve " #_param " %p %p\n", chan_name, eprofile->_param, eprofile->location_variables); \
236 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \
237 return 0; \
238 } \
239 VAR_LIST_REPLACE(eprofile->_param, resolved); \
240} \
241})

◆ RESOLVE_STRINGFIELD_FOR_READ

#define RESOLVE_STRINGFIELD_FOR_READ (   _param)

Definition at line 56 of file geoloc_dialplan.c.

57 { \
58 if (ast_test_flag(&opts, OPT_GEOLOC_RESOLVE)) { \
59 char *resolved = geoloc_eprofile_resolve_string( \
60 eprofile->_param, eprofile->location_variables, chan); \
61 if (!resolved) { \
62 ast_log(LOG_ERROR, "%s: Unable to resolve " #_param "\n", chan_name); \
63 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \
64 return 0; \
65 } \
66 ast_str_append(buf, len, "%s", resolved); \
67 ast_free(resolved); \
68 } else { \
69 ast_str_append(buf, len, "%s", eprofile->_param); \
70 } \
71})
char * geoloc_eprofile_resolve_string(const char *source, struct ast_variable *variables, struct ast_channel *chan)

◆ RESOLVE_STRINGFIELD_FOR_WRITE

#define RESOLVE_STRINGFIELD_FOR_WRITE (   _param,
  _value 
)

Definition at line 243 of file geoloc_dialplan.c.

244 { \
245if (ast_test_flag(&opts, OPT_GEOLOC_RESOLVE)) { \
246 char *resolved = geoloc_eprofile_resolve_string( \
247 _value, eprofile->location_variables, chan); \
248 if (!resolved) { \
249 ast_log(LOG_ERROR, "%s: Unable to resolve " #_param " %p %p\n", chan_name, eprofile->_param, eprofile->location_variables); \
250 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \
251 return 0; \
252 } \
253 ast_string_field_set(eprofile, _param, resolved); \
254 ast_free(resolved); \
255} else { \
256 ast_string_field_set(eprofile, _param, _value); \
257} \
258})

◆ TEST_ENUM_VALUE

#define TEST_ENUM_VALUE (   _chan_name,
  _ep,
  _field,
  _value 
)

Definition at line 200 of file geoloc_dialplan.c.

201 { \
202 enum ast_geoloc_ ## _field v; \
203 v = ast_geoloc_ ## _field ## _str_to_enum(_value); \
204 if (v == AST_GEOLOC_INVALID_VALUE) { \
205 ast_log(LOG_ERROR, "%s: %s '%s' is invalid\n", _chan_name, #_field, value); \
206 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \
207 return 0; \
208 } \
209 _ep->_field = v; \
210})
#define AST_GEOLOC_INVALID_VALUE
int value
Definition syslog.c:37

◆ TEST_VARLIST

#define TEST_VARLIST (   _chan_name,
  _ep,
  _field,
  _value 
)

Definition at line 212 of file geoloc_dialplan.c.

213 { \
214 struct ast_variable *_list; \
215 _list = ast_variable_list_from_quoted_string(_value, ",", "=", "\"" ); \
216 if (!_list) { \
217 ast_log(LOG_ERROR, "%s: %s '%s' is malformed or contains invalid values", _chan_name, #_field, _value); \
218 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \
219 return 0; \
220 } \
221 if (ast_test_flag(&opts, OPT_GEOLOC_APPEND)) { \
222 ast_variable_list_append(&_ep->_field, _list); \
223 } else {\
224 VAR_LIST_REPLACE(_ep->_field, _list); \
225 } \
226})
@ OPT_GEOLOC_APPEND
struct ast_variable * ast_variable_list_from_quoted_string(const char *input, const char *item_separator, const char *name_value_separator, const char *quote_str)
Parse a string into an ast_variable list. The reverse of ast_variable_list_join.

◆ VAR_LIST_REPLACE

#define VAR_LIST_REPLACE (   _old,
  _new 
)
Value:
_old = _new;
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition extconf.c:1260

Definition at line 196 of file geoloc_dialplan.c.

Enumeration Type Documentation

◆ my_app_option_flags

Enumerator
OPT_GEOLOC_RESOLVE 
OPT_GEOLOC_APPEND 

Definition at line 73 of file geoloc_dialplan.c.

73 {
74 OPT_GEOLOC_RESOLVE = (1 << 0),
75 OPT_GEOLOC_APPEND = (1 << 1),
76};

Function Documentation

◆ geoloc_dialplan_load()

int geoloc_dialplan_load ( void  )

Definition at line 405 of file geoloc_dialplan.c.

406{
407 int res = 0;
408
410
412}
static struct ast_custom_function geoloc_function
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
#define ast_custom_function_register(acf)
Register a custom function.
Definition pbx.h:1562

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and geoloc_function.

Referenced by load_module().

◆ geoloc_dialplan_reload()

int geoloc_dialplan_reload ( void  )

Definition at line 414 of file geoloc_dialplan.c.

415{
417}

References AST_MODULE_LOAD_SUCCESS.

Referenced by reload_module().

◆ geoloc_dialplan_unload()

int geoloc_dialplan_unload ( void  )

Definition at line 398 of file geoloc_dialplan.c.

399{
401
403}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), AST_MODULE_LOAD_SUCCESS, and geoloc_function.

Referenced by unload_module().

◆ geoloc_profile_read()

static int geoloc_profile_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  buf,
ssize_t  len 
)
static

Definition at line 84 of file geoloc_dialplan.c.

86{
87 char *parsed_data = ast_strdupa(data);
88 const char *chan_name = ast_channel_name(chan);
89 struct ast_datastore *ds;
90 struct ast_geoloc_eprofile *orig_eprofile = NULL;
91 struct ast_geoloc_eprofile *eprofile = NULL;
92 struct ast_flags opts = { 0, };
93
95 AST_APP_ARG(field);
97 );
98
99 /* Check for zero arguments */
100 if (ast_strlen_zero(parsed_data)) {
101 ast_log(LOG_ERROR, "%s: Cannot call without arguments\n", chan_name);
102 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-1");
103 return 0;
104 }
105
106 AST_STANDARD_APP_ARGS(args, parsed_data);
107
108 if (ast_strlen_zero(args.field)) {
109 ast_log(LOG_ERROR, "%s: Cannot call without a field to query\n", chan_name);
110 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-1");
111 return 0;
112 }
113
114 if (!ast_strlen_zero(args.options)) {
115 if (ast_app_parse_options(action_options, &opts, NULL, args.options)) {
116 ast_log(LOG_ERROR, "%s: Invalid options: %s\n", chan_name, args.options);
117 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-1");
118 return 0;
119 }
120 }
121
122 ds = ast_geoloc_datastore_find(chan);
123 if (!ds) {
124 ast_log(LOG_NOTICE, "%s: There is no geoloc profile on this channel\n", chan_name);
125 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-2");
126 return 0;
127 }
128
129 orig_eprofile = ast_geoloc_datastore_get_eprofile(ds, 0);
130 if (!orig_eprofile) {
131 ast_log(LOG_NOTICE, "%s: There is no geoloc profile on this channel\n", chan_name);
132 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-2");
133 return 0;
134 }
135
136 eprofile = ast_geoloc_eprofile_dup(orig_eprofile);
137 ao2_ref(orig_eprofile, -1);
138 if (!eprofile) {
139 ast_log(LOG_ERROR, "%s: Unable to duplicate eprofile\n", chan_name);
140 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-2");
141 return 0;
142 }
143
144 if (!eprofile->effective_location) {
146 }
147
148 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "0");
149 if (ast_strings_equal(args.field, "inheritable")) {
150 ast_str_append(buf, len, "%s", ds->inheritance ? "true" : "false");
151 } else if (ast_strings_equal(args.field, "id")) {
152 ast_str_append(buf, len, "%s", eprofile->id);
153 } else if (ast_strings_equal(args.field, "location_reference")) {
154 ast_str_append(buf, len, "%s", eprofile->location_reference);
155 } else if (ast_strings_equal(args.field, "method")) {
156 ast_str_append(buf, len, "%s", eprofile->method);
157 } else if (ast_strings_equal(args.field, "allow_routing_use")) {
158 ast_str_append(buf, len, "%s", eprofile->allow_routing_use ? "yes" : "no");
159 } else if (ast_strings_equal(args.field, "suppress_empty_ca_elements")) {
160 ast_str_append(buf, len, "%s", eprofile->suppress_empty_ca_elements ? "yes" : "no");
161 } else if (ast_strings_equal(args.field, "profile_precedence")) {
162 ast_str_append(buf, len, "%s", ast_geoloc_precedence_to_name(eprofile->precedence));
163 } else if (ast_strings_equal(args.field, "format")) {
164 ast_str_append(buf, len, "%s", ast_geoloc_format_to_name(eprofile->format));
165 } else if (ast_strings_equal(args.field, "pidf_element")) {
166 ast_str_append(buf, len, "%s", ast_geoloc_pidf_element_to_name(eprofile->pidf_element));
167 } else if (ast_strings_equal(args.field, "pidf_element_id")) {
168 RESOLVE_STRINGFIELD_FOR_READ(pidf_element_id);
169 } else if (ast_strings_equal(args.field, "location_source")) {
170 ast_str_append(buf, len, "%s", eprofile->location_source);
171 } else if (ast_strings_equal(args.field, "notes")) {
172 ast_str_append(buf, len, "%s", eprofile->notes);
173 } else if (ast_strings_equal(args.field, "location_info")) {
174 RESOLVE_FOR_READ(location_info);
175 } else if (ast_strings_equal(args.field, "location_info_refinement")) {
176 RESOLVE_FOR_READ(location_refinement);
177 } else if (ast_strings_equal(args.field, "location_variables")) {
178 RESOLVE_FOR_READ(location_variables);
179 } else if (ast_strings_equal(args.field, "effective_location")) {
180 RESOLVE_FOR_READ(effective_location);
181 } else if (ast_strings_equal(args.field, "usage_rules")) {
182 RESOLVE_FOR_READ(usage_rules);
183 } else if (ast_strings_equal(args.field, "confidence")) {
184 varlist_to_str(eprofile->confidence, buf, len);
185 } else if (ast_strings_equal(args.field, "device_id")) {
187 } else {
188 ast_log(LOG_ERROR, "%s: Field '%s' is not valid\n", chan_name, args.field);
189 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3");
190 }
191
192 ao2_ref(eprofile, -1);
193 return 0;
194}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
#define ast_log
Definition astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
const char * ast_channel_name(const struct ast_channel *chan)
static const struct ast_app_option action_options[128]
#define RESOLVE_FOR_READ(_param)
#define RESOLVE_STRINGFIELD_FOR_READ(_param)
static void varlist_to_str(struct ast_variable *list, struct ast_str **buf, size_t len)
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition main/app.c:3066
#define LOG_NOTICE
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
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.
struct ast_geoloc_eprofile * ast_geoloc_datastore_get_eprofile(struct ast_datastore *ds, int ix)
Retrieve a specific eprofile from a datastore by index.
struct ast_datastore * ast_geoloc_datastore_find(struct ast_channel *chan)
Retrieves the geoloc datastore from a channel, if any.
static struct @522 args
#define NULL
Definition resample.c:96
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
Definition strings.c:238
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
Structure for a data store object.
Definition datastore.h:64
unsigned int inheritance
Definition datastore.h:69
Structure used to handle boolean flags.
Definition utils.h:220
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
enum ast_geoloc_precedence precedence
const ast_string_field notes
const ast_string_field id
struct ast_variable * confidence
const ast_string_field location_source
static struct test_options options

References action_options, ast_geoloc_eprofile::allow_routing_use, ao2_ref, args, AST_APP_ARG, ast_app_parse_options(), ast_channel_name(), AST_DECLARE_APP_ARGS, ast_geoloc_datastore_find(), ast_geoloc_datastore_get_eprofile(), ast_geoloc_eprofile_dup(), ast_geoloc_eprofile_refresh_location(), ast_log, AST_STANDARD_APP_ARGS, ast_str_append(), ast_strdupa, ast_strings_equal(), ast_strlen_zero(), buf, ast_geoloc_eprofile::confidence, ast_geoloc_eprofile::effective_location, ast_geoloc_eprofile::format, ast_geoloc_eprofile::id, ast_datastore::inheritance, len(), ast_geoloc_eprofile::location_reference, ast_geoloc_eprofile::location_source, LOG_ERROR, LOG_NOTICE, ast_geoloc_eprofile::method, ast_geoloc_eprofile::notes, NULL, options, pbx_builtin_setvar_helper(), ast_geoloc_eprofile::pidf_element, ast_geoloc_eprofile::precedence, RESOLVE_FOR_READ, RESOLVE_STRINGFIELD_FOR_READ, ast_geoloc_eprofile::suppress_empty_ca_elements, and varlist_to_str().

◆ geoloc_profile_write()

static int geoloc_profile_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 260 of file geoloc_dialplan.c.

262{
263 char *parsed_data = ast_strdupa(data);
264 const char *chan_name = ast_channel_name(chan);
265 struct ast_datastore *ds; /* Reminder: datastores aren't ao2 objects */
266 RAII_VAR(struct ast_geoloc_eprofile *, eprofile, NULL, ao2_cleanup);
267 struct ast_flags opts = { 0, };
268
270 AST_APP_ARG(field);
272 );
273
274 /* Check for zero arguments */
275 if (ast_strlen_zero(parsed_data)) {
276 ast_log(LOG_ERROR, "%s: Cannot call without arguments\n", chan_name);
277 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-1");
278 return 0;
279 }
280
281 AST_STANDARD_APP_ARGS(args, parsed_data);
282
283 if (ast_strlen_zero(args.field)) {
284 ast_log(LOG_ERROR, "%s: Cannot call without a field to set\n", chan_name);
285 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-1");
286 return 0;
287 }
288
289 if (!ast_strlen_zero(args.options)) {
290 if (ast_app_parse_options(action_options, &opts, NULL, args.options)) {
291 ast_log(LOG_ERROR, "%s: Invalid options: %s\n", chan_name, args.options);
292 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-1");
293 return 0;
294 }
295 }
296
297 ast_debug(1, "%s: name: %s value: %s options: %s append: %s resolve: %s\n", chan_name,
298 args.field, value, args.options, ast_test_flag(&opts, OPT_GEOLOC_APPEND) ? "yes" : "no",
299 ast_test_flag(&opts, OPT_GEOLOC_RESOLVE) ? "yes" : "no");
300
301 ds = ast_geoloc_datastore_find(chan);
302 if (!ds) {
304 if (!ds) {
305 ast_log(LOG_WARNING, "%s: Unable to create geolocation datastore\n", chan_name);
306 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-2");
307 return 0;
308 }
310 }
311
312 eprofile = ast_geoloc_datastore_get_eprofile(ds, 0);
313 if (!eprofile) {
314 int rc;
315 eprofile = ast_geoloc_eprofile_alloc(chan_name);
316 if (!eprofile) {
317 ast_log(LOG_ERROR, "%s: Could not allocate eprofile\n", chan_name);
318 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-2");
319 return 0;
320 }
321 rc = ast_geoloc_datastore_add_eprofile(ds, eprofile);
322 if (rc <= 0) {
323 ast_log(LOG_ERROR, "%s: Could not add eprofile to datastore\n", chan_name);
324 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-2");
325 return 0;
326 }
327 }
328
329 if (ast_strings_equal(args.field, "inheritable")) {
331 } else if (ast_strings_equal(args.field, "id")) {
332 ast_string_field_set(eprofile, id, value);
333 } else if (ast_strings_equal(args.field, "location_reference")) {
335 ao2_cleanup(loc);
336 if (!loc) {
337 ast_log(LOG_ERROR, "%s: Location reference '%s' doesn't exist\n", chan_name, value);
338 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3");
339 return 0;
340 }
341 ast_string_field_set(eprofile, location_reference, value);
342 } else if (ast_strings_equal(args.field, "method")) {
344 } else if (ast_strings_equal(args.field, "allow_routing_use")) {
345 eprofile->allow_routing_use = ast_true(value);
346 } else if (ast_strings_equal(args.field, "suppress_empty_ca_elements")) {
347 eprofile->suppress_empty_ca_elements = ast_true(value);
348 } else if (ast_strings_equal(args.field, "profile_precedence")) {
349 TEST_ENUM_VALUE(chan_name, eprofile, precedence, value);
350 } else if (ast_strings_equal(args.field, "format")) {
351 TEST_ENUM_VALUE(chan_name, eprofile, format, value);
352 } else if (ast_strings_equal(args.field, "pidf_element")) {
353 TEST_ENUM_VALUE(chan_name, eprofile, pidf_element, value);
354 } else if (ast_strings_equal(args.field, "pidf_element_id")) {
355 RESOLVE_STRINGFIELD_FOR_WRITE(pidf_element_id, value);
356 } else if (ast_strings_equal(args.field, "location_source")) {
358 } else if (ast_strings_equal(args.field, "notes")) {
359 ast_string_field_set(eprofile, notes, value);
360 } else if (ast_strings_equal(args.field, "location_info")) {
361 TEST_VARLIST(chan_name, eprofile, location_info, value);
363 } else if (ast_strings_equal(args.field, "location_info_refinement")) {
364 TEST_VARLIST(chan_name, eprofile, location_refinement, value);
365 RESOLVE_FOR_WRITE(location_refinement);
366 } else if (ast_strings_equal(args.field, "location_variables")) {
367 TEST_VARLIST(chan_name, eprofile, location_variables, value);
368 RESOLVE_FOR_WRITE(location_variables);
369 } else if (ast_strings_equal(args.field, "effective_location")) {
370 TEST_VARLIST(chan_name, eprofile, effective_location, value);
371 RESOLVE_FOR_WRITE(effective_location);
372 } else if (ast_strings_equal(args.field, "usage_rules")) {
373 TEST_VARLIST(chan_name, eprofile, usage_rules, value);
374 RESOLVE_FOR_WRITE(usage_rules);
375 } else if (ast_strings_equal(args.field, "confidence")) {
376 TEST_VARLIST(chan_name, eprofile, confidence, value);
377 } else if (ast_strings_equal(args.field, "device_id")) {
378 RESOLVE_STRINGFIELD_FOR_WRITE(pidf_element_id, value);
379 } else {
380 ast_log(LOG_ERROR, "%s: Field '%s' is not valid\n", chan_name, args.field);
381 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3");
382 return 0;
383 }
384
386
387 pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "0");
388
389 return 0;
390}
#define ao2_cleanup(obj)
Definition astobj2.h:1934
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2375
#define RESOLVE_STRINGFIELD_FOR_WRITE(_param, _value)
#define RESOLVE_FOR_WRITE(_param)
#define TEST_ENUM_VALUE(_chan_name, _ep, _field, _value)
#define TEST_VARLIST(_chan_name, _ep, _field, _value)
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
static int notes
Definition pval.c:66
struct ast_geoloc_location *AST_OPTIONAL_API_NAME() ast_geoloc_get_location(const char *id)
Retrieve a geolocation location object by id.
struct ast_datastore * ast_geoloc_datastore_create(const char *id)
Create an empty geoloc datastore.
struct ast_geoloc_eprofile * ast_geoloc_eprofile_alloc(const char *name)
Geolocation Effective Profile Functions.
int ast_geoloc_datastore_set_inheritance(struct ast_datastore *ds, int inherit)
Sets the inheritance flag on the datastore.
int ast_geoloc_datastore_add_eprofile(struct ast_datastore *ds, struct ast_geoloc_eprofile *eprofile)
Add an eprofile to a datastore.
const char * method
Definition res_pjsip.c:1273
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2235
enum ast_geoloc_format format
struct ast_variable * confidence
const ast_string_field location_source
struct ast_variable * location_info
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

References action_options, ao2_cleanup, args, AST_APP_ARG, ast_app_parse_options(), ast_channel_datastore_add(), ast_channel_name(), ast_debug, AST_DECLARE_APP_ARGS, ast_geoloc_datastore_add_eprofile(), ast_geoloc_datastore_create(), ast_geoloc_datastore_find(), ast_geoloc_datastore_get_eprofile(), ast_geoloc_datastore_set_inheritance(), ast_geoloc_eprofile_alloc(), ast_geoloc_eprofile_refresh_location(), ast_geoloc_get_location(), ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_string_field_set, ast_strings_equal(), ast_strlen_zero(), ast_test_flag, ast_true(), ast_geoloc_location::confidence, ast_geoloc_location::format, ast_geoloc_location::location_info, ast_geoloc_location::location_source, LOG_ERROR, LOG_WARNING, method, notes, NULL, OPT_GEOLOC_APPEND, OPT_GEOLOC_RESOLVE, options, pbx_builtin_setvar_helper(), RAII_VAR, RESOLVE_FOR_WRITE, RESOLVE_STRINGFIELD_FOR_WRITE, TEST_ENUM_VALUE, TEST_VARLIST, and value.

◆ varlist_to_str()

static void varlist_to_str ( struct ast_variable list,
struct ast_str **  buf,
size_t  len 
)
static

Definition at line 30 of file geoloc_dialplan.c.

31{
32 struct ast_variable *var = list;
33
34 for (; var; var = var->next) {
35 ast_str_append(buf, len, "%s=\"%s\"%s", var->name, var->value, var->next ? "," : "");
36 }
37}
#define var
Definition ast_expr2f.c:605

References ast_str_append(), buf, len(), and var.

Referenced by geoloc_profile_read().

Variable Documentation

◆ action_options

const struct ast_app_option action_options[128] = { [ 'r' ] = { .flag = OPT_GEOLOC_RESOLVE }, [ 'a' ] = { .flag = OPT_GEOLOC_APPEND }, }
static

Definition at line 81 of file geoloc_dialplan.c.

Referenced by geoloc_profile_read(), and geoloc_profile_write().

◆ geoloc_function

struct ast_custom_function geoloc_function
static
Initial value:
= {
.name = "GEOLOC_PROFILE",
}
static int geoloc_profile_read(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static int geoloc_profile_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)

Definition at line 392 of file geoloc_dialplan.c.

392 {
393 .name = "GEOLOC_PROFILE",
394 .read2 = geoloc_profile_read,
395 .write = geoloc_profile_write,
396};

Referenced by geoloc_dialplan_load(), and geoloc_dialplan_unload().