diff options
author | twilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-06-08 05:29:08 +0000 |
---|---|---|
committer | twilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-06-08 05:29:08 +0000 |
commit | 9b1a36a294342fc418d9a359a4cf06bd90c4acb9 (patch) | |
tree | ecc27fc0db142ea1cd335a74cd1265f993fecd11 /main/rtp_engine.c | |
parent | 5f87b66641d86dbe7afec3b083016b2b1aceafc7 (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: http://svn.digium.com/svn/asterisk/trunk@268894 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/rtp_engine.c')
-rw-r--r-- | main/rtp_engine.c | 49 |
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; +} |