PageRenderTime 2915ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/user/miniupnpd/999-n56u.patch

https://bitbucket.org/altlc/wive-rtnl-ralink-rt305x-routers-firmware-amod
Patch | 671 lines | 632 code | 39 blank | 0 comment | 0 complexity | 508a02c42ee9172acf0097cf7df84f04 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, 0BSD, AGPL-1.0, LGPL-2.1, LGPL-2.0
  1. diff -ur miniupnpd-1.7.20120824/genconfig.sh miniupnpd-1.7.20120824.b/genconfig.sh
  2. --- miniupnpd-1.7.20120824/genconfig.sh 2012-07-11 06:24:52.000000000 +0800
  3. +++ miniupnpd-1.7.20120824.b/genconfig.sh 2012-09-04 18:46:50.417238227 +0800
  4. @@ -68,12 +68,15 @@
  5. OS_VERSION="Tomato $(cat ../shared/tomato_version)"
  6. fi
  7. +OS_NAME=Wive-NG-RTNL
  8. +
  9. ${RM} ${CONFIGFILE}
  10. echo "/* MiniUPnP Project" >> ${CONFIGFILE}
  11. echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
  12. echo " * (c) 2006-2012 Thomas Bernard" >> ${CONFIGFILE}
  13. -echo " * generated by $0 on `date`" >> ${CONFIGFILE}
  14. +echo " * generated by $0 on `LC_ALL=C date -u`" >> ${CONFIGFILE}
  15. echo " * using command line options $* */" >> ${CONFIGFILE}
  16. echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
  17. echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
  18. @@ -259,6 +262,13 @@
  19. echo "#endif" >> ${CONFIGFILE}
  20. FW=netfilter
  21. ;;
  22. + RT-N56U)
  23. + OS_VERSION=1.1.2.3
  24. + OS_URL=http://code.google.com/p/rt-n56u/
  25. + echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
  26. + FW=netfilter
  27. + LEASEFILE=1
  28. + ;;
  29. Darwin)
  30. echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  31. FW=ipfw
  32. @@ -326,9 +336,9 @@
  33. echo "/* Uncomment the following line to enable caching of results of" >> ${CONFIGFILE}
  34. echo " * the getifstats() function */" >> ${CONFIGFILE}
  35. -echo "/*#define ENABLE_GETIFSTATS_CACHING*/" >> ${CONFIGFILE}
  36. +echo "#define ENABLE_GETIFSTATS_CACHING" >> ${CONFIGFILE}
  37. echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE}
  38. -echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE}
  39. +echo "#define GETIFSTATS_CACHING_DURATION 3" >> ${CONFIGFILE}
  40. echo "" >> ${CONFIGFILE}
  41. echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE}
  42. @@ -394,7 +404,7 @@
  43. echo "" >> ${CONFIGFILE}
  44. echo "/* include interface name in pf and ipf rules */" >> ${CONFIGFILE}
  45. -echo "#define USE_IFNAME_IN_RULES" >> ${CONFIGFILE}
  46. +echo "/*#define USE_IFNAME_IN_RULES*/" >> ${CONFIGFILE}
  47. echo "" >> ${CONFIGFILE}
  48. echo "/* Experimental NFQUEUE support. */" >> ${CONFIGFILE}
  49. diff -ur miniupnpd-1.7.20120824/getifaddr.c miniupnpd-1.7.20120824.b/getifaddr.c
  50. --- miniupnpd-1.7.20120824/getifaddr.c 2012-03-06 04:37:13.000000000 +0800
  51. +++ miniupnpd-1.7.20120824.b/getifaddr.c 2012-09-04 19:51:03.410365520 +0800
  52. @@ -36,30 +36,39 @@
  53. int ifrlen;
  54. struct sockaddr_in * addr;
  55. ifrlen = sizeof(ifr);
  56. + int ret = -1;
  57. if(!ifname || ifname[0]=='\0')
  58. return -1;
  59. s = socket(PF_INET, SOCK_DGRAM, 0);
  60. if(s < 0)
  61. {
  62. - syslog(LOG_ERR, "socket(PF_INET, SOCK_DGRAM): %m");
  63. + syslog(LOG_DEBUG, "socket(PF_INET, SOCK_DGRAM): %m");
  64. return -1;
  65. }
  66. strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
  67. + if(ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
  68. + {
  69. + syslog(LOG_DEBUG, "ioctl(s, SIOCGIFFLAGS, ...): %m");
  70. + goto err;
  71. + } else
  72. + if ((ifr.ifr_flags & IFF_UP) == 0)
  73. + goto err;
  74. if(ioctl(s, SIOCGIFADDR, &ifr, &ifrlen) < 0)
  75. {
  76. - syslog(LOG_ERR, "ioctl(s, SIOCGIFADDR, ...): %m");
  77. - close(s);
  78. - return -1;
  79. + syslog(LOG_DEBUG, "ioctl(s, SIOCGIFADDR, ...): %m");
  80. + goto err;
  81. }
  82. addr = (struct sockaddr_in *)&ifr.ifr_addr;
  83. if(!inet_ntop(AF_INET, &addr->sin_addr, buf, len))
  84. {
  85. - syslog(LOG_ERR, "inet_ntop(): %m");
  86. - close(s);
  87. - return -1;
  88. + syslog(LOG_DEBUG, "inet_ntop(): %m");
  89. + goto err;
  90. }
  91. close(s);
  92. + ret = 0;
  93. + err:
  94. + return ret;
  95. #else /* ifndef USE_GETIFADDRS */
  96. /* Works for all address families (both ip v4 and ip v6) */
  97. struct ifaddrs * ifap;
  98. @@ -69,7 +78,7 @@
  99. return -1;
  100. if(getifaddrs(&ifap)<0)
  101. {
  102. - syslog(LOG_ERR, "getifaddrs: %m");
  103. + syslog(LOG_DEBUG, "getifaddrs: %m");
  104. return -1;
  105. }
  106. for(ife = ifap; ife; ife = ife->ifa_next)
  107. @@ -95,8 +104,9 @@
  108. }
  109. }
  110. freeifaddrs(ifap);
  111. -#endif
  112. +
  113. return 0;
  114. +#endif
  115. }
  116. #ifdef ENABLE_IPV6
  117. @@ -115,7 +125,7 @@
  118. if(getifaddrs(&ifap)<0)
  119. {
  120. - syslog(LOG_ERR, "getifaddrs: %m");
  121. + syslog(LOG_DEBUG, "getifaddrs: %m");
  122. return -1;
  123. }
  124. for(ife = ifap; ife; ife = ife->ifa_next)
  125. diff -ur miniupnpd-1.7.20120824/linux/getifstats.c miniupnpd-1.7.20120824.b/linux/getifstats.c
  126. --- miniupnpd-1.7.20120824/linux/getifstats.c 2012-04-07 01:47:58.000000000 +0800
  127. +++ miniupnpd-1.7.20120824.b/linux/getifstats.c 2012-09-07 04:14:11.335411659 +0800
  128. @@ -22,7 +22,9 @@
  129. char * p;
  130. int i;
  131. int r = -1;
  132. +#if 0
  133. char fname[64];
  134. +#endif
  135. #ifdef ENABLE_GETIFSTATS_CACHING
  136. static time_t cache_timestamp = 0;
  137. static struct ifdata cache_data;
  138. @@ -86,7 +88,9 @@
  139. break;
  140. }
  141. fclose(f);
  142. +#if 0 /* Disable get speed. In 2.6.21 kernel not supported this. */
  143. /* get interface speed */
  144. + /* NB! some interfaces, like ppp, don't support speed queries */
  145. snprintf(fname, sizeof(fname), "/sys/class/net/%s/speed", ifname);
  146. f = fopen(fname, "r");
  147. if(f) {
  148. @@ -96,9 +100,8 @@
  149. data->baudrate = 1000000*i;
  150. }
  151. fclose(f);
  152. - } else {
  153. - syslog(LOG_WARNING, "cannot read %s file : %m", fname);
  154. }
  155. +#endif
  156. #ifdef ENABLE_GETIFSTATS_CACHING
  157. if(r==0 && current_time!=((time_t)-1)) {
  158. /* cache the new data */
  159. diff -ur miniupnpd-1.7.20120824/Makefile.linux miniupnpd-1.7.20120824.b/Makefile.linux
  160. --- miniupnpd-1.7.20120824/Makefile.linux 2012-08-25 02:14:23.000000000 +0800
  161. +++ miniupnpd-1.7.20120824.b/Makefile.linux 2012-09-13 06:39:48.875968999 +0800
  162. @@ -23,7 +23,6 @@
  163. #CFLAGS = -O -g -DDEBUG
  164. CFLAGS ?= -Os
  165. CFLAGS += -fno-strict-aliasing
  166. -CFLAGS += -fno-common
  167. CFLAGS += -D_GNU_SOURCE
  168. CFLAGS += -Wall
  169. CFLAGS += -Wextra -Wstrict-prototypes -Wdeclaration-after-statement
  170. @@ -35,6 +34,22 @@
  171. STRIP ?= strip
  172. CP = cp
  173. +CFLAGS += -ffunction-sections -fdata-sections
  174. +LDFLAGS += -Wl,--gc-sections
  175. +
  176. +ifeq ($(KERNEL3X),y)
  177. +LIBS = -lip4tc
  178. +CFLAGS := $(CFLAGS) -DIPTABLES_143
  179. +LDFLAGS := $(LDFLAGS) -lip4tc
  180. +else
  181. +IPTABLESPATH=../../iptables-1.3.x
  182. +LIBS = $(IPTABLESPATH)/libiptc/libiptc.a
  183. +CFLAGS := $(CFLAGS) -I$(IPTABLESPATH)/include/
  184. +LDFLAGS := $(LDFLAGS) -L$(IPTABLESPATH)/libiptc/
  185. +endif
  186. INSTALLPREFIX ?= $(PREFIX)/usr
  187. SBININSTALLDIR = $(INSTALLPREFIX)/sbin
  188. @@ -48,80 +63,15 @@
  189. upnpevents.o upnputils.o getconnstatus.o \
  190. upnppinhole.o
  191. -LNXOBJS = linux/getifstats.o linux/ifacewatcher.o linux/getroute.o
  192. +LNXOBJS = linux/getifstats.o linux/ifacewatcher.o
  193. NETFILTEROBJS = netfilter/iptcrdr.o netfilter/iptpinhole.o
  194. ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
  195. -ifeq "$(wildcard /etc/gentoo-release )" ""
  196. -LIBS ?= -liptc
  197. -else # gentoo
  198. -# the following is better, at least on gentoo with iptables 1.4.6
  199. -# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1618
  200. -# and http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=2183
  201. -LIBS ?= -lip4tc
  202. -CFLAGS := -DIPTABLES_143 $(CFLAGS)
  203. -endif
  204. -
  205. -ARCH ?= $(shell uname -m | grep -q "x86_64" && echo 64)
  206. -ifdef IPTABLESPATH
  207. -CFLAGS := $(CFLAGS) -I$(IPTABLESPATH)/include/
  208. -LDFLAGS := $(LDFLAFGS) -L$(IPTABLESPATH)/libiptc/
  209. -# get iptables version and set IPTABLES_143 macro if needed
  210. -ifeq ($(TARGET_OPENWRT),)
  211. -IPTABLESVERSION := $(shell grep "\#define VERSION" $(IPTABLESPATH)/config.h | tr -d \" |cut -d" " -f3 )
  212. -IPTABLESVERSION1 := $(shell echo $(IPTABLESVERSION) | cut -d. -f1 )
  213. -IPTABLESVERSION2 := $(shell echo $(IPTABLESVERSION) | cut -d. -f2 )
  214. -IPTABLESVERSION3 := $(shell echo $(IPTABLESVERSION) | cut -d. -f3 )
  215. -# test if iptables version >= 1.4.3
  216. -TEST := $(shell [ \( \( $(IPTABLESVERSION1) -ge 1 \) -a \( $(IPTABLESVERSION2) -ge 4 \) \) -a \( $(IPTABLESVERSION3) -ge 3 \) ] && echo 1 )
  217. -ifeq ($(TEST), 1)
  218. -CFLAGS := $(CFLAGS) -DIPTABLES_143
  219. -# the following sucks, but works
  220. -LIBS = $(IPTABLESPATH)/libiptc/.libs/libip4tc.o
  221. -#LIBS = $(IPTABLESPATH)/libiptc/.libs/libiptc.a
  222. -else # ifeq ($(TEST), 1)
  223. -LIBS = $(IPTABLESPATH)/libiptc/libiptc.a
  224. -endif # ifeq ($(TEST), 1)
  225. -else # ($(TARGET_OPENWRT),)
  226. -# openWRT :
  227. -# check for system-wide iptables files. Test if iptables version >= 1.4.3
  228. -# the following test has to be verified :
  229. -TEST := $(shell test -f /usr/include/iptables/internal.h && grep -q "\#define IPTABLES_VERSION" /usr/include/iptables/internal.h && echo 1)
  230. -ifeq ($(TEST), 1)
  231. -CFLAGS := $(CFLAGS) -DIPTABLES_143
  232. -LIBS = -liptc
  233. -endif # ($(TEST), 1)
  234. -TEST_LIB := $(shell test -f /usr/lib$(ARCH)/libiptc.a && echo 1)
  235. -ifeq ($(TEST_LIB), 1)
  236. -LIBS = -liptc /usr/lib$(ARCH)/libiptc.a
  237. -endif # ($(TEST_LIB), 1)
  238. -endif # ($(TARGET_OPENWRT),)
  239. -else # ifdef IPTABLESPATH
  240. -# IPTABLESPATH not defined
  241. -# the following test has to be verified :
  242. -TEST := $(shell test -f /usr/include/xtables.h && grep -q "XTABLES_VERSION_CODE" /usr/include/xtables.h && echo 1)
  243. -ifeq ($(TEST), 1)
  244. -CFLAGS := $(CFLAGS) -DIPTABLES_143
  245. -LIBS = -liptc
  246. -TESTIP4TC := $(shell test -f /lib/libip4tc.so && echo 1)
  247. -ifeq ($(TESTIP4TC), 1)
  248. -LIBS := $(LIBS) -lip4tc
  249. -endif # ($(TESTIP4TC), 1)
  250. -TESTIP6TC := $(shell test -f /lib/libip6tc.so && echo 1)
  251. -ifeq ($(TESTIP6TC), 1)
  252. -LIBS := $(LIBS) -lip6tc
  253. -endif # ($(TESTIP6TC), 1)
  254. -endif # ($(TEST), 1)
  255. -endif # ifdef IPTABLESPATH
  256. -
  257. -LIBS += -lnfnetlink
  258. -
  259. TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
  260. EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
  261. - testupnppermissions miniupnpdctl testgetifaddr \
  262. - testgetroute
  263. + testupnppermissions miniupnpdctl testgetifaddr
  264. .PHONY: all clean install depend genuuid
  265. @@ -162,7 +112,7 @@
  266. sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen||$(STAGING_DIR_HOST)/bin/uuid) 2>/dev/null`/" miniupnpd.conf
  267. endif
  268. -miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(LIBS)
  269. +miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
  270. testupnpdescgen: $(TESTUPNPDESCGENOBJS)
  271. @@ -172,8 +122,6 @@
  272. testgetifaddr: testgetifaddr.o getifaddr.o
  273. -testgetroute: testgetroute.o linux/getroute.o upnputils.o -lnfnetlink
  274. -
  275. miniupnpdctl: miniupnpdctl.o
  276. config.h: genconfig.sh VERSION
  277. diff -ur miniupnpd-1.7.20120824/minissdp.c miniupnpd-1.7.20120824.b/minissdp.c
  278. --- miniupnpd-1.7.20120824/minissdp.c 2012-08-22 01:11:41.000000000 +0800
  279. +++ miniupnpd-1.7.20120824.b/minissdp.c 2012-09-04 18:42:17.221295126 +0800
  280. @@ -106,6 +106,7 @@
  281. }
  282. memset(&sockname, 0, sizeof(struct sockaddr_storage));
  283. +#ifdef ENABLE_IPV6
  284. if(ipv6) {
  285. struct sockaddr_in6 * saddr = (struct sockaddr_in6 *)&sockname;
  286. saddr->sin6_family = AF_INET6;
  287. @@ -113,6 +114,7 @@
  288. saddr->sin6_addr = in6addr_any;
  289. sockname_len = sizeof(struct sockaddr_in6);
  290. } else {
  291. +#endif
  292. struct sockaddr_in * saddr = (struct sockaddr_in *)&sockname;
  293. saddr->sin_family = AF_INET;
  294. saddr->sin_port = htons(SSDP_PORT);
  295. @@ -121,7 +123,9 @@
  296. saddr->sin_addr.s_addr = htonl(INADDR_ANY);
  297. /*saddr->sin_addr.s_addr = inet_addr(ifaddr);*/
  298. sockname_len = sizeof(struct sockaddr_in);
  299. +#ifdef ENABLE_IPV6
  300. }
  301. +#endif
  302. if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &j, sizeof(j)) < 0)
  303. {
  304. @@ -582,7 +586,8 @@
  305. }
  306. if (lan_addr == NULL)
  307. {
  308. - syslog(LOG_ERR, "Can't find in which sub network the client is");
  309. + syslog(LOG_INFO, "Can't find in which sub network the client %s is",
  310. + sender_str);
  311. return;
  312. }
  313. announced_host = lan_addr->str;
  314. diff -ur miniupnpd-1.7.20120824/miniupnpd.c miniupnpd-1.7.20120824.b/miniupnpd.c
  315. --- miniupnpd-1.7.20120824/miniupnpd.c 2012-08-22 01:11:41.000000000 +0800
  316. +++ miniupnpd-1.7.20120824.b/miniupnpd.c 2012-09-04 18:42:17.221295126 +0800
  317. @@ -1101,6 +1101,7 @@
  318. }
  319. openlog("miniupnpd", openlog_option, LOG_MINIUPNPD);
  320. + syslog(LOG_INFO, "version " MINIUPNPD_VERSION " started");
  321. if(!debug_flag)
  322. {
  323. @@ -1448,6 +1449,9 @@
  324. }
  325. #endif
  326. should_send_public_address_change_notif = 0;
  327. +#ifdef ENABLE_LEASEFILE
  328. + reload_from_lease_file();
  329. +#endif
  330. }
  331. /* Check if we need to send SSDP NOTIFY messages and do it if
  332. * needed */
  333. @@ -1759,7 +1763,7 @@
  334. {
  335. /* ignore EAGAIN, EWOULDBLOCK, EINTR, we just try again later */
  336. if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)
  337. - syslog(LOG_ERR, "accept(http): %m");
  338. + syslog(LOG_DEBUG, "accept(http): %m");
  339. }
  340. else
  341. {
  342. diff -ur miniupnpd-1.7.20120824/natpmp.c miniupnpd-1.7.20120824.b/natpmp.c
  343. --- miniupnpd-1.7.20120824/natpmp.c 2012-05-28 07:12:51.000000000 +0800
  344. +++ miniupnpd-1.7.20120824.b/natpmp.c 2012-09-04 18:42:17.221295126 +0800
  345. @@ -97,7 +97,7 @@
  346. resp[3] = 3; /* Network Failure (e.g. NAT box itself
  347. * has not obtained a DHCP lease) */
  348. } else if(getifaddr(ext_if_name, tmp, INET_ADDRSTRLEN) < 0) {
  349. - syslog(LOG_ERR, "Failed to get IP for interface %s", ext_if_name);
  350. + syslog(LOG_DEBUG, "Failed to get IP for interface %s", ext_if_name);
  351. resp[3] = 3; /* Network Failure (e.g. NAT box itself
  352. * has not obtained a DHCP lease) */
  353. } else {
  354. @@ -220,7 +220,7 @@
  355. r = _upnp_delete_redir(eport2, proto2);
  356. /* TODO : check return value */
  357. if(r<0) {
  358. - syslog(LOG_ERR, "failed to remove port mapping");
  359. + syslog(LOG_DEBUG, "failed to remove port mapping");
  360. index++;
  361. } else {
  362. syslog(LOG_INFO, "NAT-PMP %s port %hu mapping removed",
  363. @@ -237,7 +237,7 @@
  364. r = _upnp_delete_redir(eport, proto);
  365. /*syslog(LOG_DEBUG, "%hu %d r=%d", eport, proto, r);*/
  366. if(r<0) {
  367. - syslog(LOG_ERR, "Failed to remove NAT-PMP mapping eport %hu, protocol %s",
  368. + syslog(LOG_DEBUG, "Failed to remove NAT-PMP mapping eport %hu, protocol %s",
  369. eport, (proto==IPPROTO_TCP)?"TCP":"UDP");
  370. resp[3] = 2; /* Not Authorized/Refused */
  371. }
  372. @@ -259,7 +259,7 @@
  373. eport, (proto==IPPROTO_TCP)?"tcp":"udp", iaddr_old, iport_old);
  374. /* remove and then add again */
  375. if(_upnp_delete_redir(eport, proto) < 0) {
  376. - syslog(LOG_ERR, "failed to remove port mapping");
  377. + syslog(LOG_DEBUG, "failed to remove port mapping");
  378. break;
  379. }
  380. } else {
  381. @@ -282,7 +282,7 @@
  382. if(upnp_redirect_internal(NULL, eport, senderaddrstr,
  383. iport, proto, desc,
  384. timestamp) < 0) {
  385. - syslog(LOG_ERR, "Failed to add NAT-PMP %hu %s->%s:%hu '%s'",
  386. + syslog(LOG_DEBUG, "Failed to add NAT-PMP %hu %s->%s:%hu '%s'",
  387. eport, (proto==IPPROTO_TCP)?"tcp":"udp", senderaddrstr, iport, desc);
  388. resp[3] = 3; /* Failure */
  389. #if 0
  390. @@ -308,7 +308,7 @@
  391. n = sendto(s, resp, resplen, 0,
  392. (struct sockaddr *)&senderaddr, sizeof(senderaddr));
  393. if(n<0) {
  394. - syslog(LOG_ERR, "sendto(natpmp): %m");
  395. + syslog(LOG_DEBUG, "sendto(natpmp): %m");
  396. } else if(n<resplen) {
  397. syslog(LOG_ERR, "sendto(natpmp): sent only %d bytes out of %d",
  398. n, resplen);
  399. diff -ur miniupnpd-1.7.20120824/netfilter/iptcrdr.c miniupnpd-1.7.20120824.b/netfilter/iptcrdr.c
  400. --- miniupnpd-1.7.20120824/netfilter/iptcrdr.c 2012-05-01 17:11:16.000000000 +0800
  401. +++ miniupnpd-1.7.20120824.b/netfilter/iptcrdr.c 2012-09-10 00:58:17.970067787 +0800
  402. @@ -18,7 +18,7 @@
  403. #include <linux/version.h>
  404. -#if IPTABLES_143
  405. +#ifdef IPTABLES_143
  406. /* IPTABLES API version >= 1.4.3 */
  407. /* added in order to compile on gentoo :
  408. @@ -40,7 +40,7 @@
  409. #else
  410. /* IPTABLES API version < 1.4.3 */
  411. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
  412. -#include <linux/netfilter_ipv4/ip_nat.h>
  413. +#include <linux/netfilter/nf_nat.h>
  414. #else
  415. #if 0
  416. #include <linux/netfilter/nf_nat.h>
  417. diff -ur miniupnpd-1.7.20120824/upnpdescstrings.h miniupnpd-1.7.20120824.b/upnpdescstrings.h
  418. --- miniupnpd-1.7.20120824/upnpdescstrings.h 2012-02-05 07:05:26.000000000 +0800
  419. +++ miniupnpd-1.7.20120824.b/upnpdescstrings.h 2012-09-04 18:42:17.221295126 +0800
  420. @@ -11,10 +11,10 @@
  421. /* strings used in the root device xml description */
  422. /*#define ROOTDEV_FRIENDLYNAME OS_NAME " router"*/
  423. -#define ROOTDEV_MANUFACTURER OS_NAME
  424. -#define ROOTDEV_MANUFACTURERURL OS_URL
  425. -#define ROOTDEV_MODELNAME OS_NAME " router"
  426. -#define ROOTDEV_MODELDESCRIPTION OS_NAME " router"
  427. +#define ROOTDEV_MANUFACTURER "Wive-NG-RTNL"
  428. +#define ROOTDEV_MANUFACTURERURL "http://wive-ng.sourceforge.net/"
  429. +#define ROOTDEV_MODELNAME "Wireless Router"
  430. +#define ROOTDEV_MODELDESCRIPTION OS_NAME " Router"
  431. #define ROOTDEV_MODELURL OS_URL
  432. #define WANDEV_FRIENDLYNAME "WANDevice"
  433. diff -ur miniupnpd-1.7.20120824/upnpevents.c miniupnpd-1.7.20120824.b/upnpevents.c
  434. --- miniupnpd-1.7.20120824/upnpevents.c 2012-05-01 17:11:15.000000000 +0800
  435. +++ miniupnpd-1.7.20120824.b/upnpevents.c 2012-09-04 18:42:17.221295126 +0800
  436. @@ -376,7 +376,7 @@
  437. i = send(obj->s, obj->buffer + obj->sent, obj->tosend - obj->sent, 0);
  438. if(i<0) {
  439. if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) {
  440. - syslog(LOG_NOTICE, "%s: send(): %m", "upnp_event_send");
  441. + syslog(LOG_DEBUG, "%s: send(): %m", "upnp_event_send");
  442. obj->state = EError;
  443. return;
  444. } else {
  445. @@ -400,7 +400,7 @@
  446. if(errno != EAGAIN &&
  447. errno != EWOULDBLOCK &&
  448. errno != EINTR) {
  449. - syslog(LOG_ERR, "%s: recv(): %m", "upnp_event_recv");
  450. + syslog(LOG_DEBUG, "%s: recv(): %m", "upnp_event_recv");
  451. obj->state = EError;
  452. }
  453. return;
  454. diff -ur miniupnpd-1.7.20120824/upnpglobalvars.c miniupnpd-1.7.20120824.b/upnpglobalvars.c
  455. --- miniupnpd-1.7.20120824/upnpglobalvars.c 2012-04-26 22:35:49.000000000 +0800
  456. +++ miniupnpd-1.7.20120824.b/upnpglobalvars.c 2012-09-04 18:42:17.221295126 +0800
  457. @@ -73,10 +73,10 @@
  458. #ifdef USE_NETFILTER
  459. /* chain name to use, both in the nat table
  460. * and the filter table */
  461. -const char * miniupnpd_nat_chain = "MINIUPNPD";
  462. -const char * miniupnpd_forward_chain = "MINIUPNPD";
  463. +const char * miniupnpd_nat_chain = "UPNP";
  464. +const char * miniupnpd_forward_chain = "UPNP";
  465. #ifdef ENABLE_6FC_SERVICE
  466. -const char * miniupnpd_v6_filter_chain = "MINIUPNPD";
  467. +const char * miniupnpd_v6_filter_chain = "UPNP";
  468. #endif
  469. #endif
  470. diff -ur miniupnpd-1.7.20120824/upnphttp.c miniupnpd-1.7.20120824.b/upnphttp.c
  471. --- miniupnpd-1.7.20120824/upnphttp.c 2012-05-28 21:26:58.000000000 +0800
  472. +++ miniupnpd-1.7.20120824.b/upnphttp.c 2012-09-04 18:43:27.969838251 +0800
  473. @@ -12,6 +12,7 @@
  474. #include <string.h>
  475. #include <sys/types.h>
  476. #include <sys/socket.h>
  477. +#include <arpa/inet.h>
  478. #include <sys/param.h>
  479. #include <netinet/in.h>
  480. #include <arpa/inet.h>
  481. @@ -514,7 +515,7 @@
  482. return;
  483. }
  484. #endif
  485. - syslog(LOG_NOTICE, "%s not found, responding ERROR 404", HttpUrl);
  486. + syslog(LOG_INFO, "%s not found, responding ERROR 404", HttpUrl);
  487. Send404(h);
  488. }
  489. #ifdef ENABLE_EVENTS
  490. @@ -568,7 +569,8 @@
  491. }
  492. else if(n==0)
  493. {
  494. - syslog(LOG_WARNING, "HTTP Connection closed unexpectedly");
  495. + syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly",
  496. + inet_ntoa(h->clientaddr));
  497. h->state = EToDelete;
  498. }
  499. else
  500. @@ -604,7 +606,8 @@
  501. }
  502. else if(n==0)
  503. {
  504. - syslog(LOG_WARNING, "HTTP Connection closed inexpectedly");
  505. + syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly",
  506. + inet_ntoa(h->clientaddr));
  507. h->state = EToDelete;
  508. }
  509. else
  510. diff -ur miniupnpd-1.7.20120824/upnpredirect.c miniupnpd-1.7.20120824.b/upnpredirect.c
  511. --- miniupnpd-1.7.20120824/upnpredirect.c 2012-05-02 04:11:50.000000000 +0800
  512. +++ miniupnpd-1.7.20120824.b/upnpredirect.c 2012-09-04 18:42:17.221295126 +0800
  513. @@ -165,7 +165,7 @@
  514. if(!lease_file) return -1;
  515. fd = fopen( lease_file, "r");
  516. if (fd==NULL) {
  517. - syslog(LOG_ERR, "could not open lease file: %s", lease_file);
  518. + syslog(LOG_DEBUG, "could not open lease file: %s", lease_file);
  519. return -1;
  520. }
  521. if(unlink(lease_file) < 0) {
  522. @@ -287,14 +287,20 @@
  523. * xbox 360 does not keep track of the port it redirects and will
  524. * redirect another port when receiving ConflictInMappingEntry */
  525. if(strcmp(iaddr, iaddr_old)==0 && iport==iport_old) {
  526. - syslog(LOG_INFO, "ignoring redirect request as it matches existing redirect");
  527. + /* redirection allready exists */
  528. + syslog(LOG_INFO, "port %hu %s already redirected to %s:%hu, replacing", eport, (proto==IPPROTO_TCP)?"tcp":"udp", iaddr_old, iport_old);
  529. + /* remove and then add again */
  530. + if(_upnp_delete_redir(eport, proto) < 0) {
  531. + syslog(LOG_ERR, "failed to remove port mapping");
  532. + return 0;
  533. + }
  534. } else {
  535. syslog(LOG_INFO, "port %hu protocol %s already redirected to %s:%hu",
  536. eport, protocol, iaddr_old, iport_old);
  537. return -2;
  538. }
  539. - } else {
  540. + }
  541. timestamp = (leaseduration > 0) ? time(NULL) + leaseduration : 0;
  542. syslog(LOG_INFO, "redirecting port %hu to %s:%hu protocol %s for: %s",
  543. eport, iaddr, iport, protocol, desc);
  544. @@ -302,9 +308,6 @@
  545. desc, timestamp);
  546. }
  547. - return 0;
  548. -}
  549. -
  550. int
  551. upnp_redirect_internal(const char * rhost, unsigned short eport,
  552. const char * iaddr, unsigned short iport,
  553. @@ -511,7 +514,7 @@
  554. {
  555. if(tmp->to_remove)
  556. {
  557. - syslog(LOG_NOTICE, "remove port mapping %hu %s because it has expired",
  558. + syslog(LOG_INFO, "remove port mapping %hu %s because it has expired",
  559. tmp->eport, (tmp->proto==IPPROTO_TCP)?"TCP":"UDP");
  560. _upnp_delete_redir(tmp->eport, tmp->proto);
  561. *p = tmp->next;
  562. @@ -553,7 +556,7 @@
  563. {
  564. if(packets == list->packets && bytes == list->bytes)
  565. {
  566. - _upnp_delete_redir(list->eport, list->proto);
  567. + if(_upnp_delete_redir(list->eport, list->proto) >= 0)
  568. n++;
  569. }
  570. }
  571. diff -ur miniupnpd-1.7.20120824/upnpsoap.c miniupnpd-1.7.20120824.b/upnpsoap.c
  572. --- miniupnpd-1.7.20120824/upnpsoap.c 2012-05-25 02:05:47.000000000 +0800
  573. +++ miniupnpd-1.7.20120824.b/upnpsoap.c 2012-09-04 18:42:17.221295126 +0800
  574. @@ -271,7 +271,7 @@
  575. }
  576. else if(getifaddr(ext_if_name, ext_ip_addr, INET_ADDRSTRLEN) < 0)
  577. {
  578. - syslog(LOG_ERR, "Failed to get ip address for interface %s",
  579. + syslog(LOG_DEBUG, "Failed to get ip address for interface %s",
  580. ext_if_name);
  581. strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);
  582. }
  583. @@ -355,7 +355,7 @@
  584. }
  585. else
  586. {
  587. - syslog(LOG_ERR, "Failed to convert hostname '%s' to ip address", int_ip);
  588. + syslog(LOG_DEBUG, "Failed to convert hostname '%s' to ip address", int_ip);
  589. ClearNameValueList(&data);
  590. SoapError(h, 402, "Invalid Args");
  591. return;
  592. @@ -522,7 +522,7 @@
  593. }
  594. else
  595. {
  596. - syslog(LOG_ERR, "Failed to convert hostname '%s' to ip address", int_ip);
  597. + syslog(LOG_DEBUG, "Failed to convert hostname '%s' to ip address", int_ip);
  598. ClearNameValueList(&data);
  599. SoapError(h, 402, "Invalid Args");
  600. return;
  601. @@ -1113,7 +1113,7 @@
  602. }
  603. else
  604. {
  605. - syslog(LOG_NOTICE, "%s: Unknown: %s", action, var_name?var_name:"");
  606. + syslog(LOG_DEBUG, "%s: Unknown: %s", action, var_name?var_name:"");
  607. SoapError(h, 404, "Invalid Var");
  608. }
  609. @@ -1246,7 +1246,7 @@
  610. }
  611. else
  612. {
  613. - syslog(LOG_ERR, "Failed to convert hostname '%s' to ip address", int_ip);
  614. + syslog(LOG_DEBUG, "Failed to convert hostname '%s' to ip address", int_ip);
  615. SoapError(h, 402, "Invalid Args");
  616. return -1;
  617. }
  618. @@ -1836,7 +1836,7 @@
  619. i++;
  620. }
  621. - syslog(LOG_NOTICE, "SoapMethod: Unknown: %.*s", methodlen, p);
  622. + syslog(LOG_DEBUG, "SoapMethod: Unknown: %.*s", methodlen, p);
  623. }
  624. SoapError(h, 401, "Invalid Action");
  625. @@ -1884,7 +1884,7 @@
  626. char body[2048];
  627. int bodylen;
  628. - syslog(LOG_INFO, "Returning UPnPError %d: %s", errCode, errDesc);
  629. + syslog(LOG_DEBUG, "Returning UPnPError %d: %s", errCode, errDesc);
  630. bodylen = snprintf(body, sizeof(body), resp, errCode, errDesc);
  631. BuildResp2_upnphttp(h, 500, "Internal Server Error", body, bodylen);
  632. SendRespAndClose_upnphttp(h);