4 * Copyright 2007 Andy Green <andy@warmcat.com>
5 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
7 * SPDX-License-Identifier: (ISC OR GPL-2.0-only)
10 #ifndef __RADIOTAP_ITER_H
11 #define __RADIOTAP_ITER_H
13 #define RADIOTAP_SUPPORT_OVERRIDES
15 #include "packet-ieee80211-radiotap-defs.h"
17 /* Radiotap header iteration
18 * implemented in radiotap.c
21 struct radiotap_override
{
23 unsigned align
:4, size
:4;
26 struct radiotap_align_size
{
27 unsigned align
:4, size
:4;
30 struct ieee80211_radiotap_namespace
{
31 const struct radiotap_align_size
*align_size
;
37 struct ieee80211_radiotap_vendor_namespaces
{
38 const struct ieee80211_radiotap_namespace
*ns
;
43 * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
45 * Describes the radiotap parser state. Fields prefixed with an underscore
46 * must not be used by users of the parser, only by the parser internally.
49 struct ieee80211_radiotap_iterator
{
50 struct ieee80211_radiotap_header
*_rtheader
; /**< pointer to the radiotap header we are walking through */
51 const struct ieee80211_radiotap_vendor_namespaces
*_vns
; /**< vendor namespace definitions*/
52 const struct ieee80211_radiotap_namespace
*current_namespace
; /**< pointer to the current namespace definition (or internally
53 %NULL if the current namespace is unknown)*/
55 unsigned char *_arg
, *_next_ns_data
; /**< beginning of the next namespace's data */
56 uint32_t *_next_bitmap
; /**< internal pointer to next present u32 */
58 unsigned char *this_arg
; /**< pointer to current radiotap arg; it is valid after each call
59 to ieee80211_radiotap_iterator_next() but also after
60 ieee80211_radiotap_iterator_init() where it will point to
61 the beginning of the actual data portion */
62 #ifdef RADIOTAP_SUPPORT_OVERRIDES
63 const struct radiotap_override
*overrides
; /**< override standard radiotap fields */
64 int n_overrides
; /**< number of overrides */
66 int this_arg_index
; /**< index of current arg, valid after each successful call to
67 ieee80211_radiotap_iterator_next() */
68 int this_arg_size
; /**< length of the current arg, for convenience*/
73 int _max_length
; /**< length of radiotap header in cpu byte ordering */
74 int _arg_index
; /**< next argument index */
75 uint32_t _bitmap_shifter
; /**< internal shifter for curr u32 bitmap, b0 set == arg present */
76 int _reset_on_ext
; /**< internal; reset the arg index to 0 when going to the next bitmap word */
79 extern int ieee80211_radiotap_iterator_init(
80 struct ieee80211_radiotap_iterator
*iterator
,
81 struct ieee80211_radiotap_header
*radiotap_header
,
82 int max_length
, const struct ieee80211_radiotap_vendor_namespaces
*vns
);
84 extern int ieee80211_radiotap_iterator_next(
85 struct ieee80211_radiotap_iterator
*iterator
);
87 #endif /* __RADIOTAP_ITER_H */