GETNETCONFIG(3)

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

πŸ’» GETNETCONFIG(3) β€” the netconfig girlies' guide πŸ’…

okay so this is a Library Functions Manual page, bestie, and it's literally all about getting your network configuration database entries. no cap, it's more useful than it sounds 🫢


✨ NAME ✨

getnetconfig, setnetconfig, endnetconfig, getnetconfigent, freenetconfigent, nc_perror, nc_sperror β€” get network configuration database entry πŸ’–


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” she's iconic, she's everywhere, she's linked by default πŸŽ€


🌸 SYNOPSIS 🌸

#include <netconfig.h>

struct netconfig *
getnetconfig(void *handlep);

void *
setnetconfig(void);

int
endnetconfig(void *handlep);

struct netconfig *
getnetconfigent(const char *netid);

void
freenetconfigent(struct netconfig *netconfigp);

void
nc_perror(const char *msg);

char *
nc_sperror(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so these library routines are your backstage pass to the system network configuration database, /etc/netconfig. main character access only, iykyk πŸ’…

  • getnetconfig() β€” hands you a pointer to the current entry in the netconfig database, formatted as a struct netconfig. call it again and again and it keeps returning successive entries, like it's scrolling through a feed. it can search the entire netconfig file for you, no skips. when it hits the end of the file it returns NULL (sad but expected 😭). the handlep argument is the handle you got from setnetconfig().
  • setnetconfig() β€” calling this basically "binds" to, or "rewinds", the netconfig database ✨. you must call it before your first getnetconfig(), and honestly you can call it at any other time too, no judgement. it does not need to be called before getnetconfigent() though β€” that one's independent, periodt. it returns a unique handle for getnetconfig() to use.
  • endnetconfig() β€” call this when you're done processing so resources get released for reuse, very responsible of you 🫢. the handlep argument is the handle from setnetconfig(). but bestie, heads up πŸ™ˆ: the last call to endnetconfig() frees all memory allocated by getnetconfig() for the struct netconfig data structure. also, you may not call endnetconfig() before setnetconfig() β€” that's not it.
  • getnetconfigent() β€” returns a pointer to the netconfig structure corresponding to netid. if netid is invalid (aka it doesn't name an entry in the netconfig database), you get NULL. it's giving "no thoughts head empty" πŸ’€
  • freenetconfigent() β€” frees the netconfig structure pointed to by netconfigp, which you previously got from getnetconfigent(). clean up after yourself, queen πŸ‘‘
  • nc_perror() β€” prints a message to the standard error saying why any of the above routines failed. the message gets the string msg and a colon prepended to it, and a newline character is appended at the end. little formatting moment πŸ’–
  • nc_sperror() β€” same energy as nc_perror() but instead of sending the message to standard error, it returns a pointer to a string containing the error message. quieter, lowkey, still slays 🌈

also, side note: nc_perror() and nc_sperror() work with the NETPATH access routines defined in getnetpath(3) too. versatile icons πŸ”₯


⭐ RETURN VALUES ⭐

  • setnetconfig() β€” returns a unique handle for getnetconfig() to use. if something goes wrong it returns NULL, and you can hit up nc_perror() or nc_sperror() to print the reason for the failure.
  • getnetconfig() β€” returns a pointer to the current entry in the netconfig database, formatted as a struct netconfig. returns NULL at the end of the file, or upon failure. it's giving mysterious πŸ’€
  • endnetconfig() β€” returns 0 on success and -1 on failure (like, for example, if setnetconfig() wasn't called previously β€” we been knew πŸ™ˆ).
  • getnetconfigent() β€” on success, returns a pointer to the struct netconfig structure corresponding to netid; otherwise it returns NULL.
  • nc_sperror() β€” returns a pointer to a buffer containing the error message string. this buffer gets overwritten on each call, so don't get attached πŸ’€. in multithreaded applications, this buffer is implemented as thread-specific data ✨ (she's considerate like that).

πŸ“ FILES πŸ“

  • /etc/netconfig β€” the whole vibe lives here

πŸ‘‘ SEE ALSO πŸ‘‘


k that's the whole page, bestie β€” go forth and configure your networks πŸ’–βœ¨πŸŽ€

this cutie came from the Debian crowd, dated April 22, 2000 β€” vintage but still serving πŸ¦‹

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms