package devices // [impllnx dsn~low-level-abstraction~0>>utest] import "golang.org/x/sys/unix" // TransmitterLinux is the Linux implementation for the Transmitter interface type TransmitterLinux struct { socket int } // Send implements sending packets on Linux func (tl TransmitterLinux) Send(data []byte) error { err := unix.Send(tl.socket, data, 0) return err } // Close closes the transmitter socket func (tl TransmitterLinux) Close() error { return unix.Close(tl.socket) } // CreateTransmitter creates the Transmitter object func CreateTransmitter(device string) (Transmitter, error) { ret := TransmitterLinux{} var err error ret.socket, err = unix.Socket(unix.AF_PACKET, unix.SOCK_RAW, unix.ETH_P_ALL) if err != nil { panic(err) } return ret, err } // CreateReceiver creates and starts the Receiver instance func CreateReceiver(device string) (Receiver, error) { //TODO return nil, nil }