summaryrefslogtreecommitdiff
path: root/main/rtp_engine.c
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2010-06-08 05:29:08 +0000
committerTerry Wilson <twilson@digium.com>2010-06-08 05:29:08 +0000
commit857814f4354fb26255d4d5db6e06e90749e9bad0 (patch)
treeecc27fc0db142ea1cd335a74cd1265f993fecd11 /main/rtp_engine.c
parentebbf166c2d15fd233ee307e760b2a88c46d19f6b (diff)
Add SRTP support for Asterisk
After 5 years in mantis and over a year on reviewboard, SRTP support is finally being comitted. This includes generic CHANNEL dialplan functions that work for getting the status of whether a call has secure media or signaling as defined by the underlying channel technology and for setting whether or not a new channel being bridged to a calling channel should have secure signaling or media. See doc/tex/secure-calls.tex for examples. Original patch by mikma, updated for trunk and revised by me. (closes issue #5413) Reported by: mikma Tested by: twilson, notthematrix, hemanshurpatel Review: https://reviewboard.asterisk.org/r/191/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@268894 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/rtp_engine.c')
-rw-r--r--main/rtp_engine.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 26881be80..2d23958ae 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -39,6 +39,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/translate.h"
+struct ast_srtp_res *res_srtp = NULL;
+struct ast_srtp_policy_res *res_srtp_policy = NULL;
+
/*! Structure that represents an RTP session (instance) */
struct ast_rtp_instance {
/*! Engine that is handling this RTP instance */
@@ -67,6 +70,8 @@ struct ast_rtp_instance {
struct ast_rtp_glue *glue;
/*! Channel associated with the instance */
struct ast_channel *chan;
+ /*! SRTP info associated with the instance */
+ struct ast_srtp *srtp;
};
/*! List of RTP engines that are currently registered */
@@ -1670,3 +1675,47 @@ struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance)
{
return instance->chan;
}
+
+int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res)
+{
+ if (res_srtp || res_srtp_policy) {
+ return -1;
+ }
+ if (!srtp_res || !policy_res) {
+ return -1;
+ }
+
+ res_srtp = srtp_res;
+ res_srtp_policy = policy_res;
+
+ return 0;
+}
+
+void ast_rtp_engine_unregister_srtp(void)
+{
+ res_srtp = NULL;
+ res_srtp_policy = NULL;
+}
+
+int ast_rtp_engine_srtp_is_registered(void)
+{
+ return res_srtp && res_srtp_policy;
+}
+
+int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy *policy)
+{
+ if (!res_srtp) {
+ return -1;
+ }
+
+ if (!instance->srtp) {
+ return res_srtp->create(&instance->srtp, instance, policy);
+ } else {
+ return res_srtp->add_stream(instance->srtp, policy);
+ }
+}
+
+struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance)
+{
+ return instance->srtp;
+}