Makefile 14 KB

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