From 4ace87cce3861b01cfb6629a11d68b85e0fdb402 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 11 Jan 2023 12:02:03 +0100 Subject: [PATCH] dtls: add logging of DTLS packet content-type --- src/tls/openssl/tls_udp.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/tls/openssl/tls_udp.c b/src/tls/openssl/tls_udp.c index fadb068b3..aab4a1ada 100644 --- a/src/tls/openssl/tls_udp.c +++ b/src/tls/openssl/tls_udp.c @@ -34,6 +34,15 @@ enum { }; +/* TLS ContentType defined in RFC 5246 */ +enum content_type { + TYPE_CHANGE_CIPHER_SPEC = 20, + TYPE_ALERT = 21, + TYPE_HANDSHAKE = 22, + TYPE_APPLICATION_DATA = 23 +}; + + struct dtls_sock { struct sa peer; struct udp_helper *uh; @@ -66,6 +75,21 @@ struct tls_conn { }; +#if DEBUG_LEVEL >= 6 +static const char *content_type_str(enum content_type content_type) +{ + switch (content_type) { + + case TYPE_CHANGE_CIPHER_SPEC: return "CHANGE_CIPHER_SPEC"; + case TYPE_ALERT: return "ALERT"; + case TYPE_HANDSHAKE: return "HANDSHAKE"; + case TYPE_APPLICATION_DATA: return "APPLICATION_DATA"; + default: return "???"; + } +} +#endif + + static int bio_create(BIO *b) { BIO_set_init(b, 1); @@ -702,6 +726,8 @@ static bool recv_handler(struct sa *src, struct mbuf *mb, void *arg) if (b < 20 || b > 63) return false; + DEBUG_INFO("receive '%s' from %J\n", content_type_str(b), src); + tc = conn_lookup(sock, src); if (tc) { conn_recv(tc, mb);