-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/sniff.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc index 81eccab..3c227ab 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc | |||
@@ -154,57 +154,72 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack | |||
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | /* This decodes the 802.11b frame header out of the 802.11b packet | 157 | /* This decodes the 802.11b frame header out of the 802.11b packet |
158 | all the infos is placed into the packetinfo structure */ | 158 | all the infos is placed into the packetinfo structure */ |
159 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) | 159 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) |
160 | { | 160 | { |
161 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; | 161 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; |
162 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); | 162 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); |
163 | 163 | ||
164 | /* Get the sender, bssid and dest mac address */ | 164 | /* Get the sender, bssid and dest mac address */ |
165 | etheraddr_string(mgthdr->bssid,ppinfo->bssid); | 165 | etheraddr_string(mgthdr->bssid,ppinfo->bssid); |
166 | etheraddr_string(mgthdr->da,ppinfo->desthwaddr); | 166 | etheraddr_string(mgthdr->da,ppinfo->desthwaddr); |
167 | etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); | 167 | etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); |
168 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); | 168 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void etheraddr_string(register const u_char *ep, char *text) | 173 | void etheraddr_string(register const u_char *ep, char *text) |
174 | { | 174 | { |
175 | static char hex[] = "0123456789abcdef"; | 175 | static char hex[] = "0123456789abcdef"; |
176 | register unsigned int i, j; | 176 | register unsigned int i, j; |
177 | register char *cp; | 177 | register char *cp; |
178 | char buf[sizeof("00:00:00:00:00:00")]; | 178 | char buf[sizeof("00:00:00:00:00:00\0")]; |
179 | cp = buf; | 179 | cp = buf; |
180 | if ((j = *ep >> 4) != 0) | 180 | if ((j = *ep >> 4) != 0) |
181 | *cp++ = hex[j]; | 181 | { |
182 | *cp++ = hex[j]; | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | *cp++ = '0'; | ||
187 | } | ||
182 | *cp++ = hex[*ep++ & 0xf]; | 188 | *cp++ = hex[*ep++ & 0xf]; |
183 | for (i = 5; (int)--i >= 0;) { | 189 | |
190 | for (i = 5; (int)--i >= 0;) | ||
191 | { | ||
184 | *cp++ = ':'; | 192 | *cp++ = ':'; |
185 | if ((j = *ep >> 4) != 0) | 193 | if ((j = *ep >> 4) != 0) |
186 | *cp++ = hex[j]; | 194 | { |
195 | *cp++ = hex[j]; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | *cp++ = '0'; | ||
200 | } | ||
201 | |||
187 | *cp++ = hex[*ep++ & 0xf]; | 202 | *cp++ = hex[*ep++ & 0xf]; |
188 | } | 203 | } |
189 | *cp = '\0'; | 204 | *cp = '\0'; |
190 | strcpy(text,buf); | 205 | strcpy(text,buf); |
191 | } | 206 | } |
192 | 207 | ||
193 | /* beacon handler */ | 208 | /* beacon handler */ |
194 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | 209 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) |
195 | { | 210 | { |
196 | struct mgmt_body_t pbody; | 211 | struct mgmt_body_t pbody; |
197 | int offset = 0; | 212 | int offset = 0; |
198 | 213 | ||
199 | /* Get the static informations out of the packet */ | 214 | /* Get the static informations out of the packet */ |
200 | memset(&pbody, 0, sizeof(pbody)); | 215 | memset(&pbody, 0, sizeof(pbody)); |
201 | memcpy(&pbody.timestamp, p, 8); | 216 | memcpy(&pbody.timestamp, p, 8); |
202 | offset += 8; | 217 | offset += 8; |
203 | pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); | 218 | pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); |
204 | offset += 2; | 219 | offset += 2; |
205 | pbody.capability_info = EXTRACT_LE_16BITS(p+offset); | 220 | pbody.capability_info = EXTRACT_LE_16BITS(p+offset); |
206 | offset += 2; | 221 | offset += 2; |
207 | 222 | ||
208 | /* Gets the different flags out of the capabilities */ | 223 | /* Gets the different flags out of the capabilities */ |
209 | ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info); | 224 | ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info); |
210 | ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info); | 225 | ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info); |