Documentation
¶
Index ¶
- Constants
- Variables
- func BindToInterface(fd int, ifname string) error
- func MakeBroadcastSocket(ifname string) (int, error)
- func MakeRawUDPPacket(payload []byte, serverAddr, clientAddr net.UDPAddr) ([]byte, error)
- func NewReadSocket(ifname string, timeout time.Duration) (io.ReadCloser, error)
- func NewWriteSocket(ifname string, remoteAddr unix.SockaddrInet4) (io.WriteCloser, error)
- type DHCP
- type Socket
- type TransactionID
Constants ¶
const (
MaxUDPReceivedPacketSize = 8192
)
Variables ¶
var ( DefaultReadTimeout = 3 * time.Second DefaultTimeout = 3 * time.Second )
Functions ¶
func BindToInterface ¶
func MakeBroadcastSocket ¶
MakeBroadcastSocket creates a socket that can be passed to unix.Sendto that will send packets out to the broadcast address.
func MakeRawUDPPacket ¶
MakeRawUDPPacket converts a payload (a serialized packet) into a raw UDP packet for the specified serverAddr from the specified clientAddr.
func NewReadSocket ¶
returns a reader which should always be closed, even if we return an error
func NewWriteSocket ¶
func NewWriteSocket(ifname string, remoteAddr unix.SockaddrInet4) (io.WriteCloser, error)
Linux specific returns a writer which should always be closed, even if we return an error
Types ¶
type DHCP ¶
type DHCP struct {
// contains filtered or unexported fields
}
func (*DHCP) DiscoverRequest ¶
Issues a DHCP Discover packet from the nic specified by mac and name ifname Returns nil if a reply to the transaction was received, or error if time out Does not return the DHCP Offer that was received from the DHCP server
type TransactionID ¶
type TransactionID [4]byte
TransactionID represents a 4-byte DHCP transaction ID as defined in RFC 951, Section 3.
The TransactionID is used to match DHCP replies to their original request.
func GenerateTransactionID ¶
func GenerateTransactionID() (TransactionID, error)
GenerateTransactionID generates a random 32-bits number suitable for use as TransactionID