Skip to content

Commit

Permalink
first portion of changes
Browse files Browse the repository at this point in the history
use writeback to external io handler in transport_write if external io
is in use

logic fix

implemented write handler for external io

added support for external io mode into transport_read_pdu
instead of duplicating it.

added missed EOL in new file

logic fix

dropped unneeded 'else'

WIP: making whole io switchable

moved streampool related code to separate function

implemented switchable Read

implemented switchable write

changes requested by akallabeth

DataHandler inplementation should not be switched, it is intended to be
used from external user
use SSIZE_T type for signed size type

improoved 'freerdp_set_transport_callbacks' logic a bit

overwrite already allocated rdpIoUpdate instead of changing pointer to
new one

dropped noisy log messages
  • Loading branch information
Gluzskiy Alexandr committed Jul 15, 2020
1 parent 369c232 commit 06017fb
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 70 deletions.
1 change: 1 addition & 0 deletions include/freerdp/freerdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ extern "C"
FREERDP_API const char* freerdp_get_logon_error_info_data(UINT32 data);

FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount);
FREERDP_API void freerdp_set_transport_callbacks(rdpContext* context, void *io_callbacks);

FREERDP_API BOOL freerdp_nla_impersonate(rdpContext* context);
FREERDP_API BOOL freerdp_nla_revert_to_self(rdpContext* context);
Expand Down
51 changes: 51 additions & 0 deletions include/freerdp/io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* IO Update Interface API
*
* Copyright 2020 Gluzskiy Alexandr <sss at sss dot chaoslab dot ru>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FREERDP_UPDATE_IO_H
#define FREERDP_UPDATE_IO_H

#include <freerdp/types.h>

typedef int (*pRead)(rdpContext* context, const uint8_t* buf, size_t buf_size);
typedef int (*pWrite)(rdpContext* context, const uint8_t* buf, size_t buf_size);
typedef int (*pDataHandler)(rdpContext* context, const uint8_t* buf, size_t buf_size);

struct rdp_io_update
{
rdpContext* context; /* 0 */
UINT32 paddingA[16 - 1]; /* 1 */

/* switchable read
* used to read bytes from IO backend */
pWrite Read; /* 16 */

/* switchable write
* used to write bytes to IO backend */
pWrite Write; /* 17 */

/* switchable data handler
* used if IO backed doing internal polling and reading
* and just passing recieved data to freerdp */
pDataHandler DataHandler; /* 18 */
UINT32 paddingB[32 - 19]; /* 19 */
};
typedef struct rdp_io_update rdpIoUpdate;


#endif /* FREERDP_UPDATE_IO_H */
1 change: 1 addition & 0 deletions include/freerdp/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ struct rdp_settings
default value - currently UNUSED! */
ALIGN64 char* ActionScript;
ALIGN64 DWORD Floatbar;

};
typedef struct rdp_settings rdpSettings;

Expand Down
4 changes: 3 additions & 1 deletion include/freerdp/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef struct rdp_update rdpUpdate;
#include <freerdp/altsec.h>
#include <freerdp/window.h>
#include <freerdp/pointer.h>
#include <freerdp/io.h>

/* Bitmap Updates */
#define EX_COMPRESSED_BITMAP_HEADER_PRESENT 0x01
Expand Down Expand Up @@ -223,7 +224,8 @@ struct rdp_update
rdpSecondaryUpdate* secondary; /* 34 */
rdpAltSecUpdate* altsec; /* 35 */
rdpWindowUpdate* window; /* 36 */
UINT32 paddingC[48 - 37]; /* 37 */
rdpIoUpdate* io; /* 37 */
UINT32 paddingC[48 - 38]; /* 38 */

pRefreshRect RefreshRect; /* 48 */
pSuppressOutput SuppressOutput; /* 49 */
Expand Down
2 changes: 2 additions & 0 deletions libfreerdp/core/freerdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ BOOL freerdp_context_new(freerdp* instance)
update_register_client_callbacks(rdp->update);
instance->context->abortEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

transport_register_default_io_callbacks(rdp->update);

if (!instance->context->abortEvent)
goto fail;

Expand Down
1 change: 1 addition & 0 deletions libfreerdp/core/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ BOOL freerdp_peer_context_new(freerdp_peer* client)
client->autodetect->context = context;
update_register_server_callbacks(client->update);
autodetect_register_server_callbacks(client->autodetect);
transport_register_default_io_callbacks(rdp->update);

if (!(context->errorDescription = calloc(1, 500)))
{
Expand Down

0 comments on commit 06017fb

Please sign in to comment.