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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _IPXE_IP_H
  2. #define _IPXE_IP_H
  3. /** @file
  4. *
  5. * IP protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/in.h>
  11. #include <ipxe/list.h>
  12. #include <ipxe/retry.h>
  13. #include <ipxe/netdevice.h>
  14. struct io_buffer;
  15. /* IP constants */
  16. #define IP_VER 0x40U
  17. #define IP_MASK_VER 0xf0U
  18. #define IP_MASK_HLEN 0x0fU
  19. #define IP_MASK_OFFSET 0x1fffU
  20. #define IP_MASK_DONOTFRAG 0x4000U
  21. #define IP_MASK_MOREFRAGS 0x2000U
  22. #define IP_PSHLEN 12
  23. /* IP header defaults */
  24. #define IP_TOS 0
  25. #define IP_TTL 64
  26. /** An IPv4 packet header */
  27. struct iphdr {
  28. uint8_t verhdrlen;
  29. uint8_t service;
  30. uint16_t len;
  31. uint16_t ident;
  32. uint16_t frags;
  33. uint8_t ttl;
  34. uint8_t protocol;
  35. uint16_t chksum;
  36. struct in_addr src;
  37. struct in_addr dest;
  38. } __attribute__ (( packed ));
  39. /** An IPv4 pseudo header */
  40. struct ipv4_pseudo_header {
  41. struct in_addr src;
  42. struct in_addr dest;
  43. uint8_t zero_padding;
  44. uint8_t protocol;
  45. uint16_t len;
  46. };
  47. /** An IPv4 address/routing table entry */
  48. struct ipv4_miniroute {
  49. /** List of miniroutes */
  50. struct list_head list;
  51. /** Network device */
  52. struct net_device *netdev;
  53. /** IPv4 address */
  54. struct in_addr address;
  55. /** Subnet mask */
  56. struct in_addr netmask;
  57. /** Gateway address */
  58. struct in_addr gateway;
  59. };
  60. extern struct list_head ipv4_miniroutes;
  61. extern struct net_protocol ipv4_protocol __net_protocol;
  62. extern int ipv4_has_any_addr ( struct net_device *netdev );
  63. extern int parse_ipv4_setting ( const struct setting_type *type,
  64. const char *value, void *buf, size_t len );
  65. extern int format_ipv4_setting ( const struct setting_type *type,
  66. const void *raw, size_t raw_len, char *buf,
  67. size_t len );
  68. #endif /* _IPXE_IP_H */