()
| 122 | } |
| 123 | |
| 124 | func NewICMPDecoder() *ICMPDecoder { |
| 125 | ipDecoder := NewIPDecoder() |
| 126 | |
| 127 | var ( |
| 128 | icmpv4 layers.ICMPv4 |
| 129 | icmpv6 layers.ICMPv6 |
| 130 | ) |
| 131 | ipDecoder.layers++ |
| 132 | ipDecoder.v4parser.AddDecodingLayer(&icmpv4) |
| 133 | ipDecoder.v6parser.AddDecodingLayer(&icmpv6) |
| 134 | |
| 135 | return &ICMPDecoder{ |
| 136 | IPDecoder: ipDecoder, |
| 137 | icmpv4: &icmpv4, |
| 138 | icmpv6: &icmpv6, |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | func (pd *ICMPDecoder) Decode(packet RawPacket) (*ICMP, error) { |
| 143 | // Should decode to IP and optionally ICMP layer |