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.

220 lines
7.5 KiB

  1. #ifndef _INC_WINSNMPN
  2. #define _INC_WINSNMPN
  3. //
  4. // winsnmpn.h
  5. //
  6. // Private include file for ACE*COMM's
  7. // NetPlus Win32 WinSNMP implementation
  8. // Copyright 1995-1997 ACE*COMM Corp
  9. // Rleased to Microsoft under Contract
  10. // Beta 1 version, 970228
  11. // Bob Natale ([email protected])
  12. //
  13. // 970310 - Removed NPWSNMPSTATUSREPORT structure
  14. // - Added localAddress to TaskData
  15. // - Removed unused #defines
  16. //
  17. // 970417 - Added OSVERSIONINFO to TaskData
  18. //
  19. #include <winsock.h>
  20. #include <wsipx.h>
  21. //
  22. #ifdef SOLARIS
  23. #define THR_FLAGS THR_BOUND|THR_DETACHED
  24. #define THR_TYPE LPVOID
  25. #else // Win32
  26. #define THR_TYPE DWORD
  27. #endif // SOLARIS
  28. //
  29. #define DEFSESSIONS 10 // just for testing -- should be rolled back to 10
  30. #define DEFVBLS 100 // just for testing -- should be rolled back to 100
  31. #define DEFPDUS 100 // just for testing -- should be rolled back to 100
  32. #define DEFENTITIES 100 // just for testing -- should be rolled back to 100
  33. #define DEFCONTEXTS 100 // just for testing -- should be rolled back to 100
  34. #define DEFMSGS 100 // just for testing -- should be rolled back to 100
  35. #define DEFTRAPS 10 // just for testing -- should be rolled back to 10
  36. #define DEFAGENTS 5 // just for testing -- should be rolled back to 5
  37. #define MAXCENTISECONDS 429496729U
  38. #define MAXMILLISECONDS 4294967295U
  39. #define DEFTIMEOUT 300 // centisecs = 3 seconds
  40. #define DEFRETRY 3
  41. #define IP_SNMP_PORT 161
  42. #define IP_TRAP_PORT 162
  43. #define IPX_SNMP_PORT 36879
  44. #define IPX_TRAP_PORT 36880
  45. #define SNMPTRAPPIPE "\\\\.\\PIPE\\MGMTAPI"
  46. #define TRAPSERVERTIMEOUT 30000 // millisecs = 30 seconds
  47. #define NP_WSX95 "NP_WSX95"
  48. #define NP_WSX95_EXE "NP_WSX95.EXE"
  49. #define WSNMP_TRAPS_ON WM_USER + 12
  50. #define WSNMP_TRAPS_OFF WM_USER + 13
  51. #define LOOPBACK_ADDR "127.0.0.1"
  52. #define MAXTRAPIDS 20 // Max sub-ids in trap matches
  53. #define MAX_FRIEND_NAME_LEN 31
  54. #define MAX_CONTEXT_LEN 256
  55. #define MAX_HOSTNAME 64
  56. #define AF_INET_ADDR_SIZE 4
  57. #define AF_IPX_ADDR_SIZE 10
  58. #define NP_SEND 1 // "To send" msg status
  59. #define NP_SENT 2 // "Sent" msg status
  60. #define NP_RCVD 3 // "Received" msg status
  61. #define NP_READY 4 // "Ready" for pickup by app
  62. #define NP_EXPIRED 5 // "Timed out" for thrNotify
  63. #define NP_REQUEST 1 // Agent request/response msg type
  64. #define NP_RESPONSE 2 // Mgr request/response msg type
  65. #define NP_TRAP 3 // Trap msg type
  66. #define MAX_PENDING_WAIT 1000 // Trap service status period
  67. typedef union
  68. {
  69. SOCKADDR_IN inet;
  70. SOCKADDR_IPX ipx;
  71. } SAS, *LPSAS;
  72. typedef struct _VB
  73. {
  74. smiOID name;
  75. smiVALUE value;
  76. smiINT32 data_length;
  77. struct _VB *next_var;
  78. } VARBIND, *LPVARBIND;
  79. typedef struct
  80. {
  81. smiOID enterprise;
  82. smiIPADDR agent_addr;
  83. smiINT32 generic_trap;
  84. smiINT32 specific_trap;
  85. smiTIMETICKS time_ticks;
  86. } V1TRAP, *LPV1TRAP;
  87. typedef struct _tdBuffer // SNMP Buffer Descriptor
  88. {
  89. struct _tdBuffer *next; // Link to the next buffer of the table
  90. struct _tdBuffer *prev; // Link to the previous buffer of the table
  91. DWORD Used; // Number of entries in use in this buffer
  92. } SNMPBD, FAR *LPSNMPBD;
  93. typedef struct // SNMP Table Descriptor
  94. {
  95. DWORD Used; // Number currently ulilized
  96. DWORD Allocated; // Number currently allocated
  97. DWORD BlocksToAdd; // Incremented in chunks of this many records
  98. DWORD BlockSize; // Record size (bytes)
  99. LPSNMPBD HeadBuffer; // circular list to the buffers of the table
  100. // 'HeadBuffer' points to a SNMPBD structure suffixed with
  101. // 'BlocksToAdd' blocks of size 'BlockSize' each
  102. } SNMPTD, FAR *LPSNMPTD;
  103. typedef struct
  104. {
  105. HSNMP_SESSION hTask;
  106. smiUINT32 nTranslateMode;
  107. smiUINT32 nRetransmitMode;
  108. DWORD localAddress;
  109. SNMPAPI_STATUS conveyAddress; // SNMPAPI_ON/OFF
  110. HANDLE timerThread;
  111. SOCKET ipSock;
  112. HANDLE ipThread;
  113. SOCKET ipxSock;
  114. HANDLE ipxThread;
  115. SOCKET trapSock; // Win95-only
  116. HANDLE trapThread;
  117. HWND trapWnd; // Win95-only
  118. HANDLE trapPipe; // NT-only
  119. OVERLAPPED trapOl; // for overlapped pipe I/O, bug# 270672
  120. HANDLE trapEvent; // for termination of thrTrap
  121. HANDLE hExitEvent; // for termination of thrManager
  122. smiUINT32 nLastReqId;
  123. SNMPAPI_STATUS nLastError;
  124. OSVERSIONINFO sEnv; // Operating System
  125. } TASK, FAR *LPTASK;
  126. typedef struct
  127. {
  128. HSNMP_SESSION nTask;
  129. HWND hWnd;
  130. DWORD wMsg;
  131. SNMPAPI_CALLBACK fCallBack;
  132. LPVOID lpClientData;
  133. HANDLE thrEvent;
  134. HANDLE thrHandle;
  135. DWORD thrCount;
  136. SNMPAPI_STATUS nLastError;
  137. } SESSION, FAR *LPSESSION;
  138. typedef struct
  139. {
  140. HSNMP_SESSION Session;
  141. smiINT32 type;
  142. smiINT32 appReqId;
  143. smiINT32 errStatus;
  144. smiINT32 errIndex;
  145. HSNMP_VBL VBL;
  146. LPVARBIND VBL_addr;
  147. LPV1TRAP v1Trap;
  148. } PDUS, FAR *LPPDUS;
  149. typedef struct
  150. {
  151. HSNMP_SESSION Session;
  152. LPVARBIND vbList;
  153. } VBLS, FAR *LPVBLS;
  154. typedef struct
  155. {
  156. HSNMP_SESSION Session;
  157. smiUINT32 refCount;
  158. smiUINT32 version;
  159. smiBYTE name[MAX_FRIEND_NAME_LEN+1]; // friendly name
  160. smiTIMETICKS nPolicyTimeout; // centiseconds
  161. smiTIMETICKS nActualTimeout; // centiseconds
  162. smiUINT32 nPolicyRetry;
  163. smiUINT32 nActualRetry;
  164. smiUINT32 Agent;
  165. SAS addr;
  166. } ENTITY, FAR *LPENTITY;
  167. typedef struct
  168. {
  169. HSNMP_SESSION Session;
  170. smiUINT32 refCount;
  171. smiUINT32 version;
  172. smiBYTE name[MAX_FRIEND_NAME_LEN+1]; // friendly name
  173. smiUINT32 commLen; // len of commStr
  174. smiBYTE commStr[MAX_CONTEXT_LEN]; // raw value
  175. } CTXT, FAR *LPCTXT;
  176. typedef struct
  177. {
  178. HSNMP_SESSION Session;
  179. DWORD Status; // NP_SEND|SENT|RCVD|READY
  180. DWORD Type; // PDU type
  181. HSNMP_ENTITY agentEntity;
  182. HSNMP_ENTITY ourEntity;
  183. HSNMP_CONTEXT Context;
  184. smiUINT32 dllReqId;
  185. smiUINT32 appReqId;
  186. smiUINT32 nRetransmitMode;
  187. smiUINT32 Ticks; // Msg sent time
  188. smiUINT32 Wait; // Msg timeout interval (millisecs)
  189. smiUINT32 Tries; // Msg retry count
  190. smiLPBYTE Addr;
  191. smiUINT32 Size;
  192. SAS Host;
  193. smiUINT32 PolicyTries; // the Tries counter started from here
  194. } SNMPMSG, FAR *LPSNMPMSG;
  195. typedef struct
  196. {
  197. HSNMP_SESSION Session;
  198. HSNMP_ENTITY ourEntity;
  199. HSNMP_ENTITY agentEntity;
  200. HSNMP_CONTEXT Context;
  201. smiOID notification;
  202. smiUINT32 notificationValue[MAXTRAPIDS];
  203. } TRAPNOTICE, FAR *LPTRAPNOTICE;
  204. typedef struct
  205. {
  206. HSNMP_SESSION Session;
  207. HSNMP_ENTITY Entity;
  208. SOCKET Socket;
  209. HANDLE Thread;
  210. } AGENT, FAR *LPAGENT;
  211. #endif // _INC_WINSNMPN