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