miniupnpc 2.3.0__tar.gz → 2.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. miniupnpc-2.3.2/DESCRIPTION +6 -0
  2. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/MANIFEST.in +1 -0
  3. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/Makefile +10 -4
  4. {miniupnpc-2.3.0/miniupnpc.egg-info → miniupnpc-2.3.2}/PKG-INFO +2 -2
  5. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/README +1 -1
  6. miniupnpc-2.3.2/VERSION +1 -0
  7. miniupnpc-2.3.2/include/igd_desc_parse.h +75 -0
  8. miniupnpc-2.3.2/include/miniupnpc.h +303 -0
  9. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/include/miniupnpc_declspec.h +2 -1
  10. miniupnpc-2.3.2/include/miniupnpctypes.h +27 -0
  11. miniupnpc-2.3.2/include/miniwget.h +54 -0
  12. miniupnpc-2.3.2/include/portlistingparse.h +91 -0
  13. miniupnpc-2.3.2/include/upnpcommands.h +568 -0
  14. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/include/upnpdev.h +18 -4
  15. miniupnpc-2.3.2/include/upnperrors.h +36 -0
  16. miniupnpc-2.3.2/include/upnpreplyparse.h +82 -0
  17. {miniupnpc-2.3.0 → miniupnpc-2.3.2/miniupnpc.egg-info}/PKG-INFO +2 -2
  18. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/miniupnpc.egg-info/SOURCES.txt +1 -0
  19. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/addr_is_reserved.c +6 -3
  20. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minissdpc.c +9 -6
  21. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/miniupnpc.c +1 -1
  22. miniupnpc-2.3.2/src/miniwget_private.h +54 -0
  23. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/upnpcommands.c +150 -232
  24. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/upnpreplyparse.c +23 -33
  25. miniupnpc-2.3.0/VERSION +0 -1
  26. miniupnpc-2.3.0/include/igd_desc_parse.h +0 -49
  27. miniupnpc-2.3.0/include/miniupnpc.h +0 -162
  28. miniupnpc-2.3.0/include/miniupnpctypes.h +0 -21
  29. miniupnpc-2.3.0/include/miniwget.h +0 -27
  30. miniupnpc-2.3.0/include/portlistingparse.h +0 -65
  31. miniupnpc-2.3.0/include/upnpcommands.h +0 -348
  32. miniupnpc-2.3.0/include/upnperrors.h +0 -26
  33. miniupnpc-2.3.0/include/upnpreplyparse.h +0 -63
  34. miniupnpc-2.3.0/src/miniwget_private.h +0 -15
  35. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/LICENSE +0 -0
  36. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/external-ip.sh +0 -0
  37. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/miniupnpc.egg-info/dependency_links.txt +0 -0
  38. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/miniupnpc.egg-info/top_level.txt +0 -0
  39. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/miniupnpcstrings.h.in +0 -0
  40. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/setup.cfg +0 -0
  41. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/setup.py +0 -0
  42. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/setupmingw32.py +0 -0
  43. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/addr_is_reserved.h +0 -0
  44. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/codelength.h +0 -0
  45. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/connecthostport.c +0 -0
  46. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/connecthostport.h +0 -0
  47. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/igd_desc_parse.c +0 -0
  48. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/listdevices.c +0 -0
  49. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minihttptestserver.c +0 -0
  50. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minisoap.c +0 -0
  51. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minisoap.h +0 -0
  52. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minissdpc.h +0 -0
  53. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/miniupnpc_socketdef.h +0 -0
  54. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/miniupnpcmodule.c +0 -0
  55. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/miniwget.c +0 -0
  56. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minixml.c +0 -0
  57. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minixml.h +0 -0
  58. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/minixmlvalid.c +0 -0
  59. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/portlistingparse.c +0 -0
  60. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/receivedata.c +0 -0
  61. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/receivedata.h +0 -0
  62. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/testaddr_is_reserved.c +0 -0
  63. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/testigddescparse.c +0 -0
  64. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/testminiwget.c +0 -0
  65. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/testminixml.c +0 -0
  66. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/testportlistingparse.c +0 -0
  67. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/testupnpreplyparse.c +0 -0
  68. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/upnpc.c +0 -0
  69. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/upnpdev.c +0 -0
  70. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/upnperrors.c +0 -0
  71. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/src/win32_snprintf.h +0 -0
  72. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/testminiwget.sh +0 -0
  73. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/testupnpreplyparse.sh +0 -0
  74. {miniupnpc-2.3.0 → miniupnpc-2.3.2}/updateminiupnpcstrings.sh +0 -0
@@ -0,0 +1,6 @@
1
+ MiniUPnPc is a library enabling applications to access the services provided
2
+ by an UPnP "Internet Gateway Device" present on the network. In UPnP
3
+ terminology, MiniUPnPc is a UPnP Control Point.
4
+
5
+ MiniUPnPc is designed to have low footprint and the libc as unique
6
+ dependency.
@@ -1,6 +1,7 @@
1
1
  include README
2
2
  include VERSION
3
3
  include LICENSE
4
+ include DESCRIPTION
4
5
  include src/miniupnpcmodule.c
5
6
  include setup.py
6
7
  include Makefile
@@ -1,9 +1,9 @@
1
- # $Id: Makefile,v 1.150 2023/06/15 22:55:24 nanard Exp $
1
+ # $Id: Makefile,v 1.155 2025/03/02 01:17:19 nanard Exp $
2
2
  # MiniUPnP Project
3
3
  # http://miniupnp.free.fr/
4
4
  # https://miniupnp.tuxfamily.org/
5
5
  # https://github.com/miniupnp/miniupnp
6
- # (c) 2005-2024 Thomas Bernard
6
+ # (c) 2005-2025 Thomas Bernard
7
7
  # to install use :
8
8
  # $ make DESTDIR=/tmp/dummylocation install
9
9
  # or
@@ -84,9 +84,10 @@ ifneq (, $(findstring sun, $(OS))$(findstring solaris, $(OS)))
84
84
  endif
85
85
 
86
86
  # APIVERSION is used to build SONAME
87
- APIVERSION = 19
87
+ APIVERSION = 20
88
88
 
89
89
  SRCS = $(wildcard $(SRCDIR)/*.c)
90
+ PRIVATE_HEADERS = $(wildcard $(SRCDIR)/*.h)
90
91
 
91
92
  LIBOBJS = $(addprefix $(BUILD)/,miniwget.o minixml.o igd_desc_parse.o minisoap.o \
92
93
  miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
@@ -167,7 +168,7 @@ endif
167
168
 
168
169
 
169
170
  .PHONY: install clean depend all check test everything \
170
- installpythonmodule updateversion
171
+ installpythonmodule updateversion doc
171
172
 
172
173
  all: $(LIBRARY) $(EXECUTABLES)
173
174
 
@@ -178,6 +179,8 @@ check: validateminixml validateminiwget validateupnpreplyparse \
178
179
 
179
180
  everything: all $(EXECUTABLES_ADDTESTS)
180
181
 
182
+ doc: doxygen/html/index.html
183
+
181
184
  # note : the python module "wheel" is required for bdist_wheel
182
185
  pythonmodule: $(LIBRARY) $(SRCDIR)/miniupnpcmodule.c setup.py
183
186
  MAKE=$(MAKE) python setup.py build
@@ -397,6 +400,9 @@ ideb:
397
400
 
398
401
  minihttptestserver: minihttptestserver.o
399
402
 
403
+ doxygen/html/index.html: Doxyfile $(SRCS) $(HEADERS) $(PRIVATE_HEADERS)
404
+ doxygen
405
+
400
406
  print-%:
401
407
  @echo "$* = $($*)"
402
408
 
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: miniupnpc
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: MiniUPnP IGD client
5
5
  Home-page: https://miniupnp.tuxfamily.org/
6
6
  Author: Thomas BERNARD
7
7
  Author-email: miniupnp@free.fr
8
8
  License: BSD 3-Clause License
9
9
 
10
- Copyright (c) 2005-2024, Thomas BERNARD
10
+ Copyright (c) 2005-2025, Thomas BERNARD
11
11
  All rights reserved.
12
12
 
13
13
  Redistribution and use in source and binary forms, with or without
@@ -2,7 +2,7 @@ Project: miniupnp
2
2
  Project web page: http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
3
3
  github: https://github.com/miniupnp/miniupnp
4
4
  Author: Thomas Bernard
5
- Copyright (c) 2005-2023 Thomas Bernard
5
+ Copyright (c) 2005-2025 Thomas Bernard
6
6
  This software is subject to the conditions detailed in the
7
7
  LICENSE file provided within this distribution.
8
8
 
@@ -0,0 +1 @@
1
+ 2.3.2
@@ -0,0 +1,75 @@
1
+ /* $Id: igd_desc_parse.h,v 1.14 2025/02/08 23:15:16 nanard Exp $ */
2
+ /* Project : miniupnp
3
+ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
4
+ * Author : Thomas Bernard
5
+ * Copyright (c) 2005-2025 Thomas Bernard
6
+ * This software is subject to the conditions detailed in the
7
+ * LICENCE file provided in this distribution.
8
+ * */
9
+ #ifndef IGD_DESC_PARSE_H_INCLUDED
10
+ #define IGD_DESC_PARSE_H_INCLUDED
11
+
12
+ /*! \file igd_desc_parse.h
13
+ * \brief API to parse UPNP device description XML
14
+ * \todo should not be exposed in the public API
15
+ */
16
+
17
+ /*! \brief maximum lenght of URLs */
18
+ #define MINIUPNPC_URL_MAXSIZE (128)
19
+
20
+ /*! \brief Structure to store the result of the parsing of UPnP
21
+ * descriptions of Internet Gateway Devices services */
22
+ struct IGDdatas_service {
23
+ /*! \brief controlURL for the service */
24
+ char controlurl[MINIUPNPC_URL_MAXSIZE];
25
+ /*! \brief eventSubURL for the service */
26
+ char eventsuburl[MINIUPNPC_URL_MAXSIZE];
27
+ /*! \brief SCPDURL for the service */
28
+ char scpdurl[MINIUPNPC_URL_MAXSIZE];
29
+ /*! \brief serviceType */
30
+ char servicetype[MINIUPNPC_URL_MAXSIZE];
31
+ /*char devicetype[MINIUPNPC_URL_MAXSIZE];*/
32
+ };
33
+
34
+ /*! \brief Structure to store the result of the parsing of UPnP
35
+ * descriptions of Internet Gateway Devices */
36
+ struct IGDdatas {
37
+ /*! \brief current element name */
38
+ char cureltname[MINIUPNPC_URL_MAXSIZE];
39
+ /*! \brief URLBase */
40
+ char urlbase[MINIUPNPC_URL_MAXSIZE];
41
+ /*! \brief presentationURL */
42
+ char presentationurl[MINIUPNPC_URL_MAXSIZE];
43
+ /*! \brief depth into the XML tree */
44
+ int level;
45
+ /*! \brief "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */
46
+ struct IGDdatas_service CIF;
47
+ /*! \brief first of "urn:schemas-upnp-org:service:WANIPConnection:1"
48
+ * or "urn:schemas-upnp-org:service:WANPPPConnection:1" */
49
+ struct IGDdatas_service first;
50
+ /*! \brief second of "urn:schemas-upnp-org:service:WANIPConnection:1"
51
+ * or "urn:schemas-upnp-org:service:WANPPPConnection:1" */
52
+ struct IGDdatas_service second;
53
+ /*! \brief "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1" */
54
+ struct IGDdatas_service IPv6FC;
55
+ /*! \brief currently parsed service */
56
+ struct IGDdatas_service tmp;
57
+ };
58
+
59
+ /*!
60
+ * \brief XML start element handler
61
+ */
62
+ void IGDstartelt(void *, const char *, int);
63
+ /*!
64
+ * \brief XML end element handler
65
+ */
66
+ void IGDendelt(void *, const char *, int);
67
+ /*!
68
+ * \brief XML characted data handler
69
+ */
70
+ void IGDdata(void *, const char *, int);
71
+ #ifdef DEBUG
72
+ void printIGD(struct IGDdatas *);
73
+ #endif /* DEBUG */
74
+
75
+ #endif /* IGD_DESC_PARSE_H_INCLUDED */
@@ -0,0 +1,303 @@
1
+ /* $Id: miniupnpc.h,v 1.76 2025/03/05 10:35:57 nanard Exp $ */
2
+ /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
+ * Project: miniupnp
4
+ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
5
+ * Author: Thomas Bernard
6
+ * Copyright (c) 2005-2025 Thomas Bernard
7
+ * This software is subjects to the conditions detailed
8
+ * in the LICENCE file provided within this distribution */
9
+ #ifndef MINIUPNPC_H_INCLUDED
10
+ #define MINIUPNPC_H_INCLUDED
11
+
12
+ /*! \file miniupnpc.h
13
+ * \brief Main C API for MiniUPnPc
14
+ *
15
+ * Contains functions to discover devices and check for device validity
16
+ * or connectivity.
17
+ *
18
+ * \mainpage MiniUPnPc API documentation
19
+ * MiniUPnPc (MiniUPnP client) is a library implementing a UPnP
20
+ * Internet Gateway Device (IGD) control point.
21
+ *
22
+ * It should be used by applications that needs to listen to incoming
23
+ * traffic from the internet which are running on a LAN where a
24
+ * UPnP IGD is running on the router (or gateway).
25
+ *
26
+ * See more documentation on the website http://miniupnp.free.fr
27
+ * or https://miniupnp.tuxfamily.org/ or GitHub :
28
+ * https://github.com/miniupnp/miniupnp/tree/master/miniupnpc
29
+ */
30
+ #include "miniupnpc_declspec.h"
31
+ #include "igd_desc_parse.h"
32
+ #include "upnpdev.h"
33
+
34
+ /* error codes : */
35
+ /*! \brief value for success */
36
+ #define UPNPDISCOVER_SUCCESS (0)
37
+ /*! \brief value for unknown error */
38
+ #define UPNPDISCOVER_UNKNOWN_ERROR (-1)
39
+ /*! \brief value for a socket error */
40
+ #define UPNPDISCOVER_SOCKET_ERROR (-101)
41
+ /*! \brief value for a memory allocation error */
42
+ #define UPNPDISCOVER_MEMORY_ERROR (-102)
43
+
44
+ /*! \brief software version */
45
+ #define MINIUPNPC_VERSION "2.3.2"
46
+ /*! \brief C API version */
47
+ #define MINIUPNPC_API_VERSION 20
48
+
49
+ /*! \brief any (ie system chosen) port */
50
+ #define UPNP_LOCAL_PORT_ANY 0
51
+ /*! \brief Use as an alias for 1900 for backwards compatibility */
52
+ #define UPNP_LOCAL_PORT_SAME 1
53
+
54
+ #ifdef __cplusplus
55
+ extern "C" {
56
+ #endif
57
+
58
+ /* Structures definitions : */
59
+
60
+ /*!
61
+ * \brief UPnP method argument
62
+ */
63
+ struct UPNParg {
64
+ const char * elt; /*!< \brief UPnP argument name */
65
+ const char * val; /*!< \brief UPnP argument value */
66
+ };
67
+
68
+ /*!
69
+ * \brief execute a UPnP method (SOAP action)
70
+ *
71
+ * \param[in] url Control URL for the service
72
+ * \param[in] service service to use
73
+ * \param[in] action action to call
74
+ * \param[in] args action arguments
75
+ * \param[out] bufsize the size of the returned buffer
76
+ * \return NULL in case of error or the raw XML response
77
+ */
78
+ char *
79
+ simpleUPnPcommand(const char * url, const char * service,
80
+ const char * action, const struct UPNParg * args,
81
+ int * bufsize);
82
+
83
+ /*!
84
+ * \brief Discover UPnP IGD on the network.
85
+ *
86
+ * The discovered devices are returned as a chained list.
87
+ * It is up to the caller to free the list with freeUPNPDevlist().
88
+ * If available, device list will be obtained from MiniSSDPd.
89
+ *
90
+ * \param[in] delay (in millisecond) maximum time for waiting any device
91
+ * response
92
+ * \param[in] multicastif If not NULL, used instead of the default
93
+ * multicast interface for sending SSDP discover packets
94
+ * \param[in] minissdpdsock Path to minissdpd socket, default is used if
95
+ * NULL
96
+ * \param[in] localport Source port to send SSDP packets.
97
+ * #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
98
+ * #UPNP_LOCAL_PORT_ANY to let system assign a source port
99
+ * \param[in] ipv6 0 for IPv4, 1 of IPv6
100
+ * \param[in] ttl should default to 2 as advised by UDA 1.1
101
+ * \param[out] error error code when NULL is returned
102
+ * \return NULL or a linked list
103
+ */
104
+ MINIUPNP_LIBSPEC struct UPNPDev *
105
+ upnpDiscover(int delay, const char * multicastif,
106
+ const char * minissdpdsock, int localport,
107
+ int ipv6, unsigned char ttl,
108
+ int * error);
109
+
110
+ /*!
111
+ * \brief Discover all UPnP devices on the network
112
+ *
113
+ * search for "ssdp:all"
114
+ * \param[in] delay (in millisecond) maximum time for waiting any device
115
+ * response
116
+ * \param[in] multicastif If not NULL, used instead of the default
117
+ * multicast interface for sending SSDP discover packets
118
+ * \param[in] minissdpdsock Path to minissdpd socket, default is used if
119
+ * NULL
120
+ * \param[in] localport Source port to send SSDP packets.
121
+ * #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
122
+ * #UPNP_LOCAL_PORT_ANY to let system assign a source port
123
+ * \param[in] ipv6 0 for IPv4, 1 of IPv6
124
+ * \param[in] ttl should default to 2 as advised by UDA 1.1
125
+ * \param[out] error error code when NULL is returned
126
+ * \return NULL or a linked list
127
+ */
128
+ MINIUPNP_LIBSPEC struct UPNPDev *
129
+ upnpDiscoverAll(int delay, const char * multicastif,
130
+ const char * minissdpdsock, int localport,
131
+ int ipv6, unsigned char ttl,
132
+ int * error);
133
+
134
+ /*!
135
+ * \brief Discover one type of UPnP devices
136
+ *
137
+ * \param[in] device device type to search
138
+ * \param[in] delay (in millisecond) maximum time for waiting any device
139
+ * response
140
+ * \param[in] multicastif If not NULL, used instead of the default
141
+ * multicast interface for sending SSDP discover packets
142
+ * \param[in] minissdpdsock Path to minissdpd socket, default is used if
143
+ * NULL
144
+ * \param[in] localport Source port to send SSDP packets.
145
+ * #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
146
+ * #UPNP_LOCAL_PORT_ANY to let system assign a source port
147
+ * \param[in] ipv6 0 for IPv4, 1 of IPv6
148
+ * \param[in] ttl should default to 2 as advised by UDA 1.1
149
+ * \param[out] error error code when NULL is returned
150
+ * \return NULL or a linked list
151
+ */
152
+ MINIUPNP_LIBSPEC struct UPNPDev *
153
+ upnpDiscoverDevice(const char * device, int delay, const char * multicastif,
154
+ const char * minissdpdsock, int localport,
155
+ int ipv6, unsigned char ttl,
156
+ int * error);
157
+
158
+ /*!
159
+ * \brief Discover one or several type of UPnP devices
160
+ *
161
+ * \param[in] deviceTypes array of device types to search (ending with NULL)
162
+ * \param[in] delay (in millisecond) maximum time for waiting any device
163
+ * response
164
+ * \param[in] multicastif If not NULL, used instead of the default
165
+ * multicast interface for sending SSDP discover packets
166
+ * \param[in] minissdpdsock Path to minissdpd socket, default is used if
167
+ * NULL
168
+ * \param[in] localport Source port to send SSDP packets.
169
+ * #UPNP_LOCAL_PORT_SAME for 1900 (same as destination port)
170
+ * #UPNP_LOCAL_PORT_ANY to let system assign a source port
171
+ * \param[in] ipv6 0 for IPv4, 1 of IPv6
172
+ * \param[in] ttl should default to 2 as advised by UDA 1.1
173
+ * \param[out] error error code when NULL is returned
174
+ * \param[in] searchalltypes 0 to stop with the first type returning results
175
+ * \return NULL or a linked list
176
+ */
177
+ MINIUPNP_LIBSPEC struct UPNPDev *
178
+ upnpDiscoverDevices(const char * const deviceTypes[],
179
+ int delay, const char * multicastif,
180
+ const char * minissdpdsock, int localport,
181
+ int ipv6, unsigned char ttl,
182
+ int * error,
183
+ int searchalltypes);
184
+
185
+ /*!
186
+ * \brief parse root XML description of a UPnP device
187
+ *
188
+ * fill the IGDdatas structure.
189
+ * \param[in] buffer character buffer containing the XML description
190
+ * \param[in] bufsize size in bytes of the buffer
191
+ * \param[out] data IGDdatas structure to fill
192
+ */
193
+ MINIUPNP_LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data);
194
+
195
+ /*!
196
+ * \brief structure used to get fast access to urls
197
+ */
198
+ struct UPNPUrls {
199
+ /*! \brief controlURL of the WANIPConnection */
200
+ char * controlURL;
201
+ /*! \brief url of the description of the WANIPConnection */
202
+ char * ipcondescURL;
203
+ /*! \brief controlURL of the WANCommonInterfaceConfig */
204
+ char * controlURL_CIF;
205
+ /*! \brief controlURL of the WANIPv6FirewallControl */
206
+ char * controlURL_6FC;
207
+ /*! \brief url of the root description */
208
+ char * rootdescURL;
209
+ };
210
+
211
+ /*! \brief NO IGD found */
212
+ #define UPNP_NO_IGD (0)
213
+ /*! \brief valid and connected IGD */
214
+ #define UPNP_CONNECTED_IGD (1)
215
+ /*! \brief valid and connected IGD but with a reserved address
216
+ * (non routable) */
217
+ #define UPNP_PRIVATEIP_IGD (2)
218
+ /*! \brief valid but not connected IGD */
219
+ #define UPNP_DISCONNECTED_IGD (3)
220
+ /*! \brief UPnP device not recognized as an IGD */
221
+ #define UPNP_UNKNOWN_DEVICE (4)
222
+
223
+ /*!
224
+ * \brief look for a valid and possibly connected IGD in the list
225
+ *
226
+ * In any non zero return case, the urls and data structures
227
+ * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
228
+ * free allocated memory.
229
+ * \param[in] devlist A device list obtained with upnpDiscover() /
230
+ * upnpDiscoverAll() / upnpDiscoverDevice() / upnpDiscoverDevices()
231
+ * \param[out] urls Urls for the IGD found
232
+ * \param[out] data datas for the IGD found
233
+ * \param[out] lanaddr buffer to copy the local address of the host to reach the IGD
234
+ * \param[in] lanaddrlen size of the lanaddr buffer
235
+ * \param[out] wanaddr buffer to copy the public address of the IGD
236
+ * \param[in] wanaddrlen size of the wanaddr buffer
237
+ * \return #UPNP_NO_IGD / #UPNP_CONNECTED_IGD / #UPNP_PRIVATEIP_IGD /
238
+ * #UPNP_DISCONNECTED_IGD / #UPNP_UNKNOWN_DEVICE
239
+ */
240
+ MINIUPNP_LIBSPEC int
241
+ UPNP_GetValidIGD(struct UPNPDev * devlist,
242
+ struct UPNPUrls * urls,
243
+ struct IGDdatas * data,
244
+ char * lanaddr, int lanaddrlen,
245
+ char * wanaddr, int wanaddrlen);
246
+
247
+ /*!
248
+ * \brief Get IGD URLs and data for URL
249
+ *
250
+ * Used when skipping the discovery process.
251
+ * \param[in] rootdescurl Root description URL of the device
252
+ * \param[out] urls Urls for the IGD found
253
+ * \param[out] data datas for the IGD found
254
+ * \param[out] lanaddr buffer to copy the local address of the host to reach the IGD
255
+ * \param[in] lanaddrlen size of the lanaddr buffer
256
+ * \return 0 Not ok / 1 OK
257
+ */
258
+ MINIUPNP_LIBSPEC int
259
+ UPNP_GetIGDFromUrl(const char * rootdescurl,
260
+ struct UPNPUrls * urls,
261
+ struct IGDdatas * data,
262
+ char * lanaddr, int lanaddrlen);
263
+
264
+ /*!
265
+ * \brief Prepare the URLs for usage
266
+ *
267
+ * build absolute URLs from the root description
268
+ * \param[out] urls URL structure to initialize
269
+ * \param[in] data datas for the IGD
270
+ * \param[in] descURL root description URL for the IGD
271
+ * \param[in] scope_id if not 0, add the scope to the linklocal IPv6
272
+ * addresses in URLs
273
+ */
274
+ MINIUPNP_LIBSPEC void
275
+ GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
276
+ const char * descURL, unsigned int scope_id);
277
+
278
+ /*!
279
+ * \brief free the members of a UPNPUrls struct
280
+ *
281
+ * All URLs buffers are freed and zeroed
282
+ * \param[out] urls
283
+ */
284
+ MINIUPNP_LIBSPEC void
285
+ FreeUPNPUrls(struct UPNPUrls * urls);
286
+
287
+ /*!
288
+ * \brief check the current connection status of an IGD
289
+ *
290
+ * it uses UPNP_GetStatusInfo()
291
+ * \param[in] urls IGD URLs
292
+ * \param[in] data IGD data
293
+ * \return 1 Connected / 0 Disconnected
294
+ */
295
+ MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data);
296
+
297
+
298
+ #ifdef __cplusplus
299
+ }
300
+ #endif
301
+
302
+ #endif
303
+
@@ -1,6 +1,8 @@
1
1
  #ifndef MINIUPNPC_DECLSPEC_H_INCLUDED
2
2
  #define MINIUPNPC_DECLSPEC_H_INCLUDED
3
3
 
4
+ /*! \file miniupnpc_declspec.h
5
+ * \brief define #MINIUPNP_LIBSPEC for dll exports and imports */
4
6
  #if defined(_WIN32) && !defined(MINIUPNP_STATICLIB)
5
7
  /* for windows dll */
6
8
  #ifdef MINIUPNP_EXPORTS
@@ -18,4 +20,3 @@
18
20
  #endif
19
21
 
20
22
  #endif /* MINIUPNPC_DECLSPEC_H_INCLUDED */
21
-
@@ -0,0 +1,27 @@
1
+ /* $Id: miniupnpctypes.h,v 1.4 2025/02/08 23:15:16 nanard Exp $ */
2
+ /* Project: miniupnp
3
+ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org
4
+ * Author: Thomas Bernard
5
+ * Copyright (c) 2021-2025 Thomas Bernard
6
+ * This software is subject to the conditions detailed in the
7
+ * LICENCE file provided within this distribution */
8
+ #ifndef MINIUPNPCTYPES_H_INCLUDED
9
+ #define MINIUPNPCTYPES_H_INCLUDED
10
+
11
+ /*! \file miniupnpctypes.h
12
+ * \brief type definitions
13
+ *
14
+ * Use unsigned long long when available :
15
+ * strtoull is C99
16
+ *
17
+ * \def UNSIGNED_INTEGER
18
+ * \brief `unsigned long long` or `unsigned int`
19
+ * \todo int can be 16 bits, so it should be `unsigned long`
20
+ */
21
+ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
22
+ #define UNSIGNED_INTEGER unsigned long long
23
+ #else
24
+ #define UNSIGNED_INTEGER unsigned int
25
+ #endif
26
+
27
+ #endif
@@ -0,0 +1,54 @@
1
+ /* $Id: miniwget.h,v 1.14 2025/02/08 23:15:17 nanard Exp $ */
2
+ /* Project : miniupnp
3
+ * Author : Thomas Bernard
4
+ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
5
+ * Copyright (c) 2005-2025 Thomas Bernard
6
+ * This software is subject to the conditions detailed in the
7
+ * LICENCE file provided in this distribution.
8
+ * */
9
+ #ifndef MINIWGET_H_INCLUDED
10
+ #define MINIWGET_H_INCLUDED
11
+
12
+ /*! \file miniwget.h
13
+ * \brief Lightweight HTTP client API
14
+ */
15
+ #include "miniupnpc_declspec.h"
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /*! \brief perform HTTP GET on an URL
22
+ *
23
+ * \param[in] url HTTP URL to GET
24
+ * \param[out] size length of the returned buffer. -1 in case of memory
25
+ * allocation error
26
+ * \param[in] scope_id interface id for IPv6 to use if not specified in the URL
27
+ * \param[out] status_code HTTP response status code (200, 404, etc.)
28
+ * \return the body of the HTTP response
29
+ */
30
+ MINIUPNP_LIBSPEC void * miniwget(const char * url, int * size,
31
+ unsigned int scope_id, int * status_code);
32
+
33
+ /*! \brief perform HTTP GET on an URL
34
+ *
35
+ * Also get the local address used to reach the HTTP server
36
+ *
37
+ * \param[in] url HTTP URL to GET
38
+ * \param[out] size length of the returned buffer. -1 in case of memory
39
+ * allocation error
40
+ * \param[out] addr local address used to connect to the server
41
+ * \param[in] addrlen size of the addr buffer
42
+ * \param[in] scope_id interface id for IPv6 to use if not specified in the URL
43
+ * \param[out] status_code HTTP response status code (200, 404, etc.)
44
+ * \return the body of the HTTP response
45
+ */
46
+ MINIUPNP_LIBSPEC void * miniwget_getaddr(const char * url, int * size,
47
+ char * addr, int addrlen,
48
+ unsigned int scope_id, int * status_code);
49
+
50
+ #ifdef __cplusplus
51
+ }
52
+ #endif
53
+
54
+ #endif
@@ -0,0 +1,91 @@
1
+ /* $Id: portlistingparse.h,v 1.12 2025/02/08 23:15:17 nanard Exp $ */
2
+ /* MiniUPnP project
3
+ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4
+ * (c) 2011-2025 Thomas Bernard
5
+ * This software is subject to the conditions detailed
6
+ * in the LICENCE file provided within the distribution */
7
+ #ifndef PORTLISTINGPARSE_H_INCLUDED
8
+ #define PORTLISTINGPARSE_H_INCLUDED
9
+
10
+ /*! \file portlistingparse.h
11
+ * \brief Parsing of the list of port mappings
12
+ *
13
+ * As returned by GetListOfPortMappings.
14
+ * Sample of PortMappingEntry :
15
+ *
16
+ * <p:PortMappingEntry>
17
+ * <p:NewRemoteHost>202.233.2.1</p:NewRemoteHost>
18
+ * <p:NewExternalPort>2345</p:NewExternalPort>
19
+ * <p:NewProtocol>TCP</p:NewProtocol>
20
+ * <p:NewInternalPort>2345</p:NewInternalPort>
21
+ * <p:NewInternalClient>192.168.1.137</p:NewInternalClient>
22
+ * <p:NewEnabled>1</p:NewEnabled>
23
+ * <p:NewDescription>dooom</p:NewDescription>
24
+ * <p:NewLeaseTime>345</p:NewLeaseTime>
25
+ * </p:PortMappingEntry>
26
+ */
27
+ #include "miniupnpc_declspec.h"
28
+ /* for the definition of UNSIGNED_INTEGER */
29
+ #include "miniupnpctypes.h"
30
+
31
+ #ifdef __cplusplus
32
+ extern "C" {
33
+ #endif
34
+
35
+ /*!
36
+ * \brief enum of all XML elements
37
+ */
38
+ typedef enum { PortMappingEltNone,
39
+ PortMappingEntry, NewRemoteHost,
40
+ NewExternalPort, NewProtocol,
41
+ NewInternalPort, NewInternalClient,
42
+ NewEnabled, NewDescription,
43
+ NewLeaseTime } portMappingElt;
44
+
45
+ /*!
46
+ * \brief linked list of port mappings
47
+ */
48
+ struct PortMapping {
49
+ struct PortMapping * l_next; /*!< \brief next list element */
50
+ UNSIGNED_INTEGER leaseTime; /*!< \brief in seconds */
51
+ unsigned short externalPort; /*!< \brief external port */
52
+ unsigned short internalPort; /*!< \brief internal port */
53
+ char remoteHost[64]; /*!< \brief empty for wildcard */
54
+ char internalClient[64]; /*!< \brief internal IP address */
55
+ char description[64]; /*!< \brief description */
56
+ char protocol[4]; /*!< \brief `TCP` or `UDP` */
57
+ unsigned char enabled; /*!< \brief 0 (false) or 1 (true) */
58
+ };
59
+
60
+ /*!
61
+ * \brief structure for ParsePortListing()
62
+ */
63
+ struct PortMappingParserData {
64
+ struct PortMapping * l_head; /*!< \brief list head */
65
+ portMappingElt curelt; /*!< \brief currently parsed element */
66
+ };
67
+
68
+ /*!
69
+ * \brief parse the NewPortListing part of GetListOfPortMappings response
70
+ *
71
+ * \param[in] buffer XML data
72
+ * \param[in] bufsize length of XML data
73
+ * \param[out] pdata Parsed data
74
+ */
75
+ MINIUPNP_LIBSPEC void
76
+ ParsePortListing(const char * buffer, int bufsize,
77
+ struct PortMappingParserData * pdata);
78
+
79
+ /*!
80
+ * \brief free parsed data structure
81
+ *
82
+ * \param[in] pdata Parsed data to free
83
+ */
84
+ MINIUPNP_LIBSPEC void
85
+ FreePortListing(struct PortMappingParserData * pdata);
86
+
87
+ #ifdef __cplusplus
88
+ }
89
+ #endif
90
+
91
+ #endif