00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_HASH_HH_
00023 # define WIFI_HASH_HH_
00024
00025 # include <openssl/md5.h>
00026 # include <boost/array.hpp>
00027
00028 # include <wipal/wifi/unique_id/unique_id.hh>
00029 # include <wipal/proto/udp.hh>
00030 # include <wipal/proto/icmp6.hh>
00031 # include <wipal/proto/ip4.hh>
00032 # include <wipal/proto/ip6.hh>
00033
00034 namespace wpl
00035 {
00036
00037 namespace wifi
00038 {
00039
00040 namespace internals
00041 {
00042
00043 struct hash_value: public boost::array<unsigned char, MD5_DIGEST_LENGTH>
00044 {
00045 hash_value(const void* data, size_t len);
00046 };
00047
00048 bool unique_udp(const udp::header* const, const size_t);
00049 bool unique_icmp6(const icmp6::header* const, const size_t);
00050
00051 bool unique_ip4(const ip4::header* const header,
00052 const size_t caplen,
00053 const ip4::addr* const ignore = 0);
00054
00055 bool unique_ip6(const ip6::header* const header,
00056 const size_t caplen,
00057 const ip6::addr* const ignore = 0);
00058
00059 struct hsh_80211_tag {};
00060 struct hsh_80211_x_tag {};
00061 struct hsh_en2_tag {};
00062
00063 }
00064
00065 typedef unique_id<internals::hash_value,
00066 internals::empty<internals::hsh_80211_tag> >
00067 hsh_80211_id;
00068
00069 typedef unique_id<internals::hash_value,
00070 internals::empty<internals::hsh_80211_x_tag> >
00071 hsh_80211_x_id;
00072
00073 typedef unique_id<internals::hash_value,
00074 internals::empty<internals::hsh_en2_tag> >
00075 hsh_en2_id;
00076
00077 template <>
00078 struct unique_id_factory<hsh_80211_id>
00079 {
00080 template <class HeaderType, class S>
00081 boost::optional<hsh_80211_id>
00082 build(const pkt::packet<S>& packet,
00083 addr_mapping& mapping);
00084 };
00085
00086 template <>
00087 struct unique_id_factory<hsh_80211_x_id>
00088 {
00089 template <class HeaderType, class S>
00090 boost::optional<hsh_80211_x_id>
00091 build(const pkt::packet<S>& packet,
00092 addr_mapping& mapping);
00093 };
00094
00095 template <>
00096 struct unique_id_factory<hsh_en2_id>
00097 {
00098 template <class HeaderType, class S>
00099 boost::optional<hsh_en2_id>
00100 build(const pkt::packet<S>& packet,
00101 addr_mapping& mapping);
00102 };
00103
00104 }
00105
00106 }
00107
00108 WP_HASH_NAMESPACE_BEGIN
00109
00110 template <>
00111 struct hash< wpl::wifi::internals::hash_value >
00112 {
00113 size_t
00114 operator () (const wpl::wifi::internals::hash_value&) const;
00115 };
00116
00117 WP_HASH_NAMESPACE_END
00118
00119 # include "hash.hxx"
00120
00121 #endif // ! WIFI_HASH_HH_