@@ -44,7 +44,7 @@ class UnauthenticatedSessionDeleter
44
44
* @brief
45
45
* An UnauthenticatedSession stores the binding of TransportAddress, and message counters.
46
46
*/
47
- class UnauthenticatedSession : public ReferenceCounted <UnauthenticatedSession, UnauthenticatedSessionDeleter>
47
+ class UnauthenticatedSession : public ReferenceCounted <UnauthenticatedSession, UnauthenticatedSessionDeleter, 0 >
48
48
{
49
49
public:
50
50
UnauthenticatedSession (const PeerAddress & address) : mPeerAddress (address) { mLocalMessageCounter .Init (); }
@@ -82,6 +82,39 @@ template <size_t kMaxConnectionCount, Time::Source kTimeSource = Time::Source::k
82
82
class UnauthenticatedSessionTable
83
83
{
84
84
public:
85
+ /* *
86
+ * Get a session given the peer address. If the session doesn't exist in the cache, allocate a new entry for it.
87
+ *
88
+ * @return the session found or allocated, nullptr if not found and allocation failed.
89
+ */
90
+ CHECK_RETURN_VALUE
91
+ Optional<UnauthenticatedSessionHandle> FindOrAllocateEntry (const PeerAddress & address)
92
+ {
93
+ UnauthenticatedSession * result = FindEntry (address);
94
+ if (result != nullptr )
95
+ return MakeOptional<UnauthenticatedSessionHandle>(*result);
96
+
97
+ CHIP_ERROR err = AllocEntry (address, result);
98
+ if (err == CHIP_NO_ERROR)
99
+ {
100
+ return MakeOptional<UnauthenticatedSessionHandle>(*result);
101
+ }
102
+ else
103
+ {
104
+ return Optional<UnauthenticatedSessionHandle>::Missing ();
105
+ }
106
+ }
107
+
108
+ // / Mark a session as active
109
+ void MarkSessionActive (UnauthenticatedSessionHandle session)
110
+ {
111
+ session->SetLastActivityTimeMs (mTimeSource .GetCurrentMonotonicTimeMs ());
112
+ }
113
+
114
+ // / Allows access to the underlying time source used for keeping track of connection active time
115
+ Time::TimeSource<kTimeSource > & GetTimeSource () { return mTimeSource ; }
116
+
117
+ private:
85
118
/* *
86
119
* Allocates a new session out of the internal resource pool.
87
120
*
@@ -125,36 +158,6 @@ class UnauthenticatedSessionTable
125
158
return result;
126
159
}
127
160
128
- /* *
129
- * Get a peer given the peer id. If the peer doesn't exist in the cache, allocate a new entry for it.
130
- *
131
- * @return the peer found or allocated, nullptr if not found and allocate failed.
132
- */
133
- CHECK_RETURN_VALUE
134
- UnauthenticatedSession * FindOrAllocateEntry (const PeerAddress & address)
135
- {
136
- UnauthenticatedSession * result = FindEntry (address);
137
- if (result != nullptr )
138
- return result;
139
-
140
- CHIP_ERROR err = AllocEntry (address, result);
141
- if (err == CHIP_NO_ERROR)
142
- {
143
- return result;
144
- }
145
- else
146
- {
147
- return nullptr ;
148
- }
149
- }
150
-
151
- // / Mark a session as active
152
- void MarkSessionActive (UnauthenticatedSession & entry) { entry.SetLastActivityTimeMs (mTimeSource .GetCurrentMonotonicTimeMs ()); }
153
-
154
- // / Allows access to the underlying time source used for keeping track of connection active time
155
- Time::TimeSource<kTimeSource > & GetTimeSource () { return mTimeSource ; }
156
-
157
- private:
158
161
UnauthenticatedSession * FindLeastRecentUsedEntry ()
159
162
{
160
163
UnauthenticatedSession * result = nullptr ;
0 commit comments