iPXE
ip.h
Go to the documentation of this file.
00001 #ifndef _IPXE_IP_H
00002 #define _IPXE_IP_H
00003 
00004 /** @file
00005  *
00006  * IP protocol
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/in.h>
00014 #include <ipxe/list.h>
00015 #include <ipxe/retry.h>
00016 #include <ipxe/netdevice.h>
00017 
00018 struct io_buffer;
00019 
00020 /* IP constants */
00021 
00022 #define IP_VER                  0x40U
00023 #define IP_MASK_VER             0xf0U
00024 #define IP_MASK_HLEN            0x0fU
00025 #define IP_MASK_OFFSET          0x1fffU
00026 #define IP_MASK_DONOTFRAG       0x4000U
00027 #define IP_MASK_MOREFRAGS       0x2000U
00028 #define IP_PSHLEN       12
00029 
00030 /* IP header defaults */
00031 #define IP_TOS          0
00032 #define IP_TTL          64
00033 
00034 /** An IPv4 packet header */
00035 struct iphdr {
00036         uint8_t  verhdrlen;
00037         uint8_t  service;
00038         uint16_t len;
00039         uint16_t ident;
00040         uint16_t frags;
00041         uint8_t  ttl;
00042         uint8_t  protocol;
00043         uint16_t chksum;
00044         struct in_addr src;
00045         struct in_addr dest;
00046 } __attribute__ (( packed ));
00047 
00048 /** An IPv4 pseudo header */
00049 struct ipv4_pseudo_header {
00050         struct in_addr src;
00051         struct in_addr dest;
00052         uint8_t zero_padding;
00053         uint8_t protocol;
00054         uint16_t len;
00055 };
00056 
00057 /** An IPv4 address/routing table entry */
00058 struct ipv4_miniroute {
00059         /** List of miniroutes */
00060         struct list_head list;
00061 
00062         /** Network device */
00063         struct net_device *netdev;
00064 
00065         /** IPv4 address */
00066         struct in_addr address;
00067         /** Subnet mask */
00068         struct in_addr netmask;
00069         /** Gateway address */
00070         struct in_addr gateway;
00071 };
00072 
00073 extern struct list_head ipv4_miniroutes;
00074 
00075 extern struct net_protocol ipv4_protocol __net_protocol;
00076 
00077 extern int ipv4_has_any_addr ( struct net_device *netdev );
00078 extern int parse_ipv4_setting ( const struct setting_type *type,
00079                                 const char *value, void *buf, size_t len );
00080 extern int format_ipv4_setting ( const struct setting_type *type,
00081                                  const void *raw, size_t raw_len, char *buf,
00082                                  size_t len );
00083 
00084 #endif /* _IPXE_IP_H */