Asterisk - The Open Source Telephony Project GIT-master-8f1982c
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjlib.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/logger.h"
#include "asterisk/sorcery.h"
#include "asterisk/cli.h"
#include "asterisk/vector.h"
#include "include/res_pjsip_private.h"
#include "asterisk/res_pjsip_cli.h"
Go to the source code of this file.
Macros | |
#define | MD5_DIGEST_LENGTH 16 |
#define | SHA256_DIGEST_LENGTH 32 |
Functions | |
static int | ami_show_auths (struct mansession *s, const struct message *m) |
int | ast_sip_auth_digest_algorithms_vector_init (const char *id, struct pjsip_auth_algorithm_type_vector *algorithms, const char *agent_type, const char *value) |
Populate a vector of algorithm types from a string. More... | |
int | ast_sip_auth_digest_algorithms_vector_to_str (const struct pjsip_auth_algorithm_type_vector *algorithms, char **buf) |
Dump a vector of algorithm types to a string. More... | |
const pjsip_auth_algorithm * | ast_sip_auth_get_algorithm_by_iana_name (const pj_str_t *iana_name) |
Get algorithm by IANA name. More... | |
const pjsip_auth_algorithm * | ast_sip_auth_get_algorithm_by_type (pjsip_auth_algorithm_type algorithm_type) |
Get algorithm by algorithm type. More... | |
const char * | ast_sip_auth_get_creds (const struct ast_sip_auth *auth, const pjsip_auth_algorithm_type algorithm_type, int *cred_type) |
Get the plain text or digest password from an auth object. More... | |
int | ast_sip_auth_is_algorithm_available (const struct ast_sip_auth *auth, const struct pjsip_auth_algorithm_type_vector *algorithms, pjsip_auth_algorithm_type algorithm_type) |
Checks an pjsip_auth_algorithm_type_vector to see if it contains an algorithm. More... | |
pj_bool_t | ast_sip_auth_is_algorithm_supported (pjsip_auth_algorithm_type algorithm_type) |
Is algorithm supported by OpenSSL and pjproject? More... | |
const char * | ast_sip_auth_type_to_str (enum ast_sip_auth_type type) |
Converts the given auth type to a string. More... | |
int | ast_sip_destroy_sorcery_auth (void) |
int | ast_sip_for_each_auth (const struct ast_sip_auth_vector *vector, ao2_callback_fn on_auth, void *arg) |
For every auth in the array call the given 'on_auth' handler. More... | |
int | ast_sip_format_auths_ami (const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami) |
Format auth details for AMI. More... | |
int | ast_sip_initialize_sorcery_auth (void) |
Initialize sorcery with auth support. More... | |
static void * | auth_alloc (const char *name) |
static int | auth_apply (const struct ast_sorcery *sorcery, void *obj) |
static void | auth_destroy (void *obj) |
static int | auth_type_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | auth_type_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | check_algorithm (const struct ast_sip_auth *auth, const pjsip_auth_algorithm_type algorithm_type, const char *which_supported) |
static struct ao2_container * | cli_get_auths (void) |
static struct ao2_container * | cli_get_container (const char *regex) |
static int | cli_iterator (void *container, ao2_callback_fn callback, void *args) |
static int | cli_print_body (void *obj, void *arg, int flags) |
static int | cli_print_header (void *obj, void *arg, int flags) |
static void * | cli_retrieve_by_id (const char *id) |
static int | format_ami_auth_handler (void *obj, void *arg, int flags) |
static int | format_ami_authlist_handler (void *obj, void *arg, int flags) |
static int | format_ami_endpoint_auth (const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami) |
static void | global_loaded (const char *object_type) |
static int | md5cred_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | password_digest_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | password_digest_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | sip_auth_to_ami (const struct ast_sip_auth *auth, struct ast_str **buf) |
static int | uac_algorithms_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | uac_algorithms_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | uas_algorithms_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | uas_algorithms_to_str (const void *obj, const intptr_t *args, char **buf) |
Variables | |
static const char * | auth_types_map [] |
static struct ast_cli_entry | cli_commands [] |
static struct ast_sip_cli_formatter_entry * | cli_formatter |
static struct ast_sip_endpoint_formatter | endpoint_auth_formatter |
static struct ast_sorcery_observer | global_observer |
Observer which is used to update our interval and default_realm when the global setting changes. More... | |
const pjsip_auth_algorithm | pjsip_auth_algorithms [] |
#define MD5_DIGEST_LENGTH 16 |
Definition at line 42 of file config_auth.c.
#define SHA256_DIGEST_LENGTH 32 |
Definition at line 43 of file config_auth.c.
|
static |
Definition at line 596 of file config_auth.c.
References ao2_callback, ao2_container_count(), ao2_ref, astman_get_header(), astman_send_error(), astman_send_list_complete_end(), astman_send_list_complete_start(), astman_send_listack(), cli_get_auths(), ast_sip_ami::count, format_ami_authlist_handler(), ast_sip_ami::m, OBJ_NODATA, and ast_sip_ami::s.
Referenced by ast_sip_initialize_sorcery_auth().
int ast_sip_auth_digest_algorithms_vector_init | ( | const char * | id, |
struct pjsip_auth_algorithm_type_vector * | algorithms, | ||
const char * | agent_type, | ||
const char * | value | ||
) |
Populate a vector of algorithm types from a string.
id | The object id to use in error messages |
algorithms | The initialized but empty vector to populate |
agent_type | The type of agent to use in error messages ("UAC" or "UAS") |
value | The comma-separated string to parse for algorithms |
0 | Success |
non-zero | Failure |
Definition at line 192 of file config_auth.c.
References agent_type, pjsip_auth_algorithm::algorithm_type, ast_assert, ast_log, ast_sip_auth_get_algorithm_by_iana_name(), ast_sip_auth_is_algorithm_supported(), ast_strdupa, ast_strip(), ast_strlen_zero(), AST_VECTOR_APPEND, AST_VECTOR_FREE, LOG_WARNING, NULL, strsep(), and value.
Referenced by alloc_artificial_auth(), auth_apply(), global_apply(), uac_algorithms_handler(), and uas_algorithms_handler().
int ast_sip_auth_digest_algorithms_vector_to_str | ( | const struct pjsip_auth_algorithm_type_vector * | algorithms, |
char ** | buf | ||
) |
Dump a vector of algorithm types to a string.
algorithms | The vector to dump | |
[out] | buf | Pointer to the buffer to dump the algorithms to Must be freed by the caller. |
0 | Success |
non-zero | Failure |
Definition at line 248 of file config_auth.c.
References ast_sip_auth_get_algorithm_by_type(), ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_strdup, AST_VECTOR_GET, AST_VECTOR_SIZE, buf, pjsip_auth_algorithm::iana_name, NULL, PJSTR_PRINTF_SPEC, PJSTR_PRINTF_VAR, and str.
Referenced by uac_algorithms_to_str(), and uas_algorithms_to_str().
const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_iana_name | ( | const pj_str_t * | iana_name | ) |
Get algorithm by IANA name.
iana_name | The algorithm IANA name |
The | algorithm or NULL if not found |
Definition at line 83 of file config_auth.c.
References NULL, PJSIP_AUTH_ALGORITHM_MD5, and pjsip_auth_algorithms.
Referenced by ast_sip_auth_digest_algorithms_vector_init(), digest_lookup(), get_supported_algorithm(), and password_digest_handler().
const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_type | ( | pjsip_auth_algorithm_type | algorithm_type | ) |
Get algorithm by algorithm type.
algorithm_type | The algorithm type |
The | algorithm or NULL if not found |
Definition at line 66 of file config_auth.c.
References NULL, PJSIP_AUTH_ALGORITHM_MD5, and pjsip_auth_algorithms.
Referenced by ast_sip_auth_digest_algorithms_vector_to_str(), check_algorithm(), digest_check_auth(), and password_digest_to_str().
const char * ast_sip_auth_get_creds | ( | const struct ast_sip_auth * | auth, |
const pjsip_auth_algorithm_type | algorithm_type, | ||
int * | cred_type | ||
) |
Get the plain text or digest password from an auth object.
auth | The auth object |
algorithm_type | The algorithm type to retrieve the password for |
cred_type | [out]Pointer to an int to receive the credential type |
If a password digest is available for the algorithm type it will be returned, otherwise if a plain text password is available that will be returned instead.
The | plain text or digest password or NULL if not found for the algorithm type |
Definition at line 407 of file config_auth.c.
References ast_sip_auth_password_digest::algorithm_type, ast_sip_auth::auth_pass, ast_sip_auth_password_digest::digest, and ast_sip_auth::password_digests.
Referenced by digest_lookup(), and get_creds_for_header().
int ast_sip_auth_is_algorithm_available | ( | const struct ast_sip_auth * | auth, |
const struct pjsip_auth_algorithm_type_vector * | algorithms, | ||
pjsip_auth_algorithm_type | algorithm_type | ||
) |
Checks an pjsip_auth_algorithm_type_vector to see if it contains an algorithm.
auth | The auth object |
algorithms | The auth object's supported_algorithms_uac or supported_algorithms_uas |
algorithm_type | The algorithm_type to check |
1 | The algorithm-type is in the vector |
0 | The algorithm-type is not in the vector |
Definition at line 386 of file config_auth.c.
References ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sip_auth::auth_pass, and ast_sip_auth::password_digests.
Referenced by digest_lookup(), and get_creds_for_header().
pj_bool_t ast_sip_auth_is_algorithm_supported | ( | pjsip_auth_algorithm_type | algorithm_type | ) |
Is algorithm supported by OpenSSL and pjproject?
algorithm_type | The algorithm IANA name |
The | algorithm or NULL if not found |
Definition at line 104 of file config_auth.c.
References PJSIP_AUTH_ALGORITHM_MD5.
Referenced by ast_sip_auth_digest_algorithms_vector_init(), get_supported_algorithm(), and password_digest_handler().
const char * ast_sip_auth_type_to_str | ( | enum ast_sip_auth_type | type | ) |
Converts the given auth type to a string.
type | the auth type to convert |
a | string representative of the auth type |
Definition at line 179 of file config_auth.c.
References ARRAY_IN_BOUNDS, auth_types_map, and type.
Referenced by auth_type_to_str().
int ast_sip_destroy_sorcery_auth | ( | void | ) |
Definition at line 792 of file config_auth.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(), ast_sorcery_observer_remove(), cli_commands, cli_formatter, endpoint_auth_formatter, and global_observer.
Referenced by ast_res_pjsip_destroy_configuration().
int ast_sip_for_each_auth | ( | const struct ast_sip_auth_vector * | array, |
ao2_callback_fn | on_auth, | ||
void * | arg | ||
) |
For every auth in the array call the given 'on_auth' handler.
array | an array of auths |
on_auth | callback for each auth |
arg | user data passed to handler |
0 | Success, non-zero on failure |
Definition at line 484 of file config_auth.c.
References ao2_cleanup, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), AST_VECTOR_GET, AST_VECTOR_SIZE, RAII_VAR, and SIP_SORCERY_AUTH_TYPE.
Referenced by ast_sip_format_auths_ami(), and cli_iterator().
int ast_sip_format_auths_ami | ( | const struct ast_sip_auth_vector * | auths, |
struct ast_sip_ami * | ami | ||
) |
Format auth details for AMI.
auths | an auth array |
ami | ami variable container |
0 | Success, non-zero on failure |
Definition at line 544 of file config_auth.c.
References ast_sip_for_each_auth(), and format_ami_auth_handler().
Referenced by ami_outbound_registration_task(), and format_ami_endpoint_auth().
int ast_sip_initialize_sorcery_auth | ( | void | ) |
Initialize sorcery with auth support.
Definition at line 729 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, ast_sorcery_observer_add(), auth_alloc(), auth_apply(), auth_type_handler(), auth_type_to_str(), cli_commands, cli_formatter, cli_get_container(), cli_iterator(), cli_print_body(), cli_print_header(), cli_retrieve_by_id(), endpoint_auth_formatter, EVENT_FLAG_SYSTEM, FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, global_observer, ast_sip_cli_formatter_entry::iterate, LOG_ERROR, md5cred_to_str(), ast_sip_cli_formatter_entry::name, NULL, OPT_NOOP_T, OPT_STRINGFIELD_T, OPT_UINT_T, password_digest_handler(), password_digest_to_str(), ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, ast_sip_cli_formatter_entry::retrieve_by_id, SIP_SORCERY_AUTH_TYPE, sorcery, STRFLDSET, uac_algorithms_handler(), uac_algorithms_to_str(), uas_algorithms_handler(), and uas_algorithms_to_str().
Referenced by ast_res_pjsip_initialize_configuration().
|
static |
Definition at line 129 of file config_auth.c.
References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, AST_VECTOR_INIT, auth_destroy(), NULL, ast_sip_auth::supported_algorithms_uac, and ast_sip_auth::supported_algorithms_uas.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 439 of file config_auth.c.
References ast_alloca, ast_log, ast_sip_auth_digest_algorithms_vector_init(), AST_SIP_AUTH_MAX_SUPPORTED_ALGORITHMS_LENGTH, AST_SIP_AUTH_TYPE_GOOGLE_OAUTH, ast_sip_get_default_auth_algorithms_uac(), ast_sip_get_default_auth_algorithms_uas(), ast_sorcery_object_get_id(), ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sip_auth::auth_user, check_algorithm(), LOG_ERROR, ast_sip_auth::oauth_clientid, ast_sip_auth::oauth_secret, ast_sip_auth::refresh_token, ast_sip_auth::supported_algorithms_uac, ast_sip_auth::supported_algorithms_uas, and ast_sip_auth::type.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 114 of file config_auth.c.
References ast_free, ast_string_field_free_memory, AST_VECTOR_FREE, ast_sip_auth::password_digests, PJSIP_AUTH_ALGORITHM_COUNT, PJSIP_AUTH_ALGORITHM_NOT_SET, ast_sip_auth::supported_algorithms_uac, and ast_sip_auth::supported_algorithms_uas.
Referenced by auth_alloc().
|
static |
Definition at line 148 of file config_auth.c.
References ast_log, AST_SIP_AUTH_TYPE_DIGEST, AST_SIP_AUTH_TYPE_GOOGLE_OAUTH, AST_SIP_AUTH_TYPE_MD5, AST_SIP_AUTH_TYPE_USER_PASS, LOG_WARNING, ast_sip_auth::type, and var.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 185 of file config_auth.c.
References ast_sip_auth_type_to_str(), ast_strdup, buf, and ast_sip_auth::type.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 422 of file config_auth.c.
References ast_sip_auth_password_digest::algorithm_type, ast_log, ast_sip_auth_get_algorithm_by_type(), ast_sorcery_object_get_id(), ast_strlen_zero(), ast_sip_auth::auth_pass, pjsip_auth_algorithm::iana_name, LOG_ERROR, ast_sip_auth::password_digests, PJSTR_PRINTF_SPEC, and PJSTR_PRINTF_VAR.
Referenced by auth_apply().
|
static |
Definition at line 565 of file config_auth.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_fields(), and NULL.
Referenced by ami_show_auths().
|
static |
Definition at line 626 of file config_auth.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_list, ao2_container_dup(), ao2_ref, ast_sip_get_sorcery(), ast_sorcery_object_id_compare(), ast_sorcery_object_id_sort(), ast_sorcery_retrieve_by_regex(), container, NULL, RAII_VAR, and regex().
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 650 of file config_auth.c.
References args, ast_sip_for_each_auth(), callback(), and container.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 675 of file config_auth.c.
References ast_assert, ast_sip_cli_print_sorcery_objectset(), ast_sorcery_object_get_id(), ast_str_append(), ast_sip_auth::auth_user, CLI_INDENT_TO_SPACES, voicemailpwcheck::context, and NULL.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 660 of file config_auth.c.
References ast_assert, ast_str_append(), CLI_HEADER_FILLER, CLI_INDENT_TO_SPACES, CLI_MAX_WIDTH, voicemailpwcheck::context, and NULL.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 655 of file config_auth.c.
References ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), and SIP_SORCERY_AUTH_TYPE.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 517 of file config_auth.c.
References ast_sip_ami::arg, ast_free, ast_sip_create_ami_event(), ast_sorcery_object_get_id(), ast_str_append(), ast_str_buffer(), astman_append(), buf, ast_sip_ami::count, RAII_VAR, ast_sip_ami::s, and sip_auth_to_ami().
Referenced by ast_sip_format_auths_ami().
|
static |
Definition at line 575 of file config_auth.c.
References ast_sip_ami::arg, ast_free, ast_sip_create_ami_event(), ast_str_buffer(), astman_append(), buf, CMP_STOP, ast_sip_ami::count, ast_sip_ami::s, and sip_auth_to_ami().
Referenced by ami_show_auths().
|
static |
Definition at line 550 of file config_auth.c.
References ast_sip_ami::arg, ast_sip_format_auths_ami(), ast_sip_endpoint::inbound_auths, and ast_sip_endpoint::outbound_auths.
|
static |
Definition at line 718 of file config_auth.c.
References ast_sip_get_sorcery(), and ast_sorcery_force_reload_object().
|
static |
Definition at line 375 of file config_auth.c.
References ast_strdup, buf, ast_sip_auth_password_digest::digest, ast_sip_auth::password_digests, and PJSIP_AUTH_ALGORITHM_MD5.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 287 of file config_auth.c.
References pjsip_auth_algorithm::algorithm_type, ast_sip_auth_password_digest::algorithm_type, ast_calloc, ast_log, ast_sip_auth_get_algorithm_by_iana_name(), ast_sip_auth_is_algorithm_supported(), ast_sorcery_object_get_id(), ast_strdupa, ast_strlen_zero(), ast_strsep(), AST_STRSEP_TRIM, ast_sip_auth_password_digest::digest, pjsip_auth_algorithm::digest_str_length, LOG_WARNING, NULL, ast_sip_auth::password_digests, value, and var.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 347 of file config_auth.c.
References ast_sip_auth_password_digest::algorithm_type, ast_sip_auth_get_algorithm_by_type(), ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_strdup, buf, ast_sip_auth_password_digest::digest, pjsip_auth_algorithm::iana_name, ast_sip_auth::password_digests, PJSIP_AUTH_ALGORITHM_COUNT, PJSIP_AUTH_ALGORITHM_NOT_SET, PJSTR_PRINTF_SPEC, PJSTR_PRINTF_VAR, and str.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 511 of file config_auth.c.
References ast_sip_sorcery_object_to_ami(), and buf.
Referenced by format_ami_auth_handler(), and format_ami_authlist_handler().
|
static |
Definition at line 232 of file config_auth.c.
References ast_sip_auth_digest_algorithms_vector_init(), ast_sorcery_object_get_id(), ast_sip_auth::supported_algorithms_uac, and var.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 275 of file config_auth.c.
References ast_sip_auth_digest_algorithms_vector_to_str(), buf, and ast_sip_auth::supported_algorithms_uac.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 240 of file config_auth.c.
References ast_sip_auth_digest_algorithms_vector_init(), ast_sorcery_object_get_id(), ast_sip_auth::supported_algorithms_uas, and var.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 281 of file config_auth.c.
References ast_sip_auth_digest_algorithms_vector_to_str(), buf, and ast_sip_auth::supported_algorithms_uas.
Referenced by ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 172 of file config_auth.c.
Referenced by ast_sip_auth_type_to_str().
|
static |
Definition at line 699 of file config_auth.c.
Referenced by ast_sip_destroy_sorcery_auth(), and ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 716 of file config_auth.c.
Referenced by ast_sip_destroy_sorcery_auth(), and ast_sip_initialize_sorcery_auth().
|
static |
Definition at line 561 of file config_auth.c.
Referenced by ast_sip_destroy_sorcery_auth(), and ast_sip_initialize_sorcery_auth().
|
static |
Observer which is used to update our interval and default_realm when the global setting changes.
Definition at line 724 of file config_auth.c.
Referenced by ast_sip_destroy_sorcery_auth(), and ast_sip_initialize_sorcery_auth().
const pjsip_auth_algorithm pjsip_auth_algorithms[] |
Definition at line 46 of file config_auth.c.
Referenced by ast_sip_auth_get_algorithm_by_iana_name(), and ast_sip_auth_get_algorithm_by_type().