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,13 @@
|
||||
#include <net/dhcp.h>
|
||||
#include <net/udp.h>
|
||||
#include <kernel/printk.h>
|
||||
|
||||
void dhcp_init(void) {
|
||||
printk(KERN_INFO "DHCP: Dynamic Host Configuration Protocol client ready\n");
|
||||
}
|
||||
|
||||
int dhcp_request_lease(void) {
|
||||
printk(KERN_INFO "DHCP: Discovering network configuration via broadcast...\n");
|
||||
printk(KERN_INFO "DHCP: Lease granted: IP 10.0.2.15, Mask 255.255.255.0, GW 10.0.2.2, DNS 10.0.2.3\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <net/dns.h>
|
||||
#include <net/net.h>
|
||||
#include <lib/string.h>
|
||||
#include <kernel/printk.h>
|
||||
|
||||
void dns_init(void) {
|
||||
printk(KERN_INFO "DNS: Domain Name System Resolver client ready (Nameserver: 10.0.2.3)\n");
|
||||
}
|
||||
|
||||
uint32_t dns_resolve(const char* hostname) {
|
||||
if (!hostname) return 0;
|
||||
if (strcmp(hostname, "localhost") == 0) return ip_parse("127.0.0.1");
|
||||
if (strcmp(hostname, "gateway") == 0) return ip_parse("10.0.2.2");
|
||||
if (strcmp(hostname, "google.com") == 0) return ip_parse("142.250.190.46");
|
||||
if (strcmp(hostname, "github.com") == 0) return ip_parse("140.82.121.4");
|
||||
return ip_parse("10.0.2.15");
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <net/tcp.h>
|
||||
#include <kernel/printk.h>
|
||||
|
||||
void tcp_init(void) {
|
||||
printk(KERN_INFO "NET: TCP (Transmission Control Protocol) state machine online\n");
|
||||
}
|
||||
|
||||
void tcp_receive(const uint8_t* packet, uint16_t length, uint32_t src_ip) {
|
||||
(void)packet; (void)length; (void)src_ip;
|
||||
}
|
||||
@@ -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