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 1040 : 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 530 : PacketInterfaceKey(const boost::uuids::uuid &uuid, 45 530 : const std::string &name) : 46 : InterfaceKey(AgentKey::ADD_DEL_CHANGE, Interface::PACKET, uuid, name, 47 530 : false) { 48 530 : } 49 : 50 2056 : virtual ~PacketInterfaceKey() {} 51 : 52 522 : Interface *AllocEntry(const InterfaceTable *table) const { 53 522 : return new PacketInterface(name_); 54 : } 55 2 : Interface *AllocEntry(const InterfaceTable *table, 56 : const InterfaceData *data) const { 57 2 : return new PacketInterface(name_); 58 : } 59 : 60 498 : InterfaceKey *Clone() const { 61 498 : return new PacketInterfaceKey(*this); 62 : } 63 : }; 64 : 65 : struct PacketInterfaceData : public InterfaceData { 66 2 : PacketInterfaceData(Interface::Transport transport) : 67 2 : InterfaceData(NULL, NULL, transport) { 68 2 : PktInit(); 69 2 : } 70 : }; 71 : 72 : #endif // vnsw_agent_packet_interface_hpp