1 /** 2 * Windows API header module 3 * 4 * Translated from MinGW Windows headers 5 * 6 * Authors: Stewart Gordon 7 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 * Source: $(DRUNTIMESRC core/sys/windows/_snmp.d) 9 */ 10 module core.sys.windows.snmp; 11 version (Windows): 12 13 import core.sys.windows.basetsd /+: HANDLE+/; 14 import core.sys.windows.windef /+: BOOL, BYTE, DWORD, INT, LONG, UINT, ULONG+/; 15 import core.sys.windows.winnt /+: LPSTR, LPVOID, ULARGE_INTEGER, VOID+/; 16 17 // These are not documented on MSDN 18 enum { 19 DEFAULT_SNMP_PORT_UDP = 161, 20 DEFAULT_SNMP_PORT_IPX = 36879, 21 DEFAULT_SNMPTRAP_PORT_UDP = 162, 22 DEFAULT_SNMPTRAP_PORT_IPX = 36880 23 } 24 25 enum : BYTE { 26 ASN_UNIVERSAL = 0x00, 27 ASN_PRIMITIVE = 0x00, 28 ASN_CONSTRUCTOR = 0x20, 29 ASN_APPLICATION = 0x40, 30 ASN_CONTEXT = 0x80, 31 ASN_PRIVATE = 0xC0, 32 33 SNMP_PDU_GET = ASN_CONTEXT | ASN_CONSTRUCTOR, 34 SNMP_PDU_GETNEXT, 35 SNMP_PDU_RESPONSE, 36 SNMP_PDU_SET, 37 SNMP_PDU_GETBULK, // = ASN_CONTEXT | ASN_CONSTRUCTOR | 4 38 SNMP_PDU_V1TRAP = ASN_CONTEXT | ASN_CONSTRUCTOR | 4, 39 SNMP_PDU_INFORM = ASN_CONTEXT | ASN_CONSTRUCTOR | 6, 40 SNMP_PDU_TRAP, 41 SNMP_PDU_REPORT, 42 ASN_INTEGER = ASN_UNIVERSAL | ASN_PRIMITIVE | 2, 43 ASN_BITS, 44 ASN_OCTETSTRING, 45 ASN_NULL, 46 ASN_OBJECTIDENTIFIER, // = ASN_UNIVERSAL | ASN_PRIMITIVE | 6 47 ASN_INTEGER32 = ASN_INTEGER, 48 ASN_SEQUENCE = ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10, 49 ASN_SEQUENCEOF = ASN_SEQUENCE, 50 ASN_IPADDRESS = ASN_APPLICATION | ASN_PRIMITIVE, 51 ASN_COUNTER32, 52 ASN_GAUGE32, 53 ASN_TIMETICKS, 54 ASN_OPAQUE, // = ASN_APPLICATION | ASN_PRIMITIVE | 4 55 ASN_COUNTER64 = ASN_APPLICATION | ASN_PRIMITIVE | 6, 56 ASN_UNSIGNED32, // = ASN_APPLICATION | ASN_PRIMITIVE | 7 57 SNMP_EXCEPTION_NOSUCHOBJECT = ASN_CONTEXT | ASN_PRIMITIVE, 58 SNMP_EXCEPTION_NOSUCHINSTANCE, 59 SNMP_EXCEPTION_ENDOFMIBVIEW, 60 SNMP_EXTENSION_GET = SNMP_PDU_GET, 61 SNMP_EXTENSION_GET_NEXT = SNMP_PDU_GETNEXT, 62 SNMP_EXTENSION_GET_BULK = SNMP_PDU_GETBULK, 63 SNMP_EXTENSION_SET_TEST = ASN_PRIVATE | ASN_CONSTRUCTOR, 64 SNMP_EXTENSION_SET_COMMIT = SNMP_PDU_SET, 65 SNMP_EXTENSION_SET_UNDO = ASN_PRIVATE | ASN_CONSTRUCTOR | 1, 66 SNMP_EXTENSION_SET_CLEANUP 67 } 68 69 70 enum : AsnInteger { 71 SNMP_ERRORSTATUS_NOERROR, 72 SNMP_ERRORSTATUS_TOOBIG, 73 SNMP_ERRORSTATUS_NOSUCHNAME, 74 SNMP_ERRORSTATUS_BADVALUE, 75 SNMP_ERRORSTATUS_READONLY, 76 SNMP_ERRORSTATUS_GENERR, 77 SNMP_ERRORSTATUS_NOACCESS, 78 SNMP_ERRORSTATUS_WRONGTYPE, 79 SNMP_ERRORSTATUS_WRONGLENGTH, 80 SNMP_ERRORSTATUS_WRONGENCODING, 81 SNMP_ERRORSTATUS_WRONGVALUE, 82 SNMP_ERRORSTATUS_NOCREATION, 83 SNMP_ERRORSTATUS_INCONSISTENTVALUE, 84 SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE, 85 SNMP_ERRORSTATUS_COMMITFAILED, 86 SNMP_ERRORSTATUS_UNDOFAILED, 87 SNMP_ERRORSTATUS_AUTHORIZATIONERROR, 88 SNMP_ERRORSTATUS_NOTWRITABLE, 89 SNMP_ERRORSTATUS_INCONSISTENTNAME 90 } 91 92 enum : AsnInteger { 93 SNMP_GENERICTRAP_COLDSTART, 94 SNMP_GENERICTRAP_WARMSTART, 95 SNMP_GENERICTRAP_LINKDOWN, 96 SNMP_GENERICTRAP_LINKUP, 97 SNMP_GENERICTRAP_AUTHFAILURE, 98 SNMP_GENERICTRAP_EGPNEIGHLOSS, 99 SNMP_GENERICTRAP_ENTERSPECIFIC 100 } 101 102 // These are not documented on MSDN 103 enum { 104 SNMP_ACCESS_NONE, 105 SNMP_ACCESS_NOTIFY, 106 SNMP_ACCESS_READ_ONLY, 107 SNMP_ACCESS_READ_WRITE, 108 SNMP_ACCESS_READ_CREATE 109 } 110 111 enum : BOOL { 112 SNMPAPI_ERROR = false, 113 SNMPAPI_NOERROR = true 114 } 115 116 enum : INT { 117 SNMP_LOG_SILENT, 118 SNMP_LOG_FATAL, 119 SNMP_LOG_ERROR, 120 SNMP_LOG_WARNING, 121 SNMP_LOG_TRACE, 122 SNMP_LOG_VERBOSE 123 } 124 125 enum INT 126 SNMP_OUTPUT_TO_CONSOLE = 1, 127 SNMP_OUTPUT_TO_LOGFILE = 2, 128 SNMP_OUTPUT_TO_EVENTLOG = 4, 129 SNMP_OUTPUT_TO_DEBUGGER = 8; 130 131 enum size_t SNMP_MAX_OID_LEN = 128; 132 133 enum : DWORD { 134 SNMP_MEM_ALLOC_ERROR = 1, 135 SNMP_BERAPI_INVALID_LENGTH = 10, 136 SNMP_BERAPI_INVALID_TAG, 137 SNMP_BERAPI_OVERFLOW, 138 SNMP_BERAPI_SHORT_BUFFER, 139 SNMP_BERAPI_INVALID_OBJELEM, 140 SNMP_PDUAPI_UNRECOGNIZED_PDU = 20, 141 SNMP_PDUAPI_INVALID_ES, 142 SNMP_PDUAPI_INVALID_GT, 143 SNMP_AUTHAPI_INVALID_VERSION = 30, 144 SNMP_AUTHAPI_INVALID_MSG_TYPE, 145 SNMP_AUTHAPI_TRIV_AUTH_FAILED, 146 } 147 148 alias INT SNMPAPI; 149 alias LONG AsnInteger32; 150 alias ULONG AsnUnsigned32, AsnCounter32, AsnGauge32, AsnTimeticks; 151 alias ULARGE_INTEGER AsnCounter64; 152 153 align (4): 154 155 struct AsnOctetString { 156 align (4): 157 BYTE* stream; 158 UINT length; 159 BOOL dynamic; 160 } 161 alias AsnOctetString AsnBits, AsnSequence, AsnImplicitSequence, 162 AsnIPAddress, AsnNetworkAddress, AsnDisplayString, AsnOpaque; 163 164 struct AsnObjectIdentifier { 165 align (4): 166 UINT idLength; 167 UINT* ids; 168 } 169 alias AsnObjectIdentifier AsnObjectName; 170 171 struct AsnAny { 172 align (4): 173 BYTE asnType; 174 union _asnValue { 175 AsnInteger32 number; 176 AsnUnsigned32 unsigned32; 177 AsnCounter64 counter64; 178 AsnOctetString string; 179 AsnBits bits; 180 AsnObjectIdentifier object; 181 AsnSequence sequence; 182 AsnIPAddress address; 183 AsnCounter32 counter; 184 AsnGauge32 gauge; 185 AsnTimeticks ticks; 186 AsnOpaque arbitrary; 187 } 188 _asnValue asnValue; 189 } 190 alias AsnAny AsnObjectSyntax; 191 192 struct SnmpVarBind { 193 align (4): 194 AsnObjectName name; 195 AsnObjectSyntax value; 196 } 197 198 struct SnmpVarBindList { 199 align (4): 200 SnmpVarBind* list; 201 UINT len; 202 } 203 204 extern (Windows) { 205 VOID SnmpExtensionClose(); 206 BOOL SnmpExtensionInit(DWORD, HANDLE*, AsnObjectIdentifier*); 207 BOOL SnmpExtensionInitEx(AsnObjectIdentifier*); 208 BOOL SnmpExtensionMonitor(LPVOID); 209 BOOL SnmpExtensionQuery(BYTE, SnmpVarBindList*, AsnInteger32*, 210 AsnInteger32*); 211 BOOL SnmpExtensionQueryEx(DWORD, DWORD, SnmpVarBindList*, AsnOctetString*, 212 AsnInteger32*, AsnInteger32*); 213 BOOL SnmpExtensionTrap(AsnObjectIdentifier*, AsnInteger32*, AsnInteger32*, 214 AsnTimeticks*, SnmpVarBindList*); 215 DWORD SnmpSvcGetUptime(); 216 VOID SnmpSvcSetLogLevel(INT); 217 VOID SnmpSvcSetLogType(INT); 218 SNMPAPI SnmpUtilAsnAnyCpy(AsnAny*, AsnAny*); 219 VOID SnmpUtilAsnAnyFree(AsnAny*); 220 VOID SnmpUtilDbgPrint(INT, LPSTR, ...); 221 LPSTR SnmpUtilIdsToA(UINT*, UINT); 222 LPVOID SnmpUtilMemAlloc(UINT); 223 VOID SnmpUtilMemFree(LPVOID); 224 LPVOID SnmpUtilMemReAlloc(LPVOID, UINT); 225 SNMPAPI SnmpUtilOctetsCmp(AsnOctetString*, AsnOctetString*); 226 SNMPAPI SnmpUtilOctetsCpy(AsnOctetString*, AsnOctetString*); 227 VOID SnmpUtilOctetsFree(AsnOctetString*); 228 SNMPAPI SnmpUtilOctetsNCmp(AsnOctetString*, AsnOctetString*, UINT); 229 SNMPAPI SnmpUtilOidAppend(AsnObjectIdentifier*, AsnObjectIdentifier*); 230 SNMPAPI SnmpUtilOidCmp(AsnObjectIdentifier*, AsnObjectIdentifier*); 231 SNMPAPI SnmpUtilOidCpy(AsnObjectIdentifier*, AsnObjectIdentifier*); 232 VOID SnmpUtilOidFree(AsnObjectIdentifier*); 233 SNMPAPI SnmpUtilOidNCmp(AsnObjectIdentifier*, AsnObjectIdentifier*, UINT); 234 LPSTR SnmpUtilOidToA(AsnObjectIdentifier*); 235 VOID SnmpUtilPrintAsnAny(AsnAny*); 236 VOID SnmpUtilPrintOid(AsnObjectIdentifier*); 237 SNMPAPI SnmpUtilVarBindCpy(SnmpVarBind*, SnmpVarBind*); 238 SNMPAPI SnmpUtilVarBindListCpy(SnmpVarBindList*, SnmpVarBindList*); 239 VOID SnmpUtilVarBindFree(SnmpVarBind*); 240 VOID SnmpUtilVarBindListFree(SnmpVarBindList*); 241 } 242 243 alias SnmpUtilMemAlloc SNMP_malloc; 244 alias SnmpUtilMemFree SNMP_free; 245 alias SnmpUtilMemReAlloc SNMP_realloc; 246 alias SnmpUtilMemAlloc SNMP_DBG_malloc; 247 alias SnmpUtilMemFree SNMP_DBG_free; 248 alias SnmpUtilMemReAlloc SNMP_DBG_realloc; 249 alias SnmpUtilOidAppend SNMP_oidappend; 250 alias SnmpUtilOidCmp SNMP_oidcmp; 251 alias SnmpUtilOidCpy SNMP_oidcpy; 252 alias SnmpUtilOidFree SNMP_oidfree; 253 alias SnmpUtilOidNCmp SNMP_oidncmp; 254 alias SnmpUtilPrintAsnAny SNMP_printany; 255 alias SnmpUtilVarBindCpy SNMP_CopyVarBind; 256 alias SnmpUtilVarBindListCpy SNMP_CopyVarBindList; 257 alias SnmpUtilVarBindFree SNMP_FreeVarBind; 258 alias SnmpUtilVarBindListFree SNMP_FreeVarBindList; 259 alias ASN_IPADDRESS ASN_RFC1155_IPADDRESS; 260 alias ASN_COUNTER32 ASN_RFC1155_COUNTER; 261 alias ASN_GAUGE32 ASN_RFC1155_GAUGE; 262 alias ASN_TIMETICKS ASN_RFC1155_TIMETICKS; 263 alias ASN_OPAQUE ASN_RFC1155_OPAQUE; 264 alias ASN_OCTETSTRING ASN_RFC1213_DISPSTRING; 265 alias SNMP_PDU_GET ASN_RFC1157_GETREQUEST; 266 alias SNMP_PDU_GETNEXT ASN_RFC1157_GETNEXTREQUEST; 267 alias SNMP_PDU_RESPONSE ASN_RFC1157_GETRESPONSE; 268 alias SNMP_PDU_SET ASN_RFC1157_SETREQUEST; 269 alias SNMP_PDU_V1TRAP ASN_RFC1157_TRAP; 270 alias ASN_CONTEXT ASN_CONTEXTSPECIFIC; 271 alias ASN_PRIMITIVE ASN_PRIMATIVE; 272 alias SnmpVarBindList RFC1157VarBindList; 273 alias SnmpVarBind RFC1157VarBind; 274 alias AsnInteger32 AsnInteger; 275 alias AsnCounter32 AsnCounter; 276 alias AsnGauge32 AsnGauge;