Fixed x86 GRUB config label
[librecmc/librecmc.git] / package / network / utils / iptables / patches / 500-add-xt_id-match.patch
1 --- /dev/null
2 +++ b/extensions/libxt_id.c
3 @@ -0,0 +1,55 @@
4 +/* Shared library add-on to iptables to add id match support. */
5 +
6 +#include <stdio.h>
7 +#include <xtables.h>
8 +#include <linux/netfilter/xt_id.h>
9 +
10 +enum {
11 +       O_ID = 0,
12 +};
13 +
14 +static const struct xt_option_entry id_opts[] = {
15 +       {
16 +               .name  = "id",
17 +               .id    = O_ID,
18 +               .type  = XTTYPE_UINT32,
19 +               .flags = XTOPT_MAND | XTOPT_PUT,
20 +               XTOPT_POINTER(struct xt_id_info, id)
21 +       },
22 +       XTOPT_TABLEEND,
23 +};
24 +
25 +static void
26 +id_print(const void *ip, const struct xt_entry_match *match, int numeric)
27 +{
28 +       struct xt_id_info *idinfo = (void *)match->data;
29 +
30 +       printf(" ID:%08lx", idinfo->id);
31 +}
32 +
33 +
34 +/* Saves the union ipt_matchinfo in parsable form to stdout. */
35 +static void
36 +id_save(const void *ip, const struct xt_entry_match *match)
37 +{
38 +       struct xt_id_info *idinfo = (void *)match->data;
39 +
40 +       printf(" --id 0x%lx", idinfo->id);
41 +}
42 +
43 +static struct xtables_match id_match = {
44 +       .family         = NFPROTO_UNSPEC,
45 +       .name           = "id",
46 +       .version        = XTABLES_VERSION,
47 +       .size           = XT_ALIGN(sizeof(struct xt_id_info)),
48 +       .userspacesize  = XT_ALIGN(sizeof(struct xt_id_info)),
49 +       .print          = id_print,
50 +       .save           = id_save,
51 +       .x6_parse       = xtables_option_parse,
52 +       .x6_options     = id_opts,
53 +};
54 +
55 +void _init(void)
56 +{
57 +       xtables_register_match(&id_match);
58 +}
59 --- /dev/null
60 +++ b/include/linux/netfilter/xt_id.h
61 @@ -0,0 +1,8 @@
62 +#ifndef _XT_ID_H
63 +#define _XT_ID_H
64 +
65 +struct xt_id_info {
66 +       __u32 id;
67 +};
68 +
69 +#endif /* XT_ID_H */