1 #ifndef _GPXE_IP_H 2 #define _GPXE_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 <gpxe/in.h> 14 #include <gpxe/list.h> 15 #include <gpxe/retry.h> 16 17 struct io_buffer; 18 struct net_device; 19 struct net_protocol; 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 #define IP_FRAG_IOB_SIZE 1500 36 #define IP_FRAG_TIMEOUT 50 37 38 /** An IPv4 packet header */ 39 struct iphdr { 40 uint8_t verhdrlen; 41 uint8_t service; 42 uint16_t len; 43 uint16_t ident; 44 uint16_t frags; 45 uint8_t ttl; 46 uint8_t protocol; 47 uint16_t chksum; 48 struct in_addr src; 49 struct in_addr dest; 50 } __attribute__ (( packed )); 51 52 /** An IPv4 pseudo header */ 53 struct ipv4_pseudo_header { 54 struct in_addr src; 55 struct in_addr dest; 56 uint8_t zero_padding; 57 uint8_t protocol; 58 uint16_t len; 59 }; 60 61 /** An IPv4 address/routing table entry */ 62 struct ipv4_miniroute { 63 /** List of miniroutes */ 64 struct list_head list; 65 66 /** Network device */ 67 struct net_device *netdev; 68 69 /** IPv4 address */ 70 struct in_addr address; 71 /** Subnet mask */ 72 struct in_addr netmask; 73 /** Gateway address */ 74 struct in_addr gateway; 75 }; 76 77 /* Fragment reassembly buffer */ 78 struct frag_buffer { 79 /* Identification number */ 80 uint16_t ident; 81 /* Source network address */ 82 struct in_addr src; 83 /* Destination network address */ 84 struct in_addr dest; 85 /* Reassembled I/O buffer */ 86 struct io_buffer *frag_iob; 87 /* Reassembly timer */ 88 struct retry_timer frag_timer; 89 /* List of fragment reassembly buffers */ 90 struct list_head list; 91 }; 92 93 extern struct list_head ipv4_miniroutes; 94 95 extern struct net_protocol ipv4_protocol; 96 97 #endif /* _GPXE_IP_H */ 98