免费注册 查看新帖 |

Chinaunix

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

[其他] 已解决。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-08-10 17:10 |只看该作者 |倒序浏览
本帖最后由 Redshadows 于 2012-08-11 01:44 编辑

用户手册里面写着,可是本人英语不太好,最后一句看不懂


       typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *h,
                                   const u_char *bytes);

       int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user);

       callback specifies a pcap_handler routine to be called with three argu-
       ments:  a  u_char  pointer  which  is  passed  in  the user argument to
       pcap_loop() or pcap_dispatch(),  a  const  struct  pcap_pkthdr  pointer
       pointing  to  the  packet  time  stamp  and lengths, and a const u_char
       pointer to the first caplen (as  given  in  the  struct  pcap_pkthdr  a
       pointer  to which is passed to the callback routine) bytes of data from
       the packet.


a const u_char pointer to the first caplen (as  given  in  the  struct  pcap_pkthdr  a pointer  to which is passed to the callback routine) bytes of data from the packet.
请问一下是什么意思?

就是pcap_handler的const u_char *bytes是什么干什么用的?我google了也找不到。。。

万分感谢。

论坛徽章:
0
2 [报告]
发表于 2012-08-10 17:14 |只看该作者
a const u_char pointer to the first caplen (as  given  in  the  struct  pcap_pkthdr  a pointer  to which is passed to the callback routine) bytes of data from the packet.

caplen不是一个值吗?表示接收到的数据包的实际长度?怎么又有个指针指向第一个caplen了???

论坛徽章:
0
3 [报告]
发表于 2012-08-10 17:26 |只看该作者
typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes);

我看到一段别人定义的callback的代码

它把从bytes + 12处开始的长为h->len的数据保存起来,这又是什么意思呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP