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.

318 lines
5.4 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // IPUtil.h : Declaration of some global helper function for sockets
  3. // Copyright (c)1997-2001 Microsoft Corporation
  4. //
  5. // some global definitions
  6. // Original Create Date: 5/16/2001
  7. // Original Author: shawnwu
  8. //////////////////////////////////////////////////////////////////////
  9. //
  10. // for active socket
  11. //
  12. //#include <ntspider.h>
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. //
  17. // the following section is copied from net\tcpip\commands\common2\common2.h
  18. //
  19. // Include Files
  20. //
  21. #include "ipexport.h"
  22. #include "ipinfo.h"
  23. #include "llinfo.h"
  24. #include "tcpinfo.h"
  25. #undef SOCKET
  26. //#include "..\common\tcpcmd.h"
  27. //
  28. // the following section is to replace the above include file
  29. // begin tcpcmd.h
  30. //
  31. //#ifndef TCPCMD_INCLUDED
  32. //#define TCPCMD_INCLUDED
  33. #define NOGDI
  34. #define NOMINMAX
  35. //
  36. // added by shawnwu
  37. //
  38. //#include <winsock.h>
  39. //
  40. //#include <windef.h>
  41. //#include <winbase.h>
  42. //#include <winsock2.h>
  43. //#include <ws2tcpip.h>
  44. //#ifndef WIN16
  45. //#endif // WIN16
  46. //#include <direct.h>
  47. //#include <io.h>
  48. //#include <stdlib.h>
  49. //#include <stdio.h>
  50. //#include <time.h>
  51. //#include <string.h>
  52. //#include <nls.h>
  53. //
  54. // global variable declarations
  55. //
  56. extern int optind;
  57. extern int opterr;
  58. extern char *optarg;
  59. //
  60. // function prototypes
  61. //
  62. char *
  63. GetFileFromPath(
  64. char *);
  65. HANDLE
  66. OpenStream(
  67. char *);
  68. int
  69. lwccmp(
  70. char *,
  71. char *);
  72. long
  73. netnumber(
  74. char *);
  75. long
  76. hostnumber(
  77. char *);
  78. void
  79. blkfree(
  80. char **);
  81. struct sockaddr_storage *
  82. resolve_host(
  83. char *,
  84. int *);
  85. int
  86. resolve_port(
  87. char *,
  88. char *);
  89. char *
  90. tempfile(
  91. char *);
  92. char *
  93. udp_alloc(
  94. unsigned int);
  95. void
  96. udp_close(
  97. SOCKET);
  98. void
  99. udp_free(
  100. char *);
  101. SOCKET
  102. udp_open(
  103. int,
  104. int *);
  105. int
  106. udp_port(void);
  107. int
  108. udp_port_used(
  109. int,
  110. int);
  111. int
  112. udp_read(
  113. SOCKET,
  114. char *,
  115. int,
  116. struct sockaddr_storage *,
  117. int *,
  118. int);
  119. int
  120. udp_write(
  121. SOCKET,
  122. char *,
  123. int,
  124. struct sockaddr_storage *,
  125. int);
  126. void
  127. gate_ioctl(
  128. HANDLE,
  129. int,
  130. int,
  131. int,
  132. long,
  133. long);
  134. void
  135. get_route_table(void);
  136. int
  137. tcpcmd_send(
  138. SOCKET s, // socket descriptor
  139. char *buf, // data buffer
  140. int len, // length of data buffer
  141. int flags // transmission flags
  142. );
  143. void
  144. s_perror(
  145. char *yourmsg, // your message to be displayed
  146. int lerrno // errno to be converted
  147. );
  148. void fatal(char * message);
  149. //#ifndef WIN16
  150. //struct netent *getnetbyname(IN char *name);
  151. //unsigned long inet_network(IN char *cp);
  152. //#endif // WIN16
  153. #define perror(string) s_perror(string, (int)GetLastError())
  154. #define HZ 1000
  155. #define TCGETA 0x4
  156. #define TCSETA 0x10
  157. #define ECHO 17
  158. #define SIGPIPE 99
  159. #define MAX_RETRANSMISSION_COUNT 8
  160. #define MAX_RETRANSMISSION_TIME 8 // in seconds
  161. // if x is aabbccdd (where aa, bb, cc, dd are hex bytes)
  162. // we want net_long(x) to be ddccbbaa. A small and fast way to do this is
  163. // to first byteswap it to get bbaaddcc and then swap high and low words.
  164. //
  165. //__inline
  166. //ULONG
  167. //FASTCALL
  168. //net_long(
  169. // ULONG x)
  170. //{
  171. // register ULONG byteswapped;
  172. // byteswapped = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
  173. // return (byteswapped << 16) | (byteswapped >> 16);
  174. //}
  175. //#endif //TCPCMD_INCLUDED
  176. //
  177. // end for tcpcmd.h
  178. //
  179. //
  180. // Definitions
  181. //
  182. #define MAX_ID_LENGTH 50
  183. // Table Types
  184. #define TYPE_IF 0
  185. #define TYPE_IP 1
  186. #define TYPE_IPADDR 2
  187. #define TYPE_ROUTE 3
  188. #define TYPE_ARP 4
  189. #define TYPE_ICMP 5
  190. #define TYPE_TCP 6
  191. #define TYPE_TCPCONN 7
  192. #define TYPE_UDP 8
  193. #define TYPE_UDPCONN 9
  194. //
  195. // Structure Definitions
  196. //
  197. typedef struct _GenericTable {
  198. LIST_ENTRY ListEntry;
  199. } GenericTable;
  200. typedef struct _IfEntry {
  201. LIST_ENTRY ListEntry;
  202. IFEntry Info;
  203. } IfEntry;
  204. typedef struct _IpEntry {
  205. LIST_ENTRY ListEntry;
  206. IPSNMPInfo Info;
  207. } IpEntry;
  208. typedef struct _IpAddrEntry {
  209. LIST_ENTRY ListEntry;
  210. IPAddrEntry Info;
  211. } IpAddrEntry;
  212. typedef struct _RouteEntry {
  213. LIST_ENTRY ListEntry;
  214. IPRouteEntry Info;
  215. } RouteEntry;
  216. typedef struct _ArpEntry {
  217. LIST_ENTRY ListEntry;
  218. IPNetToMediaEntry Info;
  219. } ArpEntry;
  220. typedef struct _IcmpEntry {
  221. LIST_ENTRY ListEntry;
  222. ICMPStats InInfo;
  223. ICMPStats OutInfo;
  224. } IcmpEntry;
  225. typedef struct _TcpEntry {
  226. LIST_ENTRY ListEntry;
  227. TCPStats Info;
  228. } TcpEntry;
  229. typedef struct _TcpConnEntry {
  230. LIST_ENTRY ListEntry;
  231. TCPConnTableEntry Info;
  232. } TcpConnEntry;
  233. typedef struct _UdpEntry {
  234. LIST_ENTRY ListEntry;
  235. UDPStats Info;
  236. } UdpEntry;
  237. typedef struct _UdpConnEntry {
  238. LIST_ENTRY ListEntry;
  239. UDPEntry Info;
  240. } UdpConnEntry;
  241. //
  242. // Function Prototypes
  243. //
  244. void *GetTable( ulong Type, ulong *pResult );
  245. void FreeTable( GenericTable *pList );
  246. ulong MapSnmpErrorToNt( ulong ErrCode );
  247. ulong InetEqual( uchar *Inet1, uchar *Inet2 );
  248. ulong PutMsg(ulong Handle, ulong MsgNum, ... );
  249. uchar *LoadMsg( ulong MsgNum, ... );