Add network name reference for endpoint lists

This commit is contained in:
Daniel
2020-03-20 23:02:08 +01:00
parent 34f2beb8d4
commit 544ede719c
2 changed files with 93 additions and 12 deletions

View File

@@ -1,6 +1,9 @@
package reference
import "strconv"
import (
"strconv"
"strings"
)
var (
protocolNames = map[uint8]string{
@@ -9,20 +12,20 @@ var (
6: "TCP",
17: "UDP",
27: "RDP",
58: "ICMPv6",
58: "ICMP6",
33: "DCCP",
136: "UDPLite",
136: "UDP-LITE",
}
protocolNumbers = map[string]uint8{
"ICMP": 1,
"IGMP": 2,
"TCP": 6,
"UDP": 17,
"RDP": 27,
"DCCP": 33,
"ICMPv6": 58,
"UDPLite": 136,
"ICMP": 1,
"IGMP": 2,
"TCP": 6,
"UDP": 17,
"RDP": 27,
"DCCP": 33,
"ICMP6": 58,
"UDP-LITE": 136,
}
)
@@ -37,7 +40,7 @@ func GetProtocolName(protocol uint8) (name string) {
// GetProtocolNumber returns the number of a IP protocol name.
func GetProtocolNumber(protocol string) (number uint8, ok bool) {
number, ok = protocolNumbers[protocol]
number, ok = protocolNumbers[strings.ToUpper(protocol)]
if ok {
return number, true
}