SCTP_GETPADDRS(3)

πŸ“¦
version 1.0.21 Β· 3 versions
  • 1.0.21 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 14.5 Β· freebsd 14.5
  • 15.1 Β· freebsd 15.1
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– SCTP_GETPADDRS(3) πŸ’–

okay bestie, so this is a page from the Linux Programmer's Manual, and it's all about a lil libsctp function called sctp_getpaddrs β€” she's the one who tells you every single peer address chillin' in your SCTP association. no cap. let's get into it πŸ¦‹


✨ NAME ✨

sctp_getpaddrs β€” Returns all peer addresses in an association.

like, all of them. the whole friend group. periodt πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>

int sctp_getpaddrs(int sd, sctp_assoc_t assoc_id,
                   struct sockaddr **addrs);

void sctp_freepaddrs(struct sockaddr *addrs);

πŸŽ€ DESCRIPTION πŸŽ€

so sctp_getpaddrs returns all peer addresses in an association. on return, addrs will point to a dynamically allocated packed array of sockaddr structures β€” and it's the appropriate type for each address, bestie, it's not playing games. the caller should use sctp_freepaddrs to free the memory afterwards, because we are responsible queens who clean up after themselves 🧚

not me stressing this but: the in/out parameter addrs must not be NULL. like, do not. πŸ’€

if sd is an IPv4 socket, the addresses returned will be all IPv4 addresses. if sd is an IPv6 socket, the addresses returned can be a mix of IPv4 or IPv6 addresses ✨

for one-to-many style sockets, id specifies the association to query. for one-to-one style sockets, id is just... ignored. she said "not my business" πŸ™ˆ

sctp_freepaddrs frees all the resources allocated by sctp_getpaddrs. it's giving cleanup crew, it's giving closure 🫢


⭐ RETURN VALUE ⭐

on success, sctp_getpaddrs returns the number of peer addresses in the association. iconic, honestly.

if there is no association on this socket, 0 is returned and the value of *addrs is undefined. 😭

on error, sctp_getpaddrs returns -1 and the value of *addrs is undefined. yes bestie, undefined means undefined, don't go reading it and acting surprised πŸ’€


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie πŸ’œ this one's from Linux 2.6, dated 2005-10-25 β€” yeah she's an elder but she still ate πŸ‘‘ go free your addrs, stay hydrated, and never pass NULL πŸ’…πŸŒΈ

πŸ“¦ where this page comes from