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