-
Notifications
You must be signed in to change notification settings - Fork 4
/
ethernet.h
30 lines (23 loc) · 893 Bytes
/
ethernet.h
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
#ifndef ETHERNET_H
#define ETHERNET_H
#include <stddef.h>
#include <stdint.h>
#define ETHERNET_ADDR_LEN 6
#define ETHERNET_ADDR_STR_LEN 18 /* "xx:xx:xx:xx:xx:xx\0" */
#define ETHERNET_HDR_SIZE 14
#define ETHERNET_TRL_SIZE 4
#define ETHERNET_FRAME_SIZE_MIN 64
#define ETHERNET_FRAME_SIZE_MAX 1518
#define ETHERNET_PAYLOAD_SIZE_MIN \
(ETHERNET_FRAME_SIZE_MIN - (ETHERNET_HDR_SIZE + ETHERNET_TRL_SIZE))
#define ETHERNET_PAYLOAD_SIZE_MAX \
(ETHERNET_FRAME_SIZE_MAX - (ETHERNET_HDR_SIZE + ETHERNET_TRL_SIZE))
#define ETHERNET_TYPE_IP (0x0800)
#define ETHERNET_TYPE_ARP (0x0806)
#define ETHERNET_TYPE_IPV6 (0x86dd)
extern const uint8_t ETHERNET_ADDR_ANY[ETHERNET_ADDR_LEN];
extern const uint8_t ETHERNET_ADDR_BROADCAST[ETHERNET_ADDR_LEN];
int ethernet_addr_pton(const char *p, uint8_t *n);
char *ethernet_addr_ntop(const uint8_t *n, char *p, size_t size);
int ethernet_init(void);
#endif