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