Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef __VNSW_AGENT_QOS_CONFIG_KSYNC_H__ 6 : #define __VNSW_AGENT_QOS_CONFIG_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/qos_queue.h" 15 : #include "oper/forwarding_class.h" 16 : #include "oper/qos_config.h" 17 : class KSync; 18 : class QosConfigKSyncObject; 19 : 20 : class QosConfigKSyncEntry : public KSyncNetlinkDBEntry { 21 : public: 22 : static const uint32_t kDefaultQosMsgSize = 4096; 23 : typedef std::pair<uint32_t, KSyncEntryPtr> KSyncQosFcPair; 24 : typedef std::map<uint32_t, KSyncEntryPtr> KSyncQosFcMap; 25 : 26 : QosConfigKSyncEntry(QosConfigKSyncObject *obj, 27 : const QosConfigKSyncEntry *entry); 28 : QosConfigKSyncEntry(QosConfigKSyncObject *obj, 29 : const AgentQosConfig *qc); 30 : virtual ~QosConfigKSyncEntry(); 31 : 32 : KSyncDBObject *GetObject() const; 33 : virtual bool IsLess(const KSyncEntry &rhs) const; 34 : virtual std::string ToString() const; 35 : virtual KSyncEntry *UnresolvedReference(); 36 : virtual bool Sync(DBEntry *e); 37 : virtual int AddMsg(char *buf, int buf_len); 38 : virtual int ChangeMsg(char *buf, int buf_len); 39 : virtual int DeleteMsg(char *buf, int buf_len); 40 0 : boost::uuids::uuid uuid() const { return uuid_;} 41 0 : uint32_t id() const { return id_;} 42 0 : int MsgLen() { return kDefaultQosMsgSize; } 43 : private: 44 : bool CopyQosMap(KSyncQosFcMap &ksync_map, 45 : const AgentQosConfig::QosIdForwardingClassMap *map); 46 : 47 : KSyncDBObject *ksync_obj_; 48 : boost::uuids::uuid uuid_; 49 : uint32_t id_; 50 : KSyncQosFcMap dscp_map_; 51 : KSyncQosFcMap vlan_priority_map_; 52 : KSyncQosFcMap mpls_exp_map_; 53 : uint32_t default_forwarding_class_; 54 : int Encode(sandesh_op::type op, char *buf, int buf_len); 55 : DISALLOW_COPY_AND_ASSIGN(QosConfigKSyncEntry); 56 : }; 57 : 58 : class QosConfigKSyncObject : public KSyncDBObject { 59 : public: 60 : QosConfigKSyncObject(KSync *ksync); 61 : virtual ~QosConfigKSyncObject(); 62 : KSync *ksync() const { return ksync_; } 63 : virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index); 64 : virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e); 65 : void RegisterDBClients(); 66 : private: 67 : KSync *ksync_; 68 : DISALLOW_COPY_AND_ASSIGN(QosConfigKSyncObject); 69 : }; 70 : #endif