File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,8 @@ class Session {
148
148
Connection getConnection ();
149
149
const libyang::Context getContext () const ;
150
150
151
+ uint32_t getId () const ;
152
+
151
153
private:
152
154
friend Connection;
153
155
friend Session wrapUnmanagedSession (sr_session_ctx_s* session);
Original file line number Diff line number Diff line change @@ -685,6 +685,16 @@ const libyang::Context Session::getContext() const
685
685
return libyang::createUnmanagedContext (const_cast <ly_ctx*>(ctx), [sess = m_sess] (ly_ctx*) { sr_session_release_context (sess.get ()); });
686
686
}
687
687
688
+ /* *
689
+ * @brief Get the internal, sysrepo-level session ID
690
+ *
691
+ * Wraps `sr_session_get_id`.
692
+ */
693
+ uint32_t Session::getId () const
694
+ {
695
+ return sr_session_get_id (m_sess.get ());
696
+ }
697
+
688
698
sr_session_ctx_s* getRawSession (Session sess)
689
699
{
690
700
return sess.m_sess .get ();
Original file line number Diff line number Diff line change @@ -213,4 +213,10 @@ TEST_CASE("session")
213
213
REQUIRE (*data->printStr (libyang::DataFormat::JSON, libyang::PrintFlags::WithSiblings) == " {\n\n }\n " );
214
214
REQUIRE_THROWS_AS (sess.setItem (" /test_module:leafInt32" , " 123" ), sysrepo::ErrorWithCode);
215
215
}
216
+
217
+ DOCTEST_SUBCASE (" session IDs" )
218
+ {
219
+ REQUIRE (sess.getId () == sess.getId ());
220
+ REQUIRE (sess.getId () != conn->sessionStart ().getId ());
221
+ }
216
222
}
You can’t perform that action at this time.
0 commit comments