about summary refs log tree commit diff
path: root/pkgs/servers/dante/dante-1.4.3-miniupnpc-2.2.8.patch
blob: 6f55c141acd5544f9105a2471acdcc0745c86ea7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
diff --git a/include/autoconf.h.in b/include/autoconf.h.in
index bab2fcfa6c...22bc9202ca 100644
--- a/include/autoconf.h.in
+++ b/include/autoconf.h.in
@@ -797,6 +797,9 @@
 /* UPNP support library 1.7 */
 #undef HAVE_LIBMINIUPNP17
 
+/* UPNP support library 2.2.8 */
+#undef HAVE_LIBMINIUPNP228
+
 /* Define to 1 if you have the `prldap60' library (-lprldap60). */
 #undef HAVE_LIBPRLDAP60
 
diff --git a/include/common.h b/include/common.h
index 137f5ec51f...2c24759b52 100755
--- a/include/common.h
+++ b/include/common.h
@@ -1404,8 +1404,14 @@
 /* return codes from UPNP_GetValidIGD(). */
 #define UPNP_NO_IGD           (0)
 #define UPNP_CONNECTED_IGD    (1)
+#if HAVE_LIBMINIUPNP228
+#define UPNP_RESERVED_IGD     (2)
+#define UPNP_DISCONNECTED_IGD (3)
+#define UPNP_UNKNOWN_DEVICE   (4)
+#else /* !HAVE_LIBMINIUPNP_228 */
 #define UPNP_DISCONNECTED_IGD (2)
 #define UPNP_UNKNOWN_DEVICE   (3)
+#endif /* !HAVE_LIBMINIUPNP_228 */
 
 #define UPNP_SUCCESS          (1)
 #define UPNP_FAILURE          (2)
diff --git a/lib/upnp.c b/lib/upnp.c
index d9535ca03c...dc99d53c06 100644
--- a/lib/upnp.c
+++ b/lib/upnp.c
@@ -154,7 +154,7 @@
                            addrstring,
                            NULL,
                            0
-#if HAVE_LIBMINIUPNP17
+#if HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228
                           ,0,
 
 #if MINIUPNPC_API_VERSION >= 14
@@ -162,7 +162,7 @@
 #endif /* MINIUPNPC_API_VERSION >= 14 */
 
                           &rc
-#endif /* HAVE_LIBMINIUPNP17 */
+#endif /* HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */
                          );
 
 #if SOCKS_CLIENT && SOCKSLIBRARY_DYNAMIC
@@ -208,7 +208,12 @@
          socks_autoadd_directroute(&commands, &protocols, &saddr, &smask);
       }
 
+#if HAVE_LIBMINIUPNP228
+      devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr),
+                                 NULL, 0);
+#else /* !HAVE_LIBMINIUPNP228 */
       devtype = UPNP_GetValidIGD(dev, &url, &data, myaddr, sizeof(myaddr));
+#endif /* !HAVE_LIBMINIUPNP228 */
       switch (devtype) {
          case UPNP_NO_IGD:
             snprintf(emsg, emsglen, "no UPNP IGD discovered on local network");
@@ -226,9 +231,10 @@
             rc = 0;
             break;
 
-         case UPNP_DISCONNECTED_IGD:
+#if HAVE_LIBMINIUPNP228
+         case UPNP_RESERVED_IGD:
             snprintf(emsg, emsglen,
-                    "UPNP IGD discovered at url %s, but it is not connected",
+                    "UPNP IGD discovered at url %s, but its IP is reserved",
                     str2vis(url.controlURL,
                            strlen(url.controlURL),
                             vbuf,
@@ -236,6 +242,18 @@
 
             swarnx("%s: %s", function, emsg);
             rc = -1;
+#endif /* HAVE_LIBMINIUPNP228 */
+
+         case UPNP_DISCONNECTED_IGD:
+            snprintf(emsg, emsglen,
+                    "UPNP IGD discovered at url %s, but it is not connected",
+                    str2vis(url.controlURL,
+                           strlen(url.controlURL),
+                            vbuf,
+                            sizeof(vbuf)));
+
+            swarnx("%s: %s", function, emsg);
+            rc = -1;
             break;
 
          case UPNP_UNKNOWN_DEVICE:
@@ -273,12 +291,12 @@
 #if HAVE_LIBMINIUPNP13
       STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.servicetype);
 
-#elif HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17
+#elif HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228
       STRCPY_ASSERTLEN(gw->state.data.upnp.servicetype, data.CIF.servicetype);
 
 #else
 #  error "unexpected miniupnp version"
-#endif /* HAVE_LIBMINIUPNP17 */
+#endif /* HAVE_LIBMINIUPNP14 || HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */
 
       slog(LOG_NEGOTIATE, "%s: inited ok.  controlurl: %s, servicetype: %s",
            function,
@@ -756,9 +774,9 @@
                                        buf,
                                        protocol,
                                        NULL
-#if HAVE_LIBMINIUPNP17
+#if HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228
                                        ,0
-#endif /* HAVE_LIBMINIUPNP17 */
+#endif /* HAVE_LIBMINIUPNP17 || HAVE_LIBMINIUPNP228 */
                                        )) != UPNPCOMMAND_SUCCESS) {
                snprintf(emsg, emsglen,
                        "UPNP_AddPortMapping() failed: %s", strupnperror(rc));
diff --git a/miniupnpc.m4 b/miniupnpc.m4
index 85086d4917...ebb8875763 100644
--- a/miniupnpc.m4
+++ b/miniupnpc.m4
@@ -20,7 +20,7 @@
 	LIBS=$oLIBS
     fi
     if test x"${have_libminiupnp}" = xt; then
-        AC_MSG_CHECKING([for miniupnpc version >= 1.7])
+        AC_MSG_CHECKING([for miniupnpc version >= 2.2.8])
 	AC_TRY_COMPILE([
             #include <stdio.h>
             #include <miniupnpc/miniupnpc.h>
@@ -30,12 +30,34 @@
             #ifndef MINIUPNPC_API_VERSION
 	    #error "no api version define"
             #else
-            # if MINIUPNPC_API_VERSION < 8
+            # if MINIUPNPC_API_VERSION < 18
             #error "api version too low"
             # endif
             #endif],
          [AC_MSG_RESULT(yes)
           AC_DEFINE(HAVE_LIBMINIUPNP, 1, [UPNP support library])
+          AC_DEFINE(HAVE_LIBMINIUPNP228, 1, [UPNP support library 2.2.8])
+          unset no_upnp
+	  SOCKDDEPS="${SOCKDDEPS}${SOCKDDEPS:+ }$UPNPLIB"
+	  DLIBDEPS="${DLIBDEPS}${DLIBDEPS:+ }$UPNPLIB"],
+         [AC_MSG_RESULT(no)])
+
+        AC_MSG_CHECKING([for miniupnpc version >= 1.7])
+	AC_TRY_COMPILE([
+            #include <stdio.h>
+            #include <miniupnpc/miniupnpc.h>
+            #include <miniupnpc/upnpcommands.h>
+            #include <miniupnpc/upnperrors.h>], [
+
+            #ifndef MINIUPNPC_API_VERSION
+	    #error "no api version define"
+            #else
+            # if MINIUPNPC_API_VERSION < 8 || MINIUPNPC_API_VERSION > 17
+            #error "api version too low or high"
+            # endif
+            #endif],
+         [AC_MSG_RESULT(yes)
+          AC_DEFINE(HAVE_LIBMINIUPNP, 1, [UPNP support library])
           AC_DEFINE(HAVE_LIBMINIUPNP17, 1, [UPNP support library 1.7])
           unset no_upnp
 	  SOCKDDEPS="${SOCKDDEPS}${SOCKDDEPS:+ }$UPNPLIB"