cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

peer.h (6440B)


      1/**
      2 * FreeRDP: A Remote Desktop Protocol Implementation
      3 * RDP Server Peer
      4 *
      5 * Copyright 2011 Vic Lee
      6 *
      7 * Licensed under the Apache License, Version 2.0 (the "License");
      8 * you may not use this file except in compliance with the License.
      9 * You may obtain a copy of the License at
     10 *
     11 *     http://www.apache.org/licenses/LICENSE-2.0
     12 *
     13 * Unless required by applicable law or agreed to in writing, software
     14 * distributed under the License is distributed on an "AS IS" BASIS,
     15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 * See the License for the specific language governing permissions and
     17 * limitations under the License.
     18 */
     19
     20#ifndef FREERDP_PEER_H
     21#define FREERDP_PEER_H
     22
     23#include <freerdp/api.h>
     24#include <freerdp/types.h>
     25#include <freerdp/settings.h>
     26#include <freerdp/input.h>
     27#include <freerdp/update.h>
     28#include <freerdp/autodetect.h>
     29
     30#include <winpr/sspi.h>
     31#include <winpr/ntlm.h>
     32
     33typedef BOOL (*psPeerContextNew)(freerdp_peer* peer, rdpContext* context);
     34typedef void (*psPeerContextFree)(freerdp_peer* peer, rdpContext* context);
     35
     36typedef BOOL (*psPeerInitialize)(freerdp_peer* peer);
     37typedef BOOL (*psPeerGetFileDescriptor)(freerdp_peer* peer, void** rfds, int* rcount);
     38typedef HANDLE (*psPeerGetEventHandle)(freerdp_peer* peer);
     39typedef DWORD (*psPeerGetEventHandles)(freerdp_peer* peer, HANDLE* events, DWORD count);
     40typedef HANDLE (*psPeerGetReceiveEventHandle)(freerdp_peer* peer);
     41typedef BOOL (*psPeerCheckFileDescriptor)(freerdp_peer* peer);
     42typedef BOOL (*psPeerIsWriteBlocked)(freerdp_peer* peer);
     43typedef int (*psPeerDrainOutputBuffer)(freerdp_peer* peer);
     44typedef BOOL (*psPeerHasMoreToRead)(freerdp_peer* peer);
     45typedef BOOL (*psPeerClose)(freerdp_peer* peer);
     46typedef void (*psPeerDisconnect)(freerdp_peer* peer);
     47typedef BOOL (*psPeerCapabilities)(freerdp_peer* peer);
     48typedef BOOL (*psPeerPostConnect)(freerdp_peer* peer);
     49typedef BOOL (*psPeerActivate)(freerdp_peer* peer);
     50typedef BOOL (*psPeerLogon)(freerdp_peer* peer, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic);
     51typedef BOOL (*psPeerSendServerRedirection)(freerdp_peer* peer, UINT32 sessionId,
     52                                            const char* targetNetAddress, const char* routingToken,
     53                                            const char* userName, const char* domain,
     54                                            const char* password, const char* targetFQDN,
     55                                            const char* targetNetBiosName, DWORD tsvUrlLength,
     56                                            const BYTE* tsvUrl, UINT32 targetNetAddressesCount,
     57                                            const char** targetNetAddresses);
     58typedef BOOL (*psPeerAdjustMonitorsLayout)(freerdp_peer* peer);
     59typedef BOOL (*psPeerClientCapabilities)(freerdp_peer* peer);
     60
     61typedef BOOL (*psPeerSendChannelData)(freerdp_peer* peer, UINT16 channelId, const BYTE* data,
     62                                      size_t size);
     63typedef BOOL (*psPeerReceiveChannelData)(freerdp_peer* peer, UINT16 channelId, const BYTE* data,
     64                                         size_t size, UINT32 flags, size_t totalSize);
     65
     66typedef HANDLE (*psPeerVirtualChannelOpen)(freerdp_peer* peer, const char* name, UINT32 flags);
     67typedef BOOL (*psPeerVirtualChannelClose)(freerdp_peer* peer, HANDLE hChannel);
     68typedef int (*psPeerVirtualChannelRead)(freerdp_peer* peer, HANDLE hChannel, BYTE* buffer,
     69                                        UINT32 length);
     70typedef int (*psPeerVirtualChannelWrite)(freerdp_peer* peer, HANDLE hChannel, const BYTE* buffer,
     71                                         UINT32 length);
     72typedef void* (*psPeerVirtualChannelGetData)(freerdp_peer* peer, HANDLE hChannel);
     73typedef int (*psPeerVirtualChannelSetData)(freerdp_peer* peer, HANDLE hChannel, void* data);
     74
     75/** @brief the result of the license callback */
     76typedef enum
     77{
     78	LICENSE_CB_INTERNAL_ERROR, /** an internal error happened in the callback */
     79	LICENSE_CB_ABORT,          /** licensing process failed, abort the connection */
     80	LICENSE_CB_IN_PROGRESS, /** incoming packet has been treated, we're waiting for further packets
     81	                           to complete the workflow */
     82	LICENSE_CB_COMPLETED    /** the licensing workflow has completed, go to next step */
     83} LicenseCallbackResult;
     84
     85typedef LicenseCallbackResult (*psPeerLicenseCallback)(freerdp_peer* peer, wStream* s);
     86
     87struct rdp_freerdp_peer
     88{
     89	rdpContext* context;
     90
     91	int sockfd;
     92	char hostname[50];
     93
     94	rdpInput* input;
     95	rdpUpdate* update;
     96	rdpSettings* settings;
     97	rdpAutoDetect* autodetect;
     98
     99	void* ContextExtra;
    100	size_t ContextSize;
    101	psPeerContextNew ContextNew;
    102	psPeerContextFree ContextFree;
    103
    104	psPeerInitialize Initialize;
    105	psPeerGetFileDescriptor GetFileDescriptor;
    106	psPeerGetEventHandle GetEventHandle;
    107	psPeerGetReceiveEventHandle GetReceiveEventHandle;
    108	psPeerCheckFileDescriptor CheckFileDescriptor;
    109	psPeerClose Close;
    110	psPeerDisconnect Disconnect;
    111
    112	psPeerCapabilities Capabilities;
    113	psPeerPostConnect PostConnect;
    114	psPeerActivate Activate;
    115	psPeerLogon Logon;
    116
    117	psPeerSendChannelData SendChannelData;
    118	psPeerReceiveChannelData ReceiveChannelData;
    119
    120	psPeerVirtualChannelOpen VirtualChannelOpen;
    121	psPeerVirtualChannelClose VirtualChannelClose;
    122	psPeerVirtualChannelRead VirtualChannelRead;
    123	psPeerVirtualChannelWrite VirtualChannelWrite;
    124	psPeerVirtualChannelGetData VirtualChannelGetData;
    125	psPeerVirtualChannelSetData VirtualChannelSetData;
    126
    127	int pId;
    128	UINT32 ack_frame_id;
    129	BOOL local;
    130	BOOL connected;
    131	BOOL activated;
    132	BOOL authenticated;
    133	SEC_WINNT_AUTH_IDENTITY identity;
    134
    135	psPeerIsWriteBlocked IsWriteBlocked;
    136	psPeerDrainOutputBuffer DrainOutputBuffer;
    137	psPeerHasMoreToRead HasMoreToRead;
    138	psPeerGetEventHandles GetEventHandles;
    139	psPeerAdjustMonitorsLayout AdjustMonitorsLayout;
    140	psPeerClientCapabilities ClientCapabilities;
    141	psPeerComputeNtlmHash ComputeNtlmHash;
    142	psPeerLicenseCallback LicenseCallback;
    143
    144	psPeerSendServerRedirection SendServerRedirection;
    145};
    146
    147#ifdef __cplusplus
    148extern "C"
    149{
    150#endif
    151
    152	FREERDP_API BOOL freerdp_peer_context_new(freerdp_peer* client);
    153	FREERDP_API void freerdp_peer_context_free(freerdp_peer* client);
    154
    155	FREERDP_API const char* freerdp_peer_os_major_type_string(freerdp_peer* client);
    156	FREERDP_API const char* freerdp_peer_os_minor_type_string(freerdp_peer* client);
    157
    158	FREERDP_API freerdp_peer* freerdp_peer_new(int sockfd);
    159	FREERDP_API void freerdp_peer_free(freerdp_peer* client);
    160
    161#ifdef __cplusplus
    162}
    163#endif
    164
    165#endif /* FREERDP_PEER_H */