Makefile 13 KB

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