anon.tor.cells
Class Cell

java.lang.Object
  extended by anon.tor.cells.Cell
Direct Known Subclasses:
CreateCell, CreatedCell, DestroyCell, PaddingCell, RelayCell

public abstract class Cell
extends java.lang.Object

Author:
stefan

Field Summary
static int CELL_PAYLOAD_SIZE
           
static int CELL_SIZE
           
private  int m_circID
           
private  int m_command
           
protected  byte[] m_payload
           
 
Constructor Summary
protected Cell(int command)
           
protected Cell(int command, int circID)
           
protected Cell(int command, int circID, byte[] payload)
           
protected Cell(int command, int circID, byte[] payload, int offset)
           
 
Method Summary
static Cell createCell(byte[] cellData)
          creates a cell with the given data
 byte[] getCellData()
          creates a fixed-sized cell

2 bytes - circID
1 byte - command
509 bytes - payload
 int getCircuitID()
          gets the circuit id
 int getCommand()
          returns the command of the cell
 byte[] getPayload()
          gets the payload of the cell
 void setPayload(byte[] payload, int offset)
          sets the payload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CELL_SIZE

public static final int CELL_SIZE
See Also:
Constant Field Values

CELL_PAYLOAD_SIZE

public static final int CELL_PAYLOAD_SIZE
See Also:
Constant Field Values

m_circID

private int m_circID

m_command

private int m_command

m_payload

protected byte[] m_payload
Constructor Detail

Cell

protected Cell(int command)

Cell

protected Cell(int command,
               int circID)

Cell

protected Cell(int command,
               int circID,
               byte[] payload)

Cell

protected Cell(int command,
               int circID,
               byte[] payload,
               int offset)
Method Detail

getCellData

public byte[] getCellData()
creates a fixed-sized cell

2 bytes - circID
1 byte - command
509 bytes - payload

Returns:
composed cell

getCommand

public int getCommand()
returns the command of the cell

Returns:
command

getCircuitID

public int getCircuitID()
gets the circuit id

Returns:
ID

getPayload

public byte[] getPayload()
gets the payload of the cell

Returns:
payload

setPayload

public void setPayload(byte[] payload,
                       int offset)
sets the payload

Parameters:
payload - payload
offset - offset

createCell

public static Cell createCell(byte[] cellData)
creates a cell with the given data

Parameters:
cellData - data
Returns:
a cell