jSyncManager

org.jSyncManager.API.Protocol
Class SLP_Packet

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.SLP_Packet
All Implemented Interfaces:
java.io.Serializable

public class SLP_Packet
extends java.lang.Object
implements java.io.Serializable

SLP_Packet class. This class provides the class representation of an SLP packet.

Version:
$Revision: 1.7 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/05/01 23:53:59 $.
See Also:
Serialized Form

Field Summary
 char bodySize
          A field to hold the size of tha encapsulated data packet.
 byte checksum
          A field to hold the packet header checksum.
static byte CMP_PACKET
          Denotes that the packet type is CMP Packet.
 char CRC
          A field to hold the packet CRC value.
 byte[] data
          A fiold to hold the encapsulated packet data.
 byte destinationSocket
          A field to hold the destination socket.
static byte FIRST_TRANSACTION_ID
          Denotes the initial transaction ID for the first packet.
 byte packetType
          A field to hold the packet type.
static byte PAD_PACKET
          Denotes that the packet type is a PAD Packet.
static byte[] PREAMBLE
          The SLP Packet Preamble.
 byte sourceSocket
          A field to hold the source socket.
static byte SYSTEM_PACKET
          Denotes that the packet type is System Packet.
static byte TEST_PACKET
          Denotes that the packet type is a Test Packet.
 byte transactionID
          A field to hold the packet transaction ID number.
 
Constructor Summary
SLP_Packet()
          Constructs a new SLP packet.
 
Method Summary
(package private)  char calcCRC()
          Calculate the CRC value for this packet.
(package private)  byte calcHeaderChecksum()
          Calculate the header checksum for this packet.
(package private)  boolean checkCRC()
          Tests to see if the CRC value is correct.
(package private)  boolean checkHeaderChecksum()
          Tests to see if the header checksum is valid.
(package private)  GenericPacket getGenericPacket()
          Retreives the GenericPacket containing the data within this packet.
(package private)  byte[] packet2Bytes(boolean flag)
          Converts this packet to a byte array suitable for transmission.
 java.lang.String toString()
          Converts this packet to a human-readable segment of text.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST_TRANSACTION_ID

public static final byte FIRST_TRANSACTION_ID
Denotes the initial transaction ID for the first packet.

SYSTEM_PACKET

public static final byte SYSTEM_PACKET
Denotes that the packet type is System Packet.

CMP_PACKET

public static final byte CMP_PACKET
Denotes that the packet type is CMP Packet. NOTE: After version 1 of the protocol stack, this packet type is no longer in use. The jSyncManager doesn't handle receipt of this type of packet. It is present here for the sae of completeness.

PAD_PACKET

public static final byte PAD_PACKET
Denotes that the packet type is a PAD Packet.

TEST_PACKET

public static final byte TEST_PACKET
Denotes that the packet type is a Test Packet.

PREAMBLE

public static final byte[] PREAMBLE
The SLP Packet Preamble. The SLP Preamble is the three byte set that marks the beginning of every SLP packet.

destinationSocket

public byte destinationSocket
A field to hold the destination socket.

sourceSocket

public byte sourceSocket
A field to hold the source socket.

packetType

public byte packetType
A field to hold the packet type.

bodySize

public char bodySize
A field to hold the size of tha encapsulated data packet.

transactionID

public byte transactionID
A field to hold the packet transaction ID number.

checksum

public byte checksum
A field to hold the packet header checksum. The packet header has a checksum in it to help ensure that the header data was received correctly before attempting to read the data portion of the packet. This checksum includes the preamble, the destination socket, source socket, packet type, body size, and the transaction ID.

data

public byte[] data
A fiold to hold the encapsulated packet data.

CRC

public char CRC
A field to hold the packet CRC value. The packet CRC value is calculated using every byte of data from the packet preamble up to, but not including, the CRC value itself.
Constructor Detail

SLP_Packet

public SLP_Packet()
Constructs a new SLP packet.
Method Detail

calcCRC

char calcCRC()
Calculate the CRC value for this packet.

calcHeaderChecksum

byte calcHeaderChecksum()
Calculate the header checksum for this packet.

checkCRC

boolean checkCRC()
Tests to see if the CRC value is correct. This method will check to see whether the calculated CRC value of this packet matches the CRC value reported by the packet.
Returns:
true if the packet is good (ie: CRCs match), false otherwise.
See Also:
calcCRC()

checkHeaderChecksum

boolean checkHeaderChecksum()
Tests to see if the header checksum is valid. This method will check to see if the calculated header checksum of this packet matchs the reported header checksum contained within a received packet.
Returns:
true if the packet header is good (ie: checksums match), false otherwise.
See Also:
calcHeaderChecksum()

getGenericPacket

GenericPacket getGenericPacket()
Retreives the GenericPacket containing the data within this packet.
Returns:
the GenericPacket containing the data within this packet.

packet2Bytes

byte[] packet2Bytes(boolean flag)
Converts this packet to a byte array suitable for transmission.
Returns:
a byte array representing this packet object.

toString

public java.lang.String toString()
Converts this packet to a human-readable segment of text.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this packet, suitable for use as a trace/debug aid.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.