j_waste.network
Class PingPacket

java.lang.Object
  extended byj_waste.network.Packet
      extended byj_waste.network.HeadedPacket
          extended byj_waste.network.PingPacket
All Implemented Interfaces:
NetworkConstants

public class PingPacket
extends HeadedPacket
implements NetworkConstants

This class represents a Ping packet.

Version:
0.1
Author:
Mattias Ek (matek@users.sourceforge.net)

Field Summary
 
Fields inherited from class j_waste.network.HeadedPacket
iscomplete, packetData, padBytes
 
Fields inherited from class j_waste.network.Packet
packet
 
Fields inherited from interface j_waste.network.NetworkConstants
ABORT, CAP_BANDWIDTH, CAP_REMOTE_IP, CAP_SATURATION, GENERAL_TYPE_BROADCAST, GENERAL_TYPE_LOCAL, GENERAL_TYPE_ROUTED, HEADER_SIZE, MAX_BROADCAST_SIZE, MAX_ROUTED_SIZE, NO_ABORT, PREMATURE_ABORT, PRIO_CHAT, PRIO_CHAT_REPLY, PRIO_FILE_REQ_REPLY, PRIO_FILE_REQUEST, PRIO_KEYDIST, PRIO_KEYDIST_REPLY, PRIO_LCAPS, PRIO_LOCAL_SATURATE, PRIO_PING, PRIO_SEARCH, PRIO_SEARCH_REPLY, PRIO_SEARCH_USERLIST, PRIO_UPLOAD, TYPE_CHAT, TYPE_CHAT_REPLY, TYPE_FILE_REQ_REPLY, TYPE_FILE_REQUEST, TYPE_KEYDIST, TYPE_KEYDIST_REPLY, TYPE_LCAPS, TYPE_LOCAL_SATURATE, TYPE_PING, TYPE_SEARCH, TYPE_SEARCH_REPLY, TYPE_SEARCH_USERLIST, TYPE_UPLOAD
 
Constructor Summary
PingPacket()
          Main constructor.
PingPacket(byte[] pkg)
          Creates a new PingPacket from a byte array.
PingPacket(byte[] guid, java.lang.String debug_only)
          Creates a new PingPacket.
PingPacket(java.net.InetAddress ia, short p, java.lang.String s)
          Alternative constructor.
 
Method Summary
 void finalizePacket()
          Finalize this PingPacket.
 java.net.InetAddress getIP()
          Returns the IP number.
 int getPort()
          Returns the port number.
 java.lang.String getSender()
          Returns the sender of this packet.
 void setIP(java.net.InetAddress ip)
          Sets the IP number.
 void setPort(short port)
          Sets the port.
 void setSender(java.lang.String sender)
          Sets the sender of this packet.
 byte[] toByteArray()
          Returns a byte array representation of this PingPacket.
 
Methods inherited from class j_waste.network.HeadedPacket
createPacket, getData, getGeneralType, getGUID, getHeader, getIntPrio, getIntType, getLength, getMD5, getPrio, getTTL, getType, setLength, setTTL
 
Methods inherited from class j_waste.network.Packet
padCD, reverseBytes, reverseInt, reverseShort, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PingPacket

public PingPacket()
Main constructor.


PingPacket

public PingPacket(java.net.InetAddress ia,
                  short p,
                  java.lang.String s)
Alternative constructor.

Parameters:
ia - an InetAddress.
p - a port number.
s - a sender.

PingPacket

public PingPacket(byte[] guid,
                  java.lang.String debug_only)
Creates a new PingPacket. For debug use only.

Parameters:
guid - a GUID.
debug_only - a string to indicate debug use.

PingPacket

public PingPacket(byte[] pkg)
           throws InvalidPacketException
Creates a new PingPacket from a byte array.

Parameters:
pkg - a byte array containing the raw data (header + payload) for the packet.
Method Detail

setSender

public void setSender(java.lang.String sender)
Sets the sender of this packet.

Parameters:
sender - A string containing the nickname of the sender of the packet.

getSender

public java.lang.String getSender()
Returns the sender of this packet.

Returns:
The sender of this packet.

setIP

public void setIP(java.net.InetAddress ip)
Sets the IP number.

Parameters:
ip - The IP number.

getIP

public java.net.InetAddress getIP()
Returns the IP number.

Returns:
The IP number.

setPort

public void setPort(short port)
Sets the port.

Parameters:
port - The port.

getPort

public int getPort()
Returns the port number.

Returns:
The port number.

toByteArray

public byte[] toByteArray()
Returns a byte array representation of this PingPacket.

Overrides:
toByteArray in class HeadedPacket
Returns:
a byte array with this PingPacket.

finalizePacket

public void finalizePacket()
Finalize this PingPacket.

Overrides:
finalizePacket in class HeadedPacket