summaryrefslogtreecommitdiffstats
path: root/session.hpp
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-10-12 13:20:49 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-11-02 15:44:15 -0700
commit9e801a2b5b36acd307606af5eafdb885dfe8daee (patch)
tree87d6cdef2c9008d76e9a99784e83f2b3af90ebc0 /session.hpp
parentf6110552bd0e940efe51eb11c0415bebb2ab883f (diff)
downloadphosphor-net-ipmid-9e801a2b5b36acd307606af5eafdb885dfe8daee.tar.gz
phosphor-net-ipmid-9e801a2b5b36acd307606af5eafdb885dfe8daee.zip
netipmid: apply clang-format rules
Lots of whitespace change. Let clang-format do its job and keep the code looking nice. Change-Id: Idfcad1a99cab8170d55a06163de8ad3f420b68b7 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'session.hpp')
-rw-r--r--session.hpp382
1 files changed, 189 insertions, 193 deletions
diff --git a/session.hpp b/session.hpp
index f010a49..338a815 100644
--- a/session.hpp
+++ b/session.hpp
@@ -1,5 +1,11 @@
#pragma once
+#include "auth_algo.hpp"
+#include "crypt_algo.hpp"
+#include "endian.hpp"
+#include "integrity_algo.hpp"
+#include "socket_channel.hpp"
+
#include <chrono>
#include <exception>
#include <list>
@@ -7,12 +13,6 @@
#include <string>
#include <vector>
-#include "auth_algo.hpp"
-#include "crypt_algo.hpp"
-#include "integrity_algo.hpp"
-#include "endian.hpp"
-#include "socket_channel.hpp"
-
namespace session
{
@@ -31,10 +31,10 @@ enum class Privilege : uint8_t
enum class State
{
- INACTIVE, // Session is not in use
- SETUP_IN_PROGRESS, // Session Setup Sequence is progressing
- ACTIVE, // Session is active
- TEAR_DOWN_IN_PROGRESS,// When Closing Session
+ INACTIVE, // Session is not in use
+ SETUP_IN_PROGRESS, // Session Setup Sequence is progressing
+ ACTIVE, // Session is active
+ TEAR_DOWN_IN_PROGRESS, // When Closing Session
};
// Seconds of inactivity allowed during session setup stage
@@ -60,24 +60,24 @@ constexpr auto SESSION_INACTIVITY_TIMEOUT = 60s;
*/
struct SequenceNumbers
{
- auto get(bool inbound = true) const
- {
- return inbound ? in : out;
- }
-
- void set(uint32_t seqNumber, bool inbound = true)
- {
- inbound ? (in = seqNumber) : (out = seqNumber);
- }
-
- auto increment()
- {
- return ++out;
- }
-
- private:
- uint32_t in = 0;
- uint32_t out = 0;
+ auto get(bool inbound = true) const
+ {
+ return inbound ? in : out;
+ }
+
+ void set(uint32_t seqNumber, bool inbound = true)
+ {
+ inbound ? (in = seqNumber) : (out = seqNumber);
+ }
+
+ auto increment()
+ {
+ return ++out;
+ }
+
+ private:
+ uint32_t in = 0;
+ uint32_t out = 0;
};
/**
* @class Session
@@ -93,183 +93,179 @@ struct SequenceNumbers
*/
class Session
{
- public:
-
- Session() = default;
- ~Session() = default;
- Session(const Session&) = delete;
- Session& operator=(const Session&) = delete;
- Session(Session&&) = default;
- Session& operator=(Session&&) = default;
-
- /**
- * @brief Session Constructor
- *
- * This is issued by the Session Manager when a session is started for
- * the Open SessionRequest command
- *
- * @param[in] inRemoteConsoleSessID - Remote Console Session ID
- * @param[in] priv - Privilege Level requested in the Command
- */
- Session(SessionID inRemoteConsoleSessID, Privilege priv):
- curPrivLevel(priv),
- bmcSessionID(std::rand()),
- remoteConsoleSessionID(inRemoteConsoleSessID) {}
-
- auto getBMCSessionID() const
- {
- return bmcSessionID;
- }
-
- auto getRCSessionID() const
- {
- return remoteConsoleSessionID;
- }
-
- auto getAuthAlgo() const
+ public:
+ Session() = default;
+ ~Session() = default;
+ Session(const Session&) = delete;
+ Session& operator=(const Session&) = delete;
+ Session(Session&&) = default;
+ Session& operator=(Session&&) = default;
+
+ /**
+ * @brief Session Constructor
+ *
+ * This is issued by the Session Manager when a session is started for
+ * the Open SessionRequest command
+ *
+ * @param[in] inRemoteConsoleSessID - Remote Console Session ID
+ * @param[in] priv - Privilege Level requested in the Command
+ */
+ Session(SessionID inRemoteConsoleSessID, Privilege priv) :
+ curPrivLevel(priv), bmcSessionID(std::rand()),
+ remoteConsoleSessionID(inRemoteConsoleSessID)
+ {
+ }
+
+ auto getBMCSessionID() const
+ {
+ return bmcSessionID;
+ }
+
+ auto getRCSessionID() const
+ {
+ return remoteConsoleSessionID;
+ }
+
+ auto getAuthAlgo() const
+ {
+ if (authAlgoInterface)
{
- if(authAlgoInterface)
- {
- return authAlgoInterface.get();
- }
- else
- {
- throw std::runtime_error("Authentication Algorithm Empty");
- }
+ return authAlgoInterface.get();
}
-
- void setAuthAlgo(std::unique_ptr<cipher::rakp_auth::Interface>&&
- inAuthAlgo)
+ else
{
- authAlgoInterface = std::move(inAuthAlgo);
+ throw std::runtime_error("Authentication Algorithm Empty");
}
-
- /**
- * @brief Get Session's Integrity Algorithm
- *
- * @return pointer to the integrity algorithm
- */
- auto getIntegrityAlgo() const
+ }
+
+ void setAuthAlgo(std::unique_ptr<cipher::rakp_auth::Interface>&& inAuthAlgo)
+ {
+ authAlgoInterface = std::move(inAuthAlgo);
+ }
+
+ /**
+ * @brief Get Session's Integrity Algorithm
+ *
+ * @return pointer to the integrity algorithm
+ */
+ auto getIntegrityAlgo() const
+ {
+ if (integrityAlgoInterface)
{
- if(integrityAlgoInterface)
- {
- return integrityAlgoInterface.get();
- }
- else
- {
- throw std::runtime_error("Integrity Algorithm Empty");
- }
+ return integrityAlgoInterface.get();
}
-
- /**
- * @brief Set Session's Integrity Algorithm
- *
- * @param[in] integrityAlgo - unique pointer to integrity algorithm
- * instance
- */
- void setIntegrityAlgo(
- std::unique_ptr<cipher::integrity::Interface>&& integrityAlgo)
- {
- integrityAlgoInterface = std::move(integrityAlgo);
- }
-
- /** @brief Check if integrity algorithm is enabled for this session.
- *
- * @return true if integrity algorithm is enabled else false.
- */
- auto isIntegrityAlgoEnabled()
- {
- return integrityAlgoInterface ? true : false;
- }
-
- /**
- * @brief Get Session's Confidentiality Algorithm
- *
- * @return pointer to the confidentiality algorithm
- */
- auto getCryptAlgo() const
- {
- if(cryptAlgoInterface)
- {
- return cryptAlgoInterface.get();
- }
- else
- {
- throw std::runtime_error("Confidentiality Algorithm Empty");
- }
- }
-
- /**
- * @brief Set Session's Confidentiality Algorithm
- *
- * @param[in] confAlgo - unique pointer to confidentiality algorithm
- * instance
- */
- void setCryptAlgo(
- std::unique_ptr<cipher::crypt::Interface>&& cryptAlgo)
+ else
{
- cryptAlgoInterface = std::move(cryptAlgo);
+ throw std::runtime_error("Integrity Algorithm Empty");
}
-
- /** @brief Check if confidentiality algorithm is enabled for this
- * session.
- *
- * @return true if confidentiality algorithm is enabled else false.
- */
- auto isCryptAlgoEnabled()
+ }
+
+ /**
+ * @brief Set Session's Integrity Algorithm
+ *
+ * @param[in] integrityAlgo - unique pointer to integrity algorithm
+ * instance
+ */
+ void setIntegrityAlgo(
+ std::unique_ptr<cipher::integrity::Interface>&& integrityAlgo)
+ {
+ integrityAlgoInterface = std::move(integrityAlgo);
+ }
+
+ /** @brief Check if integrity algorithm is enabled for this session.
+ *
+ * @return true if integrity algorithm is enabled else false.
+ */
+ auto isIntegrityAlgoEnabled()
+ {
+ return integrityAlgoInterface ? true : false;
+ }
+
+ /**
+ * @brief Get Session's Confidentiality Algorithm
+ *
+ * @return pointer to the confidentiality algorithm
+ */
+ auto getCryptAlgo() const
+ {
+ if (cryptAlgoInterface)
{
- return cryptAlgoInterface ? true : false;
+ return cryptAlgoInterface.get();
}
-
- void updateLastTransactionTime()
+ else
{
- lastTime = std::chrono::steady_clock::now();
+ throw std::runtime_error("Confidentiality Algorithm Empty");
}
-
- /**
- * @brief Session Active Status
- *
- * Session Active status is decided upon the Session State and the last
- * transaction time is compared against the session inactivity timeout.
- *
- */
- bool isSessionActive();
-
- /**
- * @brief Session's Current Privilege Level
- */
- Privilege curPrivLevel;
-
- /**
- * @brief Session's Maximum Privilege Level
- */
- Privilege maxPrivLevel = Privilege::CALLBACK;
-
- SequenceNumbers sequenceNums; // Session Sequence Numbers
- State state = State::INACTIVE; // Session State
- std::string userName {}; // User Name
-
- /** @brief Socket channel for communicating with the remote client.*/
- std::shared_ptr<udpsocket::Channel> channelPtr;
-
- private:
-
- SessionID bmcSessionID = 0; //BMC Session ID
- SessionID remoteConsoleSessionID = 0; //Remote Console Session ID
-
- // Authentication Algorithm Interface for the Session
- std::unique_ptr<cipher::rakp_auth::Interface> authAlgoInterface;
-
- // Integrity Algorithm Interface for the Session
- std::unique_ptr<cipher::integrity::Interface> integrityAlgoInterface =
- nullptr;
-
- // Confidentiality Algorithm Interface for the Session
- std::unique_ptr<cipher::crypt::Interface> cryptAlgoInterface =
- nullptr;
-
- // Last Transaction Time
- decltype(std::chrono::steady_clock::now()) lastTime;
+ }
+
+ /**
+ * @brief Set Session's Confidentiality Algorithm
+ *
+ * @param[in] confAlgo - unique pointer to confidentiality algorithm
+ * instance
+ */
+ void setCryptAlgo(std::unique_ptr<cipher::crypt::Interface>&& cryptAlgo)
+ {
+ cryptAlgoInterface = std::move(cryptAlgo);
+ }
+
+ /** @brief Check if confidentiality algorithm is enabled for this
+ * session.
+ *
+ * @return true if confidentiality algorithm is enabled else false.
+ */
+ auto isCryptAlgoEnabled()
+ {
+ return cryptAlgoInterface ? true : false;
+ }
+
+ void updateLastTransactionTime()
+ {
+ lastTime = std::chrono::steady_clock::now();
+ }
+
+ /**
+ * @brief Session Active Status
+ *
+ * Session Active status is decided upon the Session State and the last
+ * transaction time is compared against the session inactivity timeout.
+ *
+ */
+ bool isSessionActive();
+
+ /**
+ * @brief Session's Current Privilege Level
+ */
+ Privilege curPrivLevel;
+
+ /**
+ * @brief Session's Maximum Privilege Level
+ */
+ Privilege maxPrivLevel = Privilege::CALLBACK;
+
+ SequenceNumbers sequenceNums; // Session Sequence Numbers
+ State state = State::INACTIVE; // Session State
+ std::string userName{}; // User Name
+
+ /** @brief Socket channel for communicating with the remote client.*/
+ std::shared_ptr<udpsocket::Channel> channelPtr;
+
+ private:
+ SessionID bmcSessionID = 0; // BMC Session ID
+ SessionID remoteConsoleSessionID = 0; // Remote Console Session ID
+
+ // Authentication Algorithm Interface for the Session
+ std::unique_ptr<cipher::rakp_auth::Interface> authAlgoInterface;
+
+ // Integrity Algorithm Interface for the Session
+ std::unique_ptr<cipher::integrity::Interface> integrityAlgoInterface =
+ nullptr;
+
+ // Confidentiality Algorithm Interface for the Session
+ std::unique_ptr<cipher::crypt::Interface> cryptAlgoInterface = nullptr;
+
+ // Last Transaction Time
+ decltype(std::chrono::steady_clock::now()) lastTime;
};
} // namespace session
OpenPOWER on IntegriCloud