OpenSDN source code
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 
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:
22  KSyncNetlinkEntry(uint32_t index) : KSyncEntry(index) { };
23  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  virtual int MsgLen() { return kDefaultMsgSize; }
33  bool Add();
34  bool Change();
35  bool Delete();
36  virtual bool Sync() = 0;
37  virtual bool AllowDeleteStateComp() {return true;}
38 private:
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
51 public:
53  KSyncNetlinkDBEntry(uint32_t index) : KSyncDBEntry(index) { };
54  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  virtual int MsgLen() { return kDefaultMsgSize; }
64  bool Add();
65  bool Change();
66  bool Delete();
67 private:
69 };
70 
71 #endif //ctrlplane_ksync_entry_netlink_h
static const int kDefaultMsgSize
Definition: ksync_entry.h:70
virtual int MsgLen()
Definition: ksync_netlink.h:63
KSyncNetlinkDBEntry(uint32_t index)
Definition: ksync_netlink.h:53
virtual int ChangeMsg(char *msg, int len)=0
DISALLOW_COPY_AND_ASSIGN(KSyncNetlinkDBEntry)
virtual ~KSyncNetlinkDBEntry()
Definition: ksync_netlink.h:54
virtual int DeleteMsg(char *msg, int len)=0
virtual int AddMsg(char *msg, int len)=0
virtual int DeleteMsg(char *msg, int len)=0
virtual bool Sync()=0
virtual int ChangeMsg(char *msgi, int len)=0
virtual int MsgLen()
Definition: ksync_netlink.h:32
DISALLOW_COPY_AND_ASSIGN(KSyncNetlinkEntry)
KSyncNetlinkEntry(uint32_t index)
Definition: ksync_netlink.h:22
virtual int AddMsg(char *msg, int len)=0
virtual ~KSyncNetlinkEntry()
Definition: ksync_netlink.h:23
virtual bool AllowDeleteStateComp()
Definition: ksync_netlink.h:37