Skip to content

Commit

Permalink
make maxCodes global
Browse files Browse the repository at this point in the history
Signed-off-by: Elazar Gershuni <elazarg@ibm.com>
  • Loading branch information
Elazar Gershuni committed Mar 13, 2024
1 parent 0ff579e commit 47aa3c3
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions pkg/netp/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47aa3c3

Please sign in to comment.