|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindbright.ssh2.SSH2DataBuffer
com.mindbright.ssh2.SSH2TransportPDU
public class SSH2TransportPDU
Handles one packet data unit. These are the actual packets which are sent over en encrypted tunnel. Encryption and compression are applied to these.
There is a difference bwteeen incoming and outgoing PDUs. The latter have extra space allocated in them to help speed up the encryption process.
This class makes an effort to avoid copying data wherever possible.
Field Summary | |
---|---|
static SSH2TransportPDU |
factoryInstance
|
static int |
PACKET_DEFAULT_SIZE
|
static int |
PACKET_MAX_SIZE
|
static int |
PACKET_MIN_SIZE
|
protected int |
padSize
|
static int |
pktDefaultSize
|
protected int |
pktSize
|
protected int |
pktType
|
Fields inherited from class com.mindbright.ssh2.SSH2DataBuffer |
---|
BOOLEAN_FALSE, BOOLEAN_TRUE, data, rPos, wPos |
Constructor Summary | |
---|---|
protected |
SSH2TransportPDU()
|
protected |
SSH2TransportPDU(int pktType,
int bufSize)
Constructor which creates a prefabricated packet. |
Method Summary | |
---|---|
protected void |
checkMac(Mac mac,
int macSize)
|
static SSH2TransportPDU |
createIncomingPacket()
Have the factory create a PDU for an incoming packet. |
static SSH2TransportPDU |
createIncomingPacket(int bufSize)
Have the factory create a PDU for an incoming packet. |
static SSH2TransportPDU |
createOutgoingPacket(int pktType)
Have the factory create a PDU for an outgoing packet. |
static SSH2TransportPDU |
createOutgoingPacket(int pktType,
int bufSize)
Have the factory create a PDU for an outgoing packet. |
protected SSH2TransportPDU |
createPDU(int bufSize)
Create a new PDU to use for incoming packets. |
protected SSH2TransportPDU |
createPDU(int pktType,
int bufSize)
Create a new PDU for an outgoing packet. |
static SSH2Transport.TranceiverContext |
createTranceiverContext(java.lang.String cipherName,
java.lang.String macName,
java.lang.String compName)
Static function which creates a tranceiver context with the mentioned algorithms. |
SSH2Transport.TranceiverContext |
createTranceiverContextImpl(java.lang.String cipherName,
java.lang.String macName,
java.lang.String compName)
An implementation which actually creates a tranceiver context. |
int |
getPayloadLength()
Get the length of the payload. |
int |
getPayloadOffset()
Get the offset in the data buffer where the payload starts. |
int |
getType()
|
SSH2TransportPDU |
makeCopy()
Create a copy of this PDU. |
void |
readFrom(java.io.InputStream in,
int seqNum,
SSH2Transport.TranceiverContext context)
Read and decrypt an incoming packet from the given stream. |
protected void |
readNextNFrom(java.io.InputStream in,
int n)
Read a number of bytes from the stream and store in the internal buffer. |
void |
release()
Release this PDU. |
static void |
setFactoryInstance(SSH2TransportPDU factory)
Register a factor which handles the creation and destruction of incoming and outgoing packets. |
void |
setType(int pktType)
|
java.lang.String |
toString()
Creates a string representation of this PDU. |
void |
writeByte(int b)
|
void |
writeRaw(byte[] raw,
int off,
int len)
|
void |
writeString(byte[] str,
int off,
int len)
|
void |
writeTo(java.io.OutputStream out,
int seqNum,
SSH2Transport.TranceiverContext context,
SecureRandomAndPad rand)
Encrypts and writes an outgoing packet to the stream. |
Methods inherited from class com.mindbright.ssh2.SSH2DataBuffer |
---|
getData, getMaxReadSize, getMaxSize, getMaxWriteSize, getRPos, getWPos, readBigInt, readBigIntBits, readBoolean, readByte, readInt, readJavaString, readLong, readRaw, readRaw, readRestRaw, readString, readString, reset, setData, setRPos, setWPos, writeBigInt, writeBigIntBits, writeBoolean, writeInt, writeLong, writeRaw, writeString, writeString, writeUTF8String |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int PACKET_DEFAULT_SIZE
public static final int PACKET_MIN_SIZE
public static final int PACKET_MAX_SIZE
public static int pktDefaultSize
public static SSH2TransportPDU factoryInstance
protected int pktSize
protected int padSize
protected int pktType
Constructor Detail |
---|
protected SSH2TransportPDU()
protected SSH2TransportPDU(int pktType, int bufSize)
pktType
- Type of packet to create.bufSize
- How many bytes it should have room for.Method Detail |
---|
protected SSH2TransportPDU createPDU(int bufSize)
bufSize
- How many bytes it should have room for.protected SSH2TransportPDU createPDU(int pktType, int bufSize)
pktType
- Type of packet to create.bufSize
- How many bytes it should have room for.public static final void setFactoryInstance(SSH2TransportPDU factory)
public static final SSH2TransportPDU createIncomingPacket(int bufSize)
bufSize
- How many bytes it should have room for.public static final SSH2TransportPDU createIncomingPacket()
public static final SSH2TransportPDU createOutgoingPacket(int pktType, int bufSize)
pktType
- Type of packet to create.bufSize
- How many bytes it should have room for.public static final SSH2TransportPDU createOutgoingPacket(int pktType)
pktType
- Type of packet to create.public static final SSH2Transport.TranceiverContext createTranceiverContext(java.lang.String cipherName, java.lang.String macName, java.lang.String compName) throws java.lang.Exception
cipherName
- Name of cipher algorithm to use.macName
- Name of message authentication cipher to use.compName
- Name of compression algorithm to use.
java.lang.Exception
public void release()
public SSH2TransportPDU makeCopy()
public int getType()
public void setType(int pktType)
public int getPayloadLength()
public int getPayloadOffset()
public void readFrom(java.io.InputStream in, int seqNum, SSH2Transport.TranceiverContext context) throws java.io.IOException, SSH2Exception, ShortBufferException
in
- Stream to read packet from.seqNum
- Sequence number of packet.context
- Tranceiver context.
java.io.IOException
SSH2Exception
ShortBufferException
protected void checkMac(Mac mac, int macSize) throws SSH2MacCheckException, ShortBufferException
SSH2MacCheckException
ShortBufferException
protected final void readNextNFrom(java.io.InputStream in, int n) throws java.io.IOException, SSH2EOFException
in
- Stream to read data from.n
- Number of bytes to read.
java.io.IOException
SSH2EOFException
public final void writeByte(int b)
writeByte
in class SSH2DataBuffer
public final void writeString(byte[] str, int off, int len)
writeString
in class SSH2DataBuffer
public final void writeRaw(byte[] raw, int off, int len)
writeRaw
in class SSH2DataBuffer
public void writeTo(java.io.OutputStream out, int seqNum, SSH2Transport.TranceiverContext context, SecureRandomAndPad rand) throws java.io.IOException, ShortBufferException, SSH2CompressionException
out
- Stream to write resulting data to.seqNum
- Sequence number of packet.context
- Tranceiver context to use.rand
- An object from which random numbers and padding
data is read.
java.io.IOException
ShortBufferException
SSH2CompressionException
public java.lang.String toString()
toString
in class java.lang.Object
public SSH2Transport.TranceiverContext createTranceiverContextImpl(java.lang.String cipherName, java.lang.String macName, java.lang.String compName) throws java.lang.Exception
cipherName
- Name of cipher algorithm to use.macName
- Name of message authentication cipher to use.compName
- Name of compression algorithm to use.
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |