#include "asterisk.h"
#include <pjsip.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/module.h"
Go to the source code of this file.
|
static void | __reg_module (void) |
|
static void | __unreg_module (void) |
|
struct ast_module * | AST_MODULE_SELF_SYM (void) |
|
static struct ast_sip_endpoint * | auth_username_identify (pjsip_rx_data *rdata) |
|
static struct ast_sip_endpoint * | find_endpoint (pjsip_rx_data *rdata, char *endpoint_name, char *domain_name) |
|
static int | find_transport_state_in_use (void *obj, void *arg, int flags) |
|
static pjsip_authorization_hdr * | get_auth_header (pjsip_rx_data *rdata, char *username, size_t username_size, char *realm, size_t realm_size, pjsip_authorization_hdr *start) |
|
static int | get_from_header (pjsip_rx_data *rdata, char *username, size_t username_size, char *domain, size_t domain_size) |
|
static int | load_module (void) |
|
static int | unload_module (void) |
|
static struct ast_sip_endpoint * | username_identify (pjsip_rx_data *rdata) |
|
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP username endpoint identifier" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 4, .requires = "res_pjsip", } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
static struct ast_sip_endpoint_identifier | auth_username_identifier |
|
static struct ast_sip_endpoint_identifier | username_identifier |
|
◆ DOMAIN_NAME_LEN
#define DOMAIN_NAME_LEN 255 |
◆ USERNAME_LEN
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ AST_MODULE_SELF_SYM()
◆ auth_username_identify()
Definition at line 165 of file res_pjsip_endpoint_identifier_user.c.
References ao2_cleanup, ast_debug, AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME, DOMAIN_NAME_LEN, find_endpoint(), get_auth_header(), ast_sip_endpoint::ident_method, NULL, and USERNAME_LEN.
169 pjsip_authorization_hdr *auth_header =
NULL;
171 while ((auth_header =
get_auth_header(rdata, username,
sizeof(username), realm,
sizeof(realm),
172 auth_header ? auth_header->next :
NULL))) {
173 ast_debug(3,
"Attempting identify by Authorization username '%s' realm '%s'\n", username,
178 ast_debug(3,
"Endpoint not found for Authentication username '%s' realm '%s'\n",
184 ast_debug(3,
"Endpoint found for '%s' but 'auth_username' method not supported'\n",
189 ast_debug(3,
"Identified by Authorization username '%s' realm '%s'\n", username, realm);
static struct ast_sip_endpoint * find_endpoint(pjsip_rx_data *rdata, char *endpoint_name, char *domain_name)
enum ast_sip_endpoint_identifier_type ident_method
#define ast_debug(level,...)
Log a DEBUG message.
An entity with which Asterisk communicates.
static pjsip_authorization_hdr * get_auth_header(pjsip_rx_data *rdata, char *username, size_t username_size, char *realm, size_t realm_size, pjsip_authorization_hdr *start)
◆ find_endpoint()
static struct ast_sip_endpoint* find_endpoint |
( |
pjsip_rx_data * |
rdata, |
|
|
char * |
endpoint_name, |
|
|
char * |
domain_name |
|
) |
| |
|
static |
Definition at line 81 of file res_pjsip_endpoint_identifier_user.c.
References ao2_callback, ao2_cleanup, ao2_ref, ast_sip_get_disable_multi_domain(), ast_sip_get_sorcery(), ast_sip_get_transport_states(), ast_sorcery_retrieve_by_id(), ast_strlen_zero, ast_sip_transport::domain, ast_sip_domain_alias::domain, DOMAIN_NAME_LEN, find_transport_state_in_use(), ast_sip_transport_state::id, NULL, transport_states, and USERNAME_LEN.
Referenced by auth_username_identify(), and username_identify().
94 snprintf(
id,
sizeof(
id),
"%s@%s", endpoint_name, domain_name);
104 snprintf(
id,
sizeof(
id),
"%s@%s", endpoint_name, alias->
domain);
117 snprintf(
id,
sizeof(
id),
"%s@%s", endpoint_name, transport->
domain);
#define ao2_callback(c, flags, cb_fn, arg)
static struct ao2_container * transport_states
static int find_transport_state_in_use(void *obj, void *arg, int flags)
#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.
Structure for SIP transport information.
#define ao2_ref(o, delta)
unsigned int ast_sip_get_disable_multi_domain(void)
Retrieve the system setting 'disable multi domain'.
An entity with which Asterisk communicates.
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
const ast_string_field domain
const ast_string_field domain
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
◆ find_transport_state_in_use()
static int find_transport_state_in_use |
( |
void * |
obj, |
|
|
void * |
arg, |
|
|
int |
flags |
|
) |
| |
|
static |
◆ get_auth_header()
static pjsip_authorization_hdr* get_auth_header |
( |
pjsip_rx_data * |
rdata, |
|
|
char * |
username, |
|
|
size_t |
username_size, |
|
|
char * |
realm, |
|
|
size_t |
realm_size, |
|
|
pjsip_authorization_hdr * |
start |
|
) |
| |
|
static |
Definition at line 46 of file res_pjsip_endpoint_identifier_user.c.
References ast_copy_pj_str(), and NULL.
Referenced by auth_username_identify().
49 pjsip_authorization_hdr *
header;
51 header = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_AUTHORIZATION, start);
53 if (!header || pj_stricmp2(&header->scheme,
"digest")) {
57 ast_copy_pj_str(username, &header->credential.digest.username, username_size);
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
◆ get_from_header()
static int get_from_header |
( |
pjsip_rx_data * |
rdata, |
|
|
char * |
username, |
|
|
size_t |
username_size, |
|
|
char * |
domain, |
|
|
size_t |
domain_size |
|
) |
| |
|
static |
Definition at line 32 of file res_pjsip_endpoint_identifier_user.c.
References ast_copy_pj_str().
Referenced by username_identify().
34 pjsip_uri *from = rdata->msg_info.from->uri;
35 pjsip_sip_uri *sip_from;
37 if (!PJSIP_URI_SCHEME_IS_SIP(from) && !PJSIP_URI_SCHEME_IS_SIPS(from)) {
40 sip_from = (pjsip_sip_uri *) pjsip_uri_get_uri(from);
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ username_identify()
Definition at line 132 of file res_pjsip_endpoint_identifier_user.c.
References ao2_cleanup, ast_debug, AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME, AST_SIP_USER_OPTIONS_TRUNCATE_CHECK, DOMAIN_NAME_LEN, find_endpoint(), get_from_header(), ast_sip_endpoint::ident_method, NULL, and USERNAME_LEN.
138 if (
get_from_header(rdata, username,
sizeof(username), domain,
sizeof(domain))) {
148 ast_debug(3,
"Attempting identify by From username '%s' domain '%s'\n", username, domain);
152 ast_debug(3,
"Endpoint not found for From username '%s' domain '%s'\n", username, domain);
156 ast_debug(3,
"Endpoint found for '%s' but 'username' method not supported'\n", username);
160 ast_debug(3,
"Identified by From username '%s' domain '%s'\n", username, domain);
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
Truncate the URI user field options string if enabled.
static int get_from_header(pjsip_rx_data *rdata, char *username, size_t username_size, char *domain, size_t domain_size)
static struct ast_sip_endpoint * find_endpoint(pjsip_rx_data *rdata, char *endpoint_name, char *domain_name)
enum ast_sip_endpoint_identifier_type ident_method
#define ast_debug(level,...)
Log a DEBUG message.
An entity with which Asterisk communicates.
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP username endpoint identifier" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 4, .requires = "res_pjsip", } |
|
static |
◆ ast_module_info
◆ auth_username_identifier
◆ username_identifier