public class FSPpacket extends Object
FSPpacket class represents one packet sent over network while carrying payload of FSP protocol.
DatagramPacket
Modifier and Type | Field and Description |
---|---|
short |
bb_key
server access KEY, needs to be correct
|
short |
bb_len
number of required bytes in buffer
|
int |
bb_pos
file position pointer (4GB-1 max)
|
short |
bb_seq
client side sequence number, any number can be used
|
byte[] |
buf
buffer for holding user generated data to be transmitted via FSP protocol
|
static byte |
CC_BYE
finish a session
|
static byte |
CC_DEL_DIR
delete directory
|
static byte |
CC_DEL_FILE
delete file
|
static byte |
CC_ERR
error response from server
|
static byte |
CC_GET_DIR
get a directory listing
|
static byte |
CC_GET_FILE
get a file
|
static byte |
CC_GET_PRO
get directory protection
|
static byte |
CC_GRAB_DONE
atomic get+delete done
|
static byte |
CC_GRAB_FILE
atomic get+delete
|
static byte |
CC_INFO
get server info block
|
static byte |
CC_INSTALL
close a opened file for writing and move it to final location
|
static byte |
CC_LIMIT
commands greater then 0x7f are reserved for FSP v3 headers
|
static byte |
CC_MAKE_DIR
make directory
|
static byte |
CC_RENAME
rename file or directory
|
static byte |
CC_SET_PRO
set directory protection
|
static byte |
CC_STAT
get file/directory information
|
static byte |
CC_TEST
reserved for testing FSP v3 header
|
static byte |
CC_UP_LOAD
open temporary file for writing
|
static byte |
CC_VERSION
get server setup
|
byte |
cmd
FSP command, use one of CC_ constants
|
static int |
HSIZE
Size of FSP protocol v2 header - 12 bytes.
|
static int |
MAXSIZE
Maximum packet size (HSIZE+MAXSPACE).
|
static int |
MAXSPACE
Maximum payload supported by this library.
|
protected boolean |
serverside |
static int |
SPACE
Maximum standard FSP data payload - 1024 bytes.
|
byte |
sum
FSP packet checksum, field is computed by assemble()
|
int |
xtra_len
optional data size in buffer
|
Constructor and Description |
---|
FSPpacket()
Constructs a new storage for handling client side of
FSP packets.
|
FSPpacket(boolean serverside)
Constructs a new storage for handling FSP packets.
|
Modifier and Type | Method and Description |
---|---|
DatagramPacket |
assemble(DatagramPacket udp)
Generate UDP packet from this FSP packet.
|
boolean |
disassemble(DatagramPacket udp)
Disassemble UDP packet into this FSP packet.
|
void |
expect(byte command)
Test if packet is expected response to sent command.
|
boolean |
isServerSide()
check if we are using server side checksum method.
|
void |
setData(byte[] data1,
int offset1,
int length1,
byte[] data2,
int offset2,
int length2)
set FSP data payload to data1 and data2
|
String |
toString()
prints header of FSP packet.
|
public static final int HSIZE
public static final int SPACE
public static final int MAXSPACE
public static final int MAXSIZE
protected boolean serverside
public byte cmd
public byte sum
public short bb_key
public short bb_seq
public short bb_len
public int bb_pos
public int xtra_len
public byte[] buf
public static final byte CC_VERSION
public static final byte CC_INFO
public static final byte CC_ERR
public static final byte CC_GET_DIR
public static final byte CC_GET_FILE
public static final byte CC_UP_LOAD
public static final byte CC_INSTALL
public static final byte CC_DEL_FILE
public static final byte CC_DEL_DIR
public static final byte CC_GET_PRO
public static final byte CC_SET_PRO
public static final byte CC_MAKE_DIR
public static final byte CC_BYE
public static final byte CC_GRAB_FILE
public static final byte CC_GRAB_DONE
public static final byte CC_STAT
public static final byte CC_RENAME
public static final byte CC_LIMIT
public static final byte CC_TEST
public FSPpacket()
public FSPpacket(boolean serverside)
serverside
- Use server-side checksum method for FSP packetspublic boolean disassemble(DatagramPacket udp)
udp
- the DatagramPacket to be disassembled.public DatagramPacket assemble(DatagramPacket udp)
udp
- storage for assembled packetpublic String toString()
public void setData(byte[] data1, int offset1, int length1, byte[] data2, int offset2, int length2)
data1
- data payload arrayoffset1
- starting offset of data in data1 arraylength1
- data sizedata2
- xtra data payload arrayoffset2
- starting offset of xtra data in data2 arraylength2
- xtra data sizeIllegalArgumentException
- If data can't fit into
packet, have invalid offsets or negative lengthpublic boolean isServerSide()
public void expect(byte command) throws IOException
command
- expected replyIOException
- unexpected response receivedCopyright © 2020 FSP Project. All rights reserved.