Merge "endpoint snapshot: avoid second cleanup on alloc failure"
authorMatt Jordan <mjordan@digium.com>
Sat, 5 Sep 2015 23:48:26 +0000 (18:48 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Sat, 5 Sep 2015 23:48:26 +0000 (18:48 -0500)
CHANGES
channels/pjsip/dialplan_functions.c
contrib/ast-db-manage/config/versions/154177371065_add_default_from_user.py [new file with mode: 0644]
include/asterisk/res_pjsip.h
res/res_pjsip.c
res/res_pjsip/config_global.c
res/res_pjsip_transport_websocket.c
res/res_rtp_asterisk.c

diff --git a/CHANGES b/CHANGES
index 322419d..8c8329c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -177,6 +177,18 @@ cdr_adaptive_odbc
    names. This setting is configurable for cdr_adaptive_odbc via the
    quoted_identifiers in configuration file cdr_adaptive_odbc.conf.
 
+
+------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 13.5.0 to Asterisk 13.6.0 ------------
+------------------------------------------------------------------------------
+
+Dialplan Functions
+------------------
+ * The CHANNEL function, when used on a PJSIP channel, now exposes a 'call-id'
+   extraction option when using with the 'pjsip' signalling option. It will
+   return the SIP Call-ID associated with the INVITE request that established
+   the PJSIP channel.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.4.0 to Asterisk 13.5.0 ------------
 ------------------------------------------------------------------------------
index 24daac8..b86cfad 100644 (file)
                                <literal>type</literal> parameter must be provided. It specifies
                                which signalling parameter to read.</para>
                                <enumlist>
+                                       <enum name="call-id">
+                                               <para>The SIP call-id.</para>
+                                       </enum>
                                        <enum name="secure">
                                                <para>Whether or not the signalling uses a secure transport.</para>
                                                <enumlist>
@@ -594,6 +597,8 @@ static int channel_read_pjsip(struct ast_channel *chan, const char *type, const
        if (ast_strlen_zero(type)) {
                ast_log(LOG_WARNING, "You must supply a type field for 'pjsip' information\n");
                return -1;
+       } else if (!strcmp(type, "call-id")) {
+               snprintf(buf, buflen, "%.*s", (int) pj_strlen(&dlg->call_id->id), pj_strbuf(&dlg->call_id->id));
        } else if (!strcmp(type, "secure")) {
 #ifdef HAVE_PJSIP_GET_DEST_INFO
                pjsip_host_info dest;
diff --git a/contrib/ast-db-manage/config/versions/154177371065_add_default_from_user.py b/contrib/ast-db-manage/config/versions/154177371065_add_default_from_user.py
new file mode 100644 (file)
index 0000000..7e6cf99
--- /dev/null
@@ -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')
index 508a7be..b7b875d 100644 (file)
@@ -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 {                                                    \
index b8463ce..4af886b 100644 (file)
                                         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 */
index 42ba234..b348896 100644 (file)
@@ -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;
index e48b630..3157a94 100644 (file)
@@ -419,7 +419,7 @@ static int load_module(void)
        CHECK_PJSIP_MODULE_LOADED();
 
        pjsip_transport_register_type(PJSIP_TRANSPORT_RELIABLE, "WS", 5060, &transport_type_ws);
-       pjsip_transport_register_type(PJSIP_TRANSPORT_RELIABLE, "WSS", 5060, &transport_type_wss);
+       pjsip_transport_register_type(PJSIP_TRANSPORT_RELIABLE | PJSIP_TRANSPORT_SECURE, "WSS", 5060, &transport_type_wss);
 
        if (ast_sip_register_service(&websocket_module) != PJ_SUCCESS) {
                return AST_MODULE_LOAD_DECLINE;
index 545e216..09a0fef 100644 (file)
@@ -706,8 +706,7 @@ static void ast_rtp_ice_start(struct ast_rtp_instance *instance)
        ao2_iterator_destroy(&i);
 
        if (has_rtp && has_rtcp &&
-           pj_ice_sess_create_check_list(rtp->ice, &ufrag, &passwd, ao2_container_count(
-                                                 rtp->ice_active_remote_candidates), &candidates[0]) == PJ_SUCCESS) {
+           pj_ice_sess_create_check_list(rtp->ice, &ufrag, &passwd, cand_cnt, &candidates[0]) == PJ_SUCCESS) {
                ast_test_suite_event_notify("ICECHECKLISTCREATE", "Result: SUCCESS");
                pj_ice_sess_start_check(rtp->ice);
                pj_timer_heap_poll(timer_heap, NULL);