home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / WIN_NT / SNMPKT.ZIP / MSTOOLS / H / SNMP.H < prev   
Encoding:
C/C++ Source or Header  |  1992-11-13  |  7.8 KB  |  301 lines

  1. /*++ BUILD Version: 0001    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1992, Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     snmp.h
  8.  
  9. Abstract:
  10.  
  11.     Type definitions for SNMP Extension Agent Development.
  12.  
  13.  
  14.     This PRE-RELEASE header file contains definitions that may change
  15.     prior to the official release of Windows NT.   Microsoft makes no
  16.     warranty of any kind as to the suitability or correctness of this
  17.     code.
  18.  
  19.  
  20. --*/
  21.  
  22. #ifndef snmp_h
  23. #define snmp_h
  24.  
  25.  
  26.  
  27.  
  28. #include <windows.h>
  29.  
  30.  
  31.  
  32. //
  33. // SNMP API Constant Definitions
  34. //
  35.  
  36. // Purely for code readability
  37. #define IN
  38. #define OUT
  39.  
  40.  
  41. // API return type
  42. #define SNMPAPI int _stdcall
  43.  
  44.  
  45. // API return codes
  46. #define SNMPAPI_NOERROR TRUE
  47. #define SNMPAPI_ERROR   FALSE
  48.  
  49.  
  50. // class field of BER tag
  51. #define ASN_UNIVERSAL         0x00
  52. #define ASN_APPLICATION       0x40
  53. #define ASN_CONTEXTSPECIFIC   0x80
  54. #define ASN_PRIVATE           0xC0
  55.  
  56. // primative/constructed field of BER tag
  57. #define ASN_PRIMATIVE         0x00
  58. #define ASN_CONSTRUCTOR       0x20
  59.  
  60.  
  61. // ASN.1 simple types
  62. #define ASN_INTEGER           (ASN_UNIVERSAL | ASN_PRIMATIVE | 0x02)
  63. #define ASN_OCTETSTRING       (ASN_UNIVERSAL | ASN_PRIMATIVE | 0x04)
  64. #define ASN_NULL              (ASN_UNIVERSAL | ASN_PRIMATIVE | 0x05)
  65. #define ASN_OBJECTIDENTIFIER  (ASN_UNIVERSAL | ASN_PRIMATIVE | 0x06)
  66.  
  67. // ASN.1 constructor types
  68. #define ASN_SEQUENCE          (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)
  69. #define ASN_SEQUENCEOF        ASN_SEQUENCE
  70.  
  71. // ASN.1 application specific primatives
  72. #define ASN_RFC1155_IPADDRESS  (ASN_APPLICATION | ASN_PRIMATIVE | 0x00)
  73. #define ASN_RFC1155_COUNTER    (ASN_APPLICATION | ASN_PRIMATIVE | 0x01)
  74. #define ASN_RFC1155_GAUGE      (ASN_APPLICATION | ASN_PRIMATIVE | 0x02)
  75. #define ASN_RFC1155_TIMETICKS  (ASN_APPLICATION | ASN_PRIMATIVE | 0x03)
  76. #define ASN_RFC1155_OPAQUE     (ASN_APPLICATION | ASN_PRIMATIVE | 0x04)
  77. #define ASN_RFC1213_DISPSTRING ASN_OCTETSTRING
  78.  
  79. // ASN.1 application specific constructors
  80. #define ASN_RFC1157_GETREQUEST     \
  81.             (ASN_CONTEXTSPECIFIC | ASN_CONSTRUCTOR | 0x00)
  82. #define ASN_RFC1157_GETNEXTREQUEST \
  83.             (ASN_CONTEXTSPECIFIC | ASN_CONSTRUCTOR | 0x01)
  84. #define ASN_RFC1157_GETRESPONSE    \
  85.             (ASN_CONTEXTSPECIFIC | ASN_CONSTRUCTOR | 0x02)
  86. #define ASN_RFC1157_SETREQUEST     \
  87.             (ASN_CONTEXTSPECIFIC | ASN_CONSTRUCTOR | 0x03)
  88. #define ASN_RFC1157_TRAP           \
  89.             (ASN_CONTEXTSPECIFIC | ASN_CONSTRUCTOR | 0x04)
  90.  
  91.  
  92. // PDU error status
  93. #define SNMP_ERRORSTATUS_NOERROR        0
  94. #define SNMP_ERRORSTATUS_TOOBIG         1
  95. #define SNMP_ERRORSTATUS_NOSUCHNAME     2
  96. #define SNMP_ERRORSTATUS_BADVALUE       3
  97. #define SNMP_ERRORSTATUS_READONLY       4
  98. #define SNMP_ERRORSTATUS_GENERR         5
  99.  
  100.  
  101. // PDU generic traps
  102. #define SNMP_GENERICTRAP_COLDSTART      0
  103. #define SNMP_GENERICTRAP_WARMSTART      1
  104. #define SNMP_GENERICTRAP_LINKDOWN       2
  105. #define SNMP_GENERICTRAP_LINKUP         3
  106. #define SNMP_GENERICTRAP_AUTHFAILURE    4
  107. #define SNMP_GENERICTRAP_EGPNEIGHLOSS   5
  108. #define SNMP_GENERICTRAP_ENTERSPECIFIC  6
  109.  
  110.  
  111.  
  112. //
  113. // SNMP Error codes
  114. //
  115.  
  116. // General error codes
  117. #define SNMP_MEM_ALLOC_ERROR          1
  118.  
  119. // BER API error codes (using Get/Set LastError)
  120. #define SNMP_BERAPI_INVALID_LENGTH    10
  121. #define SNMP_BERAPI_INVALID_TAG       11
  122. #define SNMP_BERAPI_OVERFLOW          12
  123. #define SNMP_BERAPI_SHORT_BUFFER      13
  124. #define SNMP_BERAPI_INVALID_OBJELEM   14
  125.  
  126. // PDU API Error Codes
  127. #define SNMP_PDUAPI_UNRECOGNIZED_PDU  20
  128. #define SNMP_PDUAPI_INVALID_ES        21
  129. #define SNMP_PDUAPI_INVALID_GT        22
  130.  
  131. // AUTHENTICATION API Error Codes
  132. #define SNMP_AUTHAPI_INVALID_VERSION  30
  133. #define SNMP_AUTHAPI_INVALID_MSG_TYPE 31
  134. #define SNMP_AUTHAPI_TRIV_AUTH_FAILED 32
  135.  
  136.  
  137.  
  138. //
  139. // SNMP API Type Definitions
  140. //
  141.  
  142. typedef long           AsnInteger;
  143. typedef struct {
  144.     BYTE *stream;
  145.     UINT  length;
  146.     BOOL dynamic;
  147. }                      AsnOctetString;
  148. typedef struct {
  149.     UINT idLength;
  150.     UINT *ids;
  151. }                      AsnObjectIdentifier;
  152.  
  153. typedef AsnOctetString AsnSequence;
  154. typedef AsnSequence    AsnImplicitSequence;
  155.  
  156. typedef AsnOctetString AsnIPAddress;
  157. typedef AsnOctetString AsnDisplayString;
  158. typedef AsnInteger     AsnCounter;
  159. typedef AsnInteger     AsnGauge;
  160. typedef AsnInteger     AsnTimeticks;
  161. typedef AsnOctetString AsnOpaque;
  162.  
  163. typedef struct {
  164.     BYTE asnType;
  165.     union {
  166.         // RFC 1155 SimpleSyntax (subset of ISO ASN.1)
  167.         AsnInteger           number;
  168.         AsnOctetString       string;
  169.         AsnObjectIdentifier  object;
  170.  
  171.         // ISO ASN.1
  172.         AsnSequence          sequence;
  173.  
  174.         // RFC 1155 ApplicationSyntax
  175.         AsnIPAddress         address;
  176.         AsnCounter           counter;
  177.         AsnGauge             gauge;
  178.         AsnTimeticks         ticks;
  179.         AsnOpaque            arbitrary;
  180.     } asnValue;
  181. } AsnAny;
  182.  
  183. typedef AsnObjectIdentifier AsnObjectName;
  184. typedef AsnAny              AsnObjectSyntax;
  185. typedef AsnIPAddress        AsnNetworkAddress;
  186.  
  187. typedef struct vb {
  188.     AsnObjectName   name;
  189.     AsnObjectSyntax value;
  190. } RFC1157VarBind;
  191.  
  192. typedef struct {
  193.     RFC1157VarBind *list;
  194.     UINT           len;
  195. } RFC1157VarBindList;
  196.  
  197. typedef struct {
  198.     RFC1157VarBindList varBinds;
  199.     AsnInteger         requestType;
  200.     AsnInteger         requestId;
  201.     AsnInteger         errorStatus;
  202.     AsnInteger         errorIndex;
  203. } RFC1157Pdu;
  204.  
  205. typedef struct {
  206.     RFC1157VarBindList  varBinds;
  207.     AsnObjectIdentifier enterprise;
  208.     AsnNetworkAddress   agentAddr;
  209.     AsnInteger          genericTrap;
  210.     AsnInteger          specificTrap;
  211.     AsnTimeticks        timeStamp;
  212. } RFC1157TrapPdu;
  213.  
  214. typedef struct {
  215.    BYTE pduType;
  216.    union {
  217.       RFC1157Pdu     pdu;
  218.       RFC1157TrapPdu trap;
  219.    } pduValue;
  220. } RFC1157Pdus;
  221.  
  222. typedef struct {
  223.     AsnObjectIdentifier dstParty;
  224.     AsnObjectIdentifier srcParty;
  225.     RFC1157Pdus pdu;
  226.     AsnOctetString community; // This is temporary
  227. } SnmpMgmtCom;
  228.  
  229.  
  230.  
  231. //
  232. // SNMP Utility Prototypes
  233. //
  234.  
  235.  
  236. // Preferred names for the APIs, prototypes following may change in future.
  237.  
  238. #define SnmpUtilOidCpy(a,b)      SNMP_oidcpy(a,b)
  239. #define SnmpUtilOidAppend(a,b)   SNMP_oidappend(a,b)
  240. #define SnmpUtilOidNCmp(a,b,c)   SNMP_oidncmp(a,b,c)
  241. #define SnmpUtilOidCmp(a,b)      SNMP_oidcmp(a,b)
  242. #define SnmpUtilOidFree(a)       SNMP_oidfree(a)
  243.  
  244. #define SnmpUtilVarBindListCpy(a,b)  SNMP_CopyVarListBind(a,b)
  245. #define SnmpUtilVarBindCpy(a,b)      SNMP_CopyVarBind(a,b)
  246. #define SnmpUtilVarBindListFree(a)   SNMP_FreeVarBindList(a)
  247. #define SnmpUtilVarBindFree(a)       SNMP_FreeVarBind(a)
  248.  
  249. #define SnmpUtilPrintAsnAny(a)   SNMP_printany(a)
  250.  
  251.  
  252. SNMPAPI SNMP_oidcpy(
  253.     OUT AsnObjectIdentifier *DestObjId, // Destination OID
  254.     IN AsnObjectIdentifier *SrcObjId    // Source OID
  255.     );
  256.  
  257. SNMPAPI SNMP_oidappend(
  258.     IN OUT AsnObjectIdentifier *DestObjId, // Destination OID
  259.     IN AsnObjectIdentifier *SrcObjId       // Source OID
  260.     );
  261.  
  262. int _stdcall SNMP_oidncmp(
  263.     IN AsnObjectIdentifier *A, // First OID
  264.     IN AsnObjectIdentifier *B, // Second OID
  265.     IN UINT Len                // Max len to compare
  266.     );
  267.  
  268. #define SNMP_oidcmp(A,B) SNMP_oidncmp(A,B,max((A)->idLength,(B)->idLength))
  269.  
  270. void _stdcall SNMP_oidfree(
  271.     IN OUT AsnObjectIdentifier *Obj // OID to free
  272.     );
  273.  
  274.  
  275. SNMPAPI SNMP_CopyVarBindList(
  276.     RFC1157VarBindList *dst, // Destination var bind list
  277.     RFC1157VarBindList *src  // Source var bind list
  278.     );
  279.  
  280. SNMPAPI SNMP_CopyVarBind(
  281.     RFC1157VarBind *dst, // Destination var bind
  282.     RFC1157VarBind *src  // Source var bind
  283.     );
  284.  
  285.  
  286. void _stdcall SNMP_FreeVarBindList(
  287.     RFC1157VarBindList *VarBindList // Variable bindings list to free
  288.     );
  289.  
  290. void _stdcall SNMP_FreeVarBind(
  291.     RFC1157VarBind *VarBind // Variable binding to free
  292.     );
  293.  
  294.  
  295. void _stdcall SNMP_printany(
  296.     IN AsnAny *Any
  297.     );
  298.  
  299.  
  300. #endif /* snmp_h */
  301.