OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ksync_netlink.h
Go to the documentation of this file.
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 #include <tbb/atomic.h>
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:
23  KSyncNetlinkEntry(uint32_t index) : KSyncEntry(index) { };
24  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  virtual int MsgLen() { return kDefaultMsgSize; }
34  bool Add();
35  bool Change();
36  bool Delete();
37  virtual bool Sync() = 0;
38  virtual bool AllowDeleteStateComp() {return true;}
39 private:
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
52 public:
54  KSyncNetlinkDBEntry(uint32_t index) : KSyncDBEntry(index) { };
55  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  virtual int MsgLen() { return kDefaultMsgSize; }
65  bool Add();
66  bool Change();
67  bool Delete();
68 private:
70 };
71 
72 #endif //ctrlplane_ksync_entry_netlink_h
virtual ~KSyncNetlinkEntry()
Definition: ksync_netlink.h:24
virtual bool Sync()=0
DISALLOW_COPY_AND_ASSIGN(KSyncNetlinkDBEntry)
virtual int DeleteMsg(char *msg, int len)=0
virtual ~KSyncNetlinkDBEntry()
Definition: ksync_netlink.h:55
static const int kDefaultMsgSize
Definition: ksync_entry.h:70
virtual int DeleteMsg(char *msg, int len)=0
virtual int ChangeMsg(char *msg, int len)=0
virtual int MsgLen()
Definition: ksync_netlink.h:33
virtual int MsgLen()
Definition: ksync_netlink.h:64
KSyncNetlinkDBEntry(uint32_t index)
Definition: ksync_netlink.h:54
DISALLOW_COPY_AND_ASSIGN(KSyncNetlinkEntry)
virtual int ChangeMsg(char *msgi, int len)=0
virtual bool AllowDeleteStateComp()
Definition: ksync_netlink.h:38
KSyncNetlinkEntry(uint32_t index)
Definition: ksync_netlink.h:23
virtual int AddMsg(char *msg, int len)=0
virtual int AddMsg(char *msg, int len)=0