Fork me on GitHub
Loading...
Searching...
No Matches
dtls.h
Go to the documentation of this file.
1
14
15#ifndef JANUS_DTLS_H
16#define JANUS_DTLS_H
17
18#include <inttypes.h>
19#include <glib.h>
20
21#include "rtp.h"
22#include "rtpsrtp.h"
23#include "sctp.h"
24#include "refcount.h"
25#include "dtls-bio.h"
26
29const char *janus_get_ssl_version(void);
30
41gint janus_dtls_srtp_init(const char *server_pem, const char *server_key, const char *password,
42 const char *ciphers, guint16 timeout, gboolean rsa_private_key, gboolean accept_selfsigned, gboolean pqc);
49
50
57
65
67typedef struct janus_dtls_srtp {
69 void *pc;
79 GQueue *early_msgs;
81 SSL *ssl;
91 srtp_t srtp_in;
93 srtp_t srtp_out;
95 srtp_policy_t remote_policy;
97 srtp_policy_t local_policy;
99 int ready;
102#ifdef HAVE_SCTP
104 janus_sctp_association *sctp;
105#endif
107 volatile gint destroyed;
111
112
132void janus_dtls_srtp_incoming_msg(janus_dtls_srtp *dtls, char *buf, uint16_t len);
139
144void janus_dtls_callback(const SSL *ssl, int where, int ret);
145
150int janus_dtls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx);
151
152#ifdef HAVE_SCTP
155void janus_dtls_sctp_data_ready(janus_dtls_srtp *dtls);
156
164void janus_dtls_wrap_sctp_data(janus_dtls_srtp *dtls, char *label, char *protocol, gboolean textdata, char *buf, int len);
165
171int janus_dtls_send_sctp_data(janus_dtls_srtp *dtls, char *buf, int len);
172
180void janus_dtls_notify_sctp_data(janus_dtls_srtp *dtls, char *label, char *protocol, gboolean textdata, char *buf, int len);
181#endif
182
187gboolean janus_dtls_retry(gpointer stack);
188
193
198
202const gchar *janus_get_dtls_srtp_profile(int profile);
203
206gboolean janus_is_dtls(char *buf);
207
208#endif
OpenSSL BIO agent writer.
const gchar * janus_get_dtls_srtp_profile(int profile)
Helper method to get a string representation of an SRTP profile.
Definition dtls.c:58
gboolean janus_dtls_are_selfsigned_certs_ok(void)
Method to check whether DTLS self-signed certificates are ok (default) or not.
Definition dtls.c:118
const gchar * janus_get_dtls_srtp_state(janus_dtls_state state)
Helper method to get a string representation of a Janus DTLS state.
Definition dtls.c:28
const char * janus_get_ssl_version(void)
Helper method to return info on the crypto library and its version.
Definition dtls.c:398
int janus_dtls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
DTLS certificate verification callback (http://www.openssl.org/docs/ssl/SSL_CTX_set_verify....
Definition dtls.c:1093
int janus_dtls_srtp_create_sctp(janus_dtls_srtp *dtls)
Create an SCTP association, for data channels.
Definition dtls.c:712
gboolean janus_is_dtls(char *buf)
Helper method to demultiplex DTLS from other protocols.
Definition dtls.c:100
void janus_dtls_srtp_incoming_msg(janus_dtls_srtp *dtls, char *buf, uint16_t len)
Handle an incoming DTLS message.
Definition dtls.c:736
void janus_dtls_srtp_cleanup(void)
Method to cleanup DTLS stuff before exiting.
Definition dtls.c:565
void janus_dtls_srtp_handshake(janus_dtls_srtp *dtls)
Start a DTLS handshake.
Definition dtls.c:678
const gchar * janus_get_dtls_srtp_role(janus_dtls_role role)
Helper method to get a string representation of a DTLS role.
Definition dtls.c:44
void janus_dtls_srtp_send_alert(janus_dtls_srtp *dtls)
Send an alert on a janus_dtls_srtp instance.
Definition dtls.c:1041
janus_dtls_srtp * janus_dtls_srtp_create(void *ice_pc, janus_dtls_role role)
Create a janus_dtls_srtp instance.
Definition dtls.c:587
gint janus_dtls_srtp_init(const char *server_pem, const char *server_key, const char *password, const char *ciphers, guint16 timeout, gboolean rsa_private_key, gboolean accept_selfsigned, gboolean pqc)
DTLS stuff initialization.
Definition dtls.c:403
gboolean janus_dtls_retry(gpointer stack)
DTLS retransmission timer.
Definition dtls.c:1163
void janus_dtls_callback(const SSL *ssl, int where, int ret)
DTLS alert callback (http://www.openssl.org/docs/ssl/SSL_CTX_set_info_callback.html).
Definition dtls.c:1068
gchar * janus_dtls_get_local_fingerprint(void)
Method to return a string representation (SHA-256) of the certificate fingerprint.
Definition dtls.c:135
void janus_dtls_srtp_destroy(janus_dtls_srtp *dtls)
Destroy a janus_dtls_srtp instance.
Definition dtls.c:1052
janus_dtls_state
DTLS state.
Definition dtls.h:59
@ JANUS_DTLS_STATE_CREATED
Definition dtls.h:61
@ JANUS_DTLS_STATE_FAILED
Definition dtls.h:60
@ JANUS_DTLS_STATE_CONNECTED
Definition dtls.h:63
@ JANUS_DTLS_STATE_TRYING
Definition dtls.h:62
janus_dtls_role
DTLS roles.
Definition dtls.h:52
@ JANUS_DTLS_ROLE_SERVER
Definition dtls.h:54
@ JANUS_DTLS_ROLE_CLIENT
Definition dtls.h:55
@ JANUS_DTLS_ROLE_ACTPASS
Definition dtls.h:53
Reference counter mechanism.
RTP processing (headers).
SRTP definitions (headers).
SCTP processing for data channels (headers).
Janus DTLS-SRTP handle.
Definition dtls.h:67
int retransmissions
The number of retransmissions that have occurred for this DTLS instance so far.
Definition dtls.h:101
BIO * read_bio
Read BIO (incoming DTLS data).
Definition dtls.h:83
srtp_t srtp_in
libsrtp context for incoming SRTP packets
Definition dtls.h:91
gint64 dtls_started
Monotonic time of when the DTLS handshake has started.
Definition dtls.h:75
int ready
Whether this DTLS stack is now ready to be used for messages as well (e.g., SCTP encapsulation).
Definition dtls.h:99
janus_dtls_state dtls_state
DTLS state of this component: -1=failed, 0=nothing, 1=trying, 2=connected.
Definition dtls.h:73
srtp_policy_t remote_policy
libsrtp policy for incoming SRTP packets
Definition dtls.h:95
srtp_policy_t local_policy
libsrtp policy for outgoing SRTP packets
Definition dtls.h:97
void * pc
Opaque pointer to the WebRTC PeerConnection this DTLS-SRTP context belongs to.
Definition dtls.h:69
srtp_t srtp_out
libsrtp context for outgoing SRTP packets
Definition dtls.h:93
gint srtp_profile
The SRTP profile currently in use.
Definition dtls.h:89
gint64 dtls_connected
Monotonic time of when the DTLS state has switched to connected.
Definition dtls.h:77
gint srtp_valid
Whether SRTP has been correctly set up for this component or not.
Definition dtls.h:87
GQueue * early_msgs
DTLS handshake messages received before the handshake started.
Definition dtls.h:79
janus_dtls_role dtls_role
DTLS role of the server for this stream: 1=client, 0=server.
Definition dtls.h:71
BIO * write_bio
Write BIO (outgoing DTLS data).
Definition dtls.h:85
SSL * ssl
SSL context used for DTLS for this component.
Definition dtls.h:81
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition dtls.h:107
janus_refcount ref
Reference counter for this instance.
Definition dtls.h:109
Definition refcount.h:78