|
xorp
|
00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- 00002 // vim:set sts=4 ts=8: 00003 00004 // Copyright (c) 2008-2011 XORP, Inc and Others 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License, Version 2, June 00008 // 1991 as published by the Free Software Foundation. Redistribution 00009 // and/or modification of this program under the terms of any other 00010 // version of the GNU General Public License is not permitted. 00011 // 00012 // This program is distributed in the hope that it will be useful, but 00013 // WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, 00015 // see the GNU General Public License, Version 2, a copy of which can be 00016 // found in the XORP LICENSE.gpl file. 00017 // 00018 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; 00019 // http://xorp.net 00020 00021 // $XORP: xorp/vrrp/vrrp_vif.hh,v 1.10 2008/12/18 11:34:52 abittau Exp $ 00022 00023 #ifndef __VRRP_VRRP_VIF_HH__ 00024 #define __VRRP_VRRP_VIF_HH__ 00025 00026 00027 00028 00029 #include "libxorp/ipv4.hh" 00030 #include "libfeaclient/ifmgr_atoms.hh" 00031 #include "libxipc/xrl_error.hh" 00032 00033 //#include "vrrp.hh" 00034 //#include "vrrp_interface.hh" 00035 00036 class VrrpTarget; 00037 class Vrrp; 00038 00044 class VrrpVif { 00045 public: 00046 typedef set<uint8_t> VRIDS; 00047 00053 VrrpVif(VrrpTarget& vt, const string& ifname, const string& vifname); 00054 ~VrrpVif(); 00055 00056 VrrpTarget& get_vrrp_target() { return _vt; } 00057 00064 bool own(const IPv4& addr); 00065 00072 Vrrp* find_vrid(uint32_t vrid); 00073 00079 void add_vrid(uint32_t vrid); 00080 00086 void delete_vrid(uint32_t vrid); 00087 00093 bool ready() const; 00094 00100 void configure(const IfMgrIfTree& conf); 00101 00107 const IPv4& addr() const; 00108 00117 void send(const Mac& src, const Mac& dst, uint32_t ether, 00118 const vector<uint8_t>& payload); 00119 00123 void join_mcast(); 00124 00128 void leave_mcast(); 00129 00136 void recv(const IPv4& from, const vector<uint8_t>& payload); 00137 00143 void add_mac(const Mac& mac); 00144 void add_ip(const IPv4& ip, uint32_t prefix); 00145 00151 void delete_mac(const Mac& mac); 00152 00153 void delete_ip(const IPv4& ip); 00154 00158 void start_arps(); 00159 00163 void stop_arps(); 00164 00171 void recv_arp(const Mac& src, const vector<uint8_t>& payload); 00172 00178 void get_vrids(VRIDS& vrids); 00179 00185 void xrl_cb(const XrlError& xrl_error); 00186 00187 private: 00188 typedef set<IPv4> IPS; 00189 typedef map<uint32_t, Vrrp*> VRRPS; 00190 00197 void set_ready(bool ready); 00198 00206 template <class T> bool is_enabled(const T* obj); 00207 00208 VrrpTarget& _vt; 00209 string _ifname; 00210 string _vifname; 00211 bool _ready; // is it configured? 00212 IPS _ips; // IPs assigned to this vif 00213 VRRPS _vrrps; // VRRPs enabled on this vif 00214 uint32_t _join; 00215 uint32_t _arps; 00216 }; 00217 00218 #endif // __VRRP_VRRP_VIF_HH__