SSL_INJECT_NET_DGRAM(3SSL)

πŸ’– SSL_INJECT_NET_DGRAM πŸ’–

okay bestie, so this one is a page from the OpenSSL manuals β€” specifically the 3SSL section, iykyk β€” and it's all about one tiny little function called SSL_inject_net_dgram. let's get into it 🫢


✨ NAME ✨

SSL_inject_net_dgram β€” inject a datagram as though received from the network 🌐✨

like, you're just gonna pretend the network handed you this packet. and honestly? iconic behavior.


🌸 SYNOPSIS 🌸

#include <openssl/ssl.h>

int SSL_inject_net_dgram(SSL *s, const unsigned char *buf,
                         size_t buf_len,
                         const BIO_ADDR *peer,
                         const BIO_ADDR *local);

there she is. five args, no notes. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so this function lets you inject a datagram payload straight into a QUIC connection SSL object. the payload gets processed as though it was received from the network. literally it's giving "I made this at home but we're gonna act like it came from the outside world."

what's it for? two main character reasons:

  • debugging purposes πŸ›πŸ”
  • letting datagrams be fed to QUIC from alternative sources β€” because sometimes the network isn't the one serving, and that's okay ✨

now, the args, one by one:

  • buf is required. it must point to a datagram payload you want to inject. no buf, no vibes, no function.
  • buf_len is the length of that buffer, in bytes. πŸ“
  • good news tho: the buffer is copied, so it does not need to remain valid after this function returns. go ahead and free it, bestie, she's safe πŸ’–
  • peer and local are optional β€” they point to BIO_ADDR structures describing the remote and local UDP endpoint addresses for the packet. πŸ“¬
  • and here's the tea: even though the injected packet was not actually received from the network directly by OpenSSL, the packet will be processed as though the received datagram had the given addresses. fake it till you make it, periodt. πŸ‘‘

πŸŽ€ RETURN VALUES πŸŽ€

  • returns 1 on success πŸŽ‰
  • returns 0 on failure 😭
⚠️ heads up: this function always fails if you call it on an SSL object that is not a QUIC connection SSL object. no QUIC, no service. she said what she said. πŸ’€

πŸ’œ SEE ALSO πŸ’œ

go read these too, they're all part of the same little friend group:


🌈 HISTORY 🌈

the function SSL_inject_net_dgram() was added in OpenSSL 3.2. so if you're on something older, she's not there yet, sorry babe πŸ₯²


Copyright 2023 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 in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie!! πŸŽ€ this was OpenSSL 4.0.3, dated 2026-09-29 β€” slay, go inject some datagrams responsibly πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from