Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions | Variables
config_global.c File Reference
#include "asterisk.h"
#include <pjsip.h>
#include <pjlib.h>
#include "asterisk/res_pjsip.h"
#include "include/res_pjsip_private.h"
#include "asterisk/pbx.h"
#include "asterisk/sorcery.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/ast_version.h"
#include "asterisk/res_pjsip_cli.h"
Include dependency graph for config_global.c:

Go to the source code of this file.

Data Structures

struct  global_config
 

Macros

#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL   30
 
#define DEFAULT_DEBUG   "no"
 
#define DEFAULT_DISABLE_MULTI_DOMAIN   0
 
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER   "ip,username,anonymous"
 
#define DEFAULT_FROM_USER   "asterisk"
 
#define DEFAULT_IGNORE_URI_USER_OPTIONS   0
 
#define DEFAULT_KEEPALIVE_INTERVAL   90
 
#define DEFAULT_MAX_FORWARDS   70
 
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME   0
 
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED   0
 
#define DEFAULT_MWI_TPS_QUEUE_HIGH   AST_TASKPROCESSOR_HIGH_WATER_LEVEL
 
#define DEFAULT_MWI_TPS_QUEUE_LOW   -1
 
#define DEFAULT_NOREFERSUB   1
 
#define DEFAULT_OUTBOUND_ENDPOINT   "default_outbound_endpoint"
 
#define DEFAULT_REALM   "asterisk"
 
#define DEFAULT_REGCONTEXT   ""
 
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION   0
 
#define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER   TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL
 
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT   5
 
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD   5
 
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL   30
 
#define DEFAULT_USE_CALLERID_CONTACT   0
 
#define DEFAULT_USERAGENT_PREFIX   "Asterisk PBX"
 
#define DEFAULT_VOICEMAIL_EXTENSION   ""
 

Functions

static AO2_GLOBAL_OBJ_STATIC (global_cfg)
 Cached global config object. More...
 
int ast_sip_destroy_sorcery_global (void)
 
unsigned int ast_sip_get_contact_expiration_check_interval (void)
 Retrieve the system contact expiration check interval setting. More...
 
char * ast_sip_get_debug (void)
 Retrieve the system debug setting (yes|no|host). More...
 
void ast_sip_get_default_from_user (char *from_user, size_t size)
 Retrieve the global default from user. More...
 
void ast_sip_get_default_realm (char *realm, size_t size)
 Retrieve the global default realm. More...
 
char * ast_sip_get_default_voicemail_extension (void)
 Retrieve the default voicemail extension. More...
 
unsigned int ast_sip_get_disable_multi_domain (void)
 Retrieve the system setting 'disable multi domain'. More...
 
char * ast_sip_get_endpoint_identifier_order (void)
 Retrieve the global endpoint_identifier_order setting. More...
 
unsigned int ast_sip_get_ignore_uri_user_options (void)
 Retrieve the global setting 'ignore_uri_user_options'. More...
 
unsigned int ast_sip_get_keep_alive_interval (void)
 Retrieve the system keep alive interval setting. More...
 
unsigned int ast_sip_get_max_initial_qualify_time (void)
 Retrieve the system max initial qualify time. More...
 
unsigned int ast_sip_get_mwi_disable_initial_unsolicited (void)
 Retrieve the global setting 'disable sending unsolicited mwi on startup'. More...
 
unsigned int ast_sip_get_mwi_tps_queue_high (void)
 Retrieve the global MWI taskprocessor high water alert trigger level. More...
 
int ast_sip_get_mwi_tps_queue_low (void)
 Retrieve the global MWI taskprocessor low water clear alert level. More...
 
unsigned int ast_sip_get_norefersub (void)
 Retrieve the global setting 'norefersub'. More...
 
char * ast_sip_get_regcontext (void)
 Retrieve the global regcontext setting. More...
 
unsigned int ast_sip_get_send_contact_status_on_update_registration (void)
 Retrieve the global setting 'send_contact_status_on_update_registration'. More...
 
enum ast_sip_taskprocessor_overload_trigger ast_sip_get_taskprocessor_overload_trigger (void)
 
void ast_sip_get_unidentified_request_thresholds (unsigned int *count, unsigned int *period, unsigned int *prune_interval)
 Retrieve the unidentified request security event thresholds. More...
 
unsigned int ast_sip_get_use_callerid_contact (void)
 Retrieve the global setting 'use_callerid_contact'. More...
 
char * ast_sip_global_default_outbound_endpoint (void)
 
int ast_sip_initialize_sorcery_global (void)
 
const char * ast_sip_overload_trigger_to_str (enum ast_sip_taskprocessor_overload_trigger trigger)
 
static int check_regcontext (const struct global_config *cfg)
 
static struct global_configget_global_cfg (void)
 
static void * global_alloc (const char *name)
 
static int global_apply (const struct ast_sorcery *sorcery, void *obj)
 
static void global_destructor (void *obj)
 
static void global_loaded_observer (const char *name, const struct ast_sorcery *sorcery, const char *object_type, int reloaded)
 
static int overload_trigger_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int overload_trigger_to_str (const void *obj, const intptr_t *args, char **buf)
 
int sip_cli_print_global (struct ast_sip_cli_context *context)
 

Variables

static char default_useragent [256]
 
static const struct ast_sorcery_instance_observer observer_callbacks_global
 
static const char * overload_trigger_map []
 
static char * previous_regcontext = NULL
 

Macro Definition Documentation

◆ DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL

#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL   30

◆ DEFAULT_DEBUG

#define DEFAULT_DEBUG   "no"

Definition at line 36 of file config_global.c.

Referenced by ast_sip_get_debug(), and ast_sip_initialize_sorcery_global().

◆ DEFAULT_DISABLE_MULTI_DOMAIN

#define DEFAULT_DISABLE_MULTI_DOMAIN   0

◆ DEFAULT_ENDPOINT_IDENTIFIER_ORDER

#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER   "ip,username,anonymous"

◆ DEFAULT_FROM_USER

#define DEFAULT_FROM_USER   "asterisk"

◆ DEFAULT_IGNORE_URI_USER_OPTIONS

#define DEFAULT_IGNORE_URI_USER_OPTIONS   0

◆ DEFAULT_KEEPALIVE_INTERVAL

#define DEFAULT_KEEPALIVE_INTERVAL   90

◆ DEFAULT_MAX_FORWARDS

#define DEFAULT_MAX_FORWARDS   70

Definition at line 32 of file config_global.c.

Referenced by ast_sip_initialize_sorcery_global().

◆ DEFAULT_MAX_INITIAL_QUALIFY_TIME

#define DEFAULT_MAX_INITIAL_QUALIFY_TIME   0

◆ DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED

#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED   0

◆ DEFAULT_MWI_TPS_QUEUE_HIGH

#define DEFAULT_MWI_TPS_QUEUE_HIGH   AST_TASKPROCESSOR_HIGH_WATER_LEVEL

◆ DEFAULT_MWI_TPS_QUEUE_LOW

#define DEFAULT_MWI_TPS_QUEUE_LOW   -1

◆ DEFAULT_NOREFERSUB

#define DEFAULT_NOREFERSUB   1

Definition at line 55 of file config_global.c.

Referenced by ast_sip_get_norefersub(), and ast_sip_initialize_sorcery_global().

◆ DEFAULT_OUTBOUND_ENDPOINT

#define DEFAULT_OUTBOUND_ENDPOINT   "default_outbound_endpoint"

◆ DEFAULT_REALM

#define DEFAULT_REALM   "asterisk"

Definition at line 40 of file config_global.c.

Referenced by ast_sip_get_default_realm(), and ast_sip_initialize_sorcery_global().

◆ DEFAULT_REGCONTEXT

#define DEFAULT_REGCONTEXT   ""

Definition at line 41 of file config_global.c.

Referenced by ast_sip_get_regcontext(), and ast_sip_initialize_sorcery_global().

◆ DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION

#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION   0

◆ DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER

#define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER   TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL

◆ DEFAULT_UNIDENTIFIED_REQUEST_COUNT

#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT   5

◆ DEFAULT_UNIDENTIFIED_REQUEST_PERIOD

#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD   5

◆ DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL

#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL   30

◆ DEFAULT_USE_CALLERID_CONTACT

#define DEFAULT_USE_CALLERID_CONTACT   0

◆ DEFAULT_USERAGENT_PREFIX

#define DEFAULT_USERAGENT_PREFIX   "Asterisk PBX"

Definition at line 34 of file config_global.c.

Referenced by ast_sip_initialize_sorcery_global().

◆ DEFAULT_VOICEMAIL_EXTENSION

#define DEFAULT_VOICEMAIL_EXTENSION   ""

Function Documentation

◆ AO2_GLOBAL_OBJ_STATIC()

static AO2_GLOBAL_OBJ_STATIC ( global_cfg  )
static

Cached global config object.

Cached so we don't have to keep asking sorcery for the config. We could ask for it hundreds of times a second if not more.

◆ ast_sip_destroy_sorcery_global()

int ast_sip_destroy_sorcery_global ( void  )

Definition at line 630 of file config_global.c.

References ao2_t_global_obj_release, ast_context_destroy_by_name(), ast_free, ast_sip_get_sorcery(), ast_sorcery_instance_observer_remove(), previous_regcontext, and sorcery.

Referenced by ast_res_pjsip_destroy_configuration().

631 {
633 
635 
636  if (previous_regcontext) {
639  }
640 
641  ao2_t_global_obj_release(global_cfg, "Module is unloading");
642 
643  return 0;
644 }
static char * previous_regcontext
static const struct ast_sorcery_instance_observer observer_callbacks_global
Full structure for sorcery.
Definition: sorcery.c:230
#define ao2_t_global_obj_release(holder, tag)
Release the ao2 object held in the global holder.
Definition: astobj2.h:863
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
Definition: pbx.c:8244
void ast_sorcery_instance_observer_remove(struct ast_sorcery *sorcery, const struct ast_sorcery_instance_observer *callbacks)
Remove an observer from a sorcery instance.
Definition: sorcery.c:537
#define ast_free(a)
Definition: astmm.h:182
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.

◆ ast_sip_get_contact_expiration_check_interval()

unsigned int ast_sip_get_contact_expiration_check_interval ( void  )

Retrieve the system contact expiration check interval setting.

Return values
thecontact expiration check interval.

Definition at line 309 of file config_global.c.

References ao2_ref, global_config::contact_expiration_check_interval, DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL, and get_global_cfg().

Referenced by expiration_global_loaded().

310 {
311  unsigned int interval;
312  struct global_config *cfg;
313 
314  cfg = get_global_cfg();
315  if (!cfg) {
317  }
318 
319  interval = cfg->contact_expiration_check_interval;
320  ao2_ref(cfg, -1);
321  return interval;
322 }
unsigned int contact_expiration_check_interval
Definition: config_global.c:92
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL
Definition: config_global.c:42
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_debug()

char* ast_sip_get_debug ( void  )

Retrieve the system debug setting (yes|no|host).

Note
returned string needs to be de-allocated by caller.
Return values
thesystem debug setting.

Definition at line 232 of file config_global.c.

References ao2_ref, ast_strdup, global_config::debug, DEFAULT_DEBUG, and get_global_cfg().

Referenced by check_debug().

233 {
234  char *res;
235  struct global_config *cfg;
236 
237  cfg = get_global_cfg();
238  if (!cfg) {
239  return ast_strdup(DEFAULT_DEBUG);
240  }
241 
242  res = ast_strdup(cfg->debug);
243  ao2_ref(cfg, -1);
244  return res;
245 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const ast_string_field debug
Definition: config_global.c:84
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_DEBUG
Definition: config_global.c:36
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_default_from_user()

void ast_sip_get_default_from_user ( char *  from_user,
size_t  size 
)

Retrieve the global default from user.

This is the value placed in outbound requests' From header if there is no better option (such as an endpoint-configured from_user or caller ID number).

Parameters
[out]from_userThe default from user
sizeThe buffer size of from_user
Returns
nothing

Definition at line 388 of file config_global.c.

References ao2_ref, ast_copy_string(), DEFAULT_FROM_USER, global_config::default_from_user, and get_global_cfg().

Referenced by sip_dialog_create_from().

389 {
390  struct global_config *cfg;
391 
392  cfg = get_global_cfg();
393  if (!cfg) {
394  ast_copy_string(from_user, DEFAULT_FROM_USER, size);
395  } else {
396  ast_copy_string(from_user, cfg->default_from_user, size);
397  ao2_ref(cfg, -1);
398  }
399 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_FROM_USER
Definition: config_global.c:39
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct global_config * get_global_cfg(void)
const ast_string_field default_from_user
Definition: config_global.c:84

◆ ast_sip_get_default_realm()

void ast_sip_get_default_realm ( char *  realm,
size_t  size 
)

Retrieve the global default realm.

This is the value placed in outbound challenges' realm if there is no better option (such as an auth-configured realm).

Parameters
[out]realmThe default realm
sizeThe buffer size of realm
Returns
nothing

Definition at line 375 of file config_global.c.

References ao2_ref, ast_copy_string(), DEFAULT_REALM, global_config::default_realm, and get_global_cfg().

Referenced by create_artificial_auth(), and global_loaded().

376 {
377  struct global_config *cfg;
378 
379  cfg = get_global_cfg();
380  if (!cfg) {
381  ast_copy_string(realm, DEFAULT_REALM, size);
382  } else {
383  ast_copy_string(realm, cfg->default_realm, size);
384  ao2_ref(cfg, -1);
385  }
386 }
#define DEFAULT_REALM
Definition: config_global.c:40
const ast_string_field default_realm
Definition: config_global.c:84
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_default_voicemail_extension()

char* ast_sip_get_default_voicemail_extension ( void  )

Retrieve the default voicemail extension.

Since
13.9.0
Note
returned string needs to be de-allocated by caller.
Return values
thedefault voicemail extension

Definition at line 263 of file config_global.c.

References ao2_ref, ast_strdup, DEFAULT_VOICEMAIL_EXTENSION, global_config::default_voicemail_extension, and get_global_cfg().

Referenced by global_loaded().

264 {
265  char *res;
266  struct global_config *cfg;
267 
268  cfg = get_global_cfg();
269  if (!cfg) {
271  }
272 
274  ao2_ref(cfg, -1);
275 
276  return res;
277 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const ast_string_field default_voicemail_extension
Definition: config_global.c:84
#define DEFAULT_VOICEMAIL_EXTENSION
Definition: config_global.c:44
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_disable_multi_domain()

unsigned int ast_sip_get_disable_multi_domain ( void  )

Retrieve the system setting 'disable multi domain'.

Since
13.9.0
Return values
nonzero if disable multi domain.

Definition at line 324 of file config_global.c.

References ao2_ref, DEFAULT_DISABLE_MULTI_DOMAIN, global_config::disable_multi_domain, and get_global_cfg().

Referenced by anonymous_identify(), find_endpoint(), request(), and sip_dialog_create_from().

325 {
326  unsigned int disable_multi_domain;
327  struct global_config *cfg;
328 
329  cfg = get_global_cfg();
330  if (!cfg) {
332  }
333 
334  disable_multi_domain = cfg->disable_multi_domain;
335  ao2_ref(cfg, -1);
336  return disable_multi_domain;
337 }
unsigned int disable_multi_domain
Definition: config_global.c:94
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_DISABLE_MULTI_DOMAIN
Definition: config_global.c:43
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_endpoint_identifier_order()

char* ast_sip_get_endpoint_identifier_order ( void  )

Retrieve the global endpoint_identifier_order setting.

Specifies the order by which endpoint identifiers should be regarded.

Return values
theglobal endpoint_identifier_order value

Definition at line 279 of file config_global.c.

References ao2_ref, ast_strdup, DEFAULT_ENDPOINT_IDENTIFIER_ORDER, global_config::endpoint_identifier_order, and get_global_cfg().

Referenced by ast_sip_register_endpoint_identifier_with_name(), and global_loaded().

280 {
281  char *res;
282  struct global_config *cfg;
283 
284  cfg = get_global_cfg();
285  if (!cfg) {
287  }
288 
290  ao2_ref(cfg, -1);
291  return res;
292 }
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER
Definition: config_global.c:37
const ast_string_field endpoint_identifier_order
Definition: config_global.c:84
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_ignore_uri_user_options()

unsigned int ast_sip_get_ignore_uri_user_options ( void  )

Retrieve the global setting 'ignore_uri_user_options'.

Since
13.12.0
Return values
nonzero if ignore the user field options.

Definition at line 447 of file config_global.c.

References ao2_ref, DEFAULT_IGNORE_URI_USER_OPTIONS, get_global_cfg(), and global_config::ignore_uri_user_options.

Referenced by find_registrar_aor().

448 {
449  unsigned int ignore_uri_user_options;
450  struct global_config *cfg;
451 
452  cfg = get_global_cfg();
453  if (!cfg) {
455  }
456 
457  ignore_uri_user_options = cfg->ignore_uri_user_options;
458  ao2_ref(cfg, -1);
460 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_IGNORE_URI_USER_OPTIONS
Definition: config_global.c:51
unsigned int ignore_uri_user_options
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_keep_alive_interval()

unsigned int ast_sip_get_keep_alive_interval ( void  )

Retrieve the system keep alive interval setting.

Return values
thekeep alive interval.

Definition at line 294 of file config_global.c.

References ao2_ref, DEFAULT_KEEPALIVE_INTERVAL, get_global_cfg(), and global_config::keep_alive_interval.

Referenced by keepalive_global_loaded().

295 {
296  unsigned int interval;
297  struct global_config *cfg;
298 
299  cfg = get_global_cfg();
300  if (!cfg) {
302  }
303 
304  interval = cfg->keep_alive_interval;
305  ao2_ref(cfg, -1);
306  return interval;
307 }
unsigned int keep_alive_interval
Definition: config_global.c:88
#define DEFAULT_KEEPALIVE_INTERVAL
Definition: config_global.c:33
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_max_initial_qualify_time()

unsigned int ast_sip_get_max_initial_qualify_time ( void  )

Retrieve the system max initial qualify time.

Return values
themaximum initial qualify time.

Definition at line 339 of file config_global.c.

References ao2_ref, DEFAULT_MAX_INITIAL_QUALIFY_TIME, get_global_cfg(), and global_config::max_initial_qualify_time.

Referenced by sip_options_determine_initial_qualify_time().

340 {
341  unsigned int time;
342  struct global_config *cfg;
343 
344  cfg = get_global_cfg();
345  if (!cfg) {
347  }
348 
349  time = cfg->max_initial_qualify_time;
350  ao2_ref(cfg, -1);
351  return time;
352 }
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME
Definition: config_global.c:38
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
unsigned int max_initial_qualify_time
Definition: config_global.c:90

◆ ast_sip_get_mwi_disable_initial_unsolicited()

unsigned int ast_sip_get_mwi_disable_initial_unsolicited ( void  )

Retrieve the global setting 'disable sending unsolicited mwi on startup'.

Since
13.12.0
Return values
nonzero if disable.

Definition at line 432 of file config_global.c.

References ao2_ref, DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED, global_config::disable_initial_unsolicited, get_global_cfg(), and global_config::mwi.

Referenced by load_module(), and reload().

433 {
434  unsigned int disable_initial_unsolicited;
435  struct global_config *cfg;
436 
437  cfg = get_global_cfg();
438  if (!cfg) {
440  }
441 
442  disable_initial_unsolicited = cfg->mwi.disable_initial_unsolicited;
443  ao2_ref(cfg, -1);
445 }
struct global_config::@477 mwi
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED
Definition: config_global.c:50
unsigned int disable_initial_unsolicited
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_mwi_tps_queue_high()

unsigned int ast_sip_get_mwi_tps_queue_high ( void  )

Retrieve the global MWI taskprocessor high water alert trigger level.

Since
13.12.0
Return values
thesystem MWI taskprocessor high water alert trigger level

Definition at line 402 of file config_global.c.

References ao2_ref, DEFAULT_MWI_TPS_QUEUE_HIGH, get_global_cfg(), global_config::mwi, and global_config::tps_queue_high.

Referenced by global_loaded().

403 {
404  unsigned int tps_queue_high;
405  struct global_config *cfg;
406 
407  cfg = get_global_cfg();
408  if (!cfg) {
410  }
411 
412  tps_queue_high = cfg->mwi.tps_queue_high;
413  ao2_ref(cfg, -1);
414  return tps_queue_high;
415 }
#define DEFAULT_MWI_TPS_QUEUE_HIGH
Definition: config_global.c:48
struct global_config::@477 mwi
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
unsigned int tps_queue_high

◆ ast_sip_get_mwi_tps_queue_low()

int ast_sip_get_mwi_tps_queue_low ( void  )

Retrieve the global MWI taskprocessor low water clear alert level.

Since
13.12.0
Return values
thesystem MWI taskprocessor low water clear alert level

Definition at line 417 of file config_global.c.

References ao2_ref, DEFAULT_MWI_TPS_QUEUE_LOW, get_global_cfg(), global_config::mwi, and global_config::tps_queue_low.

Referenced by global_loaded().

418 {
419  int tps_queue_low;
420  struct global_config *cfg;
421 
422  cfg = get_global_cfg();
423  if (!cfg) {
425  }
426 
427  tps_queue_low = cfg->mwi.tps_queue_low;
428  ao2_ref(cfg, -1);
429  return tps_queue_low;
430 }
#define DEFAULT_MWI_TPS_QUEUE_LOW
Definition: config_global.c:49
struct global_config::@477 mwi
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_norefersub()

unsigned int ast_sip_get_norefersub ( void  )

Retrieve the global setting 'norefersub'.

Return values
nonzero if norefersub is to be sent in "Supported" Headers

Definition at line 507 of file config_global.c.

References ao2_ref, DEFAULT_NOREFERSUB, get_global_cfg(), and global_config::norefersub.

Referenced by load_module().

508 {
509  unsigned int norefersub;
510  struct global_config *cfg;
511 
512  cfg = get_global_cfg();
513  if (!cfg) {
514  return DEFAULT_NOREFERSUB;
515  }
516 
517  norefersub = cfg->norefersub;
518  ao2_ref(cfg, -1);
519  return norefersub;
520 }
#define DEFAULT_NOREFERSUB
Definition: config_global.c:55
unsigned int norefersub
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_regcontext()

char* ast_sip_get_regcontext ( void  )

Retrieve the global regcontext setting.

Since
13.8.0
Note
returned string needs to be de-allocated by caller.
Return values
theglobal regcontext setting

Definition at line 247 of file config_global.c.

References ao2_ref, ast_strdup, DEFAULT_REGCONTEXT, get_global_cfg(), and global_config::regcontext.

Referenced by ast_sip_persistent_endpoint_update_state().

248 {
249  char *res;
250  struct global_config *cfg;
251 
252  cfg = get_global_cfg();
253  if (!cfg) {
255  }
256 
257  res = ast_strdup(cfg->regcontext);
258  ao2_ref(cfg, -1);
259 
260  return res;
261 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define DEFAULT_REGCONTEXT
Definition: config_global.c:41
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const ast_string_field regcontext
Definition: config_global.c:84
static struct global_config * get_global_cfg(void)

◆ ast_sip_get_send_contact_status_on_update_registration()

unsigned int ast_sip_get_send_contact_status_on_update_registration ( void  )

Retrieve the global setting 'send_contact_status_on_update_registration'.

Since
16.2.0
Return values
nonzero if need to send AMI ContactStatus event when a contact is updated.

Definition at line 477 of file config_global.c.

References ao2_ref, DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION, get_global_cfg(), and global_config::send_contact_status_on_update_registration.

Referenced by contact_observer_updated().

478 {
480  struct global_config *cfg;
481 
482  cfg = get_global_cfg();
483  if (!cfg) {
485  }
486 
487  send_contact_status_on_update_registration = cfg->send_contact_status_on_update_registration;
488  ao2_ref(cfg, -1);
490 }
unsigned int send_contact_status_on_update_registration
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION
Definition: config_global.c:53

◆ ast_sip_get_taskprocessor_overload_trigger()

enum ast_sip_taskprocessor_overload_trigger ast_sip_get_taskprocessor_overload_trigger ( void  )

Definition at line 492 of file config_global.c.

References ao2_ref, DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER, get_global_cfg(), and global_config::overload_trigger.

Referenced by global_loaded().

493 {
495  struct global_config *cfg;
496 
497  cfg = get_global_cfg();
498  if (!cfg) {
500  }
501 
502  trigger = cfg->overload_trigger;
503  ao2_ref(cfg, -1);
504  return trigger;
505 }
enum ast_sip_taskprocessor_overload_trigger overload_trigger
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
#define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER
Definition: config_global.c:54
ast_sip_taskprocessor_overload_trigger

◆ ast_sip_get_unidentified_request_thresholds()

void ast_sip_get_unidentified_request_thresholds ( unsigned int *  count,
unsigned int *  period,
unsigned int *  prune_interval 
)

Retrieve the unidentified request security event thresholds.

Since
13.8.0
Parameters
countThe maximum number of unidentified requests per source ip to accumulate before emitting a security event
periodThe period in seconds over which to accumulate unidentified requests
prune_intervalThe interval in seconds at which expired entries will be pruned

Definition at line 354 of file config_global.c.

References ao2_ref, DEFAULT_UNIDENTIFIED_REQUEST_COUNT, DEFAULT_UNIDENTIFIED_REQUEST_PERIOD, DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL, get_global_cfg(), global_config::unidentified_request_count, global_config::unidentified_request_period, and global_config::unidentified_request_prune_interval.

Referenced by global_loaded(), and prune_task().

356 {
357  struct global_config *cfg;
358 
359  cfg = get_global_cfg();
360  if (!cfg) {
364  return;
365  }
366 
367  *count = cfg->unidentified_request_count;
368  *period = cfg->unidentified_request_period;
369  *prune_interval = cfg->unidentified_request_prune_interval;
370 
371  ao2_ref(cfg, -1);
372  return;
373 }
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL
Definition: config_global.c:47
unsigned int unidentified_request_prune_interval
unsigned int unidentified_request_count
Definition: config_global.c:96
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT
Definition: config_global.c:45
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD
Definition: config_global.c:46
static struct global_config * get_global_cfg(void)
unsigned int unidentified_request_period
Definition: config_global.c:98

◆ ast_sip_get_use_callerid_contact()

unsigned int ast_sip_get_use_callerid_contact ( void  )

Retrieve the global setting 'use_callerid_contact'.

Since
13.24.0
Return values
nonzero if CALLERID(num) is to be used as the default username in the contact

Definition at line 462 of file config_global.c.

References ao2_ref, DEFAULT_USE_CALLERID_CONTACT, get_global_cfg(), and global_config::use_callerid_contact.

Referenced by set_from_header().

463 {
464  unsigned int use_callerid_contact;
465  struct global_config *cfg;
466 
467  cfg = get_global_cfg();
468  if (!cfg) {
470  }
471 
472  use_callerid_contact = cfg->use_callerid_contact;
473  ao2_ref(cfg, -1);
474  return use_callerid_contact;
475 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_USE_CALLERID_CONTACT
Definition: config_global.c:52
unsigned int use_callerid_contact
static struct global_config * get_global_cfg(void)

◆ ast_sip_global_default_outbound_endpoint()

char* ast_sip_global_default_outbound_endpoint ( void  )

Definition at line 217 of file config_global.c.

References ao2_ref, ast_strdup, DEFAULT_OUTBOUND_ENDPOINT, global_config::default_outbound_endpoint, get_global_cfg(), and str.

Referenced by ast_sip_default_outbound_endpoint().

218 {
219  char *str;
220  struct global_config *cfg;
221 
222  cfg = get_global_cfg();
223  if (!cfg) {
225  }
226 
228  ao2_ref(cfg, -1);
229  return str;
230 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const char * str
Definition: app_jack.c:147
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
const ast_string_field default_outbound_endpoint
Definition: config_global.c:84
#define DEFAULT_OUTBOUND_ENDPOINT
Definition: config_global.c:35

◆ ast_sip_initialize_sorcery_global()

int ast_sip_initialize_sorcery_global ( void  )

Definition at line 647 of file config_global.c.

References __stringify, ast_get_version(), ast_sip_get_sorcery(), ast_sorcery_apply_default, ast_sorcery_instance_observer_add(), ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_register, global_config::contact_expiration_check_interval, global_config::debug, DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL, DEFAULT_DEBUG, DEFAULT_DISABLE_MULTI_DOMAIN, DEFAULT_ENDPOINT_IDENTIFIER_ORDER, DEFAULT_FROM_USER, global_config::default_from_user, DEFAULT_IGNORE_URI_USER_OPTIONS, DEFAULT_KEEPALIVE_INTERVAL, DEFAULT_MAX_FORWARDS, DEFAULT_MAX_INITIAL_QUALIFY_TIME, DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED, DEFAULT_MWI_TPS_QUEUE_HIGH, DEFAULT_MWI_TPS_QUEUE_LOW, DEFAULT_NOREFERSUB, DEFAULT_OUTBOUND_ENDPOINT, global_config::default_outbound_endpoint, DEFAULT_REALM, global_config::default_realm, DEFAULT_REGCONTEXT, DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION, DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER, DEFAULT_UNIDENTIFIED_REQUEST_COUNT, DEFAULT_UNIDENTIFIED_REQUEST_PERIOD, DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL, DEFAULT_USE_CALLERID_CONTACT, default_useragent, DEFAULT_USERAGENT_PREFIX, DEFAULT_VOICEMAIL_EXTENSION, global_config::default_voicemail_extension, global_config::disable_multi_domain, global_config::endpoint_identifier_order, FLDSET, global_alloc(), global_apply(), global_config::ignore_uri_user_options, global_config::keep_alive_interval, global_config::max_initial_qualify_time, global_config::mwi, global_config::norefersub, NULL, OPT_BOOL_T, OPT_INT_T, OPT_NOOP_T, OPT_STRINGFIELD_T, OPT_UINT_T, OPT_YESNO_T, overload_trigger_handler(), overload_trigger_map, overload_trigger_to_str(), global_config::regcontext, global_config::send_contact_status_on_update_registration, sorcery, STRFLDSET, global_config::unidentified_request_count, global_config::unidentified_request_period, global_config::unidentified_request_prune_interval, global_config::use_callerid_contact, and global_config::useragent.

Referenced by ast_res_pjsip_initialize_configuration().

648 {
650 
651  snprintf(default_useragent, sizeof(default_useragent), "%s %s",
653 
654  ast_sorcery_apply_default(sorcery, "global", "config", "pjsip.conf,criteria=type=global,single_object=yes,explicit_name=global");
655 
656  if (ast_sorcery_object_register(sorcery, "global", global_alloc, NULL, global_apply)) {
657  return -1;
658  }
659 
660  ast_sorcery_object_field_register(sorcery, "global", "type", "", OPT_NOOP_T, 0, 0);
661  ast_sorcery_object_field_register(sorcery, "global", "max_forwards",
664  ast_sorcery_object_field_register(sorcery, "global", "user_agent", default_useragent,
665  OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, useragent));
666  ast_sorcery_object_field_register(sorcery, "global", "default_outbound_endpoint",
668  OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_outbound_endpoint));
669  ast_sorcery_object_field_register(sorcery, "global", "debug", DEFAULT_DEBUG,
671  ast_sorcery_object_field_register(sorcery, "global", "endpoint_identifier_order",
673  OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, endpoint_identifier_order));
674  ast_sorcery_object_field_register(sorcery, "global", "keep_alive_interval",
676  OPT_UINT_T, 0, FLDSET(struct global_config, keep_alive_interval));
677  ast_sorcery_object_field_register(sorcery, "global", "max_initial_qualify_time",
679  OPT_UINT_T, 0, FLDSET(struct global_config, max_initial_qualify_time));
680  ast_sorcery_object_field_register(sorcery, "global", "default_from_user", DEFAULT_FROM_USER,
681  OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_from_user));
682  ast_sorcery_object_field_register(sorcery, "global", "default_voicemail_extension",
685  ast_sorcery_object_field_register(sorcery, "global", "regcontext", DEFAULT_REGCONTEXT,
687  ast_sorcery_object_field_register(sorcery, "global", "contact_expiration_check_interval",
689  OPT_UINT_T, 0, FLDSET(struct global_config, contact_expiration_check_interval));
690  ast_sorcery_object_field_register(sorcery, "global", "disable_multi_domain",
691  DEFAULT_DISABLE_MULTI_DOMAIN ? "yes" : "no",
692  OPT_BOOL_T, 1, FLDSET(struct global_config, disable_multi_domain));
693  ast_sorcery_object_field_register(sorcery, "global", "unidentified_request_count",
695  OPT_UINT_T, 0, FLDSET(struct global_config, unidentified_request_count));
696  ast_sorcery_object_field_register(sorcery, "global", "unidentified_request_period",
698  OPT_UINT_T, 0, FLDSET(struct global_config, unidentified_request_period));
699  ast_sorcery_object_field_register(sorcery, "global", "unidentified_request_prune_interval",
701  OPT_UINT_T, 0, FLDSET(struct global_config, unidentified_request_prune_interval));
702  ast_sorcery_object_field_register(sorcery, "global", "default_realm", DEFAULT_REALM,
704  ast_sorcery_object_field_register(sorcery, "global", "mwi_tps_queue_high",
706  OPT_UINT_T, 0, FLDSET(struct global_config, mwi.tps_queue_high));
707  ast_sorcery_object_field_register(sorcery, "global", "mwi_tps_queue_low",
709  OPT_INT_T, 0, FLDSET(struct global_config, mwi.tps_queue_low));
710  ast_sorcery_object_field_register(sorcery, "global", "mwi_disable_initial_unsolicited",
713  ast_sorcery_object_field_register(sorcery, "global", "ignore_uri_user_options",
714  DEFAULT_IGNORE_URI_USER_OPTIONS ? "yes" : "no",
715  OPT_BOOL_T, 1, FLDSET(struct global_config, ignore_uri_user_options));
716  ast_sorcery_object_field_register(sorcery, "global", "use_callerid_contact",
717  DEFAULT_USE_CALLERID_CONTACT ? "yes" : "no",
718  OPT_YESNO_T, 1, FLDSET(struct global_config, use_callerid_contact));
719  ast_sorcery_object_field_register(sorcery, "global", "send_contact_status_on_update_registration",
721  OPT_YESNO_T, 1, FLDSET(struct global_config, send_contact_status_on_update_registration));
722  ast_sorcery_object_field_register_custom(sorcery, "global", "taskprocessor_overload_trigger",
725  ast_sorcery_object_field_register(sorcery, "global", "norefersub",
726  DEFAULT_NOREFERSUB ? "yes" : "no",
727  OPT_YESNO_T, 1, FLDSET(struct global_config, norefersub));
728 
730  return -1;
731  }
732 
733  return 0;
734 }
#define DEFAULT_MWI_TPS_QUEUE_HIGH
Definition: config_global.c:48
static char default_realm[MAX_REALM_LENGTH+1]
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL
Definition: config_global.c:47
#define DEFAULT_REALM
Definition: config_global.c:40
int ast_sorcery_instance_observer_add(struct ast_sorcery *sorcery, const struct ast_sorcery_instance_observer *callbacks)
Add an observer to a sorcery instance.
Definition: sorcery.c:520
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER
Definition: config_global.c:37
const char * ast_get_version(void)
Retrieve the Asterisk version string.
Definition: version.c:16
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL
Definition: config_global.c:42
static int debug
Global debug status.
Definition: res_xmpp.c:435
#define DEFAULT_MWI_TPS_QUEUE_LOW
Definition: config_global.c:49
static const struct ast_sorcery_instance_observer observer_callbacks_global
Full structure for sorcery.
Definition: sorcery.c:230
Type for a default handler that should do nothing.
static int overload_trigger_to_str(const void *obj, const intptr_t *args, char **buf)
#define DEFAULT_NOREFERSUB
Definition: config_global.c:55
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME
Definition: config_global.c:38
#define NULL
Definition: resample.c:96
Type for default option handler for bools (ast_true/ast_false)
#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.
Definition: sorcery.h:1005
#define __stringify(x)
Definition: asterisk.h:214
#define DEFAULT_KEEPALIVE_INTERVAL
Definition: config_global.c:33
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
#define DEFAULT_REGCONTEXT
Definition: config_global.c:41
static void * global_alloc(const char *name)
Type for default option handler for unsigned integers.
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT
Definition: config_global.c:45
#define DEFAULT_VOICEMAIL_EXTENSION
Definition: config_global.c:44
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
#define DEFAULT_USE_CALLERID_CONTACT
Definition: config_global.c:52
static char default_useragent[256]
Definition: config_global.c:66
static const char * overload_trigger_map[]
Type for default option handler for bools (ast_true/ast_false)
static char * default_voicemail_extension
Definition: res_pjsip_mwi.c:49
Channel datastore data for max forwards.
Definition: max_forwards.c:29
#define DEFAULT_FROM_USER
Definition: config_global.c:39
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
static int overload_trigger_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define DEFAULT_DISABLE_MULTI_DOMAIN
Definition: config_global.c:43
#define DEFAULT_USERAGENT_PREFIX
Definition: config_global.c:34
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED
Definition: config_global.c:50
#define DEFAULT_IGNORE_URI_USER_OPTIONS
Definition: config_global.c:51
#define DEFAULT_DEBUG
Definition: config_global.c:36
static struct ast_sorcery * sorcery
#define DEFAULT_MAX_FORWARDS
Definition: config_global.c:32
unsigned int disable_initial_unsolicited
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD
Definition: config_global.c:46
static int global_apply(const struct ast_sorcery *sorcery, void *obj)
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:321
Type for default option handler for stringfields.
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION
Definition: config_global.c:53
#define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER
Definition: config_global.c:54
Type for default option handler for signed integers.
#define DEFAULT_OUTBOUND_ENDPOINT
Definition: config_global.c:35
unsigned int tps_queue_high

◆ ast_sip_overload_trigger_to_str()

const char* ast_sip_overload_trigger_to_str ( enum ast_sip_taskprocessor_overload_trigger  trigger)

Definition at line 546 of file config_global.c.

References ARRAY_IN_BOUNDS, and overload_trigger_map.

Referenced by overload_trigger_to_str().

547 {
548  return ARRAY_IN_BOUNDS(trigger, overload_trigger_map) ?
549  overload_trigger_map[trigger] : "";
550 }
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
Definition: utils.h:658
static const char * overload_trigger_map[]

◆ check_regcontext()

static int check_regcontext ( const struct global_config cfg)
static

Definition at line 147 of file config_global.c.

References ast_context_destroy_by_name(), ast_free, ast_sip_persistent_endpoint_add_to_regcontext(), ast_strdup, ast_strlen_zero, NULL, previous_regcontext, and global_config::regcontext.

Referenced by global_apply().

148 {
149  char *current = NULL;
150 
151  if (previous_regcontext && !strcmp(previous_regcontext, cfg->regcontext)) {
152  /* Nothing changed so nothing to do */
153  return 0;
154  }
155 
156  if (!ast_strlen_zero(cfg->regcontext)) {
157  current = ast_strdup(cfg->regcontext);
158  if (!current) {
159  return -1;
160  }
161 
163  ast_free(current);
164  return -1;
165  }
166  }
167 
172  }
173 
174  if (current) {
175  previous_regcontext = current;
176  }
177 
178  return 0;
179 }
static char * previous_regcontext
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
Definition: pbx.c:8244
#define ast_strlen_zero(foo)
Definition: strings.h:52
const ast_string_field regcontext
Definition: config_global.c:84
#define ast_free(a)
Definition: astmm.h:182
int ast_sip_persistent_endpoint_add_to_regcontext(const char *regcontext)

◆ get_global_cfg()

static struct global_config* get_global_cfg ( void  )
static

◆ global_alloc()

static void* global_alloc ( const char *  name)
static

Definition at line 128 of file config_global.c.

References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, global_destructor(), and NULL.

Referenced by ast_sip_initialize_sorcery_global().

129 {
130  struct global_config *cfg;
131 
132  cfg = ast_sorcery_generic_alloc(sizeof(*cfg), global_destructor);
133  if (!cfg || ast_string_field_init(cfg, 100)) {
134  ao2_cleanup(cfg);
135  return NULL;
136  }
137 
138  return cfg;
139 }
#define NULL
Definition: resample.c:96
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
static void global_destructor(void *obj)

◆ global_apply()

static int global_apply ( const struct ast_sorcery sorcery,
void *  obj 
)
static

Definition at line 181 of file config_global.c.

References ao2_t_global_obj_replace_unref, ast_log, ast_sip_add_global_request_header(), ast_sip_add_global_response_header(), ast_strlen_zero, check_regcontext(), global_config::debug, global_config::default_from_user, LOG_ERROR, global_config::max_forwards, and global_config::useragent.

Referenced by ast_sip_initialize_sorcery_global(), and global_loaded_observer().

182 {
183  struct global_config *cfg = obj;
184  char max_forwards[10];
185 
186  if (ast_strlen_zero(cfg->debug)) {
188  "Global option 'debug' can't be empty. Set it to a valid value or remove the entry to accept 'no' as the default\n");
189  return -1;
190  }
191 
194  "Global option 'default_from_user' can't be empty. Set it to a valid value or remove the entry to accept 'asterisk' as the default\n");
195  return -1;
196  }
197 
198  snprintf(max_forwards, sizeof(max_forwards), "%u", cfg->max_forwards);
199 
200  ast_sip_add_global_request_header("Max-Forwards", max_forwards, 1);
201  ast_sip_add_global_request_header("User-Agent", cfg->useragent, 1);
203 
204  if (check_regcontext(cfg)) {
205  return -1;
206  }
207 
208  ao2_t_global_obj_replace_unref(global_cfg, cfg, "Applying global settings");
209  return 0;
210 }
#define ao2_t_global_obj_replace_unref(holder, obj, tag)
Replace an ao2 object in the global holder, throwing away any old object.
Definition: astobj2.h:906
static int check_regcontext(const struct global_config *cfg)
int ast_sip_add_global_request_header(const char *name, const char *value, int replace)
const ast_string_field useragent
Definition: config_global.c:84
const ast_string_field debug
Definition: config_global.c:84
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
int ast_sip_add_global_response_header(const char *name, const char *value, int replace)
unsigned int max_forwards
Definition: config_global.c:86
#define LOG_ERROR
Definition: logger.h:285
Channel datastore data for max forwards.
Definition: max_forwards.c:29
const ast_string_field default_from_user
Definition: config_global.c:84

◆ global_destructor()

static void global_destructor ( void *  obj)
static

Definition at line 121 of file config_global.c.

References ast_string_field_free_memory.

Referenced by global_alloc().

122 {
123  struct global_config *cfg = obj;
124 
126 }
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368

◆ global_loaded_observer()

static void global_loaded_observer ( const char *  name,
const struct ast_sorcery sorcery,
const char *  object_type,
int  reloaded 
)
static

Definition at line 570 of file config_global.c.

References ao2_container_count(), ao2_ref, ast_debug, ast_log, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_alloc(), ast_sorcery_retrieve_by_fields(), global_apply(), globals, LOG_ERROR, and NULL.

571 {
572  struct ao2_container *globals;
573  struct global_config *cfg;
574 
575  if (strcmp(object_type, "global")) {
576  /* Not interested */
577  return;
578  }
579 
580  globals = ast_sorcery_retrieve_by_fields(sorcery, "global",
582  if (globals) {
583  int count;
584 
585  count = ao2_container_count(globals);
586  ao2_ref(globals, -1);
587 
588  if (1 < count) {
590  "At most one pjsip.conf type=global object can be defined. You have %d defined.\n",
591  count);
592  return;
593  }
594  if (count) {
595  return;
596  }
597  }
598 
599  ast_debug(1, "No pjsip.conf type=global object exists so applying defaults.\n");
600  cfg = ast_sorcery_alloc(sorcery, "global", NULL);
601  if (!cfg) {
602  return;
603  }
604  global_apply(sorcery, cfg);
605  ao2_ref(cfg, -1);
606 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
Perform no matching, return all objects.
Definition: sorcery.h:123
Return all matching objects.
Definition: sorcery.h:120
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define LOG_ERROR
Definition: logger.h:285
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
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.
Definition: sorcery.c:1897
static int global_apply(const struct ast_sorcery *sorcery, void *obj)
Generic container type.

◆ overload_trigger_handler()

static int overload_trigger_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 522 of file config_global.c.

References ast_log, LOG_WARNING, ast_variable::name, global_config::overload_trigger, TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL, TASKPROCESSOR_OVERLOAD_TRIGGER_NONE, TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY, and ast_variable::value.

Referenced by ast_sip_initialize_sorcery_global().

524 {
525  struct global_config *cfg = obj;
526  if (!strcasecmp(var->value, "none")) {
528  } else if (!strcasecmp(var->value, "global")) {
530  } else if (!strcasecmp(var->value, "pjsip_only")) {
532  } else {
533  ast_log(LOG_WARNING, "Unknown overload trigger '%s' specified for %s\n",
534  var->value, var->name);
535  return -1;
536  }
537  return 0;
538 }
#define LOG_WARNING
Definition: logger.h:274
enum ast_sip_taskprocessor_overload_trigger overload_trigger
#define ast_log
Definition: astobj2.c:42

◆ overload_trigger_to_str()

static int overload_trigger_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 552 of file config_global.c.

References ast_sip_overload_trigger_to_str(), ast_strdup, and global_config::overload_trigger.

Referenced by ast_sip_initialize_sorcery_global().

553 {
554  const struct global_config *cfg = obj;
556  return 0;
557 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
enum ast_sip_taskprocessor_overload_trigger overload_trigger
const char * ast_sip_overload_trigger_to_str(enum ast_sip_taskprocessor_overload_trigger trigger)

◆ sip_cli_print_global()

int sip_cli_print_global ( struct ast_sip_cli_context context)

Definition at line 612 of file config_global.c.

References ao2_ref, ast_sip_cli_print_sorcery_objectset(), ast_sip_get_sorcery(), ast_sorcery_alloc(), ast_str_append(), get_global_cfg(), NULL, and ast_sip_cli_context::output_buffer.

Referenced by cli_show_settings().

613 {
614  struct global_config *cfg = get_global_cfg();
615 
616  if (!cfg) {
617  cfg = ast_sorcery_alloc(ast_sip_get_sorcery(), "global", NULL);
618  if (!cfg) {
619  return -1;
620  }
621  }
622 
623  ast_str_append(&context->output_buffer, 0, "\nGlobal Settings:\n\n");
624  ast_sip_cli_print_sorcery_objectset(cfg, context, 0);
625 
626  ao2_ref(cfg, -1);
627  return 0;
628 }
struct ast_str * output_buffer
Definition: res_pjsip_cli.h:36
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:1091
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static struct global_config * get_global_cfg(void)
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object&#39;s ast_variable list.
Definition: pjsip_cli.c:36

Variable Documentation

◆ default_useragent

char default_useragent[256]
static

Definition at line 66 of file config_global.c.

Referenced by ast_sip_initialize_sorcery_global().

◆ observer_callbacks_global

const struct ast_sorcery_instance_observer observer_callbacks_global
static
Initial value:
= {
.object_type_loaded = global_loaded_observer,
}
static void global_loaded_observer(const char *name, const struct ast_sorcery *sorcery, const char *object_type, int reloaded)

Definition at line 608 of file config_global.c.

◆ overload_trigger_map

const char* overload_trigger_map[]
static

◆ previous_regcontext

char* previous_regcontext = NULL
static

Definition at line 145 of file config_global.c.

Referenced by ast_sip_destroy_sorcery_global(), and check_regcontext().