ARES_PARSE_PTR_REPLY(3)

πŸ“¦
version 1.34.9 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ ares_parse_ptr_reply β€” the PTR parser era ✨

ok so bestie, this is the manual page for ares_parse_ptr_reply, living in section 3 of the Library Functions Manual. she's a libc-ares girlie and she has ONE job and she does it slayfully πŸ’…


🌸 NAME 🌸

ares_parse_ptr_reply β€” parse a reply to a DNS query of type PTR into a hostent


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <ares.h>

int ares_parse_ptr_reply(const unsigned char *abuf, int alen,
                         const void *addr, int addrlen,
                         int family, struct hostent **host);

πŸ’– DESCRIPTION πŸ’–

okay so picture this: you sent out a DNS query of type PTR, the response came back, and now somebody has to make sense of it. that somebody is ares_parse_ptr_reply. she takes the response and parses it into a struct hostent. no cap. 🫢

here's the deets on the parameters:

  • abuf and alen β€” these two give the contents of the response. that's the whole raw reply, right there.
  • addr, addrlen, and family β€” these specify which address was queried for. and listen, important: they are not used to verify the response. not even a little. they are merely used to fill in the address of the struct hostent. so don't come for her thinking she's validating anything, because she is not. πŸ™ˆ

the resulting struct hostent gets stored in allocated memory, and a pointer to it gets stored into the variable pointed to by host.

⚠️ bestie, this is the part you cannot skip: it is the caller's responsibility to free the resulting host structure using ares_free_hostent(3) when it is no longer needed. that's you. you're the caller. free your girl or she's leaking in memory forever 😭

πŸ”₯ RETURN VALUES πŸ”₯

ares_parse_ptr_reply can return any of the following values:

  • ARES_SUCCESS β€” the response was successfully parsed. we ate. πŸŽ€
  • ARES_EBADRESP β€” the response was malformatted. it's giving cursed input πŸ’€
  • ARES_ENODATA β€” the response did not contain an answer to the query. nothing there. ghosted ✨
  • ARES_ENOMEM β€” memory was exhausted. she's tired, your honor 😭

🌈 SEE ALSO 🌈


and that's the whole page, bestie β€” this icon was documented back on 25 July 1998, and she comes to you courtesy of the Library Functions Manual. yes she's vintage, yes she still serves. periodt πŸ’…πŸ‘‘