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