12e4e6a17SHarald Welte /* 22e4e6a17SHarald Welte * Implements a dummy match to allow attaching comments to rules 32e4e6a17SHarald Welte * 42e4e6a17SHarald Welte * 2003-05-13 Brad Fisher (brad@info-link.net) 52e4e6a17SHarald Welte */ 62e4e6a17SHarald Welte 72e4e6a17SHarald Welte #include <linux/module.h> 82e4e6a17SHarald Welte #include <linux/skbuff.h> 92e4e6a17SHarald Welte #include <linux/netfilter/x_tables.h> 102e4e6a17SHarald Welte #include <linux/netfilter/xt_comment.h> 112e4e6a17SHarald Welte 122e4e6a17SHarald Welte MODULE_AUTHOR("Brad Fisher <brad@info-link.net>"); 132e4e6a17SHarald Welte MODULE_DESCRIPTION("iptables comment match module"); 142e4e6a17SHarald Welte MODULE_LICENSE("GPL"); 152e4e6a17SHarald Welte MODULE_ALIAS("ipt_comment"); 162e4e6a17SHarald Welte MODULE_ALIAS("ip6t_comment"); 172e4e6a17SHarald Welte 182e4e6a17SHarald Welte static int 192e4e6a17SHarald Welte match(const struct sk_buff *skb, 202e4e6a17SHarald Welte const struct net_device *in, 212e4e6a17SHarald Welte const struct net_device *out, 222e4e6a17SHarald Welte const void *matchinfo, 232e4e6a17SHarald Welte int offset, 242e4e6a17SHarald Welte unsigned int protooff, 252e4e6a17SHarald Welte int *hotdrop) 262e4e6a17SHarald Welte { 272e4e6a17SHarald Welte /* We always match */ 282e4e6a17SHarald Welte return 1; 292e4e6a17SHarald Welte } 302e4e6a17SHarald Welte 312e4e6a17SHarald Welte static int 322e4e6a17SHarald Welte checkentry(const char *tablename, 332e4e6a17SHarald Welte const void *ip, 342e4e6a17SHarald Welte void *matchinfo, 352e4e6a17SHarald Welte unsigned int matchsize, 362e4e6a17SHarald Welte unsigned int hook_mask) 372e4e6a17SHarald Welte { 382e4e6a17SHarald Welte /* Check the size */ 392e4e6a17SHarald Welte if (matchsize != XT_ALIGN(sizeof(struct xt_comment_info))) 402e4e6a17SHarald Welte return 0; 412e4e6a17SHarald Welte return 1; 422e4e6a17SHarald Welte } 432e4e6a17SHarald Welte 442e4e6a17SHarald Welte static struct xt_match comment_match = { 452e4e6a17SHarald Welte .name = "comment", 462e4e6a17SHarald Welte .match = match, 472e4e6a17SHarald Welte .checkentry = checkentry, 482e4e6a17SHarald Welte .me = THIS_MODULE 492e4e6a17SHarald Welte }; 502e4e6a17SHarald Welte 512e4e6a17SHarald Welte static struct xt_match comment6_match = { 522e4e6a17SHarald Welte .name = "comment", 532e4e6a17SHarald Welte .match = match, 542e4e6a17SHarald Welte .checkentry = checkentry, 552e4e6a17SHarald Welte .me = THIS_MODULE 562e4e6a17SHarald Welte }; 572e4e6a17SHarald Welte 582e4e6a17SHarald Welte static int __init init(void) 592e4e6a17SHarald Welte { 602e4e6a17SHarald Welte int ret; 612e4e6a17SHarald Welte 622e4e6a17SHarald Welte ret = xt_register_match(AF_INET, &comment_match); 632e4e6a17SHarald Welte if (ret) 642e4e6a17SHarald Welte return ret; 652e4e6a17SHarald Welte 662e4e6a17SHarald Welte ret = xt_register_match(AF_INET6, &comment6_match); 672e4e6a17SHarald Welte if (ret) 682e4e6a17SHarald Welte xt_unregister_match(AF_INET, &comment_match); 692e4e6a17SHarald Welte 702e4e6a17SHarald Welte return ret; 712e4e6a17SHarald Welte } 722e4e6a17SHarald Welte 732e4e6a17SHarald Welte static void __exit fini(void) 742e4e6a17SHarald Welte { 752e4e6a17SHarald Welte xt_unregister_match(AF_INET, &comment_match); 762e4e6a17SHarald Welte xt_unregister_match(AF_INET6, &comment6_match); 772e4e6a17SHarald Welte } 782e4e6a17SHarald Welte 792e4e6a17SHarald Welte module_init(init); 802e4e6a17SHarald Welte module_exit(fini); 81