Makefile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. #
  2. # Copyright (C) 2006-2016 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/kernel.mk
  9. PKG_NAME:=iptables
  10. PKG_VERSION:=1.4.21
  11. PKG_RELEASE:=3
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  13. PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
  14. ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
  15. ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
  16. ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
  17. PKG_HASH:=52004c68021da9a599feed27f65defcfb22128f7da2c0531c0f75de0f479d3e0
  18. PKG_FIXUP:=autoreconf
  19. PKG_INSTALL:=1
  20. PKG_BUILD_PARALLEL:=1
  21. PKG_LICENSE:=GPL-2.0
  22. include $(INCLUDE_DIR)/package.mk
  23. ifeq ($(DUMP),)
  24. -include $(LINUX_DIR)/.config
  25. include $(INCLUDE_DIR)/netfilter.mk
  26. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | mkhash md5)
  27. endif
  28. define Package/iptables/Default
  29. SECTION:=net
  30. CATEGORY:=Network
  31. SUBMENU:=Firewall
  32. URL:=http://netfilter.org/
  33. endef
  34. define Package/iptables/Module
  35. $(call Package/iptables/Default)
  36. DEPENDS:=iptables $(1)
  37. endef
  38. define Package/iptables
  39. $(call Package/iptables/Default)
  40. TITLE:=IP firewall administration tool
  41. MENU:=1
  42. DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libxtables
  43. endef
  44. define Package/iptables/description
  45. IP firewall administration tool.
  46. Matches:
  47. - icmp
  48. - tcp
  49. - udp
  50. - comment
  51. - conntrack
  52. - limit
  53. - mac
  54. - mark
  55. - multiport
  56. - set
  57. - state
  58. - time
  59. Targets:
  60. - ACCEPT
  61. - CT
  62. - DNAT
  63. - DROP
  64. - REJECT
  65. - LOG
  66. - MARK
  67. - MASQUERADE
  68. - REDIRECT
  69. - SET
  70. - SNAT
  71. - TCPMSS
  72. Tables:
  73. - filter
  74. - mangle
  75. - nat
  76. - raw
  77. endef
  78. define Package/iptables-mod-conntrack-extra
  79. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  80. TITLE:=Extra connection tracking extensions
  81. endef
  82. define Package/iptables-mod-conntrack-extra/description
  83. Extra iptables extensions for connection tracking.
  84. Matches:
  85. - connbytes
  86. - connlimit
  87. - connmark
  88. - recent
  89. - helper
  90. Targets:
  91. - CONNMARK
  92. endef
  93. define Package/iptables-mod-filter
  94. $(call Package/iptables/Module, +kmod-ipt-filter)
  95. TITLE:=Content inspection extensions
  96. endef
  97. define Package/iptables-mod-filter/description
  98. iptables extensions for packet content inspection.
  99. Includes support for:
  100. Matches:
  101. - string
  102. endef
  103. define Package/iptables-mod-ipopt
  104. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  105. TITLE:=IP/Packet option extensions
  106. endef
  107. define Package/iptables-mod-ipopt/description
  108. iptables extensions for matching/changing IP packet options.
  109. Matches:
  110. - dscp
  111. - ecn
  112. - length
  113. - statistic
  114. - tcpmss
  115. - unclean
  116. - hl
  117. Targets:
  118. - DSCP
  119. - CLASSIFY
  120. - ECN
  121. - HL
  122. endef
  123. define Package/iptables-mod-ipsec
  124. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  125. TITLE:=IPsec extensions
  126. endef
  127. define Package/iptables-mod-ipsec/description
  128. iptables extensions for matching ipsec traffic.
  129. Matches:
  130. - ah
  131. - esp
  132. - policy
  133. endef
  134. define Package/iptables-mod-nat-extra
  135. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  136. TITLE:=Extra NAT extensions
  137. endef
  138. define Package/iptables-mod-nat-extra/description
  139. iptables extensions for extra NAT targets.
  140. Targets:
  141. - MIRROR
  142. - NETMAP
  143. endef
  144. define Package/iptables-mod-ulog
  145. $(call Package/iptables/Module, +kmod-ipt-ulog)
  146. TITLE:=user-space packet logging
  147. endef
  148. define Package/iptables-mod-ulog/description
  149. iptables extensions for user-space packet logging.
  150. Targets:
  151. - ULOG
  152. endef
  153. define Package/iptables-mod-nflog
  154. $(call Package/iptables/Module, +kmod-nfnetlink-log +kmod-ipt-nflog)
  155. TITLE:=Netfilter NFLOG target
  156. endef
  157. define Package/iptables-mod-nflog/description
  158. iptables extension for user-space logging via NFNETLINK.
  159. Includes:
  160. - libxt_NFLOG
  161. endef
  162. define Package/iptables-mod-trace
  163. $(call Package/iptables/Module, +kmod-ipt-debug)
  164. TITLE:=Netfilter TRACE target
  165. endef
  166. define Package/iptables-mod-trace/description
  167. iptables extension for TRACE target
  168. Includes:
  169. - libxt_TRACE
  170. endef
  171. define Package/iptables-mod-nfqueue
  172. $(call Package/iptables/Module, +kmod-nfnetlink-queue +kmod-ipt-nfqueue)
  173. TITLE:=Netfilter NFQUEUE target
  174. endef
  175. define Package/iptables-mod-nfqueue/description
  176. iptables extension for user-space queuing via NFNETLINK.
  177. Includes:
  178. - libxt_NFQUEUE
  179. endef
  180. define Package/iptables-mod-hashlimit
  181. $(call Package/iptables/Module, +kmod-ipt-hashlimit)
  182. TITLE:=hashlimit matching
  183. endef
  184. define Package/iptables-mod-hashlimit/description
  185. iptables extensions for hashlimit matching
  186. Matches:
  187. - hashlimit
  188. endef
  189. define Package/iptables-mod-rpfilter
  190. $(call Package/iptables/Module, +kmod-ipt-rpfilter)
  191. TITLE:=rpfilter iptables extension
  192. endef
  193. define Package/iptables-mod-rpfilter/description
  194. iptables extensions for reverse path filter test on a packet
  195. Matches:
  196. - rpfilter
  197. endef
  198. define Package/iptables-mod-iprange
  199. $(call Package/iptables/Module, +kmod-ipt-iprange)
  200. TITLE:=IP range extension
  201. endef
  202. define Package/iptables-mod-iprange/description
  203. iptables extensions for matching ip ranges.
  204. Matches:
  205. - iprange
  206. endef
  207. define Package/iptables-mod-cluster
  208. $(call Package/iptables/Module, +kmod-ipt-cluster)
  209. TITLE:=Match cluster extension
  210. endef
  211. define Package/iptables-mod-cluster/description
  212. iptables extensions for matching cluster.
  213. Netfilter (IPv4/IPv6) module for matching cluster
  214. This option allows you to build work-load-sharing clusters of
  215. network servers/stateful firewalls without having a dedicated
  216. load-balancing router/server/switch. Basically, this match returns
  217. true when the packet must be handled by this cluster node. Thus,
  218. all nodes see all packets and this match decides which node handles
  219. what packets. The work-load sharing algorithm is based on source
  220. address hashing.
  221. This module is usable for ipv4 and ipv6.
  222. If you select it, it enables kmod-ipt-cluster.
  223. see `iptables -m cluster --help` for more information.
  224. endef
  225. define Package/iptables-mod-clusterip
  226. $(call Package/iptables/Module, +kmod-ipt-clusterip)
  227. TITLE:=Clusterip extension
  228. endef
  229. define Package/iptables-mod-clusterip/description
  230. iptables extensions for CLUSTERIP.
  231. The CLUSTERIP target allows you to build load-balancing clusters of
  232. network servers without having a dedicated load-balancing
  233. router/server/switch.
  234. If you select it, it enables kmod-ipt-clusterip.
  235. see `iptables -j CLUSTERIP --help` for more information.
  236. endef
  237. define Package/iptables-mod-extra
  238. $(call Package/iptables/Module, +kmod-ipt-extra)
  239. TITLE:=Other extra iptables extensions
  240. endef
  241. define Package/iptables-mod-extra/description
  242. Other extra iptables extensions.
  243. Matches:
  244. - addrtype
  245. - condition
  246. - owner
  247. - physdev (if ebtables is enabled)
  248. - pkttype
  249. - quota
  250. endef
  251. define Package/iptables-mod-led
  252. $(call Package/iptables/Module, +kmod-ipt-led)
  253. TITLE:=LED trigger iptables extension
  254. endef
  255. define Package/iptables-mod-led/description
  256. iptables extension for triggering a LED.
  257. Targets:
  258. - LED
  259. endef
  260. define Package/iptables-mod-tproxy
  261. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  262. TITLE:=Transparent proxy iptables extensions
  263. endef
  264. define Package/iptables-mod-tproxy/description
  265. Transparent proxy iptables extensions.
  266. Matches:
  267. - socket
  268. Targets:
  269. - TPROXY
  270. endef
  271. define Package/iptables-mod-tee
  272. $(call Package/iptables/Module, +kmod-ipt-tee)
  273. TITLE:=TEE iptables extensions
  274. endef
  275. define Package/iptables-mod-tee/description
  276. TEE iptables extensions.
  277. Targets:
  278. - TEE
  279. endef
  280. define Package/iptables-mod-u32
  281. $(call Package/iptables/Module, +kmod-ipt-u32)
  282. TITLE:=U32 iptables extensions
  283. endef
  284. define Package/iptables-mod-u32/description
  285. U32 iptables extensions.
  286. Matches:
  287. - u32
  288. endef
  289. define Package/ip6tables
  290. $(call Package/iptables/Default)
  291. DEPENDS:=@IPV6 +kmod-ip6tables +iptables
  292. CATEGORY:=Network
  293. TITLE:=IPv6 firewall administration tool
  294. MENU:=1
  295. endef
  296. define Package/ip6tables-extra
  297. $(call Package/iptables/Default)
  298. DEPENDS:=ip6tables +kmod-ip6tables-extra
  299. TITLE:=IPv6 header matching modules
  300. endef
  301. define Package/ip6tables-mod-extra/description
  302. iptables header matching modules for IPv6
  303. endef
  304. define Package/ip6tables-mod-nat
  305. $(call Package/iptables/Default)
  306. DEPENDS:=ip6tables +kmod-ipt-nat6
  307. TITLE:=IPv6 NAT extensions
  308. endef
  309. define Package/ip6tables-mod-nat/description
  310. iptables extensions for IPv6-NAT targets.
  311. endef
  312. define Package/libiptc
  313. $(call Package/iptables/Default)
  314. SECTION:=libs
  315. CATEGORY:=Libraries
  316. DEPENDS:=+libip4tc +libip6tc +libxtables
  317. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  318. endef
  319. define Package/libip4tc
  320. $(call Package/iptables/Default)
  321. SECTION:=libs
  322. CATEGORY:=Libraries
  323. TITLE:=IPv4 firewall - shared libiptc library
  324. DEPENDS:=+libxtables
  325. endef
  326. define Package/libip6tc
  327. $(call Package/iptables/Default)
  328. SECTION:=libs
  329. CATEGORY:=Libraries
  330. TITLE:=IPv6 firewall - shared libiptc library
  331. DEPENDS:=+libxtables
  332. endef
  333. define Package/libxtables
  334. $(call Package/iptables/Default)
  335. SECTION:=libs
  336. CATEGORY:=Libraries
  337. TITLE:=IPv4/IPv6 firewall - shared xtables library
  338. endef
  339. TARGET_CPPFLAGS := \
  340. -I$(PKG_BUILD_DIR)/include \
  341. -I$(LINUX_DIR)/user_headers/include \
  342. $(TARGET_CPPFLAGS)
  343. TARGET_CFLAGS += \
  344. -I$(PKG_BUILD_DIR)/include \
  345. -I$(LINUX_DIR)/user_headers/include \
  346. -ffunction-sections -fdata-sections \
  347. -DNO_LEGACY
  348. TARGET_LDFLAGS += \
  349. -Wl,--gc-sections
  350. CONFIGURE_ARGS += \
  351. --enable-shared \
  352. --enable-devel \
  353. --with-kernel="$(LINUX_DIR)/user_headers" \
  354. --with-xtlibdir=/usr/lib/iptables \
  355. --enable-static \
  356. $(if $(CONFIG_IPV6),,--disable-ipv6)
  357. MAKE_FLAGS := \
  358. $(TARGET_CONFIGURE_OPTS) \
  359. COPT_FLAGS="$(TARGET_CFLAGS)" \
  360. KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
  361. KBUILD_OUTPUT="$(LINUX_DIR)" \
  362. BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
  363. ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
  364. define Build/Configure/rebuild
  365. $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.\?o -or -name \*.a | $(XARGS) rm -f
  366. rm -f $(PKG_BUILD_DIR)/.config_*
  367. rm -f $(PKG_BUILD_DIR)/.configured_*
  368. touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
  369. endef
  370. endif
  371. define Build/Configure
  372. $(Build/Configure/rebuild)
  373. $(Build/Configure/Default)
  374. endef
  375. define Build/InstallDev
  376. $(INSTALL_DIR) $(1)/usr/include
  377. $(INSTALL_DIR) $(1)/usr/include/iptables
  378. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  379. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  380. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  381. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  382. $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
  383. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  384. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  385. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  386. $(INSTALL_DIR) $(1)/usr/lib
  387. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  388. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  389. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  390. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  391. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
  392. # XXX: needed by firewall3
  393. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext*.so $(1)/usr/lib/
  394. endef
  395. define Package/iptables/install
  396. $(INSTALL_DIR) $(1)/usr/sbin
  397. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
  398. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
  399. $(INSTALL_DIR) $(1)/usr/lib/iptables
  400. endef
  401. define Package/ip6tables/install
  402. $(INSTALL_DIR) $(1)/usr/sbin
  403. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
  404. endef
  405. define Package/libiptc/install
  406. $(INSTALL_DIR) $(1)/usr/lib
  407. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  408. endef
  409. define Package/libip4tc/install
  410. $(INSTALL_DIR) $(1)/usr/lib
  411. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  412. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext4.so $(1)/usr/lib/
  413. endef
  414. define Package/libip6tc/install
  415. $(INSTALL_DIR) $(1)/usr/lib
  416. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  417. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext6.so $(1)/usr/lib/
  418. endef
  419. define Package/libxtables/install
  420. $(INSTALL_DIR) $(1)/usr/lib
  421. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  422. $(CP) $(PKG_BUILD_DIR)/extensions/libiptext.so $(1)/usr/lib/
  423. endef
  424. define BuildPlugin
  425. define Package/$(1)/install
  426. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  427. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
  428. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  429. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  430. fi; \
  431. done
  432. $(3)
  433. endef
  434. $$(eval $$(call BuildPackage,$(1)))
  435. endef
  436. $(eval $(call BuildPackage,iptables))
  437. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  438. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  439. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m)))
  440. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  441. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  442. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  443. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  444. $(eval $(call BuildPlugin,iptables-mod-cluster,$(IPT_CLUSTER-m)))
  445. $(eval $(call BuildPlugin,iptables-mod-clusterip,$(IPT_CLUSTERIP-m)))
  446. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  447. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  448. $(eval $(call BuildPlugin,iptables-mod-rpfilter,$(IPT_RPFILTER-m)))
  449. $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
  450. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  451. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  452. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  453. $(eval $(call BuildPlugin,iptables-mod-nflog,$(IPT_NFLOG-m)))
  454. $(eval $(call BuildPlugin,iptables-mod-trace,$(IPT_DEBUG-m)))
  455. $(eval $(call BuildPlugin,iptables-mod-nfqueue,$(IPT_NFQUEUE-m)))
  456. $(eval $(call BuildPackage,ip6tables))
  457. $(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m)))
  458. $(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m)))
  459. $(eval $(call BuildPackage,libiptc))
  460. $(eval $(call BuildPackage,libip4tc))
  461. $(eval $(call BuildPackage,libip6tc))
  462. $(eval $(call BuildPackage,libxtables))