home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / WS2TCPIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  4.4 KB  |  144 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. #pragma option push -b -a8 -pc -A- /*P_O_Push_S*/
  19. #define _WS2TCPIP_H_
  20.  
  21. /* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP */
  22.  
  23. struct ip_mreq {
  24.     struct in_addr imr_multiaddr;    /* IP multicast address of group */
  25.     struct in_addr imr_interface;    /* local IP address of interface */
  26. };
  27.  
  28. /* TCP/IP specific Ioctl codes */
  29.  
  30. #define SIO_GET_INTERFACE_LIST  _IOR('t', 127, u_long)    
  31.  
  32. /* Option to use with [gs]etsockopt at the IPPROTO_IP level */
  33.  
  34. #define    IP_OPTIONS        1 /* set/get IP options */
  35. #define    IP_HDRINCL        2 /* header is included with data */
  36. #define    IP_TOS            3 /* IP type of service and preced*/
  37. #define    IP_TTL            4 /* IP time to live */
  38. #define    IP_MULTICAST_IF        9 /* set/get IP multicast i/f  */
  39. #define    IP_MULTICAST_TTL       10 /* set/get IP multicast ttl */
  40. #define    IP_MULTICAST_LOOP      11 /*set/get IP multicast loopback */
  41. #define    IP_ADD_MEMBERSHIP      12 /* add an IP group membership */
  42. #define    IP_DROP_MEMBERSHIP     13/* drop an IP group membership */
  43. #define IP_DONTFRAGMENT     14 /* don't fragment IP datagrams */
  44.  
  45.  
  46. /* Option to use with [gs]etsockopt at the IPPROTO_UDP level */
  47.  
  48. #define UDP_NOCHECKSUM    1
  49.  
  50. /* Option to use with [gs]etsockopt at the IPPROTO_TCP level */
  51.  
  52. #define  TCP_EXPEDITED_1122    0x0002
  53.  
  54.  
  55. /* IPv6 definitions */
  56.  
  57. struct in_addr6 {
  58.         u_char    s6_addr[16];    /* IPv6 address */
  59. };
  60.  
  61. struct sockaddr_in6 {
  62.         short    sin6_family;       /* AF_INET6 */
  63.         u_short sin6_port;    /* Transport level port number */
  64.         u_long    sin6_flowinfo;    /* IPv6 flow information */
  65.         struct in_addr6 sin6_addr; /* IPv6 address */
  66. };
  67.  
  68.  
  69. typedef struct in_addr6 IN6_ADDR;
  70. typedef struct in_addr6 *PIN6_ADDR;
  71. typedef struct in_addr6 FAR *LPIN6_ADDR;
  72.  
  73. typedef struct sockaddr_in6 SOCKADDR_IN6;
  74. typedef struct sockaddr_in6 *PSOCKADDR_IN6;
  75. typedef struct sockaddr_in6 FAR *LPSOCKADDR_IN6;
  76.  
  77.  
  78. #define IN6ADDR_SETANY(x) {\
  79. (x)->sin6_family = AF_INET6; \
  80. (x)->sin6_port = 0; \
  81. (x)->sin6_flowinfo = 0; \
  82. *((u_long *)((x)->sin6_addr.s6_addr)    ) = 0; \
  83. *((u_long *)((x)->sin6_addr.s6_addr) + 1) = 0; \
  84. *((u_long *)((x)->sin6_addr.s6_addr) + 2) = 0; \
  85. *((u_long *)((x)->sin6_addr.s6_addr) + 3) = 0; \
  86. }
  87. #define IN6ADDR_SETLOOPBACK(x) {\
  88. (x)->sin6_family = AF_INET6; \
  89. (x)->sin6_port = 0; \
  90. (x)->sin6_flowinfo = 0; \
  91. *((u_long *)((x)->sin6_addr.s6_addr)    ) = 0; \
  92. *((u_long *)((x)->sin6_addr.s6_addr) + 1) = 0; \
  93. *((u_long *)((x)->sin6_addr.s6_addr) + 2) = 0; \
  94. *((u_long *)((x)->sin6_addr.s6_addr) + 3) = 1; \
  95. }
  96.  
  97. #define IN6ADDR_ISANY(x) ( \
  98. (x)->sin6_family == AF_INET6 && \
  99. *((u_long *)((x)->sin6_addr.s6_addr)    ) == 0 && \
  100. *((u_long *)((x)->sin6_addr.s6_addr) + 1) == 0 && \
  101. *((u_long *)((x)->sin6_addr.s6_addr) + 2) == 0 && \
  102. *((u_long *)((x)->sin6_addr.s6_addr) + 3) == 0 \
  103. )
  104.  
  105.  
  106. #define IN6ADDR_ISLOOPBACK(x) (\
  107. (x)->sin6_family == AF_INET6 && \
  108. *((u_long *)((x)->sin6_addr.s6_addr)    ) == 0 && \
  109. *((u_long *)((x)->sin6_addr.s6_addr) + 1) == 0 && \
  110. *((u_long *)((x)->sin6_addr.s6_addr) + 2) == 0 && \
  111. *((u_long *)((x)->sin6_addr.s6_addr) + 3) == 1 \
  112. )
  113.  
  114.  
  115.  
  116. typedef union sockaddr_gen{
  117.         struct sockaddr Address;
  118.         struct sockaddr_in  AddressIn;
  119.         struct sockaddr_in6 AddressIn6;
  120. } sockaddr_gen;
  121.  
  122. /* Structure to keep interface specific information */
  123.  
  124. typedef struct _INTERFACE_INFO
  125. {
  126.     u_long        iiFlags;        /* Interface flags */
  127.     sockaddr_gen    iiAddress;        /* Interface address */
  128.     sockaddr_gen    iiBroadcastAddress;     /* Broadcast address */
  129.     sockaddr_gen    iiNetmask;        /* Network mask */
  130. } INTERFACE_INFO, FAR * LPINTERFACE_INFO;
  131.  
  132. /* Possible flags for the  iiFlags - bitmask  */ 
  133.  
  134. #define IFF_UP        0x00000001 /* Interface is up */
  135. #define IFF_BROADCAST    0x00000002 /* Broadcast is  supported */
  136. #define IFF_LOOPBACK    0x00000004 /* this is loopback interface */
  137. #define IFF_POINTTOPOINT 0x00000008 /*this is point-to-point interface*/
  138. #define IFF_MULTICAST    0x00000010 /* multicast is supported */
  139.  
  140.  
  141. #pragma option pop /*P_O_Pop*/
  142. #endif    /* _WS2TCPIP_H_ */
  143.  
  144.