DTLS_SET_TIMER_CB(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… DTLS_set_timer_cb β€” like, the timer one (3ossl, bestie)

Okay so real talk, this is the page for DTLS_timer_cb and DTLS_set_timer_cb, and it's literally all about who gets to control how long DTLS waits between packets. It's giving "small function, big responsibility" energy. Let's get into it πŸ’–


✨ NAME ✨

DTLS_timer_cb, DTLS_set_timer_cb β€” set the callback that controls the DTLS timer duration πŸ•°οΈ


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

typedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us);

void DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb);

That's the whole vibe. Two lines of actual signature, one typedef, we move 🫢


✨ DESCRIPTION ✨

So DTLS_set_timer_cb() installs an optional callback that controls the timeout interval on the DTLS protocol. Optional is the keyword here β€” nobody's forcing you, it's not a requirement, it's an option. Slay πŸ’…

Here's the part where it gets kinda cute: DTLS is gonna call your callback for every new DTLS packet that is sent. Every single one. So like, don't put anything slow in there, iykyk 😭

Your callback should return the timeout interval in microseconds. Micro. Not milli, not seconds. Microseconds, bestie, write that down ✨

The timer_us parameter that gets handed to your callback? That's the last set timeout interval returned. And on the very first invocation of the callback, that value will be 0. So the first time you get called, timer_us == 0 β€” that's your "hi, nice to meet you, nothing has happened yet" moment πŸŽ€

Now for the default behavior, because there is one and it's honestly kinda iconic:

  • At the beginning of the connection, if no timeout callback has been set via DTLS_set_timer_cb(), the default timeout value is 1 second.
  • For all subsequent timeouts, the default behavior is to double the duration up to a maximum of 1 minute.

So it's 1 second, then 2, then 4, then it keeps climbing until it hits that 1 minute ceiling and just chills there. Exponential backoff but make it ✨aesthetic✨ πŸ“ˆ

Heads up: if you do set your own callback, you're the main character now β€” the defaults above only apply when you haven't set one. Your callback owns the timer, no cap.

✨ RETURN VALUES ✨

Returns void. That's it. Nothing comes back, no error code, no little treat. It's void and it's thriving πŸ’€


✨ HISTORY ✨

DTLS_set_timer_cb() was added in OpenSSL 1.1.1. So it's been around a minute β€” a certified classic πŸ›οΈ


Copyright 2017-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the License in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>. Please actually read it, bestie, it's giving legally binding πŸ™ˆ


okay that's the whole page, mwah πŸ’‹ This gem is from the 3.5.6 era, dated 2026-04-07, and it lives at DTLS_SET_TIMER_CB(3ossl) β€” go forth and time your packets responsibly, queen πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from