aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-08 05:29:08 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-08 05:29:08 +0000
commit9b1a36a294342fc418d9a359a4cf06bd90c4acb9 (patch)
treeecc27fc0db142ea1cd335a74cd1265f993fecd11 /include
parent5f87b66641d86dbe7afec3b083016b2b1aceafc7 (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 'include')
-rw-r--r--include/asterisk/autoconfig.h.in54
-rw-r--r--include/asterisk/frame.h4
-rw-r--r--include/asterisk/global_datastores.h5
-rw-r--r--include/asterisk/res_srtp.h57
-rw-r--r--include/asterisk/rtp_engine.h11
5 files changed, 101 insertions, 30 deletions
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index ae87f77a8..859a8074a 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -702,6 +702,9 @@
/* Define to 1 if you have the `sqrtl' function. */
#undef HAVE_SQRTL
+/* Define to 1 if you have the Secure RTP library. */
+#undef HAVE_SRTP
+
/* Define to 1 if you have the ISDN SS7 library. */
#undef HAVE_SS7
@@ -791,7 +794,7 @@
/* Define to 1 if you have the `strtoq' function. */
#undef HAVE_STRTOQ
-/* Define to 1 if `st_blksize' is member of `struct stat'. */
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
/* Define to 1 if you have the mISDN Supplemental Services library. */
@@ -1059,12 +1062,12 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define to 1 if the C compiler supports function prototypes. */
-#undef PROTOTYPES
-
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
@@ -1084,11 +1087,6 @@
/* Define to the type of arg 5 for `select'. */
#undef SELECT_TYPE_ARG5
-/* Define to 1 if the `setvbuf' function takes the buffering type as its
- second argument and the buffer pointer as the third, as on System V before
- release 3. */
-#undef SETVBUF_REVERSED
-
/* The size of `char *', as computed by sizeof. */
#undef SIZEOF_CHAR_P
@@ -1118,20 +1116,30 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
-/* Define to 1 if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
+/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
#undef _LARGEFILE_SOURCE
@@ -1149,20 +1157,6 @@
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
-/* Enable extensions on Solaris. */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
-
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index bfd92fa2d..b2032b8d1 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -459,6 +459,10 @@ enum ast_control_transfer {
/*! Get the CC agent type from the channel */
#define AST_OPTION_CC_AGENT_TYPE 17
+/*! Get or set the security options on a channel */
+#define AST_OPTION_SECURE_SIGNALING 18
+#define AST_OPTION_SECURE_MEDIA 19
+
struct oprmode {
struct ast_channel *peer;
int mode;
diff --git a/include/asterisk/global_datastores.h b/include/asterisk/global_datastores.h
index 72edabac5..16267a894 100644
--- a/include/asterisk/global_datastores.h
+++ b/include/asterisk/global_datastores.h
@@ -27,10 +27,15 @@
#include "asterisk/channel.h"
extern const struct ast_datastore_info dialed_interface_info;
+extern const struct ast_datastore_info secure_call_info;
struct ast_dialed_interface {
AST_LIST_ENTRY(ast_dialed_interface) list;
char interface[1];
};
+struct ast_secure_call_store {
+ unsigned int signaling:1;
+ unsigned int media:1;
+};
#endif
diff --git a/include/asterisk/res_srtp.h b/include/asterisk/res_srtp.h
new file mode 100644
index 000000000..7853ead6f
--- /dev/null
+++ b/include/asterisk/res_srtp.h
@@ -0,0 +1,57 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010 FIXME
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief SRTP resource
+ */
+
+#ifndef _ASTERISK_RES_SRTP_H
+#define _ASTERISK_RES_SRTP_H
+
+struct ast_srtp;
+struct ast_srtp_policy;
+struct ast_rtp_instance;
+
+struct ast_srtp_cb {
+ int (*no_ctx)(struct ast_rtp_instance *rtp, unsigned long ssrc, void *data);
+};
+
+struct ast_srtp_res {
+ int (*create)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy);
+ void (*destroy)(struct ast_srtp *srtp);
+ int (*add_stream)(struct ast_srtp *srtp, struct ast_srtp_policy *policy);
+ void (*set_cb)(struct ast_srtp *srtp, const struct ast_srtp_cb *cb, void *data);
+ int (*unprotect)(struct ast_srtp *srtp, void *buf, int *size, int rtcp);
+ int (*protect)(struct ast_srtp *srtp, void **buf, int *size, int rtcp);
+ int (*get_random)(unsigned char *key, size_t len);
+};
+
+/* Crypto suites */
+enum ast_srtp_suite {
+ AST_AES_CM_128_HMAC_SHA1_80 = 1,
+ AST_AES_CM_128_HMAC_SHA1_32 = 2,
+ AST_F8_128_HMAC_SHA1_80 = 3
+};
+
+struct ast_srtp_policy_res {
+ struct ast_srtp_policy *(*alloc)(void);
+ void (*destroy)(struct ast_srtp_policy *policy);
+ int (*set_suite)(struct ast_srtp_policy *policy, enum ast_srtp_suite suite);
+ int (*set_master_key)(struct ast_srtp_policy *policy, const unsigned char *key, size_t key_len, const unsigned char *salt, size_t salt_len);
+ void (*set_ssrc)(struct ast_srtp_policy *policy, unsigned long ssrc, int inbound);
+};
+
+#endif /* _ASTERISK_RES_SRTP_H */
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index c7b433972..7d55a85f7 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -71,6 +71,9 @@ extern "C" {
#include "asterisk/astobj2.h"
#include "asterisk/frame.h"
+#include "asterisk/netsock.h"
+#include "asterisk/sched.h"
+#include "asterisk/res_srtp.h"
/* Maximum number of payloads supported */
#define AST_RTP_MAX_PT 256
@@ -458,6 +461,11 @@ int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *m
*/
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine);
+int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res);
+
+void ast_rtp_engine_unregister_srtp(void);
+int ast_rtp_engine_srtp_is_registered(void);
+
#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self)
/*!
@@ -1724,6 +1732,9 @@ struct ast_rtp_glue *ast_rtp_instance_get_active_glue(struct ast_rtp_instance *i
*/
struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance);
+int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy *policy);
+struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif