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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _GPXE_IN_H
  2. #define _GPXE_IN_H
  3. #include <stdint.h>
  4. #include <gpxe/socket.h>
  5. /* Protocol numbers */
  6. #define IP_ICMP 1
  7. #define IP_IGMP 2
  8. #define IP_TCP 6
  9. #define IP_UDP 17
  10. #define IP_ICMP6 58
  11. /* IP address constants */
  12. #define INADDR_NONE 0xffffffff
  13. #define INADDR_BROADCAST 0xffffffff
  14. #define IN_MULTICAST(addr) ( ( (addr) & 0xf0000000 ) == 0xe0000000 )
  15. /**
  16. * IP address structure
  17. */
  18. struct in_addr {
  19. uint32_t s_addr;
  20. };
  21. typedef struct in_addr in_addr;
  22. /**
  23. * IP6 address structure
  24. */
  25. struct in6_addr {
  26. union {
  27. uint8_t u6_addr8[16];
  28. uint16_t u6_addr16[8];
  29. uint32_t u6_addr32[4];
  30. } in6_u;
  31. #define s6_addr in6_u.u6_addr8
  32. #define s6_addr16 in6_u.u6_addr16
  33. #define s6_addr32 in6_u.u6_addr32
  34. };
  35. /**
  36. * IPv4 socket address
  37. */
  38. struct sockaddr_in {
  39. /** Socket address family (part of struct @c sockaddr)
  40. *
  41. * Always set to @c AF_INET for IPv4 addresses
  42. */
  43. sa_family_t sin_family;
  44. /** TCP/IP port (part of struct @c sockaddr_tcpip) */
  45. uint16_t sin_port;
  46. /** IPv4 address */
  47. struct in_addr sin_addr;
  48. };
  49. /**
  50. * IPv6 socket address
  51. */
  52. struct sockaddr_in6 {
  53. /** Socket address family (part of struct @c sockaddr)
  54. *
  55. * Always set to @c AF_INET6 for IPv6 addresses
  56. */
  57. sa_family_t sin_family;
  58. /** TCP/IP port (part of struct @c sockaddr_tcpip) */
  59. uint16_t sin_port;
  60. uint32_t sin6_flowinfo; /* Flow number */
  61. struct in6_addr sin6_addr; /* 128-bit destination address */
  62. uint32_t sin6_scope_id; /* Scope ID */
  63. };
  64. extern int inet_aton ( const char *cp, struct in_addr *inp );
  65. extern char * inet_ntoa ( struct in_addr in );
  66. /* Adding the following for IP6 support
  67. *
  68. extern int inet6_aton ( const char *cp, struct in6_addr *inp );
  69. extern char * inet6_ntoa ( struct in_addr in );
  70. */
  71. #endif /* _GPXE_IN_H */