use of streamer.ByteBuffer in project cloudstack by apache.
the class ClientX224ConnectionRequestPDU method onStart.
@Override
protected void onStart() {
super.onStart();
// Length of packet without length field
int length = 33 + userName.length();
ByteBuffer buf = new ByteBuffer(length, true);
// Type (high nibble) = 0xe = CR TPDU; credit (low nibble) = 0
buf.writeByte(X224_TPDU_CONNECTION_REQUEST);
// Destination reference = 0
buf.writeShort(0);
// Source reference = 0
buf.writeShort(0);
// Class and options = 0
buf.writeByte(0);
// Cookie
buf.writeString("Cookie: mstshash=" + userName + "\r\n", RdpConstants.CHARSET_8);
// RDP_NEG_REQ::type
buf.writeByte(RdpConstants.RDP_NEG_REQ_TYPE_NEG_REQ);
// RDP_NEG_REQ::flags (0)
buf.writeByte(RdpConstants.RDP_NEG_REQ_FLAGS);
// RDP_NEG_REQ::length (constant: 8) short int in LE format
buf.writeByte(0x08);
buf.writeByte(0x00);
// RDP_NEG_REQ: Requested protocols: PROTOCOL_SSL
buf.writeIntLE(protocol);
// Calculate length of packet and prepend it to buffer
ByteBuffer data = new ByteBuffer(5);
// Write length
data.writeVariableIntLE(buf.length);
// Reset length of buffer to actual length of data written
data.length = data.cursor;
buf.prepend(data);
data.unref();
pushDataToOTOut(buf);
switchOff();
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ClientX224DataPDU method handleData.
@Override
public void handleData(ByteBuffer buf, Link link) {
if (buf == null)
return;
if (verbose)
System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
ByteBuffer data = new ByteBuffer(3);
// X224 header
// Header length indicator
data.writeByte(2);
data.writeByte(X224_TPDU_DATA);
data.writeByte(X224_TPDU_LAST_DATA_UNIT);
buf.prepend(data);
data.unref();
pushDataToPad(STDOUT, buf);
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ClientMCSErectDomainRequest method onStart.
@Override
protected void onStart() {
super.onStart();
int length = 5;
ByteBuffer buf = new ByteBuffer(length, true);
// Erect Domain Request
buf.writeByte(0x04);
// Client SHOULD initialize both the subHeight and subinterval fields of the MCS Erect Domain Request PDU to zero.
// ErectDomainRequest::subHeight length = 1 byte
buf.writeByte(1);
// ErectDomainRequest::subHeight
buf.writeByte(0);
// ErectDomainRequest::subInterval length = 1 byte
buf.writeByte(1);
// ErectDomainRequest::subInterval
buf.writeByte(0);
pushDataToOTOut(buf);
switchOff();
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ClientSynchronizePDU method onStart.
@Override
protected void onStart() {
super.onStart();
// Large enough
int length = 1024;
ByteBuffer buf = new ByteBuffer(length, true);
/* @formatter:off */
buf.writeBytes(new byte[] { // MCS send data request
(byte) 0x64, // Initiator: 1004 (1001+3)
(byte) 0x00, (byte) 0x03, // Channel ID: 1003 (I/O Channel)
(byte) 0x03, (byte) 0xeb, // Data priority: high (0x40), segmentation: begin (0x20) | end (0x10)
(byte) 0x70, // Data length: 22 bytes (0x16, variable length field)
(byte) 0x80, (byte) 0x16, // RDP: total length: 22 bytes (LE)
(byte) 0x16, (byte) 0x00, // PDU type: PDUTYPE_DATAPDU (0x7), TS_PROTOCOL_VERSION (0x10) (LE)
(byte) 0x17, (byte) 0x00, // PDU source: 1007 (LE)
(byte) 0xec, (byte) 0x03, // Share ID: 0x000103ea (LE)
(byte) 0xea, (byte) 0x03, (byte) 0x01, (byte) 0x00, // Padding: 1 byte
(byte) 0x00, // Stream ID: STREAM_LOW (1)
(byte) 0x01, // uncompressedLength : 8 bytes (LE)
(byte) 0x08, (byte) 0x00, // pduType2 = PDUTYPE2_SYNCHRONIZE (31)
(byte) 0x1f, // generalCompressedType: 0
(byte) 0x00, // generalCompressedLength: 0 (LE?)
(byte) 0x00, (byte) 0x00, // messageType: SYNCMSGTYPE_SYNC (1) (LE)
(byte) 0x01, (byte) 0x00, // targetUser: 0x03ea
(byte) 0xea, (byte) 0x03 });
/* @formatter:on */
// Trim buffer to actual length of data written
buf.trimAtCursor();
pushDataToOTOut(buf);
switchOff();
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ClientTpkt method handleData.
@Override
public void handleData(ByteBuffer buf, Link link) {
if (buf == null)
return;
if (verbose)
System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
if (buf.length + 4 > 65535)
throw new RuntimeException("Packet is too long for TPKT (max length 65535-4): " + buf + ".");
ByteBuffer data = new ByteBuffer(4);
// TPKT version
data.writeByte(3);
// Reserved
data.writeByte(0);
// Packet length, including length of the header
data.writeShort(buf.length + 4);
buf.prepend(data);
data.unref();
pushDataToPad(STDOUT, buf);
}
Aggregations