|
|
@ -9,7 +9,6 @@ import (
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
@ -25,6 +24,14 @@ var TCP = packet.TCP
|
|
|
|
var UDP = packet.UDP
|
|
|
|
var UDP = packet.UDP
|
|
|
|
var Fragment = packet.Fragment
|
|
|
|
var Fragment = packet.Fragment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func mustIP4(s string) packet.IP4 {
|
|
|
|
|
|
|
|
ip, err := netaddr.ParseIP(s)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return packet.IP4FromNetaddr(ip)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func pfx(s string) netaddr.IPPrefix {
|
|
|
|
func pfx(s string) netaddr.IPPrefix {
|
|
|
|
pfx, err := netaddr.ParseIPPrefix(s)
|
|
|
|
pfx, err := netaddr.ParseIPPrefix(s)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -435,19 +442,19 @@ func TestOmitDropLogging(t *testing.T) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "v4_multicast_out_low",
|
|
|
|
name: "v4_multicast_out_low",
|
|
|
|
pkt: &packet.Parsed{IPVersion: 4, DstIP4: packet.NewIP4(net.ParseIP("224.0.0.0"))},
|
|
|
|
pkt: &packet.Parsed{IPVersion: 4, DstIP4: mustIP4("224.0.0.0")},
|
|
|
|
dir: out,
|
|
|
|
dir: out,
|
|
|
|
want: true,
|
|
|
|
want: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "v4_multicast_out_high",
|
|
|
|
name: "v4_multicast_out_high",
|
|
|
|
pkt: &packet.Parsed{IPVersion: 4, DstIP4: packet.NewIP4(net.ParseIP("239.255.255.255"))},
|
|
|
|
pkt: &packet.Parsed{IPVersion: 4, DstIP4: mustIP4("239.255.255.255")},
|
|
|
|
dir: out,
|
|
|
|
dir: out,
|
|
|
|
want: true,
|
|
|
|
want: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "v4_link_local_unicast",
|
|
|
|
name: "v4_link_local_unicast",
|
|
|
|
pkt: &packet.Parsed{IPVersion: 4, DstIP4: packet.NewIP4(net.ParseIP("169.254.1.2"))},
|
|
|
|
pkt: &packet.Parsed{IPVersion: 4, DstIP4: mustIP4("169.254.1.2")},
|
|
|
|
dir: out,
|
|
|
|
dir: out,
|
|
|
|
want: true,
|
|
|
|
want: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|