Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #55 from awakecoding/master
Browse files Browse the repository at this point in the history
core network refactoring
  • Loading branch information
awakecoding committed Jun 29, 2011
2 parents 46c1d75 + cecf7eb commit 1a61308
Show file tree
Hide file tree
Showing 38 changed files with 1,908 additions and 1,575 deletions.
39 changes: 3 additions & 36 deletions channels/drdynvc/drdynvc_main.c
Expand Up @@ -28,6 +28,7 @@
#include <freerdp/utils/stream.h>
#include <freerdp/utils/chan_plugin.h>
#include <freerdp/utils/wait_obj.h>
#include <freerdp/utils/hexdump.h>

#include "drdynvc_main.h"

Expand Down Expand Up @@ -72,43 +73,9 @@ struct drdynvc_plugin
};

#if LOG_LEVEL > 10
void
hexdump(char* p, int len)
{
unsigned char* line;
int i;
int thisline;
int offset;

line = (unsigned char*)p;
offset = 0;
while (offset < len)
{
printf("%04x ", offset);
thisline = len - offset;
if (thisline > 16)
{
thisline = 16;
}
for (i = 0; i < thisline; i++)
{
printf("%02x ", line[i]);
}
for (; i < 16; i++)
{
printf(" ");
}
for (i = 0; i < thisline; i++)
{
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
}
printf("\n");
offset += thisline;
line += thisline;
}
}
#define hexdump(data,length) freerdp_hexdump(data,length)
#else
#define hexdump(p,len)
#define hexdump(data,length) do { } while (0)
#endif

static int
Expand Down
5 changes: 5 additions & 0 deletions include/freerdp/types/base.h
Expand Up @@ -23,6 +23,11 @@
#ifndef __TYPES_BASE_H
#define __TYPES_BASE_H

#ifndef True
#define True (1)
#define False (0)
#endif

typedef unsigned char uint8;
typedef signed char sint8;
typedef unsigned short uint16;
Expand Down
5 changes: 0 additions & 5 deletions include/freerdp/types/ui.h
Expand Up @@ -31,11 +31,6 @@ typedef void *RD_HGLYPH;
typedef void *RD_HPALETTE;
typedef void *RD_HCURSOR;

#ifndef True
#define True (1)
#define False (0)
#endif

typedef struct _RD_POINT
{
sint16 x, y;
Expand Down
3 changes: 2 additions & 1 deletion include/freerdp/utils/Makefile.am
Expand Up @@ -11,4 +11,5 @@ include_HEADERS = \
stopwatch.h \
stream.h \
unicode.h \
wait_obj.h
wait_obj.h \
hexdump.h
27 changes: 27 additions & 0 deletions include/freerdp/utils/hexdump.h
@@ -0,0 +1,27 @@
/*
FreeRDP: A Remote Desktop Protocol client.
Hex Dump Utils
Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef __UTILS_HEXDUMP_H
#define __UTILS_HEXDUMP_H

#define FREERDP_HEXDUMP_LINE_LENGTH 16

void freerdp_hexdump(uint8* data, int length);

#endif /* __UTILS_HEXDUMP_H */
4 changes: 3 additions & 1 deletion libfreerdp-core/Makefile.am
Expand Up @@ -10,6 +10,7 @@ libfreerdp_core_la_SOURCES = \
bitmap.c bitmap.h \
cache.c cache.h \
capabilities.c capabilities.h \
connect.c connect.h \
chan.c chan.h \
ext.c ext.h \
freerdp.c \
Expand All @@ -22,7 +23,8 @@ libfreerdp_core_la_SOURCES = \
pstcache.c pstcache.h \
rail.c rail.h \
rdp.c rdp.h \
secure.c secure.h \
security.c security.h \
network.c network.h \
crypto.h \
tcp.c tcp.h \
nego.c nego.h \
Expand Down
4 changes: 2 additions & 2 deletions libfreerdp-core/asn1.c
Expand Up @@ -21,9 +21,9 @@
#include "iso.h"
#include "mcs.h"
#include "chan.h"
#include "secure.h"
#include "rdp.h"
#include "asn1.h"
#include "security.h"

/* Parse an ASN.1 BER header */
RD_BOOL
Expand All @@ -42,7 +42,7 @@ ber_parse_header(rdpMcs * mcs, STREAM s, int tagval, int *length)

if (tag != tagval)
{
ui_error(mcs->sec->rdp->inst, "expected tag %d, got %d\n", tagval, tag);
ui_error(mcs->net->rdp->inst, "expected tag %d, got %d\n", tagval, tag);
return False;
}

Expand Down
12 changes: 6 additions & 6 deletions libfreerdp-core/chan.c
Expand Up @@ -20,8 +20,8 @@
#include "frdp.h"
#include "chan.h"
#include "mcs.h"
#include "secure.h"
#include "rdp.h"
#include "security.h"
#include <freerdp/rdpset.h>
#include <freerdp/utils/memory.h>
#include <freerdp/constants/vchan.h>
Expand All @@ -38,11 +38,11 @@ vchan_send(rdpChannels * chan, int mcs_id, char * data, int total_length)
rdpSet * settings;
struct rdp_chan * channel;

settings = chan->mcs->sec->rdp->settings;
settings = chan->mcs->net->rdp->settings;
chan_index = (mcs_id - MCS_GLOBAL_CHANNEL) - 1;
if ((chan_index < 0) || (chan_index >= settings->num_channels))
{
ui_error(chan->mcs->sec->rdp->inst, "error\n");
ui_error(chan->mcs->net->rdp->inst, "error\n");
return 0;
}
channel = &(settings->channels[chan_index]);
Expand All @@ -61,12 +61,12 @@ vchan_send(rdpChannels * chan, int mcs_id, char * data, int total_length)
{
chan_flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
}
s = sec_init(chan->mcs->sec, sec_flags, length + 8);
s = sec_init(chan->mcs->net->sec, sec_flags, length + 8);
out_uint32_le(s, total_length);
out_uint32_le(s, chan_flags);
out_uint8p(s, data + sent, length);
s_mark_end(s);
sec_send_to_channel(chan->mcs->sec, s, sec_flags, mcs_id);
sec_send_to_channel(chan->mcs->net->sec, s, sec_flags, mcs_id);
sent += length;
chan_flags = 0;
}
Expand All @@ -86,7 +86,7 @@ vchan_process(rdpChannels * chan, STREAM s, int mcs_id)
length = (int) (s->end - s->p);
data = (char *) (s->p);
s->p += length;
ui_channel_data(chan->mcs->sec->rdp->inst, mcs_id, data, length, flags, total_length);
ui_channel_data(chan->mcs->net->sec->rdp->inst, mcs_id, data, length, flags, total_length);
}

rdpChannels *
Expand Down
1 change: 1 addition & 0 deletions libfreerdp-core/chan.h
Expand Up @@ -21,6 +21,7 @@
#define __CHAN_H

#include "mcs.h"
#include "network.h"

struct rdp_channels
{
Expand Down

0 comments on commit 1a61308

Please sign in to comment.