1 20 21 package org.snmp4j.mp; 22 23 import org.snmp4j.smi.OID; 24 25 32 public final class SnmpConstants { 33 34 public static final int DEFAULT_COMMAND_RESPONDER_PORT = 161; 35 public static final int DEFAULT_NOTIFICATION_RECEIVER_PORT = 162; 36 37 public static final int MIN_PDU_LENGTH = 484; 38 39 public static final int version1 = 0; 40 public static final int version2c = 1; 41 public static final int version3 = 3; 42 43 public static final int SNMP_ERROR_SUCCESS = 0; 44 public static final int SNMP_ERROR_TOO_BIG = 1; 45 public static final int SNMP_ERROR_NO_SUCH_NAME = 2; 46 public static final int SNMP_ERROR_BAD_VALUE = 3; 47 public static final int SNMP_ERROR_READ_ONLY = 4; 48 public static final int SNMP_ERROR_GENERAL_ERROR = 5; 49 public static final int SNMP_ERROR_NO_ACCESS = 6; 50 public static final int SNMP_ERROR_WRONG_TYPE = 7; 51 public static final int SNMP_ERROR_WRONG_LENGTH = 8; 52 public static final int SNMP_ERROR_WRONG_ENCODING = 9; 53 public static final int SNMP_ERROR_WRONG_VALUE =10; 54 public static final int SNMP_ERROR_NO_CREATION =11; 55 public static final int SNMP_ERROR_INCONSISTENT_VALUE =12; 56 public static final int SNMP_ERROR_RESOURCE_UNAVAILABLE =13; 57 public static final int SNMP_ERROR_COMMIT_FAILED =14; 58 public static final int SNMP_ERROR_UNDO_FAILED =15; 59 public static final int SNMP_ERROR_AUTHORIZATION_ERROR =16; 60 public static final int SNMP_ERROR_NOT_WRITEABLE =17; 61 public static final int SNMP_ERROR_INCONSISTENT_NAME =18; 62 63 public static final int SNMP_MP_OK = 0; 64 public static final int SNMP_MP_ERROR = -1400; 65 public static final int SNMP_MP_UNSUPPORTED_SECURITY_MODEL = -1402; 66 public static final int SNMP_MP_NOT_IN_TIME_WINDOW = -1403; 67 public static final int SNMP_MP_DOUBLED_MESSAGE = -1404; 68 public static final int SNMP_MP_INVALID_MESSAGE = -1405; 69 public static final int SNMP_MP_INVALID_ENGINEID = -1406; 70 public static final int SNMP_MP_NOT_INITIALIZED = -1407; 71 public static final int SNMP_MP_PARSE_ERROR = -1408; 72 public static final int SNMP_MP_UNKNOWN_MSGID = -1409; 73 public static final int SNMP_MP_MATCH_ERROR = -1410; 74 public static final int SNMP_MP_COMMUNITY_ERROR = -1411; 75 public static final int SNMP_MP_WRONG_USER_NAME = -1412; 76 public static final int SNMP_MP_BUILD_ERROR = -1413; 77 public static final int SNMP_MP_USM_ERROR = -1414; 78 public static final int SNMP_MP_UNKNOWN_PDU_HANDLERS = -1415; 79 public static final int SNMP_MP_UNAVAILABLE_CONTEXT = -1416; 80 public static final int SNMP_MP_UNKNOWN_CONTEXT = -1417; 81 public static final int SNMP_MP_REPORT_SENT = -1418; 82 83 public static final int SNMPv1v2c_CSM_OK = 0; 84 public static final int SNMPv1v2c_CSM_BAD_COMMUNITY_NAME = 1501; 85 public static final int SNMPv1v2c_CSM_BAD_COMMUNITY_USE = 1502; 86 87 88 public static final int SNMPv3_USM_OK = 0; 89 public static final int SNMPv3_USM_ERROR = 1401; 90 public static final int SNMPv3_USM_ERROR_CONFIGFILE = 1402; 91 public static final int SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL = 1403; 92 public static final int SNMPv3_USM_UNKNOWN_SECURITY_NAME = 1404; 93 public static final int SNMPv3_USM_ENCRYPTION_ERROR = 1405; 94 public static final int SNMPv3_USM_DECRYPTION_ERROR = 1406; 95 public static final int SNMPv3_USM_AUTHENTICATION_ERROR = 1407; 96 public static final int SNMPv3_USM_AUTHENTICATION_FAILURE = 1408; 97 public static final int SNMPv3_USM_PARSE_ERROR = 1409; 98 public static final int SNMPv3_USM_UNKNOWN_ENGINEID = 1410; 99 public static final int SNMPv3_USM_NOT_IN_TIME_WINDOW = 1411; 100 public static final int SNMPv3_USM_UNSUPPORTED_AUTHPROTOCOL = 1412; 101 public static final int SNMPv3_USM_UNSUPPORTED_PRIVPROTOCOL = 1413; 102 public static final int SNMPv3_USM_ADDRESS_ERROR = 1414; 103 104 public static final OID usmStatsUnsupportedSecLevels = 105 new OID(new int[]{1, 3, 6, 1, 6, 3, 15, 1, 1, 1, 0 }); 106 public static final OID usmStatsNotInTimeWindows = 107 new OID(new int[]{1, 3, 6, 1, 6, 3, 15, 1, 1, 2, 0 }); 108 public static final OID usmStatsUnknownUserNames = 109 new OID(new int[]{1, 3, 6, 1, 6, 3, 15, 1, 1, 3, 0 }); 110 public static final OID usmStatsUnknownEngineIDs = 111 new OID(new int[]{1, 3, 6, 1, 6, 3, 15, 1, 1, 4, 0 }); 112 public static final OID usmStatsWrongDigests = 113 new OID(new int[]{1, 3, 6, 1, 6, 3, 15, 1, 1, 5, 0 }); 114 public static final OID usmStatsDecryptionErrors = 115 new OID(new int[]{1, 3, 6, 1, 6, 3, 15, 1, 1, 6, 0 }); 116 117 118 public static final OID snmpUnknownSecurityModels = 119 new OID(new int[] { 1, 3, 6, 1, 6, 3, 11, 2, 1, 1, 0 }); 120 public static final OID snmpInvalidMsgs = 121 new OID(new int[] { 1, 3, 6, 1, 6, 3, 11, 2, 1, 2, 0 }); 122 public static final OID snmpUnknownPDUHandlers = 123 new OID(new int[] { 1, 3, 6, 1, 6, 3, 11, 2, 1, 3, 0 }); 124 125 public static final OID snmpInPkts = 127 new OID(new int[] { 1,3,6,1,2,1,11,1,0 }); 128 public static final OID snmpInBadVersions = 129 new OID(new int[] { 1,3,6,1,2,1,11,3,0 }); 130 public static final OID snmpInBadCommunityNames = 131 new OID(new int[] { 1,3,6,1,2,1,11,4,0 }); 132 public static final OID snmpInBadCommunityUses = 133 new OID(new int[] { 1,3,6,1,2,1,11,5,0 }); 134 public static final OID snmpInASNParseErrs = 135 new OID(new int[] { 1,3,6,1,2,1,11,6,0 }); 136 public static final OID snmpSilentDrops = 137 new OID(new int[] { 1,3,6,1,2,1,11,31,0 }); 138 public static final OID snmpProxyDrops = 139 new OID(new int[] { 1,3,6,1,2,1,11,32,0 }); 140 141 public static final OID snmpTrapOID = 142 new OID(new int[] { 1,3,6,1,6,3,1,1,4,1,0 }); 143 public static final OID snmpTrapEnterprise = 144 new OID(new int[] { 1,3,6,1,6,3,1,1,4,3,0 }); 145 146 public static final OID snmpTraps = 148 new OID(new int[] { 1,3,6,1,6,3,1,1,5 }); 149 public static final OID coldStart = 151 new OID(new int[] { 1,3,6,1,6,3,1,1,5,1 }); 152 public static final OID warmStart = 153 new OID(new int[] { 1,3,6,1,6,3,1,1,5,2 }); 154 public static final OID authenticationFailure = 155 new OID(new int[] { 1,3,6,1,6,3,1,1,5,5 }); 156 public static final OID linkDown = 157 new OID(new int[] { 1,3,6,1,6,3,1,1,5,3 }); 158 public static final OID linkUp = 159 new OID(new int[] { 1,3,6,1,6,3,1,1,5,4 }); 160 161 public static final OID sysDescr = 163 new OID(new int[] { 1,3,6,1,2,1,1,1,0 }); 164 public static final OID sysObjectID = 165 new OID(new int[] { 1,3,6,1,2,1,1,2,0 }); 166 public static final OID sysUpTime = 167 new OID(new int[] { 1,3,6,1,2,1,1,3,0 }); 168 public static final OID sysContact = 169 new OID(new int[] { 1,3,6,1,2,1,1,4,0 }); 170 public static final OID sysName = 171 new OID(new int[] { 1,3,6,1,2,1,1,5,0 }); 172 public static final OID sysLocation = 173 new OID(new int[] { 1,3,6,1,2,1,1,6,0 }); 174 public static final OID sysServices = 175 new OID(new int[] { 1,3,6,1,2,1,1,7,0 }); 176 public static final OID sysOREntry = 177 new OID(new int[] { 1,3,6,1,2,1,1,9,1 }); 178 179 public static final OID snmpUnavailableContexts = 181 new OID(new int[] { 1,3,6,1,6,3,12,1,4,0 }); 182 public static final OID snmpUnknownContexts = 183 new OID(new int[] { 1,3,6,1,6,3,12,1,5,0 }); 184 185 public static final OID snmpTrapAddress = 187 new OID(new int[] { 1,3,6,1,6,3,18,1,3,0 }); 188 public static final OID snmpTrapCommunity = 189 new OID(new int[] { 1,3,6,1,6,3,18,1,4,0 }); 190 191 public static final OID zeroDotZero = new OID(new int[] { 0,0 }); 192 193 public static final OID snmpSetSerialNo = 195 new OID(new int[] { 1,3,6,1,6,3,1,1,6,1,0 }); 196 197 public static final String [] SNMP_ERROR_MESSAGES = { 198 "Success", 199 "PDU encoding too big", 200 "No such name", 201 "Bad value", 202 "Variable is read-only", 203 "General variable binding error", 204 "No access", 205 "Wrong type", 206 "Request PDU has incorrect length", 207 "Request PDU has wrong encoding", 208 "Wrong value", 209 "Unable to create object", 210 "Inconsistent value", 211 "Resource unavailable", 212 "Commit failed", 213 "Undo failed", 214 "Authorization error", 215 "Not writable", 216 "Inconsistent naming used" 217 }; 218 219 220 228 public static int getGenericTrapID(OID oid) { 229 if ((oid == null) || (oid.size() != snmpTraps.size()+1)) { 230 return -1; 231 } 232 if (oid.leftMostCompare(snmpTraps.size(), snmpTraps) == 0) { 233 return oid.get(oid.size() - 1) - 1; 234 } 235 return -1; 236 } 237 238 public static OID getTrapOID(OID enterprise, int genericID, int specificID) { 239 OID oid; 240 if (genericID != 6) { 241 oid = new OID(snmpTraps); 242 oid.append(genericID+1); 243 } 244 else { 245 oid = new OID(enterprise); 246 oid.append(0); 247 oid.append(specificID); 248 } 249 return oid; 250 } 251 } 252 253 | Popular Tags |