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