00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_FRAME_FILTER_ANON_POLICIES_HH_
00023 # define WIFI_FRAME_FILTER_ANON_POLICIES_HH_
00024
00025 # include <map>
00026 # include <set>
00027
00028 # include <boost/array.hpp>
00029
00030 # include <wipal/tool/mapping.hh>
00031 # include <wipal/wifi/addr.hh>
00032 # include <wipal/wifi/essid.hh>
00033
00034 namespace wifi
00035 {
00036
00037 namespace frame
00038 {
00039
00040 namespace anon
00041 {
00042
00043
00044
00045
00046
00047 namespace internals
00048 {
00049
00050 struct ppmp_mapping_factory
00051 {
00052 typedef std::map<addr, addr> mac_map;
00053
00054 addr new_value(const addr& a,
00055 const mac_map& );
00056 void value_loaded(const addr& ,
00057 const addr& a,
00058 const mac_map& );
00059
00060 private:
00061 std::set<addr> values_;
00062 };
00063
00064 }
00065
00066 typedef
00067 tool::mapping<addr, addr, internals::ppmp_mapping_factory>
00068 prefix_preserving_mac_policy;
00069
00070
00071
00072
00073
00074 namespace internals
00075 {
00076
00077 struct ppep_mapping_factory
00078 {
00079 typedef std::map<essid, essid> essid_map;
00080
00081 ppep_mapping_factory();
00082
00083 essid new_value(const essid& e,
00084 const essid_map& m);
00085 void value_loaded(const essid& from,
00086 const essid& to,
00087 const essid_map& );
00088 private:
00089
00090 struct node;
00091
00092 std::pair<std::string, node*>
00093 longest_anonymized_prefix(const essid& orig_essid);
00094
00095
00096
00097
00098
00099
00100 struct node
00101 {
00102 node* child(unsigned char c);
00103 std::pair<char, node*> add_valued_child(unsigned char c);
00104 node* add_valued_child(unsigned char c,
00105 unsigned char value);
00106
00107 virtual ~node();
00108
00109 private:
00110 static unsigned char rand_extended();
00111 static unsigned char rand_alnum();
00112 static unsigned char rand_print();
00113 static unsigned char rand_other();
00114 static unsigned char rand_same_class(unsigned char c);
00115
00116 private:
00117 boost::array<std::auto_ptr<node>, 256> children_;
00118 std::set<char> children_values_;
00119 };
00120
00121 struct valued_node: public node
00122 {
00123 valued_node(char value);
00124
00125 char value;
00126 };
00127
00128
00129
00130
00131
00132 boost::shared_ptr<node> root_;
00133 };
00134
00135 }
00136
00137 typedef
00138 tool::mapping<essid, essid, internals::ppep_mapping_factory>
00139 prefix_preserving_essid_policy;
00140
00141 }
00142
00143 }
00144
00145 }
00146
00147 # include "anon_policies.hxx"
00148
00149 #endif // ! WIFI_FRAME_FILTER_ANON_POLICIES_HH_