forked from mit-pdos/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 14
/
net.h
56 lines (47 loc) · 1.31 KB
/
net.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
48
49
50
51
52
53
54
55
56
#define NETDEV_TYPE_ETHERNET (0x0001)
#define NETDEV_TYPE_SLIP (0x0002)
#include "if.h"
#define NETDEV_FLAG_BROADCAST IFF_BROADCAST
#define NETDEV_FLAG_MULTICAST IFF_MULTICAST
#define NETDEV_FLAG_P2P IFF_POINTOPOINT
#define NETDEV_FLAG_LOOPBACK IFF_LOOPBACK
#define NETDEV_FLAG_NOARP IFF_NOARP
#define NETDEV_FLAG_PROMISC IFF_PROMISC
#define NETDEV_FLAG_RUNNING IFF_RUNNING
#define NETDEV_FLAG_UP IFF_UP
#define NETPROTO_TYPE_IP (0x0800)
#define NETPROTO_TYPE_ARP (0x0806)
#define NETPROTO_TYPE_IPV6 (0x86dd)
#define NETIF_FAMILY_IPV4 (0x02)
#define NETIF_FAMILY_IPV6 (0x0a)
#ifndef IFNAMSIZ
#define IFNAMSIZ 16
#endif
struct netdev;
struct netif {
struct netif *next;
uint8_t family;
struct netdev *dev;
/* Depends on implementation of protocols. */
};
struct netdev_ops {
int (*open)(struct netdev *dev);
int (*stop)(struct netdev *dev);
int (*xmit)(struct netdev *dev, uint16_t type, const uint8_t *packet, size_t size, const void *dst);
};
struct netdev {
struct netdev *next;
struct netif *ifs;
int index;
char name[IFNAMSIZ];
uint16_t type;
uint16_t mtu;
uint16_t flags;
uint16_t hlen;
uint16_t alen;
uint8_t addr[16];
uint8_t peer[16];
uint8_t broadcast[16];
struct netdev_ops *ops;
void *priv;
};