diff options
author | Andy Green <andy@warmcat.com> | 2007-07-10 13:29:38 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2007-07-12 16:07:24 -0400 |
commit | 179f831bc33104d14deb54a52b7a8b43433f8ccc (patch) | |
tree | 8834c628a493fbd4aff1e09dc77b334154c6a050 /Documentation/networking | |
parent | 08d1f2155cd5b21bb3848f46d9747afb1ccd249d (diff) |
[PATCH] cfg80211: Radiotap parser
Generic code to walk through the fields in a radiotap header, accounting
for nasties like extended "field present" bitfields and alignment rules
Signed-off-by: Andy Green <andy@warmcat.com>
Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'Documentation/networking')
-rw-r--r-- | Documentation/networking/radiotap-headers.txt | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Documentation/networking/radiotap-headers.txt b/Documentation/networking/radiotap-headers.txt index e29e027d9be3..953331c7984f 100644 --- a/Documentation/networking/radiotap-headers.txt +++ b/Documentation/networking/radiotap-headers.txt | |||
@@ -84,4 +84,69 @@ Example valid radiotap header | |||
84 | 0x01 //<-- antenna | 84 | 0x01 //<-- antenna |
85 | 85 | ||
86 | 86 | ||
87 | Using the Radiotap Parser | ||
88 | ------------------------- | ||
89 | |||
90 | If you are having to parse a radiotap struct, you can radically simplify the | ||
91 | job by using the radiotap parser that lives in net/wireless/radiotap.c and has | ||
92 | its prototypes available in include/net/cfg80211.h. You use it like this: | ||
93 | |||
94 | #include <net/cfg80211.h> | ||
95 | |||
96 | /* buf points to the start of the radiotap header part */ | ||
97 | |||
98 | int MyFunction(u8 * buf, int buflen) | ||
99 | { | ||
100 | int pkt_rate_100kHz = 0, antenna = 0, pwr = 0; | ||
101 | struct ieee80211_radiotap_iterator iterator; | ||
102 | int ret = ieee80211_radiotap_iterator_init(&iterator, buf, buflen); | ||
103 | |||
104 | while (!ret) { | ||
105 | |||
106 | ret = ieee80211_radiotap_iterator_next(&iterator); | ||
107 | |||
108 | if (ret) | ||
109 | continue; | ||
110 | |||
111 | /* see if this argument is something we can use */ | ||
112 | |||
113 | switch (iterator.this_arg_index) { | ||
114 | /* | ||
115 | * You must take care when dereferencing iterator.this_arg | ||
116 | * for multibyte types... the pointer is not aligned. Use | ||
117 | * get_unaligned((type *)iterator.this_arg) to dereference | ||
118 | * iterator.this_arg for type "type" safely on all arches. | ||
119 | */ | ||
120 | case IEEE80211_RADIOTAP_RATE: | ||
121 | /* radiotap "rate" u8 is in | ||
122 | * 500kbps units, eg, 0x02=1Mbps | ||
123 | */ | ||
124 | pkt_rate_100kHz = (*iterator.this_arg) * 5; | ||
125 | break; | ||
126 | |||
127 | case IEEE80211_RADIOTAP_ANTENNA: | ||
128 | /* radiotap uses 0 for 1st ant */ | ||
129 | antenna = *iterator.this_arg); | ||
130 | break; | ||
131 | |||
132 | case IEEE80211_RADIOTAP_DBM_TX_POWER: | ||
133 | pwr = *iterator.this_arg; | ||
134 | break; | ||
135 | |||
136 | default: | ||
137 | break; | ||
138 | } | ||
139 | } /* while more rt headers */ | ||
140 | |||
141 | if (ret != -ENOENT) | ||
142 | return TXRX_DROP; | ||
143 | |||
144 | /* discard the radiotap header part */ | ||
145 | buf += iterator.max_length; | ||
146 | buflen -= iterator.max_length; | ||
147 | |||
148 | ... | ||
149 | |||
150 | } | ||
151 | |||
87 | Andy Green <andy@warmcat.com> | 152 | Andy Green <andy@warmcat.com> |