j_waste.network
Class Packet

java.lang.Object
  extended byj_waste.network.Packet
Direct Known Subclasses:
ArbitraryPacket, HeadedPacket, InitialPacket1, InitialPacket2, InitialPacket2PSK, KeyInfo, TestPacket

public abstract class Packet
extends java.lang.Object

This class is the base class for the packets used in J-WASTE.

Version:
0.2
Author:
Jan Lindblom (cl0wn@users.sourceforge.net)

Field Summary
protected  byte[] packet
           
 
Constructor Summary
Packet()
           
 
Method Summary
abstract  void finalizePacket()
           
protected  byte[] padCD(int l)
          Returns a 0xCD pad of the specified length
protected  byte[] reverseBytes(byte[] b)
          Reverses the byte order in a byte array of length 4.
protected  int reverseInt(int i)
          Reverses the byte order of an int.
protected  short reverseShort(short s)
          Reverses the byte order of a short.
abstract  byte[] toByteArray()
           
 java.lang.String toString()
          Presents a Packet in a nice way similar to a tcpdump.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

packet

protected byte[] packet
Constructor Detail

Packet

public Packet()
Method Detail

toByteArray

public abstract byte[] toByteArray()

finalizePacket

public abstract void finalizePacket()

toString

public java.lang.String toString()
Presents a Packet in a nice way similar to a tcpdump.

Returns:
a String with the Packet contents.

reverseBytes

protected byte[] reverseBytes(byte[] b)
Reverses the byte order in a byte array of length 4.

Parameters:
b - The byte array to be reversed.

reverseInt

protected int reverseInt(int i)
Reverses the byte order of an int.

Parameters:
i - The int to reverse.

reverseShort

protected short reverseShort(short s)
Reverses the byte order of a short.

Parameters:
s - The short to reverse.

padCD

protected byte[] padCD(int l)
Returns a 0xCD pad of the specified length

Parameters:
l - The number of bytes to be returned.
Returns:
pad A byte array of length l containing the bit pattern 0xCD.