Notify application when Tunnel TCP connection is set up.
diff --git a/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.cpp b/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.cpp
index 3528497..f1c5a2e 100644
--- a/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.cpp
+++ b/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.cpp
@@ -1635,9 +1635,9 @@
/**
* Post processing function after Tunnel has been opened.
*/
-void WeaveTunnelAgent::WeaveTunnelConnectionUp(const WeaveMessageInfo *msgInfo,
- const WeaveTunnelConnectionMgr *connMgr,
- const bool isRoutingRestricted)
+void WeaveTunnelAgent::WeaveTunnelUp(const WeaveMessageInfo *msgInfo,
+ const WeaveTunnelConnectionMgr *connMgr,
+ const bool isRoutingRestricted)
{
// Update the Weave Tunnel Agent mode on tunnel establishment.
@@ -1742,6 +1742,27 @@
}
/**
+ * Tunnel connection established notifier.
+ */
+void WeaveTunnelAgent::WeaveTunnelConnectionEstablishedNotify(const WeaveTunnelConnectionMgr *connMgr)
+{
+ if (OnServiceTunStatusNotify)
+ {
+ if (connMgr->mTunType == kType_TunnelPrimary)
+ {
+ OnServiceTunStatusNotify(WeaveTunnelConnectionMgr::kStatus_TunPrimaryConnEstablished, WEAVE_NO_ERROR, mAppContext);
+ }
+#if WEAVE_CONFIG_TUNNEL_FAILOVER_SUPPORTED
+ else if (connMgr->mTunType == kType_TunnelBackup)
+ {
+ OnServiceTunStatusNotify(WeaveTunnelConnectionMgr::kStatus_TunBackupConnEstablished, WEAVE_NO_ERROR, mAppContext);
+ }
+#endif // WEAVE_CONFIG_TUNNEL_FAILOVER_SUPPORTED
+ }
+
+}
+
+/**
* Tunnel connection error notifier.
*/
void WeaveTunnelAgent::WeaveTunnelConnectionErrorNotify(const WeaveTunnelConnectionMgr *connMgr, WEAVE_ERROR conErr)
diff --git a/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.h b/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.h
index 1367d4e..bd3455c 100644
--- a/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.h
+++ b/src/lib/profiles/weave-tunneling/WeaveTunnelAgent.h
@@ -684,9 +684,9 @@
// Tunnel Control post-processing functions
- void WeaveTunnelConnectionUp(const WeaveMessageInfo *msgInfo,
- const WeaveTunnelConnectionMgr *connMgr,
- const bool isRoutingRestricted);
+ void WeaveTunnelUp(const WeaveMessageInfo *msgInfo,
+ const WeaveTunnelConnectionMgr *connMgr,
+ const bool isRoutingRestricted);
void WeaveTunnelConnectionDown(const WeaveTunnelConnectionMgr *connMgr, WEAVE_ERROR conErr);
void WeaveTunnelServiceReconnectRequested(const WeaveTunnelConnectionMgr *connMgr,
const char *redirectHost, const uint16_t redirectPort);
@@ -706,6 +706,7 @@
WEAVE_ERROR conErr);
#endif // WEAVE_CONFIG_TUNNEL_FAILOVER_SUPPORTED
void WeaveTunnelConnectionErrorNotify(const WeaveTunnelConnectionMgr *connMgr, WEAVE_ERROR conErr);
+ void WeaveTunnelConnectionEstablishedNotify(const WeaveTunnelConnectionMgr *connMgr);
#if WEAVE_CONFIG_TUNNEL_LIVENESS_SUPPORTED
void RestartTunnelLivenessTimer(TunnelType tunType);
diff --git a/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.cpp b/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.cpp
index fa92dd6..fea4f34 100644
--- a/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.cpp
+++ b/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.cpp
@@ -871,6 +871,10 @@
tConnMgr->mServiceCon->GetTCPEndPoint()->OnTCPSendIdleChanged = HandleTCPSendIdleChanged;
#endif // WEAVE_CONFIG_TUNNEL_ENABLE_TCP_IDLE_CALLBACK
+ // Notify connection establishment
+
+ tConnMgr->mTunAgent->WeaveTunnelConnectionEstablishedNotify(tConnMgr);
+
#if WEAVE_CONFIG_PERSIST_CONNECTED_SESSION
if (tConnMgr->LoadPersistedTunnelSession)
{
@@ -918,7 +922,7 @@
// Call the TunnelOpen post processing function.
- tConnMgr->mTunAgent->WeaveTunnelConnectionUp(NULL, tConnMgr, tConnMgr->mTunAgent->mRole != kClientRole_BorderGateway);
+ tConnMgr->mTunAgent->WeaveTunnelUp(NULL, tConnMgr, tConnMgr->mTunAgent->mRole != kClientRole_BorderGateway);
}
else
#endif // WEAVE_CONFIG_TCP_CONN_REPAIR_SUPPORTED
diff --git a/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.h b/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.h
index 9a37e71..f5fb741 100644
--- a/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.h
+++ b/src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.h
@@ -107,7 +107,8 @@
kStatus_TunBackupReconnectRcvd = 9, /**< Used to indicate that the Service has requested a reconnect for the Backup Weave tunnel */
kStatus_TunPrimaryLiveness = 10, /**< Used to indicate information about the Tunnel Liveness probe on the Primary Weave tunnel */
kStatus_TunBackupLiveness = 11, /**< Used to indicate information about the Tunnel Liveness probe on the Backup Weave tunnel */
-
+ kStatus_TunPrimaryConnEstablished = 12, /**< Used to indicate that the primary Weave tunnel TCP connection is up */
+ kStatus_TunBackupConnEstablished = 13, /**< Used to indicate that the backup Weave tunnel TCP connection is up */
} TunnelConnNotifyReasons;
WeaveTunnelConnectionMgr(void);
diff --git a/src/lib/profiles/weave-tunneling/WeaveTunnelControl.cpp b/src/lib/profiles/weave-tunneling/WeaveTunnelControl.cpp
index 2c4d656..c698707 100644
--- a/src/lib/profiles/weave-tunneling/WeaveTunnelControl.cpp
+++ b/src/lib/profiles/weave-tunneling/WeaveTunnelControl.cpp
@@ -850,7 +850,7 @@
// Call the TunnelOpen post processing function.
- tunControl->mTunnelAgent->WeaveTunnelConnectionUp(msgInfo, connMgr, isRoutingRestricted);
+ tunControl->mTunnelAgent->WeaveTunnelUp(msgInfo, connMgr, isRoutingRestricted);
// Stop the online check if it is running since tunnel is established.