in_pktinfo(2type)

πŸ“¦
version 6.20 Β· 4 versions
, in arch rolling, nixpkgs unstable

✨ in_pktinfo(2type) ✨

okay bestie, pull up a chair, because this page from the in_pktinfo(2type) manual is literally about knowing exactly where your packets came from and where they're headed. it's giving "packet detective" energy and we're obsessed πŸ’–

🌸 NAME 🌸

in_pktinfo β€” all the tea about the incoming packet πŸ«–βœ¨

πŸ’… LIBRARY πŸ’…

Standard C library (libc, -lc). yes, the classic. the blueprint. no cap.

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <netinet/in.h>

struct in_pktinfo {
    unsigned int    ipi_ifindex;   /* Interface index */
    struct in_addr  ipi_spec_dst;  /* Local address */
    struct in_addr  ipi_addr;      /* Header Destination address */
};

look at her. three fields. main character energy in a struct. πŸ‘‘


πŸ”₯ DESCRIPTION πŸ”₯

πŸŽ€ recvmsg(2)

when recvmsg(2) hands this struct back to you, here's what you're lookin at:

  • .ipi_ifindex is the unique index of the interface the packet was received on. like, that specific one. no imposters. πŸ’…
  • .ipi_spec_dst is the preferred source address for replies to the given packet β€” aka "hey, if you're gonna clap back, reply from this address." 🫢
  • .ipi_addr is the destination address in the packet header.

and here's the plot twist 😭: these addresses are usually the same, but they can differ for broadcast or multicast packets. and depending on the configured routes, .ipi_spec_dst might lowkey belong to a different interface from the one that actually received the packet. the way that routes can just switch things up on you… iconic but also unhinged. πŸŒ€

🌈 sendmsg(2)

so when you're sending, it's a whole different vibe:

  • if IP_PKTINFO is passed to sendmsg(2) and .ipi_spec_dst is not zero, then it gets used as the local source address, for the routing table lookup, and for setting up IP source route options. triple threat fr fr. πŸ‘‘
  • when .ipi_ifindex is not zero, the primary local address of the interface specified by the index overwrites .ipi_spec_dst for the routing table lookup. yeah β€” it just overrides it like that. rude but that's the rules. πŸ’€
  • .ipi_addr? ignored. πŸ’€ not even invited to the function call. sorry girl, you're benched.
⚠️ heads up bestie: the overwrite thing in that second bullet is real and it's coming for your .ipi_spec_dst. set .ipi_ifindex with intention, iykyk.

⭐ STANDARDS ⭐

Linux. that's it. that's the standard. 🐧✨

πŸ¦„ HISTORY πŸ¦„

Linux 2.2 β€” so she's been around a minute, but she still ate. πŸ’–

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page!! 🌟 this one came from Linux man-pages 6.20, dated 2025-11-26 β€” so you know it's fresh πŸ“. now go forth and read your packet headers like the networking baddie you are. periodt. πŸ’…πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms