Skip to content

Commit

Permalink
Start the drdynvc channel within xrdp_wm
Browse files Browse the repository at this point in the history
The responsibility for starting the drdynvc channel is moved out of
libxrdp into the application. This will make it easier to allow the
application to check the channel is enabled before starting it.
  • Loading branch information
matt335672 committed Mar 15, 2024
1 parent 01d3ded commit 84fd2a5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
17 changes: 17 additions & 0 deletions libxrdp/libxrdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,23 @@ libxrdp_disable_channel(struct xrdp_session *session, int channel_id,
return 1;
}

/*****************************************************************************/
int
libxrdp_drdynvc_start(struct xrdp_session *session)
{
struct xrdp_rdp *rdp;
struct xrdp_sec *sec;
struct xrdp_channel *chan;

LOG_DEVEL(LOG_LEVEL_TRACE, "libxrdp_drdynvc_start:");

rdp = (struct xrdp_rdp *) (session->rdp);
sec = rdp->sec_layer;
chan = sec->chan_layer;
return xrdp_channel_drdynvc_start(chan);
}


/*****************************************************************************/
int
libxrdp_drdynvc_open(struct xrdp_session *session, const char *name,
Expand Down
2 changes: 2 additions & 0 deletions libxrdp/libxrdpinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ int
libxrdp_disable_channel(struct xrdp_session *session, int channel_id,
int is_disabled);
int
libxrdp_drdynvc_start(struct xrdp_session *session);
int
libxrdp_drdynvc_open(struct xrdp_session *session, const char *name,
int flags, struct xrdp_drdynvc_procs *procs,
int *chan_id);
Expand Down
69 changes: 38 additions & 31 deletions libxrdp/xrdp_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,46 +752,53 @@ xrdp_channel_drdynvc_send_capability_request(struct xrdp_channel *self)
int
xrdp_channel_drdynvc_start(struct xrdp_channel *self)
{
int index;
int count;
struct mcs_channel_item *ci;
struct mcs_channel_item *dci;

LOG_DEVEL(LOG_LEVEL_INFO, "xrdp_channel_drdynvc_start: drdynvc_channel_id %d", self->drdynvc_channel_id);
int rv = 0;
LOG_DEVEL(LOG_LEVEL_INFO,
"xrdp_channel_drdynvc_start: drdynvc_channel_id %d",
self->drdynvc_channel_id);
if (self->drdynvc_channel_id != -1)
{
LOG_DEVEL(LOG_LEVEL_INFO, "xrdp_channel_drdynvc_start: already started");
return 0;
LOG_DEVEL(LOG_LEVEL_INFO,
"xrdp_channel_drdynvc_start: already started");
}
dci = NULL;
count = self->mcs_layer->channel_list->count;
for (index = 0; index < count; index++)
else
{
ci = (struct mcs_channel_item *)
list_get_item(self->mcs_layer->channel_list, index);
if (ci != NULL)
int index;
int count;
struct mcs_channel_item *ci;
struct mcs_channel_item *dci;
dci = NULL;
count = self->mcs_layer->channel_list->count;
for (index = 0; index < count; index++)
{
if (g_strcasecmp(ci->name, "drdynvc") == 0)
ci = (struct mcs_channel_item *)
list_get_item(self->mcs_layer->channel_list, index);
if (ci != NULL)
{
dci = ci;
if (g_strcasecmp(ci->name, DRDYNVC_SVC_CHANNEL_NAME) == 0)
{
dci = ci;
break;
}
}
}
if (dci != NULL)
{
self->drdynvc_channel_id = (dci->chanid - MCS_GLOBAL_CHANNEL) - 1;
LOG_DEVEL(LOG_LEVEL_DEBUG, DRDYNVC_SVC_CHANNEL_NAME
"Initializing Dynamic Virtual Channel with channel id %d",
self->drdynvc_channel_id);
xrdp_channel_drdynvc_send_capability_request(self);
}
else
{
LOG(LOG_LEVEL_WARNING,
"Static channel '%s' not found. "
"Channel not initialized", DRDYNVC_SVC_CHANNEL_NAME);
rv = -1;
}
}
if (dci != NULL)
{
self->drdynvc_channel_id = (dci->chanid - MCS_GLOBAL_CHANNEL) - 1;
LOG_DEVEL(LOG_LEVEL_DEBUG,
"Initializing Dynamic Virtual Channel with channel id %d",
self->drdynvc_channel_id);
xrdp_channel_drdynvc_send_capability_request(self);
}
else
{
LOG(LOG_LEVEL_WARNING,
"Dynamic Virtual Channel named 'drdynvc' not found, "
"channel not initialized");
}
return 0;
return rv;
}

/*****************************************************************************/
Expand Down
1 change: 0 additions & 1 deletion libxrdp/xrdp_rdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,6 @@ xrdp_rdp_process_data_font(struct xrdp_rdp *self, struct stream *s)
self->session->callback(self->session->id, 0x555a, 0, 0,
0, 0);
}
xrdp_channel_drdynvc_start(self->sec_layer->chan_layer);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions xrdp/xrdp_wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,7 @@ callback(intptr_t id, int msg, intptr_t param1, intptr_t param2,
LOWORD(param3), HIWORD(param3));
case 0x555a:
// "yeah, up_and_running"
libxrdp_drdynvc_start(wm->session);
xrdp_mm_up_and_running(wm->mm);
break;
}
Expand Down

0 comments on commit 84fd2a5

Please sign in to comment.