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
00068
00069
00070
00099 template <class Bottom = tool::bottom>
00100 struct time: WP_INHERIT(public tool::static_base, time<Bottom>)
00101 {
00103
00104 typedef WP_GET_EXACT(Bottom, time<Bottom>) exact_type;
00105 typedef WP_TYPE(impl_type, exact_type) impl_type;
00107
00117 impl_type get() const;
00118
00128 exact_type& operator += (tool::microseconds microseconds);
00129
00131 exact_type operator + (tool::microseconds microseconds) const;
00132
00133 protected:
00134 ~time();
00135 };
00136
00137
00138
00139
00140
00142 template <class Bottom = tool::bottom>
00143 struct uint64_time: WP_INHERIT(public phy::time, uint64_time<Bottom>)
00144 {
00146
00147 typedef WP_GET_EXACT(Bottom, uint64_time<Bottom>) exact_type;
00148 typedef WP_TYPE(impl_type, exact_type) impl_type;
00149
00150 impl_type get_impl() const;
00151 exact_type& increment(const tool::microseconds& microseconds);
00153
00155 uint64_time();
00156
00158 uint64_time(uint64_t ms_count);
00159
00160 private:
00161 uint64_t ms_count_;
00162 };
00163
00164
00165
00166
00167
00192 template <class Bottom = tool::bottom>
00193 struct header: WP_INHERIT(public tool::static_base, header<Bottom>)
00194 {
00196
00197 typedef WP_GET_EXACT(Bottom, header<Bottom>) exact_type;
00198 typedef WP_TYPE(time_type, exact_type) time_type;
00200
00207 size_t len(size_t caplen, bool swapped) const;
00208
00217 const void* decapsulate(size_t caplen, bool swapped) const;
00218
00225 time_type time_get(bool swapped) const;
00226
00233 void time_set(const time_type& time, bool swapped);
00234
00251 template <class D1, class D2>
00252 static bool eq_80211(const pcapxx::frame_descriptor<D1>& lhs,
00253 const pcapxx::frame_descriptor<D2>& rhs,
00254 tool::endian::endianness phy_end =
00255 tool::endian::guess);
00256
00257
00276 template <class D1, class D2>
00277 static bool eq_time_and_80211(const pcapxx::frame_descriptor<D1>& lhs,
00278 const pcapxx::frame_descriptor<D2>& rhs,
00279 const unsigned precision,
00280 const tool::endian::endianness phy_end =
00281 tool::endian::guess);
00282
00283 protected:
00284 ~header();
00285 };
00286
00287 }
00288
00289 # include "phy.hxx"
00290
00291 #endif // ! PHY_PHY_HH_