Changeset 1708aa8
- Timestamp:
- 09/05/07 11:41:27 (14 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:
- 34e22d1
- Parents:
- 27bd348
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/protocols.c
r1344aa8 r1708aa8 695 695 } 696 696 697 /* Take a pointer to the start of an IEEE 802.11 MAC frame and return a pointer 698 * to the source MAC address. 699 * If the frame does not contain a sender address, e.g. ACK frame, return NULL. 700 * If the frame is a 4-address WDS frame, return TA, i.e. addr2. 701 * NB: This function decodes the 802.11 header, so it assumes that there are no 702 * bit-errors. If there are, all bets are off. 703 */ 704 static 705 uint8_t *get_source_mac_from_wifi(void *wifi) { 706 if (wifi == NULL) return NULL; 707 struct libtrace_80211_t *w = (struct libtrace_80211_t *) wifi; 708 709 /* If the frame is of type CTRL */ 710 if (w->type == 0x1) 711 /* If bit 2 of the subtype field is zero, this indicates that 712 * there is no transmitter address, i.e. the frame is either an 713 * ACK or a CTS frame */ 714 if ((w->subtype & 0x2) == 0) 715 return NULL; 716 717 /* Always return the address of the transmitter, i.e. address 2 */ 718 return (uint8_t *) &w->mac2; 719 } 697 720 698 721 uint8_t *trace_get_source_mac(libtrace_packet_t *packet) { 699 722 void *link = trace_get_link(packet); 700 libtrace_80211_t *wifi;701 723 libtrace_ether_t *ethptr = (libtrace_ether_t*)link; 702 724 if (!link) 703 725 return NULL; 704 726 switch (trace_get_link_type(packet)) { 727 case TRACE_TYPE_80211_RADIO: 728 link = trace_get_payload_from_radiotap( 729 link, NULL, NULL); 730 /* Fall through for 802.11 */ 705 731 case TRACE_TYPE_80211: 706 wifi=(libtrace_80211_t*)link; 707 return (uint8_t*)&wifi->mac2; 708 case TRACE_TYPE_80211_RADIO: 709 wifi=(libtrace_80211_t*)trace_get_payload_from_radiotap( 710 link,NULL,NULL); 711 return (uint8_t*)&wifi->mac1; 732 return get_source_mac_from_wifi(link); 712 733 case TRACE_TYPE_80211_PRISM: 713 wifi=(libtrace_80211_t*)((char*)link+144);714 return (uint8_t*)&wifi->mac2;734 link = ((char*)link+144); 735 return get_source_mac_from_wifi(link); 715 736 case TRACE_TYPE_ETH: 716 737 return (uint8_t*)ðptr->ether_shost;
Note: See TracChangeset
for help on using the changeset viewer.