|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.messages.Message
com.limegroup.gnutella.messages.PingReply
A ping reply message, aka, "pong". This implementation provides a way to "mark" pongs as being from supernodes.
Field Summary | |
static int |
STANDARD_PAYLOAD_SIZE
Constant for the standard size of the pong payload. |
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 |
Method Summary | |
static PingReply |
create(byte[] guid,
byte ttl)
Creates a new PingReply for this host with the specified GUID and ttl. |
static PingReply |
create(byte[] guid,
byte ttl,
int port,
byte[] address)
Creates a new PingReply for an external node -- the data in the reply will not contain data for this node. |
static PingReply |
create(byte[] guid,
byte ttl,
int port,
byte[] ip,
long files,
long kbytes)
Creates a new pong with the specified data -- used primarily for testing! |
static PingReply |
create(byte[] guid,
byte ttl,
int port,
byte[] ip,
long files,
long kbytes,
boolean isUltrapeer,
int dailyUptime,
boolean isGUESSCapable)
Creates a new ping from scratch with ultrapeer and daily uptime extension data. |
static PingReply |
createExternal(byte[] guid,
byte ttl,
int port,
byte[] address,
boolean ultrapeer)
Creates a new PingReply for an external node -- the data in the reply will not contain data for this node. |
static PingReply |
createExternal(byte[] guid,
byte ttl,
int port,
byte[] address,
int uptime,
boolean ultrapeer)
Creates a new PingReply for an external node -- the data in the reply will not contain data for this node. |
static PingReply |
createFromNetwork(byte[] guid,
byte ttl,
byte hops,
byte[] payload)
Creates a new PingReply instance from the network. |
static PingReply |
createGUESSReply(byte[] guid,
byte ttl,
Endpoint ep)
Creates a new PingReply instance for a GUESS node. |
static PingReply |
createGUESSReply(byte[] guid,
byte ttl,
int port,
byte[] address)
Creates a new PingReply instance for a GUESS node. |
static PingReply |
createQueryKeyReply(byte[] guid,
byte ttl,
int port,
byte[] ip,
long sharedFiles,
long sharedSize,
boolean ultrapeer,
QueryKey key)
Creates a new PingReply for this host with the specified GUID, ttl, and query key. |
static PingReply |
createQueryKeyReply(byte[] guid,
byte ttl,
QueryKey key)
Creates a new PingReply for this host with the specified GUID, ttl, and query key. |
int |
getDailyUptime()
Returns the average daily uptime in seconds from the GGEP payload. |
long |
getFiles()
Accessor for the number of files shared, as reported in the pong. |
java.lang.String |
getIP()
Returns the ip field in standard dotted decimal format, e.g., "127.0.0.1". |
byte[] |
getIPBytes()
Returns the ip address bytes (MSB first) |
long |
getKbytes()
Accessor for the number of kilobytes shared, as reported in the pong. |
int |
getPort()
Accessor for the port reported in this pong. |
QueryKey |
getQueryKey()
Returns the QueryKey (if any) associated with this pong. |
java.lang.String |
getVendor()
Returns the 4-character vendor string associated with this Pong. |
int |
getVendorMajorVersion()
Returns the major version number of the vendor returning this pong. |
int |
getVendorMinorVersion()
Returns the minor version number of the vendor returning this pong. |
boolean |
hasGGEPExtension()
Returns whether or not this pong has a GGEP extension. |
static boolean |
isPowerOf2(int x)
|
boolean |
isUltrapeer()
Returns true if this message is "marked", i.e., likely from an Ultrapeer. |
PingReply |
mutateGUID(byte[] guid)
Returns a new PingReply instance with all the same data as this, but with the specified GUID. |
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. |
boolean |
supportsUnicast()
Returns whether or not this host support unicast, GUESS-style queries. |
java.lang.String |
toString()
|
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, updateLength, write, writeGemExtension, writeGemExtension, writeGemExtensions |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int STANDARD_PAYLOAD_SIZE
Method Detail |
public static PingReply create(byte[] guid, byte ttl)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messagepublic static PingReply createQueryKeyReply(byte[] guid, byte ttl, QueryKey key)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messagekey
- the QueryKey for this replypublic static PingReply createQueryKeyReply(byte[] guid, byte ttl, int port, byte[] ip, long sharedFiles, long sharedSize, boolean ultrapeer, QueryKey key)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messagekey
- the QueryKey for this replypublic static PingReply create(byte[] guid, byte ttl, int port, byte[] address)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messageport
- the port the remote host is listening onaddress
- the address of the nodepublic static PingReply createExternal(byte[] guid, byte ttl, int port, byte[] address, boolean ultrapeer)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messageport
- the port the remote host is listening onaddress
- the address of the nodeultrapeer
- whether or not we should mark this node as
being an Ultrapeerpublic static PingReply createExternal(byte[] guid, byte ttl, int port, byte[] address, int uptime, boolean ultrapeer)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messageport
- the port the remote host is listening onaddress
- the address of the nodeultrapeer
- whether or not we should mark this node as
being an Ultrapeerpublic static PingReply createGUESSReply(byte[] guid, byte ttl, Endpoint ep) throws java.net.UnknownHostException
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messageep
- the Endpoint instance containing data about
the remote host
java.net.UnknownHostException
public static PingReply createGUESSReply(byte[] guid, byte ttl, int port, byte[] address)
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messageport
- the port the remote host is listening onaddress
- the address of the nodepublic static PingReply create(byte[] guid, byte ttl, int port, byte[] ip, long files, long kbytes)
guid
- the sixteen byte message GUIDttl
- the message TTL to useport
- my listening port. MUST fit in two signed bytes,
i.e., 0 < port < 2^16.ip
- my listening IP address. MUST be in dotted-quad big-endian,
format e.g. {18, 239, 0, 144}.files
- the number of files I'm sharing. Must fit in 4 unsigned
bytes, i.e., 0 < files < 2^32.kbytes
- the total size of all files I'm sharing, in kilobytes.
Must fit in 4 unsigned bytes, i.e., 0 < files < 2^32.public static PingReply create(byte[] guid, byte ttl, int port, byte[] ip, long files, long kbytes, boolean isUltrapeer, int dailyUptime, boolean isGUESSCapable)
guid
- the sixteen byte message GUIDttl
- the message TTL to useport
- my listening port. MUST fit in two signed bytes,
i.e., 0 < port < 2^16.ip
- my listening IP address. MUST be in dotted-quad big-endian,
format e.g. {18, 239, 0, 144}.files
- the number of files I'm sharing. Must fit in 4 unsigned
bytes, i.e., 0 < files < 2^32.kbytes
- the total size of all files I'm sharing, in kilobytes.
Must fit in 4 unsigned bytes, i.e., 0 < files < 2^32.isUltrapeer
- true if this should be a marked ultrapeer pong,
which sets kbytes to the nearest power of 2 not less than 8.dailyUptime
- my average daily uptime, in seconds, e.g.,
3600 for one hour per day. Negative values mean "don't know".
GGEP extension blocks are allocated if dailyUptime is non-negative.public PingReply mutateGUID(byte[] guid)
guid
- the guid to use for the new PingReply
public static PingReply createFromNetwork(byte[] guid, byte ttl, byte hops, byte[] payload) throws BadPacketException
guid
- the Globally Unique Identifier (GUID) for this messagettl
- the time to live for this messagehops
- the hops for this messagepayload
- the message payload
BadPacketException
- if the message is invalid for
any reason
BadPacketException
protected void writePayload(java.io.OutputStream out) throws java.io.IOException
writePayload
in class Message
java.io.IOException
public int getPort()
public java.lang.String getIP()
public byte[] getIPBytes()
public long getFiles()
public long getKbytes()
public int getDailyUptime()
public boolean supportsUnicast()
public java.lang.String getVendor()
public int getVendorMajorVersion()
public int getVendorMinorVersion()
public QueryKey getQueryKey()
public boolean hasGGEPExtension()
public Message stripExtendedPayload()
Message
stripExtendedPayload
in class Message
public boolean isUltrapeer()
public static boolean isPowerOf2(int x)
public void recordDrop()
Message
recordDrop
in class Message
public java.lang.String toString()
toString
in class Message
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |