亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 1289 | 回復(fù): 0
打印 上一主題 下一主題

[C] netfilter模塊編譯出錯(cuò) [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2015-07-29 17:14 |只看該作者 |倒序?yàn)g覽
本帖最后由 shuimuyq 于 2015-07-29 17:16 編輯

源碼如下:
/* Sample code to install a Netfilter hook function that will
* drop all incoming packets. */

#define __KERNEL__
#define MODULE

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>

/* This is the structure we shall use to register our function */
static struct nf_hook_ops nfho;

/* This is the hook function itself */
unsigned int hook_func(unsigned int hooknum,
                       struct sk_buff **skb,
                       const struct net_device *in,
                       const struct net_device *out,
                       int (*okfn)(struct sk_buff *))
{
    return NF_DROP;           /* Drop ALL packets */
}

/* Initialisation routine */
int init_module()
{
    /* Fill in our hook structure */
    nfho.hook = hook_func;         /* Handler function */
    nfho.hooknum  = NF_IP_PRE_ROUTING; /* First hook for IPv4 */
    nfho.pf       = PF_INET;
    nfho.priority = NF_IP_PRI_FIRST;   /* Make our function first */

    nf_register_hook(&nfho);
   
    return 0;
}
       
/* Cleanup routine */
void cleanup_module()
{
    nf_unregister_hook(&nfho);
}




makefile如下:
obj-m += dropall.o

all: $(obj-m)
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean




編譯錯(cuò)誤信息如下:
cc    -c -o dropall.o dropall.c
dropall.c:7:26: error: linux/module.h: No such file or directory
In file included from dropall.c:9:
/usr/include/linux/netfilter.h:64: error: field ‘in’ has incomplete type
/usr/include/linux/netfilter.h:65: error: field ‘in6’ has incomplete type
In file included from dropall.c:10:
/usr/include/linux/netfilter_ipv4.h:53: error: ‘INT_MIN’ undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:64: error: ‘INT_MAX’ undeclared here (not in a function)
dropall.c:20: warning: ‘struct net_device’ declared inside parameter list
dropall.c:20: warning: its scope is only this definition or declaration, which is probably not what you want
dropall.c:20: warning: ‘struct sk_buff’ declared inside parameter list
dropall.c: In function ‘init_module’:
dropall.c:29: error: invalid use of undefined type ‘struct nf_hook_ops’
dropall.c:30: error: invalid use of undefined type ‘struct nf_hook_ops’
dropall.c:31: error: invalid use of undefined type ‘struct nf_hook_ops’
dropall.c:31: error: ‘PF_INET’ undeclared (first use in this function)
dropall.c:31: error: (Each undeclared identifier is reported only once
dropall.c:31: error: for each function it appears in.)
dropall.c:32: error: invalid use of undefined type ‘struct nf_hook_ops’
make: *** [dropall.o] Error 1



不了解模塊編譯要怎么處理,求幫助!
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP