// protocolForValue converts a valid Internet Protocol number into it's name
// representation. If a name is given, it validates that it's a proper protocol
// name. Names/numbers are as defined at
// https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
protocolForValue converts a valid Internet Protocol number into it's name
representation. If a name is given, it validates that it's a proper protocol
name.
// protocolForValue converts a valid Internet Protocol number into it ' s name // representation . If a name is given it validates that it ' s a proper protocol // name . Names / numbers are as defined at // https : // www . iana . org / assignments / protocol - numbers / protocol - numbers . xhtml
func protocolForValue(v string) string {
	protocol := strings.ToLower(v)
	if protocol == "-1" || protocol == "all" {
		return "-1"
	}
	if _, ok := sgProtocolIntegers()[protocol]; ok {
		return protocol
	}
	p, err := strconv.Atoi(protocol)
	if err != nil {
		log.Printf("[WARN] Unable to determine valid protocol: %s", err)
		return protocol
	}
	for k, v := range sgProtocolIntegers() {
		if p == v {
			return strings.ToLower(k)
		}
	}
	log.Printf("[WARN] Unable to determine valid protocol: no matching protocols found")
	return protocol
}
func protocolForValue ( v string ) string { protocol := strings . ToLower ( v ) if protocol == " " || protocol == " " { return " " } if _ , ok := sgProtocolIntegers ( ) [ protocol ] ; ok { return protocol } p , err := strconv . Atoi ( protocol ) if err != nil { log . Printf ( " " , err ) return protocol } for k , v := range sgProtocolIntegers ( ) { if p == v { return strings . ToLower ( k ) } } log . Printf ( " " ) return protocol }
protocolForValue converts a valid Internet Protocol number into it's name
representation.
protocolForValue converts a valid Internet Protocol number into it ' s name representation .
// special case -1 // if it's a name like tcp, return that // convert to int, look for that value // we were unable to convert to int, suggesting a string name, but it wasn't // found above // guard against protocolIntegers sometime in the future not having lower // case ids in the map // fall through