java.net
Class IcmpPacket

java.lang.Object
  |
  +--java.net.RawPacket
        |
        +--java.net.IcmpPacket

public final class IcmpPacket
extends RawPacket

This class represents an ICMP packet.

ICMP packets are used to implement a connectionless ICMP packet delivery service. Each message is routed from one machine to another based solely on information contained within that packet. Multiple packets sent from one machine to another might be routed differently, and might arrive in any order.

Since:
JDK1.2

Constructor Summary
IcmpPacket(byte[] ibuf, int ilength, InetAddress iaddr, int tvalue)
          Constructs an ICMP packet for sending packets of length ilength with the specified type on the specified host.
IcmpPacket(byte[] ibuf, int ilength, InetAddress iaddr, int tvalue, int cvalue)
          Constructs an ICMP packet for sending packets of length ilength with the specified type and code on the specified host.
IcmpPacket(byte[] ibuf, int ilength, int tvalue)
          Constructs an IcmpPacket for receiving packets of length ilength.
IcmpPacket(byte[] ibuf, int ilength, int tvalue, int cvalue)
          Constructs an IcmpPacket for receiving packets of length ilength.
 
Method Summary
 byte getCode()
          Return the ICMP code of the packet.
 byte getType()
          Return the ICMP type of the packet.
 void setType(int value)
          Set the ICMP type of the packet.
 void setType(int tvalue, int cvalue)
          Set the ICMP type and code of the packet.
 
Methods inherited from class java.net.RawPacket
getAddress, getData, getLength, getOffset, setAddress, setData, setData, setLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IcmpPacket

public IcmpPacket(byte[] ibuf,
                  int ilength,
                  int tvalue)
Constructs an IcmpPacket for receiving packets of length ilength.

The length argument must be less than or equal to ibuf.length.

Parameters:
ibuf - buffer for holding the incoming datagram.
ilength - the number of bytes to read.
tvalue - the ICMP type of the packet
Since:
JDK1.2

IcmpPacket

public IcmpPacket(byte[] ibuf,
                  int ilength,
                  int tvalue,
                  int cvalue)
Constructs an IcmpPacket for receiving packets of length ilength.

The length argument must be less than or equal to ibuf.length.

Parameters:
ibuf - buffer for holding the incoming datagram.
ilength - the number of bytes to read.
tvalue - the ICMP type of the packet
cvalue - the ICMP code of the packet
Since:
JDK1.2

IcmpPacket

public IcmpPacket(byte[] ibuf,
                  int ilength,
                  InetAddress iaddr,
                  int tvalue)
Constructs an ICMP packet for sending packets of length ilength with the specified type on the specified host. The length argument must be less than or equal to ibuf.length.
Parameters:
ibuf - the packet data.
ilength - the packet length.
iaddr - the destination address.
tvalue - the type of the packet.
Since:
JDK1.2
See Also:
InetAddress

IcmpPacket

public IcmpPacket(byte[] ibuf,
                  int ilength,
                  InetAddress iaddr,
                  int tvalue,
                  int cvalue)
Constructs an ICMP packet for sending packets of length ilength with the specified type and code on the specified host. The length argument must be less than or equal to ibuf.length.
Parameters:
ibuf - the packet data.
ilength - the packet length.
iaddr - the destination address.
tvalue - the type of the packet.
cvalue - the code of the packet.
Since:
JDK1.2
See Also:
InetAddress
Method Detail

setType

public void setType(int value)
Set the ICMP type of the packet.
Parameters:
value - the type of the packet

getCode

public byte getCode()
Return the ICMP code of the packet.
Returns:
the code of the packet

setType

public void setType(int tvalue,
                    int cvalue)
Set the ICMP type and code of the packet.
Parameters:
tvalue - the type of the packet
cvalue - the code of the packet

getType

public byte getType()
Return the ICMP type of the packet.
Returns:
the type of the packet