Blame view
net/netfilter/xt_pkttype.c
1.46 KB
d2912cb15 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
1da177e4c Linux-2.6.12-rc2 |
2 |
/* (C) 1999-2001 Michal Ludvig <michal@logix.cz> |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 7 8 |
*/ #include <linux/module.h> #include <linux/skbuff.h> #include <linux/if_ether.h> #include <linux/if_packet.h> |
28658c896 [NETFILTER]: xt_p... |
9 10 |
#include <linux/in.h> #include <linux/ip.h> |
57de0abbf [NETFILTER]: xt_p... |
11 |
#include <linux/ipv6.h> |
1da177e4c Linux-2.6.12-rc2 |
12 |
|
2e4e6a17a [NETFILTER] x_tab... |
13 14 |
#include <linux/netfilter/xt_pkttype.h> #include <linux/netfilter/x_tables.h> |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 |
MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michal Ludvig <michal@logix.cz>"); |
2ae15b64e [NETFILTER]: Upda... |
18 |
MODULE_DESCRIPTION("Xtables: link layer packet type match"); |
2e4e6a17a [NETFILTER] x_tab... |
19 20 |
MODULE_ALIAS("ipt_pkttype"); MODULE_ALIAS("ip6t_pkttype"); |
1da177e4c Linux-2.6.12-rc2 |
21 |
|
d3c5ee6d5 [NETFILTER]: x_ta... |
22 |
static bool |
62fc80510 netfilter: xtable... |
23 |
pkttype_mt(const struct sk_buff *skb, struct xt_action_param *par) |
1da177e4c Linux-2.6.12-rc2 |
24 |
{ |
f7108a20d netfilter: xtable... |
25 |
const struct xt_pkttype_info *info = par->matchinfo; |
57de0abbf [NETFILTER]: xt_p... |
26 |
u_int8_t type; |
1da177e4c Linux-2.6.12-rc2 |
27 |
|
57de0abbf [NETFILTER]: xt_p... |
28 |
if (skb->pkt_type != PACKET_LOOPBACK) |
28658c896 [NETFILTER]: xt_p... |
29 |
type = skb->pkt_type; |
613dbd957 netfilter: x_tabl... |
30 |
else if (xt_family(par) == NFPROTO_IPV4 && |
57de0abbf [NETFILTER]: xt_p... |
31 32 |
ipv4_is_multicast(ip_hdr(skb)->daddr)) type = PACKET_MULTICAST; |
9a6d87626 netfilter: pkttyp... |
33 |
else if (xt_family(par) == NFPROTO_IPV6) |
57de0abbf [NETFILTER]: xt_p... |
34 35 36 |
type = PACKET_MULTICAST; else type = PACKET_BROADCAST; |
28658c896 [NETFILTER]: xt_p... |
37 38 |
return (type == info->pkttype) ^ info->invert; |
1da177e4c Linux-2.6.12-rc2 |
39 |
} |
92f3b2b1b netfilter: xtable... |
40 41 42 43 44 45 46 |
static struct xt_match pkttype_mt_reg __read_mostly = { .name = "pkttype", .revision = 0, .family = NFPROTO_UNSPEC, .match = pkttype_mt, .matchsize = sizeof(struct xt_pkttype_info), .me = THIS_MODULE, |
2e4e6a17a [NETFILTER] x_tab... |
47 |
}; |
d3c5ee6d5 [NETFILTER]: x_ta... |
48 |
static int __init pkttype_mt_init(void) |
1da177e4c Linux-2.6.12-rc2 |
49 |
{ |
92f3b2b1b netfilter: xtable... |
50 |
return xt_register_match(&pkttype_mt_reg); |
1da177e4c Linux-2.6.12-rc2 |
51 |
} |
d3c5ee6d5 [NETFILTER]: x_ta... |
52 |
static void __exit pkttype_mt_exit(void) |
1da177e4c Linux-2.6.12-rc2 |
53 |
{ |
92f3b2b1b netfilter: xtable... |
54 |
xt_unregister_match(&pkttype_mt_reg); |
1da177e4c Linux-2.6.12-rc2 |
55 |
} |
d3c5ee6d5 [NETFILTER]: x_ta... |
56 57 |
module_init(pkttype_mt_init); module_exit(pkttype_mt_exit); |