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