patch: add dtls_set_mtu()
This commit is contained in:
parent
71f79e7198
commit
88aa3a0097
2 changed files with 34 additions and 2 deletions
|
@ -63,6 +63,7 @@ int dtls_listen(struct dtls_sock **sockp, const struct sa *laddr,
|
|||
struct udp_sock *us, uint32_t htsize, int layer,
|
||||
dtls_conn_h *connh, void *arg);
|
||||
struct udp_sock *dtls_udp_sock(struct dtls_sock *sock);
|
||||
void dtls_set_mtu(struct dtls_sock *sock, size_t mtu);
|
||||
int dtls_connect(struct tls_conn **ptc, struct tls *tls,
|
||||
struct dtls_sock *sock, const struct sa *peer,
|
||||
dtls_estab_h *estabh, dtls_recv_h *recvh,
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
#include <re_dbg.h>
|
||||
|
||||
|
||||
enum {
|
||||
MTU_DEFAULT = 1400,
|
||||
MTU_FALLBACK = 548,
|
||||
};
|
||||
|
||||
|
||||
struct dtls_sock {
|
||||
struct sa peer;
|
||||
struct udp_helper *uh;
|
||||
|
@ -33,6 +39,7 @@ struct dtls_sock {
|
|||
struct mbuf *mb;
|
||||
dtls_conn_h *connh;
|
||||
void *arg;
|
||||
size_t mtu;
|
||||
};
|
||||
|
||||
|
||||
|
@ -103,13 +110,21 @@ static int bio_write(BIO *b, const char *buf, int len)
|
|||
|
||||
static long bio_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
(void)b;
|
||||
struct tls_conn *tc = b->ptr;
|
||||
(void)num;
|
||||
(void)ptr;
|
||||
|
||||
if (cmd == BIO_CTRL_FLUSH) {
|
||||
switch (cmd) {
|
||||
|
||||
case BIO_CTRL_FLUSH:
|
||||
/* The OpenSSL library needs this */
|
||||
return 1;
|
||||
|
||||
case BIO_CTRL_DGRAM_QUERY_MTU:
|
||||
return tc ? tc->sock->mtu : MTU_DEFAULT;
|
||||
|
||||
case BIO_CTRL_DGRAM_GET_FALLBACK_MTU:
|
||||
return MTU_FALLBACK;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -706,6 +721,7 @@ int dtls_listen(struct dtls_sock **sockp, const struct sa *laddr,
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
sock->mtu = MTU_DEFAULT;
|
||||
sock->connh = connh;
|
||||
sock->arg = arg;
|
||||
|
||||
|
@ -730,3 +746,18 @@ struct udp_sock *dtls_udp_sock(struct dtls_sock *sock)
|
|||
{
|
||||
return sock ? sock->us : NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set MTU on a DTLS Socket
|
||||
*
|
||||
* @param sock DTLS Socket
|
||||
* @param mtu MTU value
|
||||
*/
|
||||
void dtls_set_mtu(struct dtls_sock *sock, size_t mtu)
|
||||
{
|
||||
if (!sock)
|
||||
return;
|
||||
|
||||
sock->mtu = mtu;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue