blob: f47ca53922bcd3bbe85fdad2e1379903b25cad54 (
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
|
#pragma once
#include <camellia/types.h>
#include <stdint.h>
typedef uint8_t mac_t[6];
extern struct net_state {
mac_t mac;
uint32_t ip;
handle_t raw_h;
} state;
enum { /* ethertype */
ET_IPv4 = 0x800,
ET_ARP = 0x806,
};
struct ethernet {
const mac_t *src, *dst;
uint16_t type;
};
void arp_parse(const uint8_t *buf, size_t len);
void icmp_parse(const uint8_t *buf, size_t len);
void ipv4_parse(const uint8_t *buf, size_t len);
void ether_parse(const uint8_t *buf, size_t len);
uint8_t *ether_start(size_t len, struct ethernet ether);
void ether_finish(uint8_t *pkt);
|