SourceForge Jpcap

net.sourceforge.jpcap.net
Class IGMPPacket

java.lang.Object
  extended by net.sourceforge.jpcap.net.Packet
      extended by net.sourceforge.jpcap.net.EthernetPacket
          extended by net.sourceforge.jpcap.net.IP.Packet
              extended by net.sourceforge.jpcap.net.IPv4.Packet
                  extended by net.sourceforge.jpcap.net.IPPacket
                      extended by net.sourceforge.jpcap.net.IGMPPacket
All Implemented Interfaces:
Serializable, EthernetFields, IGMPFields, IPFields, IPv4.IGMP

public class IGMPPacket
extends IPPacket
implements IGMPFields, IPv4.IGMP

An IGMP packet.

Extends an IP packet, adding an IGMP header and IGMP data payload.

Version:
$Revision: 1.1 $
Author:
Patrick Charles, Jonas Lehmann, Esmond Pitt
See Also:
Serialized Form
Last modified by:
$Author: esmondpitt $
Last modified at:
$Date: 2008/08/21 02:58:20 $

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.jpcap.net.IPPacket
IPPacket.TestProbe
 
Field Summary
 
Fields inherited from class net.sourceforge.jpcap.net.IP.Packet
_ipHeaderLength, _ipOffset
 
Fields inherited from class net.sourceforge.jpcap.net.EthernetPacket
_byteBuffer, _bytes, _ethOffset, _timeval
 
Fields inherited from interface net.sourceforge.jpcap.net.IGMPFields
IGMP_CODE_LEN, IGMP_CODE_POS, IGMP_CSUM_LEN, IGMP_CSUM_POS, IGMP_GADDR_LEN, IGMP_GADDR_POS, IGMP_HEADER_LEN, IGMP_MRSP_LEN, IGMP_MRSP_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.IPFields
IP_CODE_LEN, IP_CODE_POS, IP_CSUM_LEN, IP_CSUM_POS, IP_DST_POS, IP_FRAG_LEN, IP_FRAG_POS, IP_HEADER_LEN, IP_ID_LEN, IP_ID_POS, IP_LEN_LEN, IP_LEN_POS, IP_SRC_POS, IP_TOS_LEN, IP_TOS_POS, IP_TTL_LEN, IP_TTL_POS, IP_VER_LEN, IP_VER_POS
 
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
IGMPPacket(int lLen, byte[] bytes)
          Construct a new IGMP packet.
IGMPPacket(int lLen, byte[] bytes, Timeval tv)
          Construct a new IGMP packet, including the capture time.
IGMPPacket(int lLen, ByteBuffer bb, Timeval tv)
          Construct a new IGMP packet, including the capture time.
 
Method Summary
 int getChecksum()
          Return the actual packet checksum as received. Derived classes override this to return the most specific checksum, e.g.: The implementation in Packet.getChecksum() returns zero.
 String getColor()
          Fetch ASCII escape sequence of the color associated with this packet type.
 byte[] getData()
          Fetch the data portion of the packet. This is overridden in derived classes to return successively smaller and smaller amounts of data. For example:
  • EthernetPacket.getData() returns the entire Ethernet payload excluding the Ethernet header
  • IP.Packet.getData() only returns the IP payload, i.e. excluding the IP header which is in the Ethernet payload
  • TCPPacket.getData() only returns the TCP payload, i.e. excluding the TCP header which is in the IP payload
 String getGroupAddress()
          Deprecated. Please use getGroupInetAddress().
 InetAddress getGroupInetAddress()
          Fetch the IGMP group address.
 byte[] getHeader()
          Fetch header portion of the packet. This is overridden in derived classes to return the header appropriate to the packet class. For example:
 int getIGMPChecksum()
          Fetch the IGMP checksum.
 byte[] getIGMPData()
          Fetch the IGMP data as a byte array.
 byte[] getIGMPHeader()
          Fetch the IGMP header as a byte array.
 int getMaxResponseTime()
          Fetch the IGMP max response time.
 int getMessageType()
          Fetch the IGMP message type.
 boolean isValidChecksum()
          Return true iff all the checksums in the packet are valid, otherwise false. Derived classes with checksums should override, and should call super.isValidChecksum() to check the validity of base class checksums. The Packet.isValidChecksum() implementation just returns true.
 void setChecksums()
          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.

 void setGroupInetAddress(InetAddress address)
          Set the IGMP group address.
 void setMaxResponseTime(byte time)
          Set the IGMP max response time.
 void setMessageType(byte type)
          Set the IGMP message type, as per IPv4.IGMP.getMessageType().
 String toColoredString(boolean colored)
          Generate string with contents describing this packet.
 
Methods inherited from class net.sourceforge.jpcap.net.IPPacket
getDestinationAddress, getDestinationAddressAsLong, getDestinationAddressBytes, getIpHeaderLength, getSourceAddress, getSourceAddressAsLong, getSourceAddressBytes, onesCompSum
 
Methods inherited from class net.sourceforge.jpcap.net.IPv4.Packet
computeReceiverChecksum, computeReceiverIPChecksum, computeSenderChecksum, computeSenderIPChecksum, getDestinationInetAddress, getFragmentFlags, getFragmentOffset, getId, getIPChecksum, getIPData, getIPHeader, getIPHeaderLength, getIPProtocol, getLength, getProtocol, getSourceInetAddress, getTimeToLive, getTypeOfService, getVersion, isValidIPChecksum, setDestinationInetAddress, setSourceInetAddress, toColoredVerboseString
 
Methods inherited from class net.sourceforge.jpcap.net.IP.Packet
getHeaderLength
 
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket
equals, getDestinationHwAddress, getDestinationMACAddress, getEthernetCRC32, getEthernetData, getEthernetHeader, getEthernetHeaderLength, getEthernetProtocol, getPacketData, getPacketLength, getSourceHwAddress, getSourceMACAddress, getTimeval, hashCode, setDestinationMACAddress, setEthernetProtocol, setSourceMACAddress, toByteArray, toString
 
Methods inherited from class net.sourceforge.jpcap.net.Packet
ipChecksum
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IGMPPacket

public IGMPPacket(int lLen,
                  byte[] bytes)
Construct a new IGMP packet.

Parameters:
lLen - link-layer header length
bytes - Packet data

IGMPPacket

public IGMPPacket(int lLen,
                  byte[] bytes,
                  Timeval tv)
Construct a new IGMP packet, including the capture time.

Parameters:
lLen - link-layer header length
bytes - Packet data
tv - Timestamp

IGMPPacket

public IGMPPacket(int lLen,
                  ByteBuffer bb,
                  Timeval tv)
Construct a new IGMP packet, including the capture time.

Parameters:
lLen - link-layer header length
bb - Packet data in a ByteBuffer
tv - Timestamp
Since:
2.0.0
Method Detail

getIGMPHeader

public byte[] getIGMPHeader()
Description copied from interface: IPv4.IGMP
Fetch the IGMP header as a byte array.

Specified by:
getIGMPHeader in interface IPv4.IGMP
Returns:
the IGMP header as a byte array.

getHeader

public byte[] getHeader()
Fetch header portion of the packet. This is overridden in derived classes to return the header appropriate to the packet class. For example:

Overrides:
getHeader in class IP.Packet

getIGMPData

public byte[] getIGMPData()
Description copied from interface: IPv4.IGMP
Fetch the IGMP data as a byte array.

Specified by:
getIGMPData in interface IPv4.IGMP
Returns:
the IGMP data as a byte array.

getData

public byte[] getData()
Fetch the data portion of the packet. This is overridden in derived classes to return successively smaller and smaller amounts of data. For example:

Overrides:
getData in class IP.Packet

getMessageType

public int getMessageType()
Description copied from interface: IPv4.IGMP
Fetch the IGMP message type. Return value can be used with IGMPMessage.getDescription(int).

Specified by:
getMessageType in interface IPv4.IGMP
Returns:
a 1-byte value containing the message type.

setMessageType

public void setMessageType(byte type)
Description copied from interface: IPv4.IGMP
Set the IGMP message type, as per IPv4.IGMP.getMessageType().

Specified by:
setMessageType in interface IPv4.IGMP
Parameters:
type - message type.
See Also:
IGMPMessages

getMaxResponseTime

public int getMaxResponseTime()
Description copied from interface: IPv4.IGMP
Fetch the IGMP max response time.

Specified by:
getMaxResponseTime in interface IPv4.IGMP
Returns:
the IGMP max response time, in tenths of a second.

setMaxResponseTime

public void setMaxResponseTime(byte time)
Description copied from interface: IPv4.IGMP
Set the IGMP max response time.

Specified by:
setMaxResponseTime in interface IPv4.IGMP
Parameters:
time - the IGMP max response time, in tenths of a second.

getIGMPChecksum

public int getIGMPChecksum()
Description copied from interface: IPv4.IGMP
Fetch the IGMP checksum.

Specified by:
getIGMPChecksum in interface IPv4.IGMP
Returns:
the IGMP checksum.

getChecksum

public int getChecksum()
Return the actual packet checksum as received. Derived classes override this to return the most specific checksum, e.g.: The implementation in Packet.getChecksum() returns zero.

Overrides:
getChecksum in class IPv4.Packet

getGroupAddress

@Deprecated
public String getGroupAddress()
Deprecated. Please use getGroupInetAddress().

Fetch the IGMP group address.

Returns:
the IGMP group address.

getGroupInetAddress

public InetAddress getGroupInetAddress()
Description copied from interface: IPv4.IGMP
Fetch the IGMP group address.

Specified by:
getGroupInetAddress in interface IPv4.IGMP
Returns:
the IGMP group address.

setGroupInetAddress

public void setGroupInetAddress(InetAddress address)
Description copied from interface: IPv4.IGMP
Set the IGMP group address.

Specified by:
setGroupInetAddress in interface IPv4.IGMP
Parameters:
address - Group address.

isValidChecksum

public boolean isValidChecksum()
Return true iff all the checksums in the packet are valid, otherwise false. Derived classes with checksums should override, and should call super.isValidChecksum() to check the validity of base class checksums. The Packet.isValidChecksum() implementation just returns true.

Overrides:
isValidChecksum in class IPv4.Packet
Returns:
true iff all the checksums in the packet are valid.

setChecksums

public void setChecksums()
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 IPv4.Packet

toColoredString

public String toColoredString(boolean colored)
Generate string with contents describing this packet.

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

getColor

public String getColor()
Fetch ASCII escape sequence of the color associated with this packet type.

Overrides:
getColor in class IP.Packet
Returns:
ASCII escape sequence string

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