27 |
#define CHANNEL_FLAG_LAST 0x02 |
#define CHANNEL_FLAG_LAST 0x02 |
28 |
#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 |
#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 |
29 |
|
|
30 |
extern BOOL use_rdp5; |
extern BOOL g_use_rdp5; |
31 |
extern BOOL encryption; |
extern BOOL g_encryption; |
32 |
|
|
33 |
VCHANNEL g_channels[MAX_CHANNELS]; |
VCHANNEL g_channels[MAX_CHANNELS]; |
34 |
unsigned int g_num_channels; |
unsigned int g_num_channels; |
35 |
|
|
36 |
/* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5 |
/* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5 |
37 |
channels to MCS channels. |
channels to MCS channels. |
38 |
|
|
39 |
The format of TAG_SRV_CHANNELS seems to be |
The format of TAG_SRV_CHANNELS seems to be |
40 |
|
|
48 |
{ |
{ |
49 |
VCHANNEL *channel; |
VCHANNEL *channel; |
50 |
|
|
51 |
if (!use_rdp5) |
if (!g_use_rdp5) |
52 |
return NULL; |
return NULL; |
53 |
|
|
54 |
if (g_num_channels >= MAX_CHANNELS) |
if (g_num_channels >= MAX_CHANNELS) |
67 |
} |
} |
68 |
|
|
69 |
STREAM |
STREAM |
70 |
channel_init(VCHANNEL *channel, uint32 length) |
channel_init(VCHANNEL * channel, uint32 length) |
71 |
{ |
{ |
72 |
STREAM s; |
STREAM s; |
73 |
|
|
74 |
s = sec_init(encryption ? SEC_ENCRYPT : 0, length + 8); |
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, length + 8); |
75 |
s_push_layer(s, channel_hdr, 8); |
s_push_layer(s, channel_hdr, 8); |
76 |
return s; |
return s; |
77 |
} |
} |
78 |
|
|
79 |
void |
void |
80 |
channel_send(STREAM s, VCHANNEL *channel) |
channel_send(STREAM s, VCHANNEL * channel) |
81 |
{ |
{ |
82 |
uint32 length, flags; |
uint32 length, flags; |
83 |
uint32 thislength, remaining; |
uint32 thislength, remaining; |
89 |
|
|
90 |
thislength = MIN(length, CHANNEL_CHUNK_LENGTH); |
thislength = MIN(length, CHANNEL_CHUNK_LENGTH); |
91 |
remaining = length - thislength; |
remaining = length - thislength; |
92 |
flags = (remaining == 0) ? CHANNEL_FLAG_FIRST|CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST; |
flags = (remaining == 0) ? CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST; |
93 |
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) |
94 |
flags |= CHANNEL_FLAG_SHOW_PROTOCOL; |
flags |= CHANNEL_FLAG_SHOW_PROTOCOL; |
95 |
|
|
96 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
97 |
out_uint32_le(s, flags); |
out_uint32_le(s, flags); |
98 |
data = s->end = s->p + thislength; |
data = s->end = s->p + thislength; |
99 |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, channel->mcs_id); |
sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); |
100 |
|
|
101 |
/* subsequent segments copied (otherwise would have to generate headers backwards) */ |
/* subsequent segments copied (otherwise would have to generate headers backwards) */ |
102 |
while (remaining > 0) |
while (remaining > 0) |
105 |
remaining -= thislength; |
remaining -= thislength; |
106 |
flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0; |
flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0; |
107 |
|
|
108 |
s = sec_init(encryption ? SEC_ENCRYPT : 0, thislength + 8); |
s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); |
109 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
110 |
out_uint32_le(s, flags); |
out_uint32_le(s, flags); |
111 |
out_uint8p(s, data, thislength); |
out_uint8p(s, data, thislength); |
112 |
s_mark_end(s); |
s_mark_end(s); |
113 |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, channel->mcs_id); |
sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); |
114 |
|
|
115 |
data += thislength; |
data += thislength; |
116 |
} |
} |
168 |
} |
} |
169 |
} |
} |
170 |
} |
} |
|
|
|