ReactOS 0.4.15-dev-8393-g61b7fb9
channels.c File Reference
#include "rdesktop.h"
Include dependency graph for channels.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ channel_init()

STREAM channel_init ( RDPCLIENT This,
VCHANNEL channel,
uint32  length 
)

Definition at line 66 of file channels.c.

67{
68 STREAM s;
69
70 s = sec_init(This, This->encryption ? SEC_ENCRYPT : 0, length + 8);
71 s_push_layer(s, channel_hdr, 8);
72 return s;
73}
#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

◆ channel_process()

void channel_process ( RDPCLIENT This,
STREAM  s,
uint16  mcs_channel 
)

Definition at line 127 of file channels.c.

128{
130 uint32 thislength;
131 VCHANNEL *channel = NULL;
132 unsigned int i;
133 STREAM in;
134
135 for (i = 0; i < This->num_channels; i++)
136 {
137 channel = &This->channels[i];
138 if (channel->mcs_id == mcs_channel)
139 break;
140 }
141
142 if (i >= This->num_channels)
143 return;
144
148 {
149 /* single fragment - pass straight up */
150 channel->process(This, s);
151 }
152 else
153 {
154 /* add fragment to defragmentation buffer */
155 in = &channel->in;
157 {
158 if (length > in->size)
159 {
160 in->data = (uint8 *) xrealloc(in->data, length);
161 in->size = length;
162 }
163 in->p = in->data;
164 }
165
166 thislength = MIN(s->end - s->p, in->data + in->size - in->p);
167 memcpy(in->p, s->p, thislength);
168 in->p += thislength;
169
171 {
172 in->end = in->p;
173 in->p = in->data;
174 channel->process(This, in);
175 }
176 }
177}
#define CHANNEL_FLAG_LAST
Definition: channels.c:26
#define CHANNEL_FLAG_FIRST
Definition: channels.c:25
#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

◆ channel_register()

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

Definition at line 43 of file channels.c.

44{
45 VCHANNEL *channel;
46
47 if (!This->use_rdp5)
48 return NULL;
49
50 if (This->num_channels >= MAX_CHANNELS)
51 {
52 error("Channel table full, increase MAX_CHANNELS\n");
53 return NULL;
54 }
55
56 channel = &This->channels[This->num_channels];
57 channel->mcs_id = MCS_GLOBAL_CHANNEL + 1 + This->num_channels;
58 strncpy(channel->name, name, 8);
59 channel->flags = flags;
60 channel->process = callback;
61 This->num_channels++;
62 return channel;
63}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define MAX_CHANNELS
Definition: channels.c:23
#define MCS_GLOBAL_CHANNEL
Definition: constants.h:87
#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

◆ channel_send()

void channel_send ( RDPCLIENT This,
STREAM  s,
VCHANNEL channel 
)

Definition at line 76 of file channels.c.

77{
79 uint32 thislength, remaining;
80 uint8 *data;
81
82 /* first fragment sent in-place */
83 s_pop_layer(s, channel_hdr);
84 length = s->end - s->p - sizeof(CHANNEL_PDU_HEADER);
85
86 DEBUG_CHANNEL(("channel_send, length = %d\n", length));
87
88 thislength = MIN(length, CHANNEL_CHUNK_LENGTH);
89/* Note: In the original clipboard implementation, this number was
90 1592, not 1600. However, I don't remember the reason and 1600 seems
91 to work so.. This applies only to *this* length, not the length of
92 continuation or ending packets. */
93 remaining = length - thislength;
97
100 data = s->end = s->p + thislength;
101 DEBUG_CHANNEL(("Sending %d bytes with FLAG_FIRST\n", thislength));
102 sec_send_to_channel(This, s, This->encryption ? SEC_ENCRYPT : 0, channel->mcs_id);
103
104 /* subsequent segments copied (otherwise would have to generate headers backwards) */
105 while (remaining > 0)
106 {
107 thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH);
108 remaining -= thislength;
109 flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0;
110 if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL)
112
113 DEBUG_CHANNEL(("Sending %d bytes with flags %d\n", thislength, flags));
114
115 s = sec_init(This, This->encryption ? SEC_ENCRYPT : 0, thislength + 8);
118 out_uint8p(s, data, thislength);
119 s_mark_end(s);
120 sec_send_to_channel(This, s, This->encryption ? SEC_ENCRYPT : 0, channel->mcs_id);
121
122 data += thislength;
123 }
124}
#define CHANNEL_CHUNK_LENGTH
Definition: channels.c:24
#define CHANNEL_FLAG_SHOW_PROTOCOL
Definition: channels.c:27
#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 sec_send_to_channel(STREAM s, uint32 flags, uint16 channel)
Definition: secure.c:436
#define DEBUG_CHANNEL(args)
Definition: rdesktop.h:159
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950