net: Cleanup headers
This commit is contained in:
parent
1f5fb5be2e
commit
e80d2da3f3
@ -1,34 +0,0 @@
|
||||
#ifndef KERNEL_MOD_NET_H
|
||||
#define KERNEL_MOD_NET_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/vfs.h>
|
||||
#include <kernel/mod/net.h>
|
||||
|
||||
#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 {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <kernel/syscall.h>
|
||||
#include <kernel/vfs.h>
|
||||
#include <kernel/hashmap.h>
|
||||
#include <kernel/mod/net.h>
|
||||
#include <kernel/net/netif.h>
|
||||
#include <kernel/net/eth.h>
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <kernel/list.h>
|
||||
#include <kernel/spinlock.h>
|
||||
#include <kernel/vfs.h>
|
||||
#include <kernel/mod/net.h>
|
||||
#include <kernel/net/netif.h>
|
||||
#include <kernel/net/eth.h>
|
||||
#include <kernel/net/ipv4.h>
|
||||
@ -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);
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <kernel/vfs.h>
|
||||
#include <kernel/spinlock.h>
|
||||
#include <kernel/list.h>
|
||||
#include <kernel/mod/net.h>
|
||||
#include <kernel/net/netif.h>
|
||||
#include <kernel/net/eth.h>
|
||||
#include <errno.h>
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <kernel/syscall.h>
|
||||
#include <kernel/misc.h>
|
||||
#include <kernel/ptrace.h>
|
||||
#include <kernel/net/netif.h>
|
||||
|
||||
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[])() = {
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <kernel/spinlock.h>
|
||||
#include <kernel/time.h>
|
||||
#include <kernel/vfs.h>
|
||||
#include <kernel/mod/net.h>
|
||||
#include <kernel/net/netif.h>
|
||||
#include <kernel/net/eth.h>
|
||||
#include <kernel/module.h>
|
||||
|
Loading…
Reference in New Issue
Block a user