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 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
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 {
44  struct in_addr src;
45  struct in_addr dest;
46 } __attribute__ (( packed ));
47 
48 /** An IPv4 pseudo header */
50  struct in_addr src;
51  struct in_addr dest;
55 };
56 
57 /** An IPv4 address/routing table entry */
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 */
struct in_addr netmask
Subnet mask.
Definition: ip.h:68
#define __attribute__(x)
Definition: compiler.h:10
unsigned short uint16_t
Definition: stdint.h:11
int ipv4_has_any_addr(struct net_device *netdev)
Check if network device has any IPv4 address.
Definition: ipv4.c:433
struct list_head list
List of miniroutes.
Definition: ip.h:60
struct in_addr src
Definition: ip.h:44
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t zero_padding
Definition: ip.h:52
Retry timers.
struct net_device * netdev
Network device.
Definition: ip.h:63
uint16_t chksum
Definition: ip.h:43
int format_ipv4_setting(const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
struct net_protocol ipv4_protocol __net_protocol
AoE protocol.
Definition: aoe.c:56
uint16_t ident
Definition: ip.h:39
uint16_t frags
Definition: ip.h:40
An IPv4 packet header.
Definition: ip.h:35
struct in_addr address
IPv4 address.
Definition: ip.h:66
A doubly-linked list entry (or list head)
Definition: list.h:18
uint16_t len
Definition: ip.h:54
struct in_addr dest
Definition: ip.h:51
An IPv4 address/routing table entry.
Definition: ip.h:58
uint16_t len
Definition: ip.h:38
struct in_addr gateway
Gateway address.
Definition: ip.h:70
static struct net_device * netdev
Definition: gdbudp.c:52
uint8_t verhdrlen
Definition: ip.h:36
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
Linked lists.
static size_t raw_len
Definition: base16.h:53
struct list_head ipv4_miniroutes
List of IPv4 miniroutes.
Definition: ipv4.c:57
IP address structure.
Definition: in.h:39
A network device.
Definition: netdevice.h:352
int parse_ipv4_setting(const struct setting_type *type, const char *value, void *buf, size_t len)
unsigned char uint8_t
Definition: stdint.h:10
struct in_addr dest
Definition: ip.h:45
An IPv4 pseudo header.
Definition: ip.h:49
A network-layer protocol.
Definition: netdevice.h:64
Network device management.
uint8_t protocol
Definition: ip.h:42
uint32_t len
Length.
Definition: ena.h:14
uint32_t type
Operating system type.
Definition: ena.h:12
uint8_t protocol
Definition: ip.h:53
__be32 raw[7]
Definition: CIB_PRM.h:28
uint8_t ttl
Definition: ip.h:41
struct in_addr src
Definition: ip.h:50
uint8_t service
Definition: ip.h:37
A setting type.
Definition: settings.h:191
A persistent I/O buffer.
Definition: iobuf.h:33