diff --git a/pkg/netp/icmp.go b/pkg/netp/icmp.go index f976adc..2d1cf40 100644 --- a/pkg/netp/icmp.go +++ b/pkg/netp/icmp.go @@ -96,23 +96,24 @@ func inverseICMPType(t int) int { } //nolint:revive // magic numbers are fine here +var maxCodes = map[int]int{ + EchoReply: 0, + DestinationUnreachable: 5, + SourceQuench: 0, + Redirect: 3, + Echo: 0, + TimeExceeded: 1, + ParameterProblem: 0, + Timestamp: 0, + TimestampReply: 0, + InformationRequest: 0, + InformationReply: 0, +} + func ValidateICMP(typeCode *ICMPTypeCode) error { if typeCode == nil { return nil } - maxCodes := map[int]int{ - EchoReply: 0, - DestinationUnreachable: 5, - SourceQuench: 0, - Redirect: 3, - Echo: 0, - TimeExceeded: 1, - ParameterProblem: 0, - Timestamp: 0, - TimestampReply: 0, - InformationRequest: 0, - InformationReply: 0, - } maxCode, ok := maxCodes[typeCode.Type] if !ok { return fmt.Errorf("invalid ICMP type %v", typeCode.Type)