| 132 | } |
| 133 | |
| 134 | func (a ICMPv6TypeCode) String() string { |
| 135 | t, c := a.Type(), a.Code() |
| 136 | strInfo, ok := icmpv6TypeCodeInfo[t] |
| 137 | if !ok { |
| 138 | // Unknown ICMPv6 type field |
| 139 | return fmt.Sprintf("%d(%d)", t, c) |
| 140 | } |
| 141 | typeStr := strInfo.typeStr |
| 142 | if strInfo.codeStr == nil && c == 0 { |
| 143 | // The ICMPv6 type does not make use of the code field |
| 144 | return fmt.Sprintf("%s", strInfo.typeStr) |
| 145 | } |
| 146 | if strInfo.codeStr == nil && c != 0 { |
| 147 | // The ICMPv6 type does not make use of the code field, but it is present anyway |
| 148 | return fmt.Sprintf("%s(Code: %d)", typeStr, c) |
| 149 | } |
| 150 | codeStr, ok := (*strInfo.codeStr)[c] |
| 151 | if !ok { |
| 152 | // We don't know this ICMPv6 code; print the numerical value |
| 153 | return fmt.Sprintf("%s(Code: %d)", typeStr, c) |
| 154 | } |
| 155 | return fmt.Sprintf("%s(%s)", typeStr, codeStr) |
| 156 | } |
| 157 | |
| 158 | func (a ICMPv6TypeCode) GoString() string { |
| 159 | t := reflect.TypeOf(a) |