diff --git a/base/usr/include/kernel/mod/net.h b/base/usr/include/kernel/mod/net.h deleted file mode 100644 index abc246a0..00000000 --- a/base/usr/include/kernel/mod/net.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef KERNEL_MOD_NET_H -#define KERNEL_MOD_NET_H - -#include - -typedef uint8_t* (*get_mac_func)(void); -typedef struct ethernet_packet* (*get_packet_func)(void); -typedef void (*send_packet_func)(uint8_t*, size_t); - -struct netif { - void *extra; - - get_mac_func get_mac; - get_packet_func get_packet; - send_packet_func send_packet; - - uint8_t hwaddr[6]; - uint32_t source; - - char * driver; - - uint32_t gateway; -}; - -extern void init_netif_funcs(get_mac_func mac_func, get_packet_func get_func, send_packet_func send_func, char * device); -extern void net_handler(void * data, char * name); -extern size_t write_dhcp_packet(uint8_t * buffer); - -extern struct socket* net_open(uint32_t type); -extern int net_send(struct socket* socket, uint8_t* payload, size_t payload_size, int flags); -extern size_t net_recv(struct socket* socket, uint8_t* buffer, size_t len); -extern int net_connect(struct socket* socket, uint32_t dest_ip, uint16_t dest_port); -extern int net_close(struct socket* socket); -#endif diff --git a/base/usr/include/kernel/net/eth.h b/base/usr/include/kernel/net/eth.h index a76cc4af..3ee47bea 100644 --- a/base/usr/include/kernel/net/eth.h +++ b/base/usr/include/kernel/net/eth.h @@ -1,7 +1,6 @@ #pragma once #include -#include #define ETHERNET_TYPE_IPV4 0x0800 #define ETHERNET_TYPE_ARP 0x0806 @@ -10,6 +9,13 @@ #define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x" #define FORMAT_MAC(m) (m)[0], (m)[1], (m)[2], (m)[3], (m)[4], (m)[5] +struct ethernet_packet { + uint8_t destination[6]; + uint8_t source[6]; + uint16_t type; + uint8_t payload[]; +} __attribute__((packed)) __attribute__((aligned(2))); + void net_eth_handle(struct ethernet_packet * frame, fs_node_t * nic, size_t size); struct EthernetDevice { diff --git a/base/usr/include/kernel/net/netif.h b/base/usr/include/kernel/net/netif.h index a13e1f94..fe3eb094 100644 --- a/base/usr/include/kernel/net/netif.h +++ b/base/usr/include/kernel/net/netif.h @@ -39,3 +39,15 @@ void net_sock_alert(sock_t * sock); void net_sock_add(sock_t * sock, void * frame, size_t size); void * net_sock_get(sock_t * sock); sock_t * net_sock_create(void); + +extern long net_socket(int,int,int); +extern long net_setsockopt(int,int,int,const void*,socklen_t); +extern long net_bind(int, const struct sockaddr*, socklen_t); +extern long net_accept(int, struct sockaddr*, socklen_t*); +extern long net_listen(int,int); +extern long net_connect(int, const struct sockaddr*, socklen_t); +extern long net_getsockopt(int,int,int,void*,socklen_t*); +extern long net_recv(int,struct msghdr*,int); +extern long net_send(int, const struct msghdr*, int); +extern long net_shutdown(int, int); + diff --git a/kernel/net/arp.c b/kernel/net/arp.c index 52b286d5..0352ad40 100644 --- a/kernel/net/arp.c +++ b/kernel/net/arp.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/kernel/net/eth.c b/kernel/net/eth.c index 9622252d..6b20e09e 100644 --- a/kernel/net/eth.c +++ b/kernel/net/eth.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -27,13 +26,6 @@ #define printf(...) #endif -struct ethernet_packet { - uint8_t destination[6]; - uint8_t source[6]; - uint16_t type; - uint8_t payload[]; -} __attribute__((packed)) __attribute__((aligned(2))); - extern spin_lock_t net_raw_sockets_lock; extern list_t * net_raw_sockets_list; extern void net_ipv4_handle(void * packet, fs_node_t * nic, size_t); diff --git a/kernel/net/loop.c b/kernel/net/loop.c index 5b3f80e7..1caf60c8 100644 --- a/kernel/net/loop.c +++ b/kernel/net/loop.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/kernel/sys/syscall.c b/kernel/sys/syscall.c index 34bd6412..e3029dcb 100644 --- a/kernel/sys/syscall.c +++ b/kernel/sys/syscall.c @@ -31,6 +31,7 @@ #include #include #include +#include static char hostname[256]; static size_t hostname_len = 0; @@ -1156,17 +1157,6 @@ long sys_times(struct tms *buf) { return arch_perf_timer() / arch_cpu_mhz(); } -extern long net_socket(); -extern long net_setsockopt(); -extern long net_bind(); -extern long net_accept(); -extern long net_listen(); -extern long net_connect(); -extern long net_getsockopt(); -extern long net_recv(); -extern long net_send(); -extern long net_shutdown(); - extern long ptrace_handle(long,pid_t,void*,void*); static long (*syscalls[])() = { diff --git a/modules/e1000.c b/modules/e1000.c index 861be4fd..61ba683b 100644 --- a/modules/e1000.c +++ b/modules/e1000.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include