James.Ji
驱动老牛
驱动老牛
  • 注册日期2001-09-17
  • 最后登录2006-05-16
  • 粉丝0
  • 关注0
  • 积分-9分
  • 威望-8点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
阅读:1578回复:2

etherInput的问题。

楼主#
更多 发布于:2003-07-29 09:13
系统:tornado 2.2,vxworks 5。
两个网口,ixe0,ixe1。我想从一个网口接收数据,
然后从令一个网口发送出去,其中用到了钩子函数;

The source code is as follows:
  
ret=etherInputHookAdd(ixeInputHook,\"ixe\",0);
if(ret != OK)
{
   printf(\"Set ixe hook function failed!\\n\");
   return 0;
}

ret=etherInputHookAdd(ixeInputHook,\"ixe\",1);
if(ret != OK)
{
   printf(\"Set ixe hook function failed!\\n\");
   return 0;
}

BOOL ixeInputHook
(
    struct ifnet *pIf,    /* interface packet was received on */
    char         *buffer, /* received packet */
    int          length   /* length of received packet */
)
{
  printf(\"\\nName=%s,unit=%d\",pIf->if_name,pIf->if_unit);
  printf(\"\\nixe InputHook is called!\\n\");
  printf(\"the length is : %d\\n\",length);
  for(i=0;i<length;i++)
  {
      if(i%16 == 0)
         printf(\"\\n\");
      printf(\"%.2x\",(unsigned char)buffer);
      printf(\":\");
  }

  return TRUE;
}

在语句中
printf(\"\\nName=%s,unit=%d\",pIf->if_name,pIf->if_unit);
打印结果为:Name=NULL,unit=6.
我想正确的结果应为: Name=ixe,unit=0 (or 1). 这样我才知道
是从哪个网口收上来的数据。也不知unit=6从那里来的。

那位大虾知道怎么回事,高分酬谢!
车到山前必有路。 虽然有些土,却是我最有感触的一句话。
seven
驱动小牛
驱动小牛
  • 注册日期2001-04-03
  • 最后登录2007-03-28
  • 粉丝0
  • 关注0
  • 积分80分
  • 威望8点
  • 贡献值0点
  • 好评度8点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2003-08-01 08:32

BOOL ixeInputHook
(
    struct ifnet *pIf,    /* interface packet was received on */
    char         *buffer, /* received packet */
    int          length   /* length of received packet */
)
{
  printf(\"\\nName=%s,unit=%d\",pIf->if_name,pIf->if_unit);
  printf(\"\\nixe InputHook is called!\\n\");
  printf(\"the length is : %d\\n\",length);.........



你这个struct还没有初始化呢!打印的东东当然不对。
我爱中医:http://www.ngotcm.com/forum/index.php
yezhi_zxz
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2004-04-23
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-08-15 11:48
  首先你看你的初始化是否调用了函数对你的网口进行配置。如下
 usrNetEndDevStart (\"ixe\",0);
 usrNetIfConfig (\"ixe\",0, \"192.168.1.1\", \"ixe0\",0xffffff00);
 usrNetEndDevStart (\"ixe\",1);
 usrNetIfConfig (\"ixe\",1, \"192.168.1.1\", \"ixe1\",0xffffff00);
由于我不知道你的网口定义的类型是什么,只有用“ixe”代替了

如果你没有初始化,那从网口接受发送的数据可能是正确的,但是你hook出来显示的数据就不一定是对的。

如果想确信的话,在shell下“b ixeInputHook”,然后进入debug模式,看看你的ifnet *pIf。就可以找出问题

good luck!
游客

返回顶部