LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 541|回复: 3

弱弱的问个语法问题

[复制链接]
发表于 2005-4-12 21:38:12 | 显示全部楼层 |阅读模式
[php]
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 *)){
  struct sk_buff *sb = *skb;
  if( sb->h.th->syn) //这行有错么
    printk("SYN\n");
  return NF_ACCEPT;
}
[/php]
我的编译结果:
[root@localhost syncookie]# make
gcc -c -I/usr/src/linux2.4/include syncookieproxy.c -o testsyn.o
syncookieproxy.c: In function `hook_func':
syncookieproxy.c:18: dereferencing pointer to incomplete type
make: *** [testsyn.o] Error 1
[root@localhost syncookie]#
发表于 2005-4-12 22:34:27 | 显示全部楼层
把代码都贴上来。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-12 22:41:55 | 显示全部楼层
[php]
#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
static struct nf_hook_ops nfho;
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 *)){
  struct sk_buff *sb = *skb;
  if( sb->h.th->syn)
    printk("SYN\n");
  return NF_ACCEPT;
}

int init_module(){

  nfho.hook = hook_func;

  nfho.hooknum  = NF_IP_PRE_ROUTING;

  nfho.pf       = PF_INET;

  nfho.priority = NF_IP_PRI_FIRST;


  nf_register_hook(&nfho);


  return 0;

}

void cleanup_module()

{

  nf_unregister_hook(&nfho);

}
/* makefile
testsyn.o:syncookieproxy.c
        gcc -c -I/usr/src/linux2.4/include syncookieproxy.c -o testsyn.o

*/
[/php]
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-13 09:45:09 | 显示全部楼层
ft!!
少加了个头文件<linux/tcp.h>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表