title: libpcap Radiotap header extraction
body: <p>I've got some code that is using the functions <code>ieee80211_radiotap_iterator_init()</code> and <code>ieee80211_radiotap_iterator_next()</code> from <a href="http://airscan.googlecode.com/svn-history/r2/trunk/radiotap-parser.c" rel="nofollow"><code>radiotap-parser.c</code></a>, </p>
  
  <p>I'm not sure what I'm doing incorrectly, perhaps someone can educate me? I'm using the sample code from <a href="http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/Documentation/networking/radiotap-headers.txt" rel="nofollow">the documentation</a> more or less without modification, it fits very well to what I was trying to achieve:</p>
  
  <pre><code>/* 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-&gt;it_len );
  
  /* Set up the iteration */
  int ret = ieee80211_radiotap_iterator_init(&amp;rti, rth, rth-&gt;it_len);
  
  /* Loop until we've consumed all the fields */
  while(!ret) {
    printf("Itteration: %d\n", count++);
    ret = ieee80211_radiotap_iterator_next(&amp;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;
    }
  }
  </code></pre>
  
  <p>There's limited scope for having screwed something up in that code, I think, I'm confused by the <code>1</code> being returned from <code>ieee80211_radiotap_iterator_next()</code> which according to the implenentation doesn't seem like an error condition in <a href="http://lxr.free-electrons.com/source/net/wireless/radiotap.c#L95" rel="nofollow">the implementation</a>.</p>
  
  <p>I'm filtering for packets of type <code>"(type mgt) and (not type mgt subtype beacon)"</code>, and I'm not even certain if libpcap will include these attributes when the data link is set to <code>DLT_IEEE802_11_RADIO</code>?</p>