mgmt: add capacity and enablement flags to CsInfo
refs #4050
Change-Id: I9363f6735c6917591e0907b3d94f36d7263d10e7
diff --git a/src/mgmt/nfd/cs-info.hpp b/src/mgmt/nfd/cs-info.hpp
index 0b9ad0a..cdd38a9 100644
--- a/src/mgmt/nfd/cs-info.hpp
+++ b/src/mgmt/nfd/cs-info.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,14 +23,16 @@
#define NDN_MGMT_NFD_CS_INFO_HPP
#include "../../encoding/block.hpp"
+#include "../../encoding/nfd-constants.hpp"
+
+#include <bitset>
namespace ndn {
namespace nfd {
-/**
- * \ingroup management
- * \brief represents the CS Information dataset
- * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#CS-Information-Dataset
+/** \ingroup management
+ * \brief represents the CS Information dataset
+ * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#CS-Information-Dataset
*/
class CsInfo
{
@@ -60,6 +62,52 @@
void
wireDecode(const Block& wire);
+ /** \brief get CS capacity (in number of packets)
+ */
+ uint64_t
+ getCapacity() const
+ {
+ return m_capacity;
+ }
+
+ CsInfo&
+ setCapacity(uint64_t capacity);
+
+ /** \brief get CS_ENABLE_ADMIT flag
+ */
+ bool
+ getEnableAdmit() const
+ {
+ return m_flags.test(BIT_CS_ENABLE_ADMIT);
+ }
+
+ CsInfo&
+ setEnableAdmit(bool enableAdmit);
+
+ /** \brief get CS_ENABLE_SERVE flag
+ */
+ bool
+ getEnableServe() const
+ {
+ return m_flags.test(BIT_CS_ENABLE_SERVE);
+ }
+
+ CsInfo&
+ setEnableServe(bool enableServe);
+
+ /** \brief get number of stored CS entries
+ */
+ uint64_t
+ getNEntries() const
+ {
+ return m_nEntries;
+ }
+
+ CsInfo&
+ setNEntries(uint64_t nEntries);
+
+ /** \brief get number of CS lookup hits since NFD starts
+ */
uint64_t
getNHits() const
{
@@ -69,6 +117,8 @@
CsInfo&
setNHits(uint64_t nHits);
+ /** \brief get number of CS lookup misses since NFD starts
+ */
uint64_t
getNMisses() const
{
@@ -79,6 +129,11 @@
setNMisses(uint64_t nMisses);
private:
+ using FlagsBitSet = std::bitset<2>;
+
+ uint64_t m_capacity;
+ FlagsBitSet m_flags;
+ uint64_t m_nEntries;
uint64_t m_nHits;
uint64_t m_nMisses;
mutable Block m_wire;
@@ -96,7 +151,7 @@
}
std::ostream&
-operator<<(std::ostream& os, const CsInfo& status);
+operator<<(std::ostream& os, const CsInfo& csi);
} // namespace nfd
} // namespace ndn