aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/netfilter.go
blob: f97d92adcb991c7a32c1da38fcb92e18fc04a236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package rosa

import "hakurei.app/internal/pkg"

func (t Toolchain) newLibmnl() (pkg.Artifact, string) {
	const (
		version  = "1.0.5"
		checksum = "DN-vbbvQDpxXJm0TJ6xlluILvfrB86avrCTX50XyE9SEFSAZ_o8nuKc5Gu0Am7-u"
	)
	return t.NewPackage("libmnl", version, pkg.NewHTTPGetTar(
		nil, "https://www.netfilter.org/projects/libmnl/files/"+
			"libmnl-"+version+".tar.bz2",
		mustDecode(checksum),
		pkg.TarBzip2,
	), &PackageAttr{
		Patches: []KV{
			{"libbsd-sys-queue", `diff --git a/examples/netfilter/nfct-daemon.c b/examples/netfilter/nfct-daemon.c
index d223ac2..a7878d0 100644
--- a/examples/netfilter/nfct-daemon.c
+++ b/examples/netfilter/nfct-daemon.c
@@ -20,7 +20,7 @@
 #include <linux/netfilter/nfnetlink.h>
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
-#include <sys/queue.h>
+#include <bsd/sys/queue.h>
 
 struct nstats {
 	LIST_ENTRY(nstats)	list;
`},
		},
	}, &MakeHelper{
		Configure: []KV{
			{"enable-static"},
		},
	},
		Libbsd,
		KernelHeaders,
	), version
}
func init() {
	artifactsM[Libmnl] = Metadata{
		f: Toolchain.newLibmnl,

		Name:        "libmnl",
		Description: "a minimalistic user-space library oriented to Netlink developers",
		Website:     "https://www.netfilter.org/projects/libmnl/",

		ID: 1663,
	}
}

func (t Toolchain) newLibnftnl() (pkg.Artifact, string) {
	const (
		version  = "1.3.1"
		checksum = "A6EFNv2TbOcjcsXX2hQ-pKsF5FvlSh-BNEf9LrgnVH4nDjcv6NbtyHkTriz9kIEu"
	)
	return t.NewPackage("libnftnl", version, pkg.NewHTTPGet(
		nil, "https://www.netfilter.org/projects/libnftnl/files/"+
			"libnftnl-"+version+".tar.xz",
		mustDecode(checksum),
	), &PackageAttr{
		SourceKind: SourceKindTarXZ,

		Env: []string{
			"CFLAGS=-D_GNU_SOURCE",
		},
	}, &MakeHelper{
		Configure: []KV{
			{"enable-static"},
		},
	},
		XZ,
		PkgConfig,

		Libmnl,
		KernelHeaders,
	), version
}
func init() {
	artifactsM[Libnftnl] = Metadata{
		f: Toolchain.newLibnftnl,

		Name:        "libnftnl",
		Description: "a userspace library providing a low-level netlink API to the in-kernel nf_tables subsystem",
		Website:     "https://www.netfilter.org/projects/libnftnl/",

		Dependencies: P{
			Libmnl,
		},

		ID: 1681,
	}
}

func (t Toolchain) newIPTables() (pkg.Artifact, string) {
	const (
		version  = "1.8.13"
		checksum = "JsNI7dyZHnHLtDkKWAxzAIMZ5t-ff3LkSPqNJsn5VM5Eq2m1bA5NKI-XfMRpQsg6"
	)
	return t.NewPackage("iptables", version, pkg.NewHTTPGet(
		nil, "https://www.netfilter.org/projects/iptables/files/"+
			"iptables-"+version+".tar.xz",
		mustDecode(checksum),
	), &PackageAttr{
		SourceKind: SourceKindTarXZ,

		ScriptEarly: `
rm \
	extensions/libxt_connlabel.txlate \
	extensions/libxt_conntrack.txlate
sed -i \
	's/de:ad:0:be:ee:ff/DE:AD:00:BE:EE:FF/g' \
	extensions/libebt_dnat.txlate \
	extensions/libebt_snat.txlate
`,
	}, &MakeHelper{
		Configure: []KV{
			{"enable-static"},
		},
		ScriptCheckEarly: `
ln -s ../system/bin/bash /bin/
chmod +w /etc/ && ln -s ../usr/src/iptables/etc/ethertypes /etc/
		`,
	},
		XZ,
		PkgConfig,
		Bash,
		Python,

		Libnftnl,
		KernelHeaders,
	), version
}
func init() {
	artifactsM[IPTables] = Metadata{
		f: Toolchain.newIPTables,

		Name:        "iptables",
		Description: "the userspace command line program used to configure the Linux 2.4.x and later packet filtering ruleset",
		Website:     "https://www.netfilter.org/projects/iptables/",

		Dependencies: P{
			Libnftnl,
		},

		ID: 1394,
	}
}