summaryrefslogtreecommitdiff
path: root/net/inet.h
blob: 1cb71b2b30b2686130f1a38bf761eb816d25760b (plain)
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
/*
 * @file
 * https://en.wikipedia.org/wiki/OSI_model
 */
#include <stdint.h>
#include <stdbool.h>
#include <netdev.h>

#define ARP_ETHERNET 1
#define ARP_IPV4 0x800
#define ARP_REPLY 2
#define ARP_REQUEST 1

#define ETH_P_ARP	0x0806
#define ETH_P_IPV4	0x0800

#define IPV4_P_ICMP	0x1
#define IPV4_P_TCP	0x6
#define IPV4_P_UDP	0x11

#define ICMP_ECHO_REPLY 0
#define ICMP_UNREACHABLE 3
#define ICMP_ECHO_REQUEST 8

uint16_t checksum(void *addr, int count);

uint16_t ntohs(uint16_t val);
uint16_t htons(uint16_t val);
uint32_t ntohl(uint32_t val);
uint32_t htonl(uint32_t val);

bool     net_packet(struct netdev *dev);