32static int get_from_header(pjsip_rx_data *rdata,
char *username,
size_t username_size,
char *domain,
size_t domain_size)
34 pjsip_uri *from = rdata->msg_info.from->uri;
46static pjsip_authorization_hdr *
get_auth_header(pjsip_rx_data *rdata,
char *username,
47 size_t username_size,
char *realm,
size_t realm_size, pjsip_authorization_hdr *start)
49 pjsip_authorization_hdr *
header;
51 header = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_AUTHORIZATION, start);
66 pjsip_rx_data *rdata = arg;
68 if (transport_state->
transport == rdata->tp_info.transport
70 && !pj_strcmp(&transport_state->
factory->addr_name.host, &rdata->tp_info.transport->local_name.host)
71 && transport_state->
factory->addr_name.port == rdata->tp_info.transport->local_name.port)) {
78#define DOMAIN_NAME_LEN 255
79#define USERNAME_LEN 255
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);
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);
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);
226 .
requires =
"res_pjsip",
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
static struct ao2_container * transport_states
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
const pj_str_t * ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
Get the user portion of the pjsip_uri.
@ AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME
@ AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
Truncate the URI user field options string if enabled.
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Unregister a SIP endpoint identifier.
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.
unsigned int ast_sip_get_disable_multi_domain(void)
Retrieve the system setting 'disable multi domain'.
#define AST_SIP_AUTH_MAX_REALM_LENGTH
int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_identifier *identifier, const char *name)
Register a SIP endpoint identifier with a name.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
const pj_str_t * ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri)
Get the host portion of the pjsip_uri.
static struct ast_sip_endpoint * 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 get_from_header(pjsip_rx_data *rdata, char *username, size_t username_size, char *domain, size_t domain_size)
static struct ast_sip_endpoint * auth_username_identify(pjsip_rx_data *rdata)
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 struct ast_sip_endpoint_identifier username_identifier
static int load_module(void)
static int find_transport_state_in_use(void *obj, void *arg, int flags)
static int unload_module(void)
static struct ast_sip_endpoint_identifier auth_username_identifier
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
const ast_string_field domain
An entity responsible for identifying the source of a SIP message.
struct ast_sip_endpoint *(* identify_endpoint)(pjsip_rx_data *rdata)
Callback used to identify the source of a message. See ast_sip_identify_endpoint for more details.
An entity with which Asterisk communicates.
enum ast_sip_endpoint_identifier_type ident_method
Structure for SIP transport information.
struct pjsip_tpfactory * factory
Transport factory.
struct pjsip_transport * transport
Transport itself.
const ast_string_field domain