OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ovsdb_resource_vxlan_id.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_RESOURCE_VXLAN_ID_H_
6 #define SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_RESOURCE_VXLAN_ID_H_
7 
8 #include <cmn/index_vector.h>
9 
10 namespace OVSDB {
11 class OvsdbResourceVxLanIdCmp;
12 class OvsdbResourceVxLanIdTable;
13 
15 public:
17  KSyncEntry *entry);
18  virtual ~OvsdbResourceVxLanId();
19 
20  // Acquire given VxLan ID, returns true on success
21  // on failure returns false and later once the VxLan ID
22  // is available it triggers Change on the KSyncEntry to
23  // notify
24  bool AcquireVxLanId(uint32_t vxlan_id);
25 
26  // Release the Acquired/Active VxLan ID
27  void ReleaseVxLanId(bool active);
28 
29  // set VxLAN ID actively in use
30  void set_active_vxlan_id(uint32_t vxlan_id);
31 
32  uint32_t VxLanId() const;
33  uint32_t active_vxlan_id() const;
34 
35 private:
40  uint32_t resource_id_;
41  uint32_t vxlan_id_;
42  uint32_t active_vxlan_id_;
44 }; // class OvsdbResourceVxLanId
45 
47 public:
49  OvsdbResourceVxLanId* const rhs) const {
50  if (lhs->resource_id_ != rhs->resource_id_)
51  return lhs->resource_id_ < rhs->resource_id_;
52  return lhs->entry_ < rhs->entry_;
53  }
54 };
55 
57 public:
60 
61 private:
62  friend class OvsdbResourceVxLanId;
63  typedef std::set<OvsdbResourceVxLanId*,
65 
66  bool AcquireVxLanId(OvsdbResourceVxLanId *entry, uint32_t vxlan_id);
67 
68  void ReleaseVxLanId(OvsdbResourceVxLanId *entry, uint32_t vxlan_id,
69  uint32_t resource_id);
70 
71  struct ResourceEntry {
73  }
77  };
78 
79  std::map<uint32_t, ResourceEntry*> vxlan_table_;
81 }; // class OvsdbResourceVxLanIdTable
82 }; // namespace OVSDB
83 
84 #endif //SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_RESOURCE_VXLAN_ID_H_
85 
bool AcquireVxLanId(OvsdbResourceVxLanId *entry, uint32_t vxlan_id)
OvsdbResourceVxLanIdTable * table_
bool AcquireVxLanId(uint32_t vxlan_id)
void set_active_vxlan_id(uint32_t vxlan_id)
DISALLOW_COPY_AND_ASSIGN(OvsdbResourceVxLanId)
OvsdbResourceVxLanId(OvsdbResourceVxLanIdTable *table, KSyncEntry *entry)
std::set< OvsdbResourceVxLanId *, OvsdbResourceVxLanIdCmp > ResourcePendingList
DISALLOW_COPY_AND_ASSIGN(OvsdbResourceVxLanIdTable)
std::map< uint32_t, ResourceEntry * > vxlan_table_
bool operator()(OvsdbResourceVxLanId *const lhs, OvsdbResourceVxLanId *const rhs) const
void ReleaseVxLanId(OvsdbResourceVxLanId *entry, uint32_t vxlan_id, uint32_t resource_id)