1*da295319SPatrick WilliamsSUMMARY = "Tools for managing kernel packet filtering capabilities" 2*da295319SPatrick WilliamsDESCRIPTION = "iptables is the userspace command line program used to configure and control network packet \ 3*da295319SPatrick Williamsfiltering code in Linux." 4*da295319SPatrick WilliamsHOMEPAGE = "http://www.netfilter.org/" 5*da295319SPatrick WilliamsBUGTRACKER = "http://bugzilla.netfilter.org/" 6*da295319SPatrick WilliamsLICENSE = "GPL-2.0-or-later" 7*da295319SPatrick WilliamsLIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ 8*da295319SPatrick Williams file://iptables/iptables.c;beginline=13;endline=25;md5=c5cffd09974558cf27d0f763df2a12dc \ 9*da295319SPatrick Williams" 10*da295319SPatrick Williams 11*da295319SPatrick WilliamsSRC_URI = "http://netfilter.org/projects/iptables/files/iptables-${PV}.tar.xz \ 12*da295319SPatrick Williams file://iptables.service \ 13*da295319SPatrick Williams file://iptables.rules \ 14*da295319SPatrick Williams file://ip6tables.service \ 15*da295319SPatrick Williams file://ip6tables.rules \ 16*da295319SPatrick Williams file://0001-configure-Add-option-to-enable-disable-libnfnetlink.patch \ 17*da295319SPatrick Williams file://0002-iptables-xshared.h-add-missing-sys.types.h-include.patch \ 18*da295319SPatrick Williams file://0004-configure.ac-only-check-conntrack-when-libnfnetlink-.patch \ 19*da295319SPatrick Williams " 20*da295319SPatrick WilliamsSRC_URI[sha256sum] = "5cc255c189356e317d070755ce9371eb63a1b783c34498fb8c30264f3cc59c9c" 21*da295319SPatrick Williams 22*da295319SPatrick WilliamsSYSTEMD_SERVICE:${PN} = "\ 23*da295319SPatrick Williams iptables.service \ 24*da295319SPatrick Williams ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'ip6tables.service', '', d)} \ 25*da295319SPatrick Williams" 26*da295319SPatrick Williams 27*da295319SPatrick Williamsinherit autotools pkgconfig systemd 28*da295319SPatrick Williams 29*da295319SPatrick WilliamsEXTRA_OECONF = "--with-kernel=${STAGING_INCDIR}" 30*da295319SPatrick Williams 31*da295319SPatrick WilliamsCFLAGS:append:libc-musl = " -D__UAPI_DEF_ETHHDR=0" 32*da295319SPatrick Williams 33*da295319SPatrick WilliamsPACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}" 34*da295319SPatrick WilliamsPACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6," 35*da295319SPatrick Williams 36*da295319SPatrick Williams# libnfnetlink recipe is in meta-networking layer 37*da295319SPatrick WilliamsPACKAGECONFIG[libnfnetlink] = "--enable-libnfnetlink,--disable-libnfnetlink,libnfnetlink libnetfilter-conntrack" 38*da295319SPatrick Williams 39*da295319SPatrick Williams# libnftnl recipe is in meta-networking layer(previously known as libnftables) 40*da295319SPatrick WilliamsPACKAGECONFIG[libnftnl] = "--enable-nftables,--disable-nftables,libnftnl" 41*da295319SPatrick Williams 42*da295319SPatrick Williamsdo_configure:prepend() { 43*da295319SPatrick Williams # Remove some libtool m4 files 44*da295319SPatrick Williams # Keep ax_check_linker_flags.m4 which belongs to autoconf-archive. 45*da295319SPatrick Williams rm -f libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 46*da295319SPatrick Williams 47*da295319SPatrick Williams # Copy a header to fix out of tree builds 48*da295319SPatrick Williams cp -f ${S}/libiptc/linux_list.h ${S}/include/libiptc/ 49*da295319SPatrick Williams} 50*da295319SPatrick Williams 51*da295319SPatrick WilliamsIPTABLES_RULES_DIR ?= "${sysconfdir}/${BPN}" 52*da295319SPatrick Williams 53*da295319SPatrick Williamsdo_install:append() { 54*da295319SPatrick Williams install -d ${D}${IPTABLES_RULES_DIR} 55*da295319SPatrick Williams install -m 0644 ${WORKDIR}/iptables.rules ${D}${IPTABLES_RULES_DIR} 56*da295319SPatrick Williams 57*da295319SPatrick Williams install -d ${D}${systemd_system_unitdir} 58*da295319SPatrick Williams install -m 0644 ${WORKDIR}/iptables.service ${D}${systemd_system_unitdir} 59*da295319SPatrick Williams 60*da295319SPatrick Williams sed -i \ 61*da295319SPatrick Williams -e 's,@SBINDIR@,${sbindir},g' \ 62*da295319SPatrick Williams -e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \ 63*da295319SPatrick Williams ${D}${systemd_system_unitdir}/iptables.service 64*da295319SPatrick Williams 65*da295319SPatrick Williams if ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'true', 'false', d)} ; then 66*da295319SPatrick Williams install -m 0644 ${WORKDIR}/ip6tables.rules ${D}${IPTABLES_RULES_DIR} 67*da295319SPatrick Williams install -m 0644 ${WORKDIR}/ip6tables.service ${D}${systemd_system_unitdir} 68*da295319SPatrick Williams 69*da295319SPatrick Williams sed -i \ 70*da295319SPatrick Williams -e 's,@SBINDIR@,${sbindir},g' \ 71*da295319SPatrick Williams -e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \ 72*da295319SPatrick Williams ${D}${systemd_system_unitdir}/ip6tables.service 73*da295319SPatrick Williams fi 74*da295319SPatrick Williams 75*da295319SPatrick Williams # if libnftnl is included, make the iptables symlink point to the nft-based binary by default 76*da295319SPatrick Williams if ${@bb.utils.contains('PACKAGECONFIG', 'libnftnl', 'true', 'false', d)} ; then 77*da295319SPatrick Williams ln -sf ${sbindir}/xtables-nft-multi ${D}${sbindir}/iptables 78*da295319SPatrick Williams fi 79*da295319SPatrick Williams} 80*da295319SPatrick Williams 81*da295319SPatrick WilliamsPACKAGES =+ "${PN}-modules ${PN}-apply" 82*da295319SPatrick WilliamsPACKAGES_DYNAMIC += "^${PN}-module-.*" 83*da295319SPatrick Williams 84*da295319SPatrick Williamspython populate_packages:prepend() { 85*da295319SPatrick Williams modules = do_split_packages(d, '${libdir}/xtables', r'lib(.*)\.so$', '${PN}-module-%s', '${PN} module %s', extra_depends='') 86*da295319SPatrick Williams if modules: 87*da295319SPatrick Williams metapkg = d.getVar('PN') + '-modules' 88*da295319SPatrick Williams d.appendVar('RDEPENDS:' + metapkg, ' ' + ' '.join(modules)) 89*da295319SPatrick Williams} 90*da295319SPatrick Williams 91*da295319SPatrick WilliamsRDEPENDS:${PN} = "${PN}-module-xt-standard" 92*da295319SPatrick WilliamsRRECOMMENDS:${PN} = " \ 93*da295319SPatrick Williams ${PN}-modules \ 94*da295319SPatrick Williams kernel-module-x-tables \ 95*da295319SPatrick Williams kernel-module-ip-tables \ 96*da295319SPatrick Williams kernel-module-iptable-filter \ 97*da295319SPatrick Williams kernel-module-iptable-nat \ 98*da295319SPatrick Williams kernel-module-nf-defrag-ipv4 \ 99*da295319SPatrick Williams kernel-module-nf-conntrack \ 100*da295319SPatrick Williams kernel-module-nf-conntrack-ipv4 \ 101*da295319SPatrick Williams kernel-module-nf-nat \ 102*da295319SPatrick Williams kernel-module-ipt-masquerade \ 103*da295319SPatrick Williams ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', '\ 104*da295319SPatrick Williams kernel-module-ip6table-filter \ 105*da295319SPatrick Williams kernel-module-ip6-tables \ 106*da295319SPatrick Williams ', '', d)} \ 107*da295319SPatrick Williams" 108*da295319SPatrick Williams 109*da295319SPatrick WilliamsFILES:${PN} += "${datadir}/xtables" 110*da295319SPatrick Williams 111*da295319SPatrick WilliamsFILES:${PN}-apply = "${sbindir}/ip*-apply" 112*da295319SPatrick WilliamsRDEPENDS:${PN}-apply = "${PN} bash" 113*da295319SPatrick Williams 114*da295319SPatrick Williams# Include the symlinks as well in respective packages 115*da295319SPatrick WilliamsFILES:${PN}-module-xt-conntrack += "${libdir}/xtables/libxt_state.so" 116*da295319SPatrick WilliamsFILES:${PN}-module-xt-ct += "${libdir}/xtables/libxt_NOTRACK.so ${libdir}/xtables/libxt_REDIRECT.so" 117*da295319SPatrick WilliamsFILES:${PN}-module-xt-nat += "${libdir}/xtables/libxt_SNAT.so ${libdir}/xtables/libxt_DNAT.so ${libdir}/xtables/libxt_MASQUERADE.so" 118*da295319SPatrick Williams 119*da295319SPatrick WilliamsALLOW_EMPTY:${PN}-modules = "1" 120*da295319SPatrick Williams 121*da295319SPatrick WilliamsINSANE_SKIP:${PN}-module-xt-conntrack = "dev-so" 122*da295319SPatrick WilliamsINSANE_SKIP:${PN}-module-xt-ct = "dev-so" 123*da295319SPatrick WilliamsINSANE_SKIP:${PN}-module-xt-nat = "dev-so" 124