summaryrefslogtreecommitdiffstats
path: root/session.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2016-08-09 08:16:12 -0500
committerTom Joseph <tomjoseph@in.ibm.com>2016-12-12 20:15:47 +0530
commitf0ca513a4c354c772e8c5e228d7b5484ed666381 (patch)
tree91df16eaf2b7d4d4ce167251856efc3f7cabaa8f /session.cpp
parent8c0446c102646b7ba8622594f5b1b808c88a9077 (diff)
downloadphosphor-net-ipmid-f0ca513a4c354c772e8c5e228d7b5484ed666381.tar.gz
phosphor-net-ipmid-f0ca513a4c354c772e8c5e228d7b5484ed666381.zip
Representation of an IPMI session
IPMI session class encapsulates the details regarding an IPMI session. It includes the details of the remote session id, BMC session id Cipher suites, session state information. Change-Id: Iffae0e05f33d1b3aa32cc17e5a3c1368d53c1d38 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'session.cpp')
-rw-r--r--session.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/session.cpp b/session.cpp
new file mode 100644
index 0000000..b80f51a
--- /dev/null
+++ b/session.cpp
@@ -0,0 +1,33 @@
+#include "session.hpp"
+
+#include <ctime>
+
+#include "endian.hpp"
+
+namespace session
+{
+
+bool Session::isSessionActive()
+{
+ auto currentTime = std::chrono::steady_clock::now();
+ auto elapsedSeconds = std::chrono::duration_cast<std::chrono::seconds>
+ (currentTime - lastTime);
+
+ switch (state)
+ {
+ case State::SETUP_IN_PROGRESS:
+ if (elapsedSeconds < SESSION_SETUP_TIMEOUT)
+ {
+ return true;
+ }
+ case State::ACTIVE:
+ if (elapsedSeconds < SESSION_INACTIVITY_TIMEOUT)
+ {
+ return true;
+ }
+ default:
+ return false;
+ }
+}
+
+} // namespace session
OpenPOWER on IntegriCloud