Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ libcommon_la_SOURCES = \
arch.h \
base64.h \
base64.c \
channel_defs.h \
defines.h \
fifo.c \
fifo.h \
Expand Down
69 changes: 69 additions & 0 deletions common/channel_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (C) 2024 Matt Burt, all xrdp contributors
*
* 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.
*/

/**
* @file common/channel_defs.h
* @brief Private xrdp channel definitions
*/

#if !defined(CHANNEL_DEFS_H)
#define CHANNEL_DEFS_H

#include <stdint.h>

/**
* Channel IDs assigned to xrdp private channels. These are chosen to avoid conflicts with
* channel IDs returned by other servers.
*/
enum
{
CHAN_ID_XRDP_BASE = (('x' << 24) | ('r' << 16) | ('d' << 8) | 'p'),
CHAN_ID_XRDP_SESSION_INFO = CHAN_ID_XRDP_BASE,
// Add further IDs here
CHAN_ID_XRDP_MAX
};

// Max length of a DVC name. This is taken from the specification of
// WTSVirtualChannelOpenEx() which limits the length of a virtual channel
// to Windows MAX_PATH
#define MAX_DVC_NAME_LEN 260

/**
* Information to connect to a channel using xrdpapi
*/
#define XRDPAPI_CONNECT_PDU_LEN 384 // Connect PDU is always this length
#define XRDPAPI_CONNECT_PDU_VERSION 1 // Current connnect PDU version

struct xrdp_chan_connect
{
uint32_t version;
uint32_t private_chan; // 0 for a standard channel
uint32_t flags;
char name[MAX_DVC_NAME_LEN + 1]; // null-terminated
};

// Events received on the CHAN_ID_XRDP_SESSION_INFO channel

// Update on all the session state data held by chansrv
//
// If more information is needed to be exported by xrdpapi, it can be
// added to this event
struct xrdp_chan_session_state
{
uint32_t is_connected; // Is the session connected?
};

#endif /* CHANNEL_DEFS_H */
8 changes: 8 additions & 0 deletions common/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ in_utf16_le_terminated_as_utf8_length(struct stream *s);
(s)->p++; \
} while (0)

/******************************************************************************/
// Platform-endian out_uint32
#if defined(B_ENDIAN)
#define out_uint32_pe(s, v) out_uint32_be(s, v)
#else
#define out_uint32_pe(s, v) out_uint32_le(s, v)
#endif

/******************************************************************************/
#define in_uint8p(s, v, n) do \
{ \
Expand Down
Loading