-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Netdev changes - rebased #613
Conversation
3e9c778
to
0d1cc6b
Compare
Passes all smoke tests when run against https://github.com/tinygo-org/tinygo/tree/net-submodule-netdev3 |
When attempting to compile the "examples/socket" program, I get the following error:
|
Fixed in #623. Missed some updates to examples when converting to net/netip APIs. |
2285bfc
to
9944056
Compare
Now that PR tinygo-org/tinygo#3704 has been merged, the tests in this branch are passing! |
Add new MQTT client example using natiu-mqtt
This moves the netdev/netlink namespace out of drivers and into their own packages. Also, defines netdev and netlink as L3/L4 and L2 OSI layers, respectively. Move some L3 functionality from netlink to netdev (GetIPAddr). For netlink, add ConnectParams for NetConnect to pass in L2 connection parameters (ssid, pass, auth_type, etc). Also adds connection mode (STA, AP, etc). For netlink, add SendEth and RecvEthFunc funcs to handle L2 send/recv of Ethernet pkts.
This adds three new L2 (intermediate) drivers for bridge/bond/vlan. Theses drivers are incomplete but illustrate how to stack L2 drivers. Here are some examples of how these driver would stack with the cy243439 driver: Bridge: bridge two cyw43 devices together, connecting the two LANs: cyw43_0 := cyw43439.NewDevice(...) cyw43_1 := cyw43439.NewDevice(...) bridge := NewBridge([]netlink.Netlinker{cyw43_0, cyw43_1}) stack := tcpip.NewStack(bridge) netdev.UseNetdev(stack) Bond: bond two cyw43 devices together, creating one logical device. The first physical device is primary, the second is backup (fail-over) device: cyw43_0 := cyw43439.NewDevice(...) // primary cyw43_1 := cyw43439.NewDevice(...) // secondary (backup) bond := NewBond([]netlink.Netlinker{cyw43_0, cyw43_1}) stack := tcpip.NewStack(bond) netdev.UseNetdev(stack) Vlan: add tagged VLAN ID=100 to cyw43: cyw43 := cyw43439.NewDevice(...) vlan100 := NewVlan(100, cyw43) stack := tcpip.NewStack(vlan100) netdev.UseNetdev(stack)
Add basis for TCP/IP stack. The stack implements Netdever interface for the top-end, and calls into a Netlinker interface on the bottom-end. Each TCP/IP stack instance represents a L3/L4 endpoint with an IP address. The Netlinker is bound when creating the stack. E.g.: spi, cs, wlreg, irq := cyw43439.PicoWSpi(0) cyw43 := cyw43439.NewDevice(spi, cs, wlreg, irq, irq) stack := tcpip.NewStack(cyw43) netdev.UseNetdev(stack) Here, the cyw43439 driver is the Netlinker for the stack. The new stack is a Netdever, so we tell the "net" package to use the stack as the netdev. The stack manages L3/L4 socket connections, ultimately calling into the Netlinker to send/recv L2 Ethernet pkts.
Signed-off-by: deadprogram <[email protected]>
9944056
to
1235dfa
Compare
I've rebased it down to 14 commits. Now merging. Thank you very much @scottfeldman @soypat and everyone else who helped work on this. |
This PR is basically #537 but fully rebased against the latest
dev