Asterisk - The Open Source Telephony Project  18.5.0
Enumerations | Functions
res_pjsip_private.h File Reference
#include "asterisk/module.h"
#include "asterisk/compat.h"
Include dependency graph for res_pjsip_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ast_sip_taskprocessor_overload_trigger { TASKPROCESSOR_OVERLOAD_TRIGGER_NONE = 0, TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL, TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY }
 

Functions

void ast_res_pjsip_cleanup_message_filter (void)
 
void ast_res_pjsip_cleanup_options_handling (void)
 
void ast_res_pjsip_destroy_configuration (void)
 
struct ast_sip_contact_statusast_res_pjsip_find_or_create_contact_status (const struct ast_sip_contact *contact)
 
int ast_res_pjsip_init_contact_transports (void)
 
int ast_res_pjsip_init_message_filter (void)
 
int ast_res_pjsip_init_options_handling (int reload)
 
int ast_res_pjsip_initialize_configuration (void)
 
int ast_res_pjsip_preinit_options_handling (void)
 
int ast_res_pjsip_reload_configuration (void)
 
void ast_sip_destroy_cli (void)
 
void ast_sip_destroy_distributor (void)
 
void ast_sip_destroy_global_headers (void)
 
int ast_sip_destroy_scheduler (void)
 
int ast_sip_destroy_sorcery_auth (void)
 
int ast_sip_destroy_sorcery_global (void)
 
int ast_sip_destroy_sorcery_location (void)
 
int ast_sip_destroy_sorcery_transport (void)
 
void ast_sip_destroy_system (void)
 
void ast_sip_destroy_transport_events (void)
 
void ast_sip_destroy_transport_management (void)
 
enum ast_sip_taskprocessor_overload_trigger ast_sip_get_taskprocessor_overload_trigger (void)
 
char * ast_sip_global_default_outbound_endpoint (void)
 
int ast_sip_initialize_cli (void)
 
int ast_sip_initialize_distributor (void)
 
void ast_sip_initialize_dns (void)
 
int ast_sip_initialize_global (void)
 
void ast_sip_initialize_global_headers (void)
 
void ast_sip_initialize_resolver (void)
 
int ast_sip_initialize_scheduler (void)
 Initialize scheduler. More...
 
int ast_sip_initialize_sorcery_auth (void)
 Initialize sorcery with auth support. More...
 
int ast_sip_initialize_sorcery_domain_alias (void)
 Initialize sorcery with domain alias support. More...
 
int ast_sip_initialize_sorcery_global (void)
 
int ast_sip_initialize_sorcery_location (void)
 Initialize sorcery with location support. More...
 
int ast_sip_initialize_sorcery_qualify (void)
 
int ast_sip_initialize_sorcery_transport (void)
 Initialize sorcery with transport support. More...
 
int ast_sip_initialize_system (void)
 
int ast_sip_initialize_transport_events (void)
 
int ast_sip_initialize_transport_management (void)
 
const char * ast_sip_overload_trigger_to_str (enum ast_sip_taskprocessor_overload_trigger trigger)
 
int ast_sip_persistent_endpoint_add_to_regcontext (const char *regcontext)
 
int ast_sip_validate_uri_length (const char *uri)
 
int ast_sip_will_uri_survive_restart (pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 
int sip_cli_print_global (struct ast_sip_cli_context *context)
 
int sip_cli_print_system (struct ast_sip_cli_context *context)
 
void sip_get_threadpool_options (struct ast_threadpool_options *threadpool_options)
 

Enumeration Type Documentation

◆ ast_sip_taskprocessor_overload_trigger

Enumerator
TASKPROCESSOR_OVERLOAD_TRIGGER_NONE 
TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL 
TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY 

Definition at line 411 of file res_pjsip_private.h.

Function Documentation

◆ ast_res_pjsip_cleanup_message_filter()

void ast_res_pjsip_cleanup_message_filter ( void  )

Definition at line 565 of file pjsip_message_filter.c.

References ast_sip_session_unregister_supplement(), ast_sip_unregister_service(), ast_sip_unregister_supplement(), filter_module_transport, and filter_module_tsx.

Referenced by ast_res_pjsip_init_message_filter(), and unload_pjsip().

566 {
571 }
static pjsip_module filter_module_transport
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
Definition: pjsip_session.c:63
static pjsip_module filter_module_tsx
static struct ast_sip_supplement filter_supplement
PJSIP Supplement for tagging messages with restrictions.
static struct ast_sip_session_supplement filter_session_supplement
PJSIP Session Supplement for tagging messages with restrictions.
void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
Unregister a an supplement to SIP out of dialog processing.
Definition: res_pjsip.c:4531
void ast_sip_unregister_service(pjsip_module *module)
Definition: res_pjsip.c:3331

◆ ast_res_pjsip_cleanup_options_handling()

void ast_res_pjsip_cleanup_options_handling ( void  )

Definition at line 2835 of file pjsip_options.c.

References ao2_cleanup, ARRAY_LEN, ast_cli_unregister_multiple(), ast_log, ast_manager_unregister(), ast_serializer_shutdown_group_join(), ast_sip_get_pjsip_endpoint(), ast_sip_get_sorcery(), ast_sip_push_task_wait_serializer(), ast_sip_unregister_endpoint_formatter(), ast_sorcery_observer_remove(), ast_taskprocessor_unreference(), LOG_WARNING, management_serializer, MAX_UNLOAD_TIMEOUT_TIME, NULL, options_module, and sip_options_cleanup_task().

Referenced by ast_res_pjsip_init_options_handling(), and unload_pjsip().

2836 {
2837  int remaining;
2838  struct ast_taskprocessor *mgmt_serializer;
2839 
2841  ast_manager_unregister("PJSIPQualify");
2842  ast_manager_unregister("PJSIPShowContacts");
2844 
2851 
2852  mgmt_serializer = management_serializer;
2854  if (mgmt_serializer) {
2856  }
2857 
2860  if (remaining) {
2861  ast_log(LOG_WARNING, "Cleanup incomplete. Could not stop %d AORs.\n",
2862  remaining);
2863  }
2865  shutdown_group = NULL;
2866 
2867  if (mgmt_serializer) {
2868  ast_taskprocessor_unreference(mgmt_serializer);
2869  }
2870 
2877 
2878  pjsip_endpt_unregister_module(ast_sip_get_pjsip_endpoint(), &options_module);
2879 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ao2_container * sip_options_contact_statuses
static struct ast_cli_entry cli_options[]
static const struct ast_sorcery_observer contact_observer_callbacks
Observer callbacks for contacts.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static int sip_options_cleanup_task(void *obj)
Management task to clean up the environment.
#define LOG_WARNING
Definition: logger.h:274
static const struct ast_sorcery_observer aor_observer_callbacks
Observer callbacks for AORs.
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition: res_pjsip.c:3685
#define NULL
Definition: resample.c:96
int ast_serializer_shutdown_group_join(struct ast_serializer_shutdown_group *shutdown_group, int timeout)
Wait for the serializers in the group to shutdown with timeout.
Definition: threadpool.c:1241
static struct ast_sip_endpoint_formatter contact_status_formatter
#define ast_log
Definition: astobj2.c:42
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
Definition: res_pjsip.c:5218
static pjsip_module options_module
static struct ao2_container * sip_options_endpoint_state_compositors
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7258
static struct ast_taskprocessor * management_serializer
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:3718
void ast_sorcery_observer_remove(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Remove an observer from a specific object type.
Definition: sorcery.c:2418
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
static struct ao2_container * sip_options_aors
#define MAX_UNLOAD_TIMEOUT_TIME
Maximum wait time to join the below shutdown group.
static struct ast_serializer_shutdown_group * shutdown_group
Shutdown group for options serializers.
static const struct ast_sorcery_observer endpoint_observer_callbacks
Observer callbacks for endpoints.

◆ ast_res_pjsip_destroy_configuration()

void ast_res_pjsip_destroy_configuration ( void  )

Definition at line 2219 of file pjsip_configuration.c.

References AMI_SHOW_ENDPOINT, AMI_SHOW_ENDPOINTS, ao2_cleanup, ARRAY_LEN, ast_cli_unregister_multiple(), ast_manager_unregister(), ast_sip_destroy_cli(), ast_sip_destroy_sorcery_auth(), ast_sip_destroy_sorcery_global(), ast_sip_destroy_sorcery_location(), ast_sip_destroy_sorcery_transport(), ast_sip_unregister_cli_formatter(), ast_sorcery_unref, NULL, and stasis_unsubscribe_and_join().

Referenced by unload_pjsip().

2220 {
2221  if (!sip_sorcery) {
2222  return;
2223  }
2224 
2231  sip_sorcery = NULL;
2239 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct stasis_subscription * acl_change_sub
#define AMI_SHOW_ENDPOINT
#define NULL
Definition: resample.c:96
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1502
struct ast_sip_cli_formatter_entry * endpoint_formatter
static struct ast_cli_entry cli_commands[]
void ast_sip_destroy_cli(void)
Definition: pjsip_cli.c:375
int ast_sip_destroy_sorcery_auth(void)
Definition: config_auth.c:426
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
static struct ao2_container * persistent_endpoints
Container for persistent endpoint information.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7258
static struct ast_sorcery * sip_sorcery
int ast_sip_destroy_sorcery_global(void)
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Definition: stasis.c:1136
int ast_sip_destroy_sorcery_location(void)
Definition: location.c:1467
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
int ast_sip_destroy_sorcery_transport(void)
#define AMI_SHOW_ENDPOINTS

◆ ast_res_pjsip_find_or_create_contact_status()

struct ast_sip_contact_status* ast_res_pjsip_find_or_create_contact_status ( const struct ast_sip_contact contact)

Definition at line 462 of file pjsip_options.c.

References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_sip_contact::aor, ast_sip_contact_status::aor, ast_assert, ast_sip_get_contact_status_label(), ast_sorcery_object_get_id(), AST_STATSD_GAUGE, ast_statsd_log_string_va(), ast_string_field_set, CREATED, ast_sip_contact_status::last_status, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ast_sip_contact_status::rtt, sip_contact_status_alloc(), sip_options_contact_status_update(), ast_sip_contact_status::status, ast_sip_contact::uri, and ast_sip_contact_status::uri.

Referenced by contact_apply_handler(), permanent_uri_handler(), sip_options_contact_add_task(), sip_options_contact_status_available_count(), sip_options_qualify_contact(), sip_options_set_contact_status_qualified(), and sip_options_set_contact_status_unqualified().

463 {
464  struct ast_sip_contact_status *contact_status;
465  int res;
466 
467  /*
468  * At startup a contact status can be retrieved when static contacts
469  * are themselves being setup. This happens before we are fully setup.
470  * Since we don't actually trigger qualify or anything as a result it
471  * is safe to do so. They'll just get back a contact status that will
472  * be updated later. At this time they only care that the contact
473  * status gets created for the static contact anyway.
474  */
476  /*
477  * We haven't been pre-initialized or we are shutting down.
478  * Neither situation should happen.
479  */
480  ast_assert(0);
481  return NULL;
482  }
483 
485 
486  /* If contact status for this contact already exists just return it */
487  contact_status = ao2_find(sip_options_contact_statuses,
489  if (contact_status) {
491  return contact_status;
492  }
493 
494  /* Otherwise we have to create and store a new contact status */
495  contact_status = sip_contact_status_alloc(ast_sorcery_object_get_id(contact));
496  if (!contact_status) {
498  return NULL;
499  }
500 
501  contact_status->rtt = 0;
502  contact_status->status = CREATED;
503  contact_status->last_status = CREATED;
504  res = ast_string_field_set(contact_status, uri, contact->uri);
505  res |= ast_string_field_set(contact_status, aor, contact->aor);
506  if (res) {
508  ao2_ref(contact_status, -1);
509  return NULL;
510  }
511 
514 
515  ast_statsd_log_string_va("PJSIP.contacts.states.%s", AST_STATSD_GAUGE,
516  "+1", 1.0, ast_sip_get_contact_status_label(contact_status->status));
517 
518  sip_options_contact_status_update(contact_status);
519 
520  return contact_status;
521 }
enum ast_sip_contact_status_type last_status
Definition: res_pjsip.h:353
A contact's status.
Definition: res_pjsip.h:341
static struct ao2_container * sip_options_contact_statuses
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1105
Assume that the ao2_container is already locked.
Definition: astobj2.h:1067
#define ast_assert(a)
Definition: utils.h:695
#define ao2_link_flags(container, obj, flags)
Definition: astobj2.h:1572
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
const ast_string_field uri
Definition: res_pjsip.h:347
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_lock(a)
Definition: astobj2.h:718
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
static struct ast_sip_contact_status * sip_contact_status_alloc(const char *name)
enum ast_sip_contact_status_type status
Definition: res_pjsip.h:351
const char * ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
translate ast_sip_contact_status_type to character string.
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
#define AST_STATSD_GAUGE
Support for publishing to a statsd server.
Definition: statsd.h:32
const ast_string_field aor
Definition: res_pjsip.h:303
void ast_statsd_log_string_va(const char *metric_name, const char *metric_type, const char *value, double sample_rate,...)
Send a stat to the configured statsd server.
Definition: res_statsd.c:176
const ast_string_field uri
Definition: res_pjsip.h:303
static void sip_options_contact_status_update(struct ast_sip_contact_status *contact_status)
const ast_string_field aor
Definition: res_pjsip.h:347
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ ast_res_pjsip_init_contact_transports()

int ast_res_pjsip_init_contact_transports ( void  )

◆ ast_res_pjsip_init_message_filter()

int ast_res_pjsip_init_message_filter ( void  )

Definition at line 573 of file pjsip_message_filter.c.

References ast_log, ast_res_pjsip_cleanup_message_filter(), ast_sip_register_service(), ast_sip_register_supplement(), ast_sip_session_register_supplement, filter_module_transport, filter_module_tsx, and LOG_ERROR.

Referenced by load_module().

574 {
577 
579  ast_log(LOG_ERROR, "Could not register message filter module for incoming and outgoing requests\n");
581  return -1;
582  }
583 
585  ast_log(LOG_ERROR, "Could not register message filter module for incoming and outgoing requests\n");
587  return -1;
588  }
589 
590  return 0;
591 }
static pjsip_module filter_module_transport
static pjsip_module filter_module_tsx
#define ast_log
Definition: astobj2.c:42
static struct ast_sip_supplement filter_supplement
PJSIP Supplement for tagging messages with restrictions.
void ast_res_pjsip_cleanup_message_filter(void)
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition: res_pjsip.c:3315
static struct ast_sip_session_supplement filter_session_supplement
PJSIP Session Supplement for tagging messages with restrictions.
void ast_sip_register_supplement(struct ast_sip_supplement *supplement)
Register a supplement to SIP out of dialog processing.
Definition: res_pjsip.c:4511
#define LOG_ERROR
Definition: logger.h:285
#define ast_sip_session_register_supplement(supplement)

◆ ast_res_pjsip_init_options_handling()

int ast_res_pjsip_init_options_handling ( int  reload)

Definition at line 2918 of file pjsip_options.c.

References ami_show_contacts(), ami_sip_qualify(), AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_hash, AOR_BUCKETS, ARRAY_LEN, ast_cli_register_multiple, ast_manager_register_xml, ast_res_pjsip_cleanup_options_handling(), ast_sip_create_serializer(), ast_sip_get_pjsip_endpoint(), ast_sip_push_task_wait_serializer(), ast_sip_register_endpoint_formatter(), ast_taskprocessor_alert_set_levels(), AST_TASKPROCESSOR_HIGH_WATER_LEVEL, ENDPOINT_STATE_COMPOSITOR_BUCKETS, EVENT_FLAG_REPORTING, EVENT_FLAG_SYSTEM, NULL, options_module, sip_options_init_task(), and sip_options_synchronize().

Referenced by load_module(), and reload_configuration_task().

2919 {
2920  struct ast_taskprocessor *mgmt_serializer;
2921 
2922  static const pj_str_t STR_OPTIONS = { "OPTIONS", 7 };
2923 
2924  if (reload) {
2926  return 0;
2927  }
2928 
2929  if (pjsip_endpt_register_module(ast_sip_get_pjsip_endpoint(), &options_module)
2930  != PJ_SUCCESS) {
2931  return -1;
2932  }
2933 
2934  if (pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), NULL, PJSIP_H_ALLOW,
2935  NULL, 1, &STR_OPTIONS) != PJ_SUCCESS) {
2937  return -1;
2938  }
2939 
2941  sip_options_aor_hash_fn, NULL, sip_options_aor_cmp_fn);
2942  if (!sip_options_aors) {
2944  return -1;
2945  }
2949  sip_options_endpoint_state_compositor_hash_fn, NULL,
2950  sip_options_endpoint_state_compositor_cmp_fn);
2953  return -1;
2954  }
2955 
2956  mgmt_serializer = ast_sip_create_serializer("pjsip/options/manage");
2957  if (!mgmt_serializer) {
2959  return -1;
2960  }
2961 
2962  /*
2963  * Set the water mark levels high because we can get a flood of
2964  * contact status updates from sip_options_synchronize() that
2965  * quickly clears on initial load or reload.
2966  */
2967  ast_taskprocessor_alert_set_levels(mgmt_serializer, -1,
2969 
2970  /*
2971  * We make sure that the environment is completely setup before we allow
2972  * any other threads to post contact_status updates to the
2973  * management_serializer.
2974  */
2976  mgmt_serializer)) {
2977  /* Set management_serializer in case pushing the task actually failed. */
2978  management_serializer = mgmt_serializer;
2980  return -1;
2981  }
2982 
2985  ami_sip_qualify);
2988 
2989  return 0;
2990 }
static int ami_sip_qualify(struct mansession *s, const struct message *m)
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_cli_entry cli_options[]
static void sip_options_synchronize(int reload)
Synchronize our local container of AORs and endpoint state compositors with the current configuration...
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Definition: taskprocessor.h:63
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static int sip_options_init_task(void *mgmt_serializer)
Management task to finish setting up the environment.
int ast_taskprocessor_alert_set_levels(struct ast_taskprocessor *tps, long low_water, long high_water)
Set the high and low alert water marks of the given taskprocessor queue.
#define NULL
Definition: resample.c:96
static struct ast_sip_endpoint_formatter contact_status_formatter
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition: res_pjsip.c:3679
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
Definition: res_pjsip.c:5218
static pjsip_module options_module
static struct ao2_container * sip_options_endpoint_state_compositors
#define ENDPOINT_STATE_COMPOSITOR_BUCKETS
These are the number of buckets to store endpoint state compositors.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
struct ast_taskprocessor * ast_sip_create_serializer(const char *name)
Create a new serializer for SIP tasks.
Definition: res_pjsip.c:5133
static struct ast_taskprocessor * management_serializer
static int reload(void)
Definition: cdr_mysql.c:741
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:3718
#define EVENT_FLAG_REPORTING
Definition: manager.h:80
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
static struct ao2_container * sip_options_aors
void ast_res_pjsip_cleanup_options_handling(void)
static int ami_show_contacts(struct mansession *s, const struct message *m)
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:186
#define AOR_BUCKETS
These are the number of buckets to store AORs in.

◆ ast_res_pjsip_initialize_configuration()

int ast_res_pjsip_initialize_configuration ( void  )

Definition at line 1973 of file pjsip_configuration.c.

References accountcode, acl_change_stasis_cb(), acl_to_str(), AMI_SHOW_ENDPOINT, ami_show_endpoint(), AMI_SHOW_ENDPOINTS, ami_show_endpoints(), ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_manager_register_xml, ast_named_acl_change_type(), ast_security_topic(), ast_sip_endpoint_alloc(), ast_sip_initialize_cli(), ast_sip_initialize_sorcery_auth(), ast_sip_initialize_sorcery_domain_alias(), ast_sip_initialize_sorcery_global(), ast_sip_initialize_sorcery_location(), ast_sip_initialize_sorcery_transport(), ast_sip_location_prune_boot_contacts(), ast_sip_register_cli_formatter(), ast_sorcery_apply_default, ast_sorcery_internal_object_register, ast_sorcery_load(), ast_sorcery_object_field_register, ast_sorcery_object_field_register_alias, ast_sorcery_object_field_register_custom, ast_sorcery_object_get_id(), ast_sorcery_object_register, ast_sorcery_observer_add(), ast_sorcery_open, ast_sorcery_unref, call_offer_pref_handler(), caller_id_handler(), caller_id_privacy_handler(), caller_id_privacy_to_str(), caller_id_tag_handler(), caller_id_tag_to_str(), caller_id_to_str(), callgroup_to_str(), CHARFLDSET, cli_endpoint_get_container(), cli_endpoint_iterate(), cli_endpoint_print_body(), cli_endpoint_print_header(), cli_endpoint_retrieve_by_id(), codec_prefs_handler(), connected_line_method_handler(), connected_line_method_to_str(), contact_acl_to_str(), contact_user_handler(), contact_user_to_str(), context, ast_sip_endpoint::context, direct_media_glare_mitigation_handler(), direct_media_glare_mitigation_to_str(), direct_media_method_handler(), direct_media_method_to_str(), dtls_handler(), dtlsautogeneratecert_to_str(), dtlscafile_to_str(), dtlscapath_to_str(), dtlscertfile_to_str(), dtlscipher_to_str(), dtlsfingerprint_to_str(), dtlsprivatekey_to_str(), dtlsrekey_to_str(), dtlssetup_to_str(), dtlsverify_to_str(), dtmf_handler(), dtmf_to_str(), endpoint_acl_handler(), EVENT_FLAG_SYSTEM, FLDSET, from_user_handler(), from_user_to_str(), ast_sip_endpoint::fromuser, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, group_handler(), ident_handler(), ident_to_str(), inbound_auth_handler(), inbound_auths_to_str(), incoming_answer_codec_prefs_to_str(), incoming_call_offer_pref_to_str(), incoming_offer_codec_prefs_to_str(), sip_to_pjsip::info(), ast_sip_cli_formatter_entry::iterate, language, load_all_endpoints(), LOG_ERROR, media_encryption_handler(), media_encryption_to_str(), mohsuggest, ast_sip_cli_formatter_entry::name, named_callgroups_to_str(), named_groups_handler(), named_pickupgroups_to_str(), nat, ast_sip_endpoint::nat, NULL, OPT_BOOL_T, OPT_CHAR_ARRAY_T, OPT_CODEC_T, OPT_NOOP_T, OPT_STRINGFIELD_T, OPT_UINT_T, OPT_YESNO_T, outbound_auth_handler(), outbound_auths_to_str(), outgoing_answer_codec_prefs_to_str(), outgoing_call_offer_pref_to_str(), outgoing_offer_codec_prefs_to_str(), PERSISTENT_BUCKETS, persistent_endpoint_cmp(), persistent_endpoint_hash(), pickupgroup_to_str(), prack_handler(), prack_to_str(), ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, redirect_handler(), ast_sip_cli_formatter_entry::retrieve_by_id, set_var_handler(), set_var_to_str(), set_var_to_vl(), sip_endpoint_apply_handler(), sip_nat_hook_alloc(), stasis_subscribe, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), STRFLDSET, t38udptl_ec_handler(), t38udptl_ec_to_str(), timers_handler(), timers_to_str(), tos_audio_to_str(), tos_handler(), tos_video_to_str(), voicemail_extension_handler(), and voicemail_extension_to_str().

Referenced by load_module().

1974 {
1977  return -1;
1978  }
1979 
1982  if (!persistent_endpoints) {
1983  return -1;
1984  }
1985 
1986  if (!(sip_sorcery = ast_sorcery_open())) {
1987  ast_log(LOG_ERROR, "Failed to open SIP sorcery failed to open\n");
1988  return -1;
1989  }
1990 
1992 
1994  ast_log(LOG_ERROR, "Failed to register SIP authentication support\n");
1996  sip_sorcery = NULL;
1997  return -1;
1998  }
1999 
2000  ast_sorcery_apply_default(sip_sorcery, "endpoint", "config", "pjsip.conf,criteria=type=endpoint");
2001  ast_sorcery_apply_default(sip_sorcery, "nat_hook", "memory", NULL);
2002 
2004  ast_log(LOG_ERROR, "Failed to register SIP endpoint object with sorcery\n");
2006  sip_sorcery = NULL;
2007  return -1;
2008  }
2009 
2011  ast_log(LOG_ERROR, "Failed to register nat_hook\n");
2012  }
2013 
2014  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "type", "", OPT_NOOP_T, 0, 0);
2015  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "context", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, context));
2016  ast_sorcery_object_field_register_alias(sip_sorcery, "endpoint", "disallow", "", OPT_CODEC_T, 0, FLDSET(struct ast_sip_endpoint, media.codecs));
2017  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow", "", OPT_CODEC_T, 1, FLDSET(struct ast_sip_endpoint, media.codecs));
2018  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmf_mode", "rfc4733", dtmf_handler, dtmf_to_str, NULL, 0, 0);
2019  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.ipv6));
2020  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_symmetric", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.symmetric));
2021  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ice_support", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.ice_support));
2022  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_ptime", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_ptime));
2023  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_rport", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, nat.force_rport));
2024  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rewrite_contact", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, nat.rewrite_contact));
2025  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
2026  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, outbound_proxy));
2027  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "moh_suggest", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mohsuggest));
2030  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_min_se", "90", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, extensions.timer.min_se));
2031  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_sess_expires", "1800", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, extensions.timer.sess_expires));
2035  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "media_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.address));
2036  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bind_rtp_to_media_address", "no", OPT_BOOL_T, 1, STRFLDSET(struct ast_sip_endpoint, media.bind_rtp_to_media_address));
2037  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "identify_by", "username,ip", ident_handler, ident_to_str, NULL, 0, 0);
2038  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "direct_media", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.enabled));
2040  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_connected_line));
2041  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_connected_line", "yes", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, id.send_connected_line));
2044  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disable_direct_media_on_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.disable_on_nat));
2046  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "allowed_not_screened", caller_id_privacy_handler, caller_id_privacy_to_str, NULL, 0, 0);
2048  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_inbound));
2049  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_outbound));
2050  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_pai", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_pai));
2051  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_rpid", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_rpid));
2052  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rpid_immediate", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.rpid_immediate));
2053  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_diversion", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_diversion));
2054  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_history_info", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_history_info));
2055  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.mailboxes));
2057  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aggregate_mwi", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.aggregate));
2058  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_subscribe_replaces_unsolicited", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.subscribe_replaces_unsolicited));
2060  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_avpf", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_avpf));
2061  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_avp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.force_avp));
2062  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "media_use_received_transport", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_received_transport));
2063  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_keepalive", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.keepalive));
2064  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.timeout));
2065  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_timeout_hold", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.rtp.timeout_hold));
2066  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "one_touch_recording", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, info.recording.enabled));
2067  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "inband_progress", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, inband_progress));
2072  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "device_state_busy_at", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, devicestate_busy_at));
2073  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.enabled));
2075  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_maxdatagram", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.t38.maxdatagram));
2076  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, faxdetect));
2077  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fax_detect_timeout", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, faxdetect_timeout));
2078  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.nat));
2079  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_ipv6", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.ipv6));
2080  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tone_zone", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, zone));
2082  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_on_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.onfeature));
2083  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "record_off_feature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.offfeature));
2084  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_transfer", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowtransfer));
2085  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "user_eq_phone", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, usereqphone));
2086  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "moh_passthrough", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, moh_passthrough));
2087  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_owner", "-", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpowner));
2088  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_session", "Asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpsession));
2091  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_audio));
2092  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_video));
2093  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_subscribe", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.allow));
2094  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sub_min_expiry", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subscription.minexpiry));
2096  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "from_domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
2097  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_from_user", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
2098  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_engine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.rtp.engine));
2099  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_verify", "no", dtls_handler, dtlsverify_to_str, NULL, 0, 0);
2101  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_auto_generate_cert", "no", dtls_handler, dtlsautogeneratecert_to_str, NULL, 0, 0);
2103  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_private_key", "", dtls_handler, dtlsprivatekey_to_str, NULL, 0, 0);
2109  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "srtp_tag_32", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.srtp_tag_32));
2110  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "media_encryption_optimistic", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.encryption_optimistic));
2111  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "g726_non_standard", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.g726_non_standard));
2112  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "redirect_method", "user", redirect_handler, NULL, NULL, 0, 0);
2114  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "message_context", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, message_context));
2119  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_deny", "", endpoint_acl_handler, NULL, NULL, 0, 0);
2120  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_permit", "", endpoint_acl_handler, NULL, NULL, 0, 0);
2122  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subscribe_context", "", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct ast_sip_endpoint, subscription.context));
2124  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "preferred_codec_only", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, preferred_codec_only));
2125  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "asymmetric_rtp_codec", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, asymmetric_rtp_codec));
2126  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtcp_mux", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtcp_mux));
2127  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_overlap", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_overlap));
2128  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "refer_blind_progress", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, refer_blind_progress));
2129  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "notify_early_inuse_ringing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, notify_early_inuse_ringing));
2130  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_audio_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_audio_streams));
2131  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_video_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_video_streams));
2132  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bundle", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.bundle));
2133  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "webrtc", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, media.webrtc));
2134  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "incoming_mwi_mailbox", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, incoming_mwi_mailbox));
2135  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "follow_early_media_fork", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.follow_early_media_fork));
2136  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "accept_multiple_sdp_answers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.accept_multiple_sdp_answers));
2137  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "suppress_q850_reason_headers", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, suppress_q850_reason_headers));
2138  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ignore_183_without_sdp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, ignore_183_without_sdp));
2139  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "incoming_call_offer_pref", "local",
2141  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "outgoing_call_offer_pref", "remote_merge",
2143  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_offer",
2144  "prefer: pending, operation: intersect, keep: all, transcode: allow",
2146  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_outgoing_offer",
2147  "prefer: pending, operation: union, keep: all, transcode: allow",
2149  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_answer",
2150  "prefer: pending, operation: intersect, keep: all",
2152  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_outgoing_answer",
2153  "prefer: pending, operation: intersect, keep: all",
2155  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "stir_shaken", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, stir_shaken));
2156  ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_unauthenticated_options", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_unauthenticated_options));
2157 
2159  ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
2161  sip_sorcery = NULL;
2162  return -1;
2163  }
2164 
2166  ast_log(LOG_ERROR, "Failed to register SIP location support with sorcery\n");
2168  sip_sorcery = NULL;
2169  return -1;
2170  }
2171 
2173 
2175  ast_log(LOG_ERROR, "Failed to register SIP domain aliases support with sorcery\n");
2177  sip_sorcery = NULL;
2178  return -1;
2179  }
2180 
2182  ast_log(LOG_ERROR, "Failed to register SIP Global support\n");
2184  sip_sorcery = NULL;
2185  return -1;
2186  }
2187 
2189  if (!endpoint_formatter) {
2190  ast_log(LOG_ERROR, "Unable to allocate memory for endpoint_formatter\n");
2192  sip_sorcery = NULL;
2193  return -1;
2194  }
2195  endpoint_formatter->name = "endpoint";
2202 
2205 
2207 
2209 
2211 
2215 
2216  return 0;
2217 }
static int direct_media_glare_mitigation_to_str(const void *obj, const intptr_t *args, char **buf)
Type for default option handler for format capabilities.
static int dtlsverify_to_str(const void *obj, const intptr_t *args, char **buf)
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:428
static int named_groups_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int codec_prefs_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int outgoing_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_sip_initialize_sorcery_domain_alias(void)
Initialize sorcery with domain alias support.
const ast_string_field fromuser
Definition: res_pjsip.h:829
static int pickupgroup_to_str(const void *obj, const intptr_t *args, char **buf)
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int caller_id_privacy_to_str(const void *obj, const intptr_t *args, char **buf)
static int dtlscapath_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: res_pjsip_cli.h:52
static int timers_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int acl_to_str(const void *obj, const intptr_t *args, char **buf)
static int set_var_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
int ast_sip_initialize_cli(void)
Definition: pjsip_cli.c:360
struct ast_sip_endpoint_nat_configuration nat
Definition: res_pjsip.h:845
#define ast_sorcery_object_field_register_alias(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object as an alias.
Definition: sorcery.h:971
static int dtlscafile_to_str(const void *obj, const intptr_t *args, char **buf)
static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
static int direct_media_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int nat
Definition: chan_mgcp.c:168
static int ami_show_endpoint(struct mansession *s, const struct message *m)
static int contact_acl_to_str(const void *obj, const intptr_t *args, char **buf)
static int set_var_to_str(const void *obj, const intptr_t *args, char **buf)
static int outgoing_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
static int connected_line_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static void * cli_endpoint_retrieve_by_id(const char *id)
const ast_string_field context
Definition: res_pjsip.h:815
static int outbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
#define CHARFLDSET(type, field)
A helper macro to pass the appropriate arguments to aco_option_register for OPT_CHAR_ARRAY_T.
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
Type for a default handler that should do nothing.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Definition: stasis.c:1079
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs ...
static int named_callgroups_to_str(const void *obj, const intptr_t *args, char **buf)
static struct stasis_subscription * acl_change_sub
static int t38udptl_ec_to_str(const void *obj, const intptr_t *args, char **buf)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static int connected_line_method_to_str(const void *obj, const intptr_t *args, char **buf)
static int caller_id_privacy_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int incoming_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
static int callgroup_to_str(const void *obj, const intptr_t *args, char **buf)
#define AMI_SHOW_ENDPOINT
static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *obj)
Callback function for when an object is finalized.
static int persistent_endpoint_hash(const void *obj, const int flags)
Hashing function for persistent endpoint information.
static struct ao2_container * cli_endpoint_get_container(const char *regex)
#define NULL
Definition: resample.c:96
static int set_var_to_vl(const void *obj, struct ast_variable **fields)
static int outbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int media_encryption_to_str(const void *obj, const intptr_t *args, char **buf)
static int ident_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int dtlscertfile_to_str(const void *obj, const intptr_t *args, char **buf)
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1502
static int incoming_offer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
static int tos_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Type for default option handler for character array strings.
struct ast_sip_cli_formatter_entry * endpoint_formatter
static int dtlssetup_to_str(const void *obj, const intptr_t *args, char **buf)
Type for default option handler for bools (ast_true/ast_false)
static int call_offer_pref_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int dtls_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int dtlsfingerprint_to_str(const void *obj, const intptr_t *args, char **buf)
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define ast_log
Definition: astobj2.c:42
static int direct_media_glare_mitigation_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#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
static struct ast_cli_entry cli_commands[]
static int contact_user_to_str(const void *obj, const intptr_t *args, char **buf)
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
static int persistent_endpoint_cmp(void *obj, void *arg, int flags)
Comparison function for persistent endpoint information.
int ast_sip_initialize_sorcery_transport(void)
Initialize sorcery with transport support.
static int dtmf_to_str(const void *obj, const intptr_t *args, char **buf)
Type for default option handler for unsigned integers.
static int dtlscipher_to_str(const void *obj, const intptr_t *args, char **buf)
static int dtlsautogeneratecert_to_str(const void *obj, const intptr_t *args, char **buf)
static int tos_audio_to_str(const void *obj, const intptr_t *args, char **buf)
static char mohsuggest[MAX_MUSICCLASS]
Definition: chan_iax2.c:430
static int inbound_auth_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:117
static void load_all_endpoints(void)
static int cli_endpoint_print_header(void *obj, void *arg, int flags)
An entity with which Asterisk communicates.
Definition: res_pjsip.h:812
static int timers_to_str(const void *obj, const intptr_t *args, char **buf)
static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static struct ao2_container * persistent_endpoints
Container for persistent endpoint information.
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
static int tos_video_to_str(const void *obj, const intptr_t *args, char **buf)
void * ast_sip_endpoint_alloc(const char *name)
Allocate a new SIP endpoint.
#define stasis_subscribe(topic, callback, data)
Definition: stasis.h:652
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
Definition: sorcery.c:2386
static void * sip_nat_hook_alloc(const char *name)
static int t38udptl_ec_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int outgoing_call_offer_pref_to_str(const void *obj, const intptr_t *args, char **buf)
void ast_sip_location_prune_boot_contacts(void)
Prune the prune_on_boot contacts.
Definition: location.c:469
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
#define ast_sorcery_internal_object_register(sorcery, type, alloc, transform, apply)
Register an internal, hidden object type.
Definition: sorcery.h:868
static struct ast_sorcery * sip_sorcery
Type for default option handler for bools (ast_true/ast_false)
def info(msg)
static int ident_to_str(const void *obj, const intptr_t *args, char **buf)
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
static int media_encryption_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int ami_show_endpoints(struct mansession *s, const struct message *m)
static int contact_user_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int group_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int incoming_answer_codec_prefs_to_str(const void *obj, const intptr_t *args, char **buf)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static int from_user_to_str(const void *obj, const intptr_t *args, char **buf)
static int caller_id_tag_to_str(const void *obj, const intptr_t *args, char **buf)
static int prack_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
static int prack_to_str(const void *obj, const intptr_t *args, char **buf)
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
int ast_sip_initialize_sorcery_auth(void)
Initialize sorcery with auth support.
Definition: config_auth.c:370
static int caller_id_to_str(const void *obj, const intptr_t *args, char **buf)
static int endpoint_acl_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define PERSISTENT_BUCKETS
Number of buckets for persistent endpoint information.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
void ast_sorcery_load(const struct ast_sorcery *sorcery)
Inform any wizards to load persistent objects.
Definition: sorcery.c:1377
static int caller_id_tag_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int dtlsprivatekey_to_str(const void *obj, const intptr_t *args, char **buf)
static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
int ast_sip_initialize_sorcery_global(void)
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Definition: stasis.c:1025
static int direct_media_method_to_str(const void *obj, const intptr_t *args, char **buf)
#define ast_sorcery_open()
Definition: sorcery.h:408
static int from_user_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static int cli_endpoint_iterate(void *obj, ao2_callback_fn callback, void *args)
Type for default option handler for stringfields.
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
static int named_pickupgroups_to_str(const void *obj, const intptr_t *args, char **buf)
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
static int redirect_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
static const struct ast_sorcery_observer endpoint_observers
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:186
static int cli_endpoint_print_body(void *obj, void *arg, int flags)
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
const char * name
Definition: res_pjsip_cli.h:58
static int inbound_auths_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_sip_initialize_sorcery_location(void)
Initialize sorcery with location support.
Definition: location.c:1366
static int dtlsrekey_to_str(const void *obj, const intptr_t *args, char **buf)
static int caller_id_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define AMI_SHOW_ENDPOINTS

◆ ast_res_pjsip_preinit_options_handling()

int ast_res_pjsip_preinit_options_handling ( void  )

Definition at line 2912 of file pjsip_options.c.

References sip_options_contact_statuses_alloc().

Referenced by load_module().

2913 {
2915  return sip_options_contact_statuses ? 0 : -1;
2916 }
static struct ao2_container * sip_options_contact_statuses
static struct ao2_container * sip_options_contact_statuses_alloc(void)
Helper function to allocate a contact statuses container.

◆ ast_res_pjsip_reload_configuration()

int ast_res_pjsip_reload_configuration ( void  )

Definition at line 2241 of file pjsip_configuration.c.

References ast_sorcery_reload().

Referenced by reload_configuration_task().

2242 {
2243  if (sip_sorcery) {
2245  }
2246  return 0;
2247 }
static struct ast_sorcery * sip_sorcery
void ast_sorcery_reload(const struct ast_sorcery *sorcery)
Inform any wizards to reload persistent objects.
Definition: sorcery.c:1408

◆ ast_sip_destroy_cli()

void ast_sip_destroy_cli ( void  )

Definition at line 375 of file pjsip_cli.c.

References ao2_ref, ARRAY_LEN, and ast_cli_unregister_multiple().

Referenced by ast_res_pjsip_destroy_configuration().

376 {
379 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct ao2_container * formatter_registry
Definition: pjsip_cli.c:34
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct ast_cli_entry pjsip_cli[]
Definition: pjsip_cli.c:356

◆ ast_sip_destroy_distributor()

void ast_sip_destroy_distributor ( void  )

Definition at line 1334 of file pjsip_distributor.c.

References ao2_cleanup, ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sched_context_destroy(), ast_sip_get_sorcery(), ast_sip_unregister_cli_formatter(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), auth_mod, distributor_mod, distributor_pool_shutdown(), and endpoint_mod.

Referenced by ast_sip_initialize_distributor(), and unload_pjsip().

1335 {
1338 
1342 
1343  ao2_global_obj_release(artificial_auth);
1345 
1347 
1348  if (prune_context) {
1350  }
1351 
1353 
1356 }
struct ast_sip_cli_formatter_entry * unid_formatter
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct ao2_container * unidentified_requests
static struct ast_cli_entry cli_commands[]
static pjsip_module endpoint_mod
static pjsip_module auth_mod
static struct ao2_container * dialog_associations
static void distributor_pool_shutdown(void)
static struct ast_sip_endpoint * artificial_endpoint
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
static pjsip_module distributor_mod
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
struct ast_sched_context * prune_context
void ast_sorcery_observer_remove(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Remove an observer from a specific object type.
Definition: sorcery.c:2418
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_sip_unregister_service(pjsip_module *module)
Definition: res_pjsip.c:3331
static struct ast_sorcery_observer global_observer
Observer which is used to update our interval and default_realm when the global setting changes...
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:269

◆ ast_sip_destroy_global_headers()

void ast_sip_destroy_global_headers ( void  )

Definition at line 181 of file pjsip_global_headers.c.

References ast_sip_unregister_service(), destroy_headers(), global_header_mod, request_headers, and response_headers.

Referenced by unload_pjsip().

182 {
185 
187 }
static pjsip_module global_header_mod
static void destroy_headers(struct header_list *headers)
static struct header_list response_headers
static struct header_list request_headers
void ast_sip_unregister_service(pjsip_module *module)
Definition: res_pjsip.c:3331

◆ ast_sip_destroy_scheduler()

int ast_sip_destroy_scheduler ( void  )

Definition at line 642 of file pjsip_scheduler.c.

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sched_context_destroy(), ast_sip_sched_task_cancel(), and NULL.

Referenced by load_module(), and unload_module().

643 {
645 
646  if (scheduler_context) {
647  if (tasks) {
648  struct ao2_iterator iter;
649  struct ast_sip_sched_task *schtd;
650 
651  /* Cancel all scheduled tasks */
652  iter = ao2_iterator_init(tasks, 0);
653  while ((schtd = ao2_iterator_next(&iter))) {
655  ao2_ref(schtd, -1);
656  }
657  ao2_iterator_destroy(&iter);
658  }
659 
662  }
663 
665  tasks = NULL;
666 
667  return 0;
668 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
int ast_sip_sched_task_cancel(struct ast_sip_sched_task *schtd)
Cancels the next invocation of a task.
static struct ast_sched_context * scheduler_context
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct ast_cli_entry cli_commands[]
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct ao2_container * tasks
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:269

◆ ast_sip_destroy_sorcery_auth()

int ast_sip_destroy_sorcery_auth ( void  )

Definition at line 426 of file config_auth.c.

References ARRAY_LEN, ast_cli_unregister_multiple(), ast_manager_unregister(), ast_sip_unregister_cli_formatter(), and ast_sip_unregister_endpoint_formatter().

Referenced by ast_res_pjsip_destroy_configuration().

427 {
431 
432  ast_manager_unregister("PJSIPShowAuths");
433 
434  return 0;
435 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition: res_pjsip.c:3685
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
static struct ast_sip_endpoint_formatter endpoint_auth_formatter
Definition: config_auth.c:212
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7258
static struct ast_sip_cli_formatter_entry * cli_formatter
Definition: config_auth.c:367
static struct ast_cli_entry cli_commands[]
Definition: config_auth.c:350

◆ 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_destroy_sorcery_location()

int ast_sip_destroy_sorcery_location ( void  )

Definition at line 1467 of file location.c.

References ARRAY_LEN, ast_cli_unregister_multiple(), ast_manager_unregister(), ast_sip_get_sorcery(), ast_sip_unregister_cli_formatter(), ast_sip_unregister_endpoint_formatter(), and ast_sorcery_observer_remove().

Referenced by ast_res_pjsip_destroy_configuration().

1468 {
1473  ast_manager_unregister("PJSIPShowAors");
1474 
1476 
1477  return 0;
1478 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
struct ast_sip_cli_formatter_entry * aor_formatter
Definition: location.c:1323
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition: res_pjsip.c:3685
struct ast_sip_endpoint_formatter endpoint_aor_formatter
Definition: location.c:875
static const struct ast_sorcery_observer aor_observer
Observer for contacts so state can be updated on respective endpoints.
Definition: location.c:105
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7258
static struct ast_cli_entry cli_commands[]
Definition: location.c:1290
void ast_sorcery_observer_remove(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Remove an observer from a specific object type.
Definition: sorcery.c:2418
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
struct ast_sip_cli_formatter_entry * contact_formatter
Definition: location.c:1322

◆ ast_sip_destroy_sorcery_transport()

int ast_sip_destroy_sorcery_transport ( void  )

Definition at line 1692 of file config_transport.c.

References ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sip_unregister_cli_formatter(), ast_sip_unregister_endpoint_formatter(), and NULL.

Referenced by ast_res_pjsip_destroy_configuration().

1693 {
1696 
1698 
1701 
1702  return 0;
1703 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct ao2_container * transport_states
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition: res_pjsip.c:3685
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
struct ast_sip_endpoint_formatter endpoint_transport_formatter
static struct ast_sip_cli_formatter_entry * cli_formatter
static struct ast_cli_entry cli_commands[]

◆ ast_sip_destroy_system()

void ast_sip_destroy_system ( void  )

Definition at line 245 of file config_system.c.

References ast_sorcery_unref.

Referenced by unload_pjsip().

246 {
248 }
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1502
static struct ast_sorcery * system_sorcery
Definition: config_system.c:75

◆ ast_sip_destroy_transport_events()

void ast_sip_destroy_transport_events ( void  )

Definition at line 382 of file pjsip_transport_events.c.

References ao2_global_obj_release, ast_sip_get_pjsip_endpoint(), and tpmgr_state_callback.

Referenced by unload_pjsip().

383 {
384  pjsip_tpmgr *tpmgr;
385 
386  tpmgr = pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint());
387  if (tpmgr) {
388  pjsip_tpmgr_set_state_cb(tpmgr, tpmgr_state_callback);
389  }
390 
391  ao2_global_obj_release(active_transports);
392 }
static pjsip_tp_state_callback tpmgr_state_callback
Existing transport events callback that we need to invoke.
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:3718

◆ ast_sip_destroy_transport_management()

void ast_sip_destroy_transport_management ( void  )

Definition at line 410 of file pjsip_transport_management.c.

References ao2_global_obj_release, AST_PTHREADT_NULL, ast_sched_clean_by_callback(), ast_sched_context_destroy(), ast_sip_get_sorcery(), ast_sip_transport_state_unregister(), ast_sip_unregister_service(), ast_sorcery_observer_remove(), idle_monitor_module, idle_sched_cb(), idle_sched_cleanup(), keepalive_interval, keepalive_thread, and NULL.

Referenced by unload_pjsip().

411 {
412  if (keepalive_interval) {
413  keepalive_interval = 0;
415  pthread_kill(keepalive_thread, SIGURG);
416  pthread_join(keepalive_thread, NULL);
418  }
419  }
420 
422 
424 
426 
429  sched = NULL;
430 
431  ao2_global_obj_release(monitored_transports);
432 }
void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb)
Clean all scheduled events with matching callback.
Definition: sched.c:407
Definition: sched.c:76
static unsigned int keepalive_interval
The global interval at which to send keepalives.
static pjsip_module idle_monitor_module
static pthread_t keepalive_thread
Thread keeping things alive.
#define NULL
Definition: resample.c:96
static int idle_sched_cb(const void *data)
static int idle_sched_cleanup(const void *data)
#define AST_PTHREADT_NULL
Definition: lock.h:66
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
struct ast_sip_tpmgr_state_callback monitored_transport_reg
void ast_sorcery_observer_remove(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Remove an observer from a specific object type.
Definition: sorcery.c:2418
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
void ast_sip_unregister_service(pjsip_module *module)
Definition: res_pjsip.c:3331
void ast_sip_transport_state_unregister(struct ast_sip_tpmgr_state_callback *element)
Unregister a transport state notification callback element.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:269
static struct ast_sorcery_observer keepalive_global_observer
Observer which is used to update our interval when the global setting changes.

◆ 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_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_cli()

int ast_sip_initialize_cli ( void  )

Definition at line 360 of file pjsip_cli.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, ast_log, formatter_compare(), formatter_hash(), formatter_sort(), and LOG_ERROR.

Referenced by ast_res_pjsip_initialize_configuration().

361 {
364 
365  if (!formatter_registry) {
366  ast_log(LOG_ERROR, "Unable to create formatter_registry.\n");
367  return -1;
368  }
369 
371 
372  return 0;
373 }
static int formatter_hash(const void *obj, int flags)
Definition: pjsip_cli.c:293
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int formatter_compare(void *obj, void *arg, int flags)
Definition: pjsip_cli.c:264
static int formatter_sort(const void *obj, const void *arg, int flags)
Definition: pjsip_cli.c:239
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define ast_log
Definition: astobj2.c:42
static struct ao2_container * formatter_registry
Definition: pjsip_cli.c:34
static struct ast_cli_entry pjsip_cli[]
Definition: pjsip_cli.c:356
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310

◆ ast_sip_initialize_distributor()

int ast_sip_initialize_distributor ( void  )

Definition at line 1260 of file pjsip_distributor.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_alloc_options, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_sched_context_create(), ast_sched_start_thread(), ast_sip_destroy_distributor(), ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_service(), ast_sorcery_observer_add(), ast_sorcery_reload_object(), auth_mod, cli_unid_get_container(), cli_unid_get_id(), cli_unid_iterate(), cli_unid_print_body(), cli_unid_print_header(), cli_unid_retrieve_by_id(), create_artificial_auth(), create_artificial_endpoint(), DEFAULT_SUSPECTS_BUCKETS, DIALOG_ASSOCIATIONS_BUCKETS, dialog_associations_cmp(), dialog_associations_hash(), distributor_mod, distributor_pool_setup(), endpoint_mod, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, ast_sip_cli_formatter_entry::iterate, LOG_ERROR, ast_sip_cli_formatter_entry::name, NULL, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, ast_sip_cli_formatter_entry::retrieve_by_id, suspects_compare(), and suspects_hash().

Referenced by load_module().

1261 {
1264  if (!unidentified_requests) {
1265  return -1;
1266  }
1267 
1271  if (!dialog_associations) {
1273  return -1;
1274  }
1275 
1276  if (distributor_pool_setup()) {
1278  return -1;
1279  }
1280 
1282  if (!prune_context) {
1284  return -1;
1285  }
1286 
1289  return -1;
1290  }
1291 
1294 
1297  return -1;
1298  }
1299 
1302  return -1;
1303  }
1306  return -1;
1307  }
1310  return -1;
1311  }
1312 
1315  if (!unid_formatter) {
1317  ast_log(LOG_ERROR, "Unable to allocate memory for unid_formatter\n");
1318  return -1;
1319  }
1320  unid_formatter->name = "unidentified_request";
1328 
1330 
1331  return 0;
1332 }
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition: sched.c:195
static const char * cli_unid_get_id(const void *obj)
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
struct ast_sip_cli_formatter_entry * unid_formatter
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
Definition: res_pjsip_cli.h:52
static int create_artificial_endpoint(void)
static int create_artificial_auth(void)
static struct ao2_container * unidentified_requests
static int dialog_associations_hash(const void *obj, int flags)
static struct ao2_container * cli_unid_get_container(const char *regex)
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
static struct ast_cli_entry cli_commands[]
static void * cli_unid_retrieve_by_id(const char *id)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define NULL
Definition: resample.c:96
static pjsip_module endpoint_mod
static int dialog_associations_cmp(void *obj, void *arg, int flags)
static pjsip_module auth_mod
static int suspects_hash(const void *obj, int flags)
static struct ao2_container * dialog_associations
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
void ast_sip_destroy_distributor(void)
#define ast_log
Definition: astobj2.c:42
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition: res_pjsip.c:3315
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
Definition: sorcery.c:2386
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:236
static int cli_unid_print_header(void *obj, void *arg, int flags)
static int cli_unid_iterate(void *container, ao2_callback_fn callback, void *args)
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
static pjsip_module distributor_mod
static int suspects_compare(void *obj, void *arg, int flags)
struct ast_sched_context * prune_context
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
static int distributor_pool_setup(void)
#define DEFAULT_SUSPECTS_BUCKETS
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static int cli_unid_print_body(void *obj, void *arg, int flags)
#define DIALOG_ASSOCIATIONS_BUCKETS
static struct ast_sorcery_observer global_observer
Observer which is used to update our interval and default_realm when the global setting changes...
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
const char * name
Definition: res_pjsip_cli.h:58
void ast_sorcery_reload_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to reload persistent objects.
Definition: sorcery.c:1442

◆ ast_sip_initialize_dns()

void ast_sip_initialize_dns ( void  )

Definition at line 314 of file config_system.c.

References ast_sip_push_task_wait_servant(), NULL, and system_create_resolver_and_set_nameservers().

Referenced by load_module(), and reload_configuration_task().

315 {
317 }
static int system_create_resolver_and_set_nameservers(void *data)
#define NULL
Definition: resample.c:96
int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
Definition: res_pjsip.c:5204

◆ ast_sip_initialize_global()

int ast_sip_initialize_global ( void  )

◆ ast_sip_initialize_global_headers()

void ast_sip_initialize_global_headers ( void  )

Definition at line 163 of file pjsip_global_headers.c.

References AST_RWLIST_HEAD_INIT, ast_sip_register_service(), global_header_mod, request_headers, and response_headers.

Referenced by load_module().

164 {
167 
169 }
static pjsip_module global_header_mod
static struct header_list response_headers
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
Definition: linkedlists.h:638
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition: res_pjsip.c:3315
static struct header_list request_headers

◆ ast_sip_initialize_resolver()

void ast_sip_initialize_resolver ( void  )

Definition at line 708 of file pjsip_resolver.c.

References ast_log, ast_sip_push_task_wait_servant(), LOG_NOTICE, NULL, and sip_replace_resolver().

Referenced by load_module().

709 {
710  /* Replace the existing PJSIP resolver with our own implementation */
712 }
#define NULL
Definition: resample.c:96
int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
Definition: res_pjsip.c:5204
static int sip_replace_resolver(void *data)

◆ ast_sip_initialize_scheduler()

int ast_sip_initialize_scheduler ( void  )

Initialize scheduler.

Since
13.9.0
Return values
-1failure
0success

Definition at line 614 of file pjsip_scheduler.c.

References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_hash, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_sched_context_create(), ast_sched_context_destroy(), ast_sched_start_thread(), LOG_ERROR, and TASK_BUCKETS.

Referenced by load_module().

615 {
617  if (!scheduler_context) {
618  ast_log(LOG_ERROR, "Failed to create scheduler. Aborting load\n");
619  return -1;
620  }
621 
623  ast_log(LOG_ERROR, "Failed to start scheduler. Aborting load\n");
625  return -1;
626  }
627 
629  AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, TASK_BUCKETS, ast_sip_sched_task_hash_fn,
630  ast_sip_sched_task_sort_fn, ast_sip_sched_task_cmp_fn);
631  if (!tasks) {
632  ast_log(LOG_ERROR, "Failed to allocate task container. Aborting load\n");
634  return -1;
635  }
636 
638 
639  return 0;
640 }
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition: sched.c:195
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_sched_context * scheduler_context
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define ast_log
Definition: astobj2.c:42
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:236
static struct ast_cli_entry cli_commands[]
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
#define TASK_BUCKETS
static struct ao2_container * tasks
Reject objects with duplicate keys in container.
Definition: astobj2.h:1192
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:269

◆ ast_sip_initialize_sorcery_auth()

int ast_sip_initialize_sorcery_auth ( void  )

Initialize sorcery with auth support.

Definition at line 370 of file config_auth.c.

References ami_show_auths(), ao2_alloc, ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_manager_register_xml, ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_endpoint_formatter(), ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_get_id(), ast_sorcery_object_register, auth_alloc(), auth_apply(), auth_type_handler(), auth_type_to_str(), cli_get_container(), cli_iterator(), cli_print_body(), cli_print_header(), cli_retrieve_by_id(), EVENT_FLAG_SYSTEM, FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, ast_sip_cli_formatter_entry::iterate, LOG_ERROR, ast_sip_cli_formatter_entry::name, NULL, OPT_NOOP_T, OPT_STRINGFIELD_T, OPT_UINT_T, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, ast_sip_cli_formatter_entry::retrieve_by_id, sorcery, and STRFLDSET.

Referenced by ast_res_pjsip_initialize_configuration().

371 {
373 
374  ast_sorcery_apply_default(sorcery, SIP_SORCERY_AUTH_TYPE, "config", "pjsip.conf,criteria=type=auth");
375 
376  if (ast_sorcery_object_register(sorcery, SIP_SORCERY_AUTH_TYPE, auth_alloc, NULL, auth_apply)) {
377  return -1;
378  }
379 
380  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "type", "",
381  OPT_NOOP_T, 0, 0);
382  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "username",
383  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, auth_user));
384  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "password",
385  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, auth_pass));
386  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "refresh_token",
387  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, refresh_token));
388  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "oauth_clientid",
389  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, oauth_clientid));
390  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "oauth_secret",
391  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, oauth_secret));
392  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "md5_cred",
393  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, md5_creds));
394  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "realm",
395  "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_auth, realm));
396  ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "nonce_lifetime",
397  "32", OPT_UINT_T, 0, FLDSET(struct ast_sip_auth, nonce_lifetime));
398  ast_sorcery_object_field_register_custom(sorcery, SIP_SORCERY_AUTH_TYPE, "auth_type",
399  "userpass", auth_type_handler, auth_type_to_str, NULL, 0, 0);
400 
402 
404  if (!cli_formatter) {
405  ast_log(LOG_ERROR, "Unable to allocate memory for cli formatter\n");
406  return -1;
407  }
408  cli_formatter->name = SIP_SORCERY_AUTH_TYPE;
415 
418 
420  return -1;
421  }
422 
423  return 0;
424 }
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
static int auth_type_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: config_auth.c:86
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
Definition: res_pjsip_cli.h:52
static int cli_iterator(void *container, ao2_callback_fn callback, void *args)
Definition: config_auth.c:301
static int auth_type_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Definition: config_auth.c:52
Full structure for sorcery.
Definition: sorcery.c:230
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
Type for a default handler that should do nothing.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static struct ao2_container * cli_get_container(const char *regex)
Definition: config_auth.c:277
#define NULL
Definition: resample.c:96
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
static void * cli_retrieve_by_id(const char *id)
Definition: config_auth.c:306
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition: res_pjsip.c:3679
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define ast_log
Definition: astobj2.c:42
#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 FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
Type for default option handler for unsigned integers.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
static int cli_print_header(void *obj, void *arg, int flags)
Definition: config_auth.c:311
static void * auth_alloc(const char *name)
Definition: config_auth.c:36
static struct ast_sip_endpoint_formatter endpoint_auth_formatter
Definition: config_auth.c:212
#define LOG_ERROR
Definition: logger.h:285
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
static struct ast_sip_cli_formatter_entry * cli_formatter
Definition: config_auth.c:367
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
static struct ast_cli_entry cli_commands[]
Definition: config_auth.c:350
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static int ami_show_auths(struct mansession *s, const struct message *m)
Definition: config_auth.c:247
Type for default option handler for stringfields.
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:186
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
const char * name
Definition: res_pjsip_cli.h:58
static int cli_print_body(void *obj, void *arg, int flags)
Definition: config_auth.c:326
static int auth_apply(const struct ast_sorcery *sorcery, void *obj)
Definition: config_auth.c:93

◆ ast_sip_initialize_sorcery_domain_alias()

int ast_sip_initialize_sorcery_domain_alias ( void  )

Initialize sorcery with domain alias support.

Definition at line 71 of file config_domain_aliases.c.

References ast_sip_get_sorcery(), ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_register, domain_alias_alloc(), domain_alias_apply(), NULL, OPT_NOOP_T, OPT_STRINGFIELD_T, SIP_SORCERY_DOMAIN_ALIAS_TYPE, sorcery, and STRFLDSET.

Referenced by ast_res_pjsip_initialize_configuration().

72 {
74 
75  ast_sorcery_apply_default(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, "config", "pjsip.conf,criteria=type=domain_alias");
76 
79  return -1;
80  }
81 
83  OPT_NOOP_T, 0, 0);
86 
87  return 0;
88 }
Full structure for sorcery.
Definition: sorcery.c:230
Type for a default handler that should do nothing.
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE
Definition: res_pjsip.h:254
static int domain_alias_apply(const struct ast_sorcery *sorcery, void *obj)
Apply handler for domain_alias type.
#define NULL
Definition: resample.c:96
Domain data structure.
Definition: sip.h:888
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
#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
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Type for default option handler for stringfields.
static void * domain_alias_alloc(const char *name)

◆ 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_initialize_sorcery_location()

int ast_sip_initialize_sorcery_location ( void  )

Initialize sorcery with location support.

Definition at line 1366 of file location.c.

References ami_show_aors(), ao2_alloc, aor_alloc(), aor_apply_handler(), ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_manager_register_xml, ast_pjproject_get_buildopt(), ast_sip_get_contact_status_label(), ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_endpoint_formatter(), ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_register, ast_sorcery_object_set_congestion_levels(), ast_sorcery_observer_add(), AST_STATSD_GAUGE, ast_statsd_log_full_va(), AST_TASKPROCESSOR_HIGH_WATER_LEVEL, cli_aor_get_container(), cli_aor_get_id(), cli_aor_iterate(), cli_aor_print_body(), cli_aor_print_header(), cli_aor_retrieve_by_id(), cli_contact_get_container(), cli_contact_get_id(), cli_contact_iterate(), cli_contact_print_body(), cli_contact_print_header(), cli_contact_retrieve_by_id(), contact_alloc(), contact_apply_handler(), contacts_to_str(), contacts_to_var_list(), default_expiration, EVENT_FLAG_SYSTEM, expiration_str2struct(), expiration_struct2str(), FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, ast_sip_cli_formatter_entry::iterate, LOG_ERROR, mailboxes, ast_sip_cli_formatter_entry::name, NULL, OPT_BOOL_T, OPT_DOUBLE_T, OPT_NOOP_T, OPT_STRINGFIELD_T, OPT_UINT_T, OPT_YESNO_T, PARSE_IN_RANGE, permanent_uri_handler(), pj_max_hostname, pjsip_max_url_size, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, REMOVED, ast_sip_cli_formatter_entry::retrieve_by_id, sorcery, STRFLDSET, voicemail_extension_handler(), and voicemail_extension_to_str().

Referenced by ast_res_pjsip_initialize_configuration().

1367 {
1369  int i;
1370 
1371  ast_pjproject_get_buildopt("PJ_MAX_HOSTNAME", "%d", &pj_max_hostname);
1372  /* As of pjproject 2.4.5, PJSIP_MAX_URL_SIZE isn't exposed yet but we try anyway. */
1373  ast_pjproject_get_buildopt("PJSIP_MAX_URL_SIZE", "%d", &pjsip_max_url_size);
1374 
1375  ast_sorcery_apply_default(sorcery, "contact", "astdb", "registrar");
1376  ast_sorcery_object_set_congestion_levels(sorcery, "contact", -1,
1378  ast_sorcery_apply_default(sorcery, "aor", "config", "pjsip.conf,criteria=type=aor");
1379 
1382  return -1;
1383  }
1384 
1385  ast_sorcery_observer_add(sorcery, "aor", &aor_observer);
1386 
1387  ast_sorcery_object_field_register(sorcery, "contact", "type", "", OPT_NOOP_T, 0, 0);
1388  ast_sorcery_object_field_register(sorcery, "contact", "uri", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, uri));
1389  ast_sorcery_object_field_register(sorcery, "contact", "path", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, path));
1390  ast_sorcery_object_field_register_custom(sorcery, "contact", "expiration_time", "", expiration_str2struct, expiration_struct2str, NULL, 0, 0);
1391  ast_sorcery_object_field_register(sorcery, "contact", "qualify_frequency", 0, OPT_UINT_T,
1392  PARSE_IN_RANGE, FLDSET(struct ast_sip_contact, qualify_frequency), 0, 86400);
1393  ast_sorcery_object_field_register(sorcery, "contact", "qualify_timeout", "3.0", OPT_DOUBLE_T, 0, FLDSET(struct ast_sip_contact, qualify_timeout));
1394  ast_sorcery_object_field_register(sorcery, "contact", "authenticate_qualify", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_contact, authenticate_qualify));
1395  ast_sorcery_object_field_register(sorcery, "contact", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, outbound_proxy));
1396  ast_sorcery_object_field_register(sorcery, "contact", "user_agent", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, user_agent));
1397  ast_sorcery_object_field_register(sorcery, "contact", "endpoint", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, endpoint_name));
1398  ast_sorcery_object_field_register(sorcery, "contact", "reg_server", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, reg_server));
1399  ast_sorcery_object_field_register(sorcery, "contact", "via_addr", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, via_addr));
1400  ast_sorcery_object_field_register(sorcery, "contact", "via_port", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_contact, via_port));
1401  ast_sorcery_object_field_register(sorcery, "contact", "call_id", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, call_id));
1402  ast_sorcery_object_field_register(sorcery, "contact", "prune_on_boot", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_contact, prune_on_boot));
1403 
1404  ast_sorcery_object_field_register(sorcery, "aor", "type", "", OPT_NOOP_T, 0, 0);
1405  ast_sorcery_object_field_register(sorcery, "aor", "minimum_expiration", "60", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, minimum_expiration));
1406  ast_sorcery_object_field_register(sorcery, "aor", "maximum_expiration", "7200", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, maximum_expiration));
1407  ast_sorcery_object_field_register(sorcery, "aor", "default_expiration", "3600", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, default_expiration));
1408  ast_sorcery_object_field_register(sorcery, "aor", "qualify_frequency", 0, OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_aor, qualify_frequency), 0, 86400);
1409  ast_sorcery_object_field_register(sorcery, "aor", "qualify_timeout", "3.0", OPT_DOUBLE_T, 0, FLDSET(struct ast_sip_aor, qualify_timeout));
1410  ast_sorcery_object_field_register(sorcery, "aor", "authenticate_qualify", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, authenticate_qualify));
1411  ast_sorcery_object_field_register(sorcery, "aor", "max_contacts", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, max_contacts));
1412  ast_sorcery_object_field_register(sorcery, "aor", "remove_existing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, remove_existing));
1414  ast_sorcery_object_field_register(sorcery, "aor", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, mailboxes));
1416  ast_sorcery_object_field_register(sorcery, "aor", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, outbound_proxy));
1417  ast_sorcery_object_field_register(sorcery, "aor", "support_path", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, support_path));
1418 
1420 
1422  if (!contact_formatter) {
1423  ast_log(LOG_ERROR, "Unable to allocate memory for contact_formatter\n");
1424  return -1;
1425  }
1426  contact_formatter->name = "contact";
1433 
1435  if (!aor_formatter) {
1436  ast_log(LOG_ERROR, "Unable to allocate memory for aor_formatter\n");
1437  return -1;
1438  }
1439  aor_formatter->name = "aor";
1446 
1450 
1451  if (ast_manager_register_xml("PJSIPShowAors", EVENT_FLAG_SYSTEM, ami_show_aors)) {
1452  return -1;
1453  }
1454 
1455  /*
1456  * Reset StatsD gauges in case we didn't shut down cleanly.
1457  * Note that this must done here, as contacts will create the contact_status
1458  * object before PJSIP options handling is initialized.
1459  */
1460  for (i = 0; i <= REMOVED; i++) {
1461  ast_statsd_log_full_va("PJSIP.contacts.states.%s", AST_STATSD_GAUGE, 0, 1.0, ast_sip_get_contact_status_label(i));
1462  }
1463 
1464  return 0;
1465 }
static int expiration_str2struct(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for translating from a string timeval to actual structure.
Definition: location.c:482
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
void ast_statsd_log_full_va(const char *metric_name, const char *metric_type, intmax_t value, double sample_rate,...)
Send a stat to the configured statsd server.
Definition: res_statsd.c:199
A SIP address of record.
Definition: res_pjsip.h:361
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
Definition: res_pjsip_cli.h:52
struct ast_sip_cli_formatter_entry * aor_formatter
Definition: location.c:1323
static int ami_show_aors(struct mansession *s, const struct message *m)
Definition: location.c:1260
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Definition: taskprocessor.h:63
static void * aor_alloc(const char *name)
Allocator for AOR.
Definition: location.c:50
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
static int cli_contact_iterate(void *container, ao2_callback_fn callback, void *args)
Definition: location.c:976
static int cli_aor_print_body(void *obj, void *arg, int flags)
Definition: location.c:1183
Full structure for sorcery.
Definition: sorcery.c:230
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
Type for a default handler that should do nothing.
static void * contact_alloc(const char *name)
Allocator for contact.
Definition: location.c:120
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_pjproject_get_buildopt(char *option, char *format_string,...)
Retrieve a pjproject build option.
const char * ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
translate ast_sip_contact_status_type to character string.
static int contacts_to_var_list(const void *obj, struct ast_variable **fields)
Definition: location.c:657
#define NULL
Definition: resample.c:96
struct ast_sip_endpoint_formatter endpoint_aor_formatter
Definition: location.c:875
static void * cli_aor_retrieve_by_id(const char *id)
Definition: location.c:1146
int ast_sorcery_object_set_congestion_levels(struct ast_sorcery *sorcery, const char *type, long low_water, long high_water)
Set the high and low alert water marks of the sorcery object type.
Definition: sorcery.c:1114
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
static int cli_aor_iterate(void *container, ao2_callback_fn callback, void *args)
Definition: location.c:1139
static int cli_contact_print_body(void *obj, void *arg, int flags)
Definition: location.c:1106
Type for default option handler for bools (ast_true/ast_false)
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition: res_pjsip.c:3679
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define ast_log
Definition: astobj2.c:42
#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 FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
Type for default option handler for unsigned integers.
static const struct ast_sorcery_observer aor_observer
Observer for contacts so state can be updated on respective endpoints.
Definition: location.c:105
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
static int cli_contact_print_header(void *obj, void *arg, int flags)
Definition: location.c:1091
static int default_expiration
Definition: pbx_dundi.c:199
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
static struct ao2_container * cli_contact_get_container(const char *regex)
Definition: location.c:1026
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
Definition: sorcery.c:2386
static const char * cli_aor_get_id(const void *obj)
Definition: location.c:1151
#define LOG_ERROR
Definition: logger.h:285
static int permanent_uri_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for permanent URIs.
Definition: location.c:589
static int voicemail_extension_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Definition: location.c:666
Type for default option handler for bools (ast_true/ast_false)
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
Contact associated with an address of record.
Definition: res_pjsip.h:281
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static int contacts_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: location.c:808
static int contact_apply_handler(const struct ast_sorcery *sorcery, void *object)
Always create a contact_status for each contact.
Definition: location.c:1326
static int aor_apply_handler(const struct ast_sorcery *sorcery, void *object)
Definition: location.c:1352
static int cli_aor_print_header(void *obj, void *arg, int flags)
Definition: location.c:1156
static int expiration_struct2str(const void *obj, const intptr_t *args, char **buf)
Custom handler for translating from an actual structure timeval to string.
Definition: location.c:489
Type for default option handler for doubles.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
static struct ast_cli_entry cli_commands[]
Definition: location.c:1290
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
static struct ao2_container * cli_aor_get_container(const char *regex)
Definition: location.c:879
#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_STATSD_GAUGE
Support for publishing to a statsd server.
Definition: statsd.h:32
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Type for default option handler for stringfields.
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
struct ast_sip_cli_formatter_entry * contact_formatter
Definition: location.c:1322
static int pjsip_max_url_size
Definition: location.c:37
static void * cli_contact_retrieve_by_id(const char *id)
Definition: location.c:1076
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:186
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
static const char * cli_contact_get_id(const void *obj)
Definition: location.c:916
const char * name
Definition: res_pjsip_cli.h:58
static int voicemail_extension_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: location.c:675
static int pj_max_hostname
Definition: location.c:36

◆ ast_sip_initialize_sorcery_qualify()

int ast_sip_initialize_sorcery_qualify ( void  )

◆ ast_sip_initialize_sorcery_transport()

int ast_sip_initialize_sorcery_transport ( void  )

Initialize sorcery with transport support.

Definition at line 1618 of file config_transport.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_cleanup, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, ast_log, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_endpoint_formatter(), ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_get_id(), ast_sorcery_object_register, ast_sorcery_retrieve_by_fields(), ca_list_file_to_str(), ca_list_path_to_str(), cert_file_to_str(), cli_get_container(), cli_iterate(), cli_print_body(), cli_print_header(), cli_retrieve_by_id(), cos, DEFAULT_STATE_BUCKETS, FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, internal_state_cmp(), internal_state_hash(), ast_sip_cli_formatter_entry::iterate, localnet_to_str(), localnet_to_vl(), LOG_ERROR, ast_sip_cli_formatter_entry::name, NULL, OPT_BOOL_T, OPT_INT_T, OPT_STRINGFIELD_T, OPT_UINT_T, PARSE_IN_RANGE, password, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, privkey_file_to_str(), require_client_cert_to_str(), ast_sip_cli_formatter_entry::retrieve_by_id, sip_transport_alloc(), sorcery, STRFLDSET, tls_method_to_str(), tos_to_str(), transport_apply(), transport_bind_handler(), transport_bind_to_str(), transport_localnet_handler(), transport_protocol_handler(), transport_protocol_to_str(), transport_state_init(), transport_tls_bool_handler(), transport_tls_file_handler(), transport_tls_method_handler(), transport_tos_handler(), verify_client_to_str(), and verify_server_to_str().

Referenced by ast_res_pjsip_initialize_configuration().

1619 {
1621  struct ao2_container *transports = NULL;
1622 
1623  /* Create outbound registration states container. */
1626  if (!transport_states) {
1627  ast_log(LOG_ERROR, "Unable to allocate transport states container\n");
1628  return -1;
1629  }
1630 
1631  ast_sorcery_apply_default(sorcery, "transport", "config", "pjsip.conf,criteria=type=transport");
1632 
1634  return -1;
1635  }
1636 
1637  /* Normally type is a OPT_NOOP_T but we're using it to make sure that state is created */
1638  ast_sorcery_object_field_register_custom(sorcery, "transport", "type", "", transport_state_init, NULL, NULL, 0, 0);
1641  ast_sorcery_object_field_register(sorcery, "transport", "async_operations", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, async_operations));
1642 
1643  ast_sorcery_object_field_register_custom(sorcery, "transport", "ca_list_file", "", transport_tls_file_handler, ca_list_file_to_str, NULL, 0, 0);
1644  ast_sorcery_object_field_register_custom(sorcery, "transport", "ca_list_path", "", transport_tls_file_handler, ca_list_path_to_str, NULL, 0, 0);
1645  ast_sorcery_object_field_register_custom(sorcery, "transport", "cert_file", "", transport_tls_file_handler, cert_file_to_str, NULL, 0, 0);
1646  ast_sorcery_object_field_register_custom(sorcery, "transport", "priv_key_file", "", transport_tls_file_handler, privkey_file_to_str, NULL, 0, 0);
1647 
1648  ast_sorcery_object_field_register(sorcery, "transport", "password", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, password));
1649  ast_sorcery_object_field_register(sorcery, "transport", "external_signaling_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, external_signaling_address));
1650  ast_sorcery_object_field_register(sorcery, "transport", "external_signaling_port", "0", OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_transport, external_signaling_port), 0, 65535);
1651  ast_sorcery_object_field_register(sorcery, "transport", "external_media_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, external_media_address));
1652  ast_sorcery_object_field_register(sorcery, "transport", "domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, domain));
1653  ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_server", "", transport_tls_bool_handler, verify_server_to_str, NULL, 0, 0);
1654  ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_client", "", transport_tls_bool_handler, verify_client_to_str, NULL, 0, 0);
1655  ast_sorcery_object_field_register_custom(sorcery, "transport", "require_client_cert", "", transport_tls_bool_handler, require_client_cert_to_str, NULL, 0, 0);
1657 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
1658  ast_sorcery_object_field_register_custom(sorcery, "transport", "cipher", "", transport_tls_cipher_handler, transport_tls_cipher_to_str, NULL, 0, 0);
1659 #endif
1661  ast_sorcery_object_field_register_custom(sorcery, "transport", "tos", "0", transport_tos_handler, tos_to_str, NULL, 0, 0);
1662  ast_sorcery_object_field_register(sorcery, "transport", "cos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, cos));
1663  ast_sorcery_object_field_register(sorcery, "transport", "websocket_write_timeout", AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, OPT_INT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_transport, write_timeout), 1, INT_MAX);
1664  ast_sorcery_object_field_register(sorcery, "transport", "allow_reload", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, allow_reload));
1665  ast_sorcery_object_field_register(sorcery, "transport", "symmetric_transport", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, symmetric_transport));
1666 
1668 
1670  if (!cli_formatter) {
1671  ast_log(LOG_ERROR, "Unable to allocate memory for cli formatter\n");
1672  return -1;
1673  }
1674  cli_formatter->name = "transport";
1681 
1684 
1685  /* trigger load of transports from realtime by trying to revrieve them all */
1687  ao2_cleanup(transports);
1688 
1689  return 0;
1690 }
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
unsigned int cos
Definition: chan_iax2.c:352
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int transport_localnet_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Helper function which turns a cipher name into an identifier.
Definition: res_pjsip_cli.h:52
static int transport_bind_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_bind_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for turning a string bind into a pj_sockaddr.
static int transport_tls_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS method setting.
static int transport_state_init(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for type just makes sure the state is created.
static int cli_print_header(void *obj, void *arg, int flags)
static struct ao2_container * transport_states
Perform no matching, return all objects.
Definition: sorcery.h:123
static int cert_file_to_str(const void *obj, const intptr_t *args, char **buf)
Full structure for sorcery.
Definition: sorcery.c:230
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
Return all matching objects.
Definition: sorcery.h:120
static int localnet_to_vl(const void *obj, struct ast_variable **fields)
#define NULL
Definition: resample.c:96
Domain data structure.
Definition: sip.h:888
static struct ast_str * password
Definition: cdr_mysql.c:77
static int verify_client_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
Apply handler for transports.
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
static int internal_state_hash(const void *obj, const int flags)
hashing function for state objects
#define DEFAULT_STATE_BUCKETS
Default number of state container buckets.
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition: res_pjsip.c:3679
#define ast_log
Definition: astobj2.c:42
#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 FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
static int require_client_cert_to_str(const void *obj, const intptr_t *args, char **buf)
Type for default option handler for unsigned integers.
static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_tls_bool_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS boolean settings.
static void * cli_retrieve_by_id(const char *id)
static void * sip_transport_alloc(const char *name)
Allocator for transport.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
static int ca_list_path_to_str(const void *obj, const intptr_t *args, char **buf)
static int verify_server_to_str(const void *obj, const intptr_t *args, char **buf)
static int cli_iterate(void *container, ao2_callback_fn callback, void *args)
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
Type for default option handler for bools (ast_true/ast_false)
Transport to bind to.
Definition: res_pjsip.h:171
struct ast_sip_endpoint_formatter endpoint_transport_formatter
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
static int transport_tos_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TOS setting.
static int internal_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static struct ao2_container * cli_get_container(const char *regex)
static int localnet_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_protocol_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for turning a string protocol into an enum.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
static int transport_tls_file_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS method setting.
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
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
static int ca_list_file_to_str(const void *obj, const intptr_t *args, char **buf)
static struct ast_sip_cli_formatter_entry * cli_formatter
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR
Default websocket write timeout, in ms (as a string)
Type for default option handler for stringfields.
static int tos_to_str(const void *obj, const intptr_t *args, char **buf)
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
static int privkey_file_to_str(const void *obj, const intptr_t *args, char **buf)
Generic container type.
static int transport_protocol_to_str(const void *obj, const intptr_t *args, char **buf)
static int cli_print_body(void *obj, void *arg, int flags)
Type for default option handler for signed integers.
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
const char * name
Definition: res_pjsip_cli.h:58
static struct ast_cli_entry cli_commands[]

◆ ast_sip_initialize_system()

int ast_sip_initialize_system ( void  )

Definition at line 175 of file config_system.c.

References __stringify, system_config::accept_multiple_sdp_answers, ao2_cleanup, ao2_container_count(), ast_log, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_alloc(), ast_sorcery_apply_default, ast_sorcery_load(), ast_sorcery_object_field_register, ast_sorcery_object_register_no_reload, ast_sorcery_open, ast_sorcery_retrieve_by_fields(), ast_sorcery_unref, system_config::compactheaders, DEFAULT_TIMER_B, DEFAULT_TIMER_T1, system_config::disable_rport, system_config::disable_tcp_switch, FLDSET, system_config::follow_early_media_fork, LOG_ERROR, NULL, OPT_BOOL_T, OPT_NOOP_T, OPT_UINT_T, RAII_VAR, system_alloc(), system_apply(), system_config::threadpool, system_config::timerb, and system_config::timert1.

Referenced by load_module().

176 {
177  RAII_VAR(struct ao2_container *, system_configs, NULL, ao2_cleanup);
178  RAII_VAR(struct system_config *, system, NULL, ao2_cleanup);
179 
181  if (!system_sorcery) {
182  ast_log(LOG_ERROR, "Failed to open SIP system sorcery\n");
183  return -1;
184  }
185 
186  ast_sorcery_apply_default(system_sorcery, "system", "config", "pjsip.conf,criteria=type=system,single_object=yes,explicit_name=system");
187 
189  ast_log(LOG_ERROR, "Failed to register with sorcery (is res_sorcery_config loaded?)\n");
192  return -1;
193  }
194 
195  ast_sorcery_object_field_register(system_sorcery, "system", "type", "", OPT_NOOP_T, 0, 0);
197  OPT_UINT_T, 0, FLDSET(struct system_config, timert1));
199  OPT_UINT_T, 0, FLDSET(struct system_config, timerb));
200  ast_sorcery_object_field_register(system_sorcery, "system", "compact_headers", "no",
201  OPT_BOOL_T, 1, FLDSET(struct system_config, compactheaders));
202  ast_sorcery_object_field_register(system_sorcery, "system", "threadpool_initial_size", "0",
203  OPT_UINT_T, 0, FLDSET(struct system_config, threadpool.initial_size));
204  ast_sorcery_object_field_register(system_sorcery, "system", "threadpool_auto_increment", "5",
205  OPT_UINT_T, 0, FLDSET(struct system_config, threadpool.auto_increment));
206  ast_sorcery_object_field_register(system_sorcery, "system", "threadpool_idle_timeout", "60",
207  OPT_UINT_T, 0, FLDSET(struct system_config, threadpool.idle_timeout));
208  ast_sorcery_object_field_register(system_sorcery, "system", "threadpool_max_size", "50",
209  OPT_UINT_T, 0, FLDSET(struct system_config, threadpool.max_size));
210  ast_sorcery_object_field_register(system_sorcery, "system", "disable_tcp_switch", "yes",
211  OPT_BOOL_T, 1, FLDSET(struct system_config, disable_tcp_switch));
212  ast_sorcery_object_field_register(system_sorcery, "system", "follow_early_media_fork", "yes",
213  OPT_BOOL_T, 1, FLDSET(struct system_config, follow_early_media_fork));
214  ast_sorcery_object_field_register(system_sorcery, "system", "accept_multiple_sdp_answers", "no",
215  OPT_BOOL_T, 1, FLDSET(struct system_config, accept_multiple_sdp_answers));
216  ast_sorcery_object_field_register(system_sorcery, "system", "disable_rport", "no",
217  OPT_BOOL_T, 1, FLDSET(struct system_config, disable_rport));
218 
220 
221  system_configs = ast_sorcery_retrieve_by_fields(system_sorcery, "system",
223 
224  if (ao2_container_count(system_configs)) {
225  return 0;
226  }
227 
228  /* No config present, allocate one and apply defaults */
229  system = ast_sorcery_alloc(system_sorcery, "system", NULL);
230  if (!system) {
231  ast_log(LOG_ERROR, "Unable to allocate default system config.\n");
233  return -1;
234  }
235 
236  if (system_apply(system_sorcery, system)) {
237  ast_log(LOG_ERROR, "Failed to apply default system config.\n");
239  return -1;
240  }
241 
242  return 0;
243 }
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
static void * system_alloc(const char *name)
Definition: config_system.c:77
Type for a default handler that should do nothing.
Return all matching objects.
Definition: sorcery.h:120
#define NULL
Definition: resample.c:96
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1502
#define ast_sorcery_object_register_no_reload(sorcery, type, alloc, transform, apply)
Register an object type that is not reloadable.
Definition: sorcery.h:853
#define ast_log
Definition: astobj2.c:42
#define __stringify(x)
Definition: asterisk.h:214
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
Type for default option handler for unsigned integers.
static int system_apply(const struct ast_sorcery *sorcery, void *obj)
Definition: config_system.c:88
static struct ast_threadpool * threadpool
Thread pool for observers.
Definition: sorcery.c:86
#define LOG_ERROR
Definition: logger.h:285
Type for default option handler for bools (ast_true/ast_false)
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
#define DEFAULT_TIMER_B
Definition: config_system.c:33
static struct ast_sorcery * system_sorcery
Definition: config_system.c:75
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
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
void ast_sorcery_load(const struct ast_sorcery *sorcery)
Inform any wizards to load persistent objects.
Definition: sorcery.c:1377
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define ast_sorcery_open()
Definition: sorcery.h:408
Generic container type.
#define DEFAULT_TIMER_T1
Definition: config_system.c:32

◆ ast_sip_initialize_transport_events()

int ast_sip_initialize_transport_events ( void  )

Definition at line 394 of file pjsip_transport_events.c.

References ACTIVE_TRANSPORTS_BUCKETS, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_global_obj_replace_unref, ao2_ref, ast_sip_get_pjsip_endpoint(), NULL, tpmgr_state_callback, and transport_state_callback().

Referenced by load_module().

395 {
396  pjsip_tpmgr *tpmgr;
397  struct ao2_container *transports;
398 
399  tpmgr = pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint());
400  if (!tpmgr) {
401  return -1;
402  }
403 
405  ACTIVE_TRANSPORTS_BUCKETS, transport_monitor_hash_fn, NULL,
406  transport_monitor_cmp_fn);
407  if (!transports) {
408  return -1;
409  }
410  ao2_global_obj_replace_unref(active_transports, transports);
411  ao2_ref(transports, -1);
412 
413  tpmgr_state_callback = pjsip_tpmgr_get_state_cb(tpmgr);
414  pjsip_tpmgr_set_state_cb(tpmgr, &transport_state_callback);
415 
416  return 0;
417 }
static pjsip_tp_state_callback tpmgr_state_callback
Existing transport events callback that we need to invoke.
#define ACTIVE_TRANSPORTS_BUCKETS
Number of buckets for monitored active transports.
#define NULL
Definition: resample.c:96
static void transport_state_callback(pjsip_transport *transport, pjsip_transport_state state, const pjsip_transport_state_info *info)
Callback invoked when transport state changes occur.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:3718
#define ao2_global_obj_replace_unref(holder, obj)
Definition: astobj2.h:908
Generic container type.

◆ ast_sip_initialize_transport_management()

int ast_sip_initialize_transport_management ( void  )

Definition at line 372 of file pjsip_transport_management.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_global_obj_release, ao2_global_obj_replace_unref, ao2_ref, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sched_context_create(), ast_sched_context_destroy(), ast_sched_start_thread(), ast_sip_get_sorcery(), ast_sip_register_service(), ast_sip_transport_state_register(), ast_sorcery_observer_add(), ast_sorcery_reload_object(), idle_monitor_module, LOG_ERROR, monitored_transport_cmp_fn(), monitored_transport_hash_fn(), NULL, and TRANSPORTS_BUCKETS.

Referenced by load_module().

373 {
374  struct ao2_container *transports;
375 
378  if (!transports) {
379  ast_log(LOG_ERROR, "Could not create container for transports to perform keepalive on.\n");
381  }
382  ao2_global_obj_replace_unref(monitored_transports, transports);
383  ao2_ref(transports, -1);
384 
386  if (!sched) {
387  ast_log(LOG_ERROR, "Failed to create keepalive scheduler context.\n");
388  ao2_global_obj_release(monitored_transports);
390  }
391 
393  ast_log(LOG_ERROR, "Failed to start keepalive scheduler thread\n");
395  sched = NULL;
396  ao2_global_obj_release(monitored_transports);
398  }
399 
401 
403 
406 
408 }
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition: sched.c:195
void ast_sip_transport_state_register(struct ast_sip_tpmgr_state_callback *element)
Register a transport state notification callback element.
Definition: sched.c:76
static pjsip_module idle_monitor_module
#define NULL
Definition: resample.c:96
#define TRANSPORTS_BUCKETS
Number of buckets for monitored transports.
#define ast_log
Definition: astobj2.c:42
static int monitored_transport_cmp_fn(void *obj, void *arg, int flags)
Comparison function for monitored transport.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition: res_pjsip.c:3315
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
Definition: sorcery.c:2386
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:236
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
struct ast_sip_tpmgr_state_callback monitored_transport_reg
#define ao2_global_obj_replace_unref(holder, obj)
Definition: astobj2.h:908
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static int monitored_transport_hash_fn(const void *obj, int flags)
Hashing function for monitored transport.
Generic container type.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:269
void ast_sorcery_reload_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to reload persistent objects.
Definition: sorcery.c:1442
static struct ast_sorcery_observer keepalive_global_observer
Observer which is used to update our interval when the global setting changes.

◆ 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[]

◆ ast_sip_persistent_endpoint_add_to_regcontext()

int ast_sip_persistent_endpoint_add_to_regcontext ( const char *  regcontext)

Definition at line 1312 of file pjsip_configuration.c.

References add_to_regcontext(), ao2_callback, ast_context_find_or_create(), ast_log, ast_strlen_zero, LOG_ERROR, NULL, and OBJ_NODATA.

Referenced by check_regcontext().

1313 {
1314  if (ast_strlen_zero(regcontext)) {
1315  return 0;
1316  }
1317 
1318  /* Make sure the regcontext exists */
1319  if (!ast_context_find_or_create(NULL, NULL, regcontext, "PJSIP")) {
1320  ast_log(LOG_ERROR, "Failed to create regcontext '%s'\n", regcontext);
1321  return -1;
1322  }
1323 
1324  /* Add any online endpoints */
1326  return 0;
1327 }
static int add_to_regcontext(void *obj, void *arg, int flags)
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
static struct ao2_container * persistent_endpoints
Container for persistent endpoint information.
#define LOG_ERROR
Definition: logger.h:285
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:321
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
Definition: pbx.c:6198

◆ ast_sip_validate_uri_length()

int ast_sip_validate_uri_length ( const char *  uri)

Definition at line 525 of file location.c.

References ast_strdupa, ast_strip_quoted(), host, pj_max_hostname, pjsip_max_url_size, and strsep().

Referenced by permanent_uri_handler(), sip_outbound_registration_apply(), and validate_publish_config().

526 {
527  int max_length = pj_max_hostname - 1;
528  char *contact = ast_strdupa(contact_uri);
529  char *host;
530  char *at;
531  int theres_a_port = 0;
532 
533  if (strlen(contact_uri) > pjsip_max_url_size - 1) {
534  return -1;
535  }
536 
537  contact = ast_strip_quoted(contact, "<", ">");
538 
539  if (!strncasecmp(contact, "sip:", 4)) {
540  host = contact + 4;
541  } else if (!strncasecmp(contact, "sips:", 5)) {
542  host = contact + 5;
543  } else {
544  /* Not a SIP URI */
545  return -1;
546  }
547 
548  at = strchr(contact, '@');
549  if (at) {
550  /* sip[s]:[email protected] */
551  host = at + 1;
552  }
553 
554  if (host[0] == '[') {
555  /* Host is an IPv6 address. Just get up to the matching bracket */
556  char *close_bracket;
557 
558  close_bracket = strchr(host, ']');
559  if (!close_bracket) {
560  return -1;
561  }
562  close_bracket++;
563  if (*close_bracket == ':') {
564  theres_a_port = 1;
565  }
566  *close_bracket = '\0';
567  } else {
568  /* uri parameters could contain ';' so trim them off first */
569  host = strsep(&host, ";?");
570  /* Host is FQDN or IPv4 address. Need to find closing delimiter */
571  if (strchr(host, ':')) {
572  theres_a_port = 1;
573  host = strsep(&host, ":");
574  }
575  }
576 
577  if (!theres_a_port) {
578  max_length -= strlen("_sips.tcp.");
579  }
580 
581  if (strlen(host) > max_length) {
582  return -1;
583  }
584 
585  return 0;
586 }
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
Definition: main/utils.c:1639
static char host[256]
Definition: muted.c:77
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
char * strsep(char **str, const char *delims)
static int pjsip_max_url_size
Definition: location.c:37
static int pj_max_hostname
Definition: location.c:36

◆ ast_sip_will_uri_survive_restart()

int ast_sip_will_uri_survive_restart ( pjsip_sip_uri *  uri,
struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata 
)

Definition at line 3723 of file res_pjsip.c.

References ast_sip_endpoint::nat, result, and ast_sip_endpoint_nat_configuration::rewrite_contact.

Referenced by register_aor_core(), and subscription_persistence_update().

3725 {
3726  pj_str_t host_name;
3727  int result = 1;
3728 
3729  /* Determine if the contact cannot survive a restart/boot. */
3730  if (uri->port == rdata->pkt_info.src_port
3731  && !pj_strcmp(&uri->host,
3732  pj_cstr(&host_name, rdata->pkt_info.src_name))
3733  /* We have already checked if the URI scheme is sip: or sips: */
3734  && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
3735  pj_str_t type_name;
3736 
3737  /* Determine the transport parameter value */
3738  if (!strcasecmp("WSS", rdata->tp_info.transport->type_name)) {
3739  /* WSS is special, as it needs to be ws. */
3740  pj_cstr(&type_name, "ws");
3741  } else {
3742  pj_cstr(&type_name, rdata->tp_info.transport->type_name);
3743  }
3744 
3745  if (!pj_stricmp(&uri->transport_param, &type_name)
3746  && (endpoint->nat.rewrite_contact
3747  /* Websockets are always rewritten */
3748  || !pj_stricmp(&uri->transport_param,
3749  pj_cstr(&type_name, "ws")))) {
3750  /*
3751  * The contact was rewritten to the reliable transport's
3752  * source address. Disconnecting the transport for any
3753  * reason invalidates the contact.
3754  */
3755  result = 0;
3756  }
3757  }
3758 
3759  return result;
3760 }
struct ast_sip_endpoint_nat_configuration nat
Definition: res_pjsip.h:845
static PGresult * result
Definition: cel_pgsql.c:88

◆ 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

◆ sip_cli_print_system()

int sip_cli_print_system ( struct ast_sip_cli_context context)

Definition at line 157 of file config_system.c.

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

Referenced by cli_show_settings().

158 {
159  struct system_config *cfg = get_system_cfg();
160 
161  if (!cfg) {
162  cfg = ast_sorcery_alloc(system_sorcery, "system", NULL);
163  if (!cfg) {
164  return -1;
165  }
166  }
167 
168  ast_str_append(&context->output_buffer, 0, "\nSystem Settings:\n\n");
169  ast_sip_cli_print_sorcery_objectset(cfg, context, 0);
170 
171  ao2_ref(cfg, -1);
172  return 0;
173 }
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
static struct ast_sorcery * system_sorcery
Definition: config_system.c:75
static struct system_config * get_system_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

◆ sip_get_threadpool_options()

void sip_get_threadpool_options ( struct ast_threadpool_options threadpool_options)

Definition at line 70 of file config_system.c.

References sip_threadpool_options.

Referenced by load_module().

71 {
72  *threadpool_options = sip_threadpool_options;
73 }
static struct ast_threadpool_options sip_threadpool_options
Definition: config_system.c:66