MINIUPNPC(3)

πŸ“¦
version 2.3.3 Β· 2 versions
, in alpine 3.24, arch rolling, debian trixie, epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– MINIUPNPC πŸ’–

okay bestie, welcome to the miniupnpc page β€” it's the UPnP client library and it's lowkey iconic. Manual section 3, library functions energy. let's get into it 🫢


✨ SYNOPSIS ✨

ngl this section is literally empty in the original. no synopsis line, no nothing. she said "I contain multitudes" and then said nothing at all πŸ’€ so we move.


πŸ¦‹ DESCRIPTION πŸ¦‹

so the miniupnpc library implements the UPnP protocol β€” the one defined to dialog with Internet Gateway Devices. and the way that it ALSO has the ability to use data gathered by minissdpd(1) about UPnP devices up on the network?? to skip the long UPnP device discovery process?? yeah. shortcut queen. periodt. ✨

here's the flow, bestie, step by step:

  1. At first, upnpDiscover(3) has to be used to discover the UPnP IGD present on the network.
  2. Then UPNP_GetValidIGD(3) to select the right one.
  3. Alternatively, UPNP_GetIGDFromUrl(3) could be used to bypass the discovery process if the root description url of the device to use is known. (iykyk β€” if you already know the url, you don't gotta go looking πŸ‘‘)
  4. Then all the UPNP_* functions can be used, such as UPNP_GetConnectionTypeInfo(3), UPNP_AddPortMapping(3), etc...

like. the pipeline is pipeline-ing. slay. πŸ’…


πŸŽ€ HEADER FILES πŸŽ€

  • miniupnpc.h β€” that's the main header file for the miniupnpc library API. It contains all the functions and structures related to device discovery. main character header fr fr.
  • upnpcommands.h β€” this header file contains the UPnP IGD methods that are accessible through the miniupnpc API. The name of the C functions are matching the UPnP methods names, ie: GetGenericPortMappingEntry is UPNP_GetGenericPortMappingEntry. so if you ever forget the name, just slap UPNP_ on the front and vibe check it 🌸

🌈 API FUNCTIONS 🌈

struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int localport, int ipv6, int * error);

execute the discovery process. okay so:

  • delay (in millisecond) is the maximum time for waiting any device response. patience is a virtue bestie ⏳
  • If available, device list will be obtained from MiniSSDPd.
  • Default path for minissdpd socket will be used if minissdpdsock argument is NULL.
  • If multicastif is not NULL, it will be used instead of the default multicast interface for sending SSDP discover packets.
  • If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent from the source port 1900 (same as destination port), if set to UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will be attempted as the source port.
  • If ipv6 is not 0, IPv6 is used instead of IPv4 for the discovery process.
struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int localport, int ipv6, int * error);

void freeUPNPDevlist(struct UPNPDev * devlist);

free the list returned by upnpDiscover(). clean up after yourself, bestie, it's giving responsibility 🧹

void freeUPNPDevlist(struct UPNPDev * devlist);

int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen, char * wanaddr, int wanaddrlen);

browse the list of device returned by upnpDiscover(), find a live UPnP internet gateway device and fill structures passed as arguments with data used for UPNP methods invocation. it's the vibe check that says "yeah this one's alive, use her" βœ…

int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen, char * wanaddr, int wanaddrlen);

int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);

permit one to bypass the upnpDiscover() call if the xml root description URL of the UPnP IGD is known. Fill structures passed as arguments with data used for UPNP methods invocation. skipping the line and still getting in?? that's the dream πŸ”₯

int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);

void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);

void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);

void FreeUPNPUrls(struct UPNPUrls *);

void FreeUPNPUrls(struct UPNPUrls *);

πŸ‘€ SEE ALSO πŸ‘€

go read that one too bestie, it's the whole reason we can skip the discovery grind 🫢


πŸ’€ BUGS πŸ’€

literally nothing listed here. no bugs were reported. flawless behavior. we love to see it πŸ™ˆβœ¨


and that's the whole page bestie!! every flag, every argument, every function, nothing skipped, no cap. go forth and UPnP πŸ’œ

sign-off szn πŸŽ€ this lil masterpiece came out of the Library Functions Manual as MINIUPNPC(3) on both ends β€” same name top and bottom, symmetrical queen πŸ‘‘ β€” and it's filed under that same MINIUPNPC(3) source/version-and-date footer vibe. mwah. πŸ’…πŸŒΈ