|
SNMP Stack 4_12 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--uk.co.westhawk.snmp.stack.Pdu
This class represents the ASN Pdu object, this is the equivalent of a GetRequest Pdu.
Field Summary | |
protected boolean |
added
|
protected boolean |
answered
|
protected SnmpContextBasisFace |
context
|
protected byte[] |
encodedPacket
|
protected int |
errind
|
protected int |
errstat
|
protected byte |
msg_type
|
protected java.util.Vector |
reqVarbinds
|
protected java.util.Vector |
respVarbinds
|
Constructor Summary | |
Pdu(SnmpContextBasisFace con)
Constructor. |
Method Summary | |
void |
addOid(AsnObjectId oid)
Add an OID (object identifier) to the Pdu. |
void |
addOid(AsnObjectId oid,
AsnObject val)
Add an OID (object identifier) to the Pdu and the value that has to be set. |
void |
addOid(java.lang.String oid)
Add an OID (object identifier) to the Pdu. |
void |
addOid(java.lang.String oid,
AsnObject val)
Add an OID (object identifier) to the Pdu and the value that has to be set. |
void |
addOid(varbind var)
Add an OID (object identifier) to the Pdu. |
protected void |
addToTrans()
Adds the Pdu to its transmitter. |
SnmpContextBasisFace |
getContext()
Returns the context of this pdu. |
int |
getErrorIndex()
Returns the error index. |
int |
getErrorStatus()
Returns the error status as indicated by the error-status field in the reponse pdu. |
java.lang.String |
getErrorStatusString()
Returns the string representation of the error status. |
byte |
getMsgType()
Returns the message type, this will indicate what kind of request we are dealing with. |
int |
getReqId()
Returns the request id of the Pdu. |
varbind[] |
getRequestVarbinds()
Returns a copy of the varbinds used to build the request. |
varbind[] |
getResponseVarbinds()
Returns a copy of the varbinds received in the response. |
boolean |
isTimedOut()
Returns whether or not this Pdu is timed out, i.e. |
protected abstract void |
new_value(int n,
varbind res)
The value of the request is set. |
void |
notifyObservers(java.lang.Object arg)
Notify all observers. |
boolean |
send()
Send the Pdu. |
protected boolean |
send(int error_status,
int error_index)
Send the Pdu. |
boolean |
send(java.lang.String com)
Deprecated. Community name has moved to SnmpContext. Use send(). |
protected boolean |
sendme()
Sends the actual packet and updates the retries. |
protected void |
setErrorIndex(int ind)
Sets the error index, this indicates which of the OIDs went wrong. |
protected void |
setErrorStatus(int err)
Sets the error status, indicating what went wrong. |
protected void |
setErrorStatus(int err,
PduException exc)
Sets the error status and the exception, indicating what went wrong. |
protected void |
setMsgType(byte type)
Sets the message type, this will indicate what kind of request we are dealing with. |
void |
setRetryIntervals(int[] rinterval)
Sets the retry intervals of the Pdu. |
protected abstract void |
tell_them()
The methods notifies all observers. |
java.lang.String |
toString()
Returns the string representation of the Pdu. |
protected java.lang.String |
toString(boolean withRespVars)
Returns the string representation of the Pdu with or without the response varbinds. |
boolean |
waitForSelf()
This method will wait until the answer is received, instead of continue with other stuff. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Vector reqVarbinds
protected java.util.Vector respVarbinds
protected byte[] encodedPacket
protected SnmpContextBasisFace context
protected boolean added
protected byte msg_type
protected int errstat
protected int errind
protected boolean answered
Constructor Detail |
public Pdu(SnmpContextBasisFace con)
con
- The context of the PduSnmpContext
,
SnmpContextv2c
,
SnmpContextv3
Method Detail |
protected abstract void new_value(int n, varbind res)
protected abstract void tell_them()
The Object to the update() method of the Observer will be a varbind, unless an exception occurred. In the case of an exception, that exception will be passed. So watch out casting!
public SnmpContextBasisFace getContext()
public void setRetryIntervals(int[] rinterval)
rinterval
- The interval in msec of each retrypublic boolean send() throws java.io.IOException, PduException
protected boolean send(int error_status, int error_index) throws java.io.IOException, PduException
error_status
- The value of the error_status field.error_index
- The value of the error_index field.send()
protected void addToTrans()
send()
protected boolean sendme()
AbstractSnmpContext.sendPacket(byte[] p)
public boolean send(java.lang.String com) throws java.io.IOException, PduException
com
- The community name of the Pdu in SNMPv1 and SNMPv2c.SnmpContext.setCommunity(java.lang.String)
,
send()
public void addOid(java.lang.String oid)
oid
- The oidaddOid(varbind)
,
varbind
public void addOid(AsnObjectId oid)
oid
- The oidaddOid(varbind)
,
varbind
public void addOid(java.lang.String oid, AsnObject val)
oid
- The oidval
- The valueaddOid(java.lang.String)
,
varbind
public void addOid(AsnObjectId oid, AsnObject val)
Thanks to Eli Bishop (eli@graphesthesia.com) for the suggestion.
oid
- The oidval
- The valueaddOid(java.lang.String)
,
varbind
public void addOid(varbind var)
var
- The varbindaddOid(String)
public varbind[] getRequestVarbinds()
public varbind[] getResponseVarbinds() throws PduException
PduException
- An agent or decoding exception occurred
whilst receiving the response.getErrorStatus()
,
notifyObservers(java.lang.Object)
public int getReqId()
public int getErrorIndex()
getErrorStatus()
public int getErrorStatus()
SnmpConstants.SNMP_ERR_DECODING_EXC
.
SnmpConstants.SNMP_ERR_DECODINGASN_EXC
.
SnmpConstants.SNMP_ERR_DECODINGPKTLNGTH_EXC
.
The actual exception will be passed to your
update(Observable ob, Object arg)
method via the the parameter
arg
.
notifyObservers(java.lang.Object)
,
getResponseVarbinds()
,
SnmpConstants.SNMP_ERR_NOERROR
,
SnmpConstants.SNMP_ERR_DECODING_EXC
,
SnmpConstants.SNMP_ERR_DECODINGASN_EXC
,
SnmpConstants.SNMP_ERR_DECODINGPKTLNGTH_EXC
,
getErrorStatusString()
public java.lang.String getErrorStatusString()
getErrorStatus()
public boolean isTimedOut()
getErrorStatus()
,
SnmpConstants.SNMP_ERR_GENERR
public boolean waitForSelf()
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String toString(boolean withRespVars)
withRespVars
- Include the response varbinds or notpublic byte getMsgType()
protected void setMsgType(byte type)
type
- The message typeprotected void setErrorStatus(int err)
err
- the error statusgetErrorIndex()
,
getErrorStatusString()
,
getErrorStatus()
protected void setErrorStatus(int err, PduException exc)
err
- the error statusexc
- the Pdu Exception that was thrown whilst decodinggetErrorIndex()
,
getErrorStatusString()
,
getErrorStatus()
protected void setErrorIndex(int ind)
ind
- the error indexsetErrorStatus(int)
,
getErrorIndex()
public void notifyObservers(java.lang.Object arg)
In the case of an exception, the error status
will be set to one of the decoding errors (see
getErrorStatus
)
and passed as the parameter
arg
in the
update(Observable obs, Object arg)
method.
notifyObservers
in class java.util.Observable
arg
- The argument passed to update, can be a PduException.SnmpConstants.SNMP_ERR_DECODING_EXC
,
getErrorStatus()
,
getResponseVarbinds()
|
SNMP Stack 4_12 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |