32 static 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;
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);
46 static 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);
53 if (!header || pj_stricmp2(&header->scheme,
"digest")) {
57 ast_copy_pj_str(username, &header->credential.digest.username, username_size);
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",
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
Truncate the URI user field options string if enabled.
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
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)
#define ao2_callback(c, flags, cb_fn, arg)
static struct ast_sip_endpoint * username_identify(pjsip_rx_data *rdata)
static int load_module(void)
static struct ao2_container * transport_states
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.
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...
static struct ast_sip_endpoint_identifier username_identifier
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
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.
#define ast_debug(level,...)
Log a DEBUG message.
Structure for SIP transport information.
struct pjsip_transport * transport
Transport itself.
#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.
static struct ast_sip_endpoint_identifier auth_username_identifier
struct pjsip_tpfactory * factory
Transport factory.
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)
const ast_string_field domain
An entity responsible for identifying the source of a SIP message.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
const ast_string_field domain
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
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.
void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Unregister a SIP endpoint identifier.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.