Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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_ALL_CODECS_ON_EMPTY_REINVITE   0
 
#define DEFAULT_ALLOW_SENDING_180_AFTER_183   0
 
#define DEFAULT_AUTH_ALGORITHMS_UAC   "MD5"
 
#define DEFAULT_AUTH_ALGORITHMS_UAS   "MD5"
 
#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_all_codecs_on_empty_reinvite (void)
 Retrieve the system setting 'all_codecs_on_empty_reinvite'. More...
 
unsigned int ast_sip_get_allow_sending_180_after_183 (void)
 Retrieve the global setting 'allow_sending_180_after_183'. More...
 
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_auth_algorithms_uac (char *default_auth_algorithms_uac, size_t size)
 Retrieve the global auth algorithms for UAC. More...
 
void ast_sip_get_default_auth_algorithms_uas (char *default_auth_algorithms_uas, size_t size)
 Retrieve the global auth algorithms for UAS. 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_ALL_CODECS_ON_EMPTY_REINVITE

#define DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE   0

Definition at line 57 of file config_global.c.

◆ DEFAULT_ALLOW_SENDING_180_AFTER_183

#define DEFAULT_ALLOW_SENDING_180_AFTER_183   0

Definition at line 51 of file config_global.c.

◆ DEFAULT_AUTH_ALGORITHMS_UAC

#define DEFAULT_AUTH_ALGORITHMS_UAC   "MD5"

Definition at line 59 of file config_global.c.

◆ DEFAULT_AUTH_ALGORITHMS_UAS

#define DEFAULT_AUTH_ALGORITHMS_UAS   "MD5"

Definition at line 58 of file config_global.c.

◆ DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL

#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL   30

Definition at line 42 of file config_global.c.

◆ DEFAULT_DEBUG

#define DEFAULT_DEBUG   "no"

Definition at line 36 of file config_global.c.

◆ DEFAULT_DISABLE_MULTI_DOMAIN

#define DEFAULT_DISABLE_MULTI_DOMAIN   0

Definition at line 43 of file config_global.c.

◆ DEFAULT_ENDPOINT_IDENTIFIER_ORDER

#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER   "ip,username,anonymous"

Definition at line 37 of file config_global.c.

◆ DEFAULT_FROM_USER

#define DEFAULT_FROM_USER   "asterisk"

Definition at line 39 of file config_global.c.

◆ DEFAULT_IGNORE_URI_USER_OPTIONS

#define DEFAULT_IGNORE_URI_USER_OPTIONS   0

Definition at line 52 of file config_global.c.

◆ DEFAULT_KEEPALIVE_INTERVAL

#define DEFAULT_KEEPALIVE_INTERVAL   90

Definition at line 33 of file config_global.c.

◆ DEFAULT_MAX_FORWARDS

#define DEFAULT_MAX_FORWARDS   70

Definition at line 32 of file config_global.c.

◆ DEFAULT_MAX_INITIAL_QUALIFY_TIME

#define DEFAULT_MAX_INITIAL_QUALIFY_TIME   0

Definition at line 38 of file config_global.c.

◆ DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED

#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED   0

Definition at line 50 of file config_global.c.

◆ DEFAULT_MWI_TPS_QUEUE_HIGH

#define DEFAULT_MWI_TPS_QUEUE_HIGH   AST_TASKPROCESSOR_HIGH_WATER_LEVEL

Definition at line 48 of file config_global.c.

◆ DEFAULT_MWI_TPS_QUEUE_LOW

#define DEFAULT_MWI_TPS_QUEUE_LOW   -1

Definition at line 49 of file config_global.c.

◆ DEFAULT_NOREFERSUB

#define DEFAULT_NOREFERSUB   1

Definition at line 56 of file config_global.c.

◆ DEFAULT_OUTBOUND_ENDPOINT

#define DEFAULT_OUTBOUND_ENDPOINT   "default_outbound_endpoint"

Definition at line 35 of file config_global.c.

◆ DEFAULT_REALM

#define DEFAULT_REALM   "asterisk"

Definition at line 40 of file config_global.c.

◆ DEFAULT_REGCONTEXT

#define DEFAULT_REGCONTEXT   ""

Definition at line 41 of file config_global.c.

◆ DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION

#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION   0

Definition at line 54 of file config_global.c.

◆ DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER

#define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER   TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL

Definition at line 55 of file config_global.c.

◆ DEFAULT_UNIDENTIFIED_REQUEST_COUNT

#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT   5

Definition at line 45 of file config_global.c.

◆ DEFAULT_UNIDENTIFIED_REQUEST_PERIOD

#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD   5

Definition at line 46 of file config_global.c.

◆ DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL

#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL   30

Definition at line 47 of file config_global.c.

◆ DEFAULT_USE_CALLERID_CONTACT

#define DEFAULT_USE_CALLERID_CONTACT   0

Definition at line 53 of file config_global.c.

◆ DEFAULT_USERAGENT_PREFIX

#define DEFAULT_USERAGENT_PREFIX   "Asterisk PBX"

Definition at line 34 of file config_global.c.

◆ DEFAULT_VOICEMAIL_EXTENSION

#define DEFAULT_VOICEMAIL_EXTENSION   ""

Definition at line 44 of file config_global.c.

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 717 of file config_global.c.

718{
720
722
726 }
727
728 ao2_t_global_obj_release(global_cfg, "Module is unloading");
729
730 return 0;
731}
#define ast_free(a)
Definition: astmm.h:180
#define ao2_t_global_obj_release(holder, tag)
Definition: astobj2.h:861
static const struct ast_sorcery_instance_observer observer_callbacks_global
static char * previous_regcontext
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
Definition: pbx.c:8220
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static struct ast_sorcery * sorcery
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
Full structure for sorcery.
Definition: sorcery.c:230

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

Referenced by ast_res_pjsip_destroy_configuration().

◆ ast_sip_get_all_codecs_on_empty_reinvite()

unsigned int ast_sip_get_all_codecs_on_empty_reinvite ( void  )

Retrieve the system setting 'all_codecs_on_empty_reinvite'.

Return values
nonzero if we should return all codecs on empty re-INVITE

Definition at line 596 of file config_global.c.

597{
598 unsigned int all_codecs_on_empty_reinvite;
599 struct global_config *cfg;
600
601 cfg = get_global_cfg();
602 if (!cfg) {
604 }
605
607 ao2_ref(cfg, -1);
609}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static struct global_config * get_global_cfg(void)
#define DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE
Definition: config_global.c:57
unsigned int all_codecs_on_empty_reinvite

References global_config::all_codecs_on_empty_reinvite, ao2_ref, DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE, and get_global_cfg().

Referenced by session_inv_on_create_offer().

◆ ast_sip_get_allow_sending_180_after_183()

unsigned int ast_sip_get_allow_sending_180_after_183 ( void  )

Retrieve the global setting 'allow_sending_180_after_183'.

Return values
nonzero if disable.

Definition at line 506 of file config_global.c.

507{
508 unsigned int allow_sending_180_after_183;
509 struct global_config *cfg;
510
511 cfg = get_global_cfg();
512 if (!cfg) {
514 }
515
517 ao2_ref(cfg, -1);
519}
#define DEFAULT_ALLOW_SENDING_180_AFTER_183
Definition: config_global.c:51
unsigned int allow_sending_180_after_183

References global_config::allow_sending_180_after_183, ao2_ref, DEFAULT_ALLOW_SENDING_180_AFTER_183, and get_global_cfg().

Referenced by chan_pjsip_indicate().

◆ 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 342 of file config_global.c.

343{
344 unsigned int interval;
345 struct global_config *cfg;
346
347 cfg = get_global_cfg();
348 if (!cfg) {
350 }
351
352 interval = cfg->contact_expiration_check_interval;
353 ao2_ref(cfg, -1);
354 return interval;
355}
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL
Definition: config_global.c:42
unsigned int contact_expiration_check_interval

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

Referenced by expiration_global_loaded().

◆ 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 265 of file config_global.c.

266{
267 char *res;
268 struct global_config *cfg;
269
270 cfg = get_global_cfg();
271 if (!cfg) {
273 }
274
275 res = ast_strdup(cfg->debug);
276 ao2_ref(cfg, -1);
277 return res;
278}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define DEFAULT_DEBUG
Definition: config_global.c:36
const ast_string_field debug
Definition: config_global.c:92

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

Referenced by check_debug().

◆ ast_sip_get_default_auth_algorithms_uac()

void ast_sip_get_default_auth_algorithms_uac ( char *  default_auth_algorithms_uac,
size_t  size 
)

Retrieve the global auth algorithms for UAC.

Parameters
[out]default_auth_algorithms_uacThe default algorithms
sizeThe buffer size of default_auth_algorithms_uac

Definition at line 434 of file config_global.c.

435{
436 struct global_config *cfg;
437
438 cfg = get_global_cfg();
439 if (!cfg) {
441 } else {
443 ao2_ref(cfg, -1);
444 }
445}
#define DEFAULT_AUTH_ALGORITHMS_UAC
Definition: config_global.c:59
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
const ast_string_field default_auth_algorithms_uac
Definition: config_global.c:92

References ao2_ref, ast_copy_string(), DEFAULT_AUTH_ALGORITHMS_UAC, global_config::default_auth_algorithms_uac, and get_global_cfg().

Referenced by auth_apply(), and create_artificial_auth().

◆ ast_sip_get_default_auth_algorithms_uas()

void ast_sip_get_default_auth_algorithms_uas ( char *  default_auth_algorithms_uas,
size_t  size 
)

Retrieve the global auth algorithms for UAS.

Parameters
[out]default_auth_algorithms_uasThe default algorithms
sizeThe buffer size of default_auth_algorithms_uas

Definition at line 421 of file config_global.c.

422{
423 struct global_config *cfg;
424
425 cfg = get_global_cfg();
426 if (!cfg) {
428 } else {
430 ao2_ref(cfg, -1);
431 }
432}
#define DEFAULT_AUTH_ALGORITHMS_UAS
Definition: config_global.c:58
const ast_string_field default_auth_algorithms_uas
Definition: config_global.c:92

References ao2_ref, ast_copy_string(), DEFAULT_AUTH_ALGORITHMS_UAS, global_config::default_auth_algorithms_uas, and get_global_cfg().

Referenced by auth_apply(), and create_artificial_auth().

◆ 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

Definition at line 447 of file config_global.c.

448{
449 struct global_config *cfg;
450
451 cfg = get_global_cfg();
452 if (!cfg) {
453 ast_copy_string(from_user, DEFAULT_FROM_USER, size);
454 } else {
455 ast_copy_string(from_user, cfg->default_from_user, size);
456 ao2_ref(cfg, -1);
457 }
458}
#define DEFAULT_FROM_USER
Definition: config_global.c:39
const ast_string_field default_from_user
Definition: config_global.c:92

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

Referenced by sip_dialog_create_from().

◆ 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

Definition at line 408 of file config_global.c.

409{
410 struct global_config *cfg;
411
412 cfg = get_global_cfg();
413 if (!cfg) {
414 ast_copy_string(realm, DEFAULT_REALM, size);
415 } else {
416 ast_copy_string(realm, cfg->default_realm, size);
417 ao2_ref(cfg, -1);
418 }
419}
#define DEFAULT_REALM
Definition: config_global.c:40
const ast_string_field default_realm
Definition: config_global.c:92

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

Referenced by create_artificial_auth(), and global_loaded().

◆ 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 296 of file config_global.c.

297{
298 char *res;
299 struct global_config *cfg;
300
301 cfg = get_global_cfg();
302 if (!cfg) {
304 }
305
307 ao2_ref(cfg, -1);
308
309 return res;
310}
#define DEFAULT_VOICEMAIL_EXTENSION
Definition: config_global.c:44
const ast_string_field default_voicemail_extension
Definition: config_global.c:92

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

Referenced by global_loaded().

◆ 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 357 of file config_global.c.

358{
359 unsigned int disable_multi_domain;
360 struct global_config *cfg;
361
362 cfg = get_global_cfg();
363 if (!cfg) {
365 }
366
368 ao2_ref(cfg, -1);
370}
#define DEFAULT_DISABLE_MULTI_DOMAIN
Definition: config_global.c:43
unsigned int disable_multi_domain

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().

◆ 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 312 of file config_global.c.

313{
314 char *res;
315 struct global_config *cfg;
316
317 cfg = get_global_cfg();
318 if (!cfg) {
320 }
321
323 ao2_ref(cfg, -1);
324 return res;
325}
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER
Definition: config_global.c:37
const ast_string_field endpoint_identifier_order
Definition: config_global.c:92

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().

◆ 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 521 of file config_global.c.

522{
523 unsigned int ignore_uri_user_options;
524 struct global_config *cfg;
525
526 cfg = get_global_cfg();
527 if (!cfg) {
529 }
530
532 ao2_ref(cfg, -1);
534}
#define DEFAULT_IGNORE_URI_USER_OPTIONS
Definition: config_global.c:52
unsigned int ignore_uri_user_options

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

Referenced by find_registrar_aor().

◆ 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 327 of file config_global.c.

328{
329 unsigned int interval;
330 struct global_config *cfg;
331
332 cfg = get_global_cfg();
333 if (!cfg) {
335 }
336
337 interval = cfg->keep_alive_interval;
338 ao2_ref(cfg, -1);
339 return interval;
340}
#define DEFAULT_KEEPALIVE_INTERVAL
Definition: config_global.c:33
unsigned int keep_alive_interval
Definition: config_global.c:96

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

Referenced by keepalive_global_loaded().

◆ 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 372 of file config_global.c.

373{
374 unsigned int time;
375 struct global_config *cfg;
376
377 cfg = get_global_cfg();
378 if (!cfg) {
380 }
381
382 time = cfg->max_initial_qualify_time;
383 ao2_ref(cfg, -1);
384 return time;
385}
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME
Definition: config_global.c:38
unsigned int max_initial_qualify_time
Definition: config_global.c:98

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().

◆ 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 491 of file config_global.c.

492{
493 unsigned int disable_initial_unsolicited;
494 struct global_config *cfg;
495
496 cfg = get_global_cfg();
497 if (!cfg) {
499 }
500
502 ao2_ref(cfg, -1);
504}
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED
Definition: config_global.c:50
unsigned int disable_initial_unsolicited
struct global_config::@454 mwi

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().

◆ 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 461 of file config_global.c.

462{
463 unsigned int tps_queue_high;
464 struct global_config *cfg;
465
466 cfg = get_global_cfg();
467 if (!cfg) {
469 }
470
472 ao2_ref(cfg, -1);
473 return tps_queue_high;
474}
#define DEFAULT_MWI_TPS_QUEUE_HIGH
Definition: config_global.c:48
unsigned int tps_queue_high

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

Referenced by global_loaded().

◆ 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 476 of file config_global.c.

477{
478 int tps_queue_low;
479 struct global_config *cfg;
480
481 cfg = get_global_cfg();
482 if (!cfg) {
484 }
485
487 ao2_ref(cfg, -1);
488 return tps_queue_low;
489}
#define DEFAULT_MWI_TPS_QUEUE_LOW
Definition: config_global.c:49

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

Referenced by global_loaded().

◆ 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 581 of file config_global.c.

582{
583 unsigned int norefersub;
584 struct global_config *cfg;
585
586 cfg = get_global_cfg();
587 if (!cfg) {
588 return DEFAULT_NOREFERSUB;
589 }
590
591 norefersub = cfg->norefersub;
592 ao2_ref(cfg, -1);
593 return norefersub;
594}
#define DEFAULT_NOREFERSUB
Definition: config_global.c:56
unsigned int norefersub

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

Referenced by load_module().

◆ 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 280 of file config_global.c.

281{
282 char *res;
283 struct global_config *cfg;
284
285 cfg = get_global_cfg();
286 if (!cfg) {
288 }
289
290 res = ast_strdup(cfg->regcontext);
291 ao2_ref(cfg, -1);
292
293 return res;
294}
#define DEFAULT_REGCONTEXT
Definition: config_global.c:41
const ast_string_field regcontext
Definition: config_global.c:92

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

Referenced by ast_sip_persistent_endpoint_update_state().

◆ 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 551 of file config_global.c.

552{
553 unsigned int send_contact_status_on_update_registration;
554 struct global_config *cfg;
555
556 cfg = get_global_cfg();
557 if (!cfg) {
559 }
560
562 ao2_ref(cfg, -1);
564}
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION
Definition: config_global.c:54
unsigned int send_contact_status_on_update_registration

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().

◆ ast_sip_get_taskprocessor_overload_trigger()

enum ast_sip_taskprocessor_overload_trigger ast_sip_get_taskprocessor_overload_trigger ( void  )

Definition at line 566 of file config_global.c.

567{
569 struct global_config *cfg;
570
571 cfg = get_global_cfg();
572 if (!cfg) {
574 }
575
576 trigger = cfg->overload_trigger;
577 ao2_ref(cfg, -1);
578 return trigger;
579}
#define DEFAULT_TASKPROCESSOR_OVERLOAD_TRIGGER
Definition: config_global.c:55
ast_sip_taskprocessor_overload_trigger
enum ast_sip_taskprocessor_overload_trigger overload_trigger

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

Referenced by global_loaded().

◆ 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 387 of file config_global.c.

389{
390 struct global_config *cfg;
391
392 cfg = get_global_cfg();
393 if (!cfg) {
397 return;
398 }
399
400 *count = cfg->unidentified_request_count;
401 *period = cfg->unidentified_request_period;
402 *prune_interval = cfg->unidentified_request_prune_interval;
403
404 ao2_ref(cfg, -1);
405 return;
406}
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT
Definition: config_global.c:45
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL
Definition: config_global.c:47
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD
Definition: config_global.c:46
unsigned int unidentified_request_prune_interval
unsigned int unidentified_request_count
unsigned int unidentified_request_period

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().

◆ 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 536 of file config_global.c.

537{
538 unsigned int use_callerid_contact;
539 struct global_config *cfg;
540
541 cfg = get_global_cfg();
542 if (!cfg) {
544 }
545
547 ao2_ref(cfg, -1);
549}
#define DEFAULT_USE_CALLERID_CONTACT
Definition: config_global.c:53
unsigned int use_callerid_contact

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

Referenced by set_from_header().

◆ ast_sip_global_default_outbound_endpoint()

char * ast_sip_global_default_outbound_endpoint ( void  )

Definition at line 250 of file config_global.c.

251{
252 char *str;
253 struct global_config *cfg;
254
255 cfg = get_global_cfg();
256 if (!cfg) {
258 }
259
261 ao2_ref(cfg, -1);
262 return str;
263}
const char * str
Definition: app_jack.c:150
#define DEFAULT_OUTBOUND_ENDPOINT
Definition: config_global.c:35
const ast_string_field default_outbound_endpoint
Definition: config_global.c:92

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().

◆ ast_sip_initialize_sorcery_global()

int ast_sip_initialize_sorcery_global ( void  )

Definition at line 734 of file config_global.c.

735{
737
738 snprintf(default_useragent, sizeof(default_useragent), "%s %s",
740
741 ast_sorcery_apply_default(sorcery, "global", "config", "pjsip.conf,criteria=type=global,single_object=yes,explicit_name=global");
742
744 return -1;
745 }
746
747 ast_sorcery_object_field_register(sorcery, "global", "type", "", OPT_NOOP_T, 0, 0);
748 ast_sorcery_object_field_register(sorcery, "global", "max_forwards",
752 OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, useragent));
753 ast_sorcery_object_field_register(sorcery, "global", "default_outbound_endpoint",
755 OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_outbound_endpoint));
758 ast_sorcery_object_field_register(sorcery, "global", "endpoint_identifier_order",
760 OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, endpoint_identifier_order));
761 ast_sorcery_object_field_register(sorcery, "global", "keep_alive_interval",
763 OPT_UINT_T, 0, FLDSET(struct global_config, keep_alive_interval));
764 ast_sorcery_object_field_register(sorcery, "global", "max_initial_qualify_time",
766 OPT_UINT_T, 0, FLDSET(struct global_config, max_initial_qualify_time));
767 ast_sorcery_object_field_register(sorcery, "global", "default_from_user", DEFAULT_FROM_USER,
768 OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_from_user));
769 ast_sorcery_object_field_register(sorcery, "global", "default_voicemail_extension",
774 ast_sorcery_object_field_register(sorcery, "global", "contact_expiration_check_interval",
776 OPT_UINT_T, 0, FLDSET(struct global_config, contact_expiration_check_interval));
777 ast_sorcery_object_field_register(sorcery, "global", "disable_multi_domain",
778 DEFAULT_DISABLE_MULTI_DOMAIN ? "yes" : "no",
779 OPT_BOOL_T, 1, FLDSET(struct global_config, disable_multi_domain));
780 ast_sorcery_object_field_register(sorcery, "global", "unidentified_request_count",
782 OPT_UINT_T, 0, FLDSET(struct global_config, unidentified_request_count));
783 ast_sorcery_object_field_register(sorcery, "global", "unidentified_request_period",
785 OPT_UINT_T, 0, FLDSET(struct global_config, unidentified_request_period));
786 ast_sorcery_object_field_register(sorcery, "global", "unidentified_request_prune_interval",
788 OPT_UINT_T, 0, FLDSET(struct global_config, unidentified_request_prune_interval));
789 ast_sorcery_object_field_register(sorcery, "global", "default_realm", DEFAULT_REALM,
791 ast_sorcery_object_field_register(sorcery, "global", "mwi_tps_queue_high",
794 ast_sorcery_object_field_register(sorcery, "global", "mwi_tps_queue_low",
797 ast_sorcery_object_field_register(sorcery, "global", "mwi_disable_initial_unsolicited",
800 ast_sorcery_object_field_register(sorcery, "global", "allow_sending_180_after_183",
802 OPT_BOOL_T, 1, FLDSET(struct global_config, allow_sending_180_after_183));
803 ast_sorcery_object_field_register(sorcery, "global", "ignore_uri_user_options",
804 DEFAULT_IGNORE_URI_USER_OPTIONS ? "yes" : "no",
805 OPT_BOOL_T, 1, FLDSET(struct global_config, ignore_uri_user_options));
806 ast_sorcery_object_field_register(sorcery, "global", "use_callerid_contact",
807 DEFAULT_USE_CALLERID_CONTACT ? "yes" : "no",
808 OPT_YESNO_T, 1, FLDSET(struct global_config, use_callerid_contact));
809 ast_sorcery_object_field_register(sorcery, "global", "send_contact_status_on_update_registration",
811 OPT_YESNO_T, 1, FLDSET(struct global_config, send_contact_status_on_update_registration));
812 ast_sorcery_object_field_register_custom(sorcery, "global", "taskprocessor_overload_trigger",
815 ast_sorcery_object_field_register(sorcery, "global", "norefersub",
816 DEFAULT_NOREFERSUB ? "yes" : "no",
817 OPT_YESNO_T, 1, FLDSET(struct global_config, norefersub));
818 ast_sorcery_object_field_register(sorcery, "global", "all_codecs_on_empty_reinvite",
820 OPT_BOOL_T, 1, FLDSET(struct global_config, all_codecs_on_empty_reinvite));
821 ast_sorcery_object_field_register(sorcery, "global", "default_auth_algorithms_uas",
823 STRFLDSET(struct global_config, default_auth_algorithms_uas));
824 ast_sorcery_object_field_register(sorcery, "global", "default_auth_algorithms_uac",
826 STRFLDSET(struct global_config, default_auth_algorithms_uac));
827
829 return -1;
830 }
832
833 return 0;
834}
const char * ast_get_version(void)
Retrieve the Asterisk version string.
#define __stringify(x)
Definition: asterisk.h:216
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:349
static int overload_trigger_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static void * global_alloc(const char *name)
static char default_useragent[256]
Definition: config_global.c:70
#define DEFAULT_USERAGENT_PREFIX
Definition: config_global.c:34
static const char * overload_trigger_map[]
#define DEFAULT_MAX_FORWARDS
Definition: config_global.c:32
static int overload_trigger_to_str(const void *obj, const intptr_t *args, char **buf)
static int global_apply(const struct ast_sorcery *sorcery, void *obj)
#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_UINT_T
Type for default option handler for unsigned integers.
@ 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_YESNO_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_INT_T
Type for default option handler for signed integers.
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
static char default_realm[AST_SIP_AUTH_MAX_REALM_LENGTH+1]
static char * default_voicemail_extension
Definition: res_pjsip_mwi.c:49
static int debug
Global debug status.
Definition: res_xmpp.c:570
#define NULL
Definition: resample.c:96
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:837
void ast_sorcery_load_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to load persistent objects.
Definition: sorcery.c:1393
#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 ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:476
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
Channel datastore data for max forwards.
Definition: max_forwards.c:29

References __stringify, ast_get_version(), ast_sip_get_sorcery(), ast_sorcery_apply_default, ast_sorcery_instance_observer_add(), ast_sorcery_load_object(), ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_register, debug, DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE, DEFAULT_ALLOW_SENDING_180_AFTER_183, DEFAULT_AUTH_ALGORITHMS_UAC, DEFAULT_AUTH_ALGORITHMS_UAS, DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL, DEFAULT_DEBUG, DEFAULT_DISABLE_MULTI_DOMAIN, DEFAULT_ENDPOINT_IDENTIFIER_ORDER, 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, DEFAULT_REALM, 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, default_voicemail_extension, global_config::disable_initial_unsolicited, FLDSET, global_alloc(), global_apply(), NULL, observer_callbacks_global, 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(), regcontext, sorcery, STRFLDSET, global_config::tps_queue_high, and global_config::tps_queue_low.

Referenced by ast_res_pjsip_initialize_configuration().

◆ ast_sip_overload_trigger_to_str()

const char * ast_sip_overload_trigger_to_str ( enum ast_sip_taskprocessor_overload_trigger  trigger)

Definition at line 635 of file config_global.c.

636{
637 return ARRAY_IN_BOUNDS(trigger, overload_trigger_map) ?
638 overload_trigger_map[trigger] : "";
639}
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
Definition: utils.h:687

References ARRAY_IN_BOUNDS, and overload_trigger_map.

Referenced by overload_trigger_to_str().

◆ check_regcontext()

static int check_regcontext ( const struct global_config cfg)
static

Definition at line 159 of file config_global.c.

160{
161 char *current = NULL;
162
163 if (previous_regcontext && !strcmp(previous_regcontext, cfg->regcontext)) {
164 /* Nothing changed so nothing to do */
165 return 0;
166 }
167
168 if (!ast_strlen_zero(cfg->regcontext)) {
170 if (!current) {
171 return -1;
172 }
173
176 return -1;
177 }
178 }
179
184 }
185
186 if (current) {
188 }
189
190 return 0;
191}
size_t current
Definition: main/cli.c:113
int ast_sip_persistent_endpoint_add_to_regcontext(const char *regcontext)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

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

Referenced by global_apply().

◆ 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 140 of file config_global.c.

141{
142 struct global_config *cfg;
143
144 cfg = ast_sorcery_generic_alloc(sizeof(*cfg), global_destructor);
145 if (!cfg || ast_string_field_init(cfg, 100)) {
146 ao2_cleanup(cfg);
147 return NULL;
148 }
149
150 return cfg;
151}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
static void global_destructor(void *obj)
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359

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

Referenced by ast_sip_initialize_sorcery_global().

◆ global_apply()

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

Definition at line 193 of file config_global.c.

194{
195 struct global_config *cfg = obj;
196 char max_forwards[10];
197 struct pjsip_auth_algorithm_type_vector algorithms;
198 int res = 0;
199
200 if (ast_strlen_zero(cfg->debug)) {
202 "Global option 'debug' can't be empty. Set it to a valid value or remove the entry to accept 'no' as the default\n");
203 return -1;
204 }
205
208 "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");
209 return -1;
210 }
211
212 snprintf(max_forwards, sizeof(max_forwards), "%u", cfg->max_forwards);
213
215 ast_sip_add_global_request_header("User-Agent", cfg->useragent, 1);
217
218 if (check_regcontext(cfg)) {
219 return -1;
220 }
221
222 AST_VECTOR_INIT(&algorithms, 0);
224 &algorithms, "UAS", cfg->default_auth_algorithms_uas);
225 AST_VECTOR_FREE(&algorithms);
226 if (res) {
227 ast_log(LOG_WARNING, "global: Invalid values in default_auth_algorithms_uas. "
228 "Defaulting to %s\n", DEFAULT_AUTH_ALGORITHMS_UAS);
229 ast_string_field_set(cfg, default_auth_algorithms_uas, DEFAULT_AUTH_ALGORITHMS_UAS);
230 }
231 AST_VECTOR_INIT(&algorithms, 0);
233 &algorithms, "UAC", cfg->default_auth_algorithms_uac);
234 AST_VECTOR_FREE(&algorithms);
235 if (res) {
236 ast_log(LOG_WARNING, "global: Invalid values in default_auth_algorithms_uac. "
237 "Defaulting to %s\n", DEFAULT_AUTH_ALGORITHMS_UAC);
238 ast_string_field_set(cfg, default_auth_algorithms_uac, DEFAULT_AUTH_ALGORITHMS_UAC);
239 }
240
241 ao2_t_global_obj_replace_unref(global_cfg, cfg, "Applying global settings");
242 return 0;
243}
#define ast_log
Definition: astobj2.c:42
#define ao2_t_global_obj_replace_unref(holder, obj, tag)
Definition: astobj2.h:904
static int check_regcontext(const struct global_config *cfg)
#define LOG_ERROR
#define LOG_WARNING
int ast_sip_auth_digest_algorithms_vector_init(const char *id, struct pjsip_auth_algorithm_type_vector *algorithms, const char *agent_type, const char *value)
Populate a vector of algorithm types from a string.
Definition: config_auth.c:192
int ast_sip_add_global_request_header(const char *name, const char *value, int replace)
int ast_sip_add_global_response_header(const char *name, const char *value, int replace)
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
const ast_string_field useragent
Definition: config_global.c:92
unsigned int max_forwards
Definition: config_global.c:94
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113

References ao2_t_global_obj_replace_unref, ast_log, ast_sip_add_global_request_header(), ast_sip_add_global_response_header(), ast_sip_auth_digest_algorithms_vector_init(), ast_string_field_set, ast_strlen_zero(), AST_VECTOR_FREE, AST_VECTOR_INIT, check_regcontext(), global_config::debug, DEFAULT_AUTH_ALGORITHMS_UAC, global_config::default_auth_algorithms_uac, DEFAULT_AUTH_ALGORITHMS_UAS, global_config::default_auth_algorithms_uas, global_config::default_from_user, LOG_ERROR, LOG_WARNING, global_config::max_forwards, and global_config::useragent.

Referenced by ast_sip_initialize_sorcery_global(), and global_loaded_observer().

◆ global_destructor()

static void global_destructor ( void *  obj)
static

Definition at line 133 of file config_global.c.

134{
135 struct global_config *cfg = obj;
136
138}
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:374

References ast_string_field_free_memory.

Referenced by global_alloc().

◆ 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 657 of file config_global.c.

658{
659 struct ao2_container *globals;
660 struct global_config *cfg;
661
662 if (strcmp(object_type, "global")) {
663 /* Not interested */
664 return;
665 }
666
669 if (globals) {
670 int count;
671
673 ao2_ref(globals, -1);
674
675 if (1 < count) {
677 "At most one pjsip.conf type=global object can be defined. You have %d defined.\n",
678 count);
679 return;
680 }
681 if (count) {
682 return;
683 }
684 }
685
686 ast_debug(1, "No pjsip.conf type=global object exists so applying defaults.\n");
687 cfg = ast_sorcery_alloc(sorcery, "global", NULL);
688 if (!cfg) {
689 return;
690 }
691 global_apply(sorcery, cfg);
692 ao2_ref(cfg, -1);
693}
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
static struct console_pvt globals
#define ast_debug(level,...)
Log a DEBUG message.
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
Definition: sorcery.h:120
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
Definition: sorcery.h:123
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
Generic container type.

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, NULL, and sorcery.

◆ overload_trigger_handler()

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

Definition at line 611 of file config_global.c.

613{
614 struct global_config *cfg = obj;
615 if (!strcasecmp(var->value, "none")) {
617 } else if (!strcasecmp(var->value, "global")) {
619 } else if (!strcasecmp(var->value, "pjsip_only")) {
621 } else {
622 ast_log(LOG_WARNING, "Unknown overload trigger '%s' specified for %s\n",
623 var->value, var->name);
624 return -1;
625 }
626 return 0;
627}
#define var
Definition: ast_expr2f.c:605
@ TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL
@ TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY
@ TASKPROCESSOR_OVERLOAD_TRIGGER_NONE

References ast_log, LOG_WARNING, global_config::overload_trigger, TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL, TASKPROCESSOR_OVERLOAD_TRIGGER_NONE, TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY, and var.

Referenced by ast_sip_initialize_sorcery_global().

◆ overload_trigger_to_str()

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

Definition at line 641 of file config_global.c.

642{
643 const struct global_config *cfg = obj;
645 return 0;
646}
const char * ast_sip_overload_trigger_to_str(enum ast_sip_taskprocessor_overload_trigger trigger)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66

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

Referenced by ast_sip_initialize_sorcery_global().

◆ sip_cli_print_global()

int sip_cli_print_global ( struct ast_sip_cli_context context)

Definition at line 699 of file config_global.c.

700{
701 struct global_config *cfg = get_global_cfg();
702
703 if (!cfg) {
704 cfg = ast_sorcery_alloc(ast_sip_get_sorcery(), "global", NULL);
705 if (!cfg) {
706 return -1;
707 }
708 }
709
710 ast_str_append(&context->output_buffer, 0, "\nGlobal Settings:\n\n");
712
713 ao2_ref(cfg, -1);
714 return 0;
715}
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
Definition: pjsip_cli.c: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:1139

References ao2_ref, ast_sip_cli_print_sorcery_objectset(), ast_sip_get_sorcery(), ast_sorcery_alloc(), ast_str_append(), voicemailpwcheck::context, get_global_cfg(), and NULL.

Referenced by cli_show_settings().

Variable Documentation

◆ default_useragent

char default_useragent[256]
static

Definition at line 70 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 695 of file config_global.c.

Referenced by ast_sip_destroy_sorcery_global(), and ast_sip_initialize_sorcery_global().

◆ overload_trigger_map

const char* overload_trigger_map[]
static

◆ previous_regcontext

char* previous_regcontext = NULL
static

Definition at line 157 of file config_global.c.

Referenced by ast_sip_destroy_sorcery_global(), and check_regcontext().