Source code of Windows XP (NT5)
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.

219 lines
7.2 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. smiUINT32 nLastReqId;
  122. SNMPAPI_STATUS nLastError;
  123. OSVERSIONINFO sEnv; // Operating System
  124. } TASK, FAR *LPTASK;
  125. typedef struct
  126. {
  127. HSNMP_SESSION nTask;
  128. HWND hWnd;
  129. DWORD wMsg;
  130. SNMPAPI_CALLBACK fCallBack;
  131. LPVOID lpClientData;
  132. HANDLE thrEvent;
  133. HANDLE thrHandle;
  134. DWORD thrCount;
  135. SNMPAPI_STATUS nLastError;
  136. } SESSION, FAR *LPSESSION;
  137. typedef struct
  138. {
  139. HSNMP_SESSION Session;
  140. smiINT32 type;
  141. smiINT32 appReqId;
  142. smiINT32 errStatus;
  143. smiINT32 errIndex;
  144. HSNMP_VBL VBL;
  145. LPVARBIND VBL_addr;
  146. LPV1TRAP v1Trap;
  147. } PDUS, FAR *LPPDUS;
  148. typedef struct
  149. {
  150. HSNMP_SESSION Session;
  151. LPVARBIND vbList;
  152. } VBLS, FAR *LPVBLS;
  153. typedef struct
  154. {
  155. HSNMP_SESSION Session;
  156. smiUINT32 refCount;
  157. smiUINT32 version;
  158. smiBYTE name[MAX_FRIEND_NAME_LEN+1]; // friendly name
  159. smiTIMETICKS nPolicyTimeout; // centiseconds
  160. smiTIMETICKS nActualTimeout; // centiseconds
  161. smiUINT32 nPolicyRetry;
  162. smiUINT32 nActualRetry;
  163. smiUINT32 Agent;
  164. SAS addr;
  165. } ENTITY, FAR *LPENTITY;
  166. typedef struct
  167. {
  168. HSNMP_SESSION Session;
  169. smiUINT32 refCount;
  170. smiUINT32 version;
  171. smiBYTE name[MAX_FRIEND_NAME_LEN+1]; // friendly name
  172. smiUINT32 commLen; // len of commStr
  173. smiBYTE commStr[MAX_CONTEXT_LEN]; // raw value
  174. } CTXT, FAR *LPCTXT;
  175. typedef struct
  176. {
  177. HSNMP_SESSION Session;
  178. DWORD Status; // NP_SEND|SENT|RCVD|READY
  179. DWORD Type; // PDU type
  180. HSNMP_ENTITY agentEntity;
  181. HSNMP_ENTITY ourEntity;
  182. HSNMP_CONTEXT Context;
  183. smiUINT32 dllReqId;
  184. smiUINT32 appReqId;
  185. smiUINT32 nRetransmitMode;
  186. smiUINT32 Ticks; // Msg sent time
  187. smiUINT32 Wait; // Msg timeout interval (millisecs)
  188. smiUINT32 Tries; // Msg retry count
  189. smiLPBYTE Addr;
  190. smiUINT32 Size;
  191. SAS Host;
  192. smiUINT32 PolicyTries; // the Tries counter started from here
  193. } SNMPMSG, FAR *LPSNMPMSG;
  194. typedef struct
  195. {
  196. HSNMP_SESSION Session;
  197. HSNMP_ENTITY ourEntity;
  198. HSNMP_ENTITY agentEntity;
  199. HSNMP_CONTEXT Context;
  200. smiOID notification;
  201. smiUINT32 notificationValue[MAXTRAPIDS];
  202. } TRAPNOTICE, FAR *LPTRAPNOTICE;
  203. typedef struct
  204. {
  205. HSNMP_SESSION Session;
  206. HSNMP_ENTITY Entity;
  207. SOCKET Socket;
  208. HANDLE Thread;
  209. } AGENT, FAR *LPAGENT;
  210. #endif // _INC_WINSNMPN