1 diff --git a/include/autoconf.h.in b/include/autoconf.h.in
2 index bab2fcfa6c...22bc9202ca 100644
3 --- a/include/autoconf.h.in
4 +++ b/include/autoconf.h.in
6 /* UPNP support library 1.7 */
7 #undef HAVE_LIBMINIUPNP17
9 +/* UPNP support library 2.2.8 */
10 +#undef HAVE_LIBMINIUPNP228
12 /* Define to 1 if you have the `prldap60' library (-lprldap60). */
13 #undef HAVE_LIBPRLDAP60
15 diff --git a/include/common.h b/include/common.h
16 index 137f5ec51f...2c24759b52 100755
17 --- a/include/common.h
18 +++ b/include/common.h
19 @@ -1404,8 +1404,14 @@
20 /* return codes from UPNP_GetValidIGD(). */
21 #define UPNP_NO_IGD (0)
22 #define UPNP_CONNECTED_IGD (1)
23 +#if HAVE_LIBMINIUPNP228
24 +#define UPNP_RESERVED_IGD (2)
25 +#define UPNP_DISCONNECTED_IGD (3)
26 +#define UPNP_UNKNOWN_DEVICE (4)
27 +#else /* !HAVE_LIBMINIUPNP_228 */
28 #define UPNP_DISCONNECTED_IGD (2)
29 #define UPNP_UNKNOWN_DEVICE (3)
30 +#endif /* !HAVE_LIBMINIUPNP_228 */
32 #define UPNP_SUCCESS (1)
33 #define UPNP_FAILURE (2)
34 diff --git a/lib/upnp.c b/lib/upnp.c
35 index d9535ca03c...dc99d53c06 100644
42 -#if HAVE_LIBMINIUPNP17
43 +#if HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228
46 #if MINIUPNPC_API_VERSION >= 14
48 #endif /* MINIUPNPC_API_VERSION >= 14 */
51 -#endif /* HAVE_LIBMINIUPNP17 */
52 +#endif /* HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */
55 #if SOCKS_CLIENT && SOCKSLIBRARY_DYNAMIC
57 socks_autoadd_directroute(&commands, &protocols, &saddr, &smask);
60 +#if HAVE_LIBMINIUPNP228
61 + devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr),
63 +#else /* !HAVE_LIBMINIUPNP228 */
64 devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr));
65 +#endif /* !HAVE_LIBMINIUPNP228 */
68 snprintf(emsg, emsglen, "no UPNP IGD discovered on local network");
73 - case UPNP_DISCONNECTED_IGD:
74 +#if HAVE_LIBMINIUPNP228
75 + case UPNP_RESERVED_IGD:
76 snprintf(emsg, emsglen,
77 - "UPNP IGD discovered at url %s, but it is not connected",
78 + "UPNP IGD discovered at url %s, but its IP is reserved",
79 str2vis(url.controlURL,
80 strlen(url.controlURL),
84 swarnx("%s: %s", function, emsg);
86 +#endif /* HAVE_LIBMINIUPNP228 */
88 + case UPNP_DISCONNECTED_IGD:
89 + snprintf(emsg, emsglen,
90 + "UPNP IGD discovered at url %s, but it is not connected",
91 + str2vis(url.controlURL,
92 + strlen(url.controlURL),
96 + swarnx("%s: %s", function, emsg);
100 case UPNP_UNKNOWN_DEVICE:
101 @@ -273,12 +291,12 @@
102 #if HAVE_LIBMINIUPNP13
103 STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.servicetype);
105 -#elif HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17
106 +#elif HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228
107 STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.CIF.servicetype);
110 # error "unexpected miniupnp version"
111 -#endif /* HAVE_LIBMINIUPNP17 */
112 +#endif /* HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */
114 slog(LOG_NEGOTIATE, "%s: inited ok. controlurl: %s, servicetype: %s",
120 -#if HAVE_LIBMINIUPNP17
121 +#if HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228
123 -#endif /* HAVE_LIBMINIUPNP17 */
124 +#endif /* HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */
125 )) != UPNPCOMMAND_SUCCESS) {
126 snprintf(emsg, emsglen,
127 "UPNP_AddPortMapping() failed: %s", strupnperror(rc));
128 diff --git a/miniupnpc.m4 b/miniupnpc.m4
129 index 85086d4917...ebb8875763 100644
135 if test x"${have_libminiupnp}" = xt; then
136 - AC_MSG_CHECKING([for miniupnpc version >= 1.7])
137 + AC_MSG_CHECKING([for miniupnpc version >= 2.2.8])
140 #include <miniupnpc/miniupnpc.h>
142 #ifndef MINIUPNPC_API_VERSION
143 #error "no api version define"
145 - # if MINIUPNPC_API_VERSION < 8
146 + # if MINIUPNPC_API_VERSION < 18
147 #error "api version too low"
151 AC_DEFINE(HAVE_LIBMINIUPNP, 1, [UPNP support library])
152 + AC_DEFINE(HAVE_LIBMINIUPNP228, 1, [UPNP support library 2.2.8])
154 + SOCKDDEPS="${SOCKDDEPS}${SOCKDDEPS:+ }$UPNPLIB"
155 + DLIBDEPS="${DLIBDEPS}${DLIBDEPS:+ }$UPNPLIB"],
156 + [AC_MSG_RESULT(no)])
158 + AC_MSG_CHECKING([for miniupnpc version >= 1.7])
161 + #include <miniupnpc/miniupnpc.h>
162 + #include <miniupnpc/upnpcommands.h>
163 + #include <miniupnpc/upnperrors.h>], [
165 + #ifndef MINIUPNPC_API_VERSION
166 + #error "no api version define"
168 + # if MINIUPNPC_API_VERSION < 8 || MINIUPNPC_API_VERSION > 17
169 + #error "api version too low or high"
172 + [AC_MSG_RESULT(yes)
173 + AC_DEFINE(HAVE_LIBMINIUPNP, 1, [UPNP support library])
174 AC_DEFINE(HAVE_LIBMINIUPNP17, 1, [UPNP support library 1.7])
176 SOCKDDEPS="${SOCKDDEPS}${SOCKDDEPS:+ }$UPNPLIB"