Commit graph

48 commits

Author SHA1 Message Date
bunnie
24a0848a43 add nonblocking flag to opcode map 2022-08-05 05:02:39 +08:00
bunnie
2094b803be loopback interface
loopback packets are intercepted on the way to the COM and
re-injected directly into the Rx queue, along with a message
sent back to the main loop to pump the Rx buffer to extract the
loopback packet.
2022-08-03 03:33:15 +08:00
bunnie
ca5455635b add some heuristics to improve the connection manager
the CM can't always detect if the EC changes state; this is
especially true after an update or a forced reset where
the state caches are not reliably updated. If no packets are
seen for a while, poll the actual state and force a sync-up.

Also try to make sure that the interrupts are enabled correctly.
2022-07-11 04:58:48 +08:00
bunnie
12190b9184 strip out the legacy xous Tcp stack implementation 2022-04-17 04:59:10 +08:00
bunnie
a97b548f94 implement Shutdown for TcpStream 2022-04-17 04:07:54 +08:00
bunnie
a555f0380e initial tcplistener draft 2022-04-16 06:26:08 +08:00
bunnie
b7adbcff52 remove no longer used UDP API stubs 2022-04-05 18:43:16 +08:00
bunnie
cbb1e3f944 fix various bugs related to UDP; prep for transition to libstd-only UDP 2022-04-05 00:39:56 +08:00
bunnie
067c603e03 strip out old UDP libraries, harmonize on just libstd UDP 2022-04-04 23:15:51 +08:00
bunnie
57339dfe2f udp libstd passing inital tests 2022-04-04 22:37:01 +08:00
bunnie
b5a6c436c2 first draft at some basic libstd UDP mechanics 2022-04-04 04:49:17 +08:00
bunnie
b4c98528e8 add notes around names that are baked into libstd 2022-03-22 22:30:43 +08:00
Sean Cross
d6063d9992 net: don't close connection when setting fields
Due to overly liberal use of `.take()`, file handles were getting closed
when doing ordinary operations. This stops that.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-18 20:47:10 +08:00
Sean Cross
0b3fc8e98e net: add functions for setting ttl, nodelay
Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-18 18:43:39 +08:00
Sean Cross
08b9f0bcfc services: net: add StdTcpPeek call
This is used to peek on a stream

Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-18 15:24:01 +08:00
Sean Cross
9217c2227f services: net: add timeout to connect api
This now adds a `timeout` parameter to the connect() API call.
Additionally, connections will not be returned until they are determined
to be open, or until an error occurs (such as a timeout).

Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-18 12:08:28 +08:00
Sean Cross
89442ff4cc net: add StdTcp calls
These calls have been tested to work to create tcp connections.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-03-17 20:38:21 +08:00
bunnie
760957154e add a crappy but slightly more accurate approximation of UDP to hosted mode
It's crappy because it uses a busy wait loop to poll the udp
rx socket in order to accurately emulate the Xous async callback
feature (which is _not_ emulated for Tcp, for example).

It's more accurate because this emulation happens. But it's a lot
more complicated to implement it because zero-cost async UDP callbacks
aren't really a host-native feature (but they are a Xous-native feature!),
and I didn't want to .. pull in tokio or mio code surface into
the Xous hosted mode, seemed a bit like crushing a fly by dropping
a house on it. Maybe that's a fine solution in Oz, but Xous doesn't live in Oz.
2022-02-21 00:54:46 +08:00
bunnie
0dbf1661cb add TCP to hosted mode emulation
Total bodge -- we lop off the TCP stack at the Xous API level, and
substitute it with a native host TCP stack.

Caveat hacker: this means that a lot of OS-specific net properties
will carry through to the hosted mode emulation. This is adequate
for "smoke testing" a build but do not be shocked, *shocked* if
there are more bugs to be found because of some weird host integration
issue.
2022-02-20 21:31:32 +08:00
bunnie
e01abb29e9 update min version requirement for EC compatibility 2022-02-04 01:44:34 +08:00
bunnie
955d0182d6 some very minor ergonomic improvements around network connection UX 2022-02-03 18:38:43 +08:00
bunnie
562a930ce0 add APIs to pause the connection manager, and pause the CM while doing EC updates
It's not a good time to bug the EC to do network stuff when it's updating
itself.

...might even want to send the network into a disconnected state,
but, let's start with just turning off the connection manager
for now.
2022-02-02 02:38:19 +08:00
bunnie
925d53f646 TCP listener is "working"
Good enough so that if you type `net server` and you hit the IP
address of the device, it'll respond with something like

Hello from Precursor!
I have been up for 86087 ms.

There's still all kinds of bugs, I'm sure. But ... I'm also not
sure /why/ you would want a web server on Precursor. This is more
just to make sure that the TCP stack isn't totally broken.

The "web server" as it may be is quite broken and doesn't parse
any headers and probably sends a bogus amount of data because
I can't figure out if the content length includes some new lines
or not. But really, this just isn't in scope. Works with Chrome,
Firefox shows the status page and then says "connection reset" and hides
all the information. Whatever, browser compatibility is well beyond
my pay grade!
2022-02-01 18:54:07 +08:00
bunnie
4690075c40 clean build, but...much testing to do. 2022-01-31 04:03:31 +08:00
bunnie
177ad38db2 derive SSID scan on shellchat from the connection manager
The connection manager keeps track of all our SSIDs, not the COM.
2022-01-30 16:53:15 +08:00
bunnie
9b1c5e3f0c checkpoint to try something else 2022-01-30 15:30:21 +08:00
bunnie
2b7e428340 checkpoint, need to fix something else 2022-01-29 16:09:59 +08:00
bunnie
8592224af2 checkpoint partial TCP progress
server-side impl done, inter-crate API half-complete, now working on lib
2022-01-29 00:57:36 +08:00
bunnie
4c4ca1577f fix connection manager state machine
seems to work a lot better, but needs a lot more testing
2022-01-27 03:56:39 +08:00
bunnie
94a8a4736f make wlan status checks asynchronous
the synchronous method would lead to stutter in the animation
of the status bar during netork congestion.
2022-01-23 00:24:45 +08:00
bunnie
0cafd10e28 refactor status bar to take advantage of the new fonts 2022-01-22 18:25:39 +08:00
bunnie
4f9374e860 add enhanced debugging to the COM for wf200 2022-01-14 15:27:24 +08:00
bunnie
a4bb889a5d update wlan status to a binary version with more detailed output 2022-01-14 02:23:57 +08:00
bunnie
7aa2c7b054 a very basic e2e pddb application that tries to restore a network connection
lots of problems to solve still, but let's pick that up on the refactor
stage -- for now we want to get some evidence that the pddb API is
workable.
2022-01-09 01:29:28 +08:00
bunnie
765519ff32 major refactor of ping implementation
- moved most ping state into the Net crate proper, since the smoltcp
implementation assumes a tightly bound set of objects and lifetimes
in its icmp abstraction

- created various convenience abstractions for handling single and
multiple pings, blocking and non-blocking.

- refactored the "net" command to use the new form

Initial testing indicates there are still some bugs (seems to be
with the way we are handling timestamping and doing pong retirement)
but at least we're not getting tons of async callback errors like
we were before, and we're not shuttling obscene amounts of state
using Arc-Mutex between the input and output of the ping operations.
2021-10-27 04:38:09 +08:00
bunnie
f53c57ba3f fix up a number of issues in ping
Now that I understand how smoltcp does ping better I have regrets.
The demo example in smoltcp uses a funky macro that was a bit
misleading. I have gotten rid of that but I probably would have made
different decisions in implementing this had I understood the API better.

Anyways. It works, but has some trouble handling the cases of timeouts
sometimes.
2021-10-22 04:08:43 +08:00
bunnie
f1fe850820 ping was surprisingly hard.
not fully working yet, but the architecture is there and it builds.
smoltcp's ping implementation (or at least its demo code) was not
very amenable to splitting into modules, had to recode most of it.

the ipv6 is still a hack.
2021-10-21 06:28:11 +08:00
bunnie
1a77f0afae add formatter for net crate ip address 2021-10-20 14:10:31 +08:00
bunnie
643e9a7d62 dns. needs more work, but it is at least minimally functional. 2021-10-20 05:18:54 +08:00
bunnie
afeae79d45 add quit opcode to Net 2021-10-19 05:02:00 +08:00
bunnie
40771fbba7 flesh out UDP API...as much as we can
Multicast/Broadcast is not supported by smoltcp it seems, so those
calls are just unimplemented. But we are able to clone UdpSocket,
for the sick puppies who like to do that sort of thing.
2021-10-19 04:42:06 +08:00
bunnie
0cbca7fbe1 add UDP send and test routines 2021-10-19 01:41:22 +08:00
bunnie
84a8bf05f8 re-org api so each protocol has its own file 2021-10-18 17:33:20 +08:00
bunnie
a8c6e8047f simple end-to-end demo of receiving UDP packets asynchronously 2021-10-18 05:55:42 +08:00
bunnie
e6643e725d implement UDP rx 2021-10-18 04:02:55 +08:00
bunnie
f1296d0dfd convert route table to use heap not static memory, since we have heap 2021-10-15 15:44:16 +08:00
bunnie
b93109cad2 cleaning up net event loop, still figuring out APIs and integration
currently there is some issue with ARPs not sure where it's breaking,
suspect issue on EC side...
2021-10-11 05:21:01 +08:00
bunnie
b43eb56346 add some skeleton for a net crate; testing COM interrupts 2021-10-08 20:01:13 +08:00