aboutsummaryrefslogtreecommitdiff
path: root/kernel/inc/net.h
blob: 211cf90b11c2d4be97a015b415435244a6d78b3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// MIT License, Copyright (c) 2020 Marvin Borner

#ifndef NET_H
#define NET_H

#include <def.h>

#define ETHERNET_TYPE_IP4 0x0800
#define ETHERNET_TYPE_IP6 0x86dd
#define ETHERNET_TYPE_ARP 0x0806

struct ethernet_packet {
	u8 dst_mac_addr[6];
	u8 src_mac_addr[6];
	u16 type;
	u8 data[];
} __attribute__((packed));

struct ip_packet {
	u8 version_ihl;
	u8 dscp_ecn;
	u16 length;
	u16 id;
	u8 flags_fragment;
	u8 ttl;
	u8 protocol;
	u16 checksum;
	u8 src_ip[4];
	u8 dst_ip[4];
	u8 data[];
} __attribute__((packed));

void ethernet_handle_packet(struct ethernet_packet *packet, int len);
void net_install();

#endif