-
Notifications
You must be signed in to change notification settings - Fork 433
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
use core::net types for IpAddress #1000
base: main
Are you sure you want to change the base?
Conversation
I intentionally did not do this because it will cause extra RAM usage when you enable IPv4 only. We conditionally enable the enum cases so |
e6623e0
to
7554dea
Compare
OK, I see, this is a fair point. My vision is that embedded systems that use an IP stack are generally not the most memory constrained one, and that they usually won't handle more that one or two I'm not sure what is the policy in smoltcp, but if it is to try to squeeze up to the last bit than can be squeezed, then I agree this PR is a bad idea. |
baba4ea
to
908d774
Compare
there's also the question of what happens when you pass an IP addr to the stack that is of a version that is not enabled. Before this was imposssible, now it'll need to either return an error or panic. |
aa2c961
to
0690d43
Compare
Similar to what was done for Ipv4Address and Ipv6Address. - use core::net::IpAddr as the ip address type - remote v4() and v6() constructor, use core IpAddr::V4(Ipv4Addr::new(_)) instead - Remove IpVersion from public API
0690d43
to
0c6666d
Compare
My system has 4kiB of RAM, so I’d like just about every byte I can find. |
Wow, a 4kiB MCU with an IP stack ! That's seriously impressive ! Curious what kind of MCU it is ? And does it have an internal ethernet MAC device or do you use an external ethernet MAC ? Anyway, I agree that this PR is not desirable for such use case. |
Hang on. I’m an idiot. I’m mixing up my projects. This latest one uses the EFM32GG11, which has 512 KiB. On top of that, I see I only allocate space for a single address, so that 12-byte overhead doesn’t seem that bad (for my configuration). I retract my statement. :) |
I don't think we have many places where this occurs? So it might not be such a big problem? |
It occurs in every function in the public API that takes an IpAddress. For example, what happens when smoltcp is configured to ipv4-only and you try to set a v6 address in an interface, or try to connect a smoltcp socket to a v6 address? |
We could introduce a trait |
Similar to what was done for Ipv4Address and Ipv6Address.