[asterisk-commits] mmichelson: branch mmichelson/outbound_auth r383211 - in /team/mmichelson/out...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 15 09:00:47 CDT 2013


Author: mmichelson
Date: Fri Mar 15 09:00:43 2013
New Revision: 383211

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


Added:
    team/mmichelson/outbound_auth/res/res_sip/location.c
      - copied unchanged from r383209, team/group/pimp_my_sip/res/res_sip/location.c
    team/mmichelson/outbound_auth/res/res_sip_nat.c
      - copied unchanged from r383209, team/group/pimp_my_sip/res/res_sip_nat.c
Modified:
    team/mmichelson/outbound_auth/   (props changed)
    team/mmichelson/outbound_auth/channels/chan_gulp.c
    team/mmichelson/outbound_auth/channels/chan_sip.c
    team/mmichelson/outbound_auth/include/asterisk/res_sip.h
    team/mmichelson/outbound_auth/include/asterisk/res_sip_session.h
    team/mmichelson/outbound_auth/include/asterisk/stasis.h
    team/mmichelson/outbound_auth/main/channel_internal_api.c
    team/mmichelson/outbound_auth/main/http.c
    team/mmichelson/outbound_auth/main/manager.c
    team/mmichelson/outbound_auth/main/stasis.c
    team/mmichelson/outbound_auth/main/stasis_cache.c
    team/mmichelson/outbound_auth/main/tcptls.c
    team/mmichelson/outbound_auth/res/res_sip.c
    team/mmichelson/outbound_auth/res/res_sip.exports.in
    team/mmichelson/outbound_auth/res/res_sip/config_transport.c
    team/mmichelson/outbound_auth/res/res_sip/sip_configuration.c
    team/mmichelson/outbound_auth/res/res_sip/sip_distributor.c
    team/mmichelson/outbound_auth/res/res_sip_endpoint_identifier_ip.c
    team/mmichelson/outbound_auth/res/res_sip_sdp_audio.c
    team/mmichelson/outbound_auth/res/res_sip_session.c
    team/mmichelson/outbound_auth/tests/test_stasis.c

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

Propchange: team/mmichelson/outbound_auth/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/mmichelson/outbound_auth/
------------------------------------------------------------------------------
--- outbound_auth-integrated (original)
+++ outbound_auth-integrated Fri Mar 15 09:00:43 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-383136
+/team/group/pimp_my_sip:1-383210

Propchange: team/mmichelson/outbound_auth/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Mar 15 09:00:43 2013
@@ -1,1 +1,1 @@
-/trunk:1-383127
+/trunk:1-383175

Modified: team/mmichelson/outbound_auth/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/channels/chan_gulp.c?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/channels/chan_gulp.c (original)
+++ team/mmichelson/outbound_auth/channels/chan_gulp.c Fri Mar 15 09:00:43 2013
@@ -57,8 +57,59 @@
 #include "asterisk/res_sip.h"
 #include "asterisk/res_sip_session.h"
 
+/*** DOCUMENTATION
+	<function name="GULP_DIAL_CONTACTS" language="en_US">
+		<synopsis>
+			Return a dial string for dialing all contacts on an AOR.
+		</synopsis>
+		<syntax>
+			<parameter name="endpoint" required="true">
+				<para>Name of the endpoint</para>
+			</parameter>
+			<parameter name="aor" required="false">
+				<para>Name of an AOR to use, if not specified the configured AORs on the endpoint are used</para>
+			</parameter>
+			<parameter name="request_user" required="false">
+				<para>Optional request user to use in the request URI</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>Returns a properly formatted dial string for dialing all contacts on an AOR.</para>
+		</description>
+	</function>
+ ***/
+
 static const char desc[] = "Gulp SIP Channel";
 static const char channel_type[] = "Gulp";
+
+/*!
+ * \brief Positions of various media
+ */
+enum sip_session_media_position {
+	/*! \brief First is audio */
+	SIP_MEDIA_AUDIO = 0,
+	/*! \brief Second is video */
+	SIP_MEDIA_VIDEO,
+	/*! \brief Last is the size for media details */
+	SIP_MEDIA_SIZE,
+};
+
+struct gulp_pvt {
+	struct ast_sip_session *session;
+	struct ast_sip_session_media *media[SIP_MEDIA_SIZE];
+};
+
+static void gulp_pvt_dtor(void *obj)
+{
+	struct gulp_pvt *pvt = obj;
+	int i;
+	ao2_cleanup(pvt->session);
+	pvt->session = NULL;
+	for (i = 0; i < SIP_MEDIA_SIZE; ++i) {
+		ao2_cleanup(pvt->media[i]);
+		pvt->media[i] = NULL;
+	}
+}
 
 /* \brief Asterisk core interaction functions */
 static struct ast_channel *gulp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause);
@@ -107,17 +158,95 @@
 	.incoming_response = gulp_incoming_response,
 };
 
+/*! \brief Dialplan function for constructing a dial string for calling all contacts */
+static int gulp_dial_contacts(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(endpoint_name);
+		AST_APP_ARG(aor_name);
+		AST_APP_ARG(request_user);
+	);
+	RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
+	const char *aor_name;
+	char *rest;
+	RAII_VAR(struct ast_str *, dial, NULL, ast_free_ptr);
+
+	AST_STANDARD_APP_ARGS(args, data);
+
+	if (ast_strlen_zero(args.endpoint_name)) {
+		ast_log(LOG_WARNING, "An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
+		return -1;
+	} else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", args.endpoint_name))) {
+		ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);
+		return -1;
+	}
+
+	aor_name = S_OR(args.aor_name, endpoint->aors);
+
+	if (ast_strlen_zero(aor_name)) {
+		ast_log(LOG_WARNING, "No AOR has been provided and no AORs are configured on endpoint '%s'\n", args.endpoint_name);
+		return -1;
+	} else if (!(dial = ast_str_create(len))) {
+		ast_log(LOG_WARNING, "Could not get enough buffer space for dialing contacts\n");
+		return -1;
+	} else if (!(rest = ast_strdupa(aor_name))) {
+		ast_log(LOG_WARNING, "Could not duplicate provided AORs\n");
+		return -1;
+	}
+
+	while ((aor_name = strsep(&rest, ","))) {
+		RAII_VAR(struct ast_sip_aor *, aor, ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
+		RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
+		struct ao2_iterator it_contacts;
+		struct ast_sip_contact *contact;
+
+		if (!aor) {
+			/* If the AOR provided is not found skip it, there may be more */
+			continue;
+		} else if (!(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
+			/* No contacts are available, skip it as well */
+			continue;
+		} else if (!ao2_container_count(contacts)) {
+			/* We were given a container but no contacts are in it... */
+			continue;
+		}
+
+		it_contacts = ao2_iterator_init(contacts, 0);
+		for (; (contact = ao2_iterator_next(&it_contacts)); ao2_ref(contact, -1)) {
+			ast_str_append(&dial, -1, "Gulp/");
+
+			if (!ast_strlen_zero(args.request_user)) {
+				ast_str_append(&dial, -1, "%s@", args.request_user);
+			}
+			ast_str_append(&dial, -1, "%s/%s&", args.endpoint_name, contact->uri);
+		}
+		ao2_iterator_destroy(&it_contacts);
+	}
+
+	/* Trim the '&' at the end off */
+	ast_str_truncate(dial, ast_str_strlen(dial) - 1);
+
+	ast_copy_string(buf, ast_str_buffer(dial), len);
+
+	return 0;
+}
+
+static struct ast_custom_function gulp_dial_contacts_function = {
+	.name = "GULP_DIAL_CONTACTS",
+	.read = gulp_dial_contacts,
+};
+
 /*! \brief Function called by RTP engine to get local audio RTP peer */
 static enum ast_rtp_glue_result gulp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(chan);
-
-	if (!session || !session->media[AST_SIP_MEDIA_AUDIO].rtp) {
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(chan);
+
+	if (!pvt || !pvt->session || !pvt->media[SIP_MEDIA_AUDIO]->rtp) {
 		return AST_RTP_GLUE_RESULT_FORBID;
 	}
 
-	ao2_ref(session->media[AST_SIP_MEDIA_AUDIO].rtp, +1);
-	*instance = session->media[AST_SIP_MEDIA_AUDIO].rtp;
+	*instance = pvt->media[SIP_MEDIA_AUDIO]->rtp;
+	ao2_ref(*instance, +1);
 
 	return AST_RTP_GLUE_RESULT_LOCAL;
 }
@@ -146,16 +275,28 @@
 {
 	struct ast_channel *chan;
 	struct ast_format fmt;
+	struct gulp_pvt *pvt;
+
+	if (!(pvt = ao2_alloc(sizeof(*pvt), gulp_pvt_dtor))) {
+		return NULL;
+	}
 
 	if (!(chan = ast_channel_alloc(1, state, "", S_OR(cid_name, ""), "", "", "", linkedid, 0, "Gulp/%s-%.*s", ast_sorcery_object_get_id(session->endpoint),
 		(int)session->inv_session->dlg->call_id->id.slen, session->inv_session->dlg->call_id->id.ptr))) {
+		ao2_cleanup(pvt);
 		return NULL;
 	}
 
 	ast_channel_tech_set(chan, &gulp_tech);
 
 	ao2_ref(session, +1);
-	ast_channel_tech_pvt_set(chan, session);
+	pvt->session = session;
+	/* If res_sip_session is ever updated to create/destroy ast_sip_session_media
+	 * during a call such as if multiple same-type stream support is introduced,
+	 * these will need to be recaptured as well */
+	pvt->media[SIP_MEDIA_AUDIO] = ao2_find(session->media, "audio", OBJ_KEY);
+	pvt->media[SIP_MEDIA_VIDEO] = ao2_find(session->media, "video", OBJ_KEY);
+	ast_channel_tech_pvt_set(chan, pvt);
 
 	ast_format_cap_copy(ast_channel_nativeformats(chan), session->endpoint->codecs);
 	ast_codec_choose(&session->endpoint->prefs, session->endpoint->codecs, 1, &fmt);
@@ -195,7 +336,8 @@
 /*! \brief Function called by core when we should answer a Gulp session */
 static int gulp_answer(struct ast_channel *ast)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct ast_sip_session *session = pvt->session;
 
 	if (ast_channel_state(ast) == AST_STATE_UP) {
 		return 0;
@@ -215,15 +357,20 @@
 /*! \brief Function called by core to read any waiting frames */
 static struct ast_frame *gulp_read(struct ast_channel *ast)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
 	struct ast_frame *f;
+	struct ast_sip_session_media *media = pvt->media[SIP_MEDIA_AUDIO];
+
+	if (!media) {
+		return &ast_null_frame;
+	}
 
 	switch (ast_channel_fdno(ast)) {
 	case 0:
-		f = ast_rtp_instance_read(session->media[AST_SIP_MEDIA_AUDIO].rtp, 0);
+		f = ast_rtp_instance_read(media->rtp, 0);
 		break;
 	case 1:
-		f = ast_rtp_instance_read(session->media[AST_SIP_MEDIA_AUDIO].rtp, 1);
+		f = ast_rtp_instance_read(media->rtp, 1);
 		break;
 	default:
 		f = &ast_null_frame;
@@ -244,11 +391,17 @@
 /*! \brief Function called by core to write frames */
 static int gulp_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
 	int res = 0;
+	struct ast_sip_session_media *media;
 
 	switch (frame->frametype) {
 	case AST_FRAME_VOICE:
+		media = pvt->media[SIP_MEDIA_AUDIO];
+
+		if (!media) {
+			return 0;
+		}
 		if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
 			char buf[256];
 
@@ -260,8 +413,8 @@
 				ast_getformatname(ast_channel_writeformat(ast)));
 			return 0;
 		}
-		if (session->media[AST_SIP_MEDIA_AUDIO].rtp) {
-			res = ast_rtp_instance_write(session->media[AST_SIP_MEDIA_AUDIO].rtp, frame);
+		if (media->rtp) {
+			res = ast_rtp_instance_write(media->rtp, frame);
 		}
 		break;
 	default:
@@ -287,7 +440,8 @@
 /*! \brief Function called by core to change the underlying owner channel */
 static int gulp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(newchan);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(newchan);
+	struct ast_sip_session *session = pvt->session;
 	struct fixup_data fix_data;
 	fix_data.session = session;
 	fix_data.chan = newchan;
@@ -359,7 +513,8 @@
 static int gulp_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 	int res = 0;
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct ast_sip_session *session = pvt->session;
 	int response_code = 0;
 
 	switch (condition) {
@@ -448,14 +603,18 @@
 /*! \brief Function called by core to start a DTMF digit */
 static int gulp_digit_begin(struct ast_channel *chan, char digit)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(chan);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(chan);
+	struct ast_sip_session *session = pvt->session;
 	int res = 0;
+	struct ast_sip_session_media *media = pvt->media[SIP_MEDIA_AUDIO];
 
 	switch (session->endpoint->dtmf) {
 	case AST_SIP_DTMF_RFC_4733:
-		if (session->media[AST_SIP_MEDIA_AUDIO].rtp) {
-			ast_rtp_instance_dtmf_begin(session->media[AST_SIP_MEDIA_AUDIO].rtp, digit);
-		}
+		if (!media || !media->rtp) {
+			return -1;
+		}
+
+		ast_rtp_instance_dtmf_begin(media->rtp, digit);
 	case AST_SIP_DTMF_NONE:
 		break;
 	case AST_SIP_DTMF_INBAND:
@@ -471,17 +630,21 @@
 /*! \brief Function called by core to stop a DTMF digit */
 static int gulp_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct ast_sip_session *session = pvt->session;
 	int res = 0;
+	struct ast_sip_session_media *media = pvt->media[SIP_MEDIA_AUDIO];
 
 	switch (session->endpoint->dtmf) {
 	case AST_SIP_DTMF_INFO:
 		/* TODO: Send INFO dtmf here */
 		break;
 	case AST_SIP_DTMF_RFC_4733:
-		if (session->media[AST_SIP_MEDIA_AUDIO].rtp) {
-			ast_rtp_instance_dtmf_end_with_duration(session->media[AST_SIP_MEDIA_AUDIO].rtp, digit, duration);
-		}
+		if (!media || !media->rtp) {
+			return -1;
+		}
+
+		ast_rtp_instance_dtmf_end_with_duration(media->rtp, digit, duration);
 	case AST_SIP_DTMF_NONE:
 		break;
 	case AST_SIP_DTMF_INBAND:
@@ -510,7 +673,8 @@
 /*! \brief Function called by core to actually start calling a remote party */
 static int gulp_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct ast_sip_session *session = pvt->session;
 
 	ao2_ref(session, +1);
 	if (ast_sip_push_task_synchronous(session->serializer, call, session)) {
@@ -597,7 +761,8 @@
 	pjsip_tx_data *packet = NULL;
 	struct hangup_data *h_data = data;
 	struct ast_channel *ast = h_data->chan;
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct ast_sip_session *session = pvt->session;
 	int cause = h_data->cause;
 
 	if (((status = pjsip_inv_end_session(session->inv_session, cause ? cause : 603, NULL, &packet)) == PJ_SUCCESS) && packet) {
@@ -611,7 +776,7 @@
 	session->channel = NULL;
 	ast_channel_tech_pvt_set(ast, NULL);
 
-	ao2_cleanup(session);
+	ao2_cleanup(pvt);
 	ao2_cleanup(h_data);
 	return 0;
 }
@@ -619,7 +784,8 @@
 /*! \brief Function called by core to hang up a Gulp session */
 static int gulp_hangup(struct ast_channel *ast)
 {
-	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
+	struct ast_sip_session *session = pvt->session;
 	int cause = hangup_cause2sip(ast_channel_hangupcause(session->channel));
 	struct hangup_data *h_data = hangup_data_alloc(cause, ast);
 	if (!h_data) {
@@ -640,35 +806,56 @@
 	session->channel = NULL;
 	ast_channel_tech_pvt_set(ast, NULL);
 
-	ao2_cleanup(session);
+	ao2_cleanup(pvt);
 	return -1;
 }
 
 struct request_data {
 	struct ast_sip_session *session;
 	const char *dest;
+	int cause;
 };
 
 static int request(void *obj)
 {
 	struct request_data *req_data = obj;
-	RAII_VAR(struct ast_sip_endpoint *, endpoint, ast_sip_endpoint_alloc("constant"), ao2_cleanup);
+	char *tmp = ast_strdupa(req_data->dest), *endpoint_name = NULL, *request_user = NULL;
+	RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
 	struct ast_sip_session *session = NULL;
-
-	if (!endpoint) {
-		return -1;
-	}
-
-	/* TODO: This needs to actually grab a proper endpoint and such */
-	ast_string_field_set(endpoint, context, "default");
-	ast_parse_allow_disallow(&endpoint->prefs, endpoint->codecs, "ulaw", 1);
-	endpoint->min_se = 90;
-	endpoint->sess_expires = 1800;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(endpoint);
+		AST_APP_ARG(aor);
+	);
+
+	if (ast_strlen_zero(tmp)) {
+		ast_log(LOG_ERROR, "Unable to create Gulp channel with empty destination\n");
+		req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+		return -1;
+	}
+
+	AST_NONSTANDARD_APP_ARGS(args, tmp, '/');
 	endpoint->sip_outbound_auths = ast_calloc(1, sizeof(char *));
 	endpoint->sip_outbound_auths[0] = ast_strdup("bob-auth");
 	endpoint->num_outbound_auths = 1;
 
-	if (!(session = ast_sip_session_create_outgoing(endpoint, req_data->dest))) {
+	/* If a request user has been specified extract it from the endpoint name portion */
+	if ((endpoint_name = strchr(args.endpoint, '@'))) {
+		request_user = args.endpoint;
+		*endpoint_name++ = '\0';
+	} else {
+		endpoint_name = args.endpoint;
+	}
+
+	if (ast_strlen_zero(endpoint_name)) {
+		ast_log(LOG_ERROR, "Unable to create Gulp channel with empty endpoint name\n");
+		req_data->cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+	} else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
+		ast_log(LOG_ERROR, "Unable to create Gulp channel - endpoint '%s' was not found\n", endpoint_name);
+		req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;
+		return -1;
+	}
+
+	if (!(session = ast_sip_session_create_outgoing(endpoint, args.aor, request_user))) {
 		return -1;
 	}
 
@@ -685,6 +872,7 @@
 	req_data.dest = data;
 
 	if (ast_sip_push_task_synchronous(NULL, request, &req_data)) {
+		*cause = req_data.cause;
 		return NULL;
 	}
 
@@ -860,6 +1048,10 @@
 {
 	struct pjsip_status_line status = rdata->msg_info.msg->line.status;
 
+	if (!session->channel) {
+		return;
+	}
+
 	switch (status.code) {
 	case 180:
 		ast_queue_control(session->channel, AST_CONTROL_RINGING);
@@ -903,6 +1095,11 @@
 		goto end;
 	}
 
+	if (ast_custom_function_register(&gulp_dial_contacts_function)) {
+		ast_log(LOG_ERROR, "Unable to register GULP_DIAL_CONTACTS dialplan function\n");
+		goto end;
+	}
+
 	if (ast_sip_session_register_supplement(&gulp_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register Gulp supplement\n");
 		goto end;
@@ -911,6 +1108,8 @@
 	return 0;
 
 end:
+	ast_custom_function_unregister(&gulp_dial_contacts_function);
+	ast_channel_unregister(&gulp_tech);
 	ast_rtp_glue_unregister(&gulp_rtp_glue);
 
 	return AST_MODULE_LOAD_FAILURE;
@@ -926,6 +1125,7 @@
 static int unload_module(void)
 {
 	ast_sip_session_unregister_supplement(&gulp_supplement);
+	ast_custom_function_unregister(&gulp_dial_contacts_function);
 	ast_channel_unregister(&gulp_tech);
 	ast_rtp_glue_unregister(&gulp_rtp_glue);
 

Modified: team/mmichelson/outbound_auth/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/channels/chan_sip.c?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/channels/chan_sip.c (original)
+++ team/mmichelson/outbound_auth/channels/chan_sip.c Fri Mar 15 09:00:43 2013
@@ -31646,8 +31646,11 @@
 			continue;
 		}
 
-		/* handle tls conf */
-		if (!ast_tls_read_conf(&default_tls_cfg, &sip_tls_desc, v->name, v->value)) {
+		/* handle tls conf, don't allow setting of tlsverifyclient as it isn't supported by chan_sip */
+		if (!strcasecmp(v->name, "tlsverifyclient")) {
+			ast_log(LOG_WARNING, "Ignoring unsupported option 'tlsverifyclient'\n");
+			continue;
+		} else if (!ast_tls_read_conf(&default_tls_cfg, &sip_tls_desc, v->name, v->value)) {
 			continue;
 		}
 

Modified: team/mmichelson/outbound_auth/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/include/asterisk/res_sip.h?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/include/asterisk/res_sip.h (original)
+++ team/mmichelson/outbound_auth/include/asterisk/res_sip.h Fri Mar 15 09:00:43 2013
@@ -28,6 +28,8 @@
 #include "asterisk/channel.h"
 /* Needed for ast_sorcery */
 #include "asterisk/sorcery.h"
+/* Needed for ast_dnsmgr */
+#include "asterisk/dnsmgr.h"
 /* Needed for pj_sockaddr */
 #include <pjlib.h>
 
@@ -39,6 +41,7 @@
 struct pjsip_transport;
 struct pjsip_tpfactory;
 struct pjsip_tls_setting;
+struct pjsip_tpselector;
 
 /*!
  * \brief Structure for SIP transport information
@@ -91,6 +94,10 @@
 		AST_STRING_FIELD(privkey_file);
 		/*! Password to open the private key */
 		AST_STRING_FIELD(password);
+		/*! External signaling address */
+		AST_STRING_FIELD(external_signaling_address);
+		/*! External media address */
+		AST_STRING_FIELD(external_media_address);
 		);
 	/*! Type of transport */
 	enum ast_sip_transport_type type;
@@ -98,43 +105,58 @@
 	pj_sockaddr host;
 	/*! Number of simultaneous asynchronous operations */
 	unsigned int async_operations;
+	/*! Optional external port for signaling */
+	unsigned int external_signaling_port;
 	/*! TLS settings */
 	pjsip_tls_setting tls;
 	/*! Configured TLS ciphers */
 	pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS];
+	/*! Optional local network information, used for NAT purposes */
+	struct ast_ha *localnet;
+	/*! DNS manager for refreshing the external address */
+	struct ast_dnsmgr_entry *external_address_refresher;
+	/*! Optional external address information */
+	struct ast_sockaddr external_address;
 	/*! Transport state information */
 	struct ast_sip_transport_state *state;
 };
 
 /*!
+ * \brief Structure for SIP nat hook information
+ */
+struct ast_sip_nat_hook {
+	/*! Sorcery object details */
+	SORCERY_OBJECT(details);
+	/*! Callback for when a message is going outside of our local network */
+	void (*outgoing_external_message)(struct pjsip_tx_data *tdata, struct ast_sip_transport *transport);
+};
+
+/*!
  * \brief Contact associated with an address of record
  */
 struct ast_sip_contact {
+	/*! Sorcery object details, the id is the aor name plus a random string */
+	SORCERY_OBJECT(details);
 	AST_DECLARE_STRING_FIELDS(
-		/* XXX This may work better as an object instead of a string */
 		/*! Full URI of the contact */
 		AST_STRING_FIELD(uri);
 	);
-	/*! Absolute time that this contact expires */
-	time_t expiration_time;
-	/*! Next list item */
-	AST_LIST_ENTRY(ast_sip_contact) next;
+	/*! Absolute time that this contact is no longer valid after */
+	struct timeval expiration_time;
 };
 
 /*!
  * \brief A SIP address of record
  */
 struct ast_sip_aor {
-	AST_DECLARE_STRING_FIELDS(
-		/*! Name of the address of record */
-		AST_STRING_FIELD(name);
-	);
+	/*! Sorcery object details, the id is the AOR name */
+	SORCERY_OBJECT(details);
 	/*! Default contact expiration if one is not provided in the contact */
-	int expiration;
-	/*! Domain for the AOR */
-	struct ast_sip_domain *domain;
-	/*! Contacts bound to this AOR */
-	AST_LIST_HEAD_NOLOCK(, ast_sip_contact) contacts;
+	unsigned int default_expiration;
+	/*! Maximum number of external contacts, 0 to disable */
+	unsigned int max_contacts;
+	/*! Any permanent configured contacts */
+	struct ao2_container *permanent_contacts;
 };
 
 /*!
@@ -223,8 +245,14 @@
 		AST_STRING_FIELD(context);
 		/*! Name of an explicit transport to use */
 		AST_STRING_FIELD(transport);
+		/*! Outbound proxy to use */
+		AST_STRING_FIELD(outbound_proxy);
+		/*! Explicit AORs to dial if none are specified */
+		AST_STRING_FIELD(aors);
                 /*! 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);       
 	);
 	/*! Identification information for this endpoint */
 	struct ast_party_id id;
@@ -250,8 +278,14 @@
 	unsigned int rtp_ipv6;
 	/*! Whether symmetric RTP is enabled or not */
 	unsigned int rtp_symmetric;
+	/*! Whether ICE support is enabled or not */
+	unsigned int ice_support;
 	/*! Whether to use the "ptime" attribute received from the endpoint or not */
 	unsigned int use_ptime;
+	/*! Whether to force using the source IP address/port for sending responses */
+	unsigned int force_rport;
+	/*! Whether to rewrite the Contact header with the source IP address/port or not */
+	unsigned int rewrite_contact;
 	/*! Enabled SIP extensions */
 	unsigned int extensions;
 	/*! Minimum session expiration period, in seconds */
@@ -266,31 +300,6 @@
 	enum ast_sip_endpoint_identifier_type ident_method;
 };
 
-/*!
- * \brief Given an endpoint, get its IP address
- *
- * \param endpoint The endpoint whose location is desired
- * \param[out] location_buf The IP address and port of the endpoint, as a string
- * \param size The size of the location buffer
- * \return void
- *
- * XXX The usefulness of retrieving an IP address is limited. It's more
- * useful to get a hostname or FQDN so that the location can be resolved.
- */
-void ast_sip_endpoint_get_location(const struct ast_sip_endpoint *endpoint, char *location_buf, size_t size);
-
-/*!
- * \brief Given an IP address, get the SIP endpoint that is located there.
- *
- * The returned endpoint will need to have its reference count decremented with ao2_ref()
- * once the caller has finished using it.
- *
- * \param addr The IP address
- * \retval NULL Could not find an endpoint with this IP address
- * \retval non-NULL The endpoint with this IP address
- */
-struct ast_sip_endpoint *ast_sip_get_endpoint_from_location(const char *addr);
- 
 /*!
  * \brief Possible returns from ast_sip_check_authentication
  */
@@ -466,6 +475,78 @@
 int ast_sip_initialize_sorcery_transport(struct ast_sorcery *sorcery);
 
 /*!
+ * \brief Initialize location support on a sorcery instance
+ *
+ * \param sorcery The sorcery instance
+ *
+ * \retval -1 failure
+ * \retval 0 success
+ */
+int ast_sip_initialize_sorcery_location(struct ast_sorcery *sorcery);
+
+/*!
+ * \brief Retrieve a named AOR
+ *
+ * \param aor_name Name of the AOR
+ *
+ * \retval NULL if not found
+ * \retval non-NULL if found
+ */
+struct ast_sip_aor *ast_sip_location_retrieve_aor(const char *aor_name);
+
+/*!
+ * \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
+ */
+struct ao2_container *ast_sip_location_retrieve_aor_contacts(const struct ast_sip_aor *aor);
+
+/*!
+ * \brief Retrieve a named contact
+ *
+ * \param contact_name Name of the contact
+ *
+ * \retval NULL if not found
+ * \retval non-NULL if found
+ */
+struct ast_sip_contact *ast_sip_location_retrieve_contact(const char *contact_name);
+
+/*!
+ * \brief Add a new contact to an AOR
+ *
+ * \param aor Pointer to the AOR
+ * \param uri Full contact URI
+ * \param expiration_time Optional expiration time of the contact
+ *
+ * \retval -1 failure
+ * \retval 0 success
+ */
+int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time);
+
+/*!
+ * \brief Update a contact
+ *
+ * \param contact New contact object with details
+ *
+ * \retval -1 failure
+ * \retval 0 success
+ */
+int ast_sip_location_update_contact(struct ast_sip_contact *contact);
+
+/*!
+* \brief Delete a contact
+*
+* \param contact Contact object to delete
+*
+* \retval -1 failure
+* \retval 0 success
+*/
+int ast_sip_location_delete_contact(struct ast_sip_contact *contact);
+
+/*!
  * \brief Initialize authentication support on a sorcery instance
  *
  * \param sorcery The sorcery instance
@@ -636,6 +717,18 @@
 };
 
 /*!
+ * \brief General purpose method for creating a dialog with an endpoint
+ *
+ * \param endpoint A pointer to the endpoint
+ * \param aor_name Optional name of the AOR to target, may even be an explicit SIP URI
+ * \param request_user Optional user to place into the target URI
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+ 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

Modified: team/mmichelson/outbound_auth/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/include/asterisk/res_sip_session.h?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/include/asterisk/res_sip_session.h (original)
+++ team/mmichelson/outbound_auth/include/asterisk/res_sip_session.h Fri Mar 15 09:00:43 2013
@@ -25,6 +25,7 @@
 
 /* Forward declarations */
 struct ast_sip_endpoint;
+struct ast_sip_transport;
 struct pjsip_inv_session;
 struct ast_channel;
 struct ast_datastore;
@@ -37,17 +38,7 @@
 struct pjmedia_sdp_session;
 struct ast_rtp_instance;
 
-/*!
- * \brief Positions of various media
- */
-enum ast_sip_session_media_position {
-	/*! \brief First is audio */
-	AST_SIP_MEDIA_AUDIO = 0,
-	/*! \brief Second is video */
-	AST_SIP_MEDIA_VIDEO,
-	/*! \brief Last is the size for media details */
-	AST_SIP_MEDIA_SIZE,
-};
+struct ast_sip_session_sdp_handler;
 
 /*!
  * \brief A structure containing SIP session media information
@@ -55,8 +46,12 @@
 struct ast_sip_session_media {
 	/*! \brief RTP instance itself */
 	struct ast_rtp_instance *rtp;
+	/*! \brief SDP handler that setup the RTP */
+	struct ast_sip_session_sdp_handler *handler;
 	/*! \brief Stream is on hold */
 	unsigned int held:1;
+	/*! \brief Stream type this session media handles */
+	char stream_type[1];
 };
 
 /*!
@@ -81,7 +76,7 @@
 	/* Datastores added to the session by supplements to the session */
 	struct ao2_container *datastores;
 	/* Media streams */
-	struct ast_sip_session_media media[AST_SIP_MEDIA_SIZE];
+	struct ao2_container *media;
 	/* Serializer for tasks relating to this SIP session */
 	struct ast_taskprocessor *serializer;
 };
@@ -166,34 +161,45 @@
 	/*!
 	 * \brief Set session details based on a stream in an incoming SDP offer or answer
 	 * \param session The session for which the media is being negotiated
+	 * \param session_media The media to be setup for this session
 	 * \param sdp The entire SDP. Useful for getting "global" information, such as connections or attributes
 	 * \param stream The stream on which to operate
 	 * \retval 0 The stream was not handled by this handler. If there are other registered handlers for this stream type, they will be called.
 	 * \retval <0 There was an error encountered. No further operation will take place and the current negotiation will be abandoned.
 	 * \retval >0 The stream was handled by this handler. No further handler of this stream type will be called.
 	 */
-	int (*negotiate_incoming_sdp_stream)(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream);
+	int (*negotiate_incoming_sdp_stream)(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream);
 	/*!
 	 * \brief Create an SDP media stream and add it to the outgoing SDP offer or answer
 	 * \param session The session for which media is being added
+	 * \param session_media The media to be setup for this session
 	 * \param stream The stream on which to operate
 	 * \retval 0 The stream was not handled by this handler. If there are other registered handlers for this stream type, they will be called.
 	 * \retval <0 There was an error encountered. No further operation will take place and the current negotiation will be abandoned.
 	 * \retval >0 The stream was handled by this handler. No further handler of this stream type will be called.
 	 */
-	int (*handle_incoming_sdp_stream)(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, struct pjmedia_sdp_media *stream);
+	int (*handle_incoming_sdp_stream)(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *sdp, struct pjmedia_sdp_media *stream);
 	/*!
 	 * \brief Create an SDP media stream and add it to the outgoing SDP offer or answer
 	 * \param session The session for which media is being added
+	 * \param session_media The media to be setup for this session
 	 * \param sdp The entire SDP as currently built
 	 * \retval 0 This handler has no stream to add. If there are other registered handlers for this stream type, they will be called.
 	 * \retval <0 There was an error encountered. No further operation will take place and the current SDP negotiation will be abandoned.
 	 * \retval >0 The handler has a stream to be added to the SDP. No further handler of this stream type will be called.
 	 */
-	int (*create_outgoing_sdp_stream)(struct ast_sip_session *session, struct pjmedia_sdp_session *sdp);
+	int (*create_outgoing_sdp_stream)(struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct pjmedia_sdp_session *sdp);
+	/*!
+	 * \brief Update media stream with external address if applicable
+	 * \param tdata The outgoing message itself
+	 * \param stream The stream on which to operate
+	 * \param transport The transport the SDP is going out on
+	 */
+	void (*change_outgoing_sdp_stream_media_address)(struct pjsip_tx_data *tdata, struct pjmedia_sdp_media *stream, struct ast_sip_transport *transport);
 	/*!
 	 * \brief Apply a negotiated SDP media stream
 	 * \param session The session for which media is being applied
+	 * \param session_media The media to be setup for this session
 	 * \param local The entire local negotiated SDP
 	 * \param local_stream The local stream which to apply
 	 * \param remote The entire remote negotiated SDP
@@ -202,9 +208,15 @@
 	 * \retval <0 There was an error encountered. No further operation will take place and the current application will be abandoned.
 	 * \retval >0 The stream was handled by this handler. No further handler of this stream type will be called.
 	 */
-	int (*apply_negotiated_sdp_stream)(struct ast_sip_session *session, const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
+	int (*apply_negotiated_sdp_stream)(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
 		const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream);
-	/*! Next item int he list. */
+	/*!
+	 * \brief Destroy a session_media created by this handler
+	 * \param session The session for which media is being destroyed
+	 * \param session_media The media to destroy
+	 */
+	void (*stream_destroy)(struct ast_sip_session_media *session_media);
+	/*! Next item in the list. */
 	AST_LIST_ENTRY(ast_sip_session_sdp_handler) next;
 };
 
@@ -231,9 +243,10 @@
  * this reference when the session is destroyed.
  *
  * \param endpoint The endpoint that this session uses for settings
- * \param uri The URI to call
- */
-struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *uri);
+ * \param location Optional name of the location to call, be it named location or explicit URI
+ * \param request_user Optional request user to place in the request URI if permitted
+ */
+struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *location, const char *request_user);
 
 /*!
  * \brief Register an SDP handler

Modified: team/mmichelson/outbound_auth/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/include/asterisk/stasis.h?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/include/asterisk/stasis.h (original)
+++ team/mmichelson/outbound_auth/include/asterisk/stasis.h Fri Mar 15 09:00:43 2013
@@ -306,9 +306,10 @@
  * delivery of the final message.
  *
  * \param subscription Subscription to cancel.
- * \since 12
- */
-void stasis_unsubscribe(struct stasis_subscription *subscription);
+ * \retval NULL for convenience
+ * \since 12
+ */
+struct stasis_subscription *stasis_unsubscribe(struct stasis_subscription *subscription);
 
 /*!
  * \brief Create a subscription which forwards all messages from one topic to
@@ -450,9 +451,10 @@
 /*!
  * Unsubscribes a caching topic from its upstream topic.
  * \param caching_topic Caching topic to unsubscribe
- * \since 12
- */
-void stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic);
+ * \retval NULL for convenience
+ * \since 12
+ */
+struct stasis_caching_topic *stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic);
 
 /*!
  * \brief Returns the topic of cached events from a caching topics.

Modified: team/mmichelson/outbound_auth/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/main/channel_internal_api.c?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/main/channel_internal_api.c (original)
+++ team/mmichelson/outbound_auth/main/channel_internal_api.c Fri Mar 15 09:00:43 2013
@@ -1367,8 +1367,7 @@
 
 	ast_string_field_free_memory(chan);
 
-	stasis_unsubscribe(chan->forwarder);
-	chan->forwarder = NULL;
+	chan->forwarder = stasis_unsubscribe(chan->forwarder);
 
 	ao2_cleanup(chan->topic);
 	chan->topic = NULL;

Modified: team/mmichelson/outbound_auth/main/http.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/main/http.c?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/main/http.c (original)
+++ team/mmichelson/outbound_auth/main/http.c Fri Mar 15 09:00:43 2013
@@ -1060,8 +1060,17 @@
 		v = ast_variable_browse(cfg, "general");
 		for (; v; v = v->next) {
 
-			/* handle tls conf */
-			if (!ast_tls_read_conf(&http_tls_cfg, &https_desc, v->name, v->value)) {
+			/* read tls config options while preventing unsupported options from being set */
+			if (strcasecmp(v->name, "tlscafile")
+				&& strcasecmp(v->name, "tlscapath")
+				&& strcasecmp(v->name, "tlscadir")
+				&& strcasecmp(v->name, "tlsverifyclient")
+				&& strcasecmp(v->name, "tlsdontverifyserver")
+				&& strcasecmp(v->name, "tlsclientmethod")
+				&& strcasecmp(v->name, "sslclientmethod")
+				&& strcasecmp(v->name, "tlscipher")
+				&& strcasecmp(v->name, "sslcipher")
+				&& !ast_tls_read_conf(&http_tls_cfg, &https_desc, v->name, v->value)) {
 				continue;
 			}
 

Modified: team/mmichelson/outbound_auth/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/outbound_auth/main/manager.c?view=diff&rev=383211&r1=383210&r2=383211
==============================================================================
--- team/mmichelson/outbound_auth/main/manager.c (original)
+++ team/mmichelson/outbound_auth/main/manager.c Fri Mar 15 09:00:43 2013
@@ -7590,8 +7590,7 @@
 {
 	struct ast_manager_user *user;
 
-	stasis_unsubscribe(channel_state_sub);
-	channel_state_sub = NULL;
+	channel_state_sub = stasis_unsubscribe(channel_state_sub);
 
 	if (registered) {
 		ast_manager_unregister("Ping");
@@ -7795,7 +7794,15 @@
 	for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
 		val = var->value;
 
-		if (!ast_tls_read_conf(&ami_tls_cfg, &amis_desc, var->name, val)) {

[... 2082 lines stripped ...]



More information about the asterisk-commits mailing list