Changeset 1267
- Timestamp:
- 05/09/07 20:51:56 (1 year ago)
- Files:
-
- trunk/lib/protocols.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/protocols.c
r1263 r1267 266 266 } 267 267 268 if (type) *type = 0;268 if (type) *type = TRACE_TYPE_80211; 269 269 270 270 return (void *) ((char*)link+144); … … 283 283 } 284 284 285 if (type) *type = 0;285 if (type) *type = TRACE_TYPE_80211; 286 286 287 287 return (void*) ((char*)link + rtaplen); … … 718 718 } 719 719 720 uint8_t *trace_get_source_mac(libtrace_packet_t *packet) { 721 void *link = trace_get_link(packet); 722 libtrace_ether_t *ethptr = (libtrace_ether_t*)link; 720 static 721 uint8_t *__trace_get_source_mac(void *link, libtrace_linktype_t *linktype, uint32_t *rem) { 722 libtrace_ether_t *ethptr = (libtrace_ether_t *) link; 723 uint16_t arphrd; 723 724 if (!link) 724 725 return NULL; 725 switch (trace_get_link_type(packet)) { 726 727 switch (*linktype) { 728 case TRACE_TYPE_ETH: 729 return (uint8_t *)ðptr->ether_shost; 730 case TRACE_TYPE_80211: 731 return get_source_mac_from_wifi(link); 726 732 case TRACE_TYPE_80211_RADIO: 727 733 link = trace_get_payload_from_radiotap( 728 link, NULL, NULL); 729 /* Fall through for 802.11 */ 730 case TRACE_TYPE_80211: 731 return get_source_mac_from_wifi(link); 734 link, linktype, rem); 735 return __trace_get_source_mac(link, linktype, rem); 732 736 case TRACE_TYPE_80211_PRISM: 733 link = ((char*)link+144); 734 return get_source_mac_from_wifi(link); 735 case TRACE_TYPE_ETH: 736 return (uint8_t*)ðptr->ether_shost; 737 link = trace_get_payload_from_prism( 738 link, linktype, rem); 739 return __trace_get_source_mac(link, linktype, rem); 740 case TRACE_TYPE_LINUX_SLL: 741 link = trace_get_payload_from_linux_sll( 742 link, &arphrd, rem); 743 *linktype = arphrd_type_to_libtrace(arphrd); 744 return __trace_get_source_mac(link, linktype, rem); 737 745 case TRACE_TYPE_POS: 738 746 case TRACE_TYPE_NONE: 739 747 case TRACE_TYPE_HDLC_POS: 740 case TRACE_TYPE_LINUX_SLL:741 748 case TRACE_TYPE_PFLOG: 742 749 case TRACE_TYPE_ATM: … … 747 754 break; 748 755 } 749 fprintf(stderr," Not implemented\n");756 fprintf(stderr,"%s not implemented for linktype %i\n", __func__, *linktype); 750 757 assert(0); 751 758 return NULL; 759 } 760 761 DLLEXPORT uint8_t *trace_get_source_mac(libtrace_packet_t *packet) { 762 if (packet == NULL) 763 return NULL; 764 void *link = trace_get_link(packet); 765 uint32_t len = trace_get_capture_length(packet); 766 libtrace_linktype_t lt = trace_get_link_type(packet); 767 return __trace_get_source_mac(link, <, &len); 752 768 } 753 769
