mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-26 00:52:50 +00:00
feat: Massive OS expansion with IPC, Sound & TTS, Block layer, FAT32/ext2/sysfs, Signals, Syscalls, Modules, Drivers & 50+ LazyBox applets
This commit is contained in:
1 parent
5662be29f5
commit
d680335f05
64 files changed
+2370
-166
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#include <net/udp.h>
|
||||
#include <lib/string.h>
|
||||
#include <kernel/printk.h>
|
||||
|
||||
void udp_init(void) {
|
||||
printk(KERN_INFO "NET: UDP (User Datagram Protocol) transport layer online\n");
|
||||
}
|
||||
|
||||
void udp_receive(const uint8_t* packet, uint16_t length, uint32_t src_ip) {
|
||||
(void)packet; (void)length; (void)src_ip;
|
||||
}
|
||||
|
||||
void udp_send(uint32_t dst_ip, uint16_t src_port, uint16_t dst_port, const void* data, uint16_t len) {
|
||||
uint8_t buffer[1500];
|
||||
udp_header_t* udp = (udp_header_t*)buffer;
|
||||
udp->src_port = htons(src_port);
|
||||
udp->dst_port = htons(dst_port);
|
||||
udp->length = htons((uint16_t)(sizeof(udp_header_t) + len));
|
||||
udp->checksum = 0;
|
||||
|
||||
if (data && len > 0) {
|
||||
memcpy(buffer + sizeof(udp_header_t), data, len);
|
||||
}
|
||||
|
||||
net_send_ip(dst_ip, IP_PROTO_UDP, buffer, (uint16_t)(sizeof(udp_header_t) + len));
|
||||
}
|
||||
Reference in new issue
Block a user