Loading...
Searching...
No Matches
dtls.h
Go to the documentation of this file.
#ifndef JANUS_DTLS_H
#define JANUS_DTLS_H
#include <inttypes.h>
#include <glib.h>
#include "rtp.h"
#include "rtpsrtp.h"
#include "sctp.h"
#include "refcount.h"
#include "dtls-bio.h"
const char *janus_get_ssl_version(void);
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);
void janus_dtls_srtp_cleanup(void);
gchar *janus_dtls_get_local_fingerprint(void);
gboolean janus_dtls_are_selfsigned_certs_ok(void);
typedef enum janus_dtls_role {
JANUS_DTLS_ROLE_ACTPASS = -1,
JANUS_DTLS_ROLE_SERVER,
JANUS_DTLS_ROLE_CLIENT,
} janus_dtls_role;
typedef enum janus_dtls_state {
JANUS_DTLS_STATE_FAILED = -1,
JANUS_DTLS_STATE_CREATED,
JANUS_DTLS_STATE_TRYING,
JANUS_DTLS_STATE_CONNECTED,
} janus_dtls_state;
typedef struct janus_dtls_srtp {
void *pc;
janus_dtls_role dtls_role;
janus_dtls_state dtls_state;
gint64 dtls_started;
gint64 dtls_connected;
SSL *ssl;
BIO *read_bio;
BIO *write_bio;
gint srtp_valid;
gint srtp_profile;
srtp_t srtp_in;
srtp_t srtp_out;
srtp_policy_t remote_policy;
srtp_policy_t local_policy;
int ready;
int retransmissions;
#ifdef HAVE_SCTP
janus_sctp_association *sctp;
#endif
volatile gint destroyed;
janus_refcount ref;
} janus_dtls_srtp;
janus_dtls_srtp *janus_dtls_srtp_create(void *pc, janus_dtls_role role);
void janus_dtls_srtp_handshake(janus_dtls_srtp *dtls);
int janus_dtls_srtp_create_sctp(janus_dtls_srtp *dtls);
void janus_dtls_srtp_incoming_msg(janus_dtls_srtp *dtls, char *buf, uint16_t len);
void janus_dtls_srtp_send_alert(janus_dtls_srtp *dtls);
void janus_dtls_srtp_destroy(janus_dtls_srtp *dtls);
void janus_dtls_callback(const SSL *ssl, int where, int ret);
int janus_dtls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx);
#ifdef HAVE_SCTP
void janus_dtls_sctp_data_ready(janus_dtls_srtp *dtls);
void janus_dtls_wrap_sctp_data(janus_dtls_srtp *dtls, char *label, char *protocol, gboolean textdata, char *buf, int len);
int janus_dtls_send_sctp_data(janus_dtls_srtp *dtls, char *buf, int len);
void janus_dtls_notify_sctp_data(janus_dtls_srtp *dtls, char *label, char *protocol, gboolean textdata, char *buf, int len);
#endif
gboolean janus_dtls_retry(gpointer stack);
const gchar *janus_get_dtls_srtp_state(janus_dtls_state state);
const gchar *janus_get_dtls_srtp_role(janus_dtls_role role);
const gchar *janus_get_dtls_srtp_profile(int profile);
gboolean janus_is_dtls(char *buf);
#endif
dtls-bio.h
OpenSSL BIO agent writer.
janus_get_dtls_srtp_profile
const gchar * janus_get_dtls_srtp_profile(int profile)
Helper method to get a string representation of an SRTP profile.
Definition dtls.c:58
janus_dtls_are_selfsigned_certs_ok
gboolean janus_dtls_are_selfsigned_certs_ok(void)
Method to check whether DTLS self-signed certificates are ok (default) or not.
Definition dtls.c:116
janus_get_dtls_srtp_state
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
janus_dtls_srtp_init
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)
DTLS stuff initialization.
Definition dtls.c:398
janus_dtls_state
janus_dtls_state
DTLS state.
Definition dtls.h:58
JANUS_DTLS_STATE_CREATED
@ JANUS_DTLS_STATE_CREATED
Definition dtls.h:60
JANUS_DTLS_STATE_FAILED
@ JANUS_DTLS_STATE_FAILED
Definition dtls.h:59
JANUS_DTLS_STATE_CONNECTED
@ JANUS_DTLS_STATE_CONNECTED
Definition dtls.h:62
JANUS_DTLS_STATE_TRYING
@ JANUS_DTLS_STATE_TRYING
Definition dtls.h:61
janus_get_ssl_version
const char * janus_get_ssl_version(void)
Helper method to return info on the crypto library and its version.
Definition dtls.c:393
janus_dtls_verify_callback
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:1027
janus_dtls_srtp_create_sctp
int janus_dtls_srtp_create_sctp(janus_dtls_srtp *dtls)
Create an SCTP association, for data channels.
Definition dtls.c:666
janus_is_dtls
gboolean janus_is_dtls(char *buf)
Helper method to demultiplex DTLS from other protocols.
Definition dtls.c:100
janus_dtls_srtp_incoming_msg
void janus_dtls_srtp_incoming_msg(janus_dtls_srtp *dtls, char *buf, uint16_t len)
Handle an incoming DTLS message.
Definition dtls.c:690
janus_dtls_srtp_cleanup
void janus_dtls_srtp_cleanup(void)
Method to cleanup DTLS stuff before exiting.
Definition dtls.c:549
janus_dtls_srtp_handshake
void janus_dtls_srtp_handshake(janus_dtls_srtp *dtls)
Start a DTLS handshake.
Definition dtls.c:647
janus_get_dtls_srtp_role
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
janus_dtls_srtp_send_alert
void janus_dtls_srtp_send_alert(janus_dtls_srtp *dtls)
Send an alert on a janus_dtls_srtp instance.
Definition dtls.c:975
janus_dtls_role
janus_dtls_role
DTLS roles.
Definition dtls.h:51
JANUS_DTLS_ROLE_SERVER
@ JANUS_DTLS_ROLE_SERVER
Definition dtls.h:53
JANUS_DTLS_ROLE_CLIENT
@ JANUS_DTLS_ROLE_CLIENT
Definition dtls.h:54
JANUS_DTLS_ROLE_ACTPASS
@ JANUS_DTLS_ROLE_ACTPASS
Definition dtls.h:52
janus_dtls_retry
gboolean janus_dtls_retry(gpointer stack)
DTLS retransmission timer.
Definition dtls.c:1097
janus_dtls_callback
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:1002
janus_dtls_srtp_create
janus_dtls_srtp * janus_dtls_srtp_create(void *pc, janus_dtls_role role)
Create a janus_dtls_srtp instance.
Definition dtls.c:568
janus_dtls_get_local_fingerprint
gchar * janus_dtls_get_local_fingerprint(void)
Method to return a string representation (SHA-256) of the certificate fingerprint.
Definition dtls.c:130
janus_dtls_srtp_destroy
void janus_dtls_srtp_destroy(janus_dtls_srtp *dtls)
Destroy a janus_dtls_srtp instance.
Definition dtls.c:986
refcount.h
Reference counter mechanism.
rtp.h
RTP processing (headers).
rtpsrtp.h
SRTP definitions (headers).
sctp.h
SCTP processing for data channels (headers).
janus_dtls_srtp
Janus DTLS-SRTP handle.
Definition dtls.h:66
janus_dtls_srtp::retransmissions
int retransmissions
The number of retransmissions that have occurred for this DTLS instance so far.
Definition dtls.h:98
janus_dtls_srtp::read_bio
BIO * read_bio
Read BIO (incoming DTLS data).
Definition dtls.h:80
janus_dtls_srtp::srtp_in
srtp_t srtp_in
libsrtp context for incoming SRTP packets
Definition dtls.h:88
janus_dtls_srtp::dtls_started
gint64 dtls_started
Monotonic time of when the DTLS handhake has started.
Definition dtls.h:74
janus_dtls_srtp::ready
int ready
Whether this DTLS stack is now ready to be used for messages as well (e.g., SCTP encapsulation).
Definition dtls.h:96
janus_dtls_srtp::dtls_state
janus_dtls_state dtls_state
DTLS state of this component: -1=failed, 0=nothing, 1=trying, 2=connected.
Definition dtls.h:72
janus_dtls_srtp::remote_policy
srtp_policy_t remote_policy
libsrtp policy for incoming SRTP packets
Definition dtls.h:92
janus_dtls_srtp::local_policy
srtp_policy_t local_policy
libsrtp policy for outgoing SRTP packets
Definition dtls.h:94
janus_dtls_srtp::pc
void * pc
Opaque pointer to the WebRTC PeerConnection this DTLS-SRTP context belongs to.
Definition dtls.h:68
janus_dtls_srtp::srtp_out
srtp_t srtp_out
libsrtp context for outgoing SRTP packets
Definition dtls.h:90
janus_dtls_srtp::srtp_profile
gint srtp_profile
The SRTP profile currently in use.
Definition dtls.h:86
janus_dtls_srtp::dtls_connected
gint64 dtls_connected
Monotonic time of when the DTLS state has switched to connected.
Definition dtls.h:76
janus_dtls_srtp::srtp_valid
gint srtp_valid
Whether SRTP has been correctly set up for this component or not.
Definition dtls.h:84
janus_dtls_srtp::dtls_role
janus_dtls_role dtls_role
DTLS role of the server for this stream: 1=client, 0=server.
Definition dtls.h:70
janus_dtls_srtp::write_bio
BIO * write_bio
Write BIO (outgoing DTLS data).
Definition dtls.h:82
janus_dtls_srtp::ssl
SSL * ssl
SSL context used for DTLS for this component.
Definition dtls.h:78
janus_dtls_srtp::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition dtls.h:104
janus_dtls_srtp::ref
janus_refcount ref
Reference counter for this instance.
Definition dtls.h:106
janus_refcount
Definition refcount.h:78