(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestDecodeIP(t *testing.T) { |
| 17 | ipDecoder := NewIPDecoder() |
| 18 | icmpDecoder := NewICMPDecoder() |
| 19 | udps := []UDP{ |
| 20 | { |
| 21 | IP: IP{ |
| 22 | Src: netip.MustParseAddr("172.16.0.1"), |
| 23 | Dst: netip.MustParseAddr("10.0.0.1"), |
| 24 | Protocol: layers.IPProtocolUDP, |
| 25 | }, |
| 26 | SrcPort: 31678, |
| 27 | DstPort: 53, |
| 28 | }, |
| 29 | { |
| 30 | |
| 31 | IP: IP{ |
| 32 | Src: netip.MustParseAddr("fd51:2391:523:f4ee::1"), |
| 33 | Dst: netip.MustParseAddr("fd51:2391:697:f4ee::2"), |
| 34 | Protocol: layers.IPProtocolUDP, |
| 35 | }, |
| 36 | SrcPort: 52139, |
| 37 | DstPort: 1053, |
| 38 | }, |
| 39 | } |
| 40 | |
| 41 | encoder := NewEncoder() |
| 42 | for _, udp := range udps { |
| 43 | p, err := encoder.Encode(&udp) |
| 44 | require.NoError(t, err) |
| 45 | |
| 46 | ipPacket, err := ipDecoder.Decode(p) |
| 47 | require.NoError(t, err) |
| 48 | assertIPLayer(t, &udp.IP, ipPacket) |
| 49 | |
| 50 | icmpPacket, err := icmpDecoder.Decode(p) |
| 51 | require.Error(t, err) |
| 52 | require.Nil(t, icmpPacket) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestDecodeICMP(t *testing.T) { |
| 57 | ipDecoder := NewIPDecoder() |
nothing calls this directly
no test coverage detected