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 ctrlplane_ksync_entry_netlink_h 7 : #define ctrlplane_ksync_entry_netlink_h 8 : 9 : #include <boost/intrusive_ptr.hpp> 10 : 11 : class KSyncObject; 12 : 13 : // Implementation of KSyncEntry with Netlink ASIO as backend to send message 14 : // Use this class in cases where KSyncEntry state-machine should be controlled 15 : // by application 16 : // 17 : // Replaces virtual functions Add with AddMsg, Change with ChangeMsg and Delete 18 : // with DeleteMsg. Uses KSyncSock in backend to send/receives netlink message 19 : // to kernel 20 : class KSyncNetlinkEntry : public KSyncEntry { 21 : public: 22 10184 : KSyncNetlinkEntry() : KSyncEntry() { }; 23 : KSyncNetlinkEntry(uint32_t index) : KSyncEntry(index) { }; 24 10184 : virtual ~KSyncNetlinkEntry() { }; 25 : 26 : // Generate netlink add message for the object 27 : virtual int AddMsg(char *msg, int len) = 0; 28 : // Generate netlink change message for the object 29 : virtual int ChangeMsg(char *msgi, int len) = 0; 30 : // Generate netlink delete message for the object 31 : virtual int DeleteMsg(char *msg, int len) = 0; 32 : 33 378 : virtual int MsgLen() { return kDefaultMsgSize; } 34 : bool Add(); 35 : bool Change(); 36 : bool Delete(); 37 : virtual bool Sync() = 0; 38 0 : virtual bool AllowDeleteStateComp() {return true;} 39 : private: 40 : DISALLOW_COPY_AND_ASSIGN(KSyncNetlinkEntry); 41 : }; 42 : 43 : // Implementation of KSyncDBEntry with Netlink ASIO as backend to send message 44 : // Use this class in cases where KSyncEntry state-machine should be managed 45 : // by DBTable notification. 46 : // Applications are not needed to generate any events to the state-machine 47 : // 48 : // Replaces virtual functions Add with AddMsg, Change with ChangeMsg and Delete 49 : // with DeleteMsg. Uses KSyncSock in backend to send/receives netlink message 50 : // to kernel 51 : class KSyncNetlinkDBEntry : public KSyncDBEntry { 52 : public: 53 38 : KSyncNetlinkDBEntry() : KSyncDBEntry() { }; 54 37185 : KSyncNetlinkDBEntry(uint32_t index) : KSyncDBEntry(index) { }; 55 37223 : virtual ~KSyncNetlinkDBEntry() { }; 56 : 57 : // Generate netlink add message for the object 58 : virtual int AddMsg(char *msg, int len) = 0; 59 : // Generate netlink change message for the object 60 : virtual int ChangeMsg(char *msg, int len) = 0; 61 : // Generate netlink delete message for the object 62 : virtual int DeleteMsg(char *msg, int len) = 0; 63 : 64 6692 : virtual int MsgLen() { return kDefaultMsgSize; } 65 : bool Add(); 66 : bool Change(); 67 : bool Delete(); 68 : private: 69 : DISALLOW_COPY_AND_ASSIGN(KSyncNetlinkDBEntry); 70 : }; 71 : 72 : #endif //ctrlplane_ksync_entry_netlink_h