Merge "res_pjsip: Change default from user value."
This commit is contained in:
commit
e1c43223ab
|
@ -0,0 +1,22 @@
|
|||
"""add default_from_user
|
||||
|
||||
Revision ID: 154177371065
|
||||
Revises: 26f10cadc157
|
||||
Create Date: 2015-09-04 14:13:59.195013
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '154177371065'
|
||||
down_revision = '26f10cadc157'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('ps_globals', sa.Column('default_from_user', sa.String(80)))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('ps_globals', 'default_from_user')
|
|
@ -2018,6 +2018,17 @@ char *ast_sip_get_debug(void);
|
|||
*/
|
||||
char *ast_sip_get_endpoint_identifier_order(void);
|
||||
|
||||
/*!
|
||||
* \brief Retrieve the global default from user.
|
||||
*
|
||||
* This is the value placed in outbound requests' From header if there
|
||||
* is no better option (such as an endpoint-configured from_user or
|
||||
* caller ID number).
|
||||
*
|
||||
* \retval The global default_from_user value.
|
||||
*/
|
||||
const char *ast_sip_get_default_from_user(void);
|
||||
|
||||
/*! \brief Determines whether the res_pjsip module is loaded */
|
||||
#define CHECK_PJSIP_MODULE_LOADED() \
|
||||
do { \
|
||||
|
|
|
@ -1286,6 +1286,11 @@
|
|||
Identifier names are usually derived from and can be found in the endpoint
|
||||
identifier module itself (res_pjsip_endpoint_identifier_*)</synopsis>
|
||||
</configOption>
|
||||
<configOption name="default_from_user" default="asterisk">
|
||||
<synopsis>When Asterisk generates an outgoing SIP request, the From header username will be
|
||||
set to this value if there is no better option (such as CallerID) to be
|
||||
used.</synopsis>
|
||||
</configOption>
|
||||
</configObject>
|
||||
</configFile>
|
||||
</configInfo>
|
||||
|
@ -2333,10 +2338,9 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u
|
|||
pjsip_sip_uri *sip_uri;
|
||||
pjsip_transport_type_e type = PJSIP_TRANSPORT_UNSPECIFIED;
|
||||
int local_port;
|
||||
char uuid_str[AST_UUID_STR_LEN];
|
||||
|
||||
if (ast_strlen_zero(user)) {
|
||||
user = ast_uuid_generate_str(uuid_str, sizeof(uuid_str));
|
||||
user = ast_sip_get_default_from_user();
|
||||
}
|
||||
|
||||
/* Parse the provided target URI so we can determine what transport it will end up using */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define DEFAULT_DEBUG "no"
|
||||
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER "ip,username,anonymous"
|
||||
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME 0
|
||||
#define DEFAULT_FROM_USER "asterisk"
|
||||
|
||||
static char default_useragent[256];
|
||||
|
||||
|
@ -46,6 +47,8 @@ struct global_config {
|
|||
AST_STRING_FIELD(debug);
|
||||
/*! Order by which endpoint identifiers are checked (comma separated list) */
|
||||
AST_STRING_FIELD(endpoint_identifier_order);
|
||||
/*! User name to place in From header if there is no better option */
|
||||
AST_STRING_FIELD(default_from_user);
|
||||
);
|
||||
/* Value to put in Max-Forwards header */
|
||||
unsigned int max_forwards;
|
||||
|
@ -179,6 +182,22 @@ unsigned int ast_sip_get_max_initial_qualify_time(void)
|
|||
return time;
|
||||
}
|
||||
|
||||
const char *ast_sip_get_default_from_user(void)
|
||||
{
|
||||
const char *from_user;
|
||||
struct global_config *cfg;
|
||||
|
||||
cfg = get_global_cfg();
|
||||
if (!cfg) {
|
||||
return DEFAULT_FROM_USER;
|
||||
}
|
||||
|
||||
from_user = cfg->default_from_user;
|
||||
ao2_ref(cfg, -1);
|
||||
|
||||
return from_user;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Observer to set default global object if none exist.
|
||||
|
@ -292,6 +311,8 @@ int ast_sip_initialize_sorcery_global(void)
|
|||
ast_sorcery_object_field_register(sorcery, "global", "max_initial_qualify_time",
|
||||
__stringify(DEFAULT_MAX_INITIAL_QUALIFY_TIME),
|
||||
OPT_UINT_T, 0, FLDSET(struct global_config, max_initial_qualify_time));
|
||||
ast_sorcery_object_field_register(sorcery, "global", "default_from_user", DEFAULT_FROM_USER,
|
||||
OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_from_user));
|
||||
|
||||
if (ast_sorcery_instance_observer_add(sorcery, &observer_callbacks_global)) {
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue