summaryrefslogtreecommitdiff
path: root/include/asterisk/sdp_srtp.h
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2016-08-08 14:50:53 -0500
committerRichard Mudgett <rmudgett@digium.com>2016-08-10 17:43:15 -0500
commit41aba83ff6f4cb5867209803f7bfb1c007254230 (patch)
tree431b74f8456756ebabb2632b2b5be5bfa623f125 /include/asterisk/sdp_srtp.h
parentd78fe8fed0d0a76e11b2884a65b66e82b28a6019 (diff)
res_srtp: Move SDP SRTP code from the core to res_srtp.
A patch made to the master branch (Now the 14 branch) inadvertently made libsrtp a required dependency in order to compile Asterisk. Rather than create dummy defines to substitute for the defines supplied by libsrtp when libsrtp is not available, most of the code in sdp_srtp.c is moved into res_srtp.c. This gets more code out of Asterisk's core that isn't used when SRTP is not available. This also makes another inadvertent required dependency on libsrtp by Asterisk's core unlikely. ASTERISK-26253 #close Reported by: Ben Merrills Change-Id: I0a46cde81501c0405399c2588633ae32706d1ee7
Diffstat (limited to 'include/asterisk/sdp_srtp.h')
-rw-r--r--include/asterisk/sdp_srtp.h95
1 files changed, 94 insertions, 1 deletions
diff --git a/include/asterisk/sdp_srtp.h b/include/asterisk/sdp_srtp.h
index 5d8f0e7d1..cf89fa9e0 100644
--- a/include/asterisk/sdp_srtp.h
+++ b/include/asterisk/sdp_srtp.h
@@ -63,6 +63,100 @@ struct ast_sdp_srtp *ast_sdp_srtp_alloc(void);
*/
void ast_sdp_srtp_destroy(struct ast_sdp_srtp *srtp);
+/*! \brief Destroy a previously allocated ast_sdp_crypto struct */
+typedef void (*sdp_crypto_destroy_cb)(struct ast_sdp_crypto *crypto);
+
+/*!
+ * \brief Initialize and return an ast_sdp_crypto struct
+ *
+ * \details
+ * This function allocates a new ast_sdp_crypto struct and initializes its values
+ *
+ * \retval NULL on failure
+ * \retval a pointer to a new ast_sdp_crypto structure
+ */
+typedef struct ast_sdp_crypto *(*sdp_crypto_alloc_cb)(void);
+
+/*!
+ * \brief Generate an SRTP a=crypto offer
+ *
+ * \details
+ * The offer is stored on the ast_sdp_crypto struct in a_crypto
+ *
+ * \param crypto A valid ast_sdp_crypto struct
+ * \param taglen Length
+ *
+ * \retval 0 success
+ * \retval nonzero failure
+ */
+typedef int (*sdp_crypto_build_offer_cb)(struct ast_sdp_crypto *crypto, int taglen);
+
+/*!
+ * \brief Parse the a=crypto line from SDP and set appropriate values on the
+ * ast_sdp_crypto struct.
+ *
+ * The attribute line should already have "a=crypto:" removed.
+ *
+ * \param p A valid ast_sdp_crypto struct
+ * \param attr the a:crypto line from SDP
+ * \param rtp The rtp instance associated with the SDP being parsed
+ * \param srtp SRTP structure
+ *
+ * \retval 0 success
+ * \retval nonzero failure
+ */
+typedef int (*sdp_crypto_parse_offer_cb)(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *srtp, const char *attr);
+
+/*!
+ * \brief Get the crypto attribute line for the srtp structure
+ *
+ * \details
+ * The attribute line does not contain the initial "a=crypto:" and does
+ * not terminate with "\r\n".
+ *
+ * \param srtp The ast_sdp_srtp structure for which to get an attribute line
+ * \param dtls_enabled Whether this connection is encrypted with datagram TLS
+ * \param default_taglen_32 Whether to default to a tag length of 32 instead of 80
+ *
+ * \retval An attribute line containing cryptographic information
+ * \retval NULL if the srtp structure does not require an attribute line containing crypto information
+ */
+typedef const char *(*sdp_srtp_get_attr_cb)(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32);
+
+struct ast_sdp_crypto_api {
+ /*! Destroy a crypto struct */
+ sdp_crypto_destroy_cb dtor;
+ /*! Allocate a crypto struct */
+ sdp_crypto_alloc_cb alloc;
+ /*! Build a SDP a=crypto offer line parameter string */
+ sdp_crypto_build_offer_cb build_offer;
+ /*! Parse a SDP a=crypto offer line parameter string */
+ sdp_crypto_parse_offer_cb parse_offer;
+ /*! Get the SDP a=crypto offer line parameter string */
+ sdp_srtp_get_attr_cb get_attr;
+};
+
+/*!
+ * \brief Register SDP SRTP crypto processing routines.
+ * \since 14.0.0
+ *
+ * \param api Callbacks to register.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_sdp_crypto_register(struct ast_sdp_crypto_api *api);
+
+/*!
+ * \brief Unregister SDP SRTP crypto processing routines.
+ * \since 14.0.0
+ *
+ * \param api Callbacks to unregister.
+ *
+ * \return Nothing
+ */
+void ast_sdp_crypto_unregister(struct ast_sdp_crypto_api *api);
+
/*! \brief Initialize an return an ast_sdp_crypto struct
*
* \details
@@ -104,7 +198,6 @@ int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *sr
*/
int ast_sdp_crypto_build_offer(struct ast_sdp_crypto *p, int taglen);
-
/*! \brief Get the crypto attribute line for the srtp structure
*
* The attribute line does not contain the initial "a=crypto:" and does