ReactOS  0.4.14-dev-50-g13bb5e2
channels.c File Reference
#include "precomp.h"
Include dependency graph for channels.c:

Go to the source code of this file.

Macros

#define MAX_CHANNELS   6
 
#define CHANNEL_CHUNK_LENGTH   1600
 
#define CHANNEL_FLAG_FIRST   0x01
 
#define CHANNEL_FLAG_LAST   0x02
 
#define CHANNEL_FLAG_SHOW_PROTOCOL   0x10
 

Functions

VCHANNELchannel_register (char *name, uint32 flags, void(*callback)(STREAM))
 
STREAM channel_init (VCHANNEL *channel, uint32 length)
 
void channel_send (STREAM s, VCHANNEL *channel)
 
void channel_process (STREAM s, uint16 mcs_channel)
 

Variables

RDP_VERSION g_rdp_version
 
RD_BOOL g_encryption
 
VCHANNEL g_channels [MAX_CHANNELS]
 
unsigned int g_num_channels
 

Macro Definition Documentation

◆ CHANNEL_CHUNK_LENGTH

#define CHANNEL_CHUNK_LENGTH   1600

Definition at line 24 of file channels.c.

◆ CHANNEL_FLAG_FIRST

#define CHANNEL_FLAG_FIRST   0x01

Definition at line 25 of file channels.c.

◆ CHANNEL_FLAG_LAST

#define CHANNEL_FLAG_LAST   0x02

Definition at line 26 of file channels.c.

◆ CHANNEL_FLAG_SHOW_PROTOCOL

#define CHANNEL_FLAG_SHOW_PROTOCOL   0x10

Definition at line 27 of file channels.c.

◆ MAX_CHANNELS

#define MAX_CHANNELS   6

Definition at line 23 of file channels.c.

Function Documentation

◆ channel_init()

STREAM channel_init ( VCHANNEL channel,
uint32  length 
)

Definition at line 69 of file channels.c.

70 {
71  STREAM s;
72 
74  s_push_layer(s, channel_hdr, 8);
75  return s;
76 }
STREAM sec_init(uint32 flags, int maxlen)
Definition: secure.c:419
RD_BOOL g_encryption
Definition: uimain.c:40
#define SEC_ENCRYPT
Definition: constants.h:101
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
Definition: parse.h:22
GLdouble s
Definition: gl.h:2039
#define s_push_layer(s, h, n)
Definition: parse.h:39

Referenced by cliprdr_send_packet(), lspci_send(), rdpdr_send_available(), rdpdr_send_clientcapabilty(), rdpdr_send_completion(), rdpdr_send_connect(), rdpdr_send_name(), rdpsnd_init_packet(), and seamless_send().

◆ channel_process()

void channel_process ( STREAM  s,
uint16  mcs_channel 
)

Definition at line 138 of file channels.c.

139 {
141  uint32 thislength;
142  VCHANNEL *channel = NULL;
143  unsigned int i;
144  STREAM in;
145 
146  for (i = 0; i < g_num_channels; i++)
147  {
148  channel = &g_channels[i];
149  if (channel->mcs_id == mcs_channel)
150  break;
151  }
152 
153  if (i >= g_num_channels)
154  return;
155 
157  in_uint32_le(s, flags);
159  {
160  /* single fragment - pass straight up */
161  channel->process(s);
162  }
163  else
164  {
165  /* add fragment to defragmentation buffer */
166  in = &channel->in;
168  {
169  if (length > in->size)
170  {
171  in->data = (uint8 *) xrealloc(in->data, length);
172  in->size = length;
173  }
174  in->p = in->data;
175  }
176 
177  thislength = MIN(s->end - s->p, in->data + in->size - in->p);
178  memcpy(in->p, s->p, thislength);
179  in->p += thislength;
180 
181  if (flags & CHANNEL_FLAG_LAST)
182  {
183  in->end = in->p;
184  in->p = in->data;
185  channel->process(in);
186  }
187  }
188 }
struct stream in
Definition: types.h:155
unsigned int uint32
Definition: types.h:32
#define CHANNEL_FLAG_LAST
Definition: channels.c:26
T MIN(T a, T b)
Definition: polytest.cpp:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
#define CHANNEL_FLAG_FIRST
Definition: channels.c:25
smooth NULL
Definition: ftsmooth.c:416
uint16 mcs_id
Definition: types.h:152
void(* process)(STREAM)
Definition: types.h:156
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned char uint8
Definition: types.h:28
GLbitfield flags
Definition: glext.h:7161
Definition: parse.h:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLdouble s
Definition: gl.h:2039
VCHANNEL g_channels[MAX_CHANNELS]
Definition: channels.c:32
GLuint in
Definition: glext.h:9616
unsigned int g_num_channels
Definition: channels.c:33
#define in_uint32_le(s, v)
Definition: parse.h:56

Referenced by sec_recv().

◆ channel_register()

VCHANNEL* channel_register ( char name,
uint32  flags,
void(*)(STREAM callback 
)

Definition at line 46 of file channels.c.

47 {
48  VCHANNEL *channel;
49 
50  if (g_rdp_version < RDP_V5)
51  return NULL;
52 
54  {
55  error("Channel table full, increase MAX_CHANNELS\n");
56  return NULL;
57  }
58 
59  channel = &g_channels[g_num_channels];
60  channel->mcs_id = MCS_GLOBAL_CHANNEL + 1 + g_num_channels;
61  strncpy(channel->name, name, 8);
62  channel->flags = flags;
63  channel->process = callback;
65  return channel;
66 }
#define error(str)
Definition: mkdosfs.c:1605
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char name[8]
Definition: types.h:153
#define MAX_CHANNELS
Definition: channels.c:23
#define MCS_GLOBAL_CHANNEL
Definition: constants.h:87
RDP_VERSION g_rdp_version
Definition: uimain.c:74
smooth NULL
Definition: ftsmooth.c:416
uint32 flags
Definition: types.h:154
uint16 mcs_id
Definition: types.h:152
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
Definition: types.h:44
void(* process)(STREAM)
Definition: types.h:156
GLbitfield flags
Definition: glext.h:7161
VCHANNEL g_channels[MAX_CHANNELS]
Definition: channels.c:32
unsigned int g_num_channels
Definition: channels.c:33
Definition: name.c:36

Referenced by cliprdr_init(), lspci_init(), rdpdr_init(), rdpsnd_init(), and seamless_init().

◆ channel_send()

void channel_send ( STREAM  s,
VCHANNEL channel 
)

Definition at line 79 of file channels.c.

80 {
82  uint32 thislength, remaining;
83  uint8 *data;
84 
85 #ifdef WITH_SCARD
87 #endif
88 
89  /* first fragment sent in-place */
90  s_pop_layer(s, channel_hdr);
91  length = s->end - s->p - 8;
92 
93  DEBUG_CHANNEL(("channel_send, length = %d\n", length));
94 
95  thislength = MIN(length, CHANNEL_CHUNK_LENGTH);
96 /* Note: In the original clipboard implementation, this number was
97  1592, not 1600. However, I don't remember the reason and 1600 seems
98  to work so.. This applies only to *this* length, not the length of
99  continuation or ending packets. */
100  remaining = length - thislength;
102  if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
104 
107  data = s->end = s->p + thislength;
108  DEBUG_CHANNEL(("Sending %d bytes with FLAG_FIRST\n", thislength));
110 
111  /* subsequent segments copied (otherwise would have to generate headers backwards) */
112  while (remaining > 0)
113  {
114  thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH);
115  remaining -= thislength;
116  flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0;
117  if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
119 
120  DEBUG_CHANNEL(("Sending %d bytes with flags %d\n", thislength, flags));
121 
122  s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8);
125  out_uint8p(s, data, thislength);
126  s_mark_end(s);
128 
129  data += thislength;
130  }
131 
132 #ifdef WITH_SCARD
134 #endif
135 }
#define out_uint8p(s, v, n)
Definition: parse.h:93
unsigned int uint32
Definition: types.h:32
STREAM sec_init(uint32 flags, int maxlen)
Definition: secure.c:419
#define CHANNEL_CHUNK_LENGTH
Definition: channels.c:24
#define out_uint32_le(s, v)
Definition: parse.h:59
RD_BOOL g_encryption
Definition: uimain.c:40
#define CHANNEL_FLAG_LAST
Definition: channels.c:26
#define SCARD_LOCK_CHANNEL
Definition: constants.h:581
T MIN(T a, T b)
Definition: polytest.cpp:79
#define CHANNEL_FLAG_FIRST
Definition: channels.c:25
#define s_pop_layer(s, h)
Definition: parse.h:40
#define DEBUG_CHANNEL(args)
Definition: rdesktop.h:159
uint32 flags
Definition: types.h:154
#define SEC_ENCRYPT
Definition: constants.h:101
uint16 mcs_id
Definition: types.h:152
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
void scard_unlock(int lock)
unsigned char uint8
Definition: types.h:28
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define CHANNEL_FLAG_SHOW_PROTOCOL
Definition: channels.c:27
GLdouble s
Definition: gl.h:2039
void sec_send_to_channel(STREAM s, uint32 flags, uint16 channel)
Definition: secure.c:436
void scard_lock(int lock)
#define s_mark_end(s)
Definition: parse.h:41
#define CHANNEL_OPTION_SHOW_PROTOCOL
Definition: constants.h:434

Referenced by cliprdr_send_packet(), lspci_send(), rdpdr_send_available(), rdpdr_send_clientcapabilty(), rdpdr_send_completion(), rdpdr_send_connect(), rdpdr_send_name(), rdpsnd_send(), and seamless_send().

Variable Documentation

◆ g_channels

◆ g_encryption

RD_BOOL g_encryption

Definition at line 40 of file uimain.c.

Referenced by channel_init(), and channel_send().

◆ g_num_channels

unsigned int g_num_channels

◆ g_rdp_version

RDP_VERSION g_rdp_version

Definition at line 74 of file uimain.c.

Referenced by channel_register().