Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtls: add logging of DTLS packet content-type #641

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/tls/openssl/tls_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down