diff --git a/tcpip/netdev.go b/tcpip/netdev.go new file mode 100644 index 0000000..92efead --- /dev/null +++ b/tcpip/netdev.go @@ -0,0 +1,52 @@ +package tcpip + +import ( + "net" + "time" + + "tinygo.org/x/drivers/netdev" +) + +func (s *Stack) GetHostByName(name string) (net.IP, error) { + return net.IP{}, netdev.ErrNotSupported +} + +func (s *Stack) GetIPAddr() (net.IP, error) { + return net.IP{}, netdev.ErrNotSupported +} + +func (s *Stack) Socket(domain int, stype int, protocol int) (int, error) { + return -1, netdev.ErrNotSupported +} + +func (s *Stack) Bind(sockfd int, ip net.IP, port int) error { + return netdev.ErrNotSupported +} + +func (s *Stack) Connect(sockfd int, host string, ip net.IP, port int) error { + return netdev.ErrNotSupported +} + +func (s *Stack) Listen(sockfd int, backlog int) error { + return netdev.ErrNotSupported +} + +func (s *Stack) Accept(sockfd int, ip net.IP, port int) (int, error) { + return -1, netdev.ErrNotSupported +} + +func (s *Stack) Send(sockfd int, buf []byte, flags int, deadline time.Time) (int, error) { + return 0, netdev.ErrNotSupported +} + +func (s *Stack) Recv(sockfd int, buf []byte, flags int, deadline time.Time) (int, error) { + return 0, netdev.ErrNotSupported +} + +func (s *Stack) Close(sockfd int) error { + return netdev.ErrNotSupported +} + +func (s *Stack) SetSockOpt(sockfd int, level int, opt int, value interface{}) error { + return netdev.ErrNotSupported +} diff --git a/tcpip/stack.go b/tcpip/stack.go new file mode 100644 index 0000000..bcabd6c --- /dev/null +++ b/tcpip/stack.go @@ -0,0 +1,20 @@ +package tcpip + +import ( + "tinygo.org/x/drivers/netlink" +) + +type Stack struct { + link netlink.Netlinker +} + +func NewStack(link netlink.Netlinker) *Stack { + s := Stack{link: link} + s.link.RecvEthFunc(s.recvEth) + return &s +} + +func (s *Stack) recvEth(pkt []byte) error { + println("recvEth", len(pkt)) + return nil +}