com.limegroup.gnutella.messages.vendor
Class VendorMessage

java.lang.Object
  extended bycom.limegroup.gnutella.messages.Message
      extended bycom.limegroup.gnutella.messages.vendor.VendorMessage
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
HopsFlowVendorMessage, LimeACKVendorMessage, MessagesSupportedVendorMessage, PushProxyAcknowledgement, PushProxyRequest, QueryStatusRequest, QueryStatusResponse, ReplyNumberVendorMessage, TCPConnectBackVendorMessage, UDPConnectBackVendorMessage

public abstract class VendorMessage
extends Message

Vendor Messages are Gnutella Messages that are NEVER forwarded after recieved. This message is abstract because it provides common methods for ALL VendorMessages, but it makes no sense to instantiate a VendorMessage.

See Also:
Serialized Form

Field Summary
protected static byte[] F_BEAR_VENDOR_ID
           
protected static byte[] F_GTKG_VENDOR_ID
           
protected static int F_HOPS_FLOW
           
protected static int F_LIME_ACK
           
protected static byte[] F_LIME_VENDOR_ID
           
protected static int F_MESSAGES_SUPPORTED
           
protected static byte[] F_NULL_VENDOR_ID
           
protected static int F_PUSH_PROXY_ACK
           
protected static int F_PUSH_PROXY_REQ
           
protected static int F_REPLY_NUMBER
           
protected static int F_TCP_CONNECT_BACK
           
protected static int F_UDP_CONNECT_BACK
           
 
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 VendorMessage(byte[] guid, byte ttl, byte hops, byte[] vendorID, int selector, int version, byte[] payload)
          Should be used when encountered a Message from the Network.
protected VendorMessage(byte[] vendorIDBytes, int selector, int version, byte[] payload)
          Package Level access only.
 
Method Summary
static VendorMessage deriveVendorMessage(byte[] guid, byte ttl, byte hops, byte[] fromNetwork)
           
 boolean equals(java.lang.Object other)
           
protected  byte[] getPayload()
          Allows subclasses to make changes gain access to the payload.
protected  int getVersion()
           
 int hashCode()
           
 void recordDrop()
          Records the dropping of this message in statistics.
 Message stripExtendedPayload()
          Returns a message identical to this but without any extended (typically GGEP) data.
protected  void writePayload(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, repOk, setGUID, setHops, setPriority, setTTL, toString, updateLength, write, writeGemExtension, writeGemExtension, writeGemExtensions
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

F_MESSAGES_SUPPORTED

protected static final int F_MESSAGES_SUPPORTED
See Also:
Constant Field Values

F_HOPS_FLOW

protected static final int F_HOPS_FLOW
See Also:
Constant Field Values

F_TCP_CONNECT_BACK

protected static final int F_TCP_CONNECT_BACK
See Also:
Constant Field Values

F_UDP_CONNECT_BACK

protected static final int F_UDP_CONNECT_BACK
See Also:
Constant Field Values

F_LIME_ACK

protected static final int F_LIME_ACK
See Also:
Constant Field Values

F_REPLY_NUMBER

protected static final int F_REPLY_NUMBER
See Also:
Constant Field Values

F_PUSH_PROXY_REQ

protected static final int F_PUSH_PROXY_REQ
See Also:
Constant Field Values

F_PUSH_PROXY_ACK

protected static final int F_PUSH_PROXY_ACK
See Also:
Constant Field Values

F_LIME_VENDOR_ID

protected static final byte[] F_LIME_VENDOR_ID

F_BEAR_VENDOR_ID

protected static final byte[] F_BEAR_VENDOR_ID

F_GTKG_VENDOR_ID

protected static final byte[] F_GTKG_VENDOR_ID

F_NULL_VENDOR_ID

protected static final byte[] F_NULL_VENDOR_ID
Constructor Detail

VendorMessage

protected VendorMessage(byte[] vendorIDBytes,
                        int selector,
                        int version,
                        byte[] payload)
                 throws BadPacketException
Package Level access only. Used by specific vendor-message to construct a Vendor Message.

Parameters:
vendorIDBytes - The Vendor ID of this message (bytes).
selector - The selector of the message.
version - The version of this message.
payload - The payload (not including vendorIDBytes, selector, and version.
Throws:
BadPacketException - Thrown if vendorIDBytes, selector, or version is 'too big'.
java.lang.NullPointerException - Thrown if payload or vendorIDBytes are null.

VendorMessage

protected VendorMessage(byte[] guid,
                        byte ttl,
                        byte hops,
                        byte[] vendorID,
                        int selector,
                        int version,
                        byte[] payload)
                 throws BadPacketException
Should be used when encountered a Message from the Network. Primarily built for the convenience of the class Message. Subclasses should call this first (well, they have to), then they can use getPayload() to parse the payload and do anything they need to.

Method Detail

getPayload

protected byte[] getPayload()
Allows subclasses to make changes gain access to the payload. They can: 1) change the contents 2) parse the contents. In general, 1) is discouraged, 2) is necessary. Subclasses CANNOT re-init the payload.


getVersion

protected int getVersion()

deriveVendorMessage

public static VendorMessage deriveVendorMessage(byte[] guid,
                                                byte ttl,
                                                byte hops,
                                                byte[] fromNetwork)
                                         throws BadPacketException
Throws:
BadPacketException

equals

public boolean equals(java.lang.Object other)
Returns:
true if the two VMPs have identical signatures - no more, no less. Does not take version into account, but if different versions have different payloads, they'll differ.

hashCode

public int hashCode()

writePayload

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

stripExtendedPayload

public Message stripExtendedPayload()
Description copied from class: Message
Returns a message identical to this but without any extended (typically GGEP) data. Since Message's are mostly immutable, the returned message may alias parts of this; in fact the returned message could even be this. The caveat is that the hops and TTL field of Message can be mutated for efficiency reasons. Hence you must not call hop() on either this or the returned value. Typically this is not a problem, as hop() is called before forwarding/broadcasting a message.

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

recordDrop

public void recordDrop()
Description copied from class: Message
Records the dropping of this message in statistics.

Specified by:
recordDrop in class Message