// NewIPEndpoint creates a new IP (v4 or v6) endpoint from a net.IP address. // It returns gopacket.InvalidEndpoint if the IP address is invalid. func NewIPEndpoint(a net.IP) gopacket.Endpoint { switch len(a) { case 4: return gopacket.NewEndpoint(EndpointIPv4, []byte(a)) case 16: return gopacket.NewEndpoint(EndpointIPv6, []byte(a)) } return gopacket.InvalidEndpoint }
// ForwardEndpoint returns the EthernetCTPForwardData ForwardAddress as an endpoint. func (c *EthernetCTPForwardData) ForwardEndpoint() gopacket.Endpoint { return gopacket.NewEndpoint(EndpointMAC, c.ForwardAddress) }
// NewRUDPPortEndpoint returns an endpoint based on a RUDP port. func NewRUDPPortEndpoint(p RUDPPort) gopacket.Endpoint { return gopacket.NewEndpoint(EndpointRUDPPort, []byte{byte(p)}) }
func newPortEndpoint(t gopacket.EndpointType, p uint16) gopacket.Endpoint { return gopacket.NewEndpoint(t, []byte{byte(p >> 8), byte(p)}) }
// NewMACEndpoint returns a new MAC address endpoint. func NewMACEndpoint(a net.HardwareAddr) gopacket.Endpoint { return gopacket.NewEndpoint(EndpointMAC, []byte(a)) }