Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef hbf_agent_oper_hpp 6 : #define hbf_agent_oper_hpp 7 : 8 : #include <netinet/in.h> 9 : #include <net/ethernet.h> 10 : #include <cmn/agent_cmn.h> 11 : #include <cmn/agent.h> 12 : #include <oper/vn.h> 13 : #include <oper/agent_route_walker.h> 14 : 15 : extern SandeshTraceBufferPtr HBFTraceBuf; 16 : 17 : #define HBFTRACE(obj, ...) \ 18 : do { \ 19 : HBF##obj::TraceMsg(HBFTraceBuf, __FILE__, __LINE__, __VA_ARGS__); \ 20 : } while (false) 21 : 22 : struct HBFIntfDBState : DBState { 23 0 : HBFIntfDBState(bool lintf, std::string projname) : 24 0 : lintf_(lintf), projname_(projname){} 25 : AgentRouteWalkerPtr vrf_walker_; 26 : bool lintf_; //Is left interface? 27 : std::string projname_; 28 : }; 29 : 30 : class HBFHandler { 31 : public: 32 : HBFHandler(Agent *agent); 33 4 : virtual ~HBFHandler() { 34 4 : } 35 : 36 : //Registered for VMI notification 37 : void ModifyVmInterface(DBTablePartBase *partition, DBEntryBase *e); 38 : void Register(); 39 : bool IsHBFLInterface(VmInterface *vm_itf); 40 : bool IsHBFRInterface(VmInterface *vm_itf); 41 : 42 : void Terminate(); 43 : const Agent *agent() const {return agent_;} 44 : 45 : private: 46 : Agent *agent_; 47 : 48 : DBTable::ListenerId interface_listener_id_; 49 : DISALLOW_COPY_AND_ASSIGN(HBFHandler); 50 : }; 51 : 52 : class HBFVrfWalker : public AgentRouteWalker { 53 : public: 54 : HBFVrfWalker(const std::string &name, Agent *agent); 55 : virtual ~HBFVrfWalker(); 56 : 57 : void Start(uint32_t hbf_intf_, bool hbf_lintf_, std::string projname); 58 : virtual bool VrfWalkNotify(DBTablePartBase *partition, DBEntryBase *e); 59 : 60 0 : static void WalkDone(HBFVrfWalker *walker) { 61 0 : LOG(ERROR, "HBF, walk done, releasing the walker"); 62 0 : walker->mgr()->ReleaseWalker(walker); 63 0 : } 64 : 65 : private: 66 : uint32_t hbf_intf_; 67 : bool hbf_lintf_; 68 : std::string projname_; 69 : DISALLOW_COPY_AND_ASSIGN(HBFVrfWalker); 70 : }; 71 : #endif