initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled

This commit is contained in:
2025-09-16 20:46:46 -04:00
commit 9d30169a8d
13378 changed files with 7050105 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
/* $Id: igd_desc_parse.h,v 1.14 2025/02/08 23:15:16 nanard Exp $ */
/* Project : miniupnp
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author : Thomas Bernard
* Copyright (c) 2005-2025 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
* */
#ifndef IGD_DESC_PARSE_H_INCLUDED
#define IGD_DESC_PARSE_H_INCLUDED
/*! \file igd_desc_parse.h
* \brief API to parse UPNP device description XML
* \todo should not be exposed in the public API
*/
/*! \brief maximum lenght of URLs */
#define MINIUPNPC_URL_MAXSIZE (128)
/*! \brief Structure to store the result of the parsing of UPnP
* descriptions of Internet Gateway Devices services */
struct IGDdatas_service {
/*! \brief controlURL for the service */
char controlurl[MINIUPNPC_URL_MAXSIZE];
/*! \brief eventSubURL for the service */
char eventsuburl[MINIUPNPC_URL_MAXSIZE];
/*! \brief SCPDURL for the service */
char scpdurl[MINIUPNPC_URL_MAXSIZE];
/*! \brief serviceType */
char servicetype[MINIUPNPC_URL_MAXSIZE];
/*char devicetype[MINIUPNPC_URL_MAXSIZE];*/
};
/*! \brief Structure to store the result of the parsing of UPnP
* descriptions of Internet Gateway Devices */
struct IGDdatas {
/*! \brief current element name */
char cureltname[MINIUPNPC_URL_MAXSIZE];
/*! \brief URLBase */
char urlbase[MINIUPNPC_URL_MAXSIZE];
/*! \brief presentationURL */
char presentationurl[MINIUPNPC_URL_MAXSIZE];
/*! \brief depth into the XML tree */
int level;
/*! \brief "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */
struct IGDdatas_service CIF;
/*! \brief first of "urn:schemas-upnp-org:service:WANIPConnection:1"
* or "urn:schemas-upnp-org:service:WANPPPConnection:1" */
struct IGDdatas_service first;
/*! \brief second of "urn:schemas-upnp-org:service:WANIPConnection:1"
* or "urn:schemas-upnp-org:service:WANPPPConnection:1" */
struct IGDdatas_service second;
/*! \brief "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1" */
struct IGDdatas_service IPv6FC;
/*! \brief currently parsed service */
struct IGDdatas_service tmp;
};
/*!
* \brief XML start element handler
*/
void IGDstartelt(void *, const char *, int);
/*!
* \brief XML end element handler
*/
void IGDendelt(void *, const char *, int);
/*!
* \brief XML characted data handler
*/
void IGDdata(void *, const char *, int);
#ifdef DEBUG
void printIGD(struct IGDdatas *);
#endif /* DEBUG */
#endif /* IGD_DESC_PARSE_H_INCLUDED */

View File

@@ -0,0 +1,305 @@
/* $Id: miniupnpc.h,v 1.80 2025/05/26 22:56:40 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project: miniupnp
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author: Thomas Bernard
* Copyright (c) 2005-2025 Thomas Bernard
* This software is subjects to the conditions detailed
* in the LICENCE file provided within this distribution */
#ifndef MINIUPNPC_H_INCLUDED
#define MINIUPNPC_H_INCLUDED
/*! \file miniupnpc.h
* \brief Main C API for MiniUPnPc
*
* Contains functions to discover devices and check for device validity
* or connectivity.
*
* \mainpage MiniUPnPc API documentation
* MiniUPnPc (MiniUPnP client) is a library implementing a UPnP
* Internet Gateway Device (IGD) control point.
*
* It should be used by applications that need to listen to incoming
* traffic from the internet which are running on a LAN where a
* UPnP IGD is running on the router (or gateway).
*
* See more documentation on the website http://miniupnp.free.fr
* or https://miniupnp.tuxfamily.org/ or GitHub :
* https://github.com/miniupnp/miniupnp/tree/master/miniupnpc
*/
#include "miniupnpc_declspec.h"
#include "igd_desc_parse.h"
#include "upnpdev.h"
/* error codes : */
/*! \brief value for success */
#define UPNPDISCOVER_SUCCESS (0)
/*! \brief value for unknown error */
#define UPNPDISCOVER_UNKNOWN_ERROR (-1)
/*! \brief value for a socket error */
#define UPNPDISCOVER_SOCKET_ERROR (-101)
/*! \brief value for a memory allocation error */
#define UPNPDISCOVER_MEMORY_ERROR (-102)
/*! \brief software version */
#define MINIUPNPC_VERSION "2.3.3"
/*! \brief C API version */
#define MINIUPNPC_API_VERSION 21
/*! \brief any (ie system chosen) port */
#define UPNP_LOCAL_PORT_ANY 0
/*! \brief Use as an alias for 1900 for backwards compatibility */
#define UPNP_LOCAL_PORT_SAME 1
#ifdef __cplusplus
extern "C" {
#endif
/* Structures definitions : */
/*!
* \brief UPnP method argument
*/
struct UPNParg {
const char * elt; /*!< \brief UPnP argument name */
const char * val; /*!< \brief UPnP argument value */
};
/*!
* \brief execute a UPnP method (SOAP action)
*
* \todo error reporting should be improved
*
* \param[in] url Control URL for the service
* \param[in] service service to use
* \param[in] action action to call
* \param[in] args action arguments
* \param[out] bufsize the size of the returned buffer
* \return NULL in case of error or the raw XML response
*/
char *
simpleUPnPcommand(const char * url, const char * service,
const char * action, const struct UPNParg * args,
int * bufsize);
/*!
* \brief Discover UPnP IGD on the network.
*
* The discovered devices are returned as a chained list.
* It is up to the caller to free the list with freeUPNPDevlist().
* If available, device list will be obtained from MiniSSDPd.
*
* \param[in] delay (in millisecond) maximum time for waiting any device
* response
* \param[in] multicastif If not NULL, used instead of the default
* multicast interface for sending SSDP discover packets
* \param[in] minissdpdsock Path to minissdpd socket, default is used if
* NULL
* \param[in] localport Source port to send SSDP packets.
* #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
* #UPNP_LOCAL_PORT_ANY to let system assign a source port
* \param[in] ipv6 0 for IPv4, 1 of IPv6
* \param[in] ttl should default to 2 as advised by UDA 1.1
* \param[out] error error code when NULL is returned
* \return NULL or a linked list
*/
MINIUPNP_LIBSPEC struct UPNPDev *
upnpDiscover(int delay, const char * multicastif,
const char * minissdpdsock, int localport,
int ipv6, unsigned char ttl,
int * error);
/*!
* \brief Discover all UPnP devices on the network
*
* search for "ssdp:all"
* \param[in] delay (in millisecond) maximum time for waiting any device
* response
* \param[in] multicastif If not NULL, used instead of the default
* multicast interface for sending SSDP discover packets
* \param[in] minissdpdsock Path to minissdpd socket, default is used if
* NULL
* \param[in] localport Source port to send SSDP packets.
* #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
* #UPNP_LOCAL_PORT_ANY to let system assign a source port
* \param[in] ipv6 0 for IPv4, 1 of IPv6
* \param[in] ttl should default to 2 as advised by UDA 1.1
* \param[out] error error code when NULL is returned
* \return NULL or a linked list
*/
MINIUPNP_LIBSPEC struct UPNPDev *
upnpDiscoverAll(int delay, const char * multicastif,
const char * minissdpdsock, int localport,
int ipv6, unsigned char ttl,
int * error);
/*!
* \brief Discover one type of UPnP devices
*
* \param[in] device device type to search
* \param[in] delay (in millisecond) maximum time for waiting any device
* response
* \param[in] multicastif If not NULL, used instead of the default
* multicast interface for sending SSDP discover packets
* \param[in] minissdpdsock Path to minissdpd socket, default is used if
* NULL
* \param[in] localport Source port to send SSDP packets.
* #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
* #UPNP_LOCAL_PORT_ANY to let system assign a source port
* \param[in] ipv6 0 for IPv4, 1 of IPv6
* \param[in] ttl should default to 2 as advised by UDA 1.1
* \param[out] error error code when NULL is returned
* \return NULL or a linked list
*/
MINIUPNP_LIBSPEC struct UPNPDev *
upnpDiscoverDevice(const char * device, int delay, const char * multicastif,
const char * minissdpdsock, int localport,
int ipv6, unsigned char ttl,
int * error);
/*!
* \brief Discover one or several type of UPnP devices
*
* \param[in] deviceTypes array of device types to search (ending with NULL)
* \param[in] delay (in millisecond) maximum time for waiting any device
* response
* \param[in] multicastif If not NULL, used instead of the default
* multicast interface for sending SSDP discover packets
* \param[in] minissdpdsock Path to minissdpd socket, default is used if
* NULL
* \param[in] localport Source port to send SSDP packets.
* #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
* #UPNP_LOCAL_PORT_ANY to let system assign a source port
* \param[in] ipv6 0 for IPv4, 1 of IPv6
* \param[in] ttl should default to 2 as advised by UDA 1.1
* \param[out] error error code when NULL is returned
* \param[in] searchalltypes 0 to stop with the first type returning results
* \return NULL or a linked list
*/
MINIUPNP_LIBSPEC struct UPNPDev *
upnpDiscoverDevices(const char * const deviceTypes[],
int delay, const char * multicastif,
const char * minissdpdsock, int localport,
int ipv6, unsigned char ttl,
int * error,
int searchalltypes);
/*!
* \brief parse root XML description of a UPnP device
*
* fill the IGDdatas structure.
* \param[in] buffer character buffer containing the XML description
* \param[in] bufsize size in bytes of the buffer
* \param[out] data IGDdatas structure to fill
*/
MINIUPNP_LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data);
/*!
* \brief structure used to get fast access to urls
*/
struct UPNPUrls {
/*! \brief controlURL of the WANIPConnection */
char * controlURL;
/*! \brief url of the description of the WANIPConnection */
char * ipcondescURL;
/*! \brief controlURL of the WANCommonInterfaceConfig */
char * controlURL_CIF;
/*! \brief controlURL of the WANIPv6FirewallControl */
char * controlURL_6FC;
/*! \brief url of the root description */
char * rootdescURL;
};
/*! \brief NO IGD found */
#define UPNP_NO_IGD (0)
/*! \brief valid and connected IGD */
#define UPNP_CONNECTED_IGD (1)
/*! \brief valid and connected IGD but with a reserved address
* (non routable) */
#define UPNP_PRIVATEIP_IGD (2)
/*! \brief valid but not connected IGD */
#define UPNP_DISCONNECTED_IGD (3)
/*! \brief UPnP device not recognized as an IGD */
#define UPNP_UNKNOWN_DEVICE (4)
/*!
* \brief look for a valid and possibly connected IGD in the list
*
* In any non zero return case, the urls and data structures
* passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
* free allocated memory.
* \param[in] devlist A device list obtained with upnpDiscover() /
* upnpDiscoverAll() / upnpDiscoverDevice() / upnpDiscoverDevices()
* \param[out] urls Urls for the IGD found
* \param[out] data datas for the IGD found
* \param[out] lanaddr buffer to copy the local address of the host to reach the IGD
* \param[in] lanaddrlen size of the lanaddr buffer
* \param[out] wanaddr buffer to copy the public address of the IGD
* \param[in] wanaddrlen size of the wanaddr buffer
* \return #UPNP_NO_IGD / #UPNP_CONNECTED_IGD / #UPNP_PRIVATEIP_IGD /
* #UPNP_DISCONNECTED_IGD / #UPNP_UNKNOWN_DEVICE
*/
MINIUPNP_LIBSPEC int
UPNP_GetValidIGD(struct UPNPDev * devlist,
struct UPNPUrls * urls,
struct IGDdatas * data,
char * lanaddr, int lanaddrlen,
char * wanaddr, int wanaddrlen);
/*!
* \brief Get IGD URLs and data for URL
*
* Used when skipping the discovery process.
* \param[in] rootdescurl Root description URL of the device
* \param[out] urls Urls for the IGD found
* \param[out] data datas for the IGD found
* \param[out] lanaddr buffer to copy the local address of the host to reach the IGD
* \param[in] lanaddrlen size of the lanaddr buffer
* \return 0 Not ok / 1 OK
*/
MINIUPNP_LIBSPEC int
UPNP_GetIGDFromUrl(const char * rootdescurl,
struct UPNPUrls * urls,
struct IGDdatas * data,
char * lanaddr, int lanaddrlen);
/*!
* \brief Prepare the URLs for usage
*
* build absolute URLs from the root description
* \param[out] urls URL structure to initialize
* \param[in] data datas for the IGD
* \param[in] descURL root description URL for the IGD
* \param[in] scope_id if not 0, add the scope to the linklocal IPv6
* addresses in URLs
*/
MINIUPNP_LIBSPEC void
GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
const char * descURL, unsigned int scope_id);
/*!
* \brief free the members of a UPNPUrls struct
*
* All URLs buffers are freed and zeroed
* \param[out] urls URL structure to free
*/
MINIUPNP_LIBSPEC void
FreeUPNPUrls(struct UPNPUrls * urls);
/*!
* \brief check the current connection status of an IGD
*
* it uses UPNP_GetStatusInfo()
* \param[in] urls IGD URLs
* \param[in] data IGD data
* \return 1 Connected / 0 Disconnected
*/
MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,22 @@
#ifndef MINIUPNPC_DECLSPEC_H_INCLUDED
#define MINIUPNPC_DECLSPEC_H_INCLUDED
/*! \file miniupnpc_declspec.h
* \brief define #MINIUPNP_LIBSPEC for dll exports and imports */
#if defined(_WIN32) && !defined(MINIUPNP_STATICLIB)
/* for windows dll */
#ifdef MINIUPNP_EXPORTS
#define MINIUPNP_LIBSPEC __declspec(dllexport)
#else
#define MINIUPNP_LIBSPEC __declspec(dllimport)
#endif
#else
#if defined(__GNUC__) && __GNUC__ >= 4
/* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */
#define MINIUPNP_LIBSPEC __attribute__ ((visibility ("default")))
#else
#define MINIUPNP_LIBSPEC
#endif
#endif
#endif /* MINIUPNPC_DECLSPEC_H_INCLUDED */

View File

@@ -0,0 +1,27 @@
/* $Id: miniupnpctypes.h,v 1.4 2025/02/08 23:15:16 nanard Exp $ */
/* Project: miniupnp
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org
* Author: Thomas Bernard
* Copyright (c) 2021-2025 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided within this distribution */
#ifndef MINIUPNPCTYPES_H_INCLUDED
#define MINIUPNPCTYPES_H_INCLUDED
/*! \file miniupnpctypes.h
* \brief type definitions
*
* Use unsigned long long when available :
* strtoull is C99
*
* \def UNSIGNED_INTEGER
* \brief `unsigned long long` or `unsigned int`
* \todo int can be 16 bits, so it should be `unsigned long`
*/
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define UNSIGNED_INTEGER unsigned long long
#else
#define UNSIGNED_INTEGER unsigned int
#endif
#endif

View File

@@ -0,0 +1,54 @@
/* $Id: miniwget.h,v 1.14 2025/02/08 23:15:17 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Copyright (c) 2005-2025 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
* */
#ifndef MINIWGET_H_INCLUDED
#define MINIWGET_H_INCLUDED
/*! \file miniwget.h
* \brief Lightweight HTTP client API
*/
#include "miniupnpc_declspec.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief perform HTTP GET on an URL
*
* \param[in] url HTTP URL to GET
* \param[out] size length of the returned buffer. -1 in case of memory
* allocation error
* \param[in] scope_id interface id for IPv6 to use if not specified in the URL
* \param[out] status_code HTTP response status code (200, 404, etc.)
* \return the body of the HTTP response
*/
MINIUPNP_LIBSPEC void * miniwget(const char * url, int * size,
unsigned int scope_id, int * status_code);
/*! \brief perform HTTP GET on an URL
*
* Also get the local address used to reach the HTTP server
*
* \param[in] url HTTP URL to GET
* \param[out] size length of the returned buffer. -1 in case of memory
* allocation error
* \param[out] addr local address used to connect to the server
* \param[in] addrlen size of the addr buffer
* \param[in] scope_id interface id for IPv6 to use if not specified in the URL
* \param[out] status_code HTTP response status code (200, 404, etc.)
* \return the body of the HTTP response
*/
MINIUPNP_LIBSPEC void * miniwget_getaddr(const char * url, int * size,
char * addr, int addrlen,
unsigned int scope_id, int * status_code);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,91 @@
/* $Id: portlistingparse.h,v 1.12 2025/02/08 23:15:17 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2011-2025 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
#ifndef PORTLISTINGPARSE_H_INCLUDED
#define PORTLISTINGPARSE_H_INCLUDED
/*! \file portlistingparse.h
* \brief Parsing of the list of port mappings
*
* As returned by GetListOfPortMappings.
* Sample of PortMappingEntry :
*
* <p:PortMappingEntry>
* <p:NewRemoteHost>202.233.2.1</p:NewRemoteHost>
* <p:NewExternalPort>2345</p:NewExternalPort>
* <p:NewProtocol>TCP</p:NewProtocol>
* <p:NewInternalPort>2345</p:NewInternalPort>
* <p:NewInternalClient>192.168.1.137</p:NewInternalClient>
* <p:NewEnabled>1</p:NewEnabled>
* <p:NewDescription>dooom</p:NewDescription>
* <p:NewLeaseTime>345</p:NewLeaseTime>
* </p:PortMappingEntry>
*/
#include "miniupnpc_declspec.h"
/* for the definition of UNSIGNED_INTEGER */
#include "miniupnpctypes.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief enum of all XML elements
*/
typedef enum { PortMappingEltNone,
PortMappingEntry, NewRemoteHost,
NewExternalPort, NewProtocol,
NewInternalPort, NewInternalClient,
NewEnabled, NewDescription,
NewLeaseTime } portMappingElt;
/*!
* \brief linked list of port mappings
*/
struct PortMapping {
struct PortMapping * l_next; /*!< \brief next list element */
UNSIGNED_INTEGER leaseTime; /*!< \brief in seconds */
unsigned short externalPort; /*!< \brief external port */
unsigned short internalPort; /*!< \brief internal port */
char remoteHost[64]; /*!< \brief empty for wildcard */
char internalClient[64]; /*!< \brief internal IP address */
char description[64]; /*!< \brief description */
char protocol[4]; /*!< \brief `TCP` or `UDP` */
unsigned char enabled; /*!< \brief 0 (false) or 1 (true) */
};
/*!
* \brief structure for ParsePortListing()
*/
struct PortMappingParserData {
struct PortMapping * l_head; /*!< \brief list head */
portMappingElt curelt; /*!< \brief currently parsed element */
};
/*!
* \brief parse the NewPortListing part of GetListOfPortMappings response
*
* \param[in] buffer XML data
* \param[in] bufsize length of XML data
* \param[out] pdata Parsed data
*/
MINIUPNP_LIBSPEC void
ParsePortListing(const char * buffer, int bufsize,
struct PortMappingParserData * pdata);
/*!
* \brief free parsed data structure
*
* \param[in] pdata Parsed data to free
*/
MINIUPNP_LIBSPEC void
FreePortListing(struct PortMappingParserData * pdata);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,645 @@
/* $Id: upnpcommands.h,v 1.36 2025/03/18 23:40:15 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project: miniupnp
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author: Thomas Bernard
* Copyright (c) 2005-2025 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided within this distribution */
#ifndef UPNPCOMMANDS_H_INCLUDED
#define UPNPCOMMANDS_H_INCLUDED
/*! \file upnpcommands.h
* \brief Internet Gateway Device methods
*
* See the documentation for both IGD v1 and IGD v2 :
* - https://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf
* - https://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v2-Device.pdf
*
* The methods are from WANIPConnection:1 or 2, WANCommonInterfaceConfig:1,
* and WANIPv6FirewallControl:1
*
*/
#include "miniupnpc_declspec.h"
#include "miniupnpctypes.h"
/* MiniUPnPc return codes : */
/*! \brief value for success */
#define UPNPCOMMAND_SUCCESS (0)
/*! \brief value for unknown error */
#define UPNPCOMMAND_UNKNOWN_ERROR (-1)
/*! \brief error while checking the arguments */
#define UPNPCOMMAND_INVALID_ARGS (-2)
/*! \brief HTTP communication error */
#define UPNPCOMMAND_HTTP_ERROR (-3)
/*! \brief The response contains invalid values */
#define UPNPCOMMAND_INVALID_RESPONSE (-4)
/*! \brief Memory allocation error */
#define UPNPCOMMAND_MEM_ALLOC_ERROR (-5)
#ifdef __cplusplus
extern "C" {
#endif
struct PortMappingParserData;
/*! \brief WANCommonInterfaceConfig:GetTotalBytesSent
*
* Note: this is a 32bits unsigned value and rolls over to 0 after reaching
* the maximum value
*
* \param[in] controlURL controlURL of the WANCommonInterfaceConfig of
* a WANDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
*/
MINIUPNP_LIBSPEC UNSIGNED_INTEGER
UPNP_GetTotalBytesSent(const char * controlURL,
const char * servicetype);
/*! \brief WANCommonInterfaceConfig:GetTotalBytesReceived
*
* Note: this is a 32bits unsigned value and rolls over to 0 after reaching
* the maximum value
*
* \param[in] controlURL controlURL of the WANCommonInterfaceConfig of a WANDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
*/
MINIUPNP_LIBSPEC UNSIGNED_INTEGER
UPNP_GetTotalBytesReceived(const char * controlURL,
const char * servicetype);
/*! \brief WANCommonInterfaceConfig:GetTotalPacketsSent
*
* Note: this is a 32bits unsigned value and rolls over to 0 after reaching
* the maximum value
*
* \param[in] controlURL controlURL of the WANCommonInterfaceConfig of a WANDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
*/
MINIUPNP_LIBSPEC UNSIGNED_INTEGER
UPNP_GetTotalPacketsSent(const char * controlURL,
const char * servicetype);
/*! \brief WANCommonInterfaceConfig:GetTotalBytesReceived
*
* Note: this is a 32bits unsigned value and rolls over to 0 after reaching
* the maximum value
*
* \param[in] controlURL controlURL of the WANCommonInterfaceConfig of a WANDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
*/
MINIUPNP_LIBSPEC UNSIGNED_INTEGER
UPNP_GetTotalPacketsReceived(const char * controlURL,
const char * servicetype);
/*! \brief WANIPConnection:GetStatusInfo()
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[out] status 64 bytes buffer : `Unconfigured`, `Connecting`,
* `Connected`, `PendingDisconnect`, `Disconnecting`, `Disconnected`
* \param[out] uptime time in seconds
* \param[out] lastconnerror 64 bytes buffer : `ERROR_NONE`,
* `ERROR_COMMAND_ABORTED`, `ERROR_NOT_ENABLED_FOR_INTERNET`,
* `ERROR_USER_DISCONNECT`, `ERROR_ISP_DISCONNECT`,
* `ERROR_IDLE_DISCONNECT`, `ERROR_FORCED_DISCONNECT`,
* `ERROR_NO_CARRIER`, `ERROR_IP_CONFIGURATION`, `ERROR_UNKNOWN`
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error code
*/
MINIUPNP_LIBSPEC int
UPNP_GetStatusInfo(const char * controlURL,
const char * servicetype,
char * status,
unsigned int * uptime,
char * lastconnerror);
/*! \brief WANIPConnection:GetConnectionTypeInfo()
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[out] connectionType 64 characters buffer : `Unconfigured`,
* `IP_Routed`, `IP_Bridged`
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error code
*/
MINIUPNP_LIBSPEC int
UPNP_GetConnectionTypeInfo(const char * controlURL,
const char * servicetype,
char * connectionType);
/*! \brief WANIPConnection:GetExternalIPAddress()
*
* possible UPnP Errors :
* - 402 Invalid Args - See UPnP Device Architecture section on Control.
* - 501 Action Failed - See UPnP Device Architecture section on Control.
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[out] extIpAdd 16 bytes buffer
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_UNKNOWN_ERROR,
* #UPNPCOMMAND_INVALID_ARGS, #UPNPCOMMAND_HTTP_ERROR or an
* UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_GetExternalIPAddress(const char * controlURL,
const char * servicetype,
char * extIpAdd);
/*! \brief UPNP_GetLinkLayerMaxBitRates()
* call `WANCommonInterfaceConfig:GetCommonLinkProperties`
*
* \param[in] controlURL controlURL of the WANCommonInterfaceConfig of a WANDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
* \param[out] bitrateDown bits per second
* \param[out] bitrateUp bits per second
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
*/
MINIUPNP_LIBSPEC int
UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
const char* servicetype,
unsigned int * bitrateDown,
unsigned int * bitrateUp);
/*! \brief WANIPConnection:AddPortMapping()
*
* List of possible UPnP errors for AddPortMapping :
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | -----------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 501 Action Failed | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 715 WildCardNotPermittedInSrcIP | The source IP address cannot be wild-carded
* 716 WildCardNotPermittedInExtPort | The external port cannot be wild-carded
* 718 ConflictInMappingEntry | The port mapping entry specified conflicts with a mapping assigned previously to another client
* 724 SamePortValuesRequired | Internal and External port values must be the same
* 725 OnlyPermanentLeasesSupported | The NAT implementation only supports permanent lease times on port mappings
* 726 RemoteHostOnlySupportsWildcard | RemoteHost must be a wildcard and cannot be a specific IP address or DNS name
* 727 ExternalPortOnlySupportsWildcard | ExternalPort must be a wildcard and cannot be a specific port value
* 728 NoPortMapsAvailable | There are not enough free ports available to complete port mapping.
* 729 ConflictWithOtherMechanisms | Attempted port mapping is not allowed due to conflict with other mechanisms.
* 732 WildCardNotPermittedInIntPort | The internal port cannot be wild-carded
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[in] extPort External port
* \param[in] inPort Internal port
* \param[in] inClient IP of Internal client.
* \param[in] desc Port Mapping description. if NULL, defaults to
* "libminiupnpc"
* \param[in] proto `TCP` or `UDP`
* \param[in] remoteHost IP or empty string for wildcard. Most IGD don't
* support it
* \param[in] leaseDuration between 0 and 604800
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_MEM_ALLOC_ERROR, #UPNPCOMMAND_HTTP_ERROR,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP error code.
*/
MINIUPNP_LIBSPEC int
UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
const char * extPort,
const char * inPort,
const char * inClient,
const char * desc,
const char * proto,
const char * remoteHost,
const char * leaseDuration);
/*! \brief WANIPConnection:AddAnyPortMapping()
*
* Only in WANIPConnection:2
*
* List of possible UPnP errors for AddPortMapping :
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 501 Action Failed | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 715 WildCardNotPermittedInSrcIP | The source IP address cannot be wild-carded
* 716 WildCardNotPermittedInExtPort | The external port cannot be wild-carded
* 728 NoPortMapsAvailable | There are not enough free ports available to complete port mapping.
* 729 ConflictWithOtherMechanisms | Attempted port mapping is not allowed due to conflict with other mechanisms.
* 732 WildCardNotPermittedInIntPort | The internal port cannot be wild-carded
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:2
* \param[in] extPort External port
* \param[in] inPort Internal port
* \param[in] inClient IP of Internal client.
* \param[in] desc Port Mapping description. if NULL, defaults to
* "libminiupnpc"
* \param[in] proto `TCP` or `UDP`
* \param[in] remoteHost IP or empty string for wildcard. Most IGD don't
* support it
* \param[in] leaseDuration between 0 and 604800
* \param[out] reservedPort 6 bytes buffer
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_MEM_ALLOC_ERROR, #UPNPCOMMAND_HTTP_ERROR,
* #UPNPCOMMAND_INVALID_RESPONSE, #UPNPCOMMAND_UNKNOWN_ERROR
* or a UPnP error code.
*/
MINIUPNP_LIBSPEC int
UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
const char * extPort,
const char * inPort,
const char * inClient,
const char * desc,
const char * proto,
const char * remoteHost,
const char * leaseDuration,
char * reservedPort);
/*! \brief WANIPConnection:DeletePortMapping()
*
* Use same argument values as what was used for UPNP_AddPortMapping()
*
* List of possible UPnP errors for UPNP_DeletePortMapping() :
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 714 NoSuchEntryInArray | The specified value does not exist in the array
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[in] extPort External port
* \param[in] proto `TCP` or `UDP`
* \param[in] remoteHost IP or empty string for wildcard. Most IGD don't
* support it
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_MEM_ALLOC_ERROR, #UPNPCOMMAND_HTTP_ERROR,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP error code.
*/
MINIUPNP_LIBSPEC int
UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
const char * extPort, const char * proto,
const char * remoteHost);
/*! \brief WANIPConnection:DeletePortRangeMapping()
*
* Only in WANIPConnection:2
* Use same argument values as what was used for AddPortMapping().
* remoteHost is usually NULL because IGD don't support it.
* Return Values :
* 0 : SUCCESS
* NON ZERO : error. Either an UPnP error code or an undefined error.
*
* List of possible UPnP errors for DeletePortMapping :
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 730 PortMappingNotFound | This error message is returned if no port mapping is found in the specified range.
* 733 InconsistentParameters | NewStartPort and NewEndPort values are not consistent.
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:2
* \param[in] extPortStart External port range start
* \param[in] extPortEnd External port range end
* \param[in] proto `TCP` or `UDP`
* \param[in] manage `0` to remove only the port mappings of this IGD,
* `1` to remove port mappings also for other clients
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_MEM_ALLOC_ERROR, #UPNPCOMMAND_HTTP_ERROR,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP error code.
*/
MINIUPNP_LIBSPEC int
UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
const char * extPortStart, const char * extPortEnd,
const char * proto,
const char * manage);
/*! \brief WANIPConnection:GetPortMappingNumberOfEntries()
*
* not supported by all routers
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[out] numEntries Port mappings count
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_HTTP_ERROR,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP error code.
*/
MINIUPNP_LIBSPEC int
UPNP_GetPortMappingNumberOfEntries(const char * controlURL,
const char * servicetype,
unsigned int * numEntries);
/*! \brief retrieves an existing port mapping for a port:protocol
*
* List of possible UPnP errors for UPNP_GetSpecificPortMappingEntry() :
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 501 Action Failed | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 714 NoSuchEntryInArray | The specified value does not exist in the array.
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[in] extPort External port
* \param[in] proto `TCP` or `UDP`
* \param[in] remoteHost IP or empty string for wildcard. Most IGD don't
* support it
* \param[out] intClient 16 bytes buffer
* \param[out] intPort 6 bytes buffer
* \param[out] desc 80 bytes buffer
* \param[out] enabled 4 bytes buffer
* \param[out] leaseDuration 16 bytes
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
*/
MINIUPNP_LIBSPEC int
UPNP_GetSpecificPortMappingEntry(const char * controlURL,
const char * servicetype,
const char * extPort,
const char * proto,
const char * remoteHost,
char * intClient,
char * intPort,
char * desc,
char * enabled,
char * leaseDuration);
/*! \brief retrieves an existing port mapping for a port:protocol
*
* List of possible UPnP errors for UPNP_GetSpecificPortMappingEntry() :
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 501 Action Failed | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 714 NoSuchEntryInArray | The specified value does not exist in the array.
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[in] extPort External port
* \param[in] proto `TCP` or `UDP`
* \param[in] remoteHost IP or empty string for wildcard. Most IGD don't
* support it
* \param[out] intClient 16 bytes buffer
* \param[out] intPort 6 bytes buffer
* \param[out] desc desclen bytes buffer
* \param[in] desclen desc buffer length
* \param[out] enabled 4 bytes buffer
* \param[out] leaseDuration 16 bytes
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
*/
MINIUPNP_LIBSPEC int
UPNP_GetSpecificPortMappingEntryExt(const char * controlURL,
const char * servicetype,
const char * extPort,
const char * proto,
const char * remoteHost,
char * intClient,
char * intPort,
char * desc,
size_t desclen,
char * enabled,
char * leaseDuration);
/*! \brief WANIPConnection:GetGenericPortMappingEntry()
*
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 713 SpecifiedArrayIndexInvalid | The specified array index is out of bounds
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[in] index
* \param[out] extPort 6 bytes buffer
* \param[out] intClient 16 bytes buffer
* \param[out] intPort 6 bytes buffer
* \param[out] protocol 4 bytes buffer
* \param[out] desc 80 bytes buffer
* \param[out] enabled 4 bytes buffer
* \param[out] rHost 64 bytes buffer
* \param[out] duration 16 bytes buffer
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
*/
MINIUPNP_LIBSPEC int
UPNP_GetGenericPortMappingEntry(const char * controlURL,
const char * servicetype,
const char * index,
char * extPort,
char * intClient,
char * intPort,
char * protocol,
char * desc,
char * enabled,
char * rHost,
char * duration);
/*! \brief WANIPConnection:GetGenericPortMappingEntry()
*
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 402 Invalid Args | See UPnP Device Architecture section on Control.
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 713 SpecifiedArrayIndexInvalid | The specified array index is out of bounds
*
* \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
* \param[in] index
* \param[out] extPort 6 bytes buffer
* \param[out] intClient 16 bytes buffer
* \param[out] intPort 6 bytes buffer
* \param[out] protocol 4 bytes buffer
* \param[out] desc desclen bytes buffer
* \param[in] desclen desc buffer length
* \param[out] enabled 4 bytes buffer
* \param[out] rHost desclen bytes buffer
* \param[in] rHostlen rHost buffer length
* \param[out] duration 16 bytes buffer
* \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
*/
MINIUPNP_LIBSPEC int
UPNP_GetGenericPortMappingEntryExt(const char * controlURL,
const char * servicetype,
const char * index,
char * extPort,
char * intClient,
char * intPort,
char * protocol,
char * desc,
size_t desclen,
char * enabled,
char * rHost,
size_t rHostlen,
char * duration);
/*! \brief retrieval of a list of existing port mappings
*
* Available in IGD v2 : WANIPConnection:GetListOfPortMappings()
*
* errorCode errorDescription (short) | Description (long)
* ---------------------------------- | ------------------
* 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
* 730 PortMappingNotFound | no port mapping is found in the specified range.
* 733 InconsistantParameters | NewStartPort and NewEndPort values are not consistent.
*
* \param[in] controlURL controlURL of the WANIPConnection of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:2
* \param[in] startPort port interval start
* \param[in] endPort port interval end
* \param[in] protocol `TCP` or `UDP`
* \param[in] numberOfPorts size limit of the list returned. `0` to request
* all port mappings
* \param[out] data port mappings list
*/
MINIUPNP_LIBSPEC int
UPNP_GetListOfPortMappings(const char * controlURL,
const char * servicetype,
const char * startPort,
const char * endPort,
const char * protocol,
const char * numberOfPorts,
struct PortMappingParserData * data);
/*! \brief GetFirewallStatus() retrieves whether the firewall is enabled
* and pinhole can be created through UPnP
*
* IGD:2, functions for service WANIPv6FirewallControl:1
*
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[out] firewallEnabled false (0) or true (1)
* \param[out] inboundPinholeAllowed false (0) or true (1)
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_GetFirewallStatus(const char * controlURL,
const char * servicetype,
int * firewallEnabled,
int * inboundPinholeAllowed);
/*! \brief retrieve default value after which automatically created pinholes
* expire
*
* The returned value may be specific to the \p proto, \p remoteHost,
* \p remotePort, \p intClient and \p intPort, but this behavior depends
* on the implementation of the firewall.
*
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[in] remoteHost
* \param[in] remotePort
* \param[in] intClient
* \param[in] intPort
* \param[in] proto `TCP` or `UDP`
* \param[out] opTimeout lifetime in seconds of an inbound "automatic"
* firewall pinhole created by an outbound traffic initiation.
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_GetOutboundPinholeTimeout(const char * controlURL,
const char * servicetype,
const char * remoteHost,
const char * remotePort,
const char * intClient,
const char * intPort,
const char * proto,
int * opTimeout);
/*! \brief create a new pinhole that allows incoming traffic to pass
* through the firewall
*
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[in] remoteHost literal presentation of IPv6 address or domain name.
* empty string for wildcard
* \param[in] remotePort remote host port. Likely 0 (for wildcard)
* \param[in] intClient IP address of internal client. cannot be wildcarded
* \param[in] intPort client port. 0 for wildcard
* \param[in] proto IP protocol integer (6 for TCP, 17 for UDP, etc.)
* 65535 for wildcard.
* \param[in] leaseTime in seconds
* \param[out] uniqueID 8 bytes buffer
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_AddPinhole(const char * controlURL, const char * servicetype,
const char * remoteHost,
const char * remotePort,
const char * intClient,
const char * intPort,
const char * proto,
const char * leaseTime,
char * uniqueID);
/*! \brief update a pinholes lease time
*
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[in] uniqueID value obtained through UPNP_AddPinhole()
* \param[in] leaseTime in seconds
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
const char * uniqueID,
const char * leaseTime);
/*! \brief remove a pinhole
*
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[in] uniqueID value obtained through UPNP_AddPinhole()
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_DeletePinhole(const char * controlURL,
const char * servicetype,
const char * uniqueID);
/*! \brief checking if a certain pinhole allows traffic to pass through the firewall
*
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[in] uniqueID value obtained through UPNP_AddPinhole()
* \param[out] isWorking `0` for false, `1` for true
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
const char * uniqueID, int * isWorking);
/*! \brief get the total number of IP packets which have been going through
* the specified pinhole
* \todo \p packets should be #UNSIGNED_INTEGER
* \param[in] controlURL controlURL of the WANIPv6FirewallControl of a
* WANConnectionDevice
* \param[in] servicetype urn:schemas-upnp-org:service:WANIPv6FirewallControl:1
* \param[in] uniqueID value obtained through UPNP_AddPinhole()
* \param[out] packets how many IP packets have been going through the
* specified pinhole
* \return #UPNPCOMMAND_UNKNOWN_ERROR, #UPNPCOMMAND_INVALID_ARGS,
* #UPNPCOMMAND_HTTP_ERROR, #UPNPCOMMAND_SUCCESS or an UPnP error code
*/
MINIUPNP_LIBSPEC int
UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
const char * uniqueID, int * packets);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,58 @@
/* $Id: upnpdev.h,v 1.6 2025/02/08 23:15:17 nanard Exp $ */
/* Project : miniupnp
* Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author : Thomas BERNARD
* copyright (c) 2005-2025 Thomas Bernard
* This software is subjet to the conditions detailed in the
* provided LICENSE file. */
#ifndef UPNPDEV_H_INCLUDED
#define UPNPDEV_H_INCLUDED
/*! \file upnpdev.h
* \brief UPNPDev device linked-list structure
* \todo could be merged into miniupnpc.h
*/
#include "miniupnpc_declspec.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief UPnP device linked-list
*/
struct UPNPDev {
/*! \brief pointer to the next element */
struct UPNPDev * pNext;
/*! \brief root description URL */
char * descURL;
/*! \brief ST: as advertised */
char * st;
/*! \brief USN: as advertised */
char * usn;
/*! \brief IPv6 scope id of the network interface */
unsigned int scope_id;
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 flexible array member */
/*! \brief buffer for descURL, st and usn */
char buffer[];
#elif defined(__GNUC__)
char buffer[0];
#else
/* Fallback to a hack */
char buffer[1];
#endif
};
/*! \brief free list returned by upnpDiscover()
* \param[in] devlist linked list to free
*/
MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
#ifdef __cplusplus
}
#endif
#endif /* UPNPDEV_H_INCLUDED */

View File

@@ -0,0 +1,82 @@
/* $Id: upnpreplyparse.h,v 1.22 2025/03/29 17:58:12 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2025 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
#ifndef UPNPREPLYPARSE_H_INCLUDED
#define UPNPREPLYPARSE_H_INCLUDED
/*! \file upnpreplyparse.h
* \brief Parsing of UPnP SOAP responses
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief Name/Value linked list
* not exposed in the public API
*/
struct NameValue;
/*! \brief data structure for parsing */
struct NameValueParserData {
/*! \brief name/value linked list */
struct NameValue * l_head;
/*! \brief current element name */
char curelt[64];
/*! \brief port listing array */
char * portListing;
/*! \brief port listing array length */
int portListingLength;
/*! \brief flag indicating the current element is */
int topelt;
/*! \brief top element character data */
const char * cdata;
/*! \brief top element character data length */
int cdatalen;
};
/*!
* \brief Parse XML and fill the structure
*
* \param[in] buffer XML data
* \param[in] bufsize buffer length
* \param[out] data structure to fill
*/
void
ParseNameValue(const char * buffer, int bufsize,
struct NameValueParserData * data);
/*!
* \brief free memory
*
* \param[in,out] pdata data structure
*/
void
ClearNameValueList(struct NameValueParserData * pdata);
/*!
* \brief get a value from the parsed data
*
* \param[in] pdata data structure
* \param[in] name name
* \return the value or NULL if not found
*/
char *
GetValueFromNameValueList(struct NameValueParserData * pdata,
const char * name);
/* DisplayNameValueList() */
#ifdef DEBUG
void
DisplayNameValueList(char * buffer, int bufsize);
#endif
#ifdef __cplusplus
}
#endif
#endif