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_mpls_ksync_h 7 : #define vnsw_agent_mpls_ksync_h 8 : 9 : #include <db/db_entry.h> 10 : #include <db/db_table.h> 11 : #include <db/db_table_partition.h> 12 : #include <ksync/ksync_entry.h> 13 : #include <ksync/ksync_object.h> 14 : #include <ksync/ksync_netlink.h> 15 : #include "oper/mpls.h" 16 : #include "vrouter/ksync/nexthop_ksync.h" 17 : 18 : class MplsKSyncObject; 19 : 20 : class MplsKSyncEntry : public KSyncNetlinkDBEntry { 21 : public: 22 : MplsKSyncEntry(MplsKSyncObject* obj, const MplsKSyncEntry *entry, 23 : uint32_t index); 24 : MplsKSyncEntry(MplsKSyncObject* obj, const MplsLabel *label); 25 : virtual ~MplsKSyncEntry(); 26 : 27 21770 : NHKSyncEntry *nh() const { 28 21770 : return static_cast<NHKSyncEntry *>(nh_.get()); 29 : } 30 : KSyncDBObject *GetObject() const; 31 : 32 : virtual bool IsLess(const KSyncEntry &rhs) const; 33 : virtual std::string ToString() const; 34 : virtual KSyncEntry *UnresolvedReference(); 35 : virtual bool Sync(DBEntry *e); 36 : virtual int AddMsg(char *buf, int buf_len); 37 : virtual int ChangeMsg(char *buf, int buf_len); 38 : virtual int DeleteMsg(char *buf, int buf_len); 39 : void FillObjectLog(sandesh_op::type op, KSyncMplsInfo &info) const; 40 : private: 41 : int Encode(sandesh_op::type op, char *buf, int buf_len); 42 : MplsKSyncObject *ksync_obj_; 43 : uint32_t label_; 44 : KSyncEntryPtr nh_; 45 : DISALLOW_COPY_AND_ASSIGN(MplsKSyncEntry); 46 : }; 47 : 48 : class MplsKSyncObject : public KSyncDBObject { 49 : public: 50 : static const int kMplsIndexCount = 128 * 1024; // support 128K mpls labels 51 : MplsKSyncObject(KSync *ksync); 52 : virtual ~MplsKSyncObject(); 53 1334 : KSync *ksync() const { return ksync_; } 54 : virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index); 55 : virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e); 56 : void RegisterDBClients(); 57 : private: 58 : KSync *ksync_; 59 : DISALLOW_COPY_AND_ASSIGN(MplsKSyncObject); 60 : }; 61 : 62 : #endif // vnsw_agent_mpls_ksync_h