1 20 21 package org.snmp4j.mp; 22 23 import java.util.*; 24 25 import org.snmp4j.*; 26 import org.snmp4j.security.*; 27 import org.snmp4j.smi.*; 28 import java.io.Serializable ; 29 30 31 39 public class StateReference implements Serializable { 40 41 private static final long serialVersionUID = 7385215386971310699L; 42 43 private Address address; 44 private transient TransportMapping transportMapping; 45 private byte[] contextEngineID; 46 private byte[] contextName; 47 private SecurityModel securityModel; 48 private byte[] securityName; 49 private int securityLevel; 50 private SecurityStateReference securityStateReference; 51 private int msgID; 52 private int maxSizeResponseScopedPDU; 53 private int msgFlags; 54 private PduHandle pduHandle; 55 private byte[] securityEngineID; 56 private int errorCode = 0; 57 58 61 public StateReference() { 62 } 63 64 77 public StateReference(PduHandle pduHandle, 78 Address peerAddress, 79 TransportMapping peerTransport, 80 SecurityModel secModel, 81 byte[] secName, 82 int errorCode) { 83 this(0, 0, 65535, pduHandle, peerAddress, peerTransport, 84 null, secModel, secName, 85 SecurityLevel.NOAUTH_NOPRIV, null, null, null, errorCode); 86 } 87 88 107 public StateReference(int msgID, 108 int msgFlags, 109 int maxSizeResponseScopedPDU, 110 PduHandle pduHandle, 111 Address peerAddress, 112 TransportMapping peerTransport, 113 byte[] secEngineID, 114 SecurityModel secModel, 115 byte[] secName, 116 int secLevel, 117 byte[] contextEngineID, 118 byte[] contextName, 119 SecurityStateReference secStateReference, 120 int errorCode) { 121 this.msgID = msgID; 122 this.msgFlags = msgFlags; 123 this.maxSizeResponseScopedPDU = maxSizeResponseScopedPDU; 124 this.pduHandle = pduHandle; 125 this.address = peerAddress; 126 this.transportMapping = peerTransport; 127 this.securityEngineID = secEngineID; 128 this.securityModel = secModel; 129 this.securityName = secName; 130 this.securityLevel = secLevel; 131 this.contextEngineID = contextEngineID; 132 this.contextName = contextName; 133 this.securityStateReference = secStateReference; 134 this.errorCode = errorCode; 135 } 136 137 public boolean isReportable() { 138 return ((msgFlags & 0x04) > 0); 139 } 140 141 public Address getAddress() { 142 return address; 143 } 144 public void setAddress(org.snmp4j.smi.Address address) { 145 this.address = address; 146 } 147 public void setContextEngineID(byte[] contextEngineID) { 148 this.contextEngineID = contextEngineID; 149 } 150 public byte[] getContextEngineID() { 151 return contextEngineID; 152 } 153 public void setContextName(byte[] contextName) { 154 this.contextName = contextName; 155 } 156 public byte[] getContextName() { 157 return contextName; 158 } 159 public void setSecurityModel(SecurityModel securityModel) { 160 this.securityModel = securityModel; 161 } 162 public SecurityModel getSecurityModel() { 163 return securityModel; 164 } 165 public void setSecurityName(byte[] securityName) { 166 this.securityName = securityName; 167 } 168 public byte[] getSecurityName() { 169 return securityName; 170 } 171 public void setSecurityLevel(int securityLevel) { 172 this.securityLevel = securityLevel; 173 } 174 public int getSecurityLevel() { 175 return securityLevel; 176 } 177 public void setSecurityStateReference(SecurityStateReference securityStateReference) { 178 this.securityStateReference = securityStateReference; 179 } 180 public SecurityStateReference getSecurityStateReference() { 181 return securityStateReference; 182 } 183 public void setMsgID(int msgID) { 184 this.msgID = msgID; 185 } 186 public int getMsgID() { 187 return msgID; 188 } 189 public void setMsgFlags(int msgFlags) { 190 this.msgFlags = msgFlags; 191 } 192 public int getMsgFlags() { 193 return msgFlags; 194 } 195 public void setMaxSizeResponseScopedPDU(int maxSizeResponseScopedPDU) { 196 this.maxSizeResponseScopedPDU = maxSizeResponseScopedPDU; 197 } 198 public int getMaxSizeResponseScopedPDU() { 199 return maxSizeResponseScopedPDU; 200 } 201 public PduHandle getPduHandle() { 202 return pduHandle; 203 } 204 205 public byte[] getSecurityEngineID() { 206 return securityEngineID; 207 } 208 209 public int getErrorCode() { 210 return errorCode; 211 } 212 213 public TransportMapping getTransportMapping() { 214 return transportMapping; 215 } 216 217 public void setPduHandle(PduHandle pduHandle) { 218 this.pduHandle = pduHandle; 219 } 220 221 public void setSecurityEngineID(byte[] securityEngineID) { 222 this.securityEngineID = securityEngineID; 223 } 224 225 public void setErrorCode(int errorCode) { 226 this.errorCode = errorCode; 227 } 228 229 public void setTransportMapping(TransportMapping transportMapping) { 230 this.transportMapping = transportMapping; 231 } 232 233 public boolean equals(Object o) { 234 if (o instanceof StateReference) { 235 StateReference other = (StateReference) o; 236 return ((msgID == other.msgID) && 237 ((pduHandle == null) && (other.pduHandle == null)) || 238 (pduHandle != null) && (pduHandle.equals(other.getPduHandle())) && 239 (Arrays.equals(securityEngineID, other.securityEngineID)) && 240 (securityModel.equals(other.securityModel)) && 241 (Arrays.equals(securityName, other.securityName)) && 242 (securityLevel == other.securityLevel) && 243 (Arrays.equals(contextEngineID, other.contextEngineID)) && 244 (Arrays.equals(contextName, other.contextName))); 245 } 246 return false; 247 } 248 249 public int hashCode() { 250 return msgID; 251 } 252 253 public String toString() { 254 return "StateReference[msgID="+msgID+",pduHandle="+pduHandle+ 255 ",securityEngineID="+OctetString.fromByteArray(securityEngineID)+ 256 ",securityModel="+securityModel+ 257 ",securityName="+OctetString.fromByteArray(securityName)+ 258 ",securityLevel="+securityLevel+ 259 ",contextEngineID="+OctetString.fromByteArray(contextEngineID)+ 260 ",contextName="+OctetString.fromByteArray(contextName)+"]"; 261 } 262 } 263 | Popular Tags |