+ * Send preconnection information if enabled.
+ * @param nego
+ * @return
+ */
+
+boolean nego_send_preconnection_pdu(rdpNego* nego)
+{
+ STREAM* s;
+ uint32 cbSize;
+ UNICONV* uniconv;
+ uint16 cchPCB_times2 = 0;
+ char* wszPCB = NULL;
+
+ if(!nego->send_preconnection_pdu)
+ return true;
+
+ DEBUG_NEGO("Sending preconnection PDU");
+ if(!nego_tcp_connect(nego))
+ return false;
+
+ /* it's easier to always send the version 2 PDU, and it's just 2 bytes overhead */
+ cbSize = PRECONNECTION_PDU_V2_MIN_SIZE;
+ if(nego->preconnection_blob) {
+ uniconv = freerdp_uniconv_new();
+ wszPCB = freerdp_uniconv_out(uniconv, nego->preconnection_blob, &cchPCB_times2);
+ freerdp_uniconv_free(uniconv);
+ cchPCB_times2 += 2; /* zero-termination */
+ cbSize += cchPCB_times2;
+ }
+
+ s = transport_send_stream_init(nego->transport, cbSize);
+ stream_write_uint32(s, cbSize); /* cbSize */
+ stream_write_uint32(s, 0); /* Flags */
+ stream_write_uint32(s, PRECONNECTION_PDU_V2); /* Version */
+ stream_write_uint32(s, nego->preconnection_id); /* Id */
+ stream_write_uint16(s, cchPCB_times2 / 2); /* cchPCB */
+ if(wszPCB)
+ {
+ stream_write(s, wszPCB, cchPCB_times2); /* wszPCB */
+ xfree(wszPCB);
+ }
+
+ if (transport_write(nego->transport, s) < 0)
+ return false;
+
+ return true;
+}
+
+/**