Orion
Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)diff --git a/net/net.h b/net/net.h new file mode 100644 index 0000000..3fd113b --- /dev/null +++ b/net/net.h @@ -0,0 +1,40 @@ +#ifndef KERNEL_NET_H +#define KERNEL_NET_H + +#include <stdint.h> +#include <stddef.h> + +typedef struct NetIF NetIF; + +/* Structure for a Network Interface */ +struct NetIF { + uint16_t type; + void (*transmit)(void *, size_t); + void (*get_mac)(char *); + + uint8_t ip[4], mac[6]; + uint8_t gatewayIp[4], gatewayMac[6]; + uint8_t dnsIp[4], dnsMac[6]; + NetIF *next; +}; + +uint16_t htons(uint16_t hostshort); +uint32_t htonl(uint32_t hostlong); +uint16_t ntohs(uint16_t hostshort); +uint32_t ntohl(uint32_t hostlong); +void init_net(void); +NetIF *net_create_interface(uint16_t type, void (*transmit)(void *, size_t), + void (*get_mac)(char *buf)); + +void ethernet_receive_frame(NetIF *netif, void *data, size_t len); +void ethernet_send_frame(NetIF *netif, uint8_t dst[6], uint16_t type, + void *data, size_t len); + +void arp_receive_packet(NetIF *netif, void *data, size_t len); +void arp_request(NetIF *netif, uint8_t dstIp[4], uint8_t *res); + +void ipv4_receive_packet(NetIF *netif, void *data, size_t len); +void ipv4_send_packet(NetIF *netif, uint8_t dst[4], uint8_t proto, + uint16_t flags, void *data, size_t len); + +#endif