]>
Commit | Line | Data |
---|---|---|
1ccea77e | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
11eeef41 EP |
2 | /* |
3 | * Copyright (c) 2003+ Evgeniy Polyakov <zbr@ioremap.net> | |
11eeef41 | 4 | */ |
8bee4bad | 5 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
11eeef41 EP |
6 | #include <linux/module.h> |
7 | #include <linux/kernel.h> | |
8 | ||
916a2790 | 9 | #include <linux/capability.h> |
11eeef41 EP |
10 | #include <linux/if.h> |
11 | #include <linux/inetdevice.h> | |
12 | #include <linux/ip.h> | |
13 | #include <linux/list.h> | |
14 | #include <linux/rculist.h> | |
15 | #include <linux/skbuff.h> | |
16 | #include <linux/slab.h> | |
17 | #include <linux/tcp.h> | |
18 | ||
19 | #include <net/ip.h> | |
20 | #include <net/tcp.h> | |
21 | ||
22 | #include <linux/netfilter/nfnetlink.h> | |
23 | #include <linux/netfilter/x_tables.h> | |
24 | #include <net/netfilter/nf_log.h> | |
25 | #include <linux/netfilter/xt_osf.h> | |
26 | ||
4b560b44 | 27 | static bool |
62fc8051 | 28 | xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p) |
11eeef41 | 29 | { |
bfb15f2a | 30 | return nf_osf_match(skb, xt_family(p), xt_hooknum(p), xt_in(p), |
e891e50a | 31 | xt_out(p), p->matchinfo, xt_net(p), nf_osf_fingers); |
11eeef41 EP |
32 | } |
33 | ||
34 | static struct xt_match xt_osf_match = { | |
35 | .name = "osf", | |
36 | .revision = 0, | |
37 | .family = NFPROTO_IPV4, | |
38 | .proto = IPPROTO_TCP, | |
39 | .hooks = (1 << NF_INET_LOCAL_IN) | | |
40 | (1 << NF_INET_PRE_ROUTING) | | |
41 | (1 << NF_INET_FORWARD), | |
42 | .match = xt_osf_match_packet, | |
43 | .matchsize = sizeof(struct xt_osf_info), | |
44 | .me = THIS_MODULE, | |
45 | }; | |
46 | ||
47 | static int __init xt_osf_init(void) | |
48 | { | |
f9324952 | 49 | int err; |
11eeef41 EP |
50 | |
51 | err = xt_register_match(&xt_osf_match); | |
52 | if (err) { | |
8bee4bad JE |
53 | pr_err("Failed to register OS fingerprint " |
54 | "matching module (%d)\n", err); | |
f9324952 | 55 | return err; |
11eeef41 EP |
56 | } |
57 | ||
58 | return 0; | |
11eeef41 EP |
59 | } |
60 | ||
61 | static void __exit xt_osf_fini(void) | |
62 | { | |
11eeef41 | 63 | xt_unregister_match(&xt_osf_match); |
11eeef41 EP |
64 | } |
65 | ||
66 | module_init(xt_osf_init); | |
67 | module_exit(xt_osf_fini); | |
68 | ||
69 | MODULE_LICENSE("GPL"); | |
70 | MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>"); | |
71 | MODULE_DESCRIPTION("Passive OS fingerprint matching."); | |
b8ddd9ea KT |
72 | MODULE_ALIAS("ipt_osf"); |
73 | MODULE_ALIAS("ip6t_osf"); |