PageRenderTime 56ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/src/sdk/include/netinet/in.h

https://gitlab.com/thomasphillips3/How-to-Make-a-Computer-Operating-System
C Header | 102 lines | 88 code | 12 blank | 2 comment | 0 complexity | a22b1d1fa81f64b24e3644566c0899d6 MD5 | raw file
  1. #ifndef _NETINET_IN_H_
  2. #define _NETINET_IN_H_
  3. #include <sys/types.h>
  4. #include <sys/socket.h>
  5. #define ntohs(n) \
  6. ((((uint16_t)(n) & 0xFF) << 8) | ((uint16_t)(n) >> 8))
  7. #define ntohl(n) \
  8. (((uint32_t)(n) << 24) | (((uint32_t)(n) & 0xFF00) << 8) | (((uint32_t)(n) & 0x00FF0000) >> 8) | ((uint32_t)(n) >> 24))
  9. #define htons ntohs
  10. #define htonl ntohl
  11. /* Standard well-defined IP protocols. */
  12. enum {
  13. IPPROTO_IP = 0, /* Dummy protocol for TCP. */
  14. #define IPPROTO_IP IPPROTO_IP
  15. IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */
  16. #define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
  17. IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */
  18. #define IPPROTO_ICMP IPPROTO_ICMP
  19. IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */
  20. #define IPPROTO_IGMP IPPROTO_IGMP
  21. IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94). */
  22. #define IPPROTO_IPIP IPPROTO_IPIP
  23. IPPROTO_TCP = 6, /* Transmission Control Protocol. */
  24. #define IPPROTO_TCP IPPROTO_TCP
  25. IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */
  26. #define IPPROTO_EGP IPPROTO_EGP
  27. IPPROTO_PUP = 12, /* PUP protocol. */
  28. #define IPPROTO_PUP IPPROTO_PUP
  29. IPPROTO_UDP = 17, /* User Datagram Protocol. */
  30. #define IPPROTO_UDP IPPROTO_UDP
  31. IPPROTO_IDP = 22, /* XNS IDP protocol. */
  32. #define IPPROTO_IDP IPPROTO_IDP
  33. IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */
  34. #define IPPROTO_TP IPPROTO_TP
  35. IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol. */
  36. #define IPPROTO_DCCP IPPROTO_DCCP
  37. IPPROTO_IPV6 = 41, /* IPv6 header. */
  38. #define IPPROTO_IPV6 IPPROTO_IPV6
  39. IPPROTO_ROUTING = 43, /* IPv6 routing header. */
  40. #define IPPROTO_ROUTING IPPROTO_ROUTING
  41. IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */
  42. #define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
  43. IPPROTO_RSVP = 46, /* Reservation Protocol. */
  44. #define IPPROTO_RSVP IPPROTO_RSVP
  45. IPPROTO_GRE = 47, /* General Routing Encapsulation. */
  46. #define IPPROTO_GRE IPPROTO_GRE
  47. IPPROTO_ESP = 50, /* encapsulating security payload. */
  48. #define IPPROTO_ESP IPPROTO_ESP
  49. IPPROTO_AH = 51, /* authentication header. */
  50. #define IPPROTO_AH IPPROTO_AH
  51. IPPROTO_ICMPV6 = 58, /* ICMPv6. */
  52. #define IPPROTO_ICMPV6 IPPROTO_ICMPV6
  53. IPPROTO_NONE = 59, /* IPv6 no next header. */
  54. #define IPPROTO_NONE IPPROTO_NONE
  55. IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */
  56. #define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
  57. IPPROTO_MTP = 92, /* Multicast Transport Protocol. */
  58. #define IPPROTO_MTP IPPROTO_MTP
  59. IPPROTO_ENCAP = 98, /* Encapsulation Header. */
  60. #define IPPROTO_ENCAP IPPROTO_ENCAP
  61. IPPROTO_PIM = 103, /* Protocol Independent Multicast. */
  62. #define IPPROTO_PIM IPPROTO_PIM
  63. IPPROTO_COMP = 108, /* Compression Header Protocol. */
  64. #define IPPROTO_COMP IPPROTO_COMP
  65. IPPROTO_SCTP = 132, /* Stream Control Transmission Protocol. */
  66. #define IPPROTO_SCTP IPPROTO_SCTP
  67. IPPROTO_UDPLITE = 136, /* UDP-Lite protocol. */
  68. #define IPPROTO_UDPLITE IPPROTO_UDPLITE
  69. IPPROTO_RAW = 255, /* Raw IP packets. */
  70. #define IPPROTO_RAW IPPROTO_RAW
  71. IPPROTO_MAX
  72. };
  73. typedef uint16_t in_port_t;
  74. typedef uint32_t in_addr_t;
  75. struct in_addr {
  76. in_addr_t s_addr;
  77. };
  78. struct sockaddr_in {
  79. sa_family_t sin_family;
  80. in_port_t sin_port; /* Port number. */
  81. struct in_addr sin_addr; /* Internet address. */
  82. /* Pad to size of `struct sockaddr'. */
  83. unsigned char sin_zero[
  84. sizeof( struct sockaddr ) -
  85. sizeof( sa_family_t ) -
  86. sizeof( in_port_t ) -
  87. sizeof( struct in_addr )
  88. ];
  89. };
  90. #endif /* _NETINET_IN_H_ */