module.c

来自「cipe 编程」· C语言 代码 · 共 121 行

C
121
字号
/*   CIPE - encrypted IP over UDP tunneling   module.c - kernel module interface stuff   Copyright 1996 Olaf Titz <olaf@bigred.inka.de>   This program is free software; you can redistribute it and/or   modify it under the terms of the GNU General Public License   as published by the Free Software Foundation; either version   2 of the License, or (at your option) any later version.*//* $Id: module.c,v 1.10 2004/01/04 20:31:44 olaf81825 Exp $ */#include "cipe.h"#include <linux/module.h>#ifdef LINUX_25#include <linux/moduleparam.h>#endif#include <linux/utsname.h>/* We put this all here so that none of the other source files needs   to include <linux/module.h>, which could lead to collisions. */#ifdef NO_DYNDEVint cipe_maxdev = 4;#elseint cipe_maxdev = 100;#endif#ifdef DEBUGint cipe_debug = DEB_CALL;#endif#ifdef LINUX_21MODULE_AUTHOR("Olaf Titz <olaf@bigred.inka.de>");MODULE_DESCRIPTION("Encrypting IP-over-UDP tunnel");#ifdef MODULE_LICENSEMODULE_LICENSE("GPL");#endifMODULE_SUPPORTED_DEVICE(DEVNAME);#ifdef LINUX_25module_param(cipe_maxdev,int,0);#elseMODULE_PARM(cipe_maxdev,"i");#endifMODULE_PARM_DESC(cipe_maxdev,"Maximum device number supported");#ifdef DEBUG#ifdef LINUX_25module_param(cipe_debug,int,0);#elseMODULE_PARM(cipe_debug,"i");#endifMODULE_PARM_DESC(cipe_debug,"Debugging level");#endif#endifint cipe_use_module(void){#ifdef LINUX_25    return try_module_get(THIS_MODULE);#else    MOD_INC_USE_COUNT;    return 1;#endif}void cipe_unuse_module(void){#ifdef LINUX_25    module_put(THIS_MODULE);#else    MOD_DEC_USE_COUNT;#endif}#if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,30)/* older kernel not always exported this */int bad_user_access_length(void){    panic("bad_user_access_length in " DEVNAME);}#endif#ifndef LINUX_25/* HACK: sanity check on SMP/non-SMP.   Is this really necessary? */int cipe_check_kernel(void){    int s=0;    const char *p=system_utsname.version;    while (p[0] && p[1] && p[2]) {	if (p[0]=='S' && p[1]=='M' && p[2]=='P') {	    s=1;	    break;	}	++p;    }    if (#ifdef __SMP__	!#endif         s) {	printk(KERN_ERR	       DEVNAME ": driver ("#ifndef __SMP__	       "not "#endif	       "SMP) "	       "mismatches kernel ("#ifdef __SMP__	       "not "#endif	       "SMP)\n");	return -EINVAL;    }    return 0;}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?