Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / ip.h
1 #ifndef _IPXE_IP_H
2 #define _IPXE_IP_H
3
4 /** @file
5  *
6  * IP protocol
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <stdint.h>
13 #include <ipxe/in.h>
14 #include <ipxe/list.h>
15 #include <ipxe/retry.h>
16 #include <ipxe/netdevice.h>
17
18 struct io_buffer;
19
20 /* IP constants */
21
22 #define IP_VER                  0x40U
23 #define IP_MASK_VER             0xf0U
24 #define IP_MASK_HLEN            0x0fU
25 #define IP_MASK_OFFSET          0x1fffU
26 #define IP_MASK_DONOTFRAG       0x4000U
27 #define IP_MASK_MOREFRAGS       0x2000U
28 #define IP_PSHLEN       12
29
30 /* IP header defaults */
31 #define IP_TOS          0
32 #define IP_TTL          64
33
34 /** An IPv4 packet header */
35 struct iphdr {
36         uint8_t  verhdrlen;
37         uint8_t  service;
38         uint16_t len;
39         uint16_t ident;
40         uint16_t frags;
41         uint8_t  ttl;
42         uint8_t  protocol;
43         uint16_t chksum;
44         struct in_addr src;
45         struct in_addr dest;
46 } __attribute__ (( packed ));
47
48 /** An IPv4 pseudo header */
49 struct ipv4_pseudo_header {
50         struct in_addr src;
51         struct in_addr dest;
52         uint8_t zero_padding;
53         uint8_t protocol;
54         uint16_t len;
55 };
56
57 /** An IPv4 address/routing table entry */
58 struct ipv4_miniroute {
59         /** List of miniroutes */
60         struct list_head list;
61
62         /** Network device */
63         struct net_device *netdev;
64
65         /** IPv4 address */
66         struct in_addr address;
67         /** Subnet mask */
68         struct in_addr netmask;
69         /** Gateway address */
70         struct in_addr gateway;
71 };
72
73 extern struct list_head ipv4_miniroutes;
74
75 extern struct net_protocol ipv4_protocol __net_protocol;
76
77 extern int ipv4_has_any_addr ( struct net_device *netdev );
78 extern int parse_ipv4_setting ( const struct setting_type *type,
79                                 const char *value, void *buf, size_t len );
80 extern int format_ipv4_setting ( const struct setting_type *type,
81                                  const void *raw, size_t raw_len, char *buf,
82                                  size_t len );
83
84 #endif /* _IPXE_IP_H */