Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_packet_interface_hpp 6 : #define vnsw_agent_packet_interface_hpp 7 : 8 : ///////////////////////////////////////////////////////////////////////////// 9 : // Implementation of Pkt Interface. Interface is used to exchange packets 10 : // between vrouter to agent 11 : ///////////////////////////////////////////////////////////////////////////// 12 : 13 : struct PacketInterfaceData; 14 : 15 : class PacketInterface : public Interface { 16 : public: 17 : PacketInterface(const std::string &name); 18 : virtual ~PacketInterface(); 19 : 20 100 : virtual bool CmpInterface(const DBEntry &rhs) const { return false; } 21 : 22 0 : std::string ToString() const { return "PKT <" + name() + ">"; } 23 : KeyPtr GetDBRequestKey() const; 24 : 25 : // Helper function to enqueue DBRequest to create a Pkt Interface 26 : static void CreateReq(InterfaceTable *table, const std::string &ifname, 27 : Interface::Transport transport); 28 : static void Create(InterfaceTable *table, const std::string &ifname, 29 : Interface::Transport transport); 30 : // Helper function to enqueue DBRequest to delete a Pkt Interface 31 : static void DeleteReq(InterfaceTable *table, const std::string &ifname); 32 : static void Delete(InterfaceTable *table, const std::string &ifname); 33 : void PostAdd(); 34 : bool Delete(const DBRequest *req); 35 : bool OnChange(PacketInterfaceData *data); 36 : virtual void ObtainOsSpecificParams(const std::string &name, Agent *agent); 37 : 38 : private: 39 : DISALLOW_COPY_AND_ASSIGN(PacketInterface); 40 : }; 41 : 42 : struct PacketInterfaceKey : public InterfaceKey { 43 61 : PacketInterfaceKey(const boost::uuids::uuid &uuid, 44 61 : const std::string &name) : 45 : InterfaceKey(AgentKey::ADD_DEL_CHANGE, Interface::PACKET, uuid, name, 46 61 : false) { 47 61 : } 48 : 49 176 : virtual ~PacketInterfaceKey() {} 50 : 51 53 : Interface *AllocEntry(const InterfaceTable *table) const { 52 53 : return new PacketInterface(name_); 53 : } 54 2 : Interface *AllocEntry(const InterfaceTable *table, 55 : const InterfaceData *data) const { 56 2 : return new PacketInterface(name_); 57 : } 58 : 59 27 : InterfaceKey *Clone() const { 60 27 : return new PacketInterfaceKey(*this); 61 : } 62 : }; 63 : 64 : struct PacketInterfaceData : public InterfaceData { 65 2 : PacketInterfaceData(Interface::Transport transport) : 66 2 : InterfaceData(NULL, NULL, transport) { 67 2 : PktInit(); 68 2 : } 69 : }; 70 : 71 : #endif // vnsw_agent_packet_interface_hpp