mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 22:37:45 +00:00
[mle] MTD to handle udp time sync message (#9978)
This commit add the possibility to handle a udp time sync message when configured as MTD.
This commit is contained in:
+39
-18
@@ -2652,13 +2652,13 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn
|
||||
case kCommandChildIdRequest:
|
||||
Get<MleRouter>().HandleChildIdRequest(rxInfo);
|
||||
break;
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
case kCommandTimeSync:
|
||||
Get<MleRouter>().HandleTimeSync(rxInfo);
|
||||
HandleTimeSync(rxInfo);
|
||||
break;
|
||||
#endif
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
case kCommandLinkMetricsManagementRequest:
|
||||
@@ -3791,6 +3791,22 @@ exit:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
void Mle::HandleTimeSync(RxInfo &aRxInfo)
|
||||
{
|
||||
Log(kMessageReceive, kTypeTimeSync, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid());
|
||||
|
||||
aRxInfo.mClass = RxInfo::kPeerMessage;
|
||||
|
||||
Get<TimeSync>().HandleTimeSyncMessage(aRxInfo.mMessage);
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
|
||||
void Mle::HandleLinkMetricsManagementResponse(RxInfo &aRxInfo)
|
||||
{
|
||||
@@ -4110,14 +4126,14 @@ const char *Mle::MessageTypeToString(MessageType aType)
|
||||
"Link Reject", // (25) kTypeLinkReject
|
||||
"Link Request", // (26) kTypeLinkRequest
|
||||
"Parent Request", // (27) kTypeParentRequest
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
"Time Sync", // (28) kTypeTimeSync
|
||||
#endif
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
"Link Metrics Management Request", // (29) kTypeLinkMetricsManagementRequest
|
||||
"Link Metrics Management Response", // (30) kTypeLinkMetricsManagementResponse
|
||||
"Link Probe", // (31) kTypeLinkProbe
|
||||
"Link Metrics Management Request", // (28) kTypeLinkMetricsManagementRequest
|
||||
"Link Metrics Management Response", // (29) kTypeLinkMetricsManagementResponse
|
||||
"Link Probe", // (30) kTypeLinkProbe
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
"Time Sync", // (31) kTypeTimeSync
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -4150,25 +4166,30 @@ const char *Mle::MessageTypeToString(MessageType aType)
|
||||
static_assert(kTypeLinkReject == 25, "kTypeLinkReject value is incorrect");
|
||||
static_assert(kTypeLinkRequest == 26, "kTypeLinkRequest value is incorrect");
|
||||
static_assert(kTypeParentRequest == 27, "kTypeParentRequest value is incorrect");
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
static_assert(kTypeTimeSync == 28, "kTypeTimeSync value is incorrect");
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
static_assert(kTypeLinkMetricsManagementRequest == 29, "kTypeLinkMetricsManagementRequest value is incorrect)");
|
||||
static_assert(kTypeLinkMetricsManagementResponse == 30, "kTypeLinkMetricsManagementResponse value is incorrect)");
|
||||
static_assert(kTypeLinkProbe == 31, "kTypeLinkProbe value is incorrect)");
|
||||
#endif
|
||||
#else // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
static_assert(kTypeLinkMetricsManagementRequest == 28, "kTypeLinkMetricsManagementRequest value is incorrect)");
|
||||
static_assert(kTypeLinkMetricsManagementResponse == 29, "kTypeLinkMetricsManagementResponse value is incorrect)");
|
||||
static_assert(kTypeLinkProbe == 30, "kTypeLinkProbe value is incorrect)");
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
static_assert(kTypeTimeSync == 31, "kTypeTimeSync value is incorrect");
|
||||
#endif
|
||||
#endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
#else // OPENTHREAD_FTD
|
||||
#else
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
static_assert(kTypeTimeSync == 28, "kTypeTimeSync value is incorrect");
|
||||
#endif
|
||||
#endif
|
||||
#else // OPENTHREAD_FTD
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
static_assert(kTypeLinkMetricsManagementRequest == 16, "kTypeLinkMetricsManagementRequest value is incorrect)");
|
||||
static_assert(kTypeLinkMetricsManagementResponse == 17, "kTypeLinkMetricsManagementResponse value is incorrect)");
|
||||
static_assert(kTypeLinkProbe == 18, "kTypeLinkProbe value is incorrect)");
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
static_assert(kTypeTimeSync == 19, "kTypeTimeSync value is incorrect");
|
||||
#endif
|
||||
#else
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
static_assert(kTypeTimeSync == 16, "kTypeTimeSync value is incorrect");
|
||||
#endif
|
||||
#endif
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
|
||||
@@ -973,14 +973,14 @@ private:
|
||||
kTypeLinkReject,
|
||||
kTypeLinkRequest,
|
||||
kTypeParentRequest,
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
kTypeTimeSync,
|
||||
#endif
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
kTypeLinkMetricsManagementRequest,
|
||||
kTypeLinkMetricsManagementResponse,
|
||||
kTypeLinkProbe,
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
kTypeTimeSync,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1313,6 +1313,10 @@ private:
|
||||
void UpdateServiceAlocs(void);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
void HandleTimeSync(RxInfo &aRxInfo);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
|
||||
void HandleLinkMetricsManagementRequest(RxInfo &aRxInfo);
|
||||
void HandleLinkProbe(RxInfo &aRxInfo);
|
||||
|
||||
@@ -3891,20 +3891,6 @@ exit:
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
void MleRouter::HandleTimeSync(RxInfo &aRxInfo)
|
||||
{
|
||||
Log(kMessageReceive, kTypeTimeSync, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid());
|
||||
|
||||
aRxInfo.mClass = RxInfo::kPeerMessage;
|
||||
|
||||
Get<TimeSync>().HandleTimeSyncMessage(aRxInfo.mMessage);
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
Error MleRouter::SendTimeSync(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -649,9 +649,6 @@ private:
|
||||
void HandleDataRequest(RxInfo &aRxInfo);
|
||||
void HandleNetworkDataUpdateRouter(void);
|
||||
void HandleDiscoveryRequest(RxInfo &aRxInfo);
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
void HandleTimeSync(RxInfo &aRxInfo);
|
||||
#endif
|
||||
|
||||
Error ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo);
|
||||
Error ReadAndProcessRouteTlvOnFed(RxInfo &aRxInfo, uint8_t aParentId);
|
||||
|
||||
Reference in New Issue
Block a user