📄 myipmr.c
字号:
static kmem_cache_t *mymrt_cachep __read_mostly;static struct timer_list myipmr_expire_timer;static int myipmr_device_event(struct notifier_block *this, unsigned long event, void *ptr){ return 0;}static struct notifier_block myip_mr_notifier={ .notifier_call = myipmr_device_event,};static void myipmr_expire_process(unsigned long dummy){}int myip_mr_input(struct sk_buff *skb){ return 0;}static int myipmr_vif_open(struct inode *inode, struct file *file){ return 0;}static struct file_operations myipmr_vif_fops = { .owner = THIS_MODULE, .open = myipmr_vif_open, .read = myseq_read, .llseek = myseq_lseek, .release = myseq_release_private,};static int myipmr_mfc_open(struct inode *inode, struct file *file){ return 0;}static struct file_operations myipmr_mfc_fops = { .owner = THIS_MODULE, .open = myipmr_mfc_open, .read = myseq_read, .llseek = myseq_lseek, .release = myseq_release_private,};void __init myip_mr_init(void){ mymrt_cachep = kmem_cache_create("myip_mrt_cache", sizeof(struct mfc_cache), 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if( !mymrt_cachep ) panic( "cannot allocate ip_mrt_cache" ); init_timer( &myipmr_expire_timer ); myipmr_expire_timer.function = myipmr_expire_process; register_netdevice_notifier(&myip_mr_notifier);#ifdef CONFIG_PROC_FS proc_net_fops_create("myip_mr_vif", 0, &myipmr_vif_fops); proc_net_fops_create("myip_mr_cache", 0, &myipmr_mfc_fops);#endif}void __exit myip_mr_exit(void){#ifdef CONFIG_PROC_FS remove_proc_entry( "myip_mr_vif", proc_net ); remove_proc_entry( "myip_mr_cache", proc_net );#endif unregister_netdevice_notifier( &myip_mr_notifier ); if( mymrt_cachep ) kmem_cache_destroy( mymrt_cachep );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -