mdw.sandStorm.lib.Gnutella
Class GnutellaPacket
java.lang.Object
|
+--mdw.sandStorm.lib.Gnutella.GnutellaPacket
- All Implemented Interfaces:
- GnutellaConst, QueueElementIF
- Direct Known Subclasses:
- GnutellaPingPacket, GnutellaPongPacket, GnutellaPushPacket, GnutellaQueryHitsPacket, GnutellaQueryPacket
- public abstract class GnutellaPacket
- extends java.lang.Object
- implements GnutellaConst, QueueElementIF
This is the base class for all Gnutella network packets.
Fields inherited from interface mdw.sandStorm.lib.Gnutella.GnutellaConst |
DEFAULT_DOWNLOAD_PORT, DEFAULT_GNUTELLA_PORT, DEFAULT_HOPS, DEFAULT_PING_INTERVAL, DEFAULT_SPEED, DEFAULT_TTL, GNUTELLA_CONNECT, GNUTELLA_FN_PING, GNUTELLA_FN_PONG, GNUTELLA_FN_PUSH, GNUTELLA_FN_QUERY, GNUTELLA_FN_QUERYHITS, GNUTELLA_OK, MAX_PAYLOAD_SIZE, PACKET_HEADER_SIZE, WRITE_CLOG_THRESHOLD |
Methods inherited from class java.lang.Object |
, clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
NUM_ALLOC
public static int NUM_ALLOC
gc
protected GnutellaConnection gc
guid
protected GnutellaGUID guid
function
protected int function
ttl
public int ttl
hops
public int hops
payload_length
protected int payload_length
payload
protected byte[] payload
GnutellaPacket
protected GnutellaPacket(GnutellaGUID guid,
int function,
int ttl,
int hops,
byte[] payload)
GnutellaPacket
protected GnutellaPacket(int function,
byte[] payload)
GnutellaPacket
protected GnutellaPacket(GnutellaGUID guid,
int function,
byte[] payload)
finalize
public void finalize()
- Overrides:
finalize
in class java.lang.Object
setConnection
void setConnection(GnutellaConnection gc)
- Used by GnutellaServer when creating a new packet.
getConnection
public GnutellaConnection getConnection()
- Return the GnutellaConnection from which this packet arrived.
In order to send a reply to this packet, you can call
'packet.send(origPacket.getConnection()'.
getGUID
public GnutellaGUID getGUID()
- Return the GUID associated with this packet.
prepareForSend
protected void prepareForSend()
- Implemented by subclasses to prepare for sending
getBuffer
BufferElement getBuffer()
- Render the packet as a BufferElement which can be pushed to an
aSocket connection.
getSize
public int getSize()
writeLEInt
protected static void writeLEInt(int i,
byte[] barr,
int offset)
readLEInt
protected static int readLEInt(byte[] barr,
int offset)
writeLEShort
protected static void writeLEShort(int i,
byte[] barr,
int offset)
readLEShort
protected static int readLEShort(byte[] barr,
int offset)
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object