00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PHY_PHY_HH_
00023 # define PHY_PHY_HH_
00024
00025 # include <wipal/tool/static_base.hh>
00026 # include <wipal/tool/microseconds.hh>
00027 # include <wipal/tool/endianness.hh>
00028 # include <wipal/pcap/frame_descriptor.hh>
00029
00030
00031 namespace phy
00032 {
00033 template <class B> struct header;
00034 template <class B> struct time;
00035 template <class B> struct uint64_time;
00036 }
00037
00038
00039 namespace tool
00040 {
00041
00042 template <class B>
00043 struct types< phy::time<B> >
00044 {
00045 typedef undefined_type impl_type;
00046 };
00047
00048 template <class B>
00049 struct types< phy::uint64_time<B> >
00050 {
00051 typedef uint64_t impl_type;
00052 };
00053
00054 template <class B>
00055 struct types< phy::header<B> >
00056 {
00057 typedef undefined_type time_type;
00058 };
00059
00060 }
00061
00062
00063
00064 namespace phy
00065 {
00066
00067 enum
00068 {
00079 eq_time_default_precision = 106
00080 };
00081
00082
00083
00084
00085
00114 template <class Bottom = tool::bottom>
00115 struct time: WP_INHERIT(public tool::static_base, time<Bottom>)
00116 {
00118
00119 typedef WP_GET_EXACT(Bottom, time<Bottom>) exact_type;
00120 typedef WP_TYPE(impl_type, exact_type) impl_type;
00122
00132 impl_type get() const;
00133
00143 exact_type& operator += (tool::microseconds microseconds);
00144
00146 exact_type operator + (tool::microseconds microseconds) const;
00147
00148 protected:
00149 ~time();
00150 };
00151
00152
00153
00154
00155
00157 template <class Bottom = tool::bottom>
00158 struct uint64_time: WP_INHERIT(public phy::time, uint64_time<Bottom>)
00159 {
00161
00162 typedef WP_GET_EXACT(Bottom, uint64_time<Bottom>) exact_type;
00163 typedef WP_TYPE(impl_type, exact_type) impl_type;
00164
00165 impl_type get_impl() const;
00166 exact_type& increment(const tool::microseconds& microseconds);
00168
00170 uint64_time();
00171
00173 uint64_time(uint64_t ms_count);
00174
00175 private:
00176 uint64_t ms_count_;
00177 };
00178
00179
00180
00181
00182
00207 template <class Bottom = tool::bottom>
00208 struct header: WP_INHERIT(public tool::static_base, header<Bottom>)
00209 {
00211
00212 typedef WP_GET_EXACT(Bottom, header<Bottom>) exact_type;
00213 typedef WP_TYPE(time_type, exact_type) time_type;
00215
00222 size_t len(size_t caplen, bool swapped) const;
00223
00232 const void* decapsulate(size_t caplen, bool swapped) const;
00233
00240 time_type time_get(bool swapped) const;
00241
00248 void time_set(const time_type& time, bool swapped);
00249
00266 template <class D1, class D2>
00267 static bool eq_80211(const pcapxx::frame_descriptor<D1>& lhs,
00268 const pcapxx::frame_descriptor<D2>& rhs,
00269 tool::endian::endianness phy_end =
00270 tool::endian::guess);
00271
00272
00291 template <class D1, class D2>
00292 static bool eq_time_and_80211(const pcapxx::frame_descriptor<D1>& lhs,
00293 const pcapxx::frame_descriptor<D2>& rhs,
00294 tool::endian::endianness phy_end =
00295 tool::endian::guess,
00296 unsigned precision =
00297 phy::eq_time_default_precision);
00298
00299 protected:
00300 ~header();
00301 };
00302
00303 }
00304
00305 # include "phy.hxx"
00306
00307 #endif // ! PHY_PHY_HH_