SourceForge Jpcap

net.sourceforge.jpcap.net
Class CDP.Packet

java.lang.Object
  extended by net.sourceforge.jpcap.net.Packet
      extended by net.sourceforge.jpcap.net.EthernetPacket
          extended by net.sourceforge.jpcap.net.CDP.Packet
All Implemented Interfaces:
Serializable, EthernetFields
Enclosing interface:
CDP

public static class CDP.Packet
extends EthernetPacket

CDP Packet class.

Since:
2.0.0
Version:
$Revision: 1.1 $
Author:
Esmond Pitt
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.jpcap.net.EthernetPacket
_byteBuffer, _bytes, _ethOffset, _timeval
 
Fields inherited from interface net.sourceforge.jpcap.net.EthernetFields
ETH_CODE_LEN, ETH_CODE_POS, ETH_DST_POS, ETH_HEADER_LEN, ETH_SRC_POS
 
Constructor Summary
CDP.Packet(int lLen, byte[] bytes)
          Creates a new CDP packet
CDP.Packet(int lLen, byte[] bytes, Timeval tv)
          Create a new CDP packet.
CDP.Packet(int lLen, ByteBuffer bb, Timeval tv)
          Create a new CDP packet.
 
Method Summary
 int getCDPChecksum()
           
 byte[] getCDPData()
           
 int getCDPTimeToLive()
           
 int getCDPVersion()
           
 void setCDPData(byte[] data)
          Set the CDP data payload.
 void setCDPTimeToLive(int ttl)
          Set the CDP time-to-live (TTL)
 void setCDPVersion(int version)
          Set the CDP protocol version
 void setChecksums()
          Set all the checksums in this packet prior to sending.
 String toColoredString(boolean colored)
          Generate string with contents describing this packet.
 
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket
equals, getColor, getData, getDestinationHwAddress, getDestinationMACAddress, getEthernetCRC32, getEthernetData, getEthernetHeader, getEthernetHeaderLength, getEthernetProtocol, getHeader, getHeaderLength, getPacketData, getPacketLength, getProtocol, getSourceHwAddress, getSourceMACAddress, getTimeval, hashCode, setDestinationMACAddress, setEthernetProtocol, setSourceMACAddress, toByteArray, toString
 
Methods inherited from class net.sourceforge.jpcap.net.Packet
getChecksum, ipChecksum, isValidChecksum
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CDP.Packet

public CDP.Packet(int lLen,
                  byte[] bytes)
Creates a new CDP packet


CDP.Packet

public CDP.Packet(int lLen,
                  byte[] bytes,
                  Timeval tv)
Create a new CDP packet.


CDP.Packet

public CDP.Packet(int lLen,
                  ByteBuffer bb,
                  Timeval tv)
Create a new CDP packet.

Parameters:
lLen - Packet length
bb - Packet bytes in a ByteBuffer
tv - TimeValue
Method Detail

getCDPVersion

public int getCDPVersion()
Returns:
the CDP protocol version.

setCDPVersion

public void setCDPVersion(int version)
Set the CDP protocol version

Parameters:
version - CDP protocol version

getCDPChecksum

public int getCDPChecksum()
Returns:
the CDP checksum.

getCDPTimeToLive

public int getCDPTimeToLive()
Returns:
the CDP time-to-live.

setCDPTimeToLive

public void setCDPTimeToLive(int ttl)
Set the CDP time-to-live (TTL)

Parameters:
ttl - CDP time-to-live

setChecksums

public void setChecksums()
Description copied from class: EthernetPacket
Set all the checksums in this packet prior to sending. Calling this method sets all the IP, ICMP, IGMP, TCP, UDP etc checksums as appropriate. It is called automatically by PacketOutputStream.writePacket(Packet). Derived classes must override this abstract method, and must call super.setChecksums(), after setting their own checksums (unless super.setChecksums() is abstract, i.e. this method). Otherwise the lower-level checksums will not be correct.

After calling this method the EthernetPacket.hashCode() of this object will probably change.

Overrides:
setChecksums in class EthernetPacket

getCDPData

public byte[] getCDPData()
Returns:
a copy of the CDP data, which is a series of MIBs in the format type:length:value, where 'type' and 'length' are two bytes each and 'length' includes the length of 'type' and 'length': as the data is a copy, changing it has no effect on the CDP packet object.

setCDPData

public void setCDPData(byte[] data)
Set the CDP data payload.

Parameters:
data - Payload data.

toColoredString

public String toColoredString(boolean colored)
Description copied from class: EthernetPacket
Generate string with contents describing this packet.

Overrides:
toColoredString in class EthernetPacket
Parameters:
colored - whether or not the string should contain ansi color escape sequences.

Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008.