private void handleCredSSP(ByteBuffer buf, Link link) { if (verbose) System.out.println("[" + this + "] INFO: CredSSP data received: " + buf + "."); // Store header position: will parse whole header later in BER format parser int headerPosition = buf.cursor - 1; long payloadLength = buf.readBerLength(); if (payloadLength > 10 * 1024) throw new RuntimeException( "[" + this + "] ERROR: CredSSP packets seems to be too long: " + payloadLength + "bytes. Data: " + buf + "."); // Length is the size of payload, so we need to append size of header int headerLength = buf.cursor - headerPosition; int packetLength = (int) payloadLength + headerLength; if (!cap(buf, packetLength, packetLength, link, false)) // Wait for full packet to arrive return; // Extract payload (with header) ByteBuffer outBuf = buf.slice(headerPosition, packetLength, true); buf.unref(); if (verbose) { outBuf.putMetadata("source", this); } pushDataToPad(CREDSSP_PAD, outBuf); }