aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/iptables/patches/500-add-xt_id-match.patch
blob: 94762f0ab7ab7e2a12241012b2eb31123ffbf1d4 (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
--- /dev/null
+++ b/extensions/libxt_id.c
@@ -0,0 +1,45 @@
+/* Shared library add-on to iptables to add id match support. */
+
+#include <stdio.h>
+#include <xtables.h>
+#include <linux/netfilter/xt_id.h>
+
+enum {
+	O_ID = 0,
+};
+
+static const struct xt_option_entry id_opts[] = {
+	{
+		.name  = "id",
+		.id    = O_ID,
+		.type  = XTTYPE_UINT32,
+		.flags = XTOPT_MAND | XTOPT_PUT,
+		XTOPT_POINTER(struct xt_id_info, id)
+	},
+	XTOPT_TABLEEND,
+};
+
+/* Saves the union ipt_matchinfo in parsable form to stdout. */
+static void
+id_save(const void *ip, const struct xt_entry_match *match)
+{
+	struct xt_id_info *idinfo = (void *)match->data;
+
+	printf(" --id %lu", idinfo->id);
+}
+
+static struct xtables_match id_match = {
+	.family		= NFPROTO_UNSPEC,
+	.name		= "id",
+	.version	= XTABLES_VERSION,
+	.size		= XT_ALIGN(sizeof(struct xt_id_info)),
+	.userspacesize	= XT_ALIGN(sizeof(struct xt_id_info)),
+	.save 		= id_save,
+	.x6_parse	= xtables_option_parse,
+	.x6_options	= id_opts,
+};
+
+void _init(void)
+{
+	xtables_register_match(&id_match);
+}
--- /dev/null
+++ b/include/linux/netfilter/xt_id.h
@@ -0,0 +1,8 @@
+#ifndef _XT_ID_H
+#define _XT_ID_H
+
+struct xt_id_info {
+	__u32 id;
+};
+
+#endif /* XT_ID_H */