Skip to content

Conversation

@scaprile
Copy link
Collaborator

  • 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

@scaprile scaprile requested review from cpq and robertc2000 September 23, 2025 17:56
#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); \
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Member

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?

Copy link
Collaborator Author

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
Copy link
Member

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 ?

Copy link
Collaborator Author

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,
Copy link
Member

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.

Copy link
Collaborator Author

@scaprile scaprile Nov 5, 2025

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"...

@scaprile scaprile merged commit b53d843 into master Nov 5, 2025
257 of 274 checks passed
@scaprile scaprile deleted the mip6 branch November 5, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants