Asterisk - The Open Source Telephony Project  18.5.0
res_srtp.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2010 FIXME
5  *
6  * See http://www.asterisk.org for more information about
7  * the Asterisk project. Please do not directly contact
8  * any of the maintainers of this project for assistance;
9  * the project provides a web site, mailing lists and IRC
10  * channels for your use.
11  *
12  * This program is free software, distributed under the terms of
13  * the GNU General Public License Version 2. See the LICENSE file
14  * at the top of the source tree.
15  */
16 
17 /*! \file
18  * \brief SRTP resource
19  */
20 
21 #ifndef _ASTERISK_RES_SRTP_H
22 #define _ASTERISK_RES_SRTP_H
23 
24 #include "asterisk.h" /* for size_t */
25 
26 struct ast_srtp;
27 struct ast_srtp_policy;
28 struct ast_rtp_instance;
29 
30 struct ast_srtp_cb {
31  int (*no_ctx)(struct ast_rtp_instance *rtp, unsigned long ssrc, void *data);
32 };
33 
34 struct ast_srtp_res {
35  /*! Create a new SRTP session for an RTP instance with a default policy */
36  int (*create)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy);
37  /* Replace an existing SRTP session with a new session, along with a new default policy */
38  int (*replace)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy);
39  /*! Destroy an SRTP session, along with all associated policies */
40  void (*destroy)(struct ast_srtp *srtp);
41  /* Add a new stream to an existing SRTP session. Note that the policy cannot be for a wildcard SSRC */
42  int (*add_stream)(struct ast_srtp *srtp, struct ast_srtp_policy *policy);
43  /* Change the source on an existing SRTP session. */
44  int (*change_source)(struct ast_srtp *srtp, unsigned int from_ssrc, unsigned int to_ssrc);
45  /* Set a callback function */
46  void (*set_cb)(struct ast_srtp *srtp, const struct ast_srtp_cb *cb, void *data);
47  /* Unprotect SRTP data */
48  int (*unprotect)(struct ast_srtp *srtp, void *buf, int *size, int rtcp);
49  /* Protect RTP data */
50  int (*protect)(struct ast_srtp *srtp, void **buf, int *size, int rtcp);
51  /* Obtain a random cryptographic key */
52  int (*get_random)(unsigned char *key, size_t len);
53 };
54 
55 /* Crypto suites */
57  /* https://www.iana.org/assignments/srtp-protection/srtp-protection.xhtml */
68 };
69 
71  struct ast_srtp_policy *(*alloc)(void);
72  void (*destroy)(struct ast_srtp_policy *policy);
73  int (*set_suite)(struct ast_srtp_policy *policy, enum ast_srtp_suite suite);
74  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);
75  void (*set_ssrc)(struct ast_srtp_policy *policy, unsigned long ssrc, int inbound);
76 };
77 
78 #endif /* _ASTERISK_RES_SRTP_H */
Asterisk main include file. File version handling, generic pbx functions.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int(* no_ctx)(struct ast_rtp_instance *rtp, unsigned long ssrc, void *data)
Definition: res_srtp.h:31
static void destroy(struct ast_trans_pvt *pvt)
Definition: translate.c:291
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:790
ast_srtp_suite
Definition: res_srtp.h:56