[asterisk-commits] mmichelson: branch mmichelson/caller_id r384965 - in /team/mmichelson/caller_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 8 11:22:41 CDT 2013


Author: mmichelson
Date: Mon Apr  8 11:22:37 2013
New Revision: 384965

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384965
Log:
Resolve conflict and reset automerge.


Added:
    team/mmichelson/caller_id/include/asterisk/stasis_channels.h
      - copied unchanged from r384920, team/group/pimp_my_sip/include/asterisk/stasis_channels.h
    team/mmichelson/caller_id/main/stasis_channels.c
      - copied unchanged from r384920, team/group/pimp_my_sip/main/stasis_channels.c
    team/mmichelson/caller_id/res/res_sip/sip_outbound_auth.c
      - copied unchanged from r384920, team/group/pimp_my_sip/res/res_sip/sip_outbound_auth.c
    team/mmichelson/caller_id/res/res_sip_outbound_authenticator_digest.c
      - copied unchanged from r384920, team/group/pimp_my_sip/res/res_sip_outbound_authenticator_digest.c
    team/mmichelson/caller_id/tests/test_stasis_channels.c
      - copied unchanged from r384920, team/group/pimp_my_sip/tests/test_stasis_channels.c
Modified:
    team/mmichelson/caller_id/   (props changed)
    team/mmichelson/caller_id/CHANGES
    team/mmichelson/caller_id/apps/app_dial.c
    team/mmichelson/caller_id/apps/app_stasis.c
    team/mmichelson/caller_id/apps/app_userevent.c
    team/mmichelson/caller_id/apps/stasis_json.c
    team/mmichelson/caller_id/channels/chan_gulp.c
    team/mmichelson/caller_id/include/asterisk/app_stasis.h
    team/mmichelson/caller_id/include/asterisk/channel.h
    team/mmichelson/caller_id/include/asterisk/res_sip.h
    team/mmichelson/caller_id/main/channel.c
    team/mmichelson/caller_id/main/channel_internal_api.c
    team/mmichelson/caller_id/main/dial.c
    team/mmichelson/caller_id/main/features.c
    team/mmichelson/caller_id/main/manager_channels.c
    team/mmichelson/caller_id/main/pbx.c
    team/mmichelson/caller_id/pbx/pbx_realtime.c
    team/mmichelson/caller_id/res/res_sip.c
    team/mmichelson/caller_id/res/res_sip.exports.in
    team/mmichelson/caller_id/res/res_sip/include/res_sip_private.h
    team/mmichelson/caller_id/res/res_sip/location.c
    team/mmichelson/caller_id/res/res_sip/sip_configuration.c
    team/mmichelson/caller_id/res/res_sip/sip_distributor.c
    team/mmichelson/caller_id/res/res_sip/sip_options.c
    team/mmichelson/caller_id/res/res_sip_authenticator_digest.c
    team/mmichelson/caller_id/res/res_sip_session.c

Propchange: team/mmichelson/caller_id/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/mmichelson/caller_id/
------------------------------------------------------------------------------
--- caller_id-integrated (original)
+++ caller_id-integrated Mon Apr  8 11:22:37 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-384898
+/team/group/pimp_my_sip:1-384964

Propchange: team/mmichelson/caller_id/
------------------------------------------------------------------------------
    outbound_auth-integrated = /team/group/pimp_my_sip:1-384900

Propchange: team/mmichelson/caller_id/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr  8 11:22:37 2013
@@ -1,1 +1,1 @@
-/trunk:1-384890
+/trunk:1-384917

Modified: team/mmichelson/caller_id/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/CHANGES?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/CHANGES (original)
+++ team/mmichelson/caller_id/CHANGES Mon Apr  8 11:22:37 2013
@@ -52,6 +52,12 @@
 
  * The deprecated use of | (pipe) as a separator in the channelvars setting in
    manager.conf has been removed.
+
+ * Channel Variables conveyed with a channel no longer contain the name of the
+   channel as part of the key field, i.e., ChanVariable(SIP/foo): bar=baz is now
+   ChanVariable: bar=baz. When multiple channels are present in a single AMI
+   event, the various ChanVariable fields will contain a suffix that specifies
+   which channel they correspond to.
 
 Channel Drivers
 ------------------

Modified: team/mmichelson/caller_id/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/apps/app_dial.c?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/apps/app_dial.c (original)
+++ team/mmichelson/caller_id/apps/app_dial.c Mon Apr  8 11:22:37 2013
@@ -67,6 +67,7 @@
 #include "asterisk/ccss.h"
 #include "asterisk/indications.h"
 #include "asterisk/framehook.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<application name="Dial" language="en_US">
@@ -818,63 +819,6 @@
 	return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
 }
 
-static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring)
-{
-	struct ast_channel *chans[] = { src, dst };
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a dial action has started.</synopsis>
-			<syntax>
-				<parameter name="SubEvent">
-					<para>A sub event type, specifying whether the dial action has begun or ended.</para>
-					<enumlist>
-						<enum name="Begin"/>
-						<enum name="End"/>
-					</enumlist>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	ast_manager_event_multichan(EVENT_FLAG_CALL, "Dial", 2, chans,
-		"SubEvent: Begin\r\n"
-		"Channel: %s\r\n"
-		"Destination: %s\r\n"
-		"CallerIDNum: %s\r\n"
-		"CallerIDName: %s\r\n"
-		"ConnectedLineNum: %s\r\n"
-		"ConnectedLineName: %s\r\n"
-		"UniqueID: %s\r\n"
-		"DestUniqueID: %s\r\n"
-		"Dialstring: %s\r\n",
-		ast_channel_name(src), ast_channel_name(dst),
-		S_COR(ast_channel_caller(src)->id.number.valid, ast_channel_caller(src)->id.number.str, "<unknown>"),
-		S_COR(ast_channel_caller(src)->id.name.valid, ast_channel_caller(src)->id.name.str, "<unknown>"),
-		S_COR(ast_channel_connected(src)->id.number.valid, ast_channel_connected(src)->id.number.str, "<unknown>"),
-		S_COR(ast_channel_connected(src)->id.name.valid, ast_channel_connected(src)->id.name.str, "<unknown>"),
-		ast_channel_uniqueid(src), ast_channel_uniqueid(dst),
-		dialstring ? dialstring : "");
-}
-
-static void senddialendevent(struct ast_channel *src, const char *dialstatus)
-{
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a dial action has ended.</synopsis>
-			<syntax>
-				<parameter name="DialStatus">
-					<para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	ast_manager_event(src, EVENT_FLAG_CALL, "Dial",
-		"SubEvent: End\r\n"
-		"Channel: %s\r\n"
-		"UniqueID: %s\r\n"
-		"DialStatus: %s\r\n",
-		ast_channel_name(src), ast_channel_uniqueid(src), dialstatus);
-}
-
 /*!
  * helper function for wait_for_answer()
  *
@@ -1069,7 +1013,7 @@
 			num->nochan++;
 		} else {
 			ast_channel_lock_both(c, in);
-			senddialevent(in, c, stuff);
+			ast_channel_publish_dial(c, in, stuff, NULL);
 			ast_channel_unlock(in);
 			ast_channel_unlock(c);
 			/* Hangup the original channel now, in case we needed it */
@@ -1089,6 +1033,33 @@
 	char privintro[1024];
 	char status[256];
 };
+
+static const char *hangup_cause_to_dial_status(int hangup_cause)
+{
+	switch(hangup_cause) {
+	case AST_CAUSE_BUSY:
+		return "BUSY";
+	case AST_CAUSE_CONGESTION:
+		return "CONGESTION";
+	case AST_CAUSE_NO_ROUTE_DESTINATION:
+	case AST_CAUSE_UNREGISTERED:
+		return "CHANUNAVAIL";
+	case AST_CAUSE_NO_ANSWER:
+	default:
+		return "NOANSWER";
+	}
+}
+
+static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out_chans, struct ast_channel *exception, const char *status)
+{
+	struct chanlist *outgoing;
+	AST_LIST_TRAVERSE(out_chans, outgoing, node) {
+		if (!outgoing->chan || outgoing->chan == exception) {
+			continue;
+		}
+		ast_channel_publish_dial(in, outgoing->chan, NULL, status);
+	}
+}
 
 static struct ast_channel *wait_for_answer(struct ast_channel *in,
 	struct dial_head *out_chans, int *to, struct ast_flags64 *peerflags,
@@ -1133,6 +1104,7 @@
 				*to = -1;
 				strcpy(pa->status, "CONGESTION");
 				ast_cdr_failed(ast_channel_cdr(in));
+				ast_channel_publish_dial(in, outgoing->chan, NULL, pa->status);
 				return NULL;
 			}
 		}
@@ -1293,6 +1265,7 @@
 #ifdef HAVE_EPOLL
 				ast_poll_channel_del(in, c);
 #endif
+				ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
 				ast_hangup(c);
 				c = o->chan = NULL;
 				ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1333,6 +1306,8 @@
 							}
 						}
 						peer = c;
+						ast_channel_publish_dial(in, peer, NULL, "ANSWER");
+						publish_dial_end_event(in, out_chans, peer, "CANCEL");
 						if (ast_channel_cdr(peer)) {
 							ast_channel_cdr(peer)->answer = ast_tvnow();
 							ast_channel_cdr(peer)->disposition = AST_CDR_ANSWERED;
@@ -1346,9 +1321,10 @@
 							DIAL_NOFORWARDHTML);
 						ast_channel_dialcontext_set(c, "");
 						ast_channel_exten_set(c, "");
-						if (CAN_EARLY_BRIDGE(peerflags, in, peer))
+						if (CAN_EARLY_BRIDGE(peerflags, in, peer)) {
 							/* Setup early bridge if appropriate */
 							ast_channel_early_bridge(in, peer);
+						}
 					}
 					/* If call has been answered, then the eventual hangup is likely to be normal hangup */
 					ast_channel_hangupcause_set(in, AST_CAUSE_NORMAL_CLEARING);
@@ -1357,6 +1333,7 @@
 				case AST_CONTROL_BUSY:
 					ast_verb(3, "%s is busy\n", ast_channel_name(c));
 					ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
+					ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
 					ast_hangup(c);
 					c = o->chan = NULL;
 					ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1365,6 +1342,7 @@
 				case AST_CONTROL_CONGESTION:
 					ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c));
 					ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
+					ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
 					ast_hangup(c);
 					c = o->chan = NULL;
 					ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1572,6 +1550,7 @@
 				*to = -1;
 				strcpy(pa->status, "CANCEL");
 				ast_cdr_noanswer(ast_channel_cdr(in));
+				publish_dial_end_event(in, out_chans, NULL, pa->status);
 				if (f) {
 					if (f->data.uint32) {
 						ast_channel_hangupcause_set(in, f->data.uint32);
@@ -1596,6 +1575,7 @@
 						ast_cdr_noanswer(ast_channel_cdr(in));
 						*result = f->subclass.integer;
 						strcpy(pa->status, "CANCEL");
+						publish_dial_end_event(in, out_chans, NULL, pa->status);
 						ast_frfree(f);
 						ast_channel_unlock(in);
 						if (is_cc_recall) {
@@ -1612,6 +1592,7 @@
 					*to = 0;
 					strcpy(pa->status, "CANCEL");
 					ast_cdr_noanswer(ast_channel_cdr(in));
+					publish_dial_end_event(in, out_chans, NULL, pa->status);
 					ast_frfree(f);
 					if (is_cc_recall) {
 						ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
@@ -1707,6 +1688,7 @@
 
 	if (!*to) {
 		ast_verb(3, "Nobody picked up in %d ms\n", orig);
+		publish_dial_end_event(in, out_chans, NULL, "NOANSWER");
 	}
 	if (!*to || ast_check_hangup(in)) {
 		ast_cdr_noanswer(ast_channel_cdr(in));
@@ -2621,7 +2603,7 @@
 			continue;
 		}
 
-		senddialevent(chan, tmp->chan, tmp->number);
+		ast_channel_publish_dial(chan, tmp->chan, tmp->number, NULL);
 		ast_channel_unlock(chan);
 
 		ast_verb(3, "Called %s\n", tmp->interface);
@@ -3098,7 +3080,6 @@
 	ast_channel_early_bridge(chan, NULL);
 	hanguptree(&out_chans, NULL, ast_channel_hangupcause(chan)==AST_CAUSE_ANSWERED_ELSEWHERE || ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE) ? 1 : 0 ); /* forward 'answered elsewhere' if we received it */
 	pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
-	senddialendevent(chan, pa.status);
 	ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
 
 	if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_INCOMPLETE)) {

Modified: team/mmichelson/caller_id/apps/app_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/apps/app_stasis.c?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/apps/app_stasis.c (original)
+++ team/mmichelson/caller_id/apps/app_stasis.c Mon Apr  8 11:22:37 2013
@@ -38,6 +38,7 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis.h"
 #include "asterisk/strings.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<application name="Stasis" language="en_US">

Modified: team/mmichelson/caller_id/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/apps/app_userevent.c?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/apps/app_userevent.c (original)
+++ team/mmichelson/caller_id/apps/app_userevent.c Mon Apr  8 11:22:37 2013
@@ -34,6 +34,7 @@
 #include "asterisk/manager.h"
 #include "asterisk/app.h"
 #include "asterisk/json.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<application name="UserEvent" language="en_US">

Modified: team/mmichelson/caller_id/apps/stasis_json.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/apps/stasis_json.c?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/apps/stasis_json.c (original)
+++ team/mmichelson/caller_id/apps/stasis_json.c Mon Apr  8 11:22:37 2013
@@ -28,6 +28,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/app_stasis.h"
+#include "asterisk/stasis_channels.h"
 
 struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot)
 {

Modified: team/mmichelson/caller_id/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/channels/chan_gulp.c?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/channels/chan_gulp.c (original)
+++ team/mmichelson/caller_id/channels/chan_gulp.c Mon Apr  8 11:22:37 2013
@@ -684,8 +684,19 @@
 	};
 
 	struct ast_sip_session *session = data;
-	if (ast_sip_send_request("INFO", &body, session->inv_session->dlg, NULL) != PJ_SUCCESS) {
+	struct pjsip_tx_data *tdata;
+
+	if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, &tdata)) {
+		ast_log(LOG_ERROR, "Could not create text video update INFO request\n");
+		return -1;
+	}
+	if (ast_sip_add_body(tdata, &body)) {
+		ast_log(LOG_ERROR, "Could not add body to text video update INFO request\n");
+		return -1;
+	}
+	if (ast_sip_send_request(tdata, session->inv_session->dlg, session->endpoint)) {
 		ast_log(LOG_ERROR, "Could not send text video update INFO request\n");
+		return -1;
 	}
 
 	return 0;

Modified: team/mmichelson/caller_id/include/asterisk/app_stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/include/asterisk/app_stasis.h?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/include/asterisk/app_stasis.h (original)
+++ team/mmichelson/caller_id/include/asterisk/app_stasis.h Mon Apr  8 11:22:37 2013
@@ -48,6 +48,8 @@
 
 #include "asterisk/channel.h"
 #include "asterisk/json.h"
+
+struct ast_channel_snapshot;
 
 /*! @{ */
 

Modified: team/mmichelson/caller_id/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/include/asterisk/channel.h?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/include/asterisk/channel.h (original)
+++ team/mmichelson/caller_id/include/asterisk/channel.h Mon Apr  8 11:22:37 2013
@@ -365,7 +365,7 @@
  * PSTN gateway).
  *
  * \todo Implement settings for transliteration between UTF8 Caller ID names in
- *       to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
+ *       to ASCII Caller ID's (DAHDI). Östen Ã
sklund might be transliterated into
  *       Osten Asklund or Oesten Aasklund depending upon language and person...
  *       We need automatic routines for incoming calls and static settings for
  *       our own accounts.
@@ -3015,7 +3015,7 @@
  *
  * \details
  * This function will generate an effective party id.
- * 
+ *
  * Each party id component of the party id 'base' is overwritten
  * by components of the party id 'overlay' if the overlay
  * component is marked as valid.  However the component 'tag' of
@@ -3788,7 +3788,7 @@
 void ast_channel_unlink(struct ast_channel *chan);
 
 /*!
- * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash 
+ * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
  * on the given channel
  *
  * \param chan channel on which to set the cause information
@@ -4125,69 +4125,6 @@
  */
 struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan);
 
-/*! \addtogroup StasisTopicsAndMessages
- * @{
- */
-
-/*!
- * \since 12
- * \brief Structure representing a snapshot of channel state.
- *
- * While not enforced programmatically, this object is shared across multiple
- * threads, and should be threated as an immutable object.
- */
-struct ast_channel_snapshot {
-	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(name);			/*!< ASCII unique channel name */
-		AST_STRING_FIELD(accountcode);		/*!< Account code for billing */
-		AST_STRING_FIELD(peeraccount);		/*!< Peer account code for billing */
-		AST_STRING_FIELD(userfield);		/*!< Userfield for CEL billing */
-		AST_STRING_FIELD(uniqueid);		/*!< Unique Channel Identifier */
-		AST_STRING_FIELD(linkedid);		/*!< Linked Channel Identifier -- gets propagated by linkage */
-		AST_STRING_FIELD(parkinglot);		/*!< Default parking lot, if empty, default parking lot */
-		AST_STRING_FIELD(hangupsource);		/*!< Who is responsible for hanging up this channel */
-		AST_STRING_FIELD(appl);			/*!< Current application */
-		AST_STRING_FIELD(data);			/*!< Data passed to current application */
-		AST_STRING_FIELD(context);		/*!< Dialplan: Current extension context */
-		AST_STRING_FIELD(exten);		/*!< Dialplan: Current extension number */
-		AST_STRING_FIELD(caller_name);		/*!< Caller ID Name */
-		AST_STRING_FIELD(caller_number);	/*!< Caller ID Number */
-		AST_STRING_FIELD(connected_name);	/*!< Connected Line Name */
-		AST_STRING_FIELD(connected_number);	/*!< Connected Line Number */
-	);
-
-	struct timeval creationtime;	/*!< The time of channel creation */
-	enum ast_channel_state state;	/*!< State of line */
-	int priority;			/*!< Dialplan: Current extension priority */
-	int amaflags;			/*!< AMA flags for billing */
-	int hangupcause;		/*!< Why is the channel hanged up. See causes.h */
-	int caller_pres;		/*!< Caller ID presentation. */
-
-	struct ast_flags flags;		/*!< channel flags of AST_FLAG_ type */
-
-	struct varshead *manager_vars;	/*!< Variables to be appended to manager events */
-};
-
-/*!
- * \since 12
- * \brief Generate a snapshot of the channel state. This is an ao2 object, so
- * ao2_cleanup() to deallocate.
- *
- * \param chan The channel from which to generate a snapshot
- *
- * \retval pointer on success (must be ast_freed)
- * \retval NULL on error
- */
-struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan);
-
-/*!
- * \since 12
- * \brief Message type for \ref ast_channel_snapshot.
- *
- * \retval Message type for \ref ast_channel_snapshot.
- */
-struct stasis_message_type *ast_channel_snapshot_type(void);
-
 /*!
  * \since 12
  * \brief A topic which publishes the events for a particular channel.
@@ -4201,81 +4138,4 @@
  */
 struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
 
-/*!
- * \since 12
- * \brief A topic which publishes the events for all channels.
- * \retval Topic for all channel events.
- */
-struct stasis_topic *ast_channel_topic_all(void);
-
-/*!
- * \since 12
- * \brief A caching topic which caches \ref ast_channel_snapshot messages from
- * ast_channel_events_all(void).
- *
- * \retval Topic for all channel events.
- */
-struct stasis_caching_topic *ast_channel_topic_all_cached(void);
-
-/*!
- * \since 12
- * \brief Blob of data associated with a channel.
- *
- * The \c blob is actually a JSON object of structured data. It has a "type" field
- * which contains the type string describing this blob.
- */
-struct ast_channel_blob {
-	/*! Channel blob is associated with (or NULL for global/all channels) */
-	struct ast_channel_snapshot *snapshot;
-	/*! JSON blob of data */
-	struct ast_json *blob;
-};
-
-/*!
- * \since 12
- * \brief Message type for \ref ast_channel_blob messages.
- *
- * \retval Message type for \ref ast_channel_blob messages.
- */
-struct stasis_message_type *ast_channel_blob_type(void);
-
-/*!
- * \since 12
- * \brief Extracts the type field from a \ref ast_channel_blob.
- * Returned \c char* is still owned by \a obj
- * \param obj Channel blob object.
- * \return Type field value from the blob.
- * \return \c NULL on error.
- */
-const char *ast_channel_blob_json_type(struct ast_channel_blob *obj);
-
-/*!
- * \since 12
- * \brief Creates a \ref ast_channel_blob message.
- *
- * The \a blob JSON object requires a \c "type" field describing the blob. It
- * should also be treated as immutable and not modified after it is put into the
- * message.
- *
- * \param chan Channel blob is associated with, or NULL for global/all channels.
- * \param blob JSON object representing the data.
- * \return \ref ast_channel_blob message.
- * \return \c NULL on error
- */
-struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
-					       struct ast_json *blob);
-
-/*! @} */
-
-/*!
- * \since 12
- * \brief Publish a \ref ast_channel_varset for a channel.
- *
- * \param chan Channel to pulish the event for, or \c NULL for 'none'.
- * \param variable Name of the variable being set
- * \param value Value.
- */
-void ast_channel_publish_varset(struct ast_channel *chan,
-				const char *variable, const char *value);
-
 #endif /* _ASTERISK_CHANNEL_H */

Modified: team/mmichelson/caller_id/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/include/asterisk/res_sip.h?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/include/asterisk/res_sip.h (original)
+++ team/mmichelson/caller_id/include/asterisk/res_sip.h Mon Apr  8 11:22:37 2013
@@ -266,7 +266,7 @@
                 /*! Musiconhold class to suggest that the other side use when placing on hold */
                 AST_STRING_FIELD(mohsuggest);
 		/*! Optional external media address to use in SDP */
-		AST_STRING_FIELD(external_media_address);       
+		AST_STRING_FIELD(external_media_address);
 	);
 	/*! Identification information for this endpoint */
 	struct ast_party_id id;
@@ -278,10 +278,14 @@
 	struct ast_codec_pref prefs;
 	/*! Configured codecs */
 	struct ast_format_cap *codecs;
-	/*! Names of authentication credentials */
-	const char **sip_auths;
+	/*! Names of inbound authentication credentials */
+	const char **sip_inbound_auths;
 	/*! Number of configured auths */
-	size_t num_auths;
+	size_t num_inbound_auths;
+	/*! Names of outbound authentication credentials */
+	const char **sip_outbound_auths;
+	/*! Number of configured outbound auths */
+	size_t num_outbound_auths;
 	/*! DTMF mode to use with this endpoint */
 	enum ast_sip_dtmf_mode dtmf;
 	/*! Whether IPv6 RTP is enabled or not */
@@ -342,13 +346,13 @@
 
 /*!
  * \brief An interchangeable way of handling digest authentication for SIP.
- * 
+ *
  * An authenticator is responsible for filling in the callbacks provided below. Each is called from a publicly available
  * function in res_sip. The authenticator can use configuration or other local policy to determine whether authentication
  * should take place and what credentials should be used when challenging and authenticating a request.
  */
 struct ast_sip_authenticator {
-    /*! 
+    /*!
      * \brief Check if a request requires authentication
      * See ast_sip_requires_authentication for more details
      */
@@ -365,7 +369,28 @@
 	enum ast_sip_check_auth_result (*check_authentication)(struct ast_sip_endpoint *endpoint,
 			pjsip_rx_data *rdata, pjsip_tx_data *tdata);
 };
- 
+
+/*!
+ * \brief an interchangeable way of responding to authentication challenges
+ *
+ * An outbound authenticator takes incoming challenges and formulates a new SIP request with
+ * credentials.
+ */
+struct ast_sip_outbound_authenticator {
+	/*!
+	 * \brief Create a new request with authentication credentials
+	 *
+	 * \param endpoint The SIP endpoint with which Asterisk is communicating
+	 * \param challenge The SIP response with authentication challenge(s)
+	 * \param tsx The transaction in which the challenge was received
+	 * \param new_request The new SIP request with challenge response(s)
+	 * \retval 0 Successfully created new request
+	 * \retval -1 Failed to create a new request
+	 */
+	int (*create_request_with_auth)(const struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *challenge,
+			struct pjsip_transaction *tsx, struct pjsip_tx_data **new_request);
+};
+
 /*!
  * \brief An entity responsible for identifying the source of a SIP message
  */
@@ -391,7 +416,7 @@
  * \retval -1 Failure
  */
 int ast_sip_register_service(pjsip_module *module);
- 
+
 /*!
  * This is the opposite of ast_sip_register_service().  Unregistering a
  * service means that PJSIP will no longer call into the module any more.
@@ -400,7 +425,7 @@
  * \param module The PJSIP module to unregister
  */
 void ast_sip_unregister_service(pjsip_module *module);
- 
+
 /*!
  * \brief Register a SIP authenticator
  *
@@ -417,7 +442,7 @@
  * \retval -1 Failure
  */
 int ast_sip_register_authenticator(struct ast_sip_authenticator *auth);
- 
+
 /*!
  * \brief Unregister a SIP authenticator
  *
@@ -427,7 +452,29 @@
  * \param auth The authenticator to unregister
  */
 void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth);
- 
+
+ /*!
+ * \brief Register an outbound SIP authenticator
+ *
+ * An outbound authenticator is responsible for creating responses to
+ * authentication challenges by remote endpoints.
+ *
+ * \param auth The authenticator to register
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticator *outbound_auth);
+
+/*!
+ * \brief Unregister an outbound SIP authenticator
+ *
+ * When there is no outbound authenticator registered, authentication challenges
+ * will be handled as any other final response would be.
+ *
+ * \param auth The authenticator to unregister
+ */
+void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authenticator *auth);
+
 /*!
  * \brief Register a SIP endpoint identifier
  *
@@ -450,7 +497,7 @@
  * \retval -1 Failure
  */
 int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier);
- 
+
 /*!
  * \brief Unregister a SIP endpoint identifier
  *
@@ -521,14 +568,32 @@
 struct ast_sip_aor *ast_sip_location_retrieve_aor(const char *aor_name);
 
 /*!
+ * \brief Retrieve the first bound contact for an AOR
+ *
+ * \param aor Pointer to the AOR
+ * \retval NULL if no contacts available
+ * \retval non-NULL if contacts available
+ */
+struct ast_sip_contact *ast_sip_location_retrieve_first_aor_contact(const struct ast_sip_aor *aor);
+
+/*!
  * \brief Retrieve all contacts currently available for an AOR
  *
  * \param aor Pointer to the AOR
  *
- * \param NULL if no contacts available
- * \param non-NULL if contacts available
+ * \retval NULL if no contacts available
+ * \retval non-NULL if contacts available
  */
 struct ao2_container *ast_sip_location_retrieve_aor_contacts(const struct ast_sip_aor *aor);
+
+/*!
+ * \brief Retrieve the first bound contact from a list of AORs
+ *
+ * \param aor_list A comma-separated list of AOR names
+ * \retval NULL if no contacts available
+ * \retval non-NULL if contacts available
+ */
+struct ast_sip_contact *ast_sip_location_retrieve_contact_from_aor_list(const char *aor_list);
 
 /*!
  * \brief Retrieve a named contact
@@ -591,6 +656,41 @@
  * \retval 0 success
  */
 int ast_sip_initialize_sorcery_auth(struct ast_sorcery *sorcery);
+
+/*!
+ * \brief Callback called when an outbound request with authentication credentials is to be sent in dialog
+ *
+ * This callback will have the created request on it. The callback's purpose is to do any extra
+ * housekeeping that needs to be done as well as to send the request out.
+ *
+ * This callback is only necessary if working with a PJSIP API that sits between the application
+ * and the dialog layer.
+ *
+ * \param dlg The dialog to which the request belongs
+ * \param tdata The created request to be sent out
+ * \param user_data Data supplied with the callback
+ *
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+typedef int (*ast_sip_dialog_outbound_auth_cb)(pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data);
+
+/*!
+ * \brief Set up outbound authentication on a SIP dialog
+ *
+ * This sets up the infrastructure so that all requests associated with a created dialog
+ * can be re-sent with authentication credentials if the original request is challenged.
+ *
+ * \param dlg The dialog on which requests will be authenticated
+ * \param endpoint The endpoint whom this dialog pertains to
+ * \param cb Callback to call to send requests with authentication
+ * \param user_data Data to be provided to the callback when it is called
+ *
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_dialog_setup_outbound_authentication(pjsip_dialog *dlg, const struct ast_sip_endpoint *endpoint,
+		ast_sip_dialog_outbound_auth_cb cb, void *user_data);
 
 /*!
  * \brief Initialize the distributor module
@@ -644,7 +744,7 @@
  * Servants are where the bulk of SIP work should be performed. These threads
  * exist in order to do the work that Asterisk threads and PJSIP threads hand
  * off to them. Servant threads register themselves with PJLIB, meaning that
- * they are capable of calling PJSIP and PJLIB functions if they wish. 
+ * they are capable of calling PJSIP and PJLIB functions if they wish.
  *
  * \par Serializer
  *
@@ -690,6 +790,18 @@
  * \param endpoint The endpoint that this dialog is communicating with
  */
 void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint);
+
+/*!
+ * \brief Get the endpoint associated with this dialog
+ *
+ * This function increases the refcount of the endpoint by one. Release
+ * the reference once you are finished with the endpoint.
+ *
+ * \param dlg The SIP dialog from which to retrieve the endpoint
+ * \retval NULL No endpoint associated with this dialog
+ * \retval non-NULL The endpoint.
+ */
+struct ast_sip_endpoint *ast_sip_dialog_get_endpoint(pjsip_dialog *dlg);
 
 /*!
  * \brief Pushes a task to SIP servants
@@ -761,26 +873,50 @@
  pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user);
 
 /*!
- * \brief General purpose method for sending a SIP request
- *
- * Its typical use would be to send one-off messages such as an out of dialog
+ * \brief General purpose method for creating a SIP request
+ *
+ * Its typical use would be to create one-off requests such as an out of dialog
  * SIP MESSAGE.
  *
- * The request can either be sent in- or out-of-dialog. If sent in-dialog, the
- * dlg parameter MUST be present. If sent out-of-dialog the endpoint parameter
+ * The request can either be in- or out-of-dialog. If in-dialog, the
+ * dlg parameter MUST be present. If out-of-dialog the endpoint parameter
  * MUST be present. If both are present, then we will assume that the message
  * is to be sent in-dialog.
  *
+ * The uri parameter can be specified if the request should be sent to an explicit
+ * URI rather than one configured on the endpoint.
+ *
  * \param method The method of the SIP request to send
- * \param body The message body for the SIP request
- * \dlg Optional. If specified, the dialog on which to send the message.
- * \endpoint Optional. If specified, the request will be sent out-of-dialog to the endpoint.
- * \retval 0 Success
- * \retval -1 Failure
- */
-int ast_sip_send_request(const char *method, const struct ast_sip_body *body,
-		struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint);
- 
+ * \param dlg Optional. If specified, the dialog on which to request the message.
+ * \param endpoint Optional. If specified, the request will be created out-of-dialog
+ * to the endpoint.
+ * \param uri Optional. If specified, the request will be sent to this URI rather
+ * than one configured for the endpoint.
+ * \param[out] tdata The newly-created request
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
+		struct ast_sip_endpoint *endpoint, const char *uri, pjsip_tx_data **tdata);
+
+/*!
+ * \brief General purpose method for sending a SIP request
+ *
+ * This is a companion function for \ref ast_sip_create_request. The request
+ * created there can be passed to this function, though any request may be
+ * passed in.
+ *
+ * This will automatically set up handling outbound authentication challenges if
+ * they arrive.
+ *
+ * \param tdata The request to send
+ * \param dlg Optional. If specified, the dialog on which the request should be sent
+ * \param endpoint Optional. If specified, the request is sent out-of-dialog to the endpoint.
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint);
+
 /*!
  * \brief Determine if an incoming request requires authentication
  *
@@ -796,7 +932,7 @@
  * \retval 0 The request does not require authentication
  */
 int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
- 
+
 /*!
  * \brief Method to determine authentication status of an incoming request
  *
@@ -812,7 +948,18 @@
  */
 enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint,
 		pjsip_rx_data *rdata, pjsip_tx_data *tdata);
- 
+
+/*!
+ * \brief Create a response to an authentication challenge
+ *
+ * This will call into an outbound authenticator's create_request_with_auth callback
+ * to create a new request with authentication credentials. See the create_request_with_auth
+ * callback in the \ref ast_sip_outbound_authenticator structure for details about
+ * the parameters and return values.
+ */
+int ast_sip_create_request_with_auth(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *challenge,
+		pjsip_transaction *tsx, pjsip_tx_data **new_request);
+
 /*!
  * \brief Determine the endpoint that has sent a SIP message
  *
@@ -826,7 +973,7 @@
  * \retval non-NULL The matching endpoint
  */
 struct ast_sip_endpoint *ast_sip_identify_endpoint(pjsip_rx_data *rdata);
- 
+
 /*!
  * \brief Add a header to an outbound SIP message
  *
@@ -837,7 +984,7 @@
  * \retval -1 Failure
  */
 int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value);
- 
+
 /*!
  * \brief Add a body to an outbound SIP message
  *
@@ -850,7 +997,7 @@
  * \retval -1 Failure
  */
 int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body);
- 
+
 /*!
  * \brief Add a multipart body to an outbound SIP message
  *
@@ -863,7 +1010,7 @@
  * \retval -1 Failure
  */
 int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies);
- 
+
 /*!
  * \brief Append body data to a SIP message
  *
@@ -911,4 +1058,24 @@
  */
 struct ast_sip_endpoint *ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata);
 
+/*!
+ * \brief Retrieve relevant SIP auth structures from sorcery
+ *
+ * \param auth_names The sorcery IDs of auths to retrieve
+ * \param num_auths The number of auths to retrieve
+ * \param[out] out The retrieved auths are stored here
+ */
+int ast_sip_retrieve_auths(const char *auth_names[], size_t num_auths, struct ast_sip_auth **out);
+
+/*!
+ * \brief Clean up retrieved auth structures from memory
+ *
+ * Call this function once you have completed operating on auths
+ * retrieved from \ref ast_sip_retrieve_auths
+ *
+ * \param auths An array of auth structures to clean up
+ * \param num_auths The number of auths in the array
+ */
+void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths);
+
 #endif /* _RES_SIP_H */

Modified: team/mmichelson/caller_id/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/main/channel.c?view=diff&rev=384965&r1=384964&r2=384965
==============================================================================
--- team/mmichelson/caller_id/main/channel.c (original)
+++ team/mmichelson/caller_id/main/channel.c Mon Apr  8 11:22:37 2013
@@ -74,6 +74,7 @@
 #include "asterisk/channel_internal.h"
 #include "asterisk/features.h"
 #include "asterisk/test.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
  ***/
@@ -151,15 +152,6 @@
 
 /*! \brief All active channels on the system */
 static struct ao2_container *channels;
-
-/*! \brief Message type for channel snapshot events */
-static struct stasis_message_type *channel_snapshot_type;
-
-static struct stasis_message_type *channel_blob_type;
-
-struct stasis_topic *channel_topic_all;
-
-struct stasis_caching_topic *channel_topic_all_cached;
 
 /*! \brief map AST_CAUSE's to readable string representations
  *
@@ -223,116 +215,6 @@
 	{ AST_CAUSE_INTERWORKING, "INTERWORKING", "Interworking, unspecified" },
 };
 
-static void publish_channel_state(struct ast_channel *chan)
-{
-	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-
-	snapshot = ast_channel_snapshot_create(chan);
-	if (!snapshot) {
-		ast_log(LOG_ERROR, "Allocation error\n");
-		return;
-	}
-
-	message = stasis_message_create(ast_channel_snapshot_type(), snapshot);
-	if (!message) {
-		return;
-	}
-
-	ast_assert(ast_channel_topic(chan) != NULL);
-	stasis_publish(ast_channel_topic(chan), message);
-}
-
-static void publish_channel_blob(struct ast_channel *chan, struct ast_json *blob)
-{
-	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-	if (blob) {
-		message = ast_channel_blob_create(chan, blob);
-	}
-	if (message) {
-		stasis_publish(ast_channel_topic(chan), message);
-	}
-}
-
-
-static void channel_blob_dtor(void *obj)
-{
-	struct ast_channel_blob *event = obj;
-	ao2_cleanup(event->snapshot);
-	ast_json_unref(event->blob);
-}
-
-struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
-					       struct ast_json *blob)
-{
-	RAII_VAR(struct ast_channel_blob *, obj, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct ast_json *type;
-
-	ast_assert(blob != NULL);
-
-	type = ast_json_object_get(blob, "type");
-	if (type == NULL) {
-		ast_log(LOG_ERROR, "Invalid ast_channel_blob; missing type field");
-		return NULL;
-	}
-
-	obj = ao2_alloc(sizeof(*obj), channel_blob_dtor);
-	if (!obj) {
-		return NULL;
-	}
-
-	if (chan) {
-		obj->snapshot = ast_channel_snapshot_create(chan);
-		if (obj->snapshot == NULL) {
-			return NULL;
-		}
-	}
-
-	obj->blob = ast_json_ref(blob);
-
-	msg = stasis_message_create(ast_channel_blob_type(), obj);
-	if (!msg) {
-		return NULL;
-	}
-
-	ao2_ref(msg, +1);
-	return msg;
-}
-
-const char *ast_channel_blob_json_type(struct ast_channel_blob *obj)
-{
-	if (obj == NULL) {
-		return NULL;
-	}
-

[... 1613 lines stripped ...]



More information about the asterisk-commits mailing list