|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cse466.packets.CSE466Packet
The base class for all of the packets. It contains the fields that are in the TOS_Msg header. Note: The parser uses the class's fields to figure out how to parse the file, so if you add or remove fields, you will confuse the parser.
Field Summary | |
int |
amType
the amType of this packet |
int |
destination
where this packet is headed |
int |
groupId
the groupID of this packet |
Constructor Summary | |
CSE466Packet()
|
Method Summary | |
protected int |
bytesToInt(byte first,
byte second)
Get the int value of the two bytes. |
protected int |
bytesToInt32(byte first,
byte second,
byte third,
byte fourth)
Get the int value of the two bytes. |
protected int |
byteToInt(byte value)
Get the int value of the byte |
protected void |
copyIntoArray(byte[] intoHere,
byte[] fromHere,
int offsetIntoIntoHere)
Copies the contents of fromHere into intoHere starting at an offset of offsetIntoIntoHere, and going for as long as the fromHere array is. |
boolean |
equals(cse466.packets.CSE466Packet other)
Returns true if the fields of this packet match the other packet's fields |
byte[] |
getByteArray()
Gives you the byte array corresponding to this packet for sending over the network. |
protected byte[] |
getByteArray(byte[] childPacket)
Gives you the byte array that corresponds to this packet. |
int |
getProperAMType()
Returns the proper AMType for this packet, or -1 if the packet doesn't have a proper amType. |
protected byte |
intToByte(int value)
Get the byte value of the value |
protected byte |
intToLSB(int value)
Get the least significant byte of the value |
protected byte |
intToLSBHigh(int value)
Get the least significant byte of the high half of the value (for 32 bit values) |
protected byte |
intToMSB(int value)
Get the most significant byte of the low half of the value (for 16 bit values) |
protected byte |
intToMSBHigh(int value)
Get the most significant byte of the value (for 32 bit values) |
void |
print()
Pretty print the contents of this packet to System.out |
byte[] |
setFromBytes(byte[] array)
Sets the fields in this packet from the byte array given. |
protected byte[] |
subArray(byte[] original,
int startIndex)
Gives you a sub array starting at startIndex in original and going to the end. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int destination
public int amType
public int groupId
Constructor Detail |
public CSE466Packet()
Method Detail |
public int getProperAMType()
public byte[] setFromBytes(byte[] array)
protected byte[] getByteArray(byte[] childPacket)
childPacket
- the payload. This will be put on the end of the
array
public byte[] getByteArray()
public void print()
public boolean equals(cse466.packets.CSE466Packet other)
other
- The packet to compare to.protected byte[] subArray(byte[] original, int startIndex)
protected void copyIntoArray(byte[] intoHere, byte[] fromHere, int offsetIntoIntoHere)
protected byte intToLSB(int value)
protected byte intToMSB(int value)
protected byte intToLSBHigh(int value)
protected byte intToMSBHigh(int value)
protected byte intToByte(int value)
protected int bytesToInt(byte first, byte second)
first
- The least significant bytesecond
- The most significant byteprotected int bytesToInt32(byte first, byte second, byte third, byte fourth)
first
- The least significant bytesecond
- The most significant byteprotected int byteToInt(byte value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |