Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / net / netfilter / xt_osf.c
CommitLineData
11eeef41
EP
1/*
2 * Copyright (c) 2003+ Evgeniy Polyakov <zbr@ioremap.net>
3 *
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
e664eabd 16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
11eeef41 17 */
8bee4bad 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11eeef41
EP
19#include <linux/module.h>
20#include <linux/kernel.h>
21
916a2790 22#include <linux/capability.h>
11eeef41
EP
23#include <linux/if.h>
24#include <linux/inetdevice.h>
25#include <linux/ip.h>
26#include <linux/list.h>
27#include <linux/rculist.h>
28#include <linux/skbuff.h>
29#include <linux/slab.h>
30#include <linux/tcp.h>
31
32#include <net/ip.h>
33#include <net/tcp.h>
34
35#include <linux/netfilter/nfnetlink.h>
36#include <linux/netfilter/x_tables.h>
37#include <net/netfilter/nf_log.h>
38#include <linux/netfilter/xt_osf.h>
39
4b560b44 40static bool
62fc8051 41xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
11eeef41 42{
bfb15f2a 43 return nf_osf_match(skb, xt_family(p), xt_hooknum(p), xt_in(p),
e891e50a 44 xt_out(p), p->matchinfo, xt_net(p), nf_osf_fingers);
11eeef41
EP
45}
46
47static struct xt_match xt_osf_match = {
48 .name = "osf",
49 .revision = 0,
50 .family = NFPROTO_IPV4,
51 .proto = IPPROTO_TCP,
52 .hooks = (1 << NF_INET_LOCAL_IN) |
53 (1 << NF_INET_PRE_ROUTING) |
54 (1 << NF_INET_FORWARD),
55 .match = xt_osf_match_packet,
56 .matchsize = sizeof(struct xt_osf_info),
57 .me = THIS_MODULE,
58};
59
60static int __init xt_osf_init(void)
61{
f9324952 62 int err;
11eeef41
EP
63
64 err = xt_register_match(&xt_osf_match);
65 if (err) {
8bee4bad
JE
66 pr_err("Failed to register OS fingerprint "
67 "matching module (%d)\n", err);
f9324952 68 return err;
11eeef41
EP
69 }
70
71 return 0;
11eeef41
EP
72}
73
74static void __exit xt_osf_fini(void)
75{
11eeef41 76 xt_unregister_match(&xt_osf_match);
11eeef41
EP
77}
78
79module_init(xt_osf_init);
80module_exit(xt_osf_fini);
81
82MODULE_LICENSE("GPL");
83MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
84MODULE_DESCRIPTION("Passive OS fingerprint matching.");
b8ddd9ea
KT
85MODULE_ALIAS("ipt_osf");
86MODULE_ALIAS("ip6t_osf");
11eeef41 87MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_OSF);