55 if (!strcasecmp(var->
value,
"userpass")) {
57 }
else if (!strcasecmp(var->
value,
"md5")) {
59 }
else if (!strcasecmp(var->
value,
"google_oauth")) {
60 #ifdef HAVE_PJSIP_OAUTH_AUTHENTICATION 63 ast_log(
LOG_WARNING,
"OAuth support is not available in the version of PJSIP in use\n");
104 switch (auth->
type) {
110 }
else if (strlen(auth->
md5_creds) != PJSIP_MD5STRLEN) {
111 ast_log(
LOG_ERROR,
"'md5' authentication requires digest of size '%d', but " 112 "digest is '%d' in size for auth '%s'\n", PJSIP_MD5STRLEN, (
int)strlen(auth->
md5_creds),
121 ast_log(
LOG_ERROR,
"'google_oauth' authentication specified but refresh_token," 122 " oauth_clientid, or oauth_secret not specified for auth '%s'\n",
154 if (on_auth(auth, arg, 0)) {
204 ami->
arg = (
void *)endpoint;
320 "%*s: <AuthId/UserName%*.*s>\n", indent,
"I/OAuth", filler, filler,
334 snprintf(title,
sizeof(title),
"%sAuth",
353 .
usage =
"Usage: pjsip list auths [ like <pattern> ]\n" 354 " List the configured PJSIP Auths\n" 355 " Optional regular expression pattern is used to filter the list.\n"),
358 .
usage =
"Usage: pjsip show auths [ like <pattern> ]\n" 359 " Show the configured PJSIP Auths\n" 360 " Optional regular expression pattern is used to filter the list.\n"),
363 .
usage =
"Usage: pjsip show auth <id>\n" 364 " Show the configured PJSIP Auth\n"),
404 if (!cli_formatter) {
408 cli_formatter->
name = SIP_SORCERY_AUTH_TYPE;
struct ast_str * output_buffer
struct ao2_container *(* get_container)(const char *regex)
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
#define AST_CLI_DEFINE(fn, txt,...)
static int auth_type_to_str(const void *obj, const intptr_t *args, char **buf)
void astman_append(struct mansession *s, const char *fmt,...)
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
const ast_string_field oauth_secret
static int cli_iterator(void *container, ao2_callback_fn callback, void *args)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
const ast_string_field md5_creds
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ao2_callback(c, flags, cb_fn, arg)
const char * ast_sip_auth_type_to_str(enum ast_sip_auth_type type)
Converts the given auth type to a string.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Structure for variables, used for configurations and for channel variables.
struct ast_sip_auth_vector outbound_auths
static int auth_type_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Perform no matching, return all objects.
int ast_sorcery_object_id_compare(void *obj, void *arg, int flags)
ao2 object comparator based on sorcery id.
Full structure for sorcery.
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Type for a default handler that should do nothing.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Return all matching objects.
static int format_ami_authlist_handler(void *obj, void *arg, int flags)
#define ast_strdup(str)
A wrapper for strdup()
static struct ao2_container * cli_get_container(const char *regex)
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
static const char * auth_types_map[]
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
const ast_string_field oauth_clientid
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
static void * cli_retrieve_by_id(const char *id)
static int format_ami_auth_handler(void *obj, void *arg, int flags)
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
#define EVENT_FLAG_SYSTEM
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
#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.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
int ast_sip_format_auths_ami(const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami)
Format auth details for AMI.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Type for default option handler for unsigned integers.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define CLI_INDENT_TO_SPACES(x)
#define ao2_ref(o, delta)
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
int ast_sip_destroy_sorcery_auth(void)
int ast_sorcery_object_id_sort(const void *obj, const void *arg, int flags)
ao2 object sorter based on sorcery id.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
void *(* retrieve_by_id)(const char *id)
struct ao2_container * container
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
An entity with which Asterisk communicates.
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
static int cli_print_header(void *obj, void *arg, int flags)
static void * auth_alloc(const char *name)
static struct ast_sip_endpoint_formatter endpoint_auth_formatter
static struct ao2_container * cli_get_auths(void)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
#define CLI_HEADER_FILLER
struct ast_sip_auth_vector inbound_auths
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy all object references in the src container into the dest container.
#define ast_sorcery_apply_default(sorcery, type, name, data)
#define ao2_alloc(data_size, destructor_fn)
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
enum ast_sip_auth_type type
static struct ast_sip_cli_formatter_entry * cli_formatter
const char *(* get_id)(const void *obj)
int ast_sip_initialize_sorcery_auth(void)
Initialize sorcery with auth support.
const ast_string_field refresh_token
struct ast_str * ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
Creates a string to store AMI event data in.
Support for logging to various files, console and syslog Configuration in file logger.conf.
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.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
static struct ast_cli_entry cli_commands[]
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Standard Command Line Interface.
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.
static int ami_show_auths(struct mansession *s, const struct message *m)
int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
Converts a sorcery object to a string of object properties.
static int format_ami_endpoint_auth(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)
Type for default option handler for stringfields.
ao2_callback_fn * print_header
static char context[AST_MAX_CONTEXT]
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
ast_sip_auth_type
Methods of storing SIP digest authentication credentials.
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
ao2_callback_fn * print_body
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
static int sip_auth_to_ami(const struct ast_sip_auth *auth, struct ast_str **buf)
const ast_string_field auth_user
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
static void auth_destroy(void *obj)
static int cli_print_body(void *obj, void *arg, int flags)
static int auth_apply(const struct ast_sorcery *sorcery, void *obj)
Sorcery Data Access Layer API.
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
unsigned show_details_only_level_0