forked from pandax381/microps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ether.h
47 lines (36 loc) · 1.44 KB
/
ether.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
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef ETHER_H
#define ETHER_H
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include "net.h"
#define ETHER_ADDR_LEN 6
#define ETHER_EUI64_ID_LEN 8
#define ETHER_ADDR_STR_LEN 18 /* "xx:xx:xx:xx:xx:xx\0" */
#define ETHER_HDR_SIZE 14
#define ETHER_FRAME_SIZE_MIN 60 /* without FCS */
#define ETHER_FRAME_SIZE_MAX 1514 /* without FCS */
#define ETHER_PAYLOAD_SIZE_MIN (ETHER_FRAME_SIZE_MIN - ETHER_HDR_SIZE)
#define ETHER_PAYLOAD_SIZE_MAX (ETHER_FRAME_SIZE_MAX - ETHER_HDR_SIZE)
/* see https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.txt */
#define ETHER_TYPE_IP 0x0800
#define ETHER_TYPE_ARP 0x0806
#define ETHER_TYPE_IPV6 0x86dd
extern const uint8_t ETHER_ADDR_ANY[ETHER_ADDR_LEN];
extern const uint8_t ETHER_ADDR_BROADCAST[ETHER_ADDR_LEN];
extern int
ether_addr_pton(const char *p, uint8_t *n);
extern char *
ether_addr_ntop(const uint8_t *n, char *p, size_t size);
extern void
ether_addr_create_eui64(const uint8_t *hwaddr, uint8_t *eui64);
extern int
ether_transmit_helper(struct net_device *dev, uint16_t type, const uint8_t *payload, size_t plen, const void *dst, ssize_t (*callback)(struct net_device *dev, const uint8_t *buf, size_t len));
extern int
ether_poll_helper(struct net_device *dev, ssize_t (*callback)(struct net_device *dev, uint8_t *buf, size_t size));
extern void
ether_setup_helper(struct net_device *net_device);
extern struct net_device *
ether_init(const char *name);
#endif