DecodeLayers decodes as many layers as possible from the given data. It initially treats the data as layer type 'typ', then uses NextLayerType on each subsequent decoded layer until it gets to a layer type it doesn't know how to parse. For each layer successfully decoded, DecodeLayers appends the
(data []byte, decoded *[]LayerType)
| 300 | // If DecodeLayers is unable to decode the next layer type, it will return the |
| 301 | // error UnsupportedLayerType. |
| 302 | func (l *DecodingLayerParser) DecodeLayers(data []byte, decoded *[]LayerType) (err error) { |
| 303 | l.Truncated = false |
| 304 | if !l.IgnorePanic { |
| 305 | defer panicToError(&err) |
| 306 | } |
| 307 | typ, err := l.decodeFunc(data, decoded) |
| 308 | if typ != LayerTypeZero { |
| 309 | // no decoder |
| 310 | if l.IgnoreUnsupported { |
| 311 | return nil |
| 312 | } |
| 313 | return UnsupportedLayerType(typ) |
| 314 | } |
| 315 | return err |
| 316 | } |
| 317 | |
| 318 | // UnsupportedLayerType is returned by DecodingLayerParser if DecodeLayers |
| 319 | // encounters a layer type that the DecodingLayerParser has no decoder for. |