00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00030 #ifndef RECEIVER_HPP
00031 #define RECEIVER_HPP
00032
00033 #include "include/proxy/worker.hpp"
00034 #include "include/utils/mroute_socket.hpp"
00035 #include "include/utils/addr_storage.hpp"
00036 #include "include/utils/if_prop.hpp"
00037
00038 #include <map>
00039 #include "boost/thread.hpp"
00040 #include "boost/thread/mutex.hpp"
00041
00042 class proxy_instance;
00043
00047 #define RECEIVER_RECV_TIMEOUT 100 //msec
00048
00049
00050
00056 typedef std::map<int, proxy_instance*> if_poxy_instance_map;
00057
00063 typedef std::pair<int, proxy_instance*> if_proxy_instance_pair;
00064
00065
00066
00073 typedef map<int, int> vif_map;
00074
00081 typedef pair<int, int> vif_pair;
00082
00086 class receiver{
00087 private:
00088 bool m_running;
00089 boost::thread* m_worker_thread;
00090 static void worker_thread(void* arg);
00091
00092 bool init_if_prop();
00093
00094 boost::mutex m_data_lock;
00095 vif_map m_vif_map;
00096
00097 void close();
00098 protected:
00102 if_poxy_instance_map m_if_proxy_map;
00103
00107 if_prop m_if_property;
00108
00112 mroute_socket* m_mrt_sock;
00113
00117 int m_addr_family;
00118
00122 int m_version;
00123
00127 virtual int get_ctrl_min_size()=0;
00128
00132 virtual int get_iov_min_size()=0;
00133
00139 virtual void analyse_packet(struct msghdr* msg, int info_size)=0;
00140
00141
00147 proxy_instance* get_proxy_instance(int if_index);
00148
00149
00155 int get_if_index(int vif);
00156 public:
00160 receiver();
00161
00165 ~receiver();
00166
00174 virtual bool init(int addr_family, int version, mroute_socket* mrt_sock);
00175
00182 void registrate_interface(int if_index, int vif, proxy_instance* p);
00183
00189 void del_interface(int if_index, int vif);
00190
00194 bool is_running();
00195
00199 void start();
00200
00204 void stop();
00205
00209 void join();
00210 };
00211
00212
00213 #endif // RECEIVER_HPP
00214