00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PRISM_HEADER_HXX_
00023 # define PRISM_HEADER_HXX_
00024
00025 # include "prism_header.hh"
00026
00027 # include <wipal/tool/endianness.hh>
00028
00029 namespace prism
00030 {
00031
00032 inline
00033 uint32_t
00034 item::get(bool swapped) const
00035 {
00036 return tool::extract_long_u(data, swapped);
00037 }
00038
00039 inline
00040 item&
00041 item::set(uint32_t value, bool swapped)
00042 {
00043 status = 0;
00044 data = tool::extract_long_u(value, swapped);
00045
00046 return *this;
00047 }
00048
00049 inline
00050 bool
00051 eq_80211(const header* lhs, size_t lhs_caplen,
00052 const header* rhs, size_t rhs_caplen)
00053 {
00054 const size_t caplen = std::min(lhs_caplen, rhs_caplen);
00055
00056 if (caplen < sizeof (prism::header))
00057 return false;
00058
00059 return 0 == memcmp(lhs + 1, rhs + 1, caplen - sizeof (prism::header));
00060 }
00061
00062 inline
00063 bool
00064 eq_time_and_80211(const header* lhs, size_t lhs_caplen, bool lhs_swapped,
00065 const header* rhs, size_t rhs_caplen, bool rhs_swapped,
00066 unsigned precision,
00067 bool check_hosttime)
00068 {
00069 const size_t caplen = std::min(lhs_caplen, rhs_caplen);
00070
00071 if (caplen < sizeof (prism::header))
00072 return false;
00073
00074 const unsigned dmac = std::abs(int (lhs->mactime.get(lhs_swapped) -
00075 rhs->mactime.get(rhs_swapped)));
00076
00077 if (dmac > precision)
00078 return false;
00079
00080 if (check_hosttime)
00081 {
00082 const unsigned dhost = std::abs(int (lhs->hosttime.get(lhs_swapped) -
00083 rhs->hosttime.get(rhs_swapped)));
00084
00085 if (dhost > precision / 10)
00086 return false;
00087 }
00088
00089 return 0 == memcmp(lhs + 1, rhs + 1, caplen - sizeof (prism::header));
00090 }
00091
00092 }
00093
00094 #endif // ! PRISM_HEADER_HXX_