Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. - layer7
  105. - string
  106. endef
  107. define Package/iptables-mod-ipopt
  108. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  109. TITLE:=IP/Packet option extensions
  110. endef
  111. define Package/iptables-mod-ipopt/description
  112. iptables extensions for matching/changing IP packet options.
  113. Matches:
  114. - dscp
  115. - ecn
  116. - length
  117. - statistic
  118. - tcpmss
  119. - unclean
  120. - hl
  121. Targets:
  122. - DSCP
  123. - CLASSIFY
  124. - ECN
  125. - HL
  126. endef
  127. define Package/iptables-mod-ipsec
  128. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  129. TITLE:=IPsec extensions
  130. endef
  131. define Package/iptables-mod-ipsec/description
  132. iptables extensions for matching ipsec traffic.
  133. Matches:
  134. - ah
  135. - esp
  136. - policy
  137. endef
  138. define Package/iptables-mod-nat-extra
  139. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  140. TITLE:=Extra NAT extensions
  141. endef
  142. define Package/iptables-mod-nat-extra/description
  143. iptables extensions for extra NAT targets.
  144. Targets:
  145. - MIRROR
  146. - NETMAP
  147. endef
  148. define Package/iptables-mod-ulog
  149. $(call Package/iptables/Module, +kmod-ipt-ulog)
  150. TITLE:=user-space packet logging
  151. endef
  152. define Package/iptables-mod-ulog/description
  153. iptables extensions for user-space packet logging.
  154. Targets:
  155. - ULOG
  156. endef
  157. define Package/iptables-mod-nflog
  158. $(call Package/iptables/Module, +kmod-nfnetlink-log +kmod-ipt-nflog)
  159. TITLE:=Netfilter NFLOG target
  160. endef
  161. define Package/iptables-mod-nflog/description
  162. iptables extension for user-space logging via NFNETLINK.
  163. Includes:
  164. - libxt_NFLOG
  165. endef
  166. define Package/iptables-mod-nfqueue
  167. $(call Package/iptables/Module, +kmod-nfnetlink-queue +kmod-ipt-nfqueue)
  168. TITLE:=Netfilter NFQUEUE target
  169. endef
  170. define Package/iptables-mod-nfqueue/description
  171. iptables extension for user-space queuing via NFNETLINK.
  172. Includes:
  173. - libxt_NFQUEUE
  174. endef
  175. define Package/iptables-mod-hashlimit
  176. $(call Package/iptables/Module, +kmod-ipt-hashlimit)
  177. TITLE:=hashlimit matching
  178. endef
  179. define Package/iptables-mod-hashlimit/description
  180. iptables extensions for hashlimit matching
  181. Matches:
  182. - hashlimit
  183. endef
  184. define Package/iptables-mod-iprange
  185. $(call Package/iptables/Module, +kmod-ipt-iprange)
  186. TITLE:=IP range extension
  187. endef
  188. define Package/iptables-mod-iprange/description
  189. iptables extensions for matching ip ranges.
  190. Matches:
  191. - iprange
  192. endef
  193. define Package/iptables-mod-cluster
  194. $(call Package/iptables/Module, +kmod-ipt-cluster)
  195. TITLE:=Match cluster extension
  196. endef
  197. define Package/iptables-mod-cluster/description
  198. iptables extensions for matching cluster.
  199. Netfilter (IPv4/IPv6) module for matching cluster
  200. This option allows you to build work-load-sharing clusters of
  201. network servers/stateful firewalls without having a dedicated
  202. load-balancing router/server/switch. Basically, this match returns
  203. true when the packet must be handled by this cluster node. Thus,
  204. all nodes see all packets and this match decides which node handles
  205. what packets. The work-load sharing algorithm is based on source
  206. address hashing.
  207. This module is usable for ipv4 and ipv6.
  208. If you select it, it enables kmod-ipt-cluster.
  209. see `iptables -m cluster --help` for more information.
  210. endef
  211. define Package/iptables-mod-clusterip
  212. $(call Package/iptables/Module, +kmod-ipt-clusterip)
  213. TITLE:=Clusterip extension
  214. endef
  215. define Package/iptables-mod-clusterip/description
  216. iptables extensions for CLUSTERIP.
  217. The CLUSTERIP target allows you to build load-balancing clusters of
  218. network servers without having a dedicated load-balancing
  219. router/server/switch.
  220. If you select it, it enables kmod-ipt-clusterip.
  221. see `iptables -j CLUSTERIP --help` for more information.
  222. endef
  223. define Package/iptables-mod-extra
  224. $(call Package/iptables/Module, +kmod-ipt-extra)
  225. TITLE:=Other extra iptables extensions
  226. endef
  227. define Package/iptables-mod-extra/description
  228. Other extra iptables extensions.
  229. Matches:
  230. - addrtype
  231. - condition
  232. - owner
  233. - physdev (if ebtables is enabled)
  234. - pkttype
  235. - quota
  236. endef
  237. define Package/iptables-mod-led
  238. $(call Package/iptables/Module, +kmod-ipt-led)
  239. TITLE:=LED trigger iptables extension
  240. endef
  241. define Package/iptables-mod-led/description
  242. iptables extension for triggering a LED.
  243. Targets:
  244. - LED
  245. endef
  246. define Package/iptables-mod-tproxy
  247. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  248. TITLE:=Transparent proxy iptables extensions
  249. endef
  250. define Package/iptables-mod-tproxy/description
  251. Transparent proxy iptables extensions.
  252. Matches:
  253. - socket
  254. Targets:
  255. - TPROXY
  256. endef
  257. define Package/iptables-mod-tee
  258. $(call Package/iptables/Module, +kmod-ipt-tee)
  259. TITLE:=TEE iptables extensions
  260. endef
  261. define Package/iptables-mod-tee/description
  262. TEE iptables extensions.
  263. Targets:
  264. - TEE
  265. endef
  266. define Package/iptables-mod-u32
  267. $(call Package/iptables/Module, +kmod-ipt-u32)
  268. TITLE:=U32 iptables extensions
  269. endef
  270. define Package/iptables-mod-u32/description
  271. U32 iptables extensions.
  272. Matches:
  273. - u32
  274. endef
  275. define Package/ip6tables
  276. $(call Package/iptables/Default)
  277. DEPENDS:=@IPV6 +kmod-ip6tables +iptables
  278. CATEGORY:=Network
  279. TITLE:=IPv6 firewall administration tool
  280. MENU:=1
  281. endef
  282. define Package/ip6tables-extra
  283. $(call Package/iptables/Default)
  284. DEPENDS:=ip6tables +kmod-ip6tables-extra
  285. TITLE:=IPv6 header matching modules
  286. endef
  287. define Package/ip6tables-mod-extra/description
  288. iptables header matching modules for IPv6
  289. endef
  290. define Package/ip6tables-mod-nat
  291. $(call Package/iptables/Default)
  292. DEPENDS:=ip6tables +kmod-ipt-nat6
  293. TITLE:=IPv6 NAT extensions
  294. endef
  295. define Package/ip6tables-mod-nat/description
  296. iptables extensions for IPv6-NAT targets.
  297. endef
  298. define Package/libiptc
  299. $(call Package/iptables/Default)
  300. SECTION:=libs
  301. CATEGORY:=Libraries
  302. DEPENDS:=+libip4tc +IPV6:libip6tc
  303. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  304. endef
  305. define Package/libip4tc
  306. $(call Package/iptables/Default)
  307. SECTION:=libs
  308. CATEGORY:=Libraries
  309. TITLE:=IPv4 firewall - shared libiptc library
  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. endef
  317. define Package/libxtables
  318. $(call Package/iptables/Default)
  319. SECTION:=libs
  320. CATEGORY:=Libraries
  321. TITLE:=IPv4/IPv6 firewall - shared xtables library
  322. endef
  323. TARGET_CPPFLAGS := \
  324. -I$(PKG_BUILD_DIR)/include \
  325. -I$(LINUX_DIR)/user_headers/include \
  326. $(TARGET_CPPFLAGS)
  327. TARGET_CFLAGS += \
  328. -I$(PKG_BUILD_DIR)/include \
  329. -I$(LINUX_DIR)/user_headers/include \
  330. -ffunction-sections -fdata-sections
  331. TARGET_LDFLAGS += \
  332. -Wl,--gc-sections
  333. CONFIGURE_ARGS += \
  334. --enable-shared \
  335. --enable-devel \
  336. --with-kernel="$(LINUX_DIR)/user_headers" \
  337. --with-xtlibdir=/usr/lib/iptables \
  338. --enable-static \
  339. $(if $(CONFIG_IPV6),,--disable-ipv6)
  340. MAKE_FLAGS := \
  341. $(TARGET_CONFIGURE_OPTS) \
  342. COPT_FLAGS="$(TARGET_CFLAGS)" \
  343. KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
  344. KBUILD_OUTPUT="$(LINUX_DIR)" \
  345. BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
  346. define Build/InstallDev
  347. $(INSTALL_DIR) $(1)/usr/include
  348. $(INSTALL_DIR) $(1)/usr/include/iptables
  349. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  350. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  351. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  352. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  353. $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
  354. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  355. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  356. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  357. $(INSTALL_DIR) $(1)/usr/lib
  358. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  359. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  360. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  361. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  362. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
  363. # XXX: needed by firewall3
  364. $(INSTALL_DIR) $(1)/usr/lib/iptables
  365. $(CP) $(PKG_BUILD_DIR)/extensions/libext*.a $(1)/usr/lib/iptables/
  366. endef
  367. define Package/iptables/install
  368. $(INSTALL_DIR) $(1)/usr/sbin
  369. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
  370. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
  371. $(INSTALL_DIR) $(1)/usr/lib/iptables
  372. endef
  373. define Package/ip6tables/install
  374. $(INSTALL_DIR) $(1)/usr/sbin
  375. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
  376. endef
  377. define Package/libiptc/install
  378. $(INSTALL_DIR) $(1)/usr/lib
  379. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  380. endef
  381. define Package/libip4tc/install
  382. $(INSTALL_DIR) $(1)/usr/lib
  383. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  384. endef
  385. define Package/libip6tc/install
  386. $(INSTALL_DIR) $(1)/usr/lib
  387. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  388. endef
  389. define Package/libxtables/install
  390. $(INSTALL_DIR) $(1)/usr/lib
  391. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  392. endef
  393. define BuildPlugin
  394. define Package/$(1)/install
  395. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  396. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
  397. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  398. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  399. fi; \
  400. done
  401. $(3)
  402. endef
  403. $$(eval $$(call BuildPackage,$(1)))
  404. endef
  405. L7_INSTALL:=\
  406. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  407. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  408. $(eval $(call BuildPackage,iptables))
  409. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  410. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  411. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  412. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  413. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  414. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  415. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  416. $(eval $(call BuildPlugin,iptables-mod-cluster,$(IPT_CLUSTER-m)))
  417. $(eval $(call BuildPlugin,iptables-mod-clusterip,$(IPT_CLUSTERIP-m)))
  418. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  419. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  420. $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
  421. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  422. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  423. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  424. $(eval $(call BuildPlugin,iptables-mod-nflog,$(IPT_NFLOG-m)))
  425. $(eval $(call BuildPlugin,iptables-mod-nfqueue,$(IPT_NFQUEUE-m)))
  426. $(eval $(call BuildPackage,ip6tables))
  427. $(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m)))
  428. $(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m)))
  429. $(eval $(call BuildPackage,libiptc))
  430. $(eval $(call BuildPackage,libip4tc))
  431. $(eval $(call BuildPackage,libip6tc))
  432. $(eval $(call BuildPackage,libxtables))