URN Logo
UNIX Resources » Linux » China Linux Forum » C/C++编程版 » 33 » netfilter编程产生的奇怪问题,请各位帮助,急啊!
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
netfilter编程产生的奇怪问题,请各位帮助,急啊!
 
 
Subject: netfilter编程产生的奇怪问题,请各位帮助,急啊!
Author: goodness4960    Posted: 2005-05-22 17:27    Length: 2,458 byte(s)
[Original] [Print] [Top]

程序及编译错误如下:
#define _KERNEL_
#define MODULE
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/netdevice.h>
#include<linux/netfilter.h>
#include<linux/netfilter_ipv4.h>
static struct nf_hook_ops nfho;
static unsigned int
my_hook(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;
}
int init_module(void)
{
nfho.hook=my_hook;
nfho.hooknum=NF_IP_PRE_ROUTING;
nfho.pf= PF_INET;
nfho.priority=NF_IP_PRI_FIRST;
return nf_register_hook(&nfho);
return 0;

}
void cleanup_module(void)
{
nf_unregister_hook(&nfho);

}
对于以上程序我在redhat 9.0 (linux-2.4.20-8)下通过如下方式编译,但是产生了如下错误,困扰了我很多天,您能告诉我产生错误的原因以及解决的方法吗?
gcc -O -c -I/usr/src/linux-2.4/include test1.c
In file included from test1.c:10:
/usr/include/linux/netfilter_ipv4.h:53: `INT_MIN' undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:53: enumerator value for `NF_IP_PRI_FIRST' not integer constant
/usr/include/linux/netfilter_ipv4.h:59: `INT_MAX' undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:59: enumerator value for `NF_IP_PRI_LAST' not integer constant
test1.c:21: warning: `struct net_device' declared inside parameter list
test1.c:21: warning: its scope is only this definition or declaration, which is probably not what you want
test1.c:21: warning: `struct sk_buff' declared inside parameter list
test1.c: In function `init_module':
test1.c:37: invalid use of undefined type `struct nf_hook_ops'
test1.c:38: invalid use of undefined type `struct nf_hook_ops'
test1.c:39: invalid use of undefined type `struct nf_hook_ops'
test1.c:40: invalid use of undefined type `struct nf_hook_ops'
/usr/include/linux/byteorder/swab.h: At top level:
test1.c:14: storage size of `nfho' isn't known
[Original] [Print] [Top]
Subject: Re: (版主请帮忙看看啊)netfilter编程产生的奇怪问题,请各位帮助,急啊!
Author: goodness4960    Posted: 2005-05-22 17:34    Length: 106 byte(s)
[Original] [Print] [Top]
这会不会和内核配置有关?但是redhat9.0 (linux-2,4.20-8)好像对和nentfilter相关的选项都是默认配置好了的吧?
[Original] [Print] [Top]
« Previous thread
请教:程序运行一次占用8k内存,但没有查到内存泄漏。
C/C++编程版
33
Next thread »
linux linker
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 03:52:56, cost 0.055292129516602 ms.