More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.sandStorm.lib.Gnutella
Class GnutellaPacket

java.lang.Object
  |
  +--seda.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.


Field Summary
protected  int function
           
protected  GnutellaConnection gc
           
protected  GnutellaGUID guid
           
 int hops
           
static int NUM_ALLOC
           
protected  byte[] payload
           
protected  int payload_length
           
 int ttl
           
 
Fields inherited from interface seda.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
 
Constructor Summary
protected GnutellaPacket(GnutellaGUID guid, int function, byte[] payload)
           
protected GnutellaPacket(GnutellaGUID guid, int function, int ttl, int hops, byte[] payload)
           
protected GnutellaPacket(int function, byte[] payload)
           
 
Method Summary
 void finalize()
           
(package private)  BufferElement getBuffer()
          Render the packet as a BufferElement which can be pushed to an aSocket connection.
 GnutellaConnection getConnection()
          Return the GnutellaConnection from which this packet arrived.
 GnutellaGUID getGUID()
          Return the GUID associated with this packet.
 int getSize()
           
protected  void prepareForSend()
          Implemented by subclasses to prepare for sending
protected static int readLEInt(byte[] barr, int offset)
           
protected static int readLEShort(byte[] barr, int offset)
           
(package private)  void setConnection(GnutellaConnection gc)
          Used by GnutellaServer when creating a new packet.
 java.lang.String toString()
           
protected static void writeLEInt(int i, byte[] barr, int offset)
           
protected static void writeLEShort(int i, byte[] barr, int offset)
           
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Constructor Detail

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)
Method Detail

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

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/