bfcp: add support for DTLS transport
This commit is contained in:
parent
baee4163be
commit
c0e30047d8
3 changed files with 22 additions and 2 deletions
|
@ -101,6 +101,7 @@ enum bfcp_priority {
|
||||||
/** BFCP Transport */
|
/** BFCP Transport */
|
||||||
enum bfcp_transp {
|
enum bfcp_transp {
|
||||||
BFCP_UDP,
|
BFCP_UDP,
|
||||||
|
BFCP_DTLS,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** BFCP Request Status */
|
/** BFCP Request Status */
|
||||||
|
@ -178,6 +179,7 @@ struct bfcp_msg {
|
||||||
struct list attrl;
|
struct list attrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct tls;
|
||||||
struct bfcp_conn;
|
struct bfcp_conn;
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,7 +261,7 @@ const char *bfcp_prim_name(enum bfcp_prim prim);
|
||||||
|
|
||||||
/* conn */
|
/* conn */
|
||||||
int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
|
int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
|
||||||
bfcp_recv_h *recvh, void *arg);
|
struct tls *tls, bfcp_recv_h *recvh, void *arg);
|
||||||
void *bfcp_sock(const struct bfcp_conn *bc);
|
void *bfcp_sock(const struct bfcp_conn *bc);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct bfcp_conn {
|
||||||
struct tmr tmr1;
|
struct tmr tmr1;
|
||||||
struct tmr tmr2;
|
struct tmr tmr2;
|
||||||
struct udp_sock *us;
|
struct udp_sock *us;
|
||||||
|
struct tls_sock *ss;
|
||||||
struct mbuf *mb;
|
struct mbuf *mb;
|
||||||
bfcp_recv_h *recvh;
|
bfcp_recv_h *recvh;
|
||||||
void *arg;
|
void *arg;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <re_list.h>
|
#include <re_list.h>
|
||||||
#include <re_sa.h>
|
#include <re_sa.h>
|
||||||
#include <re_udp.h>
|
#include <re_udp.h>
|
||||||
|
#include <re_tls.h>
|
||||||
#include <re_tmr.h>
|
#include <re_tmr.h>
|
||||||
#include <re_bfcp.h>
|
#include <re_bfcp.h>
|
||||||
#include "bfcp.h"
|
#include "bfcp.h"
|
||||||
|
@ -23,6 +24,7 @@ static void destructor(void *arg)
|
||||||
list_flush(&bc->ctransl);
|
list_flush(&bc->ctransl);
|
||||||
tmr_cancel(&bc->tmr1);
|
tmr_cancel(&bc->tmr1);
|
||||||
tmr_cancel(&bc->tmr2);
|
tmr_cancel(&bc->tmr2);
|
||||||
|
mem_deref(bc->ss);
|
||||||
mem_deref(bc->us);
|
mem_deref(bc->us);
|
||||||
mem_deref(bc->mb);
|
mem_deref(bc->mb);
|
||||||
}
|
}
|
||||||
|
@ -81,13 +83,14 @@ out:
|
||||||
* @param bcp Pointer to BFCP connection
|
* @param bcp Pointer to BFCP connection
|
||||||
* @param tp BFCP Transport type
|
* @param tp BFCP Transport type
|
||||||
* @param laddr Optional listening address/port
|
* @param laddr Optional listening address/port
|
||||||
|
* @param tls TLS Context (optional)
|
||||||
* @param recvh Receive handler
|
* @param recvh Receive handler
|
||||||
* @param arg Receive handler argument
|
* @param arg Receive handler argument
|
||||||
*
|
*
|
||||||
* @return 0 if success, otherwise errorcode
|
* @return 0 if success, otherwise errorcode
|
||||||
*/
|
*/
|
||||||
int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
|
int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
|
||||||
bfcp_recv_h *recvh, void *arg)
|
struct tls *tls, bfcp_recv_h *recvh, void *arg)
|
||||||
{
|
{
|
||||||
struct bfcp_conn *bc;
|
struct bfcp_conn *bc;
|
||||||
int err;
|
int err;
|
||||||
|
@ -106,6 +109,7 @@ int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
|
||||||
switch (bc->tp) {
|
switch (bc->tp) {
|
||||||
|
|
||||||
case BFCP_UDP:
|
case BFCP_UDP:
|
||||||
|
case BFCP_DTLS:
|
||||||
err = udp_listen(&bc->us, laddr, udp_recv_handler, bc);
|
err = udp_listen(&bc->us, laddr, udp_recv_handler, bc);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -122,6 +126,18 @@ int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bc->tp == BFCP_DTLS) {
|
||||||
|
|
||||||
|
#ifdef USE_OPENSSL_DTLS
|
||||||
|
err = tls_start_udp(&bc->ss, tls, bc->us, 0, 4);
|
||||||
|
#else
|
||||||
|
(void)tls;
|
||||||
|
err = ENOSYS;
|
||||||
|
#endif
|
||||||
|
if (err)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (err)
|
if (err)
|
||||||
mem_deref(bc);
|
mem_deref(bc);
|
||||||
|
@ -140,6 +156,7 @@ int bfcp_send(struct bfcp_conn *bc, const struct sa *dst, struct mbuf *mb)
|
||||||
switch (bc->tp) {
|
switch (bc->tp) {
|
||||||
|
|
||||||
case BFCP_UDP:
|
case BFCP_UDP:
|
||||||
|
case BFCP_DTLS:
|
||||||
return udp_send(bc->us, dst, mb);
|
return udp_send(bc->us, dst, mb);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Reference in a new issue