[asterisk-commits] twilson: branch group/srtp r167534 - in /team/group/srtp: apps/ channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 7 14:29:12 CST 2009


Author: twilson
Date: Wed Jan  7 14:29:12 2009
New Revision: 167534

URL: http://svn.digium.com/view/asterisk?view=rev&rev=167534
Log:
Ok, for now I am removing the SIPSRTP=optional setting as there is no standard way to provisionally offer SRTP that I can find.  The way that were were doing it was the way that snom supports, but it causes the Polycom to choke.  Instead, what I now have is a sip.conf peer option srtpenable=yes|no and have added the ability to check this option with the SIPPEER() dialplan function.  Now, if the value of SIPSRTP evaluates to false, then encryption will not be offered, otherwise it will.  Also gone is the SIPSRTP_CRYPTO dialplan variable since 1) We don't have MIKEY support here right now and 2) If we did, I think it would be better to just signal whether or not you want to encrypt via the dialplan and leave the choice of how to encrypt to a sip.conf variable.

An quick/short example of how to offer SRTP only to devices that are capable would be something like:

[default]
exten => _600X,1,Set(_SIPSRTP=${SIPPEER(${EXTEN},srtpcapable)})
exten => _600X,n,Dial(SIP/${EXTEN})

Modified:
    team/group/srtp/apps/app_dial.c
    team/group/srtp/channels/chan_iax2.c
    team/group/srtp/channels/chan_sip.c

Modified: team/group/srtp/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/srtp/apps/app_dial.c?view=diff&rev=167534&r1=167533&r2=167534
==============================================================================
--- team/group/srtp/apps/app_dial.c (original)
+++ team/group/srtp/apps/app_dial.c Wed Jan  7 14:29:12 2009
@@ -491,9 +491,11 @@
 #define OPT_CANCEL_ELSEWHERE ((uint64_t)1 << 33)
 #define OPT_PEER_H           ((uint64_t)1 << 34)
 #define OPT_CALLEE_GO_ON     ((uint64_t)1 << 35)
+#define OPT_ANNOUNCE_BOTH    ((uint64_t)1 << 36)
 
 enum {
 	OPT_ARG_ANNOUNCE = 0,
+	OPT_ARG_ANNOUNCE_BOTH,
 	OPT_ARG_SENDDTMF,
 	OPT_ARG_GOTO,
 	OPT_ARG_DURATION_LIMIT,
@@ -510,6 +512,7 @@
 
 AST_APP_OPTIONS(dial_exec_options, BEGIN_OPTIONS
 	AST_APP_OPTION_ARG('A', OPT_ANNOUNCE, OPT_ARG_ANNOUNCE),
+	AST_APP_OPTION_ARG('B', OPT_ANNOUNCE_BOTH, OPT_ARG_ANNOUNCE_BOTH),
 	AST_APP_OPTION('C', OPT_RESETCDR),
 	AST_APP_OPTION('c', OPT_CANCEL_ELSEWHERE),
 	AST_APP_OPTION('d', OPT_DTMF_EXIT),
@@ -1496,6 +1499,24 @@
 	bconfig->end_bridge_callback_data = originator;
 }
 
+struct prompt_data {
+	struct ast_channel *chan;
+	const char *prompt;
+};
+
+static void *play_prompt(void *data)
+{
+	struct prompt_data *pd = data;
+
+	int res;
+
+	if (!ast_strlen_zero(pd->prompt) && !(res = ast_streamfile(pd->chan, pd->prompt, pd->chan->language))) {
+		res = ast_waitstream(pd->chan, "");
+	}
+
+	return NULL;
+}
+
 static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags64 *peerflags, int *continue_exec)
 {
 	int res = -1; /* default: error */
@@ -2211,6 +2232,20 @@
 
 				ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
 			}
+
+			if (ast_test_flag64(&opts, OPT_ANNOUNCE_BOTH) && !ast_strlen_zero(opt_args[OPT_ARG_ANNOUNCE_BOTH])) {
+			   struct prompt_data one, two;
+				pthread_t thread1 = AST_PTHREADT_NULL, thread2 = AST_PTHREADT_NULL;
+
+				one.chan = chan;
+				two.chan = peer;
+				one.prompt = two.prompt = opt_args[OPT_ARG_ANNOUNCE_BOTH];
+				ast_pthread_create(&thread1, NULL, play_prompt, &one);
+				ast_pthread_create(&thread2, NULL, play_prompt, &two);
+				pthread_join(thread1, NULL);
+				pthread_join(thread2, NULL);
+			}
+
 			res = ast_bridge_call(chan, peer, &config);
 		}
 

Modified: team/group/srtp/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/srtp/channels/chan_iax2.c?view=diff&rev=167534&r1=167533&r2=167534
==============================================================================
--- team/group/srtp/channels/chan_iax2.c (original)
+++ team/group/srtp/channels/chan_iax2.c Wed Jan  7 14:29:12 2009
@@ -12200,6 +12200,8 @@
 		ast_copy_string(buf, pvt->addr.sin_addr.s_addr ? ast_inet_ntoa(pvt->addr.sin_addr) : "", buflen);
 	} else if (!strcasecmp(args, "peername")) {
 		ast_copy_string(buf, pvt->username, buflen);
+	} else if (!strcasecmp(args, "secure_signalling") || !strcasecmp(args, "secure_media")) {
+		snprintf(buf, buflen, "%d", ast_test_flag(pvt, IAX_ENCRYPTED) ? 1 : 0);
 	} else {
 		res = -1;
 	}

Modified: team/group/srtp/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/srtp/channels/chan_sip.c?view=diff&rev=167534&r1=167533&r2=167534
==============================================================================
--- team/group/srtp/channels/chan_sip.c (original)
+++ team/group/srtp/channels/chan_sip.c Wed Jan  7 14:29:12 2009
@@ -19475,6 +19475,20 @@
 	}
 }
 
+static const char* transport_to_str(enum sip_transport type)
+{
+	switch(type) {
+	case SIP_TRANSPORT_UDP :
+		return "udp";
+	case SIP_TRANSPORT_TCP :
+		return "tcp";
+	case SIP_TRANSPORT_TLS :
+		return "tls";
+	default :
+		return "unknown";
+	}
+}
+
 static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
 {
 	struct sip_pvt *p = chan->tech_pvt;
@@ -19576,6 +19590,12 @@
 			ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
 			return -1;
 		}
+	} else if (!strcasecmp(args.param, "secure_signalling")) {
+		snprintf(buf, buflen, "%d", p->socket.type == SIP_TRANSPORT_TLS ? 1 : 0);
+	} else if (!strcasecmp(args.param, "secure_media")) {
+		snprintf(buf, buflen, "%d", p->srtp ? 1 : 0);
+	} else if (!strcasecmp(args.param, "transport")) {
+		ast_copy_string(buf, transport_to_str(p->socket.type), buflen);
 	} else {
 		res = -1;
 	}




More information about the asterisk-commits mailing list