iPXE
ip.h
Go to the documentation of this file.
1#ifndef _IPXE_IP_H
2#define _IPXE_IP_H
3
4/** @file
5 *
6 * IP protocol
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/in.h>
15#include <ipxe/list.h>
16#include <ipxe/retry.h>
17#include <ipxe/netdevice.h>
18
19struct io_buffer;
20
21/* IP constants */
22
23#define IP_VER 0x40U
24#define IP_MASK_VER 0xf0U
25#define IP_MASK_HLEN 0x0fU
26#define IP_MASK_OFFSET 0x1fffU
27#define IP_MASK_DONOTFRAG 0x4000U
28#define IP_MASK_MOREFRAGS 0x2000U
29#define IP_PSHLEN 12
30
31/* IP header defaults */
32#define IP_TOS 0
33#define IP_TTL 64
34
35/** Construct a literal IPv4 address */
36#define IPV4( a, b, c, d ) \
37 htonl ( ( ( ( unsigned int ) (a) ) << 24 ) | \
38 ( ( ( unsigned int ) (b) ) << 16 ) | \
39 ( ( ( unsigned int ) (c) ) << 8 ) | \
40 ( ( ( unsigned int ) (d) ) << 0 ) )
41
42/** An IPv4 packet header */
55
56/** An IPv4 pseudo header */
64
65/** An IPv4 address/routing table entry
66 *
67 * Routing table entries are maintained in order of specificity. For
68 * a given destination address, the first matching table entry will be
69 * used as the egress route.
70 */
72 /** List of miniroutes */
74
75 /** Network device
76 *
77 * When this routing table entry is matched, this is the
78 * egress network device to be used.
79 */
81
82 /** IPv4 address
83 *
84 * When this routing table entry is matched, this is the
85 * source address to be used.
86 *
87 * The presence of this routing table entry also indicates
88 * that this address is a valid local destination address for
89 * the matching network device.
90 */
92 /** Subnet network address
93 *
94 * A subnet is a range of addresses defined by a network
95 * address and subnet mask. A destination address with all of
96 * the subnet mask bits in common with the network address is
97 * within the subnet and therefore matches this routing table
98 * entry.
99 */
101 /** Subnet mask
102 *
103 * An address with all of these bits in common with the
104 * network address matches this routing table entry.
105 */
107 /** Gateway address, or zero
108 *
109 * When this routing table entry is matched and this address
110 * is non-zero, it will be used as the next-hop address.
111 *
112 * When this routing table entry is matched and this address
113 * is zero, the subnet is local (on-link) and the next-hop
114 * address will be the original destination address.
115 */
117 /** Host mask
118 *
119 * An address in a local subnet with all of these bits set to
120 * zero represents the network address, and an address in a
121 * local subnet with all of these bits set to one represents
122 * the local directed broadcast address. All other addresses
123 * in a local subnet are valid host addresses.
124 *
125 * For most local subnets, this is the inverse of the subnet
126 * mask. In a small subnet (/31 or /32) there is no network
127 * address or directed broadcast address, and all addresses in
128 * the subnet are valid host addresses.
129 *
130 * When this routing table entry is matched and the subnet is
131 * local, a next-hop address with all of these bits set to one
132 * will be treated as a local broadcast address. All other
133 * next-hop addresses will be treated as unicast addresses.
134 *
135 * When this routing table entry is matched and the subnet is
136 * non-local, the next-hop address is always a unicast
137 * address. The host mask for non-local subnets is therefore
138 * set to @c INADDR_NONE to allow the same logic to be used as
139 * for local subnets.
140 */
142};
143
144extern struct list_head ipv4_miniroutes;
145
146extern struct net_protocol ipv4_protocol __net_protocol;
147
148extern struct ipv4_miniroute * ipv4_route ( unsigned int scope_id,
149 struct in_addr *dest );
150extern int ipv4_has_any_addr ( struct net_device *netdev );
151extern int parse_ipv4_setting ( const struct setting_type *type,
152 const char *value, void *buf, size_t len );
153extern int format_ipv4_setting ( const struct setting_type *type,
154 const void *raw, size_t raw_len, char *buf,
155 size_t len );
156
157#endif /* _IPXE_IP_H */
__be32 raw[7]
Definition CIB_PRM.h:0
pseudo_bit_t value[0x00020]
Definition arbel.h:2
unsigned short uint16_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:10
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
static size_t raw_len
Definition base16.h:54
ring len
Length.
Definition dwmac.h:226
uint32_t type
Operating system type.
Definition ena.h:1
static struct net_device * netdev
Definition gdbudp.c:53
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
#define __attribute__(x)
Definition compiler.h:10
int format_ipv4_setting(const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
int ipv4_has_any_addr(struct net_device *netdev)
Check if network device has any IPv4 address.
Definition ipv4.c:590
int parse_ipv4_setting(const struct setting_type *type, const char *value, void *buf, size_t len)
struct ipv4_miniroute * ipv4_route(unsigned int scope_id, struct in_addr *dest)
Perform IPv4 routing.
Definition ipv4.c:311
struct list_head ipv4_miniroutes
List of IPv4 miniroutes.
Definition ipv4.c:58
Linked lists.
Network device management.
#define __net_protocol
Declare a network-layer protocol.
Definition netdevice.h:477
Retry timers.
IP address structure.
Definition in.h:42
A persistent I/O buffer.
Definition iobuf.h:98
An IPv4 packet header.
Definition ip.h:43
uint8_t service
Definition ip.h:45
uint8_t protocol
Definition ip.h:50
struct in_addr dest
Definition ip.h:53
uint16_t len
Definition ip.h:46
struct in_addr src
Definition ip.h:52
uint8_t ttl
Definition ip.h:49
uint8_t verhdrlen
Definition ip.h:44
uint16_t chksum
Definition ip.h:51
uint16_t frags
Definition ip.h:48
uint16_t ident
Definition ip.h:47
An IPv4 address/routing table entry.
Definition ip.h:71
struct in_addr gateway
Gateway address, or zero.
Definition ip.h:116
struct in_addr network
Subnet network address.
Definition ip.h:100
struct in_addr netmask
Subnet mask.
Definition ip.h:106
struct list_head list
List of miniroutes.
Definition ip.h:73
struct net_device * netdev
Network device.
Definition ip.h:80
struct in_addr address
IPv4 address.
Definition ip.h:91
struct in_addr hostmask
Host mask.
Definition ip.h:141
An IPv4 pseudo header.
Definition ip.h:57
uint8_t zero_padding
Definition ip.h:60
uint16_t len
Definition ip.h:62
struct in_addr src
Definition ip.h:58
struct in_addr dest
Definition ip.h:59
uint8_t protocol
Definition ip.h:61
A doubly-linked list entry (or list head).
Definition list.h:19
A network device.
Definition netdevice.h:353
A network-layer protocol.
Definition netdevice.h:65
A setting type.
Definition settings.h:192