-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Introduce IPv6, unit tests pass #3282
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
Conversation
scaprile
commented
Sep 23, 2025
- IPv4 keeps working, all tests pass
- IPv6 I can't test. Some address-related stuff has been refactored to be more "cesantish" and to accomodate link-layer independence
src/drivers/stm32h.h
Outdated
| #if defined(MG_ENABLE_IPV6) && MG_ENABLE_IPV6 | ||
| #define MG_IPV6_INIT(mif) \ | ||
| do { \ | ||
| memcpy(mif.ip6ll, (uint8_t[16]) MG_TCPIP_LINK_LOCAL, 16); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to keep this approach for initializing static configurations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not, but let's start the game with something.
I added 64-bit htonll functions to help with other approaches.
|
|
||
| #if defined(MG_ENABLE_IPV6) && MG_ENABLE_IPV6 | ||
|
|
||
| #ifndef MG_TCPIP_GLOBAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird macro name. What does it even mean? Shall we rename it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we must
| uint8_t hops; // Hop limit | ||
| uint8_t src[16]; // Source IP | ||
| uint8_t dst[16]; // Destination IP | ||
| uint64_t src[2]; // Source IP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not uint32_t x 4 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because comparisons are faster and sentences shorter and functions more readable with uint64_t
| #endif | ||
|
|
||
| static bool tx_udp(struct mg_tcpip_if *ifp, uint8_t *mac_dst, | ||
| struct mg_addr *ip_src, struct mg_addr *ip_dst, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to rename
struct mg_addr *ip_src
to
struct mg_addr *src_addr
becase ip_src->sport down below looks weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, I maintained the same naming scheme across all functions. In fact, using 'addr' doesn't make sense: addr->port, ip does make sense, it is the IP layer information and it is the source endpoint. 'ip' doesn't mean "address", it means IP.
If I use 'l3' you will sure not like it... 'ip' is OK for me, 'addr' is not, ip->ip4 and ip->port make sense, addr->ip4 and addr->port do not
Maybe we should use l3, or net, or nwk, or "half-socket"...