免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1193 | 回复: 0
打印 上一主题 下一主题

快:请教编译问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-05-28 16:40 |只看该作者 |倒序浏览
谢谢, 请问能快点告诉我吗?email:qiaoling0826.student@sina.com
qq:83827109
原程序如下:
/*#ifdef __KERNEL__
#define __KERNEL__

#endif

#ifdef MODULE

#define MODULE

#endif*/

#include<linux/module.h>;

#include<linux/netfilter.h>;

#include<linux/list.h>;

#include<linux/netfilter_ipv4/ip_tables.h>;

/*#include<linux/icmp.h>;*/

#include<linux/ip.h>;

/*#include<linux/tcp.h>;*/

/*#include<linux/udp.h>;*/

#include<linux/netdevice.h>;

/*#include<linux/config.h>;*/

#include<linux/net.h>;

#include<linux/skbuff.h>;

#include<linux/netfilter_ipv4.h>;

static unsigned int input(unsigned int hooknum,struct sk_buff **skb,
  

   const struct net_device *in,const struct packet_type *pt,
      

int(*okfn)(struct sk_buff *))
{

       struct iphdr *iph;
      
       struct tcphdr *tcph;

       struct udphdr *udph;


      
       /*get zhe packet head*/


       iph=(*skb)->;nh.iph;
      
               

if((*skb)->;pkt_type==PACKET_OTHERHOST)
        
         {

             printk("otherhost packet drop\n";

             return NF_DROP;

            }

       if((*skb)->;len<sizeof(struct ihdr)||(*skb)->;len<(iph->;ihl<<2))


          {

             printk("check packet length failed\n";
                 

         return NF_DROP;

            }

                  

if(iph->;ihl<5||iph->;version!=4||ip_fast_csum((u8*)iph,iph->;ihl)!=0)

            {

             printk("check zhe head ,version and csum failed\n";
   

             return NF_DROP;

             }   


   
          /*unsigned int proto=iph->;protocol;*/
                 

if(iph->;protocol==1||iph->;protocol==6||iph->;protocol==17)
              {
         
                printk("tcp or udp or icmp packet was allowed\n";


              
          /* Reassemble IP fragment*/
               

           if(iph->;frag_off&htons(IP_MF|IP_OFFSET))
                  

              skb=ip_defrag(skb);            
         
           

               return NF_ACCEPT;
          }
     
        else{

            printk("others are not allowed\n";

            return NF_DROP;
           }

}



static unsigned int forward(unsigned int hooknum,struct sk_buff **skb,


     const struct net_device *in,const struct net_device *out,
      

int(*okfn)(struct sk_buff*))

{

      printk("forward is called\n";

      return NF_ACCEPT;

}



static unsigned int output(unsigned int hooknum,struct sk_buff **skb,


    const struct net_device *out,int (*okfn)(struct sk_buff *))

{

    struct rtable *rt;

    struct iphdr *iph;

    unsigned short mtu;
  

    iph=(*skb)->;nh.iph;

    rt=(struct rtable *)skb->;dst;

    mtu=rt->;u.dest.pmtu;


    /*wether fragment*/

    if((*skb)->;len>;mtu)

       ip_fragment(skb,ip_finish_output);

      
     return ip_finish_output(skb);

  }           




static struct nf_hook_ops ipt_ops[]=

{

  {

      {NULL,NULL},

       input,

       PF_INET,

       NF_IP_LOCAL_IN,

       NF_IP_PRI_FILTER

  },

  {

      {NULL,NULL},

       forward,

       PF_INET,

       NF_IP_FORWARD,
       NF_IP_PRI_FILTER
  },

  {

      {NULL,NULL},

       output,

       PF_INET,

       NF_IP_LOCAL_OUT,

       NF_IP_PRI_FILTER

    }

};


int init_module(void)

{

  return nf_register_hook(&ipt_ops);

}


void cleanup_module(void)

{

  nf_unregister_hook(&ipt_ops);

}
该程序在/opt/hardhat/devkit/ppc/8xx/bin,名为sfw.c
使用ppc_8xx-gcc -D__KERNEL__ -DMODULE -c sfw.c编译,结果为:
In file included from /opt/hardhat/devkit/ppc/8xx/bin/../target
                     /usr/include/asm/processor.h:18,
                from /opt/hardhat/devkit/ppc/8xx/bin/../target
                     /usr/include/linux/prefetch.h:13
                from /opt/hardhat/devkit/ppc/8xx/bin/../target
                     /usr/include/linux/list.h:6
                from /opt/hardhat/devkit/ppc/8xx/bin/../target
                     /usr/include/linux/module.h:12
                from sfw.c
/opt/hardhat/devkit/ppc/8xx/bin/../target
                     /usr/include/asm/mpc8xx.h:28:/platforms/rpxlite.h:No such file or directory
后来以为是路径问题
就改用ppc_8xx-gcc -D_KERNEL__-DMODULE -I/opt/hardhat/devkit/ppc/8xx/target/usr/include -c sfw.c
结果一样
请问到底是怎么回事
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP