11
11
#include <re_list.h>
12
12
#include <re_sa.h>
13
13
#include <re_udp.h>
14
+ #include <re_tls.h>
14
15
#include <re_tmr.h>
15
16
#include <re_bfcp.h>
16
17
#include "bfcp.h"
@@ -23,6 +24,7 @@ static void destructor(void *arg)
23
24
list_flush (& bc -> ctransl );
24
25
tmr_cancel (& bc -> tmr1 );
25
26
tmr_cancel (& bc -> tmr2 );
27
+ mem_deref (bc -> ss );
26
28
mem_deref (bc -> us );
27
29
mem_deref (bc -> mb );
28
30
}
@@ -81,13 +83,14 @@ static void udp_recv_handler(const struct sa *src, struct mbuf *mb, void *arg)
81
83
* @param bcp Pointer to BFCP connection
82
84
* @param tp BFCP Transport type
83
85
* @param laddr Optional listening address/port
86
+ * @param tls TLS Context (optional)
84
87
* @param recvh Receive handler
85
88
* @param arg Receive handler argument
86
89
*
87
90
* @return 0 if success, otherwise errorcode
88
91
*/
89
92
int bfcp_listen (struct bfcp_conn * * bcp , enum bfcp_transp tp , struct sa * laddr ,
90
- bfcp_recv_h * recvh , void * arg )
93
+ struct tls * tls , bfcp_recv_h * recvh , void * arg )
91
94
{
92
95
struct bfcp_conn * bc ;
93
96
int err ;
@@ -106,6 +109,7 @@ int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
106
109
switch (bc -> tp ) {
107
110
108
111
case BFCP_UDP :
112
+ case BFCP_DTLS :
109
113
err = udp_listen (& bc -> us , laddr , udp_recv_handler , bc );
110
114
if (err )
111
115
goto out ;
@@ -122,6 +126,18 @@ int bfcp_listen(struct bfcp_conn **bcp, enum bfcp_transp tp, struct sa *laddr,
122
126
goto out ;
123
127
}
124
128
129
+ if (bc -> tp == BFCP_DTLS ) {
130
+
131
+ #ifdef USE_OPENSSL_DTLS
132
+ err = tls_start_udp (& bc -> ss , tls , bc -> us , 0 , 4 );
133
+ #else
134
+ (void )tls ;
135
+ err = ENOSYS ;
136
+ #endif
137
+ if (err )
138
+ goto out ;
139
+ }
140
+
125
141
out :
126
142
if (err )
127
143
mem_deref (bc );
@@ -140,6 +156,7 @@ int bfcp_send(struct bfcp_conn *bc, const struct sa *dst, struct mbuf *mb)
140
156
switch (bc -> tp ) {
141
157
142
158
case BFCP_UDP :
159
+ case BFCP_DTLS :
143
160
return udp_send (bc -> us , dst , mb );
144
161
145
162
default :
0 commit comments