Author: mjordan
Date: Sat Feb 21 17:44:05 2015
New Revision: 432173

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432173
Log:
Re-enable automerge

Added:
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_sips_contact.c
      - copied unchanged from r432155, trunk/res/res_pjsip_sips_contact.c
Modified:
    team/mjordan/trunk-http-stuff-and-things/   (props changed)
    team/mjordan/trunk-http-stuff-and-things/CHANGES
    team/mjordan/trunk-http-stuff-and-things/apps/app_agent_pool.c
    team/mjordan/trunk-http-stuff-and-things/apps/app_confbridge.c
    team/mjordan/trunk-http-stuff-and-things/apps/app_mixmonitor.c
    team/mjordan/trunk-http-stuff-and-things/apps/app_voicemail.c
    team/mjordan/trunk-http-stuff-and-things/bridges/bridge_builtin_features.c
    team/mjordan/trunk-http-stuff-and-things/channels/chan_dahdi.c
    team/mjordan/trunk-http-stuff-and-things/channels/chan_iax2.c
    team/mjordan/trunk-http-stuff-and-things/channels/chan_pjsip.c
    team/mjordan/trunk-http-stuff-and-things/channels/chan_sip.c
    team/mjordan/trunk-http-stuff-and-things/channels/pjsip/dialplan_functions.c
    team/mjordan/trunk-http-stuff-and-things/channels/sig_analog.c
    team/mjordan/trunk-http-stuff-and-things/configs/samples/http.conf.sample
    team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip.conf.sample
    
team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip_wizard.conf.sample
    team/mjordan/trunk-http-stuff-and-things/contrib/scripts/install_prereq
    team/mjordan/trunk-http-stuff-and-things/funcs/func_curl.c
    team/mjordan/trunk-http-stuff-and-things/include/asterisk.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/bridge.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/channel.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/http.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/lock.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/module.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/sched.h
    team/mjordan/trunk-http-stuff-and-things/include/asterisk/stasis_app.h
    team/mjordan/trunk-http-stuff-and-things/main/aoc.c
    team/mjordan/trunk-http-stuff-and-things/main/asterisk.c
    team/mjordan/trunk-http-stuff-and-things/main/bridge.c
    team/mjordan/trunk-http-stuff-and-things/main/bridge_after.c
    team/mjordan/trunk-http-stuff-and-things/main/bucket.c
    team/mjordan/trunk-http-stuff-and-things/main/channel.c
    team/mjordan/trunk-http-stuff-and-things/main/codec.c
    team/mjordan/trunk-http-stuff-and-things/main/config.c
    team/mjordan/trunk-http-stuff-and-things/main/http.c
    team/mjordan/trunk-http-stuff-and-things/main/loader.c
    team/mjordan/trunk-http-stuff-and-things/main/manager.c
    team/mjordan/trunk-http-stuff-and-things/main/pbx.c
    team/mjordan/trunk-http-stuff-and-things/main/sched.c
    team/mjordan/trunk-http-stuff-and-things/main/sorcery.c
    team/mjordan/trunk-http-stuff-and-things/main/stasis_channels.c
    team/mjordan/trunk-http-stuff-and-things/main/tcptls.c
    team/mjordan/trunk-http-stuff-and-things/main/utils.c
    team/mjordan/trunk-http-stuff-and-things/main/xmldoc.c
    team/mjordan/trunk-http-stuff-and-things/pbx/pbx_spool.c
    team/mjordan/trunk-http-stuff-and-things/res/ari/ari_websockets.c
    team/mjordan/trunk-http-stuff-and-things/res/ari/resource_channels.c
    team/mjordan/trunk-http-stuff-and-things/res/ari/resource_channels.h
    team/mjordan/trunk-http-stuff-and-things/res/res_ari_channels.c
    team/mjordan/trunk-http-stuff-and-things/res/res_format_attr_h264.c
    team/mjordan/trunk-http-stuff-and-things/res/res_http_websocket.c
    team/mjordan/trunk-http-stuff-and-things/res/res_odbc.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip/pjsip_cli.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip/pjsip_configuration.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip/pjsip_options.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_acl.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_caller_id.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_config_wizard.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_exten_state.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_keepalive.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_messaging.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_multihomed.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_nat.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_outbound_publish.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_publish_asterisk.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_pubsub.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_refer.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_registrar.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_sdp_rtp.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_send_to_voicemail.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_session.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_t38.c
    team/mjordan/trunk-http-stuff-and-things/res/res_pjsip_transport_websocket.c
    team/mjordan/trunk-http-stuff-and-things/res/res_rtp_asterisk.c
    team/mjordan/trunk-http-stuff-and-things/res/res_sorcery_config.c
    team/mjordan/trunk-http-stuff-and-things/res/res_timing_pthread.c
    team/mjordan/trunk-http-stuff-and-things/res/stasis/control.c
    team/mjordan/trunk-http-stuff-and-things/res/stasis/stasis_bridge.c
    team/mjordan/trunk-http-stuff-and-things/rest-api/api-docs/channels.json

Propchange: team/mjordan/trunk-http-stuff-and-things/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/mjordan/trunk-http-stuff-and-things/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Propchange: team/mjordan/trunk-http-stuff-and-things/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Feb 21 17:44:05 2015
@@ -1,1 +1,1 @@
-/trunk:1-431277
+/trunk:1-432172

Modified: team/mjordan/trunk-http-stuff-and-things/CHANGES
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/CHANGES?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/CHANGES (original)
+++ team/mjordan/trunk-http-stuff-and-things/CHANGES Sat Feb 21 17:44:05 2015
@@ -99,6 +99,24 @@
  * Added preferchannelclass=no option to prefer the application-passed class
    over the channel-set musicclass. This allows separate hold-music from
    application (e.g. Queue or Dial) specified music.
+
+------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 13.2.0 to Asterisk 13.3.0 ------------
+------------------------------------------------------------------------------
+
+chan_pjsip/app_transfer
+------------------
+ * The Transfer application, when used with chan_pjsip, now supports using
+   a PJSIP endpoint as the transfer destination. This is in addition to
+   explicitly specifying a SIP URI to transfer to.
+
+res_ari_channels
+------------------
+ * The ARI /channels resource now supports a new operation, 'redirect'. The
+   redirect operation will perform a technology and state specific redirection
+   on the channel to a specified endpoint or destination. In the case of SIP
+   technologies, this is either a 302 Redirect response to an on-going INVITE
+   dialog or a SIP REFER request.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.1.0 to Asterisk 13.2.0 ------------

Modified: team/mjordan/trunk-http-stuff-and-things/apps/app_agent_pool.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/apps/app_agent_pool.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/apps/app_agent_pool.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/apps/app_agent_pool.c Sat Feb 21 
17:44:05 2015
@@ -552,14 +552,10 @@
        aco_option_register(&cfg_info, "fullname", ACO_EXACT, agent_types, 
NULL, OPT_STRINGFIELD_T, 0, STRFLDSET(struct agent_cfg, full_name));
 
        if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
-               goto error;
+               return -1;
        }
 
        return 0;
-
-error:
-       destroy_config();
-       return -1;
 }
 
 enum agent_state {
@@ -730,12 +726,17 @@
  */
 static enum ast_device_state agent_pvt_devstate_get(const char *agent_id)
 {
-       RAII_VAR(struct agent_pvt *, agent, ao2_find(agents, agent_id, 
OBJ_KEY), ao2_cleanup);
-
+       enum ast_device_state dev_state = AST_DEVICE_INVALID;
+       struct agent_pvt *agent;
+
+       agent = ao2_find(agents, agent_id, OBJ_KEY);
        if (agent) {
-               return agent->devstate;
-       }
-       return AST_DEVICE_INVALID;
+               agent_lock(agent);
+               dev_state = agent->devstate;
+               agent_unlock(agent);
+               ao2_ref(agent, -1);
+       }
+       return dev_state;
 }
 
 /*!
@@ -2642,7 +2643,7 @@
        }
 
        destroy_config();
-       ao2_ref(agents, -1);
+       ao2_cleanup(agents);
        agents = NULL;
        return 0;
 }
@@ -2656,12 +2657,6 @@
        if (!agents) {
                return AST_MODULE_LOAD_FAILURE;
        }
-       if (load_config()) {
-               ast_log(LOG_ERROR, "Unable to load config. Not loading 
module.\n");
-               ao2_ref(agents, -1);
-               agents = NULL;
-               return AST_MODULE_LOAD_DECLINE;
-       }
 
        /* Init agent holding bridge v_table. */
        bridge_init_agent_hold();
@@ -2687,6 +2682,13 @@
                unload_module();
                return AST_MODULE_LOAD_FAILURE;
        }
+
+       if (load_config()) {
+               ast_log(LOG_ERROR, "Unable to load config. Not loading 
module.\n");
+               unload_module();
+               return AST_MODULE_LOAD_DECLINE;
+       }
+
        return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/mjordan/trunk-http-stuff-and-things/apps/app_confbridge.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/apps/app_confbridge.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/apps/app_confbridge.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/apps/app_confbridge.c Sat Feb 21 
17:44:05 2015
@@ -1757,6 +1757,12 @@
 
        /* if we're shutting down, don't attempt to do further processing */
        if (ast_shutting_down()) {
+               /*
+                * Not taking any new calls at this time.  We cannot create
+                * the announcer channel if this is the first channel into
+                * the conference and we certainly cannot create any
+                * recording channel.
+                */
                leave_conference(&user);
                conference = NULL;
                goto confbridge_cleanup;

Modified: team/mjordan/trunk-http-stuff-and-things/apps/app_mixmonitor.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/apps/app_mixmonitor.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/apps/app_mixmonitor.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/apps/app_mixmonitor.c Sat Feb 21 
17:44:05 2015
@@ -727,12 +727,6 @@
                ast_audiohook_lock(&mixmonitor->audiohook);
        }
 
-       /* Test Event */
-       ast_test_suite_event_notify("MIXMONITOR_END", "Channel: %s\r\n"
-                                                                       "File: 
%s\r\n",
-                                                                       
ast_channel_name(mixmonitor->autochan->chan),
-                                                                       
mixmonitor->filename);
-
        ast_audiohook_unlock(&mixmonitor->audiohook);
 
        ast_channel_lock(mixmonitor->autochan->chan);
@@ -760,6 +754,7 @@
        }
 
        ast_verb(2, "End MixMonitor Recording %s\n", mixmonitor->name);
+       ast_test_suite_event_notify("MIXMONITOR_END", "File: %s\r\n", 
mixmonitor->filename);
 
        if (!AST_LIST_EMPTY(&mixmonitor->recipient_list)) {
                if (ast_strlen_zero(fs_ext)) {

Modified: team/mjordan/trunk-http-stuff-and-things/apps/app_voicemail.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/apps/app_voicemail.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/apps/app_voicemail.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/apps/app_voicemail.c Sat Feb 21 
17:44:05 2015
@@ -2430,7 +2430,7 @@
        /* We have to get the user before we can open the stream! */
        vmu = find_user(&vmus, context, mailbox);
        if (!vmu) {
-               ast_log(AST_LOG_ERROR, "Couldn't find mailbox %s in context 
%s\n", mailbox, context);
+               ast_log(AST_LOG_WARNING, "Couldn't find mailbox %s in context 
%s\n", mailbox, context);
                return -1;
        } else {
                /* No IMAP account available */
@@ -3334,7 +3334,7 @@
        if (taglen < 1)
                return NULL;
 
-       if (!(start = strstr(header, tag)))
+       if (!(start = strcasestr(header, tag)))
                return NULL;
 
        /* Since we can be called multiple times we should clear our buffer */

Modified: 
team/mjordan/trunk-http-stuff-and-things/bridges/bridge_builtin_features.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/bridges/bridge_builtin_features.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/bridges/bridge_builtin_features.c 
(original)
+++ team/mjordan/trunk-http-stuff-and-things/bridges/bridge_builtin_features.c 
Sat Feb 21 17:44:05 2015
@@ -499,6 +499,10 @@
 
 static int unload_module(void)
 {
+       ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_HANGUP);
+       ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_AUTOMON);
+       ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_AUTOMIXMON);
+
        return 0;
 }
 
@@ -508,8 +512,8 @@
        ast_bridge_features_register(AST_BRIDGE_BUILTIN_AUTOMON, 
feature_automonitor, NULL);
        ast_bridge_features_register(AST_BRIDGE_BUILTIN_AUTOMIXMON, 
feature_automixmonitor, NULL);
 
-       /* Bump up our reference count so we can't be unloaded */
-       ast_module_ref(ast_module_info->self);
+       /* This module cannot be unloaded until shutdown */
+       ast_module_shutdown_ref(ast_module_info->self);
 
        return AST_MODULE_LOAD_SUCCESS;
 }

Modified: team/mjordan/trunk-http-stuff-and-things/channels/chan_dahdi.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/channels/chan_dahdi.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/channels/chan_dahdi.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/channels/chan_dahdi.c Sat Feb 21 
17:44:05 2015
@@ -1423,7 +1423,8 @@
 
                for (;;) {
                        i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
-                       if ((res = ioctl(p->subs[idx].dfd, DAHDI_IOMUX, &i))) {
+                       res = ioctl(p->subs[idx].dfd, DAHDI_IOMUX, &i);
+                       if (res) {
                                ast_log(LOG_WARNING, "I/O MUX failed: %s\n", 
strerror(errno));
                                ast_hangup(chan);
                                return 1;
@@ -1458,7 +1459,6 @@
                                }
                                if (analog_p->ringt > 0) {
                                        if (!(--analog_p->ringt)) {
-                                               res = -1;
                                                break;
                                        }
                                }

Modified: team/mjordan/trunk-http-stuff-and-things/channels/chan_iax2.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/channels/chan_iax2.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/channels/chan_iax2.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/channels/chan_iax2.c Sat Feb 21 
17:44:05 2015
@@ -14692,7 +14692,6 @@
        ao2_ref(users, -1);
        ao2_ref(iax_peercallno_pvts, -1);
        ao2_ref(iax_transfercallno_pvts, -1);
-       ao2_ref(peercnts, -1);
        ao2_ref(callno_limits, -1);
        ao2_ref(calltoken_ignores, -1);
        if (timer) {
@@ -14700,8 +14699,11 @@
                timer = NULL;
        }
        transmit_processor = ast_taskprocessor_unreference(transmit_processor);
+
+       ast_sched_clean_by_callback(sched, peercnt_remove_cb, 
peercnt_remove_cb);
        ast_sched_context_destroy(sched);
        sched = NULL;
+       ao2_ref(peercnts, -1);
 
        con = ast_context_find(regcontext);
        if (con)

Modified: team/mjordan/trunk-http-stuff-and-things/channels/chan_pjsip.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/channels/chan_pjsip.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/channels/chan_pjsip.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/channels/chan_pjsip.c Sat Feb 21 
17:44:05 2015
@@ -1378,6 +1378,8 @@
        pj_str_t tmp;
 
        if (pjsip_inv_end_session(session->inv_session, 302, NULL, &packet) != 
PJ_SUCCESS) {
+               ast_log(LOG_WARNING, "Failed to redirect PJSIP session for 
channel %s\n",
+                       ast_channel_name(session->channel));
                message = AST_TRANSFER_FAILED;
                ast_queue_control_data(session->channel, AST_CONTROL_TRANSFER, 
&message, sizeof(message));
 
@@ -1390,6 +1392,8 @@
 
        pj_strdup2_with_null(packet->pool, &tmp, target);
        if (!(contact->uri = pjsip_parse_uri(packet->pool, tmp.ptr, tmp.slen, 
PJSIP_PARSE_URI_AS_NAMEADDR))) {
+               ast_log(LOG_WARNING, "Failed to parse destination URI '%s' for 
channel %s\n",
+                       target, ast_channel_name(session->channel));
                message = AST_TRANSFER_FAILED;
                ast_queue_control_data(session->channel, AST_CONTROL_TRANSFER, 
&message, sizeof(message));
                pjsip_tx_data_dec_ref(packet);
@@ -1431,14 +1435,28 @@
 static int transfer(void *data)
 {
        struct transfer_data *trnf_data = data;
+       struct ast_sip_endpoint *endpoint = NULL;
+       struct ast_sip_contact *contact = NULL;
+       const char *target = trnf_data->target;
+
+       /* See if we have an endpoint; if so, use its contact */
+       endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), 
"endpoint", target);
+       if (endpoint) {
+               contact = 
ast_sip_location_retrieve_contact_from_aor_list(endpoint->aors);
+               if (contact && !ast_strlen_zero(contact->uri)) {
+                       target = contact->uri;
+               }
+       }
 
        if (ast_channel_state(trnf_data->session->channel) == AST_STATE_RING) {
-               transfer_redirect(trnf_data->session, trnf_data->target);
+               transfer_redirect(trnf_data->session, target);
        } else {
-               transfer_refer(trnf_data->session, trnf_data->target);
+               transfer_refer(trnf_data->session, target);
        }
 
        ao2_ref(trnf_data, -1);
+       ao2_cleanup(endpoint);
+       ao2_cleanup(contact);
        return 0;
 }
 
@@ -2107,7 +2125,7 @@
 
 static int call_pickup_incoming_request(struct ast_sip_session *session, 
pjsip_rx_data *rdata)
 {
-       struct ast_features_pickup_config *pickup_cfg = 
ast_get_chan_features_pickup_config(session->channel);
+       struct ast_features_pickup_config *pickup_cfg;
        struct ast_channel *chan;
 
        /* We don't care about reinvites */
@@ -2115,6 +2133,7 @@
                return 0;
        }
 
+       pickup_cfg = ast_get_chan_features_pickup_config(session->channel);
        if (!pickup_cfg) {
                ast_log(LOG_ERROR, "Unable to retrieve pickup configuration 
options. Unable to detect call pickup extension.\n");
                return 0;

Modified: team/mjordan/trunk-http-stuff-and-things/channels/chan_sip.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/channels/chan_sip.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/channels/chan_sip.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/channels/chan_sip.c Sat Feb 21 
17:44:05 2015
@@ -1447,7 +1447,7 @@
 static void set_destination(struct sip_pvt *p, const char *uri);
 static void add_date(struct sip_request *req);
 static void add_expires(struct sip_request *req, int expires);
-static void build_contact(struct sip_pvt *p);
+static void build_contact(struct sip_pvt *p, struct sip_request *req, int 
incoming);
 
 /*------Request handling functions */
 static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct 
ast_sockaddr *addr, int *recount, int *nounlock);
@@ -13847,22 +13847,110 @@
        if (!ast_strlen_zero(c)) {
                ast_string_field_set(p, uri, c);
        }
-
-}
-
-/*! \brief Build contact header - the contact header we send out */
-static void build_contact(struct sip_pvt *p)
+}
+
+/*!
+ * \brief Determine if, as a UAS, we need to use a SIPS Contact.
+ *
+ * This uses the rules defined in RFC 3261 section 12.1.1 to
+ * determine if a SIPS URI should be used as the Contact header
+ * when responding to incoming SIP requests.
+ *
+ * \param req The incoming SIP request
+ * \retval 0 SIPS is not required
+ * \retval 1 SIPS is required
+ */
+static int uas_sips_contact(struct sip_request *req)
+{
+       const char *record_route = sip_get_header(req, "Record-Route");
+
+       if (!strncmp(REQ_OFFSET_TO_STR(req, rlpart2), "sips:", 5)) {
+               return 1;
+       }
+
+       if (record_route) {
+               char *record_route_uri = 
get_in_brackets(ast_strdupa(record_route));
+
+               if (!strncmp(record_route_uri, "sips:", 5)) {
+                       return 1;
+               }
+       } else {
+               const char *contact = sip_get_header(req, "Contact");
+               char *contact_uri = get_in_brackets(ast_strdupa(contact));
+
+               if (!strncmp(contact_uri, "sips:", 5)) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+/*!
+ * \brief Determine if, as a UAC, we need to use a SIPS Contact.
+ *
+ * This uses the rules defined in RFC 3621 section 8.1.1.8 to
+ * determine if a SIPS URI should be used as the Contact header
+ * on our outgoing request.
+ *
+ * \param req The outgoing SIP request
+ * \retval 0 SIPS is not required
+ * \retval 1 SIPS is required
+ */
+static int uac_sips_contact(struct sip_request *req)
+{
+       const char *route = sip_get_header(req, "Route");
+
+       if (!strncmp(REQ_OFFSET_TO_STR(req, rlpart2), "sips:", 5)) {
+               return 1;
+       }
+
+       if (route) {
+               char *route_uri = get_in_brackets(ast_strdupa(route));
+
+               if (!strncmp(route_uri, "sips:", 5)) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+/*!
+ * \brief Build contact header
+ *
+ * This is the Contact header that we send out in SIP requests and responses
+ * involving this sip_pvt.
+ *
+ * The incoming parameter is used to tell if we are building the request 
parameter
+ * is an incoming SIP request that we are building the Contact header in 
response to,
+ * or if the req parameter is an outbound SIP request that we will later be 
adding
+ * the Contact header to.
+ *
+ * \param p The sip_pvt where the built Contact will be saved.
+ * \param req The request that triggered the creation of a Contact header.
+ * \param incoming Indicates if the Contact header is being created for a 
response to an incoming request
+ */
+static void build_contact(struct sip_pvt *p, struct sip_request *req, int 
incoming)
 {
        char tmp[SIPBUFSIZE];
        char *user = ast_uri_encode(p->exten, tmp, sizeof(tmp), 
ast_uri_sip_user);
+       int use_sips;
+
+       if (incoming) {
+               use_sips = uas_sips_contact(req);
+       } else {
+               use_sips = uac_sips_contact(req);
+       }
 
        if (p->socket.type == AST_TRANSPORT_UDP) {
-               ast_string_field_build(p, our_contact, "<sip:%s%s%s>", user,
-                       ast_strlen_zero(user) ? "" : "@", 
ast_sockaddr_stringify_remote(&p->ourip));
+               ast_string_field_build(p, our_contact, "<%s:%s%s%s>", use_sips 
? "sips" : "sip",
+                       user, ast_strlen_zero(user) ? "" : "@",
+                       ast_sockaddr_stringify_remote(&p->ourip));
        } else {
-               ast_string_field_build(p, our_contact, 
"<sip:%s%s%s;transport=%s>", user,
-                       ast_strlen_zero(user) ? "" : "@", 
ast_sockaddr_stringify_remote(&p->ourip),
-                       sip_get_transport(p->socket.type));
+               ast_string_field_build(p, our_contact, 
"<%s:%s%s%s;transport=%s>",
+                       use_sips ? "sips" : "sip", user, ast_strlen_zero(user) 
? "" : "@",
+                       ast_sockaddr_stringify_remote(&p->ourip), 
sip_get_transport(p->socket.type));
        }
 }
 
@@ -14058,7 +14146,7 @@
        add_header(req, "From", from);
        add_header(req, "To", to);
        ast_string_field_set(p, exten, l);
-       build_contact(p);
+       build_contact(p, req, 0);
        add_header(req, "Contact", p->our_contact);
        add_header(req, "Call-ID", p->callid);
        add_header(req, "CSeq", tmp_n);
@@ -14487,7 +14575,6 @@
        set_socket_transport(&mwi->call->socket, mwi->transport);
        mwi->call->socket.port = htons(mwi->portno);
        ast_sip_ouraddrfor(&mwi->call->sa, &mwi->call->ourip, mwi->call);
-       build_contact(mwi->call);
        build_via(mwi->call);
 
        /* Change the dialog callid. */
@@ -15455,7 +15542,6 @@
                  internal network so we can register through nat
                 */
                ast_sip_ouraddrfor(&p->sa, &p->ourip, p);
-               build_contact(p);
        }
 
        /* set up a timeout */
@@ -15535,6 +15621,7 @@
        }
 
        add_expires(&req, r->expiry);
+       build_contact(p, &req, 0);
        add_header(&req, "Contact", p->our_contact);
 
        initialize_initreq(p, &req);
@@ -15822,7 +15909,7 @@
 
        if (!sip_cfg.ignore_regexpire) {
                if (peer->rt_fromcontact && sip_cfg.peer_rtupdate) {
-                       ast_update_realtime(tablename, "name", peer->name, 
"fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "regserver", 
"", "useragent", "", "lastms", "0", SENTINEL);
+                       ast_update_realtime(tablename, "name", peer->name, 
"fullcontact", "", "ipaddr", "", "port", "0", "regseconds", "0", "regserver", 
"", "useragent", "", "lastms", "0", SENTINEL);
                } else {
                        ast_db_del("SIP/Registry", peer->name);
                        ast_db_del("SIP/RegistryPath", peer->name);
@@ -17064,7 +17151,7 @@
        }
 
        ast_string_field_set(p, exten, name);
-       build_contact(p);
+       build_contact(p, req, 1);
        if (req->ignore) {
                /* Expires is a special case, where we only want to load the 
peer if this isn't a deregistration attempt */
                const char *expires = sip_get_header(req, "Expires");
@@ -18610,8 +18697,9 @@
                if (t)
                        *t = '\0';
 
-               if (ast_strlen_zero(p->our_contact))
-                       build_contact(p);
+               if (ast_strlen_zero(p->our_contact)) {
+                       build_contact(p, req, 1);
+               }
        }
 
        of = get_in_brackets(of);
@@ -24760,12 +24848,16 @@
 
        /* must go through authentication before getting here */
        gotdest = get_destination(p, req, NULL);
-       build_contact(p);
+       build_contact(p, req, 1);
 
        if (ast_strlen_zero(p->context))
                ast_string_field_set(p, context, sip_cfg.default_context);
 
        if (ast_shutting_down()) {
+               /*
+                * Not taking any new calls at this time.
+                * Likely a server availability OPTIONS poll.
+                */
                msg = "503 Unavailable";
        } else {
                msg = "404 Not Found";
@@ -25526,8 +25618,8 @@
                        goto request_invite_cleanup;
                }
                gotdest = get_destination(p, NULL, &cc_recall_core_id); /* Get 
destination right away */
-               extract_uri(p, req);                    /* Get the Contact URI 
*/
-               build_contact(p);                       /* Build our contact 
header */
+               extract_uri(p, req);        /* Get the Contact URI */
+               build_contact(p, req, 1);   /* Build our contact header */
 
                if (p->rtp) {
                        ast_rtp_instance_set_prop(p->rtp, 
AST_RTP_PROPERTY_DTMF, ast_test_flag(&p->flags[0], SIP_DTMF) == 
SIP_DTMF_RFC2833);
@@ -27435,7 +27527,7 @@
 
        /* Get full contact header - this needs to be used as a request URI in 
NOTIFY's */
        parse_ok_contact(p, req);
-       build_contact(p);
+       build_contact(p, req, 1);
 
        /* Initialize tag for new subscriptions */
        if (ast_strlen_zero(p->tag)) {

Modified: 
team/mjordan/trunk-http-stuff-and-things/channels/pjsip/dialplan_functions.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/channels/pjsip/dialplan_functions.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- 
team/mjordan/trunk-http-stuff-and-things/channels/pjsip/dialplan_functions.c 
(original)
+++ 
team/mjordan/trunk-http-stuff-and-things/channels/pjsip/dialplan_functions.c 
Sat Feb 21 17:44:05 2015
@@ -591,7 +591,10 @@
 
        dlg = channel->session->inv_session->dlg;
 
-       if (!strcmp(type, "secure")) {
+       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, "secure")) {
 #ifdef HAVE_PJSIP_GET_DEST_INFO
                pjsip_host_info dest;
                pj_pool_t *pool = 
pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "secure-check", 128, 128);

Modified: team/mjordan/trunk-http-stuff-and-things/channels/sig_analog.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/channels/sig_analog.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/channels/sig_analog.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/channels/sig_analog.c Sat Feb 21 
17:44:05 2015
@@ -1703,7 +1703,6 @@
        char dtmfbuf[300];
        char namebuf[ANALOG_MAX_CID];
        char numbuf[ANALOG_MAX_CID];
-       struct callerid_state *cs = NULL;
        char *name = NULL, *number = NULL;
        int flags = 0;
        struct ast_smdi_md_message *smdi_msg = NULL;
@@ -2391,7 +2390,6 @@
                                int timeout_ms;
                                int ms;
                                struct timeval start = ast_tvnow();
-                               cs = NULL;
                                ast_debug(1, "Receiving DTMF cid on channel 
%s\n", ast_channel_name(chan));
 
                                oldlinearity = analog_set_linear_mode(p, idx, 
0);
@@ -2415,8 +2413,8 @@
                                                 * or AST_FLAG_END_DTMF_ONLY 
flag settings since we
                                                 * are hanging up the channel.
                                                 */
-                                               ast_log(LOG_WARNING, "DTMFCID 
timed out waiting for ring. "
-                                                       "Exiting simple 
switch\n");
+                                               ast_log(LOG_WARNING,
+                                                       "DTMFCID timed out 
waiting for ring. Exiting simple switch\n");
                                                ast_hangup(chan);
                                                goto quit;
                                        }
@@ -2510,8 +2508,8 @@
 
                                                res = ast_waitfor(chan, ms);
                                                if (res <= 0) {
-                                                       ast_log(LOG_WARNING, 
"CID timed out waiting for ring. "
-                                                               "Exiting simple 
switch\n");
+                                                       ast_log(LOG_WARNING,
+                                                               "CID timed out 
waiting for ring. Exiting simple switch\n");
                                                        ast_hangup(chan);
                                                        goto quit;
                                                }
@@ -2537,10 +2535,8 @@
                                        ast_log(LOG_WARNING, "Unable to get 
caller ID space\n");
                                }
                        } else {
-                               ast_log(LOG_WARNING, "Channel %s in prering "
-                                       "state, but I have nothing to do. "
-                                       "Terminating simple switch, should be "
-                                       "restarted by the actual ring.\n",
+                               ast_log(LOG_WARNING,
+                                       "Channel %s in prering state, but I 
have nothing to do. Terminating simple switch, should be restarted by the 
actual ring.\n",
                                        ast_channel_name(chan));
                                ast_hangup(chan);
                                goto quit;
@@ -2609,18 +2605,12 @@
                        } else {
                                ast_log(LOG_WARNING, "Unable to get caller ID 
space\n");
                        }
-               } else {
-                       cs = NULL;
                }
 
                if (number) {
                        ast_shrink_phone_number(number);
                }
                ast_set_callerid(chan, number, name, number);
-
-               if (cs) {
-                       callerid_free(cs);
-               }
 
                analog_handle_notify_message(chan, p, flags, -1);
 
@@ -3846,8 +3836,7 @@
                        }
                        if (i->cid_start == ANALOG_CID_START_POLARITY || 
i->cid_start == ANALOG_CID_START_POLARITY_IN) {
                                i->polarity = POLARITY_REV;
-                               ast_verb(2, "Starting post polarity "
-                                       "CID detection on channel %d\n",
+                               ast_verb(2, "Starting post polarity CID 
detection on channel %d\n",
                                        i->channel);
                                chan = analog_new_ast_channel(i, 
AST_STATE_PRERING, 0, ANALOG_SUB_REAL, NULL);
                                i->ss_astchan = chan;
@@ -3861,9 +3850,9 @@
                        ast_callid_threadstorage_auto_clean(callid, 
callid_created);
                        break;
                default:
-                       ast_log(LOG_WARNING, "handle_init_event detected "
-                               "polarity reversal on non-FXO (ANALOG_SIG_FXS) "
-                               "interface %d\n", i->channel);
+                       ast_log(LOG_WARNING,
+                               "handle_init_event detected polarity reversal 
on non-FXO (ANALOG_SIG_FXS) interface %d\n",
+                               i->channel);
                        break;
                }
                break;
@@ -3888,9 +3877,9 @@
                        ast_callid_threadstorage_auto_clean(callid, 
callid_created);
                        break;
                default:
-                       ast_log(LOG_WARNING, "handle_init_event detected "
-                               "dtmfcid generation event on non-FXO 
(ANALOG_SIG_FXS) "
-                               "interface %d\n", i->channel);
+                       ast_log(LOG_WARNING,
+                               "handle_init_event detected dtmfcid generation 
event on non-FXO (ANALOG_SIG_FXS) interface %d\n",
+                               i->channel);
                        break;
                }
                break;

Modified: 
team/mjordan/trunk-http-stuff-and-things/configs/samples/http.conf.sample
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/configs/samples/http.conf.sample?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/configs/samples/http.conf.sample 
(original)
+++ team/mjordan/trunk-http-stuff-and-things/configs/samples/http.conf.sample 
Sat Feb 21 17:44:05 2015
@@ -12,6 +12,16 @@
 ;       http://<server_ip>:<bindport>/static/docs/index.html
 ;
 [general]
+;
+; The name of the server, advertised in both the Server field in HTTP
+; response message headers, as well as the <address /> element in certain HTTP
+; response message bodies. If not furnished here, "Asterisk/{version}" will be
+; used as a default value for the Server header field and the <address />
+; element. Setting this property to a blank value will result in the omission
+; of the Server header field from HTTP response message headers and the
+; <address /> element from HTTP response message bodies.
+;
+servername=Asterisk
 ;
 ; Whether HTTP/HTTPS interface is enabled or not.  Default is no.
 ; This also affects manager/rawman/mxml access (see manager.conf)

Modified: 
team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip.conf.sample
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip.conf.sample?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip.conf.sample 
(original)
+++ team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip.conf.sample 
Sat Feb 21 17:44:05 2015
@@ -795,17 +795,6 @@
                                 ; information. Value is in milliseconds; 
default
                                 ; is 100 ms.
 
-;==========================CONTACT SECTION OPTIONS=========================
-;[contact]
-;  SYNOPSIS: A way of creating an aliased name to a SIP URI
-;type=  ; Must be of type contact (default: "")
-;uri=   ; SIP URI to contact peer (default: "")
-;expiration_time=       ; Time to keep alive a contact (default: "")
-;qualify_frequency=0    ; Interval at which to qualify a contact (default: "0")
-;outbound_proxy=        ; Outbound proxy used when sending OPTIONS request
-                        ; (default: "")
-
-
 ;==========================AOR SECTION OPTIONS=========================
 ;[aor]
 ;  SYNOPSIS: The configuration for a location of an endpoint

Modified: 
team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip_wizard.conf.sample
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip_wizard.conf.sample?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- 
team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip_wizard.conf.sample
 (original)
+++ 
team/mjordan/trunk-http-stuff-and-things/configs/samples/pjsip_wizard.conf.sample
 Sat Feb 21 17:44:05 2015
@@ -24,7 +24,7 @@
 ;============EXAMPLE WIZARD CONFIGURATION FOR A PHONE=======================
 
 ; This config would create an endpoint, aor with dynamic contact, inbound
-; auth and a phoneprov object.
+; auth, a phoneprov object and a dialplan hint for extension 1000.
 
 ;[myphone]
 ;type = wizard
@@ -32,6 +32,8 @@
 ;accepts_registrations = yes
 ;has_phoneprov = yes
 ;transport = ipv4
+;has_hint = yes
+;hint_exten = 1000
 ;inbound_auth/username = testname
 ;inbound_auth/password = test password
 ;endpoint/allow = ulaw
@@ -116,6 +118,24 @@
                      ; If yes, phoneprov/MAC must be specified.
                      ; (default: "no")
 
+;has_hint=           ; Create hint and optionally a default application.
+                     ; (default: "no")
+
+;hint_context        ; Any hints created for this wizard will be placed in this
+                     ; context.
+                     ; (default: endpoint/context)
+
+;hint_exten          ; If specified, a PJSIP/<wizard_id> hint will be created
+                     ; for this extension in 'hint_context'.
+                     ; context.
+                     ; (default: none)
+
+;hint_application    ; If specified, an extension will be placed in 
'hint_context'
+                     ; at priority 1 that calls this application.  Could be any
+                     ; valid dialplan expression like
+                     ; "Gosub(stdexten,${EXTEN},1(${HINT}))"
+                     ; (default: "Dial(${HINT})")
+
 ;endpoint/<param>      ; Any parameters to be passed directly to and validated
 ;aor/<param>           ; by their respective objects.
 ;inbound_auth/<param>

Modified: 
team/mjordan/trunk-http-stuff-and-things/contrib/scripts/install_prereq
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/contrib/scripts/install_prereq?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/contrib/scripts/install_prereq 
(original)
+++ team/mjordan/trunk-http-stuff-and-things/contrib/scripts/install_prereq Sat 
Feb 21 17:44:05 2015
@@ -163,7 +163,7 @@
                        cd pjproject
                        git pull
                fi
-               ./configure --enable-shared --with-external-speex 
--with-external-gsm --with-external-srtp --disable-sound --disable-resample && 
make && make install
+               ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --enable-shared 
--with-external-speex --with-external-gsm --with-external-srtp --disable-sound 
--disable-resample && make && make install
                cd ..
                echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
                /sbin/ldconfig

Modified: team/mjordan/trunk-http-stuff-and-things/funcs/func_curl.c
URL: 
http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-http-stuff-and-things/funcs/func_curl.c?view=diff&rev=432173&r1=432172&r2=432173
==============================================================================
--- team/mjordan/trunk-http-stuff-and-things/funcs/func_curl.c (original)
+++ team/mjordan/trunk-http-stuff-and-things/funcs/func_curl.c Sat Feb 21 
17:44:05 2015
@@ -50,6 +50,7 @@
 #include "asterisk/app.h"
 #include "asterisk/utils.h"
 #include "asterisk/threadstorage.h"
+#include "asterisk/test.h"
 
 /*** DOCUMENTATION
        <function name="CURL" language="en_US">
@@ -609,6 +610,31 @@
        struct curl_write_callback_data cb_data;
 };
 
+/*!
+ * \brief Check for potential HTTP injection risk.
+ *
+ * CVE-2014-8150 brought up the fact that HTTP proxies are subject to injection
+ * attacks. An HTTP URL sent to a proxy contains a carriage-return linefeed 
combination,
+ * followed by a complete HTTP request. Proxies will handle this as two 
separate HTTP
+ * requests rather than as a malformed URL.
+ *
+ * libcURL patched this vulnerability in version 7.40.0, but we have no 
guarantee that
+ * Asterisk systems will be using an up-to-date cURL library. Therefore, we 
implement
+ * the same fix as libcURL for determining if a URL is vulnerable to an 
injection attack.
+ *
+ * \param url The URL to check for vulnerability
+ * \retval 0 The URL is not vulnerable
+ * \retval 1 The URL is vulnerable.
+ */
+static int url_is_vulnerable(const char *url)
+{
+       if (strpbrk(url, "\r\n")) {
+               return 1;
+       }
+
+       return 0;
+}
+
 static int acf_curl_helper(struct ast_channel *chan, struct curl_args *args)
 {
        struct ast_str *escapebuf = ast_str_thread_get(&thread_escapebuf, 16);
@@ -626,6 +652,11 @@
 
        if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl)))) {
                ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
+               return -1;
+       }
+
+       if (url_is_vulnerable(args->url)) {
+               ast_log(LOG_ERROR, "URL '%s' is vulnerable to HTTP injection 
attacks. Aborting CURL() call.\n", args->url);
                return -1;
        }
 
@@ -830,12 +861,62 @@

[... 4313 lines stripped ...]

-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to