00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PHY_EMPTY_HXX_
00023 # define PHY_EMPTY_HXX_
00024
00025 extern "C"
00026 {
00027 # include <sys/time.h>
00028 }
00029
00030 # include <wipal/phy/empty.hh>
00031
00032 namespace phy
00033 {
00034
00035
00036
00037
00038
00039 template <class B>
00040 typename empty_time<B>::impl_type
00041 empty_time<B>::get_impl() const
00042 {
00043 return impl_type ();
00044 }
00045
00046 template <class B>
00047 typename empty_time<B>::exact_type&
00048 empty_time<B>::increment(tool::microseconds)
00049 {
00050 return this->exact();
00051 }
00052
00053
00054
00055
00056
00057
00058 template <class B>
00059 size_t
00060 empty_header<B>::len_impl(size_t, bool) const
00061 {
00062 return 0;
00063 }
00064
00065 template <class B>
00066 typename empty_header<B>::time_type
00067 empty_header<B>::time_get_impl(bool) const
00068 {
00069 return time_type ();
00070 }
00071
00072 template <class B>
00073 void
00074 empty_header<B>::time_set_impl(const time_type&, bool)
00075 {
00076 }
00077
00078 template <class B>
00079 template <class D1, class D2>
00080 bool
00081 empty_header<B>::eq_time(const pcapxx::frame_descriptor<D1>& lhs,
00082 const pcapxx::frame_descriptor<D2>& rhs,
00083 tool::endian::endianness ,
00084 unsigned prec)
00085 {
00086 const pcapxx::pkthdr& lhs_pcap = *lhs.pcap_header();
00087 const pcapxx::pkthdr& rhs_pcap = *rhs.pcap_header();
00088
00089 const struct timeval* const lhs_tv = &lhs_pcap.ts;
00090 const struct timeval* const rhs_tv = &rhs_pcap.ts;
00091
00092 struct timeval dt;
00093
00094 if (timercmp(lhs_tv, rhs_tv, <))
00095 timersub(rhs_tv, lhs_tv, &dt);
00096 else
00097 timersub(lhs_tv, rhs_tv, &dt);
00098
00099 return 0 == dt.tv_sec and unsigned (dt.tv_usec) < prec;
00100 }
00101
00102 }
00103
00104 #endif // ! PHY_EMPTY_HXX_