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