1e28a4053SRui Paulo #ifndef __RADIOTAP_ITER_H 2e28a4053SRui Paulo #define __RADIOTAP_ITER_H 3e28a4053SRui Paulo 45b9c547cSRui Paulo #include <stdint.h> 5e28a4053SRui Paulo #include "radiotap.h" 6e28a4053SRui Paulo 7e28a4053SRui Paulo /* Radiotap header iteration 8e28a4053SRui Paulo * implemented in radiotap.c 9e28a4053SRui Paulo */ 105b9c547cSRui Paulo 115b9c547cSRui Paulo struct radiotap_override { 125b9c547cSRui Paulo uint8_t field; 135b9c547cSRui Paulo uint8_t align:4, size:4; 145b9c547cSRui Paulo }; 155b9c547cSRui Paulo 165b9c547cSRui Paulo struct radiotap_align_size { 175b9c547cSRui Paulo uint8_t align:4, size:4; 185b9c547cSRui Paulo }; 195b9c547cSRui Paulo 205b9c547cSRui Paulo struct ieee80211_radiotap_namespace { 215b9c547cSRui Paulo const struct radiotap_align_size *align_size; 225b9c547cSRui Paulo int n_bits; 235b9c547cSRui Paulo uint32_t oui; 245b9c547cSRui Paulo uint8_t subns; 255b9c547cSRui Paulo }; 265b9c547cSRui Paulo 275b9c547cSRui Paulo struct ieee80211_radiotap_vendor_namespaces { 285b9c547cSRui Paulo const struct ieee80211_radiotap_namespace *ns; 295b9c547cSRui Paulo int n_ns; 305b9c547cSRui Paulo }; 315b9c547cSRui Paulo 32e28a4053SRui Paulo /** 33e28a4053SRui Paulo * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args 345b9c547cSRui Paulo * @this_arg_index: index of current arg, valid after each successful call 355b9c547cSRui Paulo * to ieee80211_radiotap_iterator_next() 365b9c547cSRui Paulo * @this_arg: pointer to current radiotap arg; it is valid after each 375b9c547cSRui Paulo * call to ieee80211_radiotap_iterator_next() but also after 385b9c547cSRui Paulo * ieee80211_radiotap_iterator_init() where it will point to 395b9c547cSRui Paulo * the beginning of the actual data portion 405b9c547cSRui Paulo * @this_arg_size: length of the current arg, for convenience 415b9c547cSRui Paulo * @current_namespace: pointer to the current namespace definition 425b9c547cSRui Paulo * (or internally %NULL if the current namespace is unknown) 435b9c547cSRui Paulo * @is_radiotap_ns: indicates whether the current namespace is the default 445b9c547cSRui Paulo * radiotap namespace or not 455b9c547cSRui Paulo * 465b9c547cSRui Paulo * @overrides: override standard radiotap fields 475b9c547cSRui Paulo * @n_overrides: number of overrides 485b9c547cSRui Paulo * 495b9c547cSRui Paulo * @_rtheader: pointer to the radiotap header we are walking through 505b9c547cSRui Paulo * @_max_length: length of radiotap header in cpu byte ordering 515b9c547cSRui Paulo * @_arg_index: next argument index 525b9c547cSRui Paulo * @_arg: next argument pointer 535b9c547cSRui Paulo * @_next_bitmap: internal pointer to next present u32 545b9c547cSRui Paulo * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present 555b9c547cSRui Paulo * @_vns: vendor namespace definitions 565b9c547cSRui Paulo * @_next_ns_data: beginning of the next namespace's data 575b9c547cSRui Paulo * @_reset_on_ext: internal; reset the arg index to 0 when going to the 585b9c547cSRui Paulo * next bitmap word 595b9c547cSRui Paulo * 605b9c547cSRui Paulo * Describes the radiotap parser state. Fields prefixed with an underscore 615b9c547cSRui Paulo * must not be used by users of the parser, only by the parser internally. 62e28a4053SRui Paulo */ 63e28a4053SRui Paulo 64e28a4053SRui Paulo struct ieee80211_radiotap_iterator { 655b9c547cSRui Paulo struct ieee80211_radiotap_header *_rtheader; 665b9c547cSRui Paulo const struct ieee80211_radiotap_vendor_namespaces *_vns; 675b9c547cSRui Paulo const struct ieee80211_radiotap_namespace *current_namespace; 68e28a4053SRui Paulo 695b9c547cSRui Paulo unsigned char *_arg, *_next_ns_data; 70*780fb4a2SCy Schubert le32 *_next_bitmap; 715b9c547cSRui Paulo 725b9c547cSRui Paulo unsigned char *this_arg; 735b9c547cSRui Paulo #ifdef RADIOTAP_SUPPORT_OVERRIDES 745b9c547cSRui Paulo const struct radiotap_override *overrides; 755b9c547cSRui Paulo int n_overrides; 765b9c547cSRui Paulo #endif 775b9c547cSRui Paulo int this_arg_index; 785b9c547cSRui Paulo int this_arg_size; 795b9c547cSRui Paulo 805b9c547cSRui Paulo int is_radiotap_ns; 815b9c547cSRui Paulo 825b9c547cSRui Paulo int _max_length; 835b9c547cSRui Paulo int _arg_index; 845b9c547cSRui Paulo uint32_t _bitmap_shifter; 855b9c547cSRui Paulo int _reset_on_ext; 86e28a4053SRui Paulo }; 87e28a4053SRui Paulo 88e28a4053SRui Paulo extern int ieee80211_radiotap_iterator_init( 89e28a4053SRui Paulo struct ieee80211_radiotap_iterator *iterator, 90e28a4053SRui Paulo struct ieee80211_radiotap_header *radiotap_header, 915b9c547cSRui Paulo int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns); 92e28a4053SRui Paulo 93e28a4053SRui Paulo extern int ieee80211_radiotap_iterator_next( 94e28a4053SRui Paulo struct ieee80211_radiotap_iterator *iterator); 95e28a4053SRui Paulo 96e28a4053SRui Paulo #endif /* __RADIOTAP_ITER_H */ 97