Lines 42-48
Link Here
|
42 |
*/ |
42 |
*/ |
43 |
|
43 |
|
44 |
static const char rcsid[] = |
44 |
static const char rcsid[] = |
45 |
"$Id: upnp.c,v 1.153.4.4.2.2.4.2 2020/11/11 16:11:55 karls Exp $"; |
45 |
"$Id: upnp.c,v 1.153.4.4.2.2.4.2.4.1 2024/11/21 16:02:49 karls Exp $"; |
46 |
|
46 |
|
47 |
#include "common.h" |
47 |
#include "common.h" |
48 |
|
48 |
|
Lines 154-160
Link Here
|
154 |
addrstring, |
154 |
addrstring, |
155 |
NULL, |
155 |
NULL, |
156 |
0 |
156 |
0 |
157 |
#if HAVE_LIBMINIUPNP17 |
157 |
#if HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 |
158 |
,0, |
158 |
,0, |
159 |
|
159 |
|
160 |
#if MINIUPNPC_API_VERSION >= 14 |
160 |
#if MINIUPNPC_API_VERSION >= 14 |
Lines 162-168
Link Here
|
162 |
#endif /* MINIUPNPC_API_VERSION >= 14 */ |
162 |
#endif /* MINIUPNPC_API_VERSION >= 14 */ |
163 |
|
163 |
|
164 |
&rc |
164 |
&rc |
165 |
#endif /* HAVE_LIBMINIUPNP17 */ |
165 |
#endif /* HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */ |
166 |
); |
166 |
); |
167 |
|
167 |
|
168 |
#if SOCKS_CLIENT && SOCKSLIBRARY_DYNAMIC |
168 |
#if SOCKS_CLIENT && SOCKSLIBRARY_DYNAMIC |
Lines 208-214
Link Here
|
208 |
socks_autoadd_directroute(&commands, &protocols, &saddr, &smask); |
208 |
socks_autoadd_directroute(&commands, &protocols, &saddr, &smask); |
209 |
} |
209 |
} |
210 |
|
210 |
|
|
|
211 |
#if HAVE_LIBMINIUPNP228 |
212 |
devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr), |
213 |
NULL, 0); |
214 |
#else /* !HAVE_LIBMINIUPNP228 */ |
211 |
devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr)); |
215 |
devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr)); |
|
|
216 |
#endif /* !HAVE_LIBMINIUPNP228 */ |
212 |
switch (devtype) { |
217 |
switch (devtype) { |
213 |
case UPNP_NO_IGD: |
218 |
case UPNP_NO_IGD: |
214 |
snprintf(emsg, emsglen, "no UPNP IGD discovered on local network"); |
219 |
snprintf(emsg, emsglen, "no UPNP IGD discovered on local network"); |
Lines 226-231
Link Here
|
226 |
rc = 0; |
231 |
rc = 0; |
227 |
break; |
232 |
break; |
228 |
|
233 |
|
|
|
234 |
#if HAVE_LIBMINIUPNP228 |
235 |
case UPNP_RESERVED_IGD: |
236 |
snprintf(emsg, emsglen, |
237 |
"UPNP IGD discovered at url %s, but its IP is reserved", |
238 |
str2vis(url.controlURL, |
239 |
strlen(url.controlURL), |
240 |
vbuf, |
241 |
sizeof(vbuf))); |
242 |
|
243 |
swarnx("%s: %s", function, emsg); |
244 |
rc = -1; |
245 |
break; |
246 |
#endif /* HAVE_LIBMINIUPNP228 */ |
247 |
|
229 |
case UPNP_DISCONNECTED_IGD: |
248 |
case UPNP_DISCONNECTED_IGD: |
230 |
snprintf(emsg, emsglen, |
249 |
snprintf(emsg, emsglen, |
231 |
"UPNP IGD discovered at url %s, but it is not connected", |
250 |
"UPNP IGD discovered at url %s, but it is not connected", |
Lines 273-284
Link Here
|
273 |
#if HAVE_LIBMINIUPNP13 |
292 |
#if HAVE_LIBMINIUPNP13 |
274 |
STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.servicetype); |
293 |
STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.servicetype); |
275 |
|
294 |
|
276 |
#elif HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 |
295 |
#elif HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 |
277 |
STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.CIF.servicetype); |
296 |
STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.CIF.servicetype); |
278 |
|
297 |
|
279 |
#else |
298 |
#else |
280 |
# error "unexpected miniupnp version" |
299 |
# error "unexpected miniupnp version" |
281 |
#endif /* HAVE_LIBMINIUPNP17 */ |
300 |
#endif /* HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */ |
282 |
|
301 |
|
283 |
slog(LOG_NEGOTIATE, "%s: inited ok. controlurl: %s, servicetype: %s", |
302 |
slog(LOG_NEGOTIATE, "%s: inited ok. controlurl: %s, servicetype: %s", |
284 |
function, |
303 |
function, |
Lines 756-764
Link Here
|
756 |
buf, |
775 |
buf, |
757 |
protocol, |
776 |
protocol, |
758 |
NULL |
777 |
NULL |
759 |
#if HAVE_LIBMINIUPNP17 |
778 |
#if HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 |
760 |
,0 |
779 |
,0 |
761 |
#endif /* HAVE_LIBMINIUPNP17 */ |
780 |
#endif /* HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */ |
762 |
)) != UPNPCOMMAND_SUCCESS) { |
781 |
)) != UPNPCOMMAND_SUCCESS) { |
763 |
snprintf(emsg, emsglen, |
782 |
snprintf(emsg, emsglen, |
764 |
"UPNP_AddPortMapping() failed: %s", strupnperror(rc)); |
783 |
"UPNP_AddPortMapping() failed: %s", strupnperror(rc)); |