mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 20:27:47 +00:00
[ip6] fix constant name style and simplify filtering of ICMP types (#9512)
This commit contains smaller changes in `Ip6` class: - Rename constant `kForwardIcmpTypes` to follow naming convention - Simplify how it it used to filter which ICMP types are forwarded to Thread mesh.
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
|
||||
using IcmpType = ot::Ip6::Icmp::Header::Type;
|
||||
|
||||
static const IcmpType sForwardICMPTypes[] = {
|
||||
static const IcmpType kForwardIcmpTypes[] = {
|
||||
IcmpType::kTypeDstUnreach, IcmpType::kTypePacketToBig, IcmpType::kTypeTimeExceeded,
|
||||
IcmpType::kTypeParameterProblem, IcmpType::kTypeEchoRequest, IcmpType::kTypeEchoReply,
|
||||
};
|
||||
@@ -1258,8 +1258,6 @@ start:
|
||||
|
||||
if (forwardThread)
|
||||
{
|
||||
uint8_t hopLimit;
|
||||
|
||||
if (aMessage.IsOriginThreadNetif())
|
||||
{
|
||||
VerifyOrExit(Get<Mle::Mle>().IsRouterOrLeader());
|
||||
@@ -1268,24 +1266,26 @@ start:
|
||||
|
||||
VerifyOrExit(header.GetHopLimit() > 0, error = kErrorDrop);
|
||||
|
||||
hopLimit = header.GetHopLimit();
|
||||
aMessage.Write(Header::kHopLimitFieldOffset, hopLimit);
|
||||
aMessage.Write<uint8_t>(Header::kHopLimitFieldOffset, header.GetHopLimit());
|
||||
|
||||
if (nextHeader == kProtoIcmp6)
|
||||
{
|
||||
uint8_t icmpType;
|
||||
bool isAllowedType = false;
|
||||
|
||||
SuccessOrExit(error = aMessage.Read(aMessage.GetOffset(), icmpType));
|
||||
for (IcmpType type : sForwardICMPTypes)
|
||||
|
||||
error = kErrorDrop;
|
||||
|
||||
for (IcmpType type : kForwardIcmpTypes)
|
||||
{
|
||||
if (icmpType == type)
|
||||
{
|
||||
isAllowedType = true;
|
||||
error = kErrorNone;
|
||||
break;
|
||||
}
|
||||
}
|
||||
VerifyOrExit(isAllowedType, error = kErrorDrop);
|
||||
|
||||
SuccessOrExit(error);
|
||||
}
|
||||
|
||||
if (aMessage.IsOriginHostUntrusted() && (nextHeader == kProtoUdp))
|
||||
|
||||
Reference in New Issue
Block a user