Leaked source code of windows server 2003
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.

101 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2001-2002 Microsoft Corporation
  3. Module Name:
  4. SockDecl.h
  5. Abstract:
  6. Make SOCKADDR declarations available in the kernel
  7. Author:
  8. George V. Reilly (GeorgeRe) 19-Nov-2001
  9. Revision History:
  10. --*/
  11. #ifndef _SOCKDECL_H_
  12. #define _SOCKDECL_H_
  13. // BUGBUG: these should be present in kernel headers, such as <ipexport.h>
  14. // Types adapted for compatibility with kernel types (u_short -> USHORT, etc).
  15. //
  16. #ifndef s_addr
  17. struct in_addr {
  18. union {
  19. struct { UCHAR s_b1,s_b2,s_b3,s_b4; } S_un_b;
  20. struct { USHORT s_w1,s_w2; } S_un_w;
  21. ULONG S_addr;
  22. } S_un;
  23. #define s_addr S_un.S_addr
  24. /* can be used for most tcp & ip code */
  25. #define s_host S_un.S_un_b.s_b2
  26. /* host on imp */
  27. #define s_net S_un.S_un_b.s_b1
  28. /* network */
  29. #define s_imp S_un.S_un_w.s_w2
  30. /* imp */
  31. #define s_impno S_un.S_un_b.s_b4
  32. /* imp # */
  33. #define s_lh S_un.S_un_b.s_b3
  34. /* logical host */
  35. };
  36. #endif // !s_addr
  37. #ifndef s6_addr
  38. struct in6_addr {
  39. union {
  40. UCHAR Byte[16];
  41. USHORT Word[8];
  42. } u;
  43. };
  44. #define _S6_un u
  45. #define _S6_u8 Byte
  46. #define s6_addr _S6_un._S6_u8
  47. #endif // s6_addr
  48. typedef struct sockaddr {
  49. SHORT sa_family; // address family
  50. UCHAR sa_data[14]; // up to 14 bytes of direct address
  51. } SOCKADDR, *PSOCKADDR;
  52. typedef struct sockaddr_in {
  53. SHORT sin_family; // AF_INET or TDI_ADDRESS_TYPE_IP (2)
  54. USHORT sin_port; // Transport level port number
  55. struct in_addr sin_addr; // IPv6 address
  56. UCHAR sin_zero[8]; // Padding. mbz.
  57. } SOCKADDR_IN, *PSOCKADDR_IN;
  58. typedef struct sockaddr_in6 {
  59. SHORT sin6_family; // AF_INET6 or TDI_ADDRESS_TYPE_IP6 (23)
  60. USHORT sin6_port; // Transport level port number
  61. ULONG sin6_flowinfo; // IPv6 flow information
  62. struct in6_addr sin6_addr; // IPv6 address
  63. ULONG sin6_scope_id; // set of interfaces for a scope
  64. } SOCKADDR_IN6,*PSOCKADDR_IN6;
  65. #define SOCKADDR_ADDRESS_LENGTH_IP sizeof(struct sockaddr_in)
  66. #define SOCKADDR_ADDRESS_LENGTH_IP6 sizeof(struct sockaddr_in6)
  67. /* Macro that works for both IPv4 and IPv6 */
  68. #define SS_PORT(ssp) (((struct sockaddr_in*)(ssp))->sin_port)
  69. #ifndef AF_INET
  70. # define AF_INET TDI_ADDRESS_TYPE_IP
  71. # define AF_INET6 TDI_ADDRESS_TYPE_IP6
  72. #endif
  73. #endif // _SOCKDECL_H_