forked from pandax381/microps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethernet.h
35 lines (27 loc) · 964 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
31
32
33
34
35
#ifndef ETHERNET_H
#define ETHERNET_H
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include "net.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];
extern int
ethernet_addr_pton (const char *p, uint8_t *n);
extern char *
ethernet_addr_ntop (const uint8_t *n, char *p, size_t size);
extern int
ethernet_init (void);
#endif