icmp.go 504 B

1234567891011121314151617181920212223
  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package ipv4
  5. import "golang.org/x/net/internal/iana"
  6. // An ICMPType represents a type of ICMP message.
  7. type ICMPType int
  8. func (typ ICMPType) String() string {
  9. s, ok := icmpTypes[typ]
  10. if !ok {
  11. return "<nil>"
  12. }
  13. return s
  14. }
  15. // Protocol returns the ICMPv4 protocol number.
  16. func (typ ICMPType) Protocol() int {
  17. return iana.ProtocolICMP
  18. }