Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 520f46f

Browse files
committed
Surface a getter function for retrieving the WeaveConnection object
for the Tunnel connection. Needed for getting information about PeerAddress, PeerPort of TunnelConnection as well as suspension of TunnelConnection CASE session persistence during shutdown.
1 parent af77670 commit 520f46f

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

src/lib/profiles/weave-tunneling/WeaveTunnelAgent.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ WeaveTunnelAgent::AgentState WeaveTunnelAgent::GetWeaveTunnelAgentState(void)
365365
return mTunAgentState;
366366
}
367367

368+
/**
369+
* Get a pointer to the Weave Tunnel Connection.
370+
*
371+
* @return WeaveConnection pointer for an established Weave Tunnel. If tunnel is
372+
* not in the established state, a null pointer is returned.
373+
*
374+
*/
375+
nl::Weave::WeaveConnection * WeaveTunnelAgent::GetPrimaryTunnelConnection(void) const
376+
{
377+
return mPrimaryTunConnMgr.GetTunnelConnection();
378+
}
379+
368380
#if WEAVE_CONFIG_PERSIST_CONNECTED_SESSION
369381
void WeaveTunnelAgent::SetCallbacksForPersistedTunnelConnection(WeaveTunnelConnectionMgr::PersistedSecureSessionExistsFunct aIsPersistedTunnelSessionPresent,
370382
WeaveTunnelConnectionMgr::LoadPersistedSessionFunct aLoadPersistedTunnelSession)

src/lib/profiles/weave-tunneling/WeaveTunnelAgent.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ class WeaveTunnelAgent
216216
*/
217217
AgentState GetWeaveTunnelAgentState(void);
218218

219+
/**
220+
* Get the Primary Tunnel Connection
221+
*
222+
*/
223+
nl::Weave::WeaveConnection * GetPrimaryTunnelConnection(void) const;
224+
219225
#if WEAVE_CONFIG_TUNNEL_TCP_USER_TIMEOUT_SUPPORTED
220226
/**
221227
* Configure the TCP user timeout option on the primary tunnel connection.

src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,27 @@ void WeaveTunnelConnectionMgr::ServiceTunnelClose(WEAVE_ERROR err)
649649
mTunReconnectFibonacciIndex = 0;
650650
}
651651

652+
/**
653+
* Get a pointer to the Weave Tunnel Connection object for this
654+
* Tunnel Connection Manager.
655+
*
656+
* @return pointer to the WeaveConnection object for the Tunnel. If Tunnel is
657+
* not in an established state, a null pointer is returned
658+
*
659+
*/
660+
661+
nl::Weave::WeaveConnection * WeaveTunnelConnectionMgr::GetTunnelConnection(void) const
662+
{
663+
if (mConnectionState == kState_ConnectionEstablished || mConnectionState == kState_TunnelOpen)
664+
{
665+
return mServiceCon;
666+
}
667+
else
668+
{
669+
return NULL;
670+
}
671+
}
672+
652673
/**
653674
* Handler to receive tunneled IPv6 packets from the Service TCP connection and forward to the Tunnel
654675
* EndPoint interface after decapsulating the raw IPv6 packet from inside the tunnel header.

src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ class NL_DLL_EXPORT WeaveTunnelConnectionMgr
241241
*/
242242
void StopAndReconnectTunnelConn(ReconnectParam & reconnParam);
243243

244+
/**
245+
* Get a pointer to the Weave Tunnel Connection object for this
246+
* Tunnel Connection Manager.
247+
*/
248+
nl::Weave::WeaveConnection * GetTunnelConnection(void) const;
244249
private:
245250

246251
WEAVE_ERROR StartServiceTunnelConn(uint64_t destNodeId, IPAddress destIPAddr,

0 commit comments

Comments
 (0)