首页
学习
活动
专区
圈层
工具
发布

提取
EN

Stack Overflow用户
提问于 2013-05-10 13:07:05
回答 1查看 3.7K关注 0票数 0

我有一些代码使用了来自ieee80211_radiotap_iterator_init()ieee80211_radiotap_iterator_next()radiotap-parser.c函数,

我不知道我做错了什么,也许有人能教育我?我或多或少地使用了来自文献资料的示例代码,而无需修改,它非常适合我试图实现的目标:

代码语言:javascript
复制
/* where packet is `const u_char *packet' */
struct ieee80211_radiotap_iterator rti;
struct ieee80211_radiotap_header *rth = ( struct ieee80211_radiotap_header * ) packet;

/* 802.11 frame starts here */
struct wi_frame *fr= ( struct wi_frame * ) ( packet + rth->it_len );

/* Set up the iteration */
int ret = ieee80211_radiotap_iterator_init(&rti, rth, rth->it_len);

/* Loop until we've consumed all the fields */
while(!ret) {
  printf("Itteration: %d\n", count++);
  ret = ieee80211_radiotap_iterator_next(&rti);
  if(ret) {
    /*
     * The problem is here, I'm dropping into this clause with 
     * a value of `1` consistently, that doesn't match my platform's
     * definition of EINVAL or ENOENT.
     */
    continue;
  }
  switch(rti.this_arg_index) {
  default:
    printf("Constant: %d\n", *rti.this_arg);
    break;
  }
}

在代码中出错的空间有限,我想,我对从ieee80211_radiotap_iterator_next()返回的ieee80211_radiotap_iterator_next()感到困惑,根据实现,这在实施中似乎并不是一个错误条件。

我正在筛选"(type mgt) and (not type mgt subtype beacon)"类型的数据包,甚至不确定当数据链接设置为DLT_IEEE802_11_RADIO时,libpcap是否会包含这些属性

EN

回答 1

Stack Overflow用户

发布于 2013-05-10 18:45:05

第一:

我正在筛选“( mgt类型)和(不是mgt子类型信标)”类型的数据包,我甚至不确定当数据链接设置为DLT_IEEE802_11_RADIO时libpcap是否会包含这些属性?

它会的。为DLT_IEEE802_11_RADIO生成的过滤器代码获取无线电头的长度并跳过无线电头,因此它将跳过无线电头并检查它后面的802.11头。

第二:

实施

您链接到两个不同的ieee80211_radiotap_iterator_next() - 在无线电服务中心的那个实现,其中ieee80211_radiotap_iterator_next()在成功时返回“下一个当前arg索引”,而在Linux内核中的中,ieee80211_radiotap_iterator_next()在成功时返回0。如果您正在使用的无线电迭代器代码是在Radiapt-parser.c中使用的代码,则不要注意Linux内核中的代码,因为它的行为方式与您使用的代码不同。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16483010

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档