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/pkt.hh>
00029
00030 namespace wpl
00031 {
00032
00033
00034 namespace phy
00035 {
00036 template <class B> struct header;
00037 template <class B> struct time;
00038 template <class B> struct uint64_time;
00039 }
00040
00041
00042 namespace tool
00043 {
00044
00045 template <class B>
00046 struct types< phy::time<B> >
00047 {
00048 typedef undefined_type impl_type;
00049 };
00050
00051 template <class B>
00052 struct types< phy::uint64_time<B> >
00053 {
00054 typedef uint64_t impl_type;
00055 };
00056
00057 template <class B>
00058 struct types< phy::header<B> >
00059 {
00060 typedef undefined_type time_type;
00061 };
00062
00063 }
00064
00065
00066
00067 namespace phy
00068 {
00069
00070
00071
00072
00073
00102 template <class Bottom = tool::bottom>
00103 struct time: WP_INHERIT(public tool::static_base, time<Bottom>)
00104 {
00105 typedef WP_GET_EXACT(Bottom, time<Bottom>) exact_type;
00106 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 {
00195 typedef WP_GET_EXACT(Bottom, header<Bottom>) exact_type;
00196 typedef WP_TYPE(time_type, exact_type) time_type;
00197
00204 size_t len(size_t caplen, bool swapped) const;
00205
00214 const void* decapsulate(size_t caplen, bool swapped) const;
00215
00222 time_type time_get(bool swapped) const;
00223
00230 void time_set(const time_type& time, bool swapped);
00231
00248 template <class S1, class S2>
00249 static bool
00250 eq_80211(const pkt::packet<S1>& lhs,
00251 const pkt::packet<S2>& rhs,
00252 tool::end::endianness phy_end = tool::end::guess);
00253
00254
00273 template <class S1, class S2>
00274 static bool
00275 eq_time_and_80211(const pkt::packet<S1>& lhs,
00276 const pkt::packet<S2>& rhs,
00277 const unsigned precision,
00278 const tool::end::endianness phy_end =
00279 tool::end::guess);
00280
00281 protected:
00282 ~header();
00283 };
00284
00285 }
00286
00287 }
00288
00289 # include "phy.hxx"
00290
00291 #endif // ! PHY_PHY_HH_