/*************************************************************************** * Copyright (C) 2007 by Intra2net AG * * opensource@intra2net.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License * * version 2 as published by the Free Software Foundation; * * * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Spinlock used during memory allocation */ static DEFINE_SPINLOCK(ipt_crash_lock); static unsigned int ipt_crash_target(struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, unsigned int hooknum, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) const struct xt_target *target, #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) const void *targinfo) #else const void *targinfo, void *userinfo) #endif { char *data; spin_lock_bh(&ipt_crash_lock); if ((data = (char *)get_zeroed_page(GFP_ATOMIC)) == NULL) { printk("ipt_CRASH: Out of memory!\n"); } else { // Fill memory with pattern int i, j = 123; for (i = 0; i < PAGE_SIZE; i++) { data[i] = j; j++; } free_page((unsigned long)data); } spin_unlock_bh(&ipt_crash_lock); return IPT_CONTINUE; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) static struct xt_target xt_crash_reg = { #else static struct ipt_target ipt_crash_reg = { #endif .name = "CRASH", #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) .family = AF_INET, #endif .target = ipt_crash_target, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) .targetsize = sizeof(struct ipt_crash_info), #endif .me = THIS_MODULE }; static int __init init(void) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) if (xt_register_target(&xt_crash_reg)) #else if (ipt_register_target(&ipt_crash_reg)) #endif return -EINVAL; return 0; } static void __exit fini(void) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) xt_unregister_target(&xt_crash_reg); #else ipt_unregister_target(&ipt_crash_reg); #endif } module_init(init); module_exit(fini); MODULE_LICENSE("GPL");