/usr/src/xtables-addons-2.12/extensions/xt_ipv4options.c is in xtables-addons-dkms 2.12-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /*
* xt_ipv4opts - Xtables module to match IPv4 options
* Copyright © Jan Engelhardt, 2009
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License; either
* version 2 of the License, or any later version, as published by the
* Free Software Foundation.
*/
#include <linux/ip.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/netfilter/x_tables.h>
#include <net/ip.h>
#include "xt_ipv4options.h"
#include "compat_xtables.h"
static uint32_t ipv4options_rd(const uint8_t *data, int len)
{
uint32_t opts = 0;
while (len >= 2) {
switch (data[0]) {
case IPOPT_END:
return opts;
case IPOPT_NOOP:
--len;
++data;
continue;
}
if (data[1] < 2 || data[1] > len)
return opts;
opts |= 1 << (data[0] & 0x1F);
len -= data[1];
data += data[1];
}
return opts;
}
static bool ipv4options_mt(const struct sk_buff *skb,
struct xt_action_param *par)
{
const struct xt_ipv4options_mtinfo1 *info = par->matchinfo;
const struct iphdr *iph = ip_hdr(skb);
uint32_t opts = 0;
uint16_t len = ip_hdrlen(skb) - sizeof(struct iphdr);
if (len > 0)
opts = ipv4options_rd((const void *)iph +
sizeof(struct iphdr), len);
opts ^= info->invert;
opts &= info->map;
return (info->flags & XT_V4OPTS_ANY) ? opts : opts == info->map;
}
static struct xt_match ipv4options_mt_reg __read_mostly = {
.name = "ipv4options",
.revision = 1,
.family = NFPROTO_IPV4,
.match = ipv4options_mt,
.matchsize = sizeof(struct xt_ipv4options_mtinfo1),
.me = THIS_MODULE,
};
static int __init ipv4options_mt_init(void)
{
return xt_register_match(&ipv4options_mt_reg);
}
static void __exit ipv4options_mt_exit(void)
{
xt_unregister_match(&ipv4options_mt_reg);
}
MODULE_DESCRIPTION("Xatblse: IPv4 option match");
MODULE_AUTHOR("Jan Engelhardt ");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_ipv4options");
module_init(ipv4options_mt_init);
module_exit(ipv4options_mt_exit);
|