func newPacketConn(ifi *net.Interface, s socket, pbe uint16, filter []bpf.RawInstruction) (*packetConn, error) {
	pc := &packetConn{
		ifi: ifi,
		s:   s,
		pbe: pbe,
	}

	if len(filter) > 0 {
		if err := pc.SetBPF(filter); err != nil {
			return nil, err
		}
	}

	// Bind the packet socket to the interface specified by ifi
	// packet(7):
	//   Only the sll_protocol and the sll_ifindex address fields are used for
	//   purposes of binding.
	// This overrides the protocol given to socket(AF_PACKET).
	err := s.Bind(&unix.SockaddrLinklayer{
		Protocol: pc.pbe,
		Ifindex:  ifi.Index,
	})
	if err != nil {
		return nil, err
	}

	return pc, nil
}
// newPacketConn creates a net.PacketConn using the specified network
// interface, wrapped socket and big endian protocol number.
//
// It is the entry point for tests in this package.
newPacketConn creates a net.PacketConn using the specified network
interface, wrapped socket and big endian protocol number.

It is the entry point for tests in this package.
// newPacketConn creates a net . PacketConn using the specified network // interface wrapped socket and big endian protocol number . // // It is the entry point for tests in this package .
func newPacketConn(ifi *net.Interface, s socket, pbe uint16, filter []bpf.RawInstruction) (*packetConn, error) {
	pc := &packetConn{
		ifi: ifi,
		s:   s,
		pbe: pbe,
	}
	if len(filter) > 0 {
		if err := pc.SetBPF(filter); err != nil {
			return nil, err
		}
	}
	err := s.Bind(&unix.SockaddrLinklayer{
		Protocol: pc.pbe,
		Ifindex:  ifi.Index,
	})
	if err != nil {
		return nil, err
	}
	return pc, nil
}
func newPacketConn ( ifi * net . Interface , s socket , pbe uint16 , filter [ ] bpf . RawInstruction ) ( * packetConn , error ) { pc := & packetConn { ifi : ifi , s : s , pbe : pbe , } if len ( filter ) > 0 { if err := pc . SetBPF ( filter ) ; err != nil { return nil , err } } err := s . Bind ( & unix . SockaddrLinklayer { Protocol : pc . pbe , Ifindex : ifi . Index , } ) if err != nil { return nil , err } return pc , nil }
newPacketConn creates a net.PacketConn using the specified network
interface, wrapped socket and big endian protocol number.
newPacketConn creates a net . PacketConn using the specified network interface wrapped socket and big endian protocol number .
// Bind the packet socket to the interface specified by ifi // packet(7): //   Only the sll_protocol and the sll_ifindex address fields are used for //   purposes of binding. // This overrides the protocol given to socket(AF_PACKET).