Permalink
Browse files

mppc: moved to libfreerdp-codec

  • Loading branch information...
jsorg71 committed Mar 30, 2012
1 parent b1a8082 commit 6aa7eaf627aebc232179df3a85cd2bc2ff0aad70
View
@@ -635,33 +635,28 @@ int add_mppc_suite(void)
void test_mppc(void)
{
- rdpRdp rdp;
- struct rdp_mppc rmppc;
+ struct rdp_mppc_dec* rmppc;
uint32_t roff;
uint32_t rlen;
long int dur;
struct timeval start_time;
struct timeval end_time;
- rdp.mppc = &rmppc;
- rdp.mppc->history_buf = calloc(1, RDP6_HISTORY_BUF_SIZE);
- CU_ASSERT(rdp.mppc->history_buf != NULL)
- rdp.mppc->history_ptr = rdp.mppc->history_buf;
-
+ rmppc = mppc_dec_new();
/* save starting time */
gettimeofday(&start_time, NULL);
/* uncompress data */
- CU_ASSERT(decompress_rdp_5(&rdp, compressed_rd5, sizeof(compressed_rd5),
+ CU_ASSERT(decompress_rdp_5(rmppc, compressed_rd5, sizeof(compressed_rd5),
PACKET_COMPRESSED, &roff, &rlen) == true);
/* get end time */
gettimeofday(&end_time, NULL);
- CU_ASSERT(memcmp(decompressed_rd5, rdp.mppc->history_buf, sizeof(decompressed_rd5)) == 0);
- free(rdp.mppc->history_buf);
+ CU_ASSERT(memcmp(decompressed_rd5, rmppc->history_buf, sizeof(decompressed_rd5)) == 0);
+ mppc_dec_free(rmppc);
/* print time taken */
dur = ((end_time.tv_sec - start_time.tv_sec) * 1000000) + (end_time.tv_usec - start_time.tv_usec);
View
@@ -26,9 +26,10 @@
#include <sys/types.h>
#include <freerdp/freerdp.h>
-#include "rdp.h"
+#include <freerdp/codec/mppc_dec.h>
+#include <freerdp/codec/mppc_enc.h>
#include "test_mppc_enc.h"
-#include "mppc_enc.h"
+
#define BUF_SIZE (1024 * 1)
@@ -491,21 +492,17 @@ void test_mppc_enc(void)
char buf[BUF_SIZE];
/* needed by decoder */
- rdpRdp rdp;
- struct rdp_mppc rmppc;
- uint32_t roff;
- uint32_t rlen;
+ struct rdp_mppc_dec* rmppc;
+ uint32 roff;
+ uint32 rlen;
/* required for timing the test */
struct timeval start_time;
struct timeval end_time;
long int dur;
/* setup decoder */
- rdp.mppc = &rmppc;
- rdp.mppc->history_buf = calloc(1, RDP6_HISTORY_BUF_SIZE);
- CU_ASSERT(rdp.mppc->history_buf != NULL);
- rdp.mppc->history_ptr = rdp.mppc->history_buf;
+ rmppc = mppc_dec_new();
/* setup encoder for RDP 5.0 */
CU_ASSERT((enc = mppc_enc_new(PROTO_RDP_50)) != NULL);
@@ -532,10 +529,10 @@ void test_mppc_enc(void)
{
DLOG(("%d bytes compressed to %d\n", bytes_read, enc->bytes_in_opb));
clen += enc->bytes_in_opb;
- CU_ASSERT(decompress_rdp_5(&rdp, (uint8 *) enc->outputBuffer,
+ CU_ASSERT(decompress_rdp_5(rmppc, (uint8 *) enc->outputBuffer,
enc->bytes_in_opb, enc->flags, &roff, &rlen) != false);
CU_ASSERT(bytes_read == rlen);
- CU_ASSERT(memcmp(buf, &rdp.mppc->history_buf[roff], rlen) == 0);
+ CU_ASSERT(memcmp(buf, &rmppc->history_buf[roff], rlen) == 0);
}
else
{
@@ -566,10 +563,10 @@ void test_mppc_enc(void)
CU_ASSERT(compress_rdp(enc, (uint8*) decompressed_rd5_data, data_len) != false);
if (enc->flags & PACKET_COMPRESSED)
{
- CU_ASSERT(decompress_rdp_5(&rdp, (uint8 *) enc->outputBuffer,
+ CU_ASSERT(decompress_rdp_5(rmppc, (uint8 *) enc->outputBuffer,
enc->bytes_in_opb, enc->flags, &roff, &rlen) != false);
CU_ASSERT(data_len == rlen);
- CU_ASSERT(memcmp(decompressed_rd5_data, &rdp.mppc->history_buf[roff], rlen) == 0);
+ CU_ASSERT(memcmp(decompressed_rd5_data, &rmppc->history_buf[roff], rlen) == 0);
}
else
{
@@ -590,5 +587,5 @@ void test_mppc_enc(void)
}
mppc_enc_free(enc);
- free(rdp.mppc->history_buf);
+ mppc_dec_free(rmppc);
}
@@ -0,0 +1,55 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Implements Microsoft Point to Point Compression (MPPC) protocol
+ *
+ * Copyright 2011 Laxmikant Rashinkar <LK.Rashinkar@gmail.com>
+ * Copyright Jiten Pathy
+ *
+ * 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 __MPPC_H
+#define __MPPC_H
+
+#include <freerdp/types.h>
+
+/* Compression Types */
+#define PACKET_COMPRESSED 0x20
+#define PACKET_AT_FRONT 0x40
+#define PACKET_FLUSHED 0x80
+#define PACKET_COMPR_TYPE_8K 0x00
+#define PACKET_COMPR_TYPE_64K 0x01
+#define PACKET_COMPR_TYPE_RDP6 0x02
+#define PACKET_COMPR_TYPE_RDP61 0x03
+#define CompressionTypeMask 0x0F
+
+#define RDP6_HISTORY_BUF_SIZE 65536
+#define RDP6_OFFSET_CACHE_SIZE 8
+
+struct rdp_mppc_dec
+{
+ uint8* history_buf;
+ uint16* offset_cache;
+ uint8* history_buf_end;
+ uint8* history_ptr;
+};
+
+int decompress_rdp(struct rdp_mppc_dec* dec, uint8* cbuf, int len, int ctype, uint32* roff, uint32* rlen);
+int decompress_rdp_4(struct rdp_mppc_dec* dec, uint8* cbuf, int len, int ctype, uint32* roff, uint32* rlen);
+int decompress_rdp_5(struct rdp_mppc_dec* dec, uint8* cbuf, int len, int ctype, uint32* roff, uint32* rlen);
+int decompress_rdp_6(struct rdp_mppc_dec* dec, uint8* cbuf, int len, int ctype, uint32* roff, uint32* rlen);
+int decompress_rdp_61(struct rdp_mppc_dec* dec, uint8* cbuf, int len, int ctype, uint32* roff, uint32* rlen);
+struct rdp_mppc_dec* mppc_dec_new(void);
+void mppc_dec_free(struct rdp_mppc_dec* dec);
+
+#endif
@@ -22,7 +22,6 @@
#define __MPPC_ENC_H
#include <freerdp/types.h>
-#include <freerdp/freerdp.h>
#define PROTO_RDP_40 1
#define PROTO_RDP_50 2
@@ -42,6 +42,8 @@ set(FREERDP_CODEC_SRCS
nsc_encode.c
nsc_encode.h
nsc_types.h
+ mppc_dec.c
+ mppc_enc.c
)
if(WITH_SSE2)
Oops, something went wrong.

0 comments on commit 6aa7eaf

Please sign in to comment.