00001 #ifndef _GPXE_IP_H 00002 #define _GPXE_IP_H 00003 00004 /** @file 00005 * 00006 * IP protocol 00007 * 00008 */ 00009 00010 FILE_LICENCE ( GPL2_OR_LATER ); 00011 00012 #include <stdint.h> 00013 #include <gpxe/in.h> 00014 #include <gpxe/list.h> 00015 #include <gpxe/retry.h> 00016 00017 struct io_buffer; 00018 struct net_device; 00019 struct net_protocol; 00020 00021 /* IP constants */ 00022 00023 #define IP_VER 0x40U 00024 #define IP_MASK_VER 0xf0U 00025 #define IP_MASK_HLEN 0x0fU 00026 #define IP_MASK_OFFSET 0x1fffU 00027 #define IP_MASK_DONOTFRAG 0x4000U 00028 #define IP_MASK_MOREFRAGS 0x2000U 00029 #define IP_PSHLEN 12 00030 00031 /* IP header defaults */ 00032 #define IP_TOS 0 00033 #define IP_TTL 64 00034 00035 #define IP_FRAG_IOB_SIZE 1500 00036 #define IP_FRAG_TIMEOUT 50 00037 00038 /** An IPv4 packet header */ 00039 struct iphdr { 00040 uint8_t verhdrlen; 00041 uint8_t service; 00042 uint16_t len; 00043 uint16_t ident; 00044 uint16_t frags; 00045 uint8_t ttl; 00046 uint8_t protocol; 00047 uint16_t chksum; 00048 struct in_addr src; 00049 struct in_addr dest; 00050 } __attribute__ (( packed )); 00051 00052 /** An IPv4 pseudo header */ 00053 struct ipv4_pseudo_header { 00054 struct in_addr src; 00055 struct in_addr dest; 00056 uint8_t zero_padding; 00057 uint8_t protocol; 00058 uint16_t len; 00059 }; 00060 00061 /** An IPv4 address/routing table entry */ 00062 struct ipv4_miniroute { 00063 /** List of miniroutes */ 00064 struct list_head list; 00065 00066 /** Network device */ 00067 struct net_device *netdev; 00068 00069 /** IPv4 address */ 00070 struct in_addr address; 00071 /** Subnet mask */ 00072 struct in_addr netmask; 00073 /** Gateway address */ 00074 struct in_addr gateway; 00075 }; 00076 00077 /* Fragment reassembly buffer */ 00078 struct frag_buffer { 00079 /* Identification number */ 00080 uint16_t ident; 00081 /* Source network address */ 00082 struct in_addr src; 00083 /* Destination network address */ 00084 struct in_addr dest; 00085 /* Reassembled I/O buffer */ 00086 struct io_buffer *frag_iob; 00087 /* Reassembly timer */ 00088 struct retry_timer frag_timer; 00089 /* List of fragment reassembly buffers */ 00090 struct list_head list; 00091 }; 00092 00093 extern struct list_head ipv4_miniroutes; 00094 00095 extern struct net_protocol ipv4_protocol; 00096 00097 #endif /* _GPXE_IP_H */
1.5.7.1