ReactOS 0.4.16-dev-329-g9223134
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}
RD_BOOL g_encryption
Definition: uimain.c:40
#define SEC_ENCRYPT
Definition: constants.h:101
#define s_push_layer(s, h, n)
Definition: parse.h:39
STREAM sec_init(uint32 flags, int maxlen)
Definition: secure.c:419
GLdouble s
Definition: gl.h:2039
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
Definition: parse.h:23

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
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
182 {
183 in->end = in->p;
184 in->p = in->data;
185 channel->process(in);
186 }
187 }
188}
#define CHANNEL_FLAG_LAST
Definition: channels.c:26
#define CHANNEL_FLAG_FIRST
Definition: channels.c:25
unsigned int g_num_channels
Definition: channels.c:33
VCHANNEL g_channels[MAX_CHANNELS]
Definition: channels.c:32
#define in_uint32_le(s, v)
Definition: parse.h:56
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
#define MIN(x, y)
Definition: rdesktop.h:171
unsigned int uint32
Definition: types.h:32
unsigned char uint8
Definition: types.h:28
#define NULL
Definition: types.h:112
GLuint in
Definition: glext.h:9616
GLbitfield flags
Definition: glext.h:7161
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
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void(* process)(STREAM)
Definition: types.h:156
struct stream in
Definition: types.h:155
uint16 mcs_id
Definition: types.h:152

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
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];
61 strncpy(channel->name, name, 8);
62 channel->flags = flags;
63 channel->process = callback;
65 return channel;
66}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
RDP_VERSION g_rdp_version
Definition: uimain.c:74
#define MAX_CHANNELS
Definition: channels.c:23
#define MCS_GLOBAL_CHANNEL
Definition: constants.h:87
@ RDP_V5
Definition: types.h:44
#define error(str)
Definition: mkdosfs.c:1605
static IPrintDialogCallback callback
Definition: printdlg.c:326
uint32 flags
Definition: types.h:154
char name[8]
Definition: types.h:153
Definition: name.c:39

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 CHANNEL_CHUNK_LENGTH
Definition: channels.c:24
#define CHANNEL_FLAG_SHOW_PROTOCOL
Definition: channels.c:27
#define SCARD_LOCK_CHANNEL
Definition: constants.h:581
#define CHANNEL_OPTION_SHOW_PROTOCOL
Definition: constants.h:434
#define s_mark_end(s)
Definition: parse.h:41
#define out_uint32_le(s, v)
Definition: parse.h:59
#define s_pop_layer(s, h)
Definition: parse.h:40
#define out_uint8p(s, v, n)
Definition: parse.h:93
void scard_lock(int lock)
void sec_send_to_channel(STREAM s, uint32 flags, uint16 channel)
Definition: secure.c:436
void scard_unlock(int lock)
#define DEBUG_CHANNEL(args)
Definition: rdesktop.h:159
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

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
extern

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
extern

Definition at line 74 of file uimain.c.

Referenced by channel_register().