- Timestamp:
- 09/21/06 21:10:43 (16 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 01818c6
- Parents:
- 8889370
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace_int.h
r1c1e4a2 r52c7cda 363 363 libtrace_linktype_t erf_type_to_libtrace(char erf); 364 364 char libtrace_to_erf_type(libtrace_linktype_t linktype); 365 libtrace_linktype_t arphrd_type_to_libtrace(unsigned int); 366 unsigned int libtrace_to_arphrd_type(libtrace_linktype_t); 365 367 366 368 void promote_packet(libtrace_packet_t *packet); 367 369 bool demote_packet(libtrace_packet_t *packet); 368 370 371 void *trace_get_payload_from_linux_sll(void *, uint16_t *, uint32_t *); 369 372 370 373 uint64_t byteswap64(uint64_t num); -
lib/link_wireless.c
r6df012d r52c7cda 35 35 /* Used for Radiotap fields which must be naturally aligned */ 36 36 #define ALIGN_NATURAL_64(_p,_s) \ 37 37 while ( (_p - _s) % sizeof(uint64_t)) _p++ 38 38 #define ALIGN_NATURAL_32(_p,_s) \ 39 39 while ( (_p - _s) % sizeof(uint32_t)) _p++ 40 40 #define ALIGN_NATURAL_16(_p,_s) \ 41 41 while ( (_p - _s) % sizeof(uint16_t)) _p++ 42 42 43 43 /** Gets a field from a Radiotap header. … … 50 50 static void *trace_get_radiotap_field(void *link, libtrace_radiotap_field_t field) 51 51 { 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 52 struct libtrace_radiotap_t *rtap = (struct libtrace_radiotap_t *)link; 53 uint8_t *p; 54 uint8_t *s; 55 56 /* Check if the field exists in the radiotap header before proceeding 57 */ 58 if ((rtap->it_present & (1 << field)) == 0) return NULL; 59 60 /* Skip over any extended bitmasks */ 61 p = (uint8_t *) &(rtap->it_present); 62 63 while ( *((uint32_t*)p) & (1 << TRACE_RADIOTAP_EXT) ) { 64 p += sizeof (uint32_t); 65 } 66 67 /* Point p at the first field of radiotap data and remember it for later 68 * when we're doing field alignment 69 */ 70 p += sizeof(uint32_t); 71 s = p; 72 73 if (field == TRACE_RADIOTAP_TSFT) 74 /* Always aligned */ 75 return (void*)p; 76 if (rtap->it_present & (1 << TRACE_RADIOTAP_TSFT)) 77 p += sizeof (uint64_t); 78 79 if (field == TRACE_RADIOTAP_FLAGS) 80 /* Always aligned */ 81 return (void*)p; 82 if (rtap->it_present & (1 << TRACE_RADIOTAP_FLAGS)) 83 p += sizeof (uint8_t); 84 85 if (field == TRACE_RADIOTAP_RATE) 86 /* Always aligned */ 87 return (void*)p; 88 if (rtap->it_present & (1 << TRACE_RADIOTAP_RATE)) 89 p+= sizeof (uint8_t); 90 91 if (field == TRACE_RADIOTAP_CHANNEL) 92 { 93 ALIGN_NATURAL_16(p,s); 94 return (void *)p; 95 } 96 if (rtap->it_present & (1 << TRACE_RADIOTAP_CHANNEL)) 97 p+= sizeof (uint32_t); 98 99 if (field == TRACE_RADIOTAP_FHSS) 100 { 101 ALIGN_NATURAL_16(p,s); 102 return (void *)p; 103 } 104 if (rtap->it_present & (1 << TRACE_RADIOTAP_FHSS)) 105 p+= sizeof (uint16_t); 106 107 if (field == TRACE_RADIOTAP_DBM_ANTSIGNAL) 108 return (void *)p; 109 if (rtap->it_present & (1 << TRACE_RADIOTAP_DBM_ANTSIGNAL)) 110 p+= sizeof (uint8_t); 111 112 if (field == TRACE_RADIOTAP_DBM_ANTNOISE) 113 return (void *)p; 114 if (rtap->it_present & (1 << TRACE_RADIOTAP_DBM_ANTNOISE)) 115 p+= sizeof (uint8_t); 116 117 if (field == TRACE_RADIOTAP_LOCK_QUALITY) 118 { 119 ALIGN_NATURAL_16(p,s); 120 return (void *)p; 121 } 122 if (rtap->it_present & (1 << TRACE_RADIOTAP_LOCK_QUALITY)) 123 p+= sizeof (uint16_t); 124 125 if (field == TRACE_RADIOTAP_TX_ATTENUATION) 126 { 127 ALIGN_NATURAL_16(p,s); 128 return (void *)p; 129 } 130 if (rtap->it_present & (1 << TRACE_RADIOTAP_TX_ATTENUATION)) 131 p+= sizeof (uint16_t); 132 133 if (field == TRACE_RADIOTAP_DB_TX_ATTENUATION) 134 { 135 ALIGN_NATURAL_16(p,s); 136 return (void *)p; 137 } 138 if (rtap->it_present & (1 << TRACE_RADIOTAP_DB_TX_ATTENUATION)) 139 p+= sizeof (uint16_t); 140 141 if (field == TRACE_RADIOTAP_DBM_TX_POWER) 142 return (void *)p; 143 if (rtap->it_present & (1 << TRACE_RADIOTAP_DBM_TX_POWER)) 144 p+= sizeof (uint8_t); 145 146 if (field == TRACE_RADIOTAP_ANTENNA) 147 return (void *)p; 148 if (rtap->it_present & (1 << TRACE_RADIOTAP_ANTENNA)) 149 p+= sizeof (uint8_t); 150 151 if (field == TRACE_RADIOTAP_DB_ANTSIGNAL) 152 return (void *)p; 153 if (rtap->it_present & (1 << TRACE_RADIOTAP_DB_ANTSIGNAL)) 154 p+= sizeof (uint8_t); 155 156 if (field == TRACE_RADIOTAP_DB_ANTNOISE) 157 return (void *) p; 158 if (rtap->it_present & (1 << TRACE_RADIOTAP_DB_ANTNOISE)) 159 p+= sizeof (uint8_t); 160 161 if (field == TRACE_RADIOTAP_FCS) 162 ALIGN_NATURAL_32(p,s); 163 return (void *)p; 164 165 /* Unknown field */ 166 return NULL; 167 167 } 168 168 169 169 DLLEXPORT bool trace_get_wireless_tsft(void *link, 170 libtrace_linktype_t linktype, uint64_t *tsft) 171 { 172 uint64_t *p; 173 174 if (link == NULL || tsft == NULL) return false; 175 176 switch (linktype) { 177 case TRACE_TYPE_80211_RADIO: 178 if( p = (uint64_t *) trace_get_radiotap_field(link, 179 TRACE_RADIOTAP_TSFT)) { 180 *tsft = bswap_le_to_host64(*p); 181 return true; 182 } else break; 183 184 case TRACE_TYPE_80211_PRISM: 185 return false; 186 } 187 /* Unsupported link type */ 188 return false; 170 libtrace_linktype_t linktype, uint64_t *tsft) 171 { 172 uint64_t *p; 173 void *l; 174 uint16_t type; 175 if (link == NULL || tsft == NULL) return false; 176 177 switch (linktype) { 178 case TRACE_TYPE_80211_RADIO: 179 if( (p = (uint64_t *) trace_get_radiotap_field(link, 180 TRACE_RADIOTAP_TSFT))) { 181 *tsft = bswap_le_to_host64(*p); 182 return true; 183 } else break; 184 case TRACE_TYPE_LINUX_SLL: 185 l = trace_get_payload_from_linux_sll(link, &type, NULL ); 186 return trace_get_wireless_tsft(l, arphrd_type_to_libtrace(type), tsft); 187 188 case TRACE_TYPE_80211_PRISM: 189 return false; 190 default: 191 return false; 192 } 193 return false; 189 194 } 190 195 191 196 DLLEXPORT bool trace_get_wireless_flags(void *link, 192 libtrace_linktype_t linktype, uint8_t *flags) 193 { 194 uint8_t *p; 195 196 if (link == NULL || flags == NULL) return false; 197 198 switch(linktype) { 199 case TRACE_TYPE_80211_RADIO: 200 if ( p = (uint8_t *) trace_get_radiotap_field(link, 201 TRACE_RADIOTAP_FLAGS)) { 202 *flags = *p; 203 return true; 204 } else break; 205 } 206 /* Unsupported link type */ 207 return false; 197 libtrace_linktype_t linktype, uint8_t *flags) 198 { 199 uint8_t *p; 200 void *l; 201 uint16_t type; 202 203 if (link == NULL || flags == NULL) return false; 204 205 switch(linktype) { 206 case TRACE_TYPE_80211_RADIO: 207 if (( p = (uint8_t *) trace_get_radiotap_field(link, 208 TRACE_RADIOTAP_FLAGS))) { 209 *flags = *p; 210 return true; 211 } else break; 212 case TRACE_TYPE_LINUX_SLL: 213 l = trace_get_payload_from_linux_sll(link, &type, NULL); 214 return trace_get_wireless_flags(l, arphrd_type_to_libtrace(type), flags); 215 default: 216 return false; 217 } 218 return false; 208 219 } 209 220 210 221 DLLEXPORT bool trace_get_wireless_rate(void *link, 211 libtrace_linktype_t linktype, uint8_t *rate) 212 { 213 uint8_t * p; 214 if (link == NULL || rate == NULL) return false ; 215 switch (linktype) { 216 case TRACE_TYPE_80211_RADIO: 217 if ( p = (uint8_t *) trace_get_radiotap_field(link, 218 TRACE_RADIOTAP_RATE)) { 219 *rate = *p; 220 return true; 221 } else break; 222 223 } 224 return false; 222 libtrace_linktype_t linktype, uint8_t *rate) 223 { 224 uint8_t * p; 225 void *l; 226 uint16_t type; 227 228 if (link == NULL || rate == NULL) return false ; 229 switch (linktype) { 230 case TRACE_TYPE_80211_RADIO: 231 if ( (p = (uint8_t *) trace_get_radiotap_field(link, 232 TRACE_RADIOTAP_RATE))) { 233 *rate = *p; 234 return true; 235 } else break; 236 case TRACE_TYPE_LINUX_SLL: 237 l = trace_get_payload_from_linux_sll(link, &type, NULL); 238 return trace_get_wireless_rate(l, arphrd_type_to_libtrace(type), rate); 239 default: 240 return false; 241 } 242 return false; 225 243 } 226 244 227 245 DLLEXPORT bool trace_get_wireless_freq(void *link, 228 libtrace_linktype_t linktype, uint16_t *freq) 229 { 230 uint16_t *p; 231 232 if (link == NULL || freq == NULL) return false; 233 switch (linktype) { 234 case TRACE_TYPE_80211_RADIO: 235 /* NB: The channel field is actually two 16 bit fields. 236 * The chan_freq field is the first of those two, so we 237 * just cast it to a uint16_t. 238 */ 239 if ( p = (uint16_t *) trace_get_radiotap_field(link, 240 TRACE_RADIOTAP_CHANNEL)) { 241 *freq = bswap_le_to_host16(*p); 242 return true; 243 } else break; 244 } 245 return false; 246 } 247 246 libtrace_linktype_t linktype, uint16_t *freq) 247 { 248 uint16_t *p; 249 void *l; 250 uint16_t type; 251 252 if (link == NULL || freq == NULL) return false; 253 switch (linktype) { 254 case TRACE_TYPE_80211_RADIO: 255 /* NB: The channel field is actually two 16 bit fields. 256 * The chan_freq field is the first of those two, so we 257 * just cast it to a uint16_t. 258 */ 259 if (( p = (uint16_t *) trace_get_radiotap_field(link, 260 TRACE_RADIOTAP_CHANNEL))) { 261 *freq = bswap_le_to_host16(*p); 262 return true; 263 } else break; 264 case TRACE_TYPE_LINUX_SLL: 265 l = trace_get_payload_from_linux_sll(link, &type, NULL); 266 return trace_get_wireless_freq(l, arphrd_type_to_libtrace(type), freq); 267 default: 268 return false; 269 } 270 return false; 271 } 272 248 273 DLLEXPORT bool trace_get_wireless_channel_flags(void *link, 249 libtrace_linktype_t linktype, uint16_t *flags) 250 { 251 uint16_t *p; 252 if (link == NULL || flags == NULL) return false; 253 switch (linktype) { 254 case TRACE_TYPE_80211_RADIO: 255 /* NB: The channel field is actually two 16 bit fields. 256 * The chan_flags field is the second of the two, so we need 257 * to take the pointer returned by getting the channel field 258 * and increment it. 259 */ 260 if (p = (uint16_t *) trace_get_radiotap_field(link, 261 TRACE_RADIOTAP_CHANNEL)) { 262 *flags = bswap_le_to_host16(*(++p)); 263 return true; 264 } else break; 265 } 266 return false; 274 libtrace_linktype_t linktype, uint16_t *flags) 275 { 276 uint16_t *p; 277 void *l; 278 uint16_t type; 279 if (link == NULL || flags == NULL) return false; 280 switch (linktype) { 281 case TRACE_TYPE_80211_RADIO: 282 /* NB: The channel field is actually two 16 bit fields. 283 * The chan_flags field is the second of the two, so we need 284 * to take the pointer returned by getting the channel field 285 * and increment it. 286 */ 287 if ((p = (uint16_t *) trace_get_radiotap_field(link, 288 TRACE_RADIOTAP_CHANNEL))) { 289 *flags = bswap_le_to_host16(*(++p)); 290 return true; 291 } else break; 292 case TRACE_TYPE_LINUX_SLL: 293 l = trace_get_payload_from_linux_sll(link, &type, NULL); 294 return trace_get_wireless_channel_flags(l, arphrd_type_to_libtrace(type), flags); 295 default: 296 return false; 297 } 298 return false; 267 299 } 268 300 269 301 DLLEXPORT bool trace_get_wireless_fhss_hopset(void *link, 270 libtrace_linktype_t linktype, uint8_t *hopset) 271 { 272 uint8_t *p; 273 274 if (link == NULL || hopset == NULL) return false; 275 switch(linktype) { 276 case TRACE_TYPE_80211_RADIO: 277 /* NB: As above with the channel field, the fhss field is 278 * similar. 279 */ 280 if( p = (uint8_t *) trace_get_radiotap_field(link, 281 TRACE_RADIOTAP_FHSS)) { 282 *hopset = *p; 283 return true; 284 } else break; 285 } 286 return false; 302 libtrace_linktype_t linktype, uint8_t *hopset) 303 { 304 uint8_t *p; 305 void *l; 306 uint16_t type; 307 308 if (link == NULL || hopset == NULL) return false; 309 switch(linktype) { 310 case TRACE_TYPE_80211_RADIO: 311 /* NB: As above with the channel field, the fhss field is 312 * similar. 313 */ 314 if( (p = (uint8_t *) trace_get_radiotap_field(link, 315 TRACE_RADIOTAP_FHSS))) { 316 *hopset = *p; 317 return true; 318 } else break; 319 case TRACE_TYPE_LINUX_SLL: 320 l = trace_get_payload_from_linux_sll(link, &type, NULL); 321 return trace_get_wireless_fhss_hopset(l, arphrd_type_to_libtrace(type), hopset); 322 default: 323 return false; 324 } 325 return false; 287 326 } 288 327 289 328 DLLEXPORT bool trace_get_wireless_fhss_hoppattern(void *link, 290 libtrace_linktype_t linktype, uint8_t *hoppattern) 291 { 292 uint8_t *p; 293 if (link == NULL || hoppattern == NULL) return false; 294 switch (linktype) { 295 case TRACE_TYPE_80211_RADIO: 296 if(p = (uint8_t *) trace_get_radiotap_field(link, 297 TRACE_RADIOTAP_FHSS)) { 298 *hoppattern = *(++p); 299 return true; 300 } else break; 301 } 302 return false; 329 libtrace_linktype_t linktype, uint8_t *hoppattern) 330 { 331 uint8_t *p; 332 void *l; 333 uint16_t type; 334 if (link == NULL || hoppattern == NULL) return false; 335 switch (linktype) { 336 case TRACE_TYPE_80211_RADIO: 337 if((p = (uint8_t *) trace_get_radiotap_field(link, 338 TRACE_RADIOTAP_FHSS))) { 339 *hoppattern = *(++p); 340 return true; 341 } else break; 342 case TRACE_TYPE_LINUX_SLL: 343 l = trace_get_payload_from_linux_sll(link, &type, NULL); 344 return trace_get_wireless_fhss_hoppattern(l, arphrd_type_to_libtrace(type), hoppattern); 345 default: 346 return false; 347 } 348 return false; 303 349 } 304 350 305 351 DLLEXPORT bool trace_get_wireless_signal_strength_dbm(void *link, 306 libtrace_linktype_t linktype, int8_t *strength) 307 { 308 int8_t *p; 309 310 if (link == NULL || strength == NULL) return false; 311 switch(linktype) { 312 case TRACE_TYPE_80211_RADIO: 313 if (p = (int8_t *) trace_get_radiotap_field(link, 314 TRACE_RADIOTAP_DBM_ANTSIGNAL)) { 315 *strength = *p; 316 return true; 317 } else break; 318 } 319 return false; 352 libtrace_linktype_t linktype, int8_t *strength) 353 { 354 int8_t *p; 355 void *l; 356 uint16_t type; 357 358 if (link == NULL || strength == NULL) return false; 359 switch(linktype) { 360 case TRACE_TYPE_80211_RADIO: 361 if ((p = (int8_t *) trace_get_radiotap_field(link, 362 TRACE_RADIOTAP_DBM_ANTSIGNAL))) { 363 *strength = *p; 364 return true; 365 } else break; 366 case TRACE_TYPE_LINUX_SLL: 367 l = trace_get_payload_from_linux_sll(link, &type, NULL); 368 return trace_get_wireless_signal_strength_dbm(l, arphrd_type_to_libtrace(type), strength); 369 default: 370 return false; 371 } 372 return false; 320 373 } 321 374 322 375 DLLEXPORT bool trace_get_wireless_noise_strength_dbm(void *link, 323 libtrace_linktype_t linktype, int8_t *strength) 324 { 325 uint8_t *p; 326 if (link == NULL || strength == NULL) return false; 327 switch (linktype) { 328 case TRACE_TYPE_80211_RADIO: 329 if ( p = (int8_t *) trace_get_radiotap_field(link, 330 TRACE_RADIOTAP_DBM_ANTNOISE)) { 331 *strength = *p; 332 return true; 333 } else break; 334 } 335 return false; 376 libtrace_linktype_t linktype, int8_t *strength) 377 { 378 uint8_t *p; 379 void *l; 380 uint16_t type; 381 382 if (link == NULL || strength == NULL) return false; 383 switch (linktype) { 384 case TRACE_TYPE_80211_RADIO: 385 if (( p = (int8_t *) trace_get_radiotap_field(link, 386 TRACE_RADIOTAP_DBM_ANTNOISE))) { 387 *strength = *p; 388 return true; 389 } else break; 390 case TRACE_TYPE_LINUX_SLL: 391 l = trace_get_payload_from_linux_sll(link, &type, NULL); 392 return trace_get_wireless_noise_strength_dbm(l, arphrd_type_to_libtrace(type), strength); 393 default: 394 return false; 395 } 396 return false; 336 397 } 337 398 338 399 DLLEXPORT bool trace_get_wireless_signal_strength_db(void *link, 339 libtrace_linktype_t linktype, uint8_t *strength) 340 { 341 uint8_t *p; 342 343 if (link == NULL || strength == NULL) return false; 344 switch (linktype) { 345 case TRACE_TYPE_80211_RADIO: 346 if (p = (uint8_t *) trace_get_radiotap_field(link, 347 TRACE_RADIOTAP_DB_ANTSIGNAL)) { 348 *strength = *p; 349 return true; 350 } else break; 351 } 352 return false ; 400 libtrace_linktype_t linktype, uint8_t *strength) 401 { 402 uint8_t *p; 403 void *l; 404 uint16_t type; 405 406 if (link == NULL || strength == NULL) return false; 407 switch (linktype) { 408 case TRACE_TYPE_80211_RADIO: 409 if ((p = (uint8_t *) trace_get_radiotap_field(link, 410 TRACE_RADIOTAP_DB_ANTSIGNAL))) { 411 *strength = *p; 412 return true; 413 } else break; 414 case TRACE_TYPE_LINUX_SLL: 415 l = trace_get_payload_from_linux_sll(link, &type, NULL); 416 return trace_get_wireless_signal_strength_db(l, arphrd_type_to_libtrace(type), strength); 417 default: 418 return false; 419 } 420 return false ; 353 421 } 354 422 355 423 DLLEXPORT bool trace_get_wireless_noise_strength_db(void *link, 356 libtrace_linktype_t linktype, uint8_t *strength) 357 { 358 uint8_t *p; 359 360 if (link == NULL || strength == NULL) return false; 361 switch (linktype) { 362 case TRACE_TYPE_80211_RADIO: 363 if (p = (uint8_t *) trace_get_radiotap_field(link, 364 TRACE_RADIOTAP_DB_ANTNOISE)) { 365 *strength = *p; 366 return true; 367 } else break; 368 } 369 return false; 424 libtrace_linktype_t linktype, uint8_t *strength) 425 { 426 uint8_t *p; 427 void *l; 428 uint16_t type; 429 430 if (link == NULL || strength == NULL) return false; 431 switch (linktype) { 432 case TRACE_TYPE_80211_RADIO: 433 if ((p = (uint8_t *) trace_get_radiotap_field(link, 434 TRACE_RADIOTAP_DB_ANTNOISE))) { 435 *strength = *p; 436 return true; 437 } else break; 438 case TRACE_TYPE_LINUX_SLL: 439 l = trace_get_payload_from_linux_sll(link, &type, NULL); 440 return trace_get_wireless_noise_strength_db(l, arphrd_type_to_libtrace(type), strength); 441 default: 442 return false; 443 } 444 return false; 370 445 } 371 446 372 447 DLLEXPORT bool trace_get_wireless_lock_quality(void *link, 373 libtrace_linktype_t linktype, uint16_t *quality) 374 { 375 uint16_t *p; 376 377 if (link == NULL || quality == NULL) return false; 378 switch (linktype) { 379 case TRACE_TYPE_80211_RADIO: 380 if(p = (uint16_t *) trace_get_radiotap_field(link, 381 TRACE_RADIOTAP_LOCK_QUALITY)) { 382 *quality = bswap_le_to_host16(*p); 383 return true; 384 } else break; 385 } 386 return false; 448 libtrace_linktype_t linktype, uint16_t *quality) 449 { 450 uint16_t *p; 451 void *l; 452 uint16_t type; 453 454 if (link == NULL || quality == NULL) return false; 455 switch (linktype) { 456 case TRACE_TYPE_80211_RADIO: 457 if((p = (uint16_t *) trace_get_radiotap_field(link, 458 TRACE_RADIOTAP_LOCK_QUALITY))) { 459 *quality = bswap_le_to_host16(*p); 460 return true; 461 } else break; 462 case TRACE_TYPE_LINUX_SLL: 463 l = trace_get_payload_from_linux_sll(link, &type, NULL); 464 return trace_get_wireless_lock_quality(l, arphrd_type_to_libtrace(type), quality); 465 default: 466 return false; 467 } 468 return false; 387 469 } 388 470 389 471 DLLEXPORT bool trace_get_wireless_tx_attenuation(void *link, 390 libtrace_linktype_t linktype, uint16_t *attenuation) 391 { 392 uint16_t *p; 393 if (link == NULL || attenuation == 0) return false; 394 switch (linktype) { 395 case TRACE_TYPE_80211_RADIO: 396 if (p = (uint16_t *) trace_get_radiotap_field(link, 397 TRACE_RADIOTAP_TX_ATTENUATION)) { 398 *attenuation = bswap_le_to_host16(*p); 399 return true; 400 } else break; 401 } 402 return false; 472 libtrace_linktype_t linktype, uint16_t *attenuation) 473 { 474 uint16_t *p; 475 void *l; 476 uint16_t type; 477 478 if (link == NULL || attenuation == 0) return false; 479 switch (linktype) { 480 case TRACE_TYPE_80211_RADIO: 481 if ((p = (uint16_t *) trace_get_radiotap_field(link, 482 TRACE_RADIOTAP_TX_ATTENUATION))) { 483 *attenuation = bswap_le_to_host16(*p); 484 return true; 485 } else break; 486 case TRACE_TYPE_LINUX_SLL: 487 l = trace_get_payload_from_linux_sll(link, &type, NULL); 488 return trace_get_wireless_tx_attenuation(l, arphrd_type_to_libtrace(type), attenuation); 489 default: 490 return false; 491 } 492 return false; 403 493 } 404 494 405 495 DLLEXPORT bool trace_get_wireless_tx_attenuation_db(void *link, 406 libtrace_linktype_t linktype, uint16_t *attenuation) 407 { 408 uint16_t *p; 409 if (link == NULL || attenuation == NULL) return false; 410 switch (linktype) { 411 case TRACE_TYPE_80211_RADIO: 412 if (p = (uint16_t *) trace_get_radiotap_field(link, 413 TRACE_RADIOTAP_DB_TX_ATTENUATION)) { 414 *attenuation = bswap_le_to_host16(*p); 415 return true; 416 } else break; 417 } 418 return false; 496 libtrace_linktype_t linktype, uint16_t *attenuation) 497 { 498 uint16_t *p; 499 void *l; 500 uint16_t type; 501 502 if (link == NULL || attenuation == NULL) return false; 503 switch (linktype) { 504 case TRACE_TYPE_80211_RADIO: 505 if ((p = (uint16_t *) trace_get_radiotap_field(link, 506 TRACE_RADIOTAP_DB_TX_ATTENUATION))) { 507 *attenuation = bswap_le_to_host16(*p); 508 return true; 509 } else break; 510 case TRACE_TYPE_LINUX_SLL: 511 l = trace_get_payload_from_linux_sll(link, &type, NULL); 512 return trace_get_wireless_tx_attenuation_db(l, arphrd_type_to_libtrace(type), attenuation); 513 default: 514 return false; 515 } 516 return false; 419 517 } 420 518 421 519 DLLEXPORT bool trace_get_wireless_tx_power_dbm(void *link, 422 libtrace_linktype_t linktype, int8_t *txpower) 423 { 424 int8_t *p; 425 426 if (link == NULL || txpower == NULL) return false; 427 switch (linktype) { 428 case TRACE_TYPE_80211_RADIO: 429 if (p=(int8_t *) trace_get_radiotap_field(link, 430 TRACE_RADIOTAP_DBM_TX_POWER)) { 431 *txpower = *p; 432 return true; 433 } else break; 434 } 435 return false; 520 libtrace_linktype_t linktype, int8_t *txpower) 521 { 522 int8_t *p; 523 void *l; 524 uint16_t type; 525 526 if (link == NULL || txpower == NULL) return false; 527 switch (linktype) { 528 case TRACE_TYPE_80211_RADIO: 529 if ((p=(int8_t *) trace_get_radiotap_field(link, 530 TRACE_RADIOTAP_DBM_TX_POWER))) { 531 *txpower = *p; 532 return true; 533 } else break; 534 case TRACE_TYPE_LINUX_SLL: 535 l = trace_get_payload_from_linux_sll(link, &type, NULL); 536 return trace_get_wireless_tx_power_dbm(l, arphrd_type_to_libtrace(type), txpower); 537 default: 538 return false; 539 } 540 return false; 436 541 } 437 542 438 543 439 544 DLLEXPORT bool trace_get_wireless_antenna(void *link, 440 libtrace_linktype_t linktype, uint8_t *antenna) 441 { 442 uint8_t *p; 443 if (link == NULL || antenna == NULL) return false; 444 switch (linktype) { 445 case TRACE_TYPE_80211_RADIO: 446 if (p = (uint8_t *) trace_get_radiotap_field(link, 447 TRACE_RADIOTAP_ANTENNA)) { 448 *antenna = *p; 449 return true; 450 } else break; 451 } 452 return false; 545 libtrace_linktype_t linktype, uint8_t *antenna) 546 { 547 uint8_t *p; 548 void *l; 549 uint16_t type; 550 551 if (link == NULL || antenna == NULL) return false; 552 switch (linktype) { 553 case TRACE_TYPE_80211_RADIO: 554 if ((p = (uint8_t *) trace_get_radiotap_field(link, 555 TRACE_RADIOTAP_ANTENNA))) { 556 *antenna = *p; 557 return true; 558 } else break; 559 case TRACE_TYPE_LINUX_SLL: 560 l = trace_get_payload_from_linux_sll(link, &type, NULL); 561 return trace_get_wireless_antenna(l, arphrd_type_to_libtrace(type), antenna); 562 default: 563 return false; 564 } 565 return false; 453 566 } 454 567 455 568 DLLEXPORT bool trace_get_wireless_fcs(void *link, 456 libtrace_linktype_t linktype, uint32_t *fcs) 457 { 458 uint32_t *p; 459 if (link == NULL || fcs == NULL) return false; 460 switch (linktype) { 461 case TRACE_TYPE_80211_RADIO: 462 if (p = (uint32_t *) trace_get_radiotap_field(link, 463 TRACE_RADIOTAP_FCS)) { 464 *fcs = bswap_le_to_host32(*p); 465 return true; 466 } else break; 467 } 468 return false; 469 } 470 569 libtrace_linktype_t linktype, uint32_t *fcs) 570 { 571 uint32_t *p; 572 void *l; 573 uint16_t type; 574 575 if (link == NULL || fcs == NULL) return false; 576 switch (linktype) { 577 case TRACE_TYPE_80211_RADIO: 578 if ((p = (uint32_t *) trace_get_radiotap_field(link, 579 TRACE_RADIOTAP_FCS))) { 580 *fcs = bswap_le_to_host32(*p); 581 return true; 582 } else break; 583 case TRACE_TYPE_LINUX_SLL: 584 l = trace_get_payload_from_linux_sll(link, &type, NULL); 585 return trace_get_wireless_fcs(l, arphrd_type_to_libtrace(type), fcs); 586 default: 587 return false; 588 } 589 return false; 590 } 591 -
lib/protocols.c
r8889370 r52c7cda 111 111 112 112 /* NB: type is returned as an ARPHRD_ type for SLL*/ 113 staticvoid *trace_get_payload_from_linux_sll(void *link,113 void *trace_get_payload_from_linux_sll(void *link, 114 114 uint16_t *type, uint32_t *remaining) 115 115 {
Note: See TracChangeset
for help on using the changeset viewer.