com.limegroup.gnutella.routing
Class RouteTableMessage

java.lang.Object
  extended bycom.limegroup.gnutella.messages.Message
      extended bycom.limegroup.gnutella.routing.RouteTableMessage
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
PatchTableMessage, ResetTableMessage

public abstract class RouteTableMessage
extends Message

An abstract class representing all variants of the new ROUTE_TABLE_UPDATE message. Like Message, this has no public constructors. To decode bytes from call the static read(..) method. To create a new message from scratch, call one of its subclass' constructors.

See Also:
Serialized Form

Field Summary
static byte PATCH_VARIANT
           
static byte RESET_VARIANT
           
 
Fields inherited from class com.limegroup.gnutella.messages.Message
F_PING, F_PING_REPLY, F_PUSH, F_QUERY, F_QUERY_REPLY, F_ROUTE_TABLE_UPDATE, F_VENDOR_MESSAGE, F_VENDOR_MESSAGE_STABLE, N_MULTICAST, N_TCP, N_UDP, N_UNKNOWN, RECORD_STATS, SOFT_MAX
 
Constructor Summary
protected RouteTableMessage(byte[] guid, byte ttl, byte hops, int length, byte variant)
           
protected RouteTableMessage(byte ttl, int length, byte variant)
          Creates a new RouteTableMessage from scratch.
 
Method Summary
 byte getVariant()
          Returns the variant of this, i.e.
static RouteTableMessage read(byte[] guid, byte ttl, byte hops, byte[] payload)
          Creates a new RouteTableMessage from raw bytes read from the network.
 Message stripExtendedPayload()
          Returns this.
protected  void writePayload(java.io.OutputStream out)
           
protected abstract  void writePayloadData(java.io.OutputStream out)
           
 
Methods inherited from class com.limegroup.gnutella.messages.Message
compareTo, getCreationTime, getFunc, getGUID, getHops, getLength, getNetwork, getPriority, getTotalLength, getTTL, hop, isMulticast, isTCP, isUDP, isUnknownNetwork, makeGuid, read, read, read, read, read, readNullTerminatedBytes, recordDrop, repOk, setGUID, setHops, setPriority, setTTL, toString, updateLength, write, writeGemExtension, writeGemExtension, writeGemExtensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESET_VARIANT

public static final byte RESET_VARIANT
See Also:
Constant Field Values

PATCH_VARIANT

public static final byte PATCH_VARIANT
See Also:
Constant Field Values
Constructor Detail

RouteTableMessage

protected RouteTableMessage(byte ttl,
                            int length,
                            byte variant)
Creates a new RouteTableMessage from scratch.


RouteTableMessage

protected RouteTableMessage(byte[] guid,
                            byte ttl,
                            byte hops,
                            int length,
                            byte variant)
Method Detail

writePayload

protected void writePayload(java.io.OutputStream out)
                     throws java.io.IOException
Specified by:
writePayload in class Message
Throws:
java.io.IOException

writePayloadData

protected abstract void writePayloadData(java.io.OutputStream out)
                                  throws java.io.IOException
Throws:
java.io.IOException

read

public static RouteTableMessage read(byte[] guid,
                                     byte ttl,
                                     byte hops,
                                     byte[] payload)
                              throws BadPacketException
Creates a new RouteTableMessage from raw bytes read from the network. The returned value is a subclass of RouteTableMessage depending on the variant in the payload. (That's why there is no corresponding constructor in this.)

Throws:
BadPacketException - the payload is not well-formatted

getVariant

public byte getVariant()
Returns the variant of this, i.e. one of RESET_VARIANT, or PATCH_VARIANT.


stripExtendedPayload

public Message stripExtendedPayload()
Returns this.

Specified by:
stripExtendedPayload in class Message
Returns:
an instance of this without any dangerous extended payload