Commit graph

173 commits

Author SHA1 Message Date
bunnie
42c6417e46 incorporate rach mirgations into net 2025-05-11 12:36:33 +08:00
bunnie
4f14a67504 formatting changes due to changes in nightly rust
needed to get a clean check on gh
2025-02-01 22:26:40 +08:00
bunnie
043dfd84ae update formatting to latest nightly rules 2024-09-24 01:49:45 +08:00
bunnie
8424d19ea9 fixup API to not rely on copy, instead use borrow
also some more regex fixup
2024-09-23 00:00:41 +08:00
bunnie
95a31a369c fix Copy derive and related issues in net 2024-09-22 21:55:20 +08:00
bunnie
b514d31fed regex search/replace instances of xous_ipc::String to String 2024-09-22 14:26:41 +08:00
bunnie
8d30c5bfc5 format services/net 2024-01-14 22:31:48 +08:00
bunnie
8ec08c9c76 fix rust v1.75.0 warnings that are probably benign
a lot of re-import warnings have cropped up. While I appreciate
their studiousness on this, the problem is that removing some
of these exports in the API crate could mean that future users
who want access to some API features that aren't used in this
configuration are now unaccessible.

I think it's not a huge problem at the moment, just spam-cleaning
the warnings because there are too many to deal with carefully
at the moment.
2024-01-04 19:15:28 +08:00
bunnie
9c2523ded4 fix #227 2023-12-22 22:20:55 +08:00
bunnie
85def0adc5 don't block on connection manager
refactor CM routines so if the CM is hung it won't block the net
main thread.
2023-12-22 09:38:43 +08:00
bunnie
fcd7bc9bb8 allow pump to be falliable
attempt to reduce blocking in net path
2023-12-22 09:36:17 +08:00
nworbnhoj
e8e875742e replace more TcpStream::connect(&str) with TcpStream::connect((&str, u16))
resolves #453
2023-11-30 20:29:15 +11:00
bunnie
6b98322754 fix invalid unwrap()
unwrap on a routine always returns None, so the unwrap() has no meaning
(probably originally introduced just as a way to get match arms to
have the same return result without thinking too much about it).
2023-10-12 02:45:43 +08:00
bunnie
765a3e6294 harden against invalid EC configurations
panics happen due to certain default states of the EC
wire protocol, due to a MAC address being passed in that is
not unicast when garbage data is present.
2023-10-03 19:12:15 +08:00
bunnie
2faa518df8 add debug level setting on net stack 2023-10-03 17:18:07 +08:00
bunnie
ee18cb8e14 passing most nettests now. mostly an issue of poking at loopbacks. 2023-10-03 17:12:34 +08:00
bunnie
e78b40aa36 cleanup the poll timeouts 2023-09-29 11:48:52 +08:00
bunnie
5e411f3562 clean up warnings, fix icmp init 2023-09-29 06:36:27 +08:00
bunnie
64e9248815 move smoltcp to latest; no hard errors, but also panics 2023-09-29 05:30:55 +08:00
Sean Cross
5dfad296ae xous: mark MemoryRange::as_slice and friends as unsafe
Mark `MemoryRange::as_slice()` and `MemoryRange::as_slice_mut()` as
unsafe.

This is due to the fact that not all representable types can be cast to
an arbitrary value. For example, if Process A sends random values to
Process B, then Process B casts the memory to a slice of `bool`, then
any values that are not 0 or 1 are undefined.

Because these functions can leak UB into the program, they are marked as
unsafe.

This patch adds `unsafe {}` blocks to all instances where this function
is called. Additionally, all instances have been checked to verify that
they do not cast to any invalid types -- most use `u8` or `u32`.

Additionally, the long-deprecated `MemoryRange::from_parts()` call was
removed, since that causes UB without being marked as unsafe.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-09-12 10:07:38 +08:00
bunnie
39cd7f8b0a cleanup Rust lint that appeared in 1.70 2023-06-04 19:10:10 +08:00
bunnie
015f0fb8b3 sort scans by strength, and retire AP's that we haven't seen in a while 2023-05-29 03:20:04 +08:00
bunnie
0b32ac073b add scan state information to ssid scans
ssid scans can now be in-progress, and they also record
the time elapsed since the last scan was performed.

this allows the network manager to be a bit smarter about when
it decides to kick off a scan.

the ssid scan dialog box is also updated to show
the scan results in progress. This addresses #336.
2023-05-29 02:12:28 +08:00
Jean-Pierre De Jesus DIAZ
3e2eb63663
imports: remove com_rs-ref
The crate just re-exports the com_rs crate. This patch changes usages of
com_rs-ref to use com_rs directly.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-05-02 14:33:17 +02:00
bunnie
7cd2512e95 turn down some debug spew 2023-01-30 18:32:06 +08:00
Gianguido Sorà
a7b950684f Merge branch 'main' into feat/user-preferences 2022-10-27 15:34:05 +02:00
bunnie
67fc21fbdd harmonize hosted mode selection, but retain an explicit hosted flag
In general, hosted mode is assumed "by default" if the target
is not Xous. This allows packages to be built cleanly on command
lines that don't know to pass a --feature flag to specify a target.

However, an explicit "hosted" flag is still retained so that we
can confirm the build system intent. This saves us from the failure
mode that we thought we were building for target A, but accidentally
ommitted the flag, and instead we've been silently building for
"hosted" mode without any warning. The main consumer of the "hosted"
flag is now just the build.rs script inside of the utralib.
2022-10-25 17:21:02 +08:00
Gianguido Sorà
1636259003 Merge branch 'main' into feat/user-preferences 2022-10-20 10:46:01 +02:00
Gianguido Sorà
073110c737 net: add method to turn on wifi without scanning 2022-10-13 17:58:52 +02:00
bunnie
f815ed85b5 fix rust 1.64.0 rkyv warning regressions on unused enum types
rkyv-derived enums throw warnings that they are unused.
Not sure how to get rid of them; I've tried surrounding them in
`#[allow(dead_code)]` directives, and also explicitly creating
each enum variant that I'm aware of through some dummy code and
some log prints of the dummy code calls to ensure the results are
used, and the warnings still persist.

Significantly, the warnings only happen for enums that take
a value. Simple rkyv enums do not throw a warning.

These warnings overwhelm the build logs, so they need to be isolated
in order for us to ensure that the build is clean of other more
important warnings.

The method chosen to isolate them is to take the enums that are
problematic, carve them into their own special file, and add
a file-wide `#![allow(dead_code)]` directive. This only happens
in 7 service crates, and this change commits all of the modifications
in a single big commit that could be undone later if this turns out
to be a compiler regression or something similar.

I also opened an issue with the rkyv maintainer to see what his
opinion is on the situation.

https://github.com/rkyv/rkyv/issues/318
2022-10-09 17:17:20 +08:00
bunnie
4e40ae6c5d move from target selectors to feature selectors for back-ends
This will allow for e.g. xous on riscv32-imac but not a precursor
target, for example: by using feature selectors we get to have
a bigger range of targets that we support, such as for implementations
that haven't been upstreamed or have official target-triples.

The downsides are:

- patch override libraries don't absorb feature flags. so, for
example, the AES crate that is used to patch other crates won't
be aware of the target features without modifying the referencing
crates.

- features are normally meant to be additive, but target features
are mutually exclusive. The mutex is enforced by a check in
utralib that throws a panic on build if two targets are accidentally
selected at the same time.
2022-10-02 02:56:44 +08:00
bunnie
035bdaf986 complete wifi on/off interface
fully integrates wifi on and off commands. measured standby power
when wifi is off is "immeasurable" (0 mA), so probably < 1-2mA.

fix ui transitions so that the off request is respected, through
sleep/resume cycles as well.
2022-09-20 19:36:55 +08:00
bunnie
59a3bc0370 cleanup patches 2022-08-20 00:38:21 +08:00
bunnie
a5aee2b0d5 patches for debug 2022-08-16 17:54:36 +08:00
bunnie
205f0a3be3 increase threshold for retiring closes
when not in heavy loopback mode, this occurs more rarely and
probably for more legitimate reasons.
2022-08-06 00:35:18 +08:00
bunnie
bd8afc6de7 clean up debug spew for merge to main 2022-08-05 15:50:11 +08:00
bunnie
6f86aee991 give loopback its own rx buffer
instead of sharing the wifi buffer loopback has its own buffer.
this eliminates a race condition that happens whenever an Rx
happens to happen on the wifi interface while there's loopback
traffic in progress.

also, i see a lot of opportunities to optimize the net stack now
that i have tweaked this path; it might be interesting to break
the receive interrupt out directly into the COM crate instead
of passing it through LLIO then NET then COM and having COM
drain the RX buffer immediately into a local "infinite" sized
queue.

The llio->net->com loop exists because the interrupt handler
for all the i/o is shared within one hardware block, but maybe
i can create an additional interrupt responder for the com
interface just to optimize things a bit in a future SOC update.

Alternatively, I could move all the interrupts into COM and not
have them resident in LLIO. This would optimize for COM latency
at the expence of I2C latency, but that's probably OK because
I2C is much less latency sensitive (i2c and com interrupt, as
mentioned above, share the same hardware block for external
pin-based interrupts).
2022-08-05 15:12:57 +08:00
bunnie
2658dd4b71 add peek handler, heuristic to close sockets that are stuck
- Peek now has a handler for reads that can't be met immediately
- add a count to the number of times a close socket has been polled,
if it exceeds a threshold close the socket anyways. This is a compromise
between trying to figure out how to implement a fully non-blocking TcpClose,
and having an interlocked one that cleans up state but ends up blocking
the case where you have, in the same thread, a sender and receiver
(which is ironically somehow legal and does not cause deadlock,
because the TcpClose in Unix is not blocking on internal state
being cleared up).
2022-08-05 05:07:44 +08:00
bunnie
495ca1e2b7 fix timeouts, peek
- timeouts were being overwritten before they were read
- peek now behaves according to what the test bench expects
2022-08-05 05:05:41 +08:00
bunnie
32e78039b7 xous-side of 0-port listener binding
0 is a "valid" port and it means OS please give me a port.
This implements a method where a random port is chosen until
you find one that's not occupied.
2022-08-05 05:04:35 +08:00
bunnie
24a0848a43 add nonblocking flag to opcode map 2022-08-05 05:02:39 +08:00
bunnie
8a797764c1 (possibly dubious) fix on 'unattended' Stream close
If a Stream is opened and a process isn't constantly polling it,
it'll never close if the remote side goes away -- you'll just
end up hanging in a FIN-WAIT-2 condition.

Add some logic to detect this and close out streams automatically
where the remote has hung up.

I'm not actually sure this is what you're *supposed* to do, but,
lacking a formal specification, all I can do is try to get
this thing to pass the test bench. And pass it does.
2022-08-04 21:10:17 +08:00
bunnie
80f78a0f5d tweak debug noise down 2022-08-04 21:09:49 +08:00
bunnie
9f3bef04cc tweak debug noise down 2022-08-04 21:09:24 +08:00
bunnie
6045c75cf0 refactor TcpClose; fix RxWait
TcpClose should not immediately remove the socket. It
has to wait until the FIN comes. Add a fin waiter state.
Also rewrite to use "retain". Woo. I'm starting to get
the hang of Rust closures. Only took a couple years.

RxWait gets stuck in CLOSE_WAIT state. It's a state where
you "could" transmit, but you can't receive anymore.
In this case respond with a 0-length receive? That seems
to be what leads to the right behavior. I would have thought
you'd want to respond with a timeout error but that doesn't
match what's in the test bench.
2022-08-04 05:03:08 +08:00
bunnie
5d2d7ac40f add tooling for the loopback interface
- add 127.0.0.1 to the list of IPs listened to by smoltcp
- add some static Atomic types to store the IP and MAC address
so we can process packets in other areas to detect the loopback
state
- add a routine to extract the loopback packets when they happen
- bunch of debug visibility tweaks
2022-08-03 03:34:29 +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
7606d244e8 tweak debug output levels 2022-08-03 03:21:43 +08:00
bunnie
ca30657370 attempt to integrate the std net test suite.
newsflash: it doesn't work. still handy to have the test code around
as reference.
2022-08-02 16:45:56 +08:00
bunnie
7541d39fd6 add a static variable to contain our IPV4 address
this is used to do address binding checking from library calls,
so we can reject binding to address that are not our actual IP
address.
2022-08-02 16:45:17 +08:00