1 module snmp.types; 2 3 public import c.net_snmp; 4 5 /// SNMP protocol versions 6 enum SNMPVersion : long 7 { 8 v1 = SNMP_VERSION_1, 9 v2c = SNMP_VERSION_2c, 10 v3 = SNMP_VERSION_3, 11 } 12 13 /// SNMP PDU command types 14 enum PDUType : int 15 { 16 get = SNMP_MSG_GET, 17 getNext = SNMP_MSG_GETNEXT, 18 response = SNMP_MSG_RESPONSE, 19 set = SNMP_MSG_SET, 20 trap = SNMP_MSG_TRAP, 21 getBulk = SNMP_MSG_GETBULK, 22 inform = SNMP_MSG_INFORM, 23 trap2 = SNMP_MSG_TRAP2, 24 report = SNMP_MSG_REPORT, 25 } 26 27 /// SNMP error status codes (RFC 1905) 28 enum SNMPError : int 29 { 30 noError = SNMP_ERR_NOERROR, 31 tooBig = SNMP_ERR_TOOBIG, 32 noSuchName = SNMP_ERR_NOSUCHNAME, 33 badValue = SNMP_ERR_BADVALUE, 34 readOnly = SNMP_ERR_READONLY, 35 genErr = SNMP_ERR_GENERR, 36 noAccess = SNMP_ERR_NOACCESS, 37 wrongType = SNMP_ERR_WRONGTYPE, 38 wrongLength = SNMP_ERR_WRONGLENGTH, 39 wrongEncoding = SNMP_ERR_WRONGENCODING, 40 wrongValue = SNMP_ERR_WRONGVALUE, 41 noCreation = SNMP_ERR_NOCREATION, 42 inconsistentValue = SNMP_ERR_INCONSISTENTVALUE, 43 resourceUnavailable = SNMP_ERR_RESOURCEUNAVAILABLE, 44 commitFailed = SNMP_ERR_COMMITFAILED, 45 undoFailed = SNMP_ERR_UNDOFAILED, 46 authorizationError = SNMP_ERR_AUTHORIZATIONERROR, 47 notWritable = SNMP_ERR_NOTWRITABLE, 48 inconsistentName = SNMP_ERR_INCONSISTENTNAME, 49 } 50 51 /// ASN.1 / SNMP application types used in variable bindings 52 enum ASNType : ubyte 53 { 54 boolean = ASN_BOOLEAN, 55 integer = ASN_INTEGER, 56 bitStr = ASN_BIT_STR, 57 octetStr = ASN_OCTET_STR, 58 null_ = ASN_NULL, 59 objectId = ASN_OBJECT_ID, 60 ipAddress = ASN_IPADDRESS, 61 counter32 = ASN_COUNTER, 62 gauge32 = ASN_GAUGE, 63 timeticks = ASN_TIMETICKS, 64 counter64 = ASN_COUNTER64, 65 noSuchObject = SNMP_NOSUCHOBJECT, 66 noSuchInstance = SNMP_NOSUCHINSTANCE, 67 } 68 69 /// Status codes returned by snmp_synch_response 70 enum SNMPStatus : int 71 { 72 success = STAT_SUCCESS, 73 error = STAT_ERROR, 74 timeout = STAT_TIMEOUT, 75 } 76 77 unittest 78 { 79 // Verify enum values match the SNMP protocol spec (RFC 1157 / RFC 3416) 80 static assert(SNMPVersion.v1 == 0); 81 static assert(SNMPVersion.v2c == 1); 82 static assert(SNMPVersion.v3 == 3); 83 84 static assert(SNMPStatus.success == 0); 85 static assert(SNMPStatus.error == 1); 86 static assert(SNMPStatus.timeout == 2); 87 88 static assert(SNMPError.noError == 0); 89 90 // PDU types must be distinct 91 static assert(PDUType.get != PDUType.getNext); 92 static assert(PDUType.getNext != PDUType.set); 93 static assert(PDUType.get != PDUType.getBulk); 94 }