home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / ws2tcpip.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  4KB  |  142 lines

  1. /*    
  2. **    WS2TCPIP.H - WinSock2 Extension for TCP/IP protocols
  3. **
  4. **    This file contains TCP/IP specific information for use 
  5. **    by WinSock2 compatible applications. 
  6. **
  7. **    To provide the backward compatibility, all the TCP/IP  
  8. **    specific definitions that were included in the WINSOCK.H
  9. **     file are now included in WINSOCK2.H file. WS2TCPIP.H 
  10. **    file includes only the definitions  introduced in the 
  11. **    "WinSock 2 Protocol-Specific Annex" document.
  12. **
  13. **    Rev 0.3    Nov 13, 1995
  14. **      Rev 0.4    Dec 15, 1996
  15. */
  16.  
  17. #ifndef _WS2TCPIP_H_
  18. #define _WS2TCPIP_H_
  19.  
  20. /* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP */
  21.  
  22. struct ip_mreq {
  23.     struct in_addr imr_multiaddr;    /* IP multicast address of group */
  24.     struct in_addr imr_interface;    /* local IP address of interface */
  25. };
  26.  
  27. /* TCP/IP specific Ioctl codes */
  28.  
  29. #define SIO_GET_INTERFACE_LIST  _IOR('t', 127, u_long)    
  30.  
  31. /* Option to use with [gs]etsockopt at the IPPROTO_IP level */
  32.  
  33. #define    IP_OPTIONS        1 /* set/get IP options */
  34. #define    IP_HDRINCL        2 /* header is included with data */
  35. #define    IP_TOS            3 /* IP type of service and preced*/
  36. #define    IP_TTL            4 /* IP time to live */
  37. #define    IP_MULTICAST_IF        9 /* set/get IP multicast i/f  */
  38. #define    IP_MULTICAST_TTL       10 /* set/get IP multicast ttl */
  39. #define    IP_MULTICAST_LOOP      11 /*set/get IP multicast loopback */
  40. #define    IP_ADD_MEMBERSHIP      12 /* add an IP group membership */
  41. #define    IP_DROP_MEMBERSHIP     13/* drop an IP group membership */
  42. #define IP_DONTFRAGMENT     14 /* don't fragment IP datagrams */
  43.  
  44.  
  45. /* Option to use with [gs]etsockopt at the IPPROTO_UDP level */
  46.  
  47. #define UDP_NOCHECKSUM    1
  48.  
  49. /* Option to use with [gs]etsockopt at the IPPROTO_TCP level */
  50.  
  51. #define  TCP_EXPEDITED_1122    0x0002
  52.  
  53.  
  54. /* IPv6 definitions */
  55.  
  56. struct in_addr6 {
  57.         u_char    s6_addr[16];    /* IPv6 address */
  58. };
  59.  
  60. struct sockaddr_in6 {
  61.         short    sin6_family;       /* AF_INET6 */
  62.         u_short sin6_port;    /* Transport level port number */
  63.         u_long    sin6_flowinfo;    /* IPv6 flow information */
  64.         struct in_addr6 sin6_addr; /* IPv6 address */
  65. };
  66.  
  67.  
  68. typedef struct in_addr6 IN6_ADDR;
  69. typedef struct in_addr6 *PIN6_ADDR;
  70. typedef struct in_addr6 FAR *LPIN6_ADDR;
  71.  
  72. typedef struct sockaddr_in6 SOCKADDR_IN6;
  73. typedef struct sockaddr_in6 *PSOCKADDR_IN6;
  74. typedef struct sockaddr_in6 FAR *LPSOCKADDR_IN6;
  75.  
  76.  
  77. #define IN6ADDR_SETANY(x) {\
  78. (x)->sin6_family = AF_INET6; \
  79. (x)->sin6_port = 0; \
  80. (x)->sin6_flowinfo = 0; \
  81. *((u_long *)((x)->sin6_addr.s6_addr)    ) = 0; \
  82. *((u_long *)((x)->sin6_addr.s6_addr) + 1) = 0; \
  83. *((u_long *)((x)->sin6_addr.s6_addr) + 2) = 0; \
  84. *((u_long *)((x)->sin6_addr.s6_addr) + 3) = 0; \
  85. }
  86. #define IN6ADDR_SETLOOPBACK(x) {\
  87. (x)->sin6_family = AF_INET6; \
  88. (x)->sin6_port = 0; \
  89. (x)->sin6_flowinfo = 0; \
  90. *((u_long *)((x)->sin6_addr.s6_addr)    ) = 0; \
  91. *((u_long *)((x)->sin6_addr.s6_addr) + 1) = 0; \
  92. *((u_long *)((x)->sin6_addr.s6_addr) + 2) = 0; \
  93. *((u_long *)((x)->sin6_addr.s6_addr) + 3) = 1; \
  94. }
  95.  
  96. #define IN6ADDR_ISANY(x) ( \
  97. (x)->sin6_family == AF_INET6 && \
  98. *((u_long *)((x)->sin6_addr.s6_addr)    ) == 0 && \
  99. *((u_long *)((x)->sin6_addr.s6_addr) + 1) == 0 && \
  100. *((u_long *)((x)->sin6_addr.s6_addr) + 2) == 0 && \
  101. *((u_long *)((x)->sin6_addr.s6_addr) + 3) == 0 \
  102. )
  103.  
  104.  
  105. #define IN6ADDR_ISLOOPBACK(x) (\
  106. (x)->sin6_family == AF_INET6 && \
  107. *((u_long *)((x)->sin6_addr.s6_addr)    ) == 0 && \
  108. *((u_long *)((x)->sin6_addr.s6_addr) + 1) == 0 && \
  109. *((u_long *)((x)->sin6_addr.s6_addr) + 2) == 0 && \
  110. *((u_long *)((x)->sin6_addr.s6_addr) + 3) == 1 \
  111. )
  112.  
  113.  
  114.  
  115. typedef union sockaddr_gen{
  116.         struct sockaddr Address;
  117.         struct sockaddr_in  AddressIn;
  118.         struct sockaddr_in6 AddressIn6;
  119. } sockaddr_gen;
  120.  
  121. /* Structure to keep interface specific information */
  122.  
  123. typedef struct _INTERFACE_INFO
  124. {
  125.     u_long        iiFlags;        /* Interface flags */
  126.     sockaddr_gen    iiAddress;        /* Interface address */
  127.     sockaddr_gen    iiBroadcastAddress;     /* Broadcast address */
  128.     sockaddr_gen    iiNetmask;        /* Network mask */
  129. } INTERFACE_INFO, FAR * LPINTERFACE_INFO;
  130.  
  131. /* Possible flags for the  iiFlags - bitmask  */ 
  132.  
  133. #define IFF_UP        0x00000001 /* Interface is up */
  134. #define IFF_BROADCAST    0x00000002 /* Broadcast is  supported */
  135. #define IFF_LOOPBACK    0x00000004 /* this is loopback interface */
  136. #define IFF_POINTTOPOINT 0x00000008 /*this is point-to-point interface*/
  137. #define IFF_MULTICAST    0x00000010 /* multicast is supported */
  138.  
  139.  
  140. #endif    /* _WS2TCPIP_H_ */
  141.  
  142.