编译netfilter遇到的问题。。十万火急!1

内核编译和嵌入式产品的设计与开发
回复
gaochang
帖子: 19
注册时间: 2007-11-04 22:56

编译netfilter遇到的问题。。十万火急!1

#1

帖子 gaochang » 2007-12-14 10:23

模块文件


#define __KERNEL__
#define MODULE

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include </usr/src/linux-headers-2.6.22-14-generic>

/* 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);
}






MAKE 文件


# Makefile2.6
ifneq ($(KERNELRELEASE),)
#kbuild syntax. dependency relationshsip of files and target modules are listed here.
mymodule-objs := net.o
obj-m := net.o
else
PWD := $(shell pwd)
KVER ?= $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD)
clean:
rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions
endif



编译结果:
make -C /lib/modules/2.6.22-14-generic/build M=/media/DATA__/test-netfilter/code filter3/test
make[1]: Entering directory `/usr/src/linux-headers-2.6.22-14-generic'
make[1]: *** No rule to make target `filter3/test'. Stop.
make[1]: Leaving directory `/usr/src/linux-headers-2.6.22-14-generic'
make: *** [all] Error 2


什么问题呀? 怎样解决呀 ????
fifywang
帖子: 2
注册时间: 2009-05-07 12:58

Re: 编译netfilter遇到的问题。。十万火急!1

#2

帖子 fifywang » 2009-08-18 20:41

你可以尝试在makefile文件的这些行之前加入一个tab键:$(MAKE) -C $(KDIR) M=$(PWD)
回复