Skip to content

Commit 7c2d0d0

Browse files
author
Richard Aas
committed
stun/dtls: adding stun_transp_name() and dtls_udp_sock() functions
1 parent 6c99fc3 commit 7c2d0d0

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

include/re_stun.h

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void stun_msg_dump(const struct stun_msg *msg);
225225
const char *stun_class_name(uint16_t cls);
226226
const char *stun_method_name(uint16_t method);
227227
const char *stun_attr_name(uint16_t type);
228+
const char *stun_transp_name(enum stun_transp tp);
228229

229230

230231
/* DNS Discovery of a STUN Server */

include/re_tls.h

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct dtls_sock;
6060
int dtls_listen(struct dtls_sock **sockp, const struct sa *laddr,
6161
struct udp_sock *us, uint32_t htsize, int layer,
6262
dtls_conn_h *connh, void *arg);
63+
struct udp_sock *dtls_udp_sock(struct dtls_sock *sock);
6364
int dtls_connect(struct tls_conn **ptc, struct tls *tls,
6465
struct dtls_sock *sock, const struct sa *peer,
6566
dtls_estab_h *estabh, dtls_recv_h *recvh,

src/stun/stunstr.c

+19
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,22 @@ const char *stun_reason_443 = "Peer Address Family Mismatch";
2525
const char *stun_reason_486 = "Allocation Quota Reached";
2626
const char *stun_reason_500 = "Server Error";
2727
const char *stun_reason_508 = "Insufficient Capacity";
28+
29+
30+
/**
31+
* Get the name of a given STUN Transport
32+
*
33+
* @param tp STUN Transport
34+
*
35+
* @return Name of the corresponding STUN Transport
36+
*/
37+
const char *stun_transp_name(enum stun_transp tp)
38+
{
39+
switch (tp) {
40+
41+
case STUN_TRANSP_UDP: return "UDP";
42+
case STUN_TRANSP_TCP: return "TCP";
43+
case STUN_TRANSP_DTLS: return "DTLS";
44+
default: return "???";
45+
}
46+
}

src/tls/openssl/tls_udp.c

+13
Original file line numberDiff line numberDiff line change
@@ -715,3 +715,16 @@ int dtls_listen(struct dtls_sock **sockp, const struct sa *laddr,
715715

716716
return err;
717717
}
718+
719+
720+
/**
721+
* Get the underlying UDP socket of a DTLS Socket
722+
*
723+
* @param sock DTLS Socket
724+
*
725+
* @return UDP Socket
726+
*/
727+
struct udp_sock *dtls_udp_sock(struct dtls_sock *sock)
728+
{
729+
return sock ? sock->us : NULL;
730+
}

0 commit comments

Comments
 (0)