00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00030 #ifndef PROXY_HPP
00031 #define PROXY_HPP
00032
00033 #include "include/utils/addr_storage.hpp"
00034 #include "include/utils/mroute_socket.hpp"
00035 #include "include/utils/if_prop.hpp"
00036 #include "include/proxy/proxy_instance.hpp"
00037 #include "include/proxy/receiver.hpp"
00038
00039 #include <map>
00040 #include <vector>
00041 #include <string>
00042 using namespace std;
00043
00044
00050 typedef map<int, int> vif_map;
00051
00057 typedef pair<int, int> vif_pair;
00058
00059
00060
00065 typedef vector<int> down_vector;
00070 typedef vector<int> down_vector;
00076 typedef map<int, down_vector > up_down_map;
00077
00083 typedef pair<int, down_vector > up_down_pair;
00084
00085
00086
00092 typedef map<int,int > interface_map;
00093
00099 typedef pair<int,int> interface_pair;
00100
00101
00105 #define PROXY_CONFIG_LINE_LENGTH 200
00106
00110 #define PROXY_DEBUG_MSG_TIMEOUT 3000 //msec
00111
00115 #define PROXY_RP_FILTER_PATH "/proc/sys/net/ipv4/conf/"
00116
00120 #define PROXY_DEFAULT_CONIG_PATH "mcproxy.conf"
00121
00125 class proxy{
00126 private:
00127
00128 static bool m_running;
00129 int m_verbose_lvl;
00130 bool m_print_status;
00131
00132 bool m_rest_rp_filter;
00133 vector<string> m_restore_rp_filter_vector;
00134
00135 string m_config_path;
00136 int m_addr_family;
00137 int m_version;
00138
00139
00140 vector<proxy_instance*> m_proxy_instances;
00141 interface_map m_interface_map;
00142 up_down_map m_up_down_map;
00143 vif_map m_vif_map;
00144
00145 receiver* m_receiver;
00146 mroute_socket m_mrt_sock;
00147 if_prop m_if_prop;
00148
00149 int get_free_vif_number();
00150
00151
00152 vector<int> all_if_to_list();
00153
00154
00155
00156
00157
00158 bool prozess_commandline_args(int arg_count, char* args[]);
00159 void help_output();
00160 bool get_rp_filter(string interface);
00161 bool set_rp_filter(string interface, bool to);
00162 bool restore_rp_filter();
00163
00164 bool load_config(string path);
00165
00166
00167
00168 bool check_double_used_if(const vector<int>* new_interfaces);
00169 bool init_vif_map();
00170 bool init_if_prop();
00171 bool check_and_set_flags(vector<int>& interface_list);
00172 bool init_mrt_socket();
00173 bool start_proxy_instances();
00174
00175
00176
00177 static void signal_handler(int sig);
00178 void close();
00179
00180
00181 public:
00185 proxy();
00186
00190 ~proxy();
00191
00195 string get_state_table();
00196
00221 bool init(int arg_count, char* args[]);
00222
00227 bool start();
00228
00232 void end();
00233 };
00234
00235 #endif // PROXY_HPP
00236