13ff40c12SJohn Marino #ifndef __RADIOTAP_ITER_H 23ff40c12SJohn Marino #define __RADIOTAP_ITER_H 33ff40c12SJohn Marino 4*a1157835SDaniel Fojt #include <stdint.h> 53ff40c12SJohn Marino #include "radiotap.h" 63ff40c12SJohn Marino 73ff40c12SJohn Marino /* Radiotap header iteration 83ff40c12SJohn Marino * implemented in radiotap.c 93ff40c12SJohn Marino */ 10*a1157835SDaniel Fojt 11*a1157835SDaniel Fojt struct radiotap_override { 12*a1157835SDaniel Fojt uint8_t field; 13*a1157835SDaniel Fojt uint8_t align:4, size:4; 14*a1157835SDaniel Fojt }; 15*a1157835SDaniel Fojt 16*a1157835SDaniel Fojt struct radiotap_align_size { 17*a1157835SDaniel Fojt uint8_t align:4, size:4; 18*a1157835SDaniel Fojt }; 19*a1157835SDaniel Fojt 20*a1157835SDaniel Fojt struct ieee80211_radiotap_namespace { 21*a1157835SDaniel Fojt const struct radiotap_align_size *align_size; 22*a1157835SDaniel Fojt int n_bits; 23*a1157835SDaniel Fojt uint32_t oui; 24*a1157835SDaniel Fojt uint8_t subns; 25*a1157835SDaniel Fojt }; 26*a1157835SDaniel Fojt 27*a1157835SDaniel Fojt struct ieee80211_radiotap_vendor_namespaces { 28*a1157835SDaniel Fojt const struct ieee80211_radiotap_namespace *ns; 29*a1157835SDaniel Fojt int n_ns; 30*a1157835SDaniel Fojt }; 31*a1157835SDaniel Fojt 323ff40c12SJohn Marino /** 333ff40c12SJohn Marino * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args 34*a1157835SDaniel Fojt * @this_arg_index: index of current arg, valid after each successful call 35*a1157835SDaniel Fojt * to ieee80211_radiotap_iterator_next() 36*a1157835SDaniel Fojt * @this_arg: pointer to current radiotap arg; it is valid after each 37*a1157835SDaniel Fojt * call to ieee80211_radiotap_iterator_next() but also after 38*a1157835SDaniel Fojt * ieee80211_radiotap_iterator_init() where it will point to 39*a1157835SDaniel Fojt * the beginning of the actual data portion 40*a1157835SDaniel Fojt * @this_arg_size: length of the current arg, for convenience 41*a1157835SDaniel Fojt * @current_namespace: pointer to the current namespace definition 42*a1157835SDaniel Fojt * (or internally %NULL if the current namespace is unknown) 43*a1157835SDaniel Fojt * @is_radiotap_ns: indicates whether the current namespace is the default 44*a1157835SDaniel Fojt * radiotap namespace or not 45*a1157835SDaniel Fojt * 46*a1157835SDaniel Fojt * @overrides: override standard radiotap fields 47*a1157835SDaniel Fojt * @n_overrides: number of overrides 48*a1157835SDaniel Fojt * 49*a1157835SDaniel Fojt * @_rtheader: pointer to the radiotap header we are walking through 50*a1157835SDaniel Fojt * @_max_length: length of radiotap header in cpu byte ordering 51*a1157835SDaniel Fojt * @_arg_index: next argument index 52*a1157835SDaniel Fojt * @_arg: next argument pointer 53*a1157835SDaniel Fojt * @_next_bitmap: internal pointer to next present u32 54*a1157835SDaniel Fojt * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present 55*a1157835SDaniel Fojt * @_vns: vendor namespace definitions 56*a1157835SDaniel Fojt * @_next_ns_data: beginning of the next namespace's data 57*a1157835SDaniel Fojt * @_reset_on_ext: internal; reset the arg index to 0 when going to the 58*a1157835SDaniel Fojt * next bitmap word 59*a1157835SDaniel Fojt * 60*a1157835SDaniel Fojt * Describes the radiotap parser state. Fields prefixed with an underscore 61*a1157835SDaniel Fojt * must not be used by users of the parser, only by the parser internally. 623ff40c12SJohn Marino */ 633ff40c12SJohn Marino 643ff40c12SJohn Marino struct ieee80211_radiotap_iterator { 65*a1157835SDaniel Fojt struct ieee80211_radiotap_header *_rtheader; 66*a1157835SDaniel Fojt const struct ieee80211_radiotap_vendor_namespaces *_vns; 67*a1157835SDaniel Fojt const struct ieee80211_radiotap_namespace *current_namespace; 683ff40c12SJohn Marino 69*a1157835SDaniel Fojt unsigned char *_arg, *_next_ns_data; 70*a1157835SDaniel Fojt le32 *_next_bitmap; 71*a1157835SDaniel Fojt 72*a1157835SDaniel Fojt unsigned char *this_arg; 73*a1157835SDaniel Fojt #ifdef RADIOTAP_SUPPORT_OVERRIDES 74*a1157835SDaniel Fojt const struct radiotap_override *overrides; 75*a1157835SDaniel Fojt int n_overrides; 76*a1157835SDaniel Fojt #endif 77*a1157835SDaniel Fojt int this_arg_index; 78*a1157835SDaniel Fojt int this_arg_size; 79*a1157835SDaniel Fojt 80*a1157835SDaniel Fojt int is_radiotap_ns; 81*a1157835SDaniel Fojt 82*a1157835SDaniel Fojt int _max_length; 83*a1157835SDaniel Fojt int _arg_index; 84*a1157835SDaniel Fojt uint32_t _bitmap_shifter; 85*a1157835SDaniel Fojt int _reset_on_ext; 863ff40c12SJohn Marino }; 873ff40c12SJohn Marino 883ff40c12SJohn Marino extern int ieee80211_radiotap_iterator_init( 893ff40c12SJohn Marino struct ieee80211_radiotap_iterator *iterator, 903ff40c12SJohn Marino struct ieee80211_radiotap_header *radiotap_header, 91*a1157835SDaniel Fojt int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns); 923ff40c12SJohn Marino 933ff40c12SJohn Marino extern int ieee80211_radiotap_iterator_next( 943ff40c12SJohn Marino struct ieee80211_radiotap_iterator *iterator); 953ff40c12SJohn Marino 963ff40c12SJohn Marino #endif /* __RADIOTAP_ITER_H */ 97