You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ip.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef _GPXE_IP_H
  2. #define _GPXE_IP_H
  3. /** @file
  4. *
  5. * IP protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stdint.h>
  10. #include <gpxe/in.h>
  11. #include <gpxe/list.h>
  12. #include <gpxe/retry.h>
  13. struct io_buffer;
  14. struct net_device;
  15. struct net_protocol;
  16. /* IP constants */
  17. #define IP_VER 0x40U
  18. #define IP_MASK_VER 0xf0U
  19. #define IP_MASK_HLEN 0x0fU
  20. #define IP_MASK_OFFSET 0x1fffU
  21. #define IP_MASK_DONOTFRAG 0x4000U
  22. #define IP_MASK_MOREFRAGS 0x2000U
  23. #define IP_PSHLEN 12
  24. /* IP header defaults */
  25. #define IP_TOS 0
  26. #define IP_TTL 64
  27. #define IP_FRAG_IOB_SIZE 1500
  28. #define IP_FRAG_TIMEOUT 50
  29. /** An IPv4 packet header */
  30. struct iphdr {
  31. uint8_t verhdrlen;
  32. uint8_t service;
  33. uint16_t len;
  34. uint16_t ident;
  35. uint16_t frags;
  36. uint8_t ttl;
  37. uint8_t protocol;
  38. uint16_t chksum;
  39. struct in_addr src;
  40. struct in_addr dest;
  41. } __attribute__ (( packed ));
  42. /** An IPv4 pseudo header */
  43. struct ipv4_pseudo_header {
  44. struct in_addr src;
  45. struct in_addr dest;
  46. uint8_t zero_padding;
  47. uint8_t protocol;
  48. uint16_t len;
  49. };
  50. /** An IPv4 address/routing table entry */
  51. struct ipv4_miniroute {
  52. /** List of miniroutes */
  53. struct list_head list;
  54. /** Network device */
  55. struct net_device *netdev;
  56. /** IPv4 address */
  57. struct in_addr address;
  58. /** Subnet mask */
  59. struct in_addr netmask;
  60. /** Gateway address */
  61. struct in_addr gateway;
  62. };
  63. /* Fragment reassembly buffer */
  64. struct frag_buffer {
  65. /* Identification number */
  66. uint16_t ident;
  67. /* Source network address */
  68. struct in_addr src;
  69. /* Destination network address */
  70. struct in_addr dest;
  71. /* Reassembled I/O buffer */
  72. struct io_buffer *frag_iob;
  73. /* Reassembly timer */
  74. struct retry_timer frag_timer;
  75. /* List of fragment reassembly buffers */
  76. struct list_head list;
  77. };
  78. extern struct list_head ipv4_miniroutes;
  79. extern struct net_protocol ipv4_protocol;
  80. #endif /* _GPXE_IP_H */