Skip to content

Implement UDP #55

Open
jastintime wants to merge 4 commits intoUMN-Kernel-Object:trunkfrom
jastintime:udp
Open

Implement UDP #55
jastintime wants to merge 4 commits intoUMN-Kernel-Object:trunkfrom
jastintime:udp

Conversation

@jastintime
Copy link
Copy Markdown
Contributor

start off UDP header.

questions:
should we use a size_t or something similar or u64 everything
how do we want to model our general networking code(plan9 style would be sick 🔥 )

useful UDP links:
https://www.rfc-editor.org/rfc/rfc768

Notes so I don't forget:
UDP and TCP checksum is the same, can be brought out to a common file

@remexre
Copy link
Copy Markdown
Member

remexre commented Oct 9, 2025

should we use a size_t or something similar or u64 everything

if it's the size of a thing, usize (we don't have a literal equiv of ptrdiff_t, but we have isize ig)

how do we want to model our general networking code(plan9 style would be sick 🔥 )

you should do what you think is best lol

@jastintime jastintime force-pushed the udp branch 4 times, most recently from 47f4498 to 400eb78 Compare January 13, 2026 01:10
@jastintime jastintime force-pushed the udp branch 4 times, most recently from dc7c097 to d381eb1 Compare March 22, 2026 03:55
@jastintime
Copy link
Copy Markdown
Contributor Author

TODO: fix CI format complaints ( requires make format on kieran branch first)

TODO: header guards on my headers

@jastintime jastintime force-pushed the udp branch 2 times, most recently from ac4fe4d to e58d66b Compare March 22, 2026 17:15
Comment thread src/kernel/net/udp.c
@jastintime jastintime marked this pull request as ready for review March 22, 2026 17:17
@jastintime
Copy link
Copy Markdown
Contributor Author

good for review on Wednesday, needs some squashing, moving around and testing but core functionality is there.

Comment thread src/kernel/include/net/udp.h Outdated
u16 calc_chksum(u16 *buf, usize size);

// u64 udp_read(struct udp_header *header, u8 *data, usize len);
u64 udp_send_datagram(u16 src_port, u16 dst_port, struct ip_address src_addr,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc magic COUNTED_BY lets you say that len is the length of the buffer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-counted_005fby

this seems to apply only to struct fields.

u64 udp_send_datagram(u16 src_port, u16 dst_port, struct ip_address src_addr,
                      struct ip_address dst_addr, [[gnu::counted_by (len)]] u8 *data, usize len);

results in

udp.h:53:81: error: 'counted_by' attribute is not allowed for a non-field declaration 'data'

Comment thread src/kernel/net/udp.c Outdated
Comment thread src/kernel/net/udp.c Outdated
Comment thread src/kernel/net/udp.c Outdated
Comment thread src/kernel/net/udp.c Outdated
Comment thread src/kernel/net/udp.c Outdated
Signed-off-by: jastintime <130672671+jastintime@users.noreply.github.com>
Signed-off-by: jastintime <130672671+jastintime@users.noreply.github.com>
Signed-off-by: jastintime <130672671+jastintime@users.noreply.github.com>
Signed-off-by: jastintime <130672671+jastintime@users.noreply.github.com>
@jastintime
Copy link
Copy Markdown
Contributor Author

jastintime commented Mar 28, 2026

this now depends on #65 which depends on #73 being merged.

will fail CI until those get merged, should be good for looking over though.

7ce6d6b will be removed and udp added to net/include.mak once #73 gets merged.

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.

2 participants