summaryrefslogtreecommitdiffstats
path: root/tinySIGCOMP
diff options
context:
space:
mode:
Diffstat (limited to 'tinySIGCOMP')
-rwxr-xr-xtinySIGCOMP/src/adler32.c43
-rwxr-xr-xtinySIGCOMP/src/compress.c32
-rwxr-xr-xtinySIGCOMP/src/deflate.c580
-rwxr-xr-xtinySIGCOMP/src/deflate.h16
-rwxr-xr-xtinySIGCOMP/src/tcomp.c42
-rwxr-xr-xtinySIGCOMP/src/tcomp.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_buffer.c776
-rwxr-xr-xtinySIGCOMP/src/tcomp_buffer.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_compartment.c769
-rwxr-xr-xtinySIGCOMP/src/tcomp_compartment.h45
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressor.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressor_deflate.c331
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressor_deflate.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressor_dummy.c110
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressor_dummy.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressordata.c10
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressordata.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressordisp.c293
-rwxr-xr-xtinySIGCOMP/src/tcomp_compressordisp.h17
-rwxr-xr-xtinySIGCOMP/src/tcomp_decompressordisp.c586
-rwxr-xr-xtinySIGCOMP/src/tcomp_decompressordisp.h28
-rwxr-xr-xtinySIGCOMP/src/tcomp_deflatedata.c99
-rwxr-xr-xtinySIGCOMP/src/tcomp_deflatedata.ghost.c263
-rwxr-xr-xtinySIGCOMP/src/tcomp_deflatedata.h44
-rwxr-xr-xtinySIGCOMP/src/tcomp_deflatedata.zlib.c266
-rwxr-xr-xtinySIGCOMP/src/tcomp_dicts.c90
-rwxr-xr-xtinySIGCOMP/src/tcomp_dicts.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_headers_index.h8
-rwxr-xr-xtinySIGCOMP/src/tcomp_instructions.h88
-rwxr-xr-xtinySIGCOMP/src/tcomp_manager.c360
-rwxr-xr-xtinySIGCOMP/src/tcomp_manager.h8
-rwxr-xr-xtinySIGCOMP/src/tcomp_message.c541
-rwxr-xr-xtinySIGCOMP/src/tcomp_message.h43
-rwxr-xr-xtinySIGCOMP/src/tcomp_nack_codes.h68
-rwxr-xr-xtinySIGCOMP/src/tcomp_nackinfo.c259
-rwxr-xr-xtinySIGCOMP/src/tcomp_nackinfo.h67
-rwxr-xr-xtinySIGCOMP/src/tcomp_operands.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_params.c286
-rwxr-xr-xtinySIGCOMP/src/tcomp_params.h29
-rwxr-xr-xtinySIGCOMP/src/tcomp_reqfeed.c69
-rwxr-xr-xtinySIGCOMP/src/tcomp_reqfeed.h19
-rwxr-xr-xtinySIGCOMP/src/tcomp_result.c288
-rwxr-xr-xtinySIGCOMP/src/tcomp_result.h54
-rwxr-xr-xtinySIGCOMP/src/tcomp_rfc3485_dictionary_sip.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_rfc5049_sip.h8
-rwxr-xr-xtinySIGCOMP/src/tcomp_rfc5112_dictionary_presence.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_state.c245
-rwxr-xr-xtinySIGCOMP/src/tcomp_state.h37
-rwxr-xr-xtinySIGCOMP/src/tcomp_statehandler.c663
-rwxr-xr-xtinySIGCOMP/src/tcomp_statehandler.h31
-rwxr-xr-xtinySIGCOMP/src/tcomp_types.h6
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.bytecopy.c178
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.c907
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.h53
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.instructions.c2577
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.nack.c49
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.operands.c318
-rwxr-xr-xtinySIGCOMP/src/tcomp_udvm.statemanagment.c166
-rwxr-xr-xtinySIGCOMP/src/tinysigcomp_config.h14
-rwxr-xr-xtinySIGCOMP/src/trees.c402
-rwxr-xr-xtinySIGCOMP/src/trees.h214
-rwxr-xr-xtinySIGCOMP/src/zconf.h40
-rwxr-xr-xtinySIGCOMP/src/zlib.h36
-rwxr-xr-xtinySIGCOMP/src/zutil.c186
-rwxr-xr-xtinySIGCOMP/src/zutil.h54
-rwxr-xr-xtinySIGCOMP/test/rfc4465_torture_tests.h162
-rwxr-xr-xtinySIGCOMP/test/stdafx.c6
-rwxr-xr-xtinySIGCOMP/test/stdafx.h6
-rwxr-xr-xtinySIGCOMP/test/targetver.h10
-rwxr-xr-xtinySIGCOMP/test/test.c18
-rwxr-xr-xtinySIGCOMP/test/test_manager.h658
-rwxr-xr-xtinySIGCOMP/test/test_osc.h6
-rwxr-xr-xtinySIGCOMP/test/test_tortures.h2125
73 files changed, 8042 insertions, 7820 deletions
diff --git a/tinySIGCOMP/src/adler32.c b/tinySIGCOMP/src/adler32.c
index f7844d1..fe31833 100755
--- a/tinySIGCOMP/src/adler32.c
+++ b/tinySIGCOMP/src/adler32.c
@@ -56,9 +56,9 @@
/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
+uLong adler;
+const Bytef *buf;
+uInt len;
{
unsigned long sum2;
unsigned n;
@@ -70,17 +70,20 @@ uLong ZEXPORT adler32(adler, buf, len)
/* in case user likes doing a byte at a time, keep it fast */
if (len == 1) {
adler += buf[0];
- if (adler >= BASE)
+ if (adler >= BASE) {
adler -= BASE;
+ }
sum2 += adler;
- if (sum2 >= BASE)
+ if (sum2 >= BASE) {
sum2 -= BASE;
+ }
return adler | (sum2 << 16);
}
/* initial Adler-32 value (deferred check for len == 1 speed) */
- if (buf == Z_NULL)
+ if (buf == Z_NULL) {
return 1L;
+ }
/* in case short lengths are provided, keep it somewhat fast */
if (len < 16) {
@@ -88,8 +91,9 @@ uLong ZEXPORT adler32(adler, buf, len)
adler += *buf++;
sum2 += adler;
}
- if (adler >= BASE)
+ if (adler >= BASE) {
adler -= BASE;
+ }
MOD4(sum2); /* only added so many BASE's */
return adler | (sum2 << 16);
}
@@ -101,7 +105,8 @@ uLong ZEXPORT adler32(adler, buf, len)
do {
DO16(buf); /* 16 sums unrolled */
buf += 16;
- } while (--n);
+ }
+ while (--n);
MOD(adler);
MOD(sum2);
}
@@ -127,9 +132,9 @@ uLong ZEXPORT adler32(adler, buf, len)
/* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
+uLong adler1;
+uLong adler2;
+z_off_t len2;
{
unsigned long sum1;
unsigned long sum2;
@@ -142,10 +147,18 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 > BASE) sum2 -= BASE;
+ if (sum1 > BASE) {
+ sum1 -= BASE;
+ }
+ if (sum1 > BASE) {
+ sum1 -= BASE;
+ }
+ if (sum2 > (BASE << 1)) {
+ sum2 -= (BASE << 1);
+ }
+ if (sum2 > BASE) {
+ sum2 -= BASE;
+ }
return sum1 | (sum2 << 16);
}
#endif // HAS_ZLIB
diff --git a/tinySIGCOMP/src/compress.c b/tinySIGCOMP/src/compress.c
index ca01fbf..6a4e955 100755
--- a/tinySIGCOMP/src/compress.c
+++ b/tinySIGCOMP/src/compress.c
@@ -21,11 +21,11 @@
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
+Bytef *dest;
+uLongf *destLen;
+const Bytef *source;
+uLong sourceLen;
+int level;
{
z_stream stream;
int err;
@@ -34,18 +34,24 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
+ if ((uLong)stream.avail_in != sourceLen) {
+ return Z_BUF_ERROR;
+ }
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+ if ((uLong)stream.avail_out != *destLen) {
+ return Z_BUF_ERROR;
+ }
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
- if (err != Z_OK) return err;
+ if (err != Z_OK) {
+ return err;
+ }
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
@@ -61,10 +67,10 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
+Bytef *dest;
+uLongf *destLen;
+const Bytef *source;
+uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_BEST_SPEED);
}
@@ -74,7 +80,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
this function needs to be updated.
*/
uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
+uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
}
diff --git a/tinySIGCOMP/src/deflate.c b/tinySIGCOMP/src/deflate.c
index a3c208e..feffb39 100755
--- a/tinySIGCOMP/src/deflate.c
+++ b/tinySIGCOMP/src/deflate.c
@@ -53,7 +53,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
+ " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -86,8 +86,8 @@ local void flush_pending OF((z_streamp strm));
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
#ifndef FASTEST
#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
- uInt longest_match OF((deflate_state *s, IPos cur_match));
+void match_init OF((void)); /* asm code initialization */
+uInt longest_match OF((deflate_state *s, IPos cur_match));
#else
local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif
@@ -122,32 +122,34 @@ local void check_match OF((deflate_state *s, IPos start, IPos match,
* found for specific files.
*/
typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
+ ush good_length; /* reduce lazy search above this match length */
+ ush max_lazy; /* do not perform lazy search above this match length */
+ ush nice_length; /* quit search above this match length */
+ ush max_chain;
+ compress_func func;
} config;
#ifdef FASTEST
local const config configuration_table[2] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
+ /* good lazy nice chain */
+ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
+ /* 1 */ {4, 4, 8, 4, deflate_fast}
+}; /* max speed, no lazy matches */
#else
local const config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
+ /* good lazy nice chain */
+ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
+ /* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
+ /* 2 */ {4, 5, 16, 8, deflate_fast},
+ /* 3 */ {4, 6, 32, 32, deflate_fast},
+
+ /* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
+ /* 5 */ {8, 16, 32, 32, deflate_slow},
+ /* 6 */ {8, 16, 128, 128, deflate_slow},
+ /* 7 */ {8, 32, 128, 256, deflate_slow},
+ /* 8 */ {32, 128, 258, 1024, deflate_slow},
+ /* 9 */ {32, 258, 258, 4096, deflate_slow}
+}; /* max compression */
#endif
/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
@@ -159,7 +161,9 @@ local const config configuration_table[10] = {
/* result of memcmp for equal strings */
#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
+struct static_tree_desc_s {
+ int dummy;
+}; /* for buggy compilers */
#endif
/* ===========================================================================
@@ -203,10 +207,10 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
/* ========================================================================= */
int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
+z_streamp strm;
+int level;
+const char *version;
+int stream_size;
{
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
Z_DEFAULT_STRATEGY, version, stream_size);
@@ -215,15 +219,15 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size)
/* ========================================================================= */
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
+ version, stream_size)
+z_streamp strm;
+int level;
+int method;
+int windowBits;
+int memLevel;
+int strategy;
+const char *version;
+int stream_size;
{
deflate_state *s;
int wrap = 1;
@@ -235,22 +239,30 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
*/
if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
+ stream_size != sizeof(z_stream)) {
return Z_VERSION_ERROR;
}
- if (strm == Z_NULL) return Z_STREAM_ERROR;
+ if (strm == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
strm->msg = Z_NULL;
if (strm->zalloc == (alloc_func)0) {
strm->zalloc = zcalloc;
strm->opaque = (voidpf)0;
}
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ if (strm->zfree == (free_func)0) {
+ strm->zfree = zcfree;
+ }
#ifdef FASTEST
- if (level != 0) level = 1;
+ if (level != 0) {
+ level = 1;
+ }
#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
+ if (level == Z_DEFAULT_COMPRESSION) {
+ level = 6;
+ }
#endif
if (windowBits < 0) { /* suppress zlib wrapper */
@@ -264,13 +276,17 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
}
#endif
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
+ windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
+ strategy < 0 || strategy > Z_FIXED) {
return Z_STREAM_ERROR;
}
- if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
+ if (windowBits == 8) {
+ windowBits = 9; /* until 256-byte window bug fixed */
+ }
s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
+ if (s == Z_NULL) {
+ return Z_MEM_ERROR;
+ }
strm->state = (struct internal_state FAR *)s;
s->strm = strm;
@@ -296,7 +312,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
+ s->pending_buf == Z_NULL) {
s->status = FINISH_STATE;
strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
deflateEnd (strm);
@@ -314,9 +330,9 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
/* ========================================================================= */
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
+z_streamp strm;
+const Bytef *dictionary;
+uInt dictLength;
{
deflate_state *s;
uInt length = dictLength;
@@ -324,15 +340,19 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
IPos hash_head = 0;
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
- strm->state->wrap == 2 ||
- (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
+ strm->state->wrap == 2 ||
+ (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) {
return Z_STREAM_ERROR;
+ }
s = strm->state;
- if (s->wrap)
+ if (s->wrap) {
strm->adler = adler32(strm->adler, dictionary, dictLength);
+ }
- if (length < MIN_MATCH) return Z_OK;
+ if (length < MIN_MATCH) {
+ return Z_OK;
+ }
if (length > MAX_DIST(s)) {
length = MAX_DIST(s);
dictionary += dictLength - length; /* use the tail of the dictionary */
@@ -350,18 +370,20 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
for (n = 0; n <= length - MIN_MATCH; n++) {
INSERT_STRING(s, n, hash_head);
}
- if (hash_head) hash_head = 0; /* to make compiler happy */
+ if (hash_head) {
+ hash_head = 0; /* to make compiler happy */
+ }
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflateReset (strm)
- z_streamp strm;
+z_streamp strm;
{
deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
+ strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
return Z_STREAM_ERROR;
}
@@ -392,22 +414,28 @@ int ZEXPORT deflateReset (strm)
/* ========================================================================= */
int ZEXPORT deflateSetHeader (strm, head)
- z_streamp strm;
- gz_headerp head;
+z_streamp strm;
+gz_headerp head;
{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
+ if (strm == Z_NULL || strm->state == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
+ if (strm->state->wrap != 2) {
+ return Z_STREAM_ERROR;
+ }
strm->state->gzhead = head;
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
+z_streamp strm;
+int bits;
+int value;
{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (strm == Z_NULL || strm->state == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
strm->state->bi_valid = bits;
strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
return Z_OK;
@@ -415,21 +443,27 @@ int ZEXPORT deflatePrime (strm, bits, value)
/* ========================================================================= */
int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
+z_streamp strm;
+int level;
+int strategy;
{
deflate_state *s;
compress_func func;
int err = Z_OK;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (strm == Z_NULL || strm->state == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
s = strm->state;
#ifdef FASTEST
- if (level != 0) level = 1;
+ if (level != 0) {
+ level = 1;
+ }
#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
+ if (level == Z_DEFAULT_COMPRESSION) {
+ level = 6;
+ }
#endif
if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
return Z_STREAM_ERROR;
@@ -453,15 +487,17 @@ int ZEXPORT deflateParams(strm, level, strategy)
/* ========================================================================= */
int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
- z_streamp strm;
- int good_length;
- int max_lazy;
- int nice_length;
- int max_chain;
+z_streamp strm;
+int good_length;
+int max_lazy;
+int nice_length;
+int max_chain;
{
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (strm == Z_NULL || strm->state == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
s = strm->state;
s->good_match = good_length;
s->max_lazy_match = max_lazy;
@@ -488,8 +524,8 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
* seem onerous for output buffer allocation.
*/
uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
+z_streamp strm;
+uLong sourceLen;
{
deflate_state *s;
uLong destLen;
@@ -499,13 +535,15 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
/* if can't get parameters, return conservative bound */
- if (strm == Z_NULL || strm->state == Z_NULL)
+ if (strm == Z_NULL || strm->state == Z_NULL) {
return destLen;
+ }
/* if not default parameters, return conservative bound */
s = strm->state;
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
+ if (s->w_bits != 15 || s->hash_bits != 8 + 7) {
return destLen;
+ }
/* default settings: return tight bound for that case */
return compressBound(sourceLen);
@@ -517,8 +555,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
* pending_buf.
*/
local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
+deflate_state *s;
+uInt b;
{
put_byte(s, (Byte)(b >> 8));
put_byte(s, (Byte)(b & 0xff));
@@ -531,12 +569,16 @@ local void putShortMSB (s, b)
* (See also read_buf()).
*/
local void flush_pending(strm)
- z_streamp strm;
+z_streamp strm;
{
unsigned len = strm->state->pending;
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
+ if (len > strm->avail_out) {
+ len = strm->avail_out;
+ }
+ if (len == 0) {
+ return;
+ }
zmemcpy(strm->next_out, strm->state->pending_out, len);
strm->next_out += len;
@@ -551,24 +593,26 @@ local void flush_pending(strm)
/* ========================================================================= */
int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
+z_streamp strm;
+int flush;
{
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
+ flush > Z_FINISH || flush < 0) {
return Z_STREAM_ERROR;
}
s = strm->state;
if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
+ (strm->next_in == Z_NULL && strm->avail_in != 0) ||
+ (s->status == FINISH_STATE && flush != Z_FINISH)) {
ERR_RETURN(strm, Z_STREAM_ERROR);
}
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
+ if (strm->avail_out == 0) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
s->strm = strm; /* just in case */
old_flush = s->last_flush;
@@ -589,25 +633,25 @@ int ZEXPORT deflate (strm, flush)
put_byte(s, 0);
put_byte(s, 0);
put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
put_byte(s, OS_CODE);
s->status = BUSY_STATE;
}
else {
put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
+ (s->gzhead->hcrc ? 2 : 0) +
+ (s->gzhead->extra == Z_NULL ? 0 : 4) +
+ (s->gzhead->name == Z_NULL ? 0 : 8) +
+ (s->gzhead->comment == Z_NULL ? 0 : 16)
);
put_byte(s, (Byte)(s->gzhead->time & 0xff));
put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
put_byte(s, s->gzhead->os & 0xff);
if (s->gzhead->extra != NULL) {
put_byte(s, s->gzhead->extra_len & 0xff);
@@ -626,16 +670,22 @@ int ZEXPORT deflate (strm, flush)
uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
uInt level_flags;
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
+ if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) {
level_flags = 0;
- else if (s->level < 6)
+ }
+ else if (s->level < 6) {
level_flags = 1;
- else if (s->level == 6)
+ }
+ else if (s->level == 6) {
level_flags = 2;
- else
+ }
+ else {
level_flags = 3;
+ }
header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
+ if (s->strstart != 0) {
+ header |= PRESET_DICT;
+ }
header += 31 - (header % 31);
s->status = BUSY_STATE;
@@ -661,8 +711,9 @@ int ZEXPORT deflate (strm, flush)
s->pending - beg);
flush_pending(strm);
beg = s->pending;
- if (s->pending == s->pending_buf_size)
+ if (s->pending == s->pending_buf_size) {
break;
+ }
}
put_byte(s, s->gzhead->extra[s->gzindex]);
s->gzindex++;
@@ -675,8 +726,9 @@ int ZEXPORT deflate (strm, flush)
s->status = NAME_STATE;
}
}
- else
+ else {
s->status = NAME_STATE;
+ }
}
if (s->status == NAME_STATE) {
if (s->gzhead->name != NULL) {
@@ -697,7 +749,8 @@ int ZEXPORT deflate (strm, flush)
}
val = s->gzhead->name[s->gzindex++];
put_byte(s, val);
- } while (val != 0);
+ }
+ while (val != 0);
if (s->gzhead->hcrc && s->pending > beg)
strm->adler = crc32(strm->adler, s->pending_buf + beg,
s->pending - beg);
@@ -706,8 +759,9 @@ int ZEXPORT deflate (strm, flush)
s->status = COMMENT_STATE;
}
}
- else
+ else {
s->status = COMMENT_STATE;
+ }
}
if (s->status == COMMENT_STATE) {
if (s->gzhead->comment != NULL) {
@@ -728,20 +782,24 @@ int ZEXPORT deflate (strm, flush)
}
val = s->gzhead->comment[s->gzindex++];
put_byte(s, val);
- } while (val != 0);
+ }
+ while (val != 0);
if (s->gzhead->hcrc && s->pending > beg)
strm->adler = crc32(strm->adler, s->pending_buf + beg,
s->pending - beg);
- if (val == 0)
+ if (val == 0) {
s->status = HCRC_STATE;
+ }
}
- else
+ else {
s->status = HCRC_STATE;
+ }
}
if (s->status == HCRC_STATE) {
if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
+ if (s->pending + 2 > s->pending_buf_size) {
flush_pending(strm);
+ }
if (s->pending + 2 <= s->pending_buf_size) {
put_byte(s, (Byte)(strm->adler & 0xff));
put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
@@ -749,8 +807,9 @@ int ZEXPORT deflate (strm, flush)
s->status = BUSY_STATE;
}
}
- else
+ else {
s->status = BUSY_STATE;
+ }
}
#endif
@@ -768,12 +827,13 @@ int ZEXPORT deflate (strm, flush)
return Z_OK;
}
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
+ /* Make sure there is something to do and avoid duplicate consecutive
+ * flushes. For repeated and useless calls with Z_FINISH, we keep
+ * returning Z_STREAM_END instead of Z_BUF_ERROR.
+ */
+ }
+ else if (strm->avail_in == 0 && flush <= old_flush &&
+ flush != Z_FINISH) {
ERR_RETURN(strm, Z_BUF_ERROR);
}
@@ -785,7 +845,7 @@ int ZEXPORT deflate (strm, flush)
/* Start a new block or continue the current one.
*/
if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
+ (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
block_state bstate;
bstate = (*(configuration_table[s->level].func))(s, flush);
@@ -809,7 +869,8 @@ int ZEXPORT deflate (strm, flush)
if (bstate == block_done) {
if (flush == Z_PARTIAL_FLUSH) {
_tr_align(s);
- } else { /* FULL_FLUSH or SYNC_FLUSH */
+ }
+ else { /* FULL_FLUSH or SYNC_FLUSH */
_tr_stored_block(s, (char*)0, 0L, 0);
/* For a full flush, this empty block will be recognized
* as a special marker by inflate_sync().
@@ -820,15 +881,19 @@ int ZEXPORT deflate (strm, flush)
}
flush_pending(strm);
if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
+ s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
+ return Z_OK;
}
}
}
Assert(strm->avail_out > 0, "bug2");
- if (flush != Z_FINISH) return Z_OK;
- if (s->wrap <= 0) return Z_STREAM_END;
+ if (flush != Z_FINISH) {
+ return Z_OK;
+ }
+ if (s->wrap <= 0) {
+ return Z_STREAM_END;
+ }
/* Write the trailer */
#ifdef GZIP
@@ -852,27 +917,31 @@ int ZEXPORT deflate (strm, flush)
/* If avail_out is zero, the application will call deflate again
* to flush the rest.
*/
- if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
+ if (s->wrap > 0) {
+ s->wrap = -s->wrap; /* write the trailer only once! */
+ }
return s->pending != 0 ? Z_OK : Z_STREAM_END;
}
/* ========================================================================= */
int ZEXPORT deflateEnd (strm)
- z_streamp strm;
+z_streamp strm;
{
int status;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (strm == Z_NULL || strm->state == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
status = strm->state->status;
if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
+ status != EXTRA_STATE &&
+ status != NAME_STATE &&
+ status != COMMENT_STATE &&
+ status != HCRC_STATE &&
+ status != BUSY_STATE &&
+ status != FINISH_STATE) {
+ return Z_STREAM_ERROR;
}
/* Deallocate in reverse order of allocations: */
@@ -893,8 +962,8 @@ int ZEXPORT deflateEnd (strm)
* doesn't have enough memory anyway to duplicate compression states).
*/
int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
+z_streamp dest;
+z_streamp source;
{
#ifdef MAXSEG_64K
return Z_STREAM_ERROR;
@@ -913,7 +982,9 @@ int ZEXPORT deflateCopy (dest, source)
zmemcpy(dest, source, sizeof(z_stream));
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
+ if (ds == Z_NULL) {
+ return Z_MEM_ERROR;
+ }
dest->state = (struct internal_state FAR *) ds;
zmemcpy(ds, ss, sizeof(deflate_state));
ds->strm = dest;
@@ -925,7 +996,7 @@ int ZEXPORT deflateCopy (dest, source)
ds->pending_buf = (uchf *) overlay;
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
+ ds->pending_buf == Z_NULL) {
deflateEnd (dest);
return Z_MEM_ERROR;
}
@@ -955,14 +1026,18 @@ int ZEXPORT deflateCopy (dest, source)
* (See also flush_pending()).
*/
local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
+z_streamp strm;
+Bytef *buf;
+unsigned size;
{
unsigned len = strm->avail_in;
- if (len > size) len = size;
- if (len == 0) return 0;
+ if (len > size) {
+ len = size;
+ }
+ if (len == 0) {
+ return 0;
+ }
strm->avail_in -= len;
@@ -985,7 +1060,7 @@ local int read_buf(strm, buf, size)
* Initialize the "longest match" routines for a new zlib stream
*/
local void lm_init (s)
- deflate_state *s;
+deflate_state *s;
{
s->window_size = (ulg)2L*s->w_size;
@@ -1026,8 +1101,8 @@ local void lm_init (s)
* match.S. The code will be functionally equivalent.
*/
local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
+deflate_state *s;
+IPos cur_match; /* current match */
{
unsigned chain_length = s->max_chain_length;/* max hash chain length */
register Bytef *scan = s->window + s->strstart; /* current string */
@@ -1036,7 +1111,7 @@ local uInt longest_match(s, cur_match)
int best_len = s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
+ s->strstart - (IPos)MAX_DIST(s) : NIL;
/* Stop when cur_match becomes <= limit. To simplify the code,
* we prevent matches with the string of window index 0.
*/
@@ -1068,7 +1143,9 @@ local uInt longest_match(s, cur_match)
/* Do not look for matches beyond the end of the input. This is necessary
* to make deflate deterministic.
*/
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
+ if ((uInt)nice_match > s->lookahead) {
+ nice_match = s->lookahead;
+ }
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
@@ -1089,7 +1166,9 @@ local uInt longest_match(s, cur_match)
* UNALIGNED_OK if your compiler uses a different size.
*/
if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
+ *(ushf*)match != scan_start) {
+ continue;
+ }
/* It is not necessary to compare scan[2] and match[2] since they are
* always equal when the other bytes match, given that the hash keys
@@ -1103,16 +1182,19 @@ local uInt longest_match(s, cur_match)
Assert(scan[2] == match[2], "scan[2]?");
scan++, match++;
do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
+ }
+ while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ scan < strend);
/* The funny "do {}" generates better code on most compilers */
/* Here, scan <= window+strstart+257 */
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
+ if (*scan == *match) {
+ scan++;
+ }
len = (MAX_MATCH - 1) - (int)(strend-scan);
scan = strend - (MAX_MATCH-1);
@@ -1120,9 +1202,11 @@ local uInt longest_match(s, cur_match)
#else /* UNALIGNED_OK */
if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
+ match[best_len-1] != scan_end1 ||
+ *match != *scan ||
+ *++match != scan[1]) {
+ continue;
+ }
/* The check at best_len-1 can be removed because it will be made
* again later. (This heuristic is not always a win.)
@@ -1137,11 +1221,12 @@ local uInt longest_match(s, cur_match)
* the 256th check will be made at strstart+258.
*/
do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
+ }
+ while (*++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ scan < strend);
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
@@ -1153,7 +1238,9 @@ local uInt longest_match(s, cur_match)
if (len > best_len) {
s->match_start = cur_match;
best_len = len;
- if (len >= nice_match) break;
+ if (len >= nice_match) {
+ break;
+ }
#ifdef UNALIGNED_OK
scan_end = *(ushf*)(scan+best_len-1);
#else
@@ -1161,10 +1248,13 @@ local uInt longest_match(s, cur_match)
scan_end = scan[best_len];
#endif
}
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
+ }
+ while ((cur_match = prev[cur_match & wmask]) > limit
+ && --chain_length != 0);
- if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
+ if ((uInt)best_len <= s->lookahead) {
+ return (uInt)best_len;
+ }
return s->lookahead;
}
#endif /* ASMV */
@@ -1174,8 +1264,8 @@ local uInt longest_match(s, cur_match)
* Optimized version for level == 1 or strategy == Z_RLE only
*/
local uInt longest_match_fast(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
+deflate_state *s;
+IPos cur_match; /* current match */
{
register Bytef *scan = s->window + s->strstart; /* current string */
register Bytef *match; /* matched string */
@@ -1195,7 +1285,9 @@ local uInt longest_match_fast(s, cur_match)
/* Return failure if the match length is less than 2:
*/
- if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
+ if (match[0] != scan[0] || match[1] != scan[1]) {
+ return MIN_MATCH-1;
+ }
/* The check at best_len-1 can be removed because it will be made
* again later. (This heuristic is not always a win.)
@@ -1210,17 +1302,20 @@ local uInt longest_match_fast(s, cur_match)
* the 256th check will be made at strstart+258.
*/
do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
+ }
+ while (*++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ scan < strend);
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
len = MAX_MATCH - (int)(strend - scan);
- if (len < MIN_MATCH) return MIN_MATCH - 1;
+ if (len < MIN_MATCH) {
+ return MIN_MATCH - 1;
+ }
s->match_start = cur_match;
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
@@ -1231,9 +1326,9 @@ local uInt longest_match_fast(s, cur_match)
* Check that the match at match_start is indeed a match.
*/
local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
+deflate_state *s;
+IPos start, match;
+int length;
{
/* check that the match is indeed a match */
if (zmemcmp(s->window + match,
@@ -1242,12 +1337,16 @@ local void check_match(s, start, match, length)
start, match, length);
do {
fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
+ }
+ while (--length != 0);
z_error("invalid match");
}
if (z_verbose > 1) {
fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
+ do {
+ putc(s->window[start++], stderr);
+ }
+ while (--length != 0);
}
}
#else
@@ -1265,7 +1364,7 @@ local void check_match(s, start, match, length)
* option -- not supported here).
*/
local void fill_window(s)
- deflate_state *s;
+deflate_state *s;
{
register unsigned n, m;
register Posf *p;
@@ -1280,7 +1379,8 @@ local void fill_window(s)
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
more = wsize;
- } else if (more == (unsigned)(-1)) {
+ }
+ else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if
* strstart == 0 && lookahead == 1 (input done a byte at time)
*/
@@ -1310,7 +1410,8 @@ local void fill_window(s)
do {
m = *--p;
*p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
+ }
+ while (--n);
n = wsize;
#ifndef FASTEST
@@ -1321,11 +1422,14 @@ local void fill_window(s)
/* If n is not on any hash chain, prev[n] is garbage but
* its value will never be used.
*/
- } while (--n);
+ }
+ while (--n);
#endif
more += wsize;
}
- if (s->strm->avail_in == 0) return;
+ if (s->strm->avail_in == 0) {
+ return;
+ }
/* If there was no sliding:
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
@@ -1355,7 +1459,8 @@ local void fill_window(s)
* but this is not important since only literal bytes will be emitted.
*/
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
+ }
+ while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
}
/* ===========================================================================
@@ -1389,8 +1494,8 @@ local void fill_window(s)
* window to pending_buf.
*/
local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
+deflate_state *s;
+int flush;
{
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
* to pending_buf_size, and each stored block has a 5 byte header:
@@ -1411,9 +1516,13 @@ local block_state deflate_stored(s, flush)
s->block_start >= (long)s->w_size, "slide too late");
fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
+ if (s->lookahead == 0 && flush == Z_NO_FLUSH) {
+ return need_more;
+ }
- if (s->lookahead == 0) break; /* flush the current block */
+ if (s->lookahead == 0) {
+ break; /* flush the current block */
+ }
}
Assert(s->block_start >= 0L, "block gone");
@@ -1447,8 +1556,8 @@ local block_state deflate_stored(s, flush)
* matches. It is used only for the fast compression options.
*/
local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
+deflate_state *s;
+int flush;
{
IPos hash_head = NIL; /* head of the hash chain */
int bflush; /* set if current block must be flushed */
@@ -1464,7 +1573,9 @@ local block_state deflate_fast(s, flush)
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
return need_more;
}
- if (s->lookahead == 0) break; /* flush the current block */
+ if (s->lookahead == 0) {
+ break; /* flush the current block */
+ }
}
/* Insert the string window[strstart .. strstart+2] in the
@@ -1484,13 +1595,14 @@ local block_state deflate_fast(s, flush)
*/
#ifdef FASTEST
if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
- (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
+ (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
s->match_length = longest_match_fast (s, hash_head);
}
#else
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
+ }
+ else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
s->match_length = longest_match_fast (s, hash_head);
}
#endif
@@ -1509,7 +1621,7 @@ local block_state deflate_fast(s, flush)
*/
#ifndef FASTEST
if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
+ s->lookahead >= MIN_MATCH) {
s->match_length--; /* string at strstart already in table */
do {
s->strstart++;
@@ -1517,9 +1629,11 @@ local block_state deflate_fast(s, flush)
/* strstart never exceeds WSIZE-MAX_MATCH, so there are
* always MIN_MATCH bytes ahead.
*/
- } while (--s->match_length != 0);
+ }
+ while (--s->match_length != 0);
s->strstart++;
- } else
+ }
+ else
#endif
{
s->strstart += s->match_length;
@@ -1533,14 +1647,17 @@ local block_state deflate_fast(s, flush)
* matter since it will be recomputed at next deflate call.
*/
}
- } else {
+ }
+ else {
/* No match, output a literal byte */
Tracevv((stderr,"%c", s->window[s->strstart]));
_tr_tally_lit (s, s->window[s->strstart], bflush);
s->lookahead--;
s->strstart++;
}
- if (bflush) FLUSH_BLOCK(s, 0);
+ if (bflush) {
+ FLUSH_BLOCK(s, 0);
+ }
}
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
@@ -1553,8 +1670,8 @@ local block_state deflate_fast(s, flush)
* no better match at the next window position.
*/
local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
+deflate_state *s;
+int flush;
{
IPos hash_head = NIL; /* head of hash chain */
int bflush; /* set if current block must be flushed */
@@ -1571,7 +1688,9 @@ local block_state deflate_slow(s, flush)
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
return need_more;
}
- if (s->lookahead == 0) break; /* flush the current block */
+ if (s->lookahead == 0) {
+ break; /* flush the current block */
+ }
}
/* Insert the string window[strstart .. strstart+2] in the
@@ -1587,24 +1706,25 @@ local block_state deflate_slow(s, flush)
s->match_length = MIN_MATCH-1;
if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
+ s->strstart - hash_head <= MAX_DIST(s)) {
/* To simplify the code, we prevent matches with the string
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
+ }
+ else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
s->match_length = longest_match_fast (s, hash_head);
}
/* longest_match() or longest_match_fast() sets match_start */
if (s->match_length <= 5 && (s->strategy == Z_FILTERED
#if TOO_FAR <= 32767
- || (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR)
+ || (s->match_length == MIN_MATCH &&
+ s->strstart - s->match_start > TOO_FAR)
#endif
- )) {
+ )) {
/* If prev_match is also MIN_MATCH, match_start is garbage
* but we will ignore the current match anyway.
@@ -1635,14 +1755,18 @@ local block_state deflate_slow(s, flush)
if (++s->strstart <= max_insert) {
INSERT_STRING(s, s->strstart, hash_head);
}
- } while (--s->prev_length != 0);
+ }
+ while (--s->prev_length != 0);
s->match_available = 0;
s->match_length = MIN_MATCH-1;
s->strstart++;
- if (bflush) FLUSH_BLOCK(s, 0);
+ if (bflush) {
+ FLUSH_BLOCK(s, 0);
+ }
- } else if (s->match_available) {
+ }
+ else if (s->match_available) {
/* If there was no match at the previous position, output a
* single literal. If there was a match but the current match
* is longer, truncate the previous match to a single literal.
@@ -1654,8 +1778,11 @@ local block_state deflate_slow(s, flush)
}
s->strstart++;
s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
+ if (s->strm->avail_out == 0) {
+ return need_more;
+ }
+ }
+ else {
/* There is no previous match to compare with, wait for
* the next step to decide.
*/
@@ -1682,8 +1809,8 @@ local block_state deflate_slow(s, flush)
* deflate switches away from Z_RLE.)
*/
local block_state deflate_rle(s, flush)
- deflate_state *s;
- int flush;
+deflate_state *s;
+int flush;
{
int bflush; /* set if current block must be flushed */
uInt run; /* length of run */
@@ -1701,7 +1828,9 @@ local block_state deflate_rle(s, flush)
if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
return need_more;
}
- if (s->lookahead == 0) break; /* flush the current block */
+ if (s->lookahead == 0) {
+ break; /* flush the current block */
+ }
}
/* See how many times the previous byte repeats */
@@ -1711,9 +1840,11 @@ local block_state deflate_rle(s, flush)
scan = s->window + s->strstart - 1;
prev = *scan++;
do {
- if (*scan++ != prev)
+ if (*scan++ != prev) {
break;
- } while (++run < max);
+ }
+ }
+ while (++run < max);
}
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
@@ -1722,14 +1853,17 @@ local block_state deflate_rle(s, flush)
_tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
s->lookahead -= run;
s->strstart += run;
- } else {
+ }
+ else {
/* No match, output a literal byte */
Tracevv((stderr,"%c", s->window[s->strstart]));
_tr_tally_lit (s, s->window[s->strstart], bflush);
s->lookahead--;
s->strstart++;
}
- if (bflush) FLUSH_BLOCK(s, 0);
+ if (bflush) {
+ FLUSH_BLOCK(s, 0);
+ }
}
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
diff --git a/tinySIGCOMP/src/deflate.h b/tinySIGCOMP/src/deflate.h
index a4fbdfb..f79a2cf 100755
--- a/tinySIGCOMP/src/deflate.h
+++ b/tinySIGCOMP/src/deflate.h
@@ -105,7 +105,7 @@ typedef struct internal_state {
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
- /* used by deflate.c: */
+ /* used by deflate.c: */
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
@@ -188,7 +188,7 @@ typedef struct internal_state {
int nice_match; /* Stop searching when current match exceeds this */
- /* used by trees.c: */
+ /* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
@@ -279,7 +279,7 @@ typedef struct internal_state {
* distances are limited to MAX_DIST instead of WSIZE.
*/
- /* in trees.c */
+/* in trees.c */
void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
@@ -299,11 +299,11 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch _length_code[];
- extern uch _dist_code[];
+extern uch _length_code[];
+extern uch _dist_code[];
#else
- extern const uch _length_code[];
- extern const uch _dist_code[];
+extern const uch _length_code[];
+extern const uch _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
@@ -330,6 +330,6 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
#endif
#endif /* DEFLATE_H */
-
+
#endif // HAS_ZLIB
diff --git a/tinySIGCOMP/src/tcomp.c b/tinySIGCOMP/src/tcomp.c
index cfb2b50..bf4939c 100755
--- a/tinySIGCOMP/src/tcomp.c
+++ b/tinySIGCOMP/src/tcomp.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -37,36 +37,36 @@
* support for 3GPP IMS and OMA networks.
* This API is designed to efficiently work on embedded systems whith limited memory and low computing power.
*
-* As many operators have begun to commercially deploy IMS, the relevance of using SigComp to lower bandwidth usage will come quickly.
-* In my own opinion I think that most operators (especially those using RCS) will question how to reduce SIP signaling (registration, billing, presence, messaging …)
-* bandwidth usage (who will pay bits?).
-* These questions will especially concern using SIP (or all other text-based protocols) in wireless handsets as part of 2.5G, 3G and 4G cellular networks.
+* As many operators have begun to commercially deploy IMS, the relevance of using SigComp to lower bandwidth usage will come quickly.
+* In my own opinion I think that most operators (especially those using RCS) will question how to reduce SIP signaling (registration, billing, presence, messaging …)
+* bandwidth usage (who will pay bits?).
+* These questions will especially concern using SIP (or all other text-based protocols) in wireless handsets as part of 2.5G, 3G and 4G cellular networks.
*
* SigComp stands for Signaling Compression and has been defined in <a href="http://www.ietf.org/rfc/rfc3320.txt">RFC 3320</a> by the Internet Engineering Task Force (IETF) ROHC working group.
* <br> <br>
*
* @image html SigComp_Architecture.png "SigComp Architecture"
*
-* Many application protocols used for multimedia communications are text-based and engineered for bandwidth rich links. As a result the messages have not been optimized in
-* terms of size. For example, typical IMS/SIP messages range from a few hundred bytes up to two thousand bytes or more. For this reason, SigComp is mandatory for
-* 3GPP IMS netwoks and <a href="http://en.wikipedia.org/wiki/Push_to_Talk_over_Cellular">PoC systems</a>.
+* Many application protocols used for multimedia communications are text-based and engineered for bandwidth rich links. As a result the messages have not been optimized in
+* terms of size. For example, typical IMS/SIP messages range from a few hundred bytes up to two thousand bytes or more. For this reason, SigComp is mandatory for
+* 3GPP IMS netwoks and <a href="http://en.wikipedia.org/wiki/Push_to_Talk_over_Cellular">PoC systems</a>.
*
-* SigComp could also be useful for RCS (Rich Communication Suite) networks because of the size of the SIP packets (more than three thousand bytes for presence publication).
+* SigComp could also be useful for RCS (Rich Communication Suite) networks because of the size of the SIP packets (more than three thousand bytes for presence publication).
* Using SigComp in IMS/RCS context will reduce the round-trip over slow radio links.
*
* @par Supported OS
*
-* - Windows XX/Vista (Visual Studio 2005/2008 or Mingw32)
-* - Windows Mobile 5 and later (Visual Studio 2005/2008 or Mingw32ce/cegcc toolchain)
+* - Windows XX/Vista (Visual Studio 2005/2008 or Mingw32)
+* - Windows Mobile 5 and later (Visual Studio 2005/2008 or Mingw32ce/cegcc toolchain)
* - Symbian S60 (Carbide.c++ v2.0 with S60_3rd_FP2_SDK_v1.1)
* - Google Android
* - Mac OS X, iPhone (Xcode)
-* - All Linux, FreeBSD, ... (GCC 4.x)
+* - All Linux, FreeBSD, ... (GCC 4.x)
*
*
* @par FEATURES
*
-* The goal of this project is to provide a SigComp framework which:
+* The goal of this project is to provide a SigComp framework which:
*
* - Could be used as an external API or Framework
* - Highly portable (Coded in ANSI-C without any external dependencies)
@@ -116,19 +116,19 @@
*
* Compartment Identifier: Used in SIP messages (sigomp-id) and tinySigComp to allocate/deallocate memory associated
* to a compartment.
-* @code
+* @code
* #define COMPARTMENT_ID "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a475"
* @endcode
*
* Preparation:
* @code
* #define MAX_BUFFER_SIZE 0xFFFF
-*
+*
* int i = 0;
* tsk_size_t outLen = 0;
* tcomp_result_t *result = 0;
-* char outputBuffer[MAX_BUFFER_SIZE];
-*
+* char outputBuffer[MAX_BUFFER_SIZE];
+*
* tcomp_manager_handle_t *manager = 0;
* // Create SigComp manager
@@ -151,13 +151,13 @@
* Compress one or several messages using the code below:
* @code
* // Compress the SIP message
-* outLen = tcomp_manager_compress(manager,
+* outLen = tcomp_manager_compress(manager,
* COMPARTMENT_ID, strlen(COMPARTMENT_ID), // Compartment
* "REGISTER ...", strlen("REGISTER ..."), // Sip message to compress and it's size
* outputBuffer, sizeof(outputBuffer), // The ouptut buffer and it's size
* FALSE // Indicates whether to compress as stream (SCTP, TCP...) message or not
* );
-*
+*
* if(outLen){
* // send SigComp message over UDP connection
* sendto(sock, outputBuffer, outLen , 0, (SOCKADDR *)address, sizeof(address));
diff --git a/tinySIGCOMP/src/tcomp.h b/tinySIGCOMP/src/tcomp.h
index a49a9de..cd2208c 100755
--- a/tinySIGCOMP/src/tcomp.h
+++ b/tinySIGCOMP/src/tcomp.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_buffer.c b/tinySIGCOMP/src/tcomp_buffer.c
index b7bfd4d..06883ff 100755
--- a/tinySIGCOMP/src/tcomp_buffer.c
+++ b/tinySIGCOMP/src/tcomp_buffer.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -32,41 +32,40 @@
#include "tsk_memory.h"
#include "tsk_debug.h"
-#include <string.h>
+#include <string.h>
/** SigComp buffer.
*/
-typedef struct tcomp_buffer_s
-{
- TSK_DECLARE_OBJECT;
-
- tsk_size_t size; /**< The size of the buffer */
- uint8_t* lpbuffer; /**< Pointer to the buffer */
- tsk_size_t index_bytes; /**< Bytes (8bit size) cursor */
- tsk_size_t index_bits; /**< Bits (1-bit size) cursor */
- unsigned owner:1; /**< Indicates whether we are the owner of the buffer or not (external buffer) */
- uint8_t P_BIT; /**< P-BIT controller. */
+typedef struct tcomp_buffer_s {
+ TSK_DECLARE_OBJECT;
+
+ tsk_size_t size; /**< The size of the buffer */
+ uint8_t* lpbuffer; /**< Pointer to the buffer */
+ tsk_size_t index_bytes; /**< Bytes (8bit size) cursor */
+ tsk_size_t index_bits; /**< Bits (1-bit size) cursor */
+ unsigned owner:1; /**< Indicates whether we are the owner of the buffer or not (external buffer) */
+ uint8_t P_BIT; /**< P-BIT controller. */
}
tcomp_buffer_t;
tcomp_buffer_handle_t* tcomp_buffer_create(const void* data, tsk_size_t len)
{
- tcomp_buffer_t* buffer;
- if((buffer = tsk_object_new(tcomp_buffer_def_t))){
- buffer->owner = tsk_true;
- // The P-bit controls the order in which bits are passed from the dispatcher to the INPUT instructions.
- buffer->P_BIT = TCOMP_P_BIT_MSB_TO_LSB;
- if(data && len){
- tcomp_buffer_appendBuff(buffer, data, len);
- }
- }
- return buffer;
+ tcomp_buffer_t* buffer;
+ if((buffer = tsk_object_new(tcomp_buffer_def_t))) {
+ buffer->owner = tsk_true;
+ // The P-bit controls the order in which bits are passed from the dispatcher to the INPUT instructions.
+ buffer->P_BIT = TCOMP_P_BIT_MSB_TO_LSB;
+ if(data && len) {
+ tcomp_buffer_appendBuff(buffer, data, len);
+ }
+ }
+ return buffer;
}
tcomp_buffer_handle_t* tcomp_buffer_create_null()
{
- return tcomp_buffer_create(tsk_null, 0);
+ return tcomp_buffer_create(tsk_null, 0);
}
/**Compares two sigomp buffers.
@@ -76,11 +75,11 @@ tcomp_buffer_handle_t* tcomp_buffer_create_null()
*/
tsk_bool_t tcomp_buffer_equals(const tcomp_buffer_handle_t* handle1, const tcomp_buffer_handle_t* handle2)
{
- if( tcomp_buffer_getSize(handle1) == tcomp_buffer_getSize(handle2) ){
- return tcomp_buffer_startsWith(handle1, handle2);
- }
+ if( tcomp_buffer_getSize(handle1) == tcomp_buffer_getSize(handle2) ) {
+ return tcomp_buffer_startsWith(handle1, handle2);
+ }
- return tsk_false;
+ return tsk_false;
}
@@ -91,20 +90,20 @@ tsk_bool_t tcomp_buffer_equals(const tcomp_buffer_handle_t* handle1, const tcomp
*/
tsk_bool_t tcomp_buffer_startsWith(const tcomp_buffer_handle_t* handle1, const tcomp_buffer_handle_t* handle2) /*const*/
{
- tsk_size_t i;
- tcomp_buffer_t* buffer1 = (tcomp_buffer_t*)handle1;
- tcomp_buffer_t* buffer2 = (tcomp_buffer_t*)handle2;
-
- if(buffer1->size < buffer2->size){
- return tsk_false;
- }
-
- for(i = 0; i< buffer2->size; i++){
- if(buffer1->lpbuffer[i] != buffer2->lpbuffer[i]){
- return tsk_false;
- }
- }
- return tsk_true;
+ tsk_size_t i;
+ tcomp_buffer_t* buffer1 = (tcomp_buffer_t*)handle1;
+ tcomp_buffer_t* buffer2 = (tcomp_buffer_t*)handle2;
+
+ if(buffer1->size < buffer2->size) {
+ return tsk_false;
+ }
+
+ for(i = 0; i< buffer2->size; i++) {
+ if(buffer1->lpbuffer[i] != buffer2->lpbuffer[i]) {
+ return tsk_false;
+ }
+ }
+ return tsk_true;
}
/**Gets a readonly pointer to the internal buffer.
@@ -114,14 +113,14 @@ tsk_bool_t tcomp_buffer_startsWith(const tcomp_buffer_handle_t* handle1, const t
*/
const uint8_t* tcomp_buffer_getReadOnlyBufferAtPos(const tcomp_buffer_handle_t* handle, tsk_size_t position)/*const*/
{
- if(handle){
- return (((tcomp_buffer_t*)handle)->lpbuffer + position);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return tsk_null;
+ if(handle) {
+ return (((tcomp_buffer_t*)handle)->lpbuffer + position);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return tsk_null;
}
/**Gets a read/write pointer to the internal buffer.
@@ -131,18 +130,18 @@ const uint8_t* tcomp_buffer_getReadOnlyBufferAtPos(const tcomp_buffer_handle_t*
*/
uint8_t* tcomp_buffer_getBufferAtPos(const tcomp_buffer_handle_t* handle, tsk_size_t position)
{
- if(handle){
- if(position && ((tcomp_buffer_t*)handle)->size <= position){
- TSK_DEBUG_ERROR("%u <= %u", ((tcomp_buffer_t*)handle)->size, position);
- return tsk_null;
- }
- return (((tcomp_buffer_t*)handle)->lpbuffer + position);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return tsk_null;
+ if(handle) {
+ if(position && ((tcomp_buffer_t*)handle)->size <= position) {
+ TSK_DEBUG_ERROR("%u <= %u", ((tcomp_buffer_t*)handle)->size, position);
+ return tsk_null;
+ }
+ return (((tcomp_buffer_t*)handle)->lpbuffer + position);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return tsk_null;
}
@@ -151,14 +150,14 @@ uint8_t* tcomp_buffer_getBufferAtPos(const tcomp_buffer_handle_t* handle, tsk_si
*/
tsk_size_t tcomp_buffer_getSize(const tcomp_buffer_handle_t* handle) /*const*/
{
- if(handle){
- return ((tcomp_buffer_t*)handle)->size;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return 0;
+ if(handle) {
+ return ((tcomp_buffer_t*)handle)->size;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return 0;
}
/**Gets the remainning bits.
@@ -166,16 +165,16 @@ tsk_size_t tcomp_buffer_getSize(const tcomp_buffer_handle_t* handle) /*const*/
*/
tsk_size_t tcomp_buffer_getRemainingBits(const tcomp_buffer_handle_t* handle) /*const*/
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- tsk_ssize_t result = ((buffer->size * 8) - ((buffer->index_bytes * 8) + buffer->index_bits));
- return (result < 0) ? 0: result;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return 0;
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ tsk_ssize_t result = ((buffer->size * 8) - ((buffer->index_bytes * 8) + buffer->index_bits));
+ return (result < 0) ? 0: result;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return 0;
}
/**Reads @a size bytes.
@@ -185,24 +184,24 @@ tsk_size_t tcomp_buffer_getRemainingBits(const tcomp_buffer_handle_t* handle) /*
*/
uint8_t* tcomp_buffer_readBytes(tcomp_buffer_handle_t* handle, tsk_size_t length)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- tsk_size_t old_index;
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ tsk_size_t old_index;
- if((buffer->index_bytes + length) > (buffer->size)) {
- return tsk_null;
- }
+ if((buffer->index_bytes + length) > (buffer->size)) {
+ return tsk_null;
+ }
- old_index = buffer->index_bytes;
- buffer->index_bytes += length;
+ old_index = buffer->index_bytes;
+ buffer->index_bytes += length;
- return tcomp_buffer_getBufferAtPos(handle, old_index);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ return tcomp_buffer_getBufferAtPos(handle, old_index);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
- return tsk_null;
+ return tsk_null;
}
/**Reads the internal buffer from LSB to MSB as per RFC 3320 subclause 8.2.
@@ -212,35 +211,35 @@ uint8_t* tcomp_buffer_readBytes(tcomp_buffer_handle_t* handle, tsk_size_t length
*/
uint32_t tcomp_buffer_readLsbToMsb(tcomp_buffer_handle_t* handle, tsk_size_t length)
{
- // UDV Memory is always MSB first
- // MSB <-- LSB
- // FIXME: use mask
- if(handle)
- {
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- uint8_t pos = 0;
- char* end;
- uint32_t result_val = 0;
- char result_str[16]; memset(result_str, 0, 16);
- while(pos < length){
- result_str[pos++] = (buffer->lpbuffer[buffer->index_bytes]
- &(1 << (buffer->index_bits))) ? '1' : '0';
- if(++buffer->index_bits == 8){
- buffer->index_bytes++;
- buffer->index_bits = 0;
- }
- }
-
- end = (result_str+length);
- result_val = (uint32_t)strtol(result_str, &end, 2);
-
- return result_val;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return 0;
+ // UDV Memory is always MSB first
+ // MSB <-- LSB
+ // FIXME: use mask
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ uint8_t pos = 0;
+ char* end;
+ uint32_t result_val = 0;
+ char result_str[16];
+ memset(result_str, 0, 16);
+ while(pos < length) {
+ result_str[pos++] = (buffer->lpbuffer[buffer->index_bytes]
+ &(1 << (buffer->index_bits))) ? '1' : '0';
+ if(++buffer->index_bits == 8) {
+ buffer->index_bytes++;
+ buffer->index_bits = 0;
+ }
+ }
+
+ end = (result_str+length);
+ result_val = (uint32_t)strtol(result_str, &end, 2);
+
+ return result_val;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return 0;
}
/**Reads the internal buffer from MSB to LSB as per RFC 3320 subclause 8.2.
@@ -250,35 +249,36 @@ uint32_t tcomp_buffer_readLsbToMsb(tcomp_buffer_handle_t* handle, tsk_size_t len
*/
uint32_t tcomp_buffer_readMsbToLsb(tcomp_buffer_handle_t* handle, tsk_size_t length)
{
- // UDV Memory is always MSB first
- // MSB --> LSB
- // FIXME: use mask
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- uint8_t pos = 0;
- char* end;
- uint32_t result_val = 0;
- char result_str[16]; memset(result_str, 0, 16);
-
- while(pos < length){
- result_str[pos++] = (buffer->lpbuffer[buffer->index_bytes]
- &(128 >> (buffer->index_bits))) ? '1' : '0';
- if(++buffer->index_bits == 8){
- buffer->index_bytes++;
- buffer->index_bits = 0;
- }
- }
-
- end = (result_str + length);
- result_val = (uint32_t)strtol(result_str, &end, 2);
-
- return result_val;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return 0;
+ // UDV Memory is always MSB first
+ // MSB --> LSB
+ // FIXME: use mask
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ uint8_t pos = 0;
+ char* end;
+ uint32_t result_val = 0;
+ char result_str[16];
+ memset(result_str, 0, 16);
+
+ while(pos < length) {
+ result_str[pos++] = (buffer->lpbuffer[buffer->index_bytes]
+ &(128 >> (buffer->index_bits))) ? '1' : '0';
+ if(++buffer->index_bits == 8) {
+ buffer->index_bytes++;
+ buffer->index_bits = 0;
+ }
+ }
+
+ end = (result_str + length);
+ result_val = (uint32_t)strtol(result_str, &end, 2);
+
+ return result_val;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return 0;
}
/**Discards bits as per RFC 3320 subclause 8.2.
@@ -286,16 +286,16 @@ uint32_t tcomp_buffer_readMsbToLsb(tcomp_buffer_handle_t* handle, tsk_size_t len
*/
void tcomp_buffer_discardBits(tcomp_buffer_handle_t* handle)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- if(buffer->index_bits){
- buffer->index_bits=0;
- buffer->index_bytes++;
- }
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ if(buffer->index_bits) {
+ buffer->index_bits=0;
+ buffer->index_bytes++;
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
}
/**Discards last bytes as per RFC 3320 subclause 8.2.
@@ -304,18 +304,18 @@ void tcomp_buffer_discardBits(tcomp_buffer_handle_t* handle)
*/
void tcomp_buffer_discardLastBytes(tcomp_buffer_handle_t* handle, uint32_t count)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- if(buffer->size > count){
- buffer->size -= count;
- }
- else{
- tcomp_buffer_freeBuff(handle);
- }
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ if(buffer->size > count) {
+ buffer->size -= count;
+ }
+ else {
+ tcomp_buffer_freeBuff(handle);
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
}
/**Allocs the internal buffer.
@@ -324,25 +324,25 @@ void tcomp_buffer_discardLastBytes(tcomp_buffer_handle_t* handle, uint32_t count
*/
void tcomp_buffer_allocBuff(tcomp_buffer_handle_t* handle, tsk_size_t size)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- if(!buffer->owner){
- TSK_DEBUG_ERROR("The SigComp is not the owner of the internal buffer to alloc.");
- return;
- }
- if(!size){
- TSK_DEBUG_WARN("Cannot allocate zero bytes.");
- return;
- }
- buffer->index_bits = buffer->index_bytes = 0;
- buffer->size = 0;
- if((buffer->lpbuffer = tsk_realloc(buffer->lpbuffer, size))){
- buffer->size = size;
- }
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ if(!buffer->owner) {
+ TSK_DEBUG_ERROR("The SigComp is not the owner of the internal buffer to alloc.");
+ return;
+ }
+ if(!size) {
+ TSK_DEBUG_WARN("Cannot allocate zero bytes.");
+ return;
+ }
+ buffer->index_bits = buffer->index_bytes = 0;
+ buffer->size = 0;
+ if((buffer->lpbuffer = tsk_realloc(buffer->lpbuffer, size))) {
+ buffer->size = size;
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
}
/**Adds a buffer as a reference (not owned).
@@ -352,22 +352,22 @@ void tcomp_buffer_allocBuff(tcomp_buffer_handle_t* handle, tsk_size_t size)
*/
void tcomp_buffer_referenceBuff(tcomp_buffer_handle_t* handle, uint8_t* externalBuff, tsk_size_t size)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- if(buffer->size && buffer->owner){
- TSK_DEBUG_ERROR("The SigComp handle already hold an internal buffer.");
- return;
- }
-
- buffer->size = size;
- buffer->lpbuffer = externalBuff;
- buffer->index_bytes = 0;
- buffer->index_bits = 0;
- buffer->owner = 0;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ if(buffer->size && buffer->owner) {
+ TSK_DEBUG_ERROR("The SigComp handle already hold an internal buffer.");
+ return;
+ }
+
+ buffer->size = size;
+ buffer->lpbuffer = externalBuff;
+ buffer->index_bytes = 0;
+ buffer->index_bits = 0;
+ buffer->owner = 0;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
}
/**Appends data to our internal buffer.
@@ -378,39 +378,39 @@ void tcomp_buffer_referenceBuff(tcomp_buffer_handle_t* handle, uint8_t* external
*/
tsk_bool_t tcomp_buffer_appendBuff(tcomp_buffer_handle_t* handle, const void* data, tsk_size_t size)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- tsk_size_t oldSize = buffer->size;
- tsk_size_t newSize = (oldSize + size);
- {
- // realloc buffer
- if(!buffer->size){
- buffer->lpbuffer = (uint8_t*)tsk_calloc(1, newSize);
- }
- else{
- buffer->lpbuffer = (uint8_t*)tsk_realloc(buffer->lpbuffer, newSize);
- }
- }
-
- if(!buffer->lpbuffer){
- return tsk_false;
- }
-
- if(data){
- memcpy((buffer->lpbuffer+oldSize), data, size);
- }
- else{
- memset((buffer->lpbuffer+oldSize), 0, size);
- }
-
- buffer->size = newSize;
- return tsk_true;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return tsk_false;
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ tsk_size_t oldSize = buffer->size;
+ tsk_size_t newSize = (oldSize + size);
+ {
+ // realloc buffer
+ if(!buffer->size) {
+ buffer->lpbuffer = (uint8_t*)tsk_calloc(1, newSize);
+ }
+ else {
+ buffer->lpbuffer = (uint8_t*)tsk_realloc(buffer->lpbuffer, newSize);
+ }
+ }
+
+ if(!buffer->lpbuffer) {
+ return tsk_false;
+ }
+
+ if(data) {
+ memcpy((buffer->lpbuffer+oldSize), data, size);
+ }
+ else {
+ memset((buffer->lpbuffer+oldSize), 0, size);
+ }
+
+ buffer->size = newSize;
+ return tsk_true;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return tsk_false;
}
/**Removes @a size bytes from the internal buffer.
@@ -421,34 +421,36 @@ tsk_bool_t tcomp_buffer_appendBuff(tcomp_buffer_handle_t* handle, const void* da
*/
tsk_bool_t tcomp_buffer_removeBuff(tcomp_buffer_handle_t* handle, tsk_size_t pos, tsk_size_t size)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- tsk_size_t oldSize, newSize;
-
- if(((pos + size) > buffer->size)) size = (buffer->size - pos);
- memcpy((buffer->lpbuffer + pos), (buffer->lpbuffer + pos + size), (buffer->size - (pos + size)));
-
- oldSize = buffer->size;
- newSize = (oldSize - size);
- {
- if(!(buffer->size)){
- buffer->lpbuffer = (uint8_t*)tsk_calloc(1, newSize);
- }
- else{
- buffer->lpbuffer = (uint8_t*)tsk_realloc(buffer->lpbuffer, newSize);
- }
- }
- if(buffer->lpbuffer){
- buffer->size = newSize;
- return tsk_true;
- }
- return tsk_false;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return tsk_false;
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ tsk_size_t oldSize, newSize;
+
+ if(((pos + size) > buffer->size)) {
+ size = (buffer->size - pos);
+ }
+ memcpy((buffer->lpbuffer + pos), (buffer->lpbuffer + pos + size), (buffer->size - (pos + size)));
+
+ oldSize = buffer->size;
+ newSize = (oldSize - size);
+ {
+ if(!(buffer->size)) {
+ buffer->lpbuffer = (uint8_t*)tsk_calloc(1, newSize);
+ }
+ else {
+ buffer->lpbuffer = (uint8_t*)tsk_realloc(buffer->lpbuffer, newSize);
+ }
+ }
+ if(buffer->lpbuffer) {
+ buffer->size = newSize;
+ return tsk_true;
+ }
+ return tsk_false;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return tsk_false;
}
/**Free the internal buffer.
@@ -456,16 +458,16 @@ tsk_bool_t tcomp_buffer_removeBuff(tcomp_buffer_handle_t* handle, tsk_size_t pos
*/
void tcomp_buffer_freeBuff(tcomp_buffer_handle_t* handle)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- if(buffer->lpbuffer && buffer->size && buffer->owner) {
- tsk_free((void**)&(buffer->lpbuffer));
- }
- buffer->size = buffer->index_bytes = buffer->index_bits = 0;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ if(buffer->lpbuffer && buffer->size && buffer->owner) {
+ tsk_free((void**)&(buffer->lpbuffer));
+ }
+ buffer->size = buffer->index_bytes = buffer->index_bits = 0;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
}
/**Gets the bytes cursor position.
@@ -474,14 +476,14 @@ void tcomp_buffer_freeBuff(tcomp_buffer_handle_t* handle)
*/
tsk_size_t* tcomp_buffer_getIndexBytes(const tcomp_buffer_handle_t* handle)
{
- if(handle){
- return &(((tcomp_buffer_t*)handle)->index_bytes);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return 0;
+ if(handle) {
+ return &(((tcomp_buffer_t*)handle)->index_bytes);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return 0;
}
/**Gets the bits cursor position.
@@ -490,14 +492,14 @@ tsk_size_t* tcomp_buffer_getIndexBytes(const tcomp_buffer_handle_t* handle)
*/
tsk_size_t* tcomp_buffer_getIndexBits(const tcomp_buffer_handle_t* handle)
{
- if(handle){
- return &(((tcomp_buffer_t*)handle)->index_bits);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return tsk_null;
+ if(handle) {
+ return &(((tcomp_buffer_t*)handle)->index_bits);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return tsk_null;
}
/**Gets the P-bit controller value.
@@ -509,45 +511,44 @@ tsk_size_t* tcomp_buffer_getIndexBits(const tcomp_buffer_handle_t* handle)
*/
uint8_t* tcomp_buffer_getP_BIT(const tcomp_buffer_handle_t* handle)
{
- if(handle){
- return &(((tcomp_buffer_t*)handle)->P_BIT);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
-
- return tsk_null;
+ if(handle) {
+ return &(((tcomp_buffer_t*)handle)->P_BIT);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
+
+ return tsk_null;
}
/**Creates a random HASH number.
*/
uint64_t tcomp_buffer_createHash(const void *data, tsk_size_t len)
{
- if(!data || !len){
- TSK_DEBUG_ERROR("Null data.");
- return 0;
- }
- {
+ if(!data || !len) {
+ TSK_DEBUG_ERROR("Null data.");
+ return 0;
+ }
+ {
#define PRIME_1 500237
#define PRIME_2 700241
- uint64_t hash = 0;
- uint8_t* strid = (uint8_t*)data;
-
- /* Generate Hash code from id */
- {
- uint64_t b = PRIME_1, a = PRIME_2;
- tsk_size_t i;
- for(i = 0; i < len; strid++, i++)
- {
- hash = hash * a + (*strid);
- a = a * b;
- }
- }
- return hash;
+ uint64_t hash = 0;
+ uint8_t* strid = (uint8_t*)data;
+
+ /* Generate Hash code from id */
+ {
+ uint64_t b = PRIME_1, a = PRIME_2;
+ tsk_size_t i;
+ for(i = 0; i < len; strid++, i++) {
+ hash = hash * a + (*strid);
+ a = a * b;
+ }
+ }
+ return hash;
#undef PRIME_1
#undef PRIME_2
- }
+ }
}
/**Prints the internal buffer.
@@ -558,43 +559,45 @@ void tcomp_buffer_nprint(const tcomp_buffer_handle_t* handle, tsk_ssize_t size)
{
#if defined(_DEBUG) || defined(DEBUG)
- if(handle){
- tsk_size_t i, tsk_size_to_print;
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
- tsk_size_to_print = (size<0) ? buffer->size : size;
-
- if( !tsk_size_to_print || !buffer->lpbuffer) return;
-
- for(i = 0; i < tsk_size_to_print; i+=2){
- char s[10];
- uint32_t value;
- memset(s, 0, 10);
-
- if((i+1) == tsk_size_to_print){
- // last 2-byte lay in 1byte
- value = buffer->lpbuffer[i];
+ if(handle) {
+ tsk_size_t i, tsk_size_to_print;
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+ tsk_size_to_print = (size<0) ? buffer->size : size;
+
+ if( !tsk_size_to_print || !buffer->lpbuffer) {
+ return;
+ }
+
+ for(i = 0; i < tsk_size_to_print; i+=2) {
+ char s[10];
+ uint32_t value;
+ memset(s, 0, 10);
+
+ if((i+1) == tsk_size_to_print) {
+ // last 2-byte lay in 1byte
+ value = buffer->lpbuffer[i];
#if 0
- sprintf_s(s, 10, i?"%0.2x":"0x%0.2x", value);
+ sprintf_s(s, 10, i?"%0.2x":"0x%0.2x", value);
#else
- sprintf(s, i ? "%0.2x" : "0x%0.2x", value);
+ sprintf(s, i ? "%0.2x" : "0x%0.2x", value);
#endif
- }
- else{
- uint8_t *b_ptr = tcomp_buffer_getBufferAtPos(handle, i);
- value = TSK_BINARY_GET_2BYTES(b_ptr);
+ }
+ else {
+ uint8_t *b_ptr = tcomp_buffer_getBufferAtPos(handle, i);
+ value = TSK_BINARY_GET_2BYTES(b_ptr);
#if 0
- sprintf_s(s, 10, i?"%0.4x":"0x%0.4x", value);
+ sprintf_s(s, 10, i?"%0.4x":"0x%0.4x", value);
#else
- sprintf(s, i?"%0.4x":"0x%0.4x", value);
+ sprintf(s, i?"%0.4x":"0x%0.4x", value);
#endif
- }
- printf("%s ", s);
- }
- printf("\n");
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ }
+ printf("%s ", s);
+ }
+ printf("\n");
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
#endif
}
@@ -603,18 +606,18 @@ void tcomp_buffer_nprint(const tcomp_buffer_handle_t* handle, tsk_ssize_t size)
*/
void tcomp_buffer_reset(tcomp_buffer_handle_t* handle)
{
- if(handle){
- tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
-
- buffer->index_bytes = 0;
- buffer->index_bits = 0;
- if(buffer->lpbuffer){
- memset(buffer->lpbuffer, 0, buffer->size);
- }
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle");
- }
+ if(handle) {
+ tcomp_buffer_t* buffer = (tcomp_buffer_t*)handle;
+
+ buffer->index_bytes = 0;
+ buffer->index_bits = 0;
+ if(buffer->lpbuffer) {
+ memset(buffer->lpbuffer, 0, buffer->size);
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle");
+ }
}
@@ -631,31 +634,30 @@ void tcomp_buffer_reset(tcomp_buffer_handle_t* handle)
//
static tsk_object_t* tcomp_buffer_ctor(tsk_object_t *self, va_list * app)
{
- tcomp_buffer_t* buffer = self;
- if(buffer){
- }
- return self;
+ tcomp_buffer_t* buffer = self;
+ if(buffer) {
+ }
+ return self;
}
static tsk_object_t* tcomp_buffer_dtor(tsk_object_t *self)
{
- tcomp_buffer_t* buffer = self;
- if(buffer){
- tcomp_buffer_freeBuff(buffer);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp handle.");
- }
-
- return self;
+ tcomp_buffer_t* buffer = self;
+ if(buffer) {
+ tcomp_buffer_freeBuff(buffer);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp handle.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_buffer_def_s =
-{
- sizeof(tcomp_buffer_t),
- tcomp_buffer_ctor,
- tcomp_buffer_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_buffer_def_s = {
+ sizeof(tcomp_buffer_t),
+ tcomp_buffer_ctor,
+ tcomp_buffer_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_buffer_def_t = &tcomp_buffer_def_s;
diff --git a/tinySIGCOMP/src/tcomp_buffer.h b/tinySIGCOMP/src/tcomp_buffer.h
index d89b691..9b41125 100755
--- a/tinySIGCOMP/src/tcomp_buffer.h
+++ b/tinySIGCOMP/src/tcomp_buffer.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_compartment.c b/tinySIGCOMP/src/tcomp_compartment.c
index 5d774a2..28378a9 100755
--- a/tinySIGCOMP/src/tcomp_compartment.c
+++ b/tinySIGCOMP/src/tcomp_compartment.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -40,226 +40,226 @@ static void _tcomp_compartment_freeState(tcomp_compartment_t *compartment, tcomp
tcomp_compartment_t* tcomp_compartment_create(uint64_t id, uint32_t sigCompParameters, tsk_bool_t useOnlyACKedStates)
{
- tcomp_compartment_t *compartment;
- if((compartment = tsk_object_new(tcomp_compartment_def_t))){
-
-
- /*
- +---+---+---+---+---+---+---+---+
- | cpb | dms | sms |
- +---+---+---+---+---+---+---+---+
- | SigComp_version |
- +---+---+---+---+---+---+---+---+
- */
-
- // I always assume that remote params are equal to local params
-
- /* Identifier */
- compartment->identifier = id;
-
- /* Remote parameters */
- compartment->remote_parameters = tcomp_params_create();
- tcomp_params_setParameters(compartment->remote_parameters, sigCompParameters);
-
- /* Local parameters */
- compartment->local_parameters = tcomp_params_create();
- tcomp_params_setParameters(compartment->local_parameters, sigCompParameters);
-
- /* Total size */
- compartment->total_memory_size = compartment->total_memory_left = compartment->local_parameters->smsValue;
-
- /* Empty list. */
- compartment->nacks = tsk_list_create();
-
- /* Empty list. */
- compartment->local_states = tsk_list_create();
-
- /* Whether to use only ACKed states */
- compartment->useOnlyACKedStates = useOnlyACKedStates;
- }
- else{
- TSK_DEBUG_ERROR("Null Compartment");
- }
-
- return compartment;
+ tcomp_compartment_t *compartment;
+ if((compartment = tsk_object_new(tcomp_compartment_def_t))) {
+
+
+ /*
+ +---+---+---+---+---+---+---+---+
+ | cpb | dms | sms |
+ +---+---+---+---+---+---+---+---+
+ | SigComp_version |
+ +---+---+---+---+---+---+---+---+
+ */
+
+ // I always assume that remote params are equal to local params
+
+ /* Identifier */
+ compartment->identifier = id;
+
+ /* Remote parameters */
+ compartment->remote_parameters = tcomp_params_create();
+ tcomp_params_setParameters(compartment->remote_parameters, sigCompParameters);
+
+ /* Local parameters */
+ compartment->local_parameters = tcomp_params_create();
+ tcomp_params_setParameters(compartment->local_parameters, sigCompParameters);
+
+ /* Total size */
+ compartment->total_memory_size = compartment->total_memory_left = compartment->local_parameters->smsValue;
+
+ /* Empty list. */
+ compartment->nacks = tsk_list_create();
+
+ /* Empty list. */
+ compartment->local_states = tsk_list_create();
+
+ /* Whether to use only ACKed states */
+ compartment->useOnlyACKedStates = useOnlyACKedStates;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null Compartment");
+ }
+
+ return compartment;
}
int tcomp_compartment_setUseOnlyACKedStates(tcomp_compartment_t* self, tsk_bool_t useOnlyACKedStates)
{
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
- self->useOnlyACKedStates = useOnlyACKedStates;
- return 0;
+ if(!self) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+ self->useOnlyACKedStates = useOnlyACKedStates;
+ return 0;
}
/**Sets remote parameters
*/
void tcomp_compartment_setRemoteParams(tcomp_compartment_t *compartment, tcomp_params_t *lpParams)
{
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
-
- /* CPB||DMS||SMS [1-BYTE] */
- if(tcomp_params_hasCpbDmsSms(lpParams)){
- tcomp_params_setCpbCode(compartment->remote_parameters, lpParams->cpbCode);
- tcomp_params_setDmsCode(compartment->remote_parameters, lpParams->dmsCode);
- tcomp_params_setSmsCode(compartment->remote_parameters, lpParams->smsCode);
- }
-
- /* SigComp version */
- if(lpParams->SigComp_version){
- compartment->remote_parameters->SigComp_version = lpParams->SigComp_version;
- }
-
- /*
- * Returned states
- * FIXME: check states about quota
- * FIXME: not tic tac
- * FIXME: what about returned feedback?
- */
- if(lpParams->returnedStates && tcomp_buffer_getSize(lpParams->returnedStates)){
- TSK_OBJECT_SAFE_FREE(compartment->remote_parameters->returnedStates);
- /* swap */
- compartment->remote_parameters->returnedStates = lpParams->returnedStates;
- lpParams->returnedStates = 0;
- }
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
+
+ /* CPB||DMS||SMS [1-BYTE] */
+ if(tcomp_params_hasCpbDmsSms(lpParams)) {
+ tcomp_params_setCpbCode(compartment->remote_parameters, lpParams->cpbCode);
+ tcomp_params_setDmsCode(compartment->remote_parameters, lpParams->dmsCode);
+ tcomp_params_setSmsCode(compartment->remote_parameters, lpParams->smsCode);
+ }
+
+ /* SigComp version */
+ if(lpParams->SigComp_version) {
+ compartment->remote_parameters->SigComp_version = lpParams->SigComp_version;
+ }
+
+ /*
+ * Returned states
+ * FIXME: check states about quota
+ * FIXME: not tic tac
+ * FIXME: what about returned feedback?
+ */
+ if(lpParams->returnedStates && tcomp_buffer_getSize(lpParams->returnedStates)) {
+ TSK_OBJECT_SAFE_FREE(compartment->remote_parameters->returnedStates);
+ /* swap */
+ compartment->remote_parameters->returnedStates = lpParams->returnedStates;
+ lpParams->returnedStates = 0;
+ }
}
/**Sets requested feedback
*/
void tcomp_compartment_setReqFeedback(tcomp_compartment_t *compartment, tcomp_buffer_handle_t *feedback)
{
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
- tsk_safeobj_lock(compartment);
+ tsk_safeobj_lock(compartment);
- /* Delete old */
- TSK_OBJECT_SAFE_FREE(compartment->lpReqFeedback);
+ /* Delete old */
+ TSK_OBJECT_SAFE_FREE(compartment->lpReqFeedback);
- compartment->lpReqFeedback = tcomp_buffer_create(tcomp_buffer_getBuffer(feedback), tcomp_buffer_getSize(feedback));
+ compartment->lpReqFeedback = tcomp_buffer_create(tcomp_buffer_getBuffer(feedback), tcomp_buffer_getSize(feedback));
- tsk_safeobj_unlock(compartment);
+ tsk_safeobj_unlock(compartment);
}
/**Sets returned feedback
*/
void tcomp_compartment_setRetFeedback(tcomp_compartment_t *compartment, tcomp_buffer_handle_t *feedback)
{
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
-
- tsk_safeobj_lock(compartment);
-
- // Delete old
- TSK_OBJECT_SAFE_FREE(compartment->lpRetFeedback);
-
- compartment->lpRetFeedback = tcomp_buffer_create(tcomp_buffer_getBuffer(feedback), tcomp_buffer_getSize(feedback));
-
- /*
- * ACK STATE ==> Returned feedback contains the partial state-id.
- */
- if(compartment->compressorData/* && !compartment->compressorData_isStream*/){
- tcomp_buffer_handle_t *stateid = tcomp_buffer_create(tcomp_buffer_getBufferAtPos(feedback, 1), tcomp_buffer_getSize(feedback)-1);
- compartment->ackGhost(compartment->compressorData, stateid);
- TSK_OBJECT_SAFE_FREE(stateid);
- }
-
- tsk_safeobj_unlock(compartment);
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
+
+ tsk_safeobj_lock(compartment);
+
+ // Delete old
+ TSK_OBJECT_SAFE_FREE(compartment->lpRetFeedback);
+
+ compartment->lpRetFeedback = tcomp_buffer_create(tcomp_buffer_getBuffer(feedback), tcomp_buffer_getSize(feedback));
+
+ /*
+ * ACK STATE ==> Returned feedback contains the partial state-id.
+ */
+ if(compartment->compressorData/* && !compartment->compressorData_isStream*/) {
+ tcomp_buffer_handle_t *stateid = tcomp_buffer_create(tcomp_buffer_getBufferAtPos(feedback, 1), tcomp_buffer_getSize(feedback)-1);
+ compartment->ackGhost(compartment->compressorData, stateid);
+ TSK_OBJECT_SAFE_FREE(stateid);
+ }
+
+ tsk_safeobj_unlock(compartment);
}
/**Clears are compartment from the history.
*/
void tcomp_compartment_clearStates(tcomp_compartment_t *compartment)
{
- if(!compartment){
- TSK_DEBUG_ERROR("NULL sigcomp compartment.");
- return;
- }
+ if(!compartment) {
+ TSK_DEBUG_ERROR("NULL sigcomp compartment.");
+ return;
+ }
- tsk_safeobj_lock(compartment);
+ tsk_safeobj_lock(compartment);
- tsk_list_clear_items(compartment->local_states);
- compartment->total_memory_left = compartment->total_memory_size;
+ tsk_list_clear_items(compartment->local_states);
+ compartment->total_memory_left = compartment->total_memory_size;
- tsk_safeobj_unlock(compartment);
+ tsk_safeobj_unlock(compartment);
}
/**Removes a state from the compartment by priority.
*/
void tcomp_compartment_freeStateByPriority(tcomp_compartment_t *compartment)
{
- tcomp_state_t *lpState;
- tsk_list_item_t *item;
-
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
-
- tsk_safeobj_lock(compartment);
-
- lpState = 0;
- item = 0;
-
- /*
- * The order in which the existing state items are freed is determined by the state_retention_priority, which is set when the
- * state items are created. The state_retention_priority of 65535 is reserved for locally available states; these states must always be
- * freed first. Apart from this special case, states with the lowest state_retention_priority are always freed first. In the event of
- * a tie, then the state item created first in the compartment is also the first to be freed.
- */
- tsk_list_foreach(item, compartment->local_states){
- tcomp_state_t *curr = item->data;
-
- if(!curr){
- continue;
- }
-
- /* Local state ? */
- if(curr->retention_priority == 65535){
- lpState = curr;
- break;
- }
-
- /* Lower priority? */
- if(!lpState || curr->retention_priority < lpState->retention_priority){
- lpState = curr;
- continue;
- }
- }
-
- if(lpState){
- compartment->total_memory_left += TCOMP_GET_STATE_SIZE(lpState);
- tsk_list_remove_item_by_data(compartment->local_states, lpState);
- }
-
- tsk_safeobj_unlock(compartment);
+ tcomp_state_t *lpState;
+ tsk_list_item_t *item;
+
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
+
+ tsk_safeobj_lock(compartment);
+
+ lpState = 0;
+ item = 0;
+
+ /*
+ * The order in which the existing state items are freed is determined by the state_retention_priority, which is set when the
+ * state items are created. The state_retention_priority of 65535 is reserved for locally available states; these states must always be
+ * freed first. Apart from this special case, states with the lowest state_retention_priority are always freed first. In the event of
+ * a tie, then the state item created first in the compartment is also the first to be freed.
+ */
+ tsk_list_foreach(item, compartment->local_states) {
+ tcomp_state_t *curr = item->data;
+
+ if(!curr) {
+ continue;
+ }
+
+ /* Local state ? */
+ if(curr->retention_priority == 65535) {
+ lpState = curr;
+ break;
+ }
+
+ /* Lower priority? */
+ if(!lpState || curr->retention_priority < lpState->retention_priority) {
+ lpState = curr;
+ continue;
+ }
+ }
+
+ if(lpState) {
+ compartment->total_memory_left += TCOMP_GET_STATE_SIZE(lpState);
+ tsk_list_remove_item_by_data(compartment->local_states, lpState);
+ }
+
+ tsk_safeobj_unlock(compartment);
}
/**Removes a state from the compartment.
*/
static void _tcomp_compartment_freeState(tcomp_compartment_t *compartment, tcomp_state_t **lpState)
{
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
- tsk_safeobj_lock(compartment);
+ tsk_safeobj_lock(compartment);
- compartment->total_memory_left += TCOMP_GET_STATE_SIZE(*lpState);
- tsk_list_remove_item_by_data(compartment->local_states, *lpState);
- *lpState = tsk_null;
+ compartment->total_memory_left += TCOMP_GET_STATE_SIZE(*lpState);
+ tsk_list_remove_item_by_data(compartment->local_states, *lpState);
+ *lpState = tsk_null;
- tsk_safeobj_unlock(compartment);
+ tsk_safeobj_unlock(compartment);
}
/**Remove states
@@ -267,211 +267,211 @@ static void _tcomp_compartment_freeState(tcomp_compartment_t *compartment, tcomp
*/
void tcomp_compartment_freeStates(tcomp_compartment_t *compartment, tcomp_tempstate_to_free_t **tempStates, uint8_t size)
{
- uint8_t i;
- tcomp_state_t *lpState;
- tsk_list_item_t *item;
-
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
-
- if(!tempStates || !size){
- return;
- }
-
- lpState = tsk_null;
- item = tsk_null;
-
- for (i = 0; i < size; i++){
- /* lock */
- tsk_safeobj_lock(compartment);
-
- tsk_list_foreach(item, compartment->local_states){
- tcomp_state_t *curr = item->data;
-
- /* Compare current state with provided partial state */
- if(tcomp_buffer_startsWith(curr->identifier, tempStates[i]->identifier)){
- /*
- * If more than one state item in the compartment matches the partial state identifier,
- * then the state free request is ignored.
- */
- TSK_DEBUG_INFO("Request to free state with usage_count=%d", curr->usage_count);
- if(tcomp_state_dec_usage_count(curr) == 0){
- if(lpState){
- lpState = tsk_null;
- break;
- }
- else{
- lpState = curr;
- }
- }
- }
- }
-
- /* unlock */
- tsk_safeobj_unlock(compartment);
-
- if(lpState){
- _tcomp_compartment_freeState(compartment, &lpState);
- }
- }
+ uint8_t i;
+ tcomp_state_t *lpState;
+ tsk_list_item_t *item;
+
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
+
+ if(!tempStates || !size) {
+ return;
+ }
+
+ lpState = tsk_null;
+ item = tsk_null;
+
+ for (i = 0; i < size; i++) {
+ /* lock */
+ tsk_safeobj_lock(compartment);
+
+ tsk_list_foreach(item, compartment->local_states) {
+ tcomp_state_t *curr = item->data;
+
+ /* Compare current state with provided partial state */
+ if(tcomp_buffer_startsWith(curr->identifier, tempStates[i]->identifier)) {
+ /*
+ * If more than one state item in the compartment matches the partial state identifier,
+ * then the state free request is ignored.
+ */
+ TSK_DEBUG_INFO("Request to free state with usage_count=%d", curr->usage_count);
+ if(tcomp_state_dec_usage_count(curr) == 0) {
+ if(lpState) {
+ lpState = tsk_null;
+ break;
+ }
+ else {
+ lpState = curr;
+ }
+ }
+ }
+ }
+
+ /* unlock */
+ tsk_safeobj_unlock(compartment);
+
+ if(lpState) {
+ _tcomp_compartment_freeState(compartment, &lpState);
+ }
+ }
}
/**Adds a state to the compartment.
*/
void tcomp_compartment_addState(tcomp_compartment_t *compartment, tcomp_state_t **lpState)
{
- tsk_list_item_t *item;
- int32_t usage_count = 0;
- const tcomp_buffer_handle_t *identifier;
- if(!compartment || !lpState || !*lpState){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
-
- tsk_safeobj_lock(compartment);
-
- tcomp_state_makeValid(*lpState);
- identifier = (*lpState)->identifier;
-
- // check if the state exist
- tsk_list_foreach(item, compartment->local_states){
- if(tcomp_buffer_startsWith(((tcomp_state_t*)item->data)->identifier, (*lpState)->identifier)){
- *lpState = ((tcomp_state_t*)item->data); // override
- usage_count = tcomp_state_inc_usage_count(*lpState);
- break;
- }
- }
-
- if(usage_count == 0){ // alread exist?
- compartment->total_memory_left -= TCOMP_GET_STATE_SIZE(*lpState);
- usage_count = tcomp_state_inc_usage_count(*lpState);
- tsk_list_push_back_data(compartment->local_states, ((void**) lpState));
- }
-
- TSK_DEBUG_INFO("SigComp - Add new state with usage_count=%d and id=", usage_count);
- tcomp_buffer_print(identifier);
-
- *lpState = tsk_null;
-
- tsk_safeobj_unlock(compartment);
+ tsk_list_item_t *item;
+ int32_t usage_count = 0;
+ const tcomp_buffer_handle_t *identifier;
+ if(!compartment || !lpState || !*lpState) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
+
+ tsk_safeobj_lock(compartment);
+
+ tcomp_state_makeValid(*lpState);
+ identifier = (*lpState)->identifier;
+
+ // check if the state exist
+ tsk_list_foreach(item, compartment->local_states) {
+ if(tcomp_buffer_startsWith(((tcomp_state_t*)item->data)->identifier, (*lpState)->identifier)) {
+ *lpState = ((tcomp_state_t*)item->data); // override
+ usage_count = tcomp_state_inc_usage_count(*lpState);
+ break;
+ }
+ }
+
+ if(usage_count == 0) { // alread exist?
+ compartment->total_memory_left -= TCOMP_GET_STATE_SIZE(*lpState);
+ usage_count = tcomp_state_inc_usage_count(*lpState);
+ tsk_list_push_back_data(compartment->local_states, ((void**) lpState));
+ }
+
+ TSK_DEBUG_INFO("SigComp - Add new state with usage_count=%d and id=", usage_count);
+ tcomp_buffer_print(identifier);
+
+ *lpState = tsk_null;
+
+ tsk_safeobj_unlock(compartment);
}
/**Finds a state.
*/
uint32_t tcomp_compartment_findState(tcomp_compartment_t *compartment, const tcomp_buffer_handle_t *partial_identifier, tcomp_state_t **lpState)
{
- uint32_t count = 0;
- tsk_list_item_t *item;
-
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
-
- tsk_safeobj_lock(compartment);
-
- tsk_list_foreach(item, compartment->local_states){
- tcomp_state_t *curr = item->data;
-
- if(tcomp_buffer_startsWith(curr->identifier, partial_identifier)){
- *lpState = curr; // override
- count++;
- }
- }
-
- tsk_safeobj_unlock(compartment);
-
- return count;
+ uint32_t count = 0;
+ tsk_list_item_t *item;
+
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+
+ tsk_safeobj_lock(compartment);
+
+ tsk_list_foreach(item, compartment->local_states) {
+ tcomp_state_t *curr = item->data;
+
+ if(tcomp_buffer_startsWith(curr->identifier, partial_identifier)) {
+ *lpState = curr; // override
+ count++;
+ }
+ }
+
+ tsk_safeobj_unlock(compartment);
+
+ return count;
}
/**Removes a Ghost state.
*/
void tcomp_compartment_freeGhostState(tcomp_compartment_t *compartment)
{
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
- tsk_safeobj_lock(compartment);
+ tsk_safeobj_lock(compartment);
- if(compartment->compressorData){
- compartment->freeGhostState(compartment->compressorData);
- }
- else{
- TSK_DEBUG_WARN("No compression data to free.");
- }
+ if(compartment->compressorData) {
+ compartment->freeGhostState(compartment->compressorData);
+ }
+ else {
+ TSK_DEBUG_WARN("No compression data to free.");
+ }
- tsk_safeobj_unlock(compartment);
+ tsk_safeobj_unlock(compartment);
}
/**Adds a NACK to the compartment.
*/
void tcomp_compartment_addNack(tcomp_compartment_t *compartment, const uint8_t nackId[TSK_SHA1_DIGEST_SIZE])
{
- tcomp_buffer_handle_t *id;
+ tcomp_buffer_handle_t *id;
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return;
- }
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return;
+ }
#if 0
- {
- int i;
- TSK_DEBUG_INFO("Save NACK with id:");
- for(i = 0; i < TSK_SHA1_DIGEST_SIZE; ++i){
- printf("%x ", nackId[i]);
- }
- printf("\n");
- }
+ {
+ int i;
+ TSK_DEBUG_INFO("Save NACK with id:");
+ for(i = 0; i < TSK_SHA1_DIGEST_SIZE; ++i) {
+ printf("%x ", nackId[i]);
+ }
+ printf("\n");
+ }
#endif
- tsk_safeobj_lock(compartment);
+ tsk_safeobj_lock(compartment);
- if(compartment->nacks_history_count >= NACK_MAX_HISTORY_SIZE){
- tsk_list_remove_last_item(compartment->nacks);
- compartment->nacks_history_count--;
- }
+ if(compartment->nacks_history_count >= NACK_MAX_HISTORY_SIZE) {
+ tsk_list_remove_last_item(compartment->nacks);
+ compartment->nacks_history_count--;
+ }
- id = tcomp_buffer_create(nackId, TSK_SHA1_DIGEST_SIZE);
- tsk_list_push_back_data(compartment->nacks, ((void**) &id));
- compartment->nacks_history_count++;
+ id = tcomp_buffer_create(nackId, TSK_SHA1_DIGEST_SIZE);
+ tsk_list_push_back_data(compartment->nacks, ((void**) &id));
+ compartment->nacks_history_count++;
- tsk_safeobj_unlock(compartment);
+ tsk_safeobj_unlock(compartment);
}
/**Checks if the NACK exist.
*/
tsk_bool_t tcomp_compartment_hasNack(tcomp_compartment_t *compartment, const tcomp_buffer_handle_t *nackId)
{
- tsk_bool_t ret = tsk_false;
- tsk_list_item_t *item;
-
- if(!compartment){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_false;
- }
-
- tsk_safeobj_lock(compartment);
-
- item = tsk_null;
-
- tsk_list_foreach(item, compartment->nacks){
- tcomp_buffer_handle_t *curr = item->data;
-
- if(tcomp_buffer_equals(curr, nackId)){
- TSK_DEBUG_INFO("SigComp - Nack found.");
- ret = tsk_true;
- break;
- }
- }
-
- tsk_safeobj_unlock(compartment);
-
- return ret;
+ tsk_bool_t ret = tsk_false;
+ tsk_list_item_t *item;
+
+ if(!compartment) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_false;
+ }
+
+ tsk_safeobj_lock(compartment);
+
+ item = tsk_null;
+
+ tsk_list_foreach(item, compartment->nacks) {
+ tcomp_buffer_handle_t *curr = item->data;
+
+ if(tcomp_buffer_equals(curr, nackId)) {
+ TSK_DEBUG_INFO("SigComp - Nack found.");
+ ret = tsk_true;
+ break;
+ }
+ }
+
+ tsk_safeobj_unlock(compartment);
+
+ return ret;
}
@@ -489,64 +489,63 @@ tsk_bool_t tcomp_compartment_hasNack(tcomp_compartment_t *compartment, const tco
static tsk_object_t* tcomp_compartment_ctor(tsk_object_t* self, va_list * app)
{
- tcomp_compartment_t *compartment = self;
- if(compartment){
- /* Initialize safeobject */
- tsk_safeobj_init(compartment);
- }
+ tcomp_compartment_t *compartment = self;
+ if(compartment) {
+ /* Initialize safeobject */
+ tsk_safeobj_init(compartment);
+ }
- return self;
+ return self;
}
static tsk_object_t* tcomp_compartment_dtor(tsk_object_t* self)
{
- tcomp_compartment_t *compartment = self;
- if(compartment){
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(compartment);
-
- /* Delete feedbacks */
- TSK_OBJECT_SAFE_FREE(compartment->lpReqFeedback);
- TSK_OBJECT_SAFE_FREE(compartment->lpRetFeedback);
-
- /* Delete Nacks */
- TSK_OBJECT_SAFE_FREE(compartment->nacks);
-
- /* Delete Compressor data */
- TSK_OBJECT_SAFE_FREE(compartment->compressorData);
- compartment->ackGhost = tsk_null;
- compartment->freeGhostState = tsk_null;
-
- /* Delete params */
- TSK_OBJECT_SAFE_FREE(compartment->local_parameters);
- TSK_OBJECT_SAFE_FREE(compartment->remote_parameters);
-
- /* Delete NACKS */
- TSK_OBJECT_SAFE_FREE(compartment->nacks);
-
- /* Delete local states */
- TSK_OBJECT_SAFE_FREE(compartment->local_states);
- }
- else{
- TSK_DEBUG_ERROR("Null Compartment");
- }
-
- return self;
+ tcomp_compartment_t *compartment = self;
+ if(compartment) {
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(compartment);
+
+ /* Delete feedbacks */
+ TSK_OBJECT_SAFE_FREE(compartment->lpReqFeedback);
+ TSK_OBJECT_SAFE_FREE(compartment->lpRetFeedback);
+
+ /* Delete Nacks */
+ TSK_OBJECT_SAFE_FREE(compartment->nacks);
+
+ /* Delete Compressor data */
+ TSK_OBJECT_SAFE_FREE(compartment->compressorData);
+ compartment->ackGhost = tsk_null;
+ compartment->freeGhostState = tsk_null;
+
+ /* Delete params */
+ TSK_OBJECT_SAFE_FREE(compartment->local_parameters);
+ TSK_OBJECT_SAFE_FREE(compartment->remote_parameters);
+
+ /* Delete NACKS */
+ TSK_OBJECT_SAFE_FREE(compartment->nacks);
+
+ /* Delete local states */
+ TSK_OBJECT_SAFE_FREE(compartment->local_states);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null Compartment");
+ }
+
+ return self;
}
static int tcomp_compartment_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
- const tcomp_compartment_t *compartment1 = obj1;
- const tcomp_compartment_t *compartment2 = obj2;
- int64_t res = (compartment1->identifier - compartment2->identifier);
- return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
+ const tcomp_compartment_t *compartment1 = obj1;
+ const tcomp_compartment_t *compartment2 = obj2;
+ int64_t res = (compartment1->identifier - compartment2->identifier);
+ return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
}
-static const tsk_object_def_t tsk_compartment_def_s =
-{
- sizeof(tcomp_compartment_t),
- tcomp_compartment_ctor,
- tcomp_compartment_dtor,
- tcomp_compartment_cmp
+static const tsk_object_def_t tsk_compartment_def_s = {
+ sizeof(tcomp_compartment_t),
+ tcomp_compartment_ctor,
+ tcomp_compartment_dtor,
+ tcomp_compartment_cmp
};
const tsk_object_def_t *tcomp_compartment_def_t = &tsk_compartment_def_s;
diff --git a/tinySIGCOMP/src/tcomp_compartment.h b/tinySIGCOMP/src/tcomp_compartment.h
index f15ee82..82e50fc 100755
--- a/tinySIGCOMP/src/tcomp_compartment.h
+++ b/tinySIGCOMP/src/tcomp_compartment.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -43,32 +43,31 @@
TCOMP_BEGIN_DECLS
-typedef struct tcomp_compartment_s
-{
- TSK_DECLARE_OBJECT;
-
- /*
- * An identifier (in a locally chosen format) that uniquely references a compartment.
- */
- uint64_t identifier;
+typedef struct tcomp_compartment_s {
+ TSK_DECLARE_OBJECT;
+
+ /*
+ * An identifier (in a locally chosen format) that uniquely references a compartment.
+ */
+ uint64_t identifier;
- tcomp_states_L_t *local_states;
- tcomp_params_t *remote_parameters;
- tcomp_params_t *local_parameters;
- uint32_t total_memory_size;
- uint32_t total_memory_left;
+ tcomp_states_L_t *local_states;
+ tcomp_params_t *remote_parameters;
+ tcomp_params_t *local_parameters;
+ uint32_t total_memory_size;
+ uint32_t total_memory_left;
- tcomp_buffer_handle_t *lpReqFeedback;
- tcomp_buffer_handle_t *lpRetFeedback;
+ tcomp_buffer_handle_t *lpReqFeedback;
+ tcomp_buffer_handle_t *lpRetFeedback;
- TCOMP_DECLARE_COMPRESSORDATA;
+ TCOMP_DECLARE_COMPRESSORDATA;
- tcomp_buffers_L_t* nacks;
- uint8_t nacks_history_count;
+ tcomp_buffers_L_t* nacks;
+ uint8_t nacks_history_count;
- tsk_bool_t useOnlyACKedStates;
+ tsk_bool_t useOnlyACKedStates;
- TSK_DECLARE_SAFEOBJ;
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_compartment_t;
diff --git a/tinySIGCOMP/src/tcomp_compressor.h b/tinySIGCOMP/src/tcomp_compressor.h
index 6d71401..6b3ebba 100755
--- a/tinySIGCOMP/src/tcomp_compressor.h
+++ b/tinySIGCOMP/src/tcomp_compressor.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_compressor_deflate.c b/tinySIGCOMP/src/tcomp_compressor_deflate.c
index fcce528..e01ebaf 100755
--- a/tinySIGCOMP/src/tcomp_compressor_deflate.c
+++ b/tinySIGCOMP/src/tcomp_compressor_deflate.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -38,181 +38,180 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
///
-/// @brief Compress SIgComp message using deflate algorithm.
+/// @brief Compress SIgComp message using deflate algorithm.
///
-/// @param [in,out] lpCompartment If non-null, the pointer to a compartment.
-/// @param [in,out] input_ptr If non-null, the input pointer.
-/// @param input_size Size of the input.
-/// @param [in,out] output_ptr If non-null, the output pointer.
-/// @param [in,out] output_size If non-null, size of the output.
-/// @param stream The stream.
+/// @param [in,out] lpCompartment If non-null, the pointer to a compartment.
+/// @param [in,out] input_ptr If non-null, the input pointer.
+/// @param input_size Size of the input.
+/// @param [in,out] output_ptr If non-null, the output pointer.
+/// @param [in,out] output_size If non-null, size of the output.
+/// @param stream The stream.
///
-/// @return .
+/// @return .
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t tcomp_compressor_deflate_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, tsk_size_t input_size, void *output_ptr, tsk_size_t *output_size, tsk_bool_t stream)
{
#define GET_OUTPUT_BUFFER_AT(position) (((uint8_t*)output_ptr) + position)
- tsk_bool_t result = tsk_true;
- int stateChanged, stateful, windowBits, zret;
- tcomp_deflatedata_t *deflatedata = 0;
- tsk_size_t pointer = 0, state_len_index = 0, compressedDataLen;
- uint8_t smsCode, *header;
-
- tsk_safeobj_lock(lpCompartment);
-
- /* Compression Data */
- if(!lpCompartment->compressorData){
- lpCompartment->compressorData = tcomp_deflatedata_create(stream, lpCompartment->useOnlyACKedStates);
- if(!lpCompartment->compressorData){
- TSK_DEBUG_ERROR("Failed to create deflate compressor data.");
- result = tsk_false;
- goto bail;
- }
- else{
- lpCompartment->ackGhost = tcomp_deflatedata_ackGhost;
- lpCompartment->freeGhostState = tcomp_deflatedata_freeGhostState;
- lpCompartment->compressorData_isStream = stream;
- }
- }
-
- deflatedata = lpCompartment->compressorData;
-
- /* State memory size code */
- smsCode = TCOMP_MIN(lpCompartment->remote_parameters->smsCode, lpCompartment->remote_parameters->dmsCode);
- if(lpCompartment->useOnlyACKedStates){
- stateful = (deflatedata->ghostState && tcomp_deflatedata_isStateful(deflatedata));
- }
- else{
- stateful = !!deflatedata->ghostState;
- }
-
- /*
- * Init zLIB
- */
- windowBits = ( smsCode - (stream ? 2 : 1) ) + 10;
- windowBits = TSK_CLAMP(8, windowBits, 15); /* Because of zlib limitation (windowsize MUST be between 8 and 15) */
- if(windowBits != deflatedata->zWindowBits){
- /* Window size changed */
- tcomp_deflatedata_freeGhostState(deflatedata);
- tcomp_deflatedata_zSetWindowBits(deflatedata, windowBits);
-
- if( !(result = tcomp_deflatedata_zReset(deflatedata)) ) {
- goto bail;
- }
- }
- else if(!deflatedata->ghostState){
- /* No ghost --> reset zlib */
- deflatedata->ghost_copy_offset = 0;
- if( !(result = tcomp_deflatedata_zReset(deflatedata)) ) {
- goto bail;
- }
- }
-
- stateful &= !!deflatedata->ghostState;
-
- /*
- * SigComp headers
- */
- header = GET_OUTPUT_BUFFER_AT(pointer++);
-
-
- /* SigComp Header */
- if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback)){
- /* Return the requested feedback */
- *header = 0xfc; /* T=1 */
- memcpy(GET_OUTPUT_BUFFER_AT(pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
- pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
- }
- else{
- *header = 0xf8;
- }
-
- /*
- * Stateless or stateful?
- */
- if(stateful){
- TSK_DEBUG_INFO("SigComp - Compressing message with state id = ");
- tcomp_buffer_print(deflatedata->ghostState->identifier);
- memcpy(GET_OUTPUT_BUFFER_AT(pointer), tcomp_buffer_getBuffer(deflatedata->ghostState->identifier), TCOMP_PARTIAL_ID_LEN_VALUE);
-
- pointer += TCOMP_PARTIAL_ID_LEN_VALUE;
- *header |= TCOMP_PARTIAL_ID_LEN_CODE;
- }
- else{
- uint32_t codeLen = DEFLATE_BYTECODE_LEN;
- /* first byte for codelen */
- *GET_OUTPUT_BUFFER_AT(pointer++) = ((codeLen>>4)& 0x00ff);
- /* last 4 bits for codelen */
- *GET_OUTPUT_BUFFER_AT(pointer) = ((codeLen & 0x000f)<<4);
- /* first and last 4 bits for destination */
- *GET_OUTPUT_BUFFER_AT(pointer++) |= DEFLATE_BYTECODE_DESTINATION_CODE;
-
- /*
- * Upload UDVM bytecode
- */
- memcpy(GET_OUTPUT_BUFFER_AT(pointer), (const uint8_t*)DEFLATEDATA_DEFLATE_BYTECODE, codeLen);
- pointer += codeLen;
-
- //////////////////////////////////////////////////
- // FIXME: check for overflow and >=320
- //
- // [DMS]+[Req. Fed. Loc.]+[state_len]+[cpb||dms||sms]+[Sigcomp_version]+[states]
- //*output_buffer.getBuffer(pointer++) = 0x04; //reserved=0, Q=1, S=0, I=0
- //*output_buffer.getBuffer(pointer++) = (this->req_feedback_item++); //requested feedback item
-
- state_len_index = pointer;
- *GET_OUTPUT_BUFFER_AT(pointer) = 0x00, pointer += 4; /* [hash_len]+[state_len] */
- *GET_OUTPUT_BUFFER_AT(pointer++) = (tcomp_params_getParameters(lpCompartment->local_parameters)>>8); // [cpb||dms||sms]
- *GET_OUTPUT_BUFFER_AT(pointer++) = (tcomp_params_getParameters(lpCompartment->local_parameters)&0x00ff); // [Sigcomp_version]
+ tsk_bool_t result = tsk_true;
+ int stateChanged, stateful, windowBits, zret;
+ tcomp_deflatedata_t *deflatedata = 0;
+ tsk_size_t pointer = 0, state_len_index = 0, compressedDataLen;
+ uint8_t smsCode, *header;
+
+ tsk_safeobj_lock(lpCompartment);
+
+ /* Compression Data */
+ if(!lpCompartment->compressorData) {
+ lpCompartment->compressorData = tcomp_deflatedata_create(stream, lpCompartment->useOnlyACKedStates);
+ if(!lpCompartment->compressorData) {
+ TSK_DEBUG_ERROR("Failed to create deflate compressor data.");
+ result = tsk_false;
+ goto bail;
+ }
+ else {
+ lpCompartment->ackGhost = tcomp_deflatedata_ackGhost;
+ lpCompartment->freeGhostState = tcomp_deflatedata_freeGhostState;
+ lpCompartment->compressorData_isStream = stream;
+ }
+ }
+
+ deflatedata = lpCompartment->compressorData;
+
+ /* State memory size code */
+ smsCode = TCOMP_MIN(lpCompartment->remote_parameters->smsCode, lpCompartment->remote_parameters->dmsCode);
+ if(lpCompartment->useOnlyACKedStates) {
+ stateful = (deflatedata->ghostState && tcomp_deflatedata_isStateful(deflatedata));
+ }
+ else {
+ stateful = !!deflatedata->ghostState;
+ }
+
+ /*
+ * Init zLIB
+ */
+ windowBits = ( smsCode - (stream ? 2 : 1) ) + 10;
+ windowBits = TSK_CLAMP(8, windowBits, 15); /* Because of zlib limitation (windowsize MUST be between 8 and 15) */
+ if(windowBits != deflatedata->zWindowBits) {
+ /* Window size changed */
+ tcomp_deflatedata_freeGhostState(deflatedata);
+ tcomp_deflatedata_zSetWindowBits(deflatedata, windowBits);
+
+ if( !(result = tcomp_deflatedata_zReset(deflatedata)) ) {
+ goto bail;
+ }
+ }
+ else if(!deflatedata->ghostState) {
+ /* No ghost --> reset zlib */
+ deflatedata->ghost_copy_offset = 0;
+ if( !(result = tcomp_deflatedata_zReset(deflatedata)) ) {
+ goto bail;
+ }
+ }
+
+ stateful &= !!deflatedata->ghostState;
+
+ /*
+ * SigComp headers
+ */
+ header = GET_OUTPUT_BUFFER_AT(pointer++);
+
+
+ /* SigComp Header */
+ if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback)) {
+ /* Return the requested feedback */
+ *header = 0xfc; /* T=1 */
+ memcpy(GET_OUTPUT_BUFFER_AT(pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
+ pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
+ }
+ else {
+ *header = 0xf8;
+ }
+
+ /*
+ * Stateless or stateful?
+ */
+ if(stateful) {
+ TSK_DEBUG_INFO("SigComp - Compressing message with state id = ");
+ tcomp_buffer_print(deflatedata->ghostState->identifier);
+ memcpy(GET_OUTPUT_BUFFER_AT(pointer), tcomp_buffer_getBuffer(deflatedata->ghostState->identifier), TCOMP_PARTIAL_ID_LEN_VALUE);
+
+ pointer += TCOMP_PARTIAL_ID_LEN_VALUE;
+ *header |= TCOMP_PARTIAL_ID_LEN_CODE;
+ }
+ else {
+ uint32_t codeLen = DEFLATE_BYTECODE_LEN;
+ /* first byte for codelen */
+ *GET_OUTPUT_BUFFER_AT(pointer++) = ((codeLen>>4)& 0x00ff);
+ /* last 4 bits for codelen */
+ *GET_OUTPUT_BUFFER_AT(pointer) = ((codeLen & 0x000f)<<4);
+ /* first and last 4 bits for destination */
+ *GET_OUTPUT_BUFFER_AT(pointer++) |= DEFLATE_BYTECODE_DESTINATION_CODE;
+
+ /*
+ * Upload UDVM bytecode
+ */
+ memcpy(GET_OUTPUT_BUFFER_AT(pointer), (const uint8_t*)DEFLATEDATA_DEFLATE_BYTECODE, codeLen);
+ pointer += codeLen;
+
+ //////////////////////////////////////////////////
+ // FIXME: check for overflow and >=320
+ //
+ // [DMS]+[Req. Fed. Loc.]+[state_len]+[cpb||dms||sms]+[Sigcomp_version]+[states]
+ //*output_buffer.getBuffer(pointer++) = 0x04; //reserved=0, Q=1, S=0, I=0
+ //*output_buffer.getBuffer(pointer++) = (this->req_feedback_item++); //requested feedback item
+
+ state_len_index = pointer;
+ *GET_OUTPUT_BUFFER_AT(pointer) = 0x00, pointer += 4; /* [hash_len]+[state_len] */
+ *GET_OUTPUT_BUFFER_AT(pointer++) = (tcomp_params_getParameters(lpCompartment->local_parameters)>>8); // [cpb||dms||sms]
+ *GET_OUTPUT_BUFFER_AT(pointer++) = (tcomp_params_getParameters(lpCompartment->local_parameters)&0x00ff); // [Sigcomp_version]
#if USE_DICTS_FOR_COMPRESSION
- *output_buffer.getBuffer(pointer++) = 0x00; // First dict byte // FIXME
- *output_buffer.getBuffer(pointer++) = DEFLATE_FIXME_DICT; // FIXME: also change ghost
+ *output_buffer.getBuffer(pointer++) = 0x00; // First dict byte // FIXME
+ *output_buffer.getBuffer(pointer++) = DEFLATE_FIXME_DICT; // FIXME: also change ghost
#endif
- }
-
- /*
- * Compress data using ZLIB
- */
- compressedDataLen = (*output_size - pointer);
- zret = tcomp_deflatedata_zCompress(deflatedata, input_ptr, input_size, GET_OUTPUT_BUFFER_AT(pointer), &compressedDataLen, &stateChanged);
- if(!zret){
- result = tsk_false;
- goto bail;
- }
- pointer += compressedDataLen;
- *output_size = (pointer);
-
- /*
- * Update state length
- */
- if(!stateful){
- uint32_t state_len = ( (1<<(deflatedata->zWindowBits)) + DEFLATE_UDVM_CIRCULAR_START_INDEX - 64 );
- uint32_t hash_len = (state_len + 8);
-
- // FIXME: 131072 could not go in 2-bytes
- *GET_OUTPUT_BUFFER_AT(state_len_index) = (hash_len >> 8);
- *GET_OUTPUT_BUFFER_AT(state_len_index+1) = (hash_len & 0x00ff);
- *GET_OUTPUT_BUFFER_AT(state_len_index+2) = (state_len >> 8);
- *GET_OUTPUT_BUFFER_AT(state_len_index+3) = (state_len & 0x00ff);
-
- /* First time or synchronize failure (NACK reason=STATE_NOT_FOUND) */
- if(!deflatedata->ghostState){
- tcomp_deflatedata_createGhost(deflatedata, state_len, lpCompartment->local_parameters);
- }
- }
- if(!lpCompartment->useOnlyACKedStates || (lpCompartment->useOnlyACKedStates && stateChanged))
- {
- tcomp_deflatedata_updateGhost(deflatedata, (const uint8_t*)input_ptr, input_size);
- }
-
- //output_buffer.print(2000);
-
+ }
+
+ /*
+ * Compress data using ZLIB
+ */
+ compressedDataLen = (*output_size - pointer);
+ zret = tcomp_deflatedata_zCompress(deflatedata, input_ptr, input_size, GET_OUTPUT_BUFFER_AT(pointer), &compressedDataLen, &stateChanged);
+ if(!zret) {
+ result = tsk_false;
+ goto bail;
+ }
+ pointer += compressedDataLen;
+ *output_size = (pointer);
+
+ /*
+ * Update state length
+ */
+ if(!stateful) {
+ uint32_t state_len = ( (1<<(deflatedata->zWindowBits)) + DEFLATE_UDVM_CIRCULAR_START_INDEX - 64 );
+ uint32_t hash_len = (state_len + 8);
+
+ // FIXME: 131072 could not go in 2-bytes
+ *GET_OUTPUT_BUFFER_AT(state_len_index) = (hash_len >> 8);
+ *GET_OUTPUT_BUFFER_AT(state_len_index+1) = (hash_len & 0x00ff);
+ *GET_OUTPUT_BUFFER_AT(state_len_index+2) = (state_len >> 8);
+ *GET_OUTPUT_BUFFER_AT(state_len_index+3) = (state_len & 0x00ff);
+
+ /* First time or synchronize failure (NACK reason=STATE_NOT_FOUND) */
+ if(!deflatedata->ghostState) {
+ tcomp_deflatedata_createGhost(deflatedata, state_len, lpCompartment->local_parameters);
+ }
+ }
+ if(!lpCompartment->useOnlyACKedStates || (lpCompartment->useOnlyACKedStates && stateChanged)) {
+ tcomp_deflatedata_updateGhost(deflatedata, (const uint8_t*)input_ptr, input_size);
+ }
+
+ //output_buffer.print(2000);
+
bail:
- tsk_safeobj_unlock(lpCompartment);
+ tsk_safeobj_unlock(lpCompartment);
- return result;
+ return result;
#undef GET_OUTPUT_BUFFER_AT
}
diff --git a/tinySIGCOMP/src/tcomp_compressor_deflate.h b/tinySIGCOMP/src/tcomp_compressor_deflate.h
index 81216ad..92fe474 100755
--- a/tinySIGCOMP/src/tcomp_compressor_deflate.h
+++ b/tinySIGCOMP/src/tcomp_compressor_deflate.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_compressor_dummy.c b/tinySIGCOMP/src/tcomp_compressor_dummy.c
index 34d062d..f5efdf6 100755
--- a/tinySIGCOMP/src/tcomp_compressor_dummy.c
+++ b/tinySIGCOMP/src/tcomp_compressor_dummy.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -43,62 +43,62 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// @brief Dummy compressor as per RFC 4896 subclause 11. This function is used to create uncompressed sigcomp message.
-/// Used if none match.
+/// Used if none match.
///
-/// @param [in,out] lpCompartment The compartment to use.
-/// @param [in,out] input_ptr The input buffer containing the message to compress.
-/// @param input_size The size of the input buffer.
-/// @param [in,out] output_ptr The output buffer where to copy the compressed message.
+/// @param [in,out] lpCompartment The compartment to use.
+/// @param [in,out] input_ptr The input buffer containing the message to compress.
+/// @param input_size The size of the input buffer.
+/// @param [in,out] output_ptr The output buffer where to copy the compressed message.
/// @param [in,out] output_size The size of the output buffer.
-/// @param stream Indicates whether it's a stream buffer or not.
+/// @param stream Indicates whether it's a stream buffer or not.
///
-/// @return 1 if succedd and 0 otherwise.
+/// @return 1 if succedd and 0 otherwise.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t tcomp_compressor_dummy_compress(tcomp_compartment_t *lpCompartment, const void *input_ptr, tsk_size_t input_size, void *output_ptr, tsk_size_t *output_size, tsk_bool_t stream)
{
- tcomp_buffer_handle_t *output_buffer = tcomp_buffer_create_null();
- tsk_size_t pointer = 0;
- uint8_t *header;
- uint32_t codeLen;
-
- tcomp_buffer_referenceBuff(output_buffer, (uint8_t*)output_ptr, *output_size);
- header = tcomp_buffer_getBufferAtPos(output_buffer, pointer++);
-
- /* SigComp Header */
- if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback)){
- /* Return the requested feedback */
- *header = 0xfc; /* T=1 */
- memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
- pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
- }
- else{
- *header = 0xf8;
- }
-
- codeLen = UNCOMPRESSED_BYTECODE_LENGTH;
- /* first byte for codelen */
- *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) = ((codeLen>>4)& 0x00ff);
-
- /* last 4 bits for codelen */
- *tcomp_buffer_getBufferAtPos(output_buffer, pointer) = ((codeLen & 0x000f)<<4);
-
- /* first and last 4 bits for destination */
- *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) |= UNCOMPRESSED_BYTECODE_DESTINATION_CODE;
-
- /*
- * Upload UDVM bytecode
- */
- memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), (uint8_t*)DUMMYCOMPRESSOR_UNCOMPRESSED_BYTECODE, codeLen);
- pointer += codeLen;
-
- /*
- * Copy data uncompressed
- */
- memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), input_ptr, input_size);
- pointer += input_size;
- *output_size = (pointer);
-
- TSK_OBJECT_SAFE_FREE(output_buffer);
-
- return tsk_true;
+ tcomp_buffer_handle_t *output_buffer = tcomp_buffer_create_null();
+ tsk_size_t pointer = 0;
+ uint8_t *header;
+ uint32_t codeLen;
+
+ tcomp_buffer_referenceBuff(output_buffer, (uint8_t*)output_ptr, *output_size);
+ header = tcomp_buffer_getBufferAtPos(output_buffer, pointer++);
+
+ /* SigComp Header */
+ if(lpCompartment->lpReqFeedback && tcomp_buffer_getSize(lpCompartment->lpReqFeedback)) {
+ /* Return the requested feedback */
+ *header = 0xfc; /* T=1 */
+ memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), tcomp_buffer_getBuffer(lpCompartment->lpReqFeedback), tcomp_buffer_getSize(lpCompartment->lpReqFeedback));
+ pointer += tcomp_buffer_getSize(lpCompartment->lpReqFeedback);
+ }
+ else {
+ *header = 0xf8;
+ }
+
+ codeLen = UNCOMPRESSED_BYTECODE_LENGTH;
+ /* first byte for codelen */
+ *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) = ((codeLen>>4)& 0x00ff);
+
+ /* last 4 bits for codelen */
+ *tcomp_buffer_getBufferAtPos(output_buffer, pointer) = ((codeLen & 0x000f)<<4);
+
+ /* first and last 4 bits for destination */
+ *tcomp_buffer_getBufferAtPos(output_buffer, pointer++) |= UNCOMPRESSED_BYTECODE_DESTINATION_CODE;
+
+ /*
+ * Upload UDVM bytecode
+ */
+ memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), (uint8_t*)DUMMYCOMPRESSOR_UNCOMPRESSED_BYTECODE, codeLen);
+ pointer += codeLen;
+
+ /*
+ * Copy data uncompressed
+ */
+ memcpy(tcomp_buffer_getBufferAtPos(output_buffer, pointer), input_ptr, input_size);
+ pointer += input_size;
+ *output_size = (pointer);
+
+ TSK_OBJECT_SAFE_FREE(output_buffer);
+
+ return tsk_true;
}
diff --git a/tinySIGCOMP/src/tcomp_compressor_dummy.h b/tinySIGCOMP/src/tcomp_compressor_dummy.h
index 50c7c88..937131e 100755
--- a/tinySIGCOMP/src/tcomp_compressor_dummy.h
+++ b/tinySIGCOMP/src/tcomp_compressor_dummy.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_compressordata.c b/tinySIGCOMP/src/tcomp_compressordata.c
index 1d8fe54..8c0494b 100755
--- a/tinySIGCOMP/src/tcomp_compressordata.c
+++ b/tinySIGCOMP/src/tcomp_compressordata.c
@@ -2,19 +2,19 @@
//* Copyright (C) 2010-2011 Mamadou Diop.
//*
//* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-//*
+//*
//* This file is part of Open Source Doubango Framework.
//*
//* DOUBANGO is free software: you can redistribute it and/or modify
//* it under the terms of the GNU General Public License as published by
//* the Free Software Foundation, either version 3 of the License, or
//* (at your option) any later version.
-//*
+//*
//* DOUBANGO is distributed in the hope that it will be useful,
//* but WITHOUT ANY WARRANTY; without even the implied warranty of
//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//* GNU General Public License for more details.
-//*
+//*
//* You should have received a copy of the GNU General Public License
//* along with DOUBANGO.
//*
@@ -84,7 +84,7 @@
// {
// /* Initialize safeobject */
// tsk_safeobj_init(compdata);
-//
+//
// compdata->isStream = va_arg(*app, int);
// }
//
@@ -105,7 +105,7 @@
// return self;
//}
//
-//static const tsk_object_def_t tsk_compressordata_def_s =
+//static const tsk_object_def_t tsk_compressordata_def_s =
//{
// sizeof(tcomp_compressordata_t),
// tcomp_compressordata_create,
diff --git a/tinySIGCOMP/src/tcomp_compressordata.h b/tinySIGCOMP/src/tcomp_compressordata.h
index 917fa5e..f23dfd0 100755
--- a/tinySIGCOMP/src/tcomp_compressordata.h
+++ b/tinySIGCOMP/src/tcomp_compressordata.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_compressordisp.c b/tinySIGCOMP/src/tcomp_compressordisp.c
index 13ab5fd..da7bcc4 100755
--- a/tinySIGCOMP/src/tcomp_compressordisp.c
+++ b/tinySIGCOMP/src/tcomp_compressordisp.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -46,138 +46,138 @@
*/
tcomp_compressordisp_t* tcomp_compressordisp_create(const tcomp_statehandler_t* statehandler)
{
- return tsk_object_new(tcomp_compressordisp_def_t, statehandler);
+ return tsk_object_new(tcomp_compressordisp_def_t, statehandler);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Compress a message.
///
-/// @param [in,out] dispatcher The compressor dispatcher.
-/// @param compartmentId The compartment to use to compress the message.
-/// @param [in,out] input_ptr The message to compress.
-/// @param input_size The size of the input buffer.
-/// @param [in,out] output_ptr The output buffer to copy the compressed data.
-/// @param [in,out] output_size The size of the output buffer.
-/// @param stream Indicates whether it's a stream buffer or not.
+/// @param [in,out] dispatcher The compressor dispatcher.
+/// @param compartmentId The compartment to use to compress the message.
+/// @param [in,out] input_ptr The message to compress.
+/// @param input_size The size of the input buffer.
+/// @param [in,out] output_ptr The output buffer to copy the compressed data.
+/// @param [in,out] output_size The size of the output buffer.
+/// @param stream Indicates whether it's a stream buffer or not.
///
-/// @return @a tsk_true if succeed and @a tsk_false otherwize.
+/// @return @a tsk_true if succeed and @a tsk_false otherwize.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t tcomp_compressordisp_compress(tcomp_compressordisp_t *dispatcher, uint64_t compartmentId, const void *input_ptr, tsk_size_t input_size, void *output_ptr, tsk_size_t *output_size, tsk_bool_t stream)
{
- tsk_bool_t ret = tsk_true;
- int i = 0;
-
- /* For each compartment id create/retrieve one compressor instance */
- tcomp_compartment_t *lpCompartment = tcomp_statehandler_getCompartment(dispatcher->stateHandler, compartmentId);
-
- if(!lpCompartment){
- TSK_DEBUG_ERROR("You must provide a valid compartment to perform compression.");
- return tsk_false;
- }
-
-
- /*
- * Performs compression.
- */
- tsk_safeobj_lock(dispatcher);
-
- for( i = 0; (i < TCOMP_MAX_COMPRESSORS && dispatcher->compressors[i]); i++ ){
- if((ret = dispatcher->compressors[i](lpCompartment, input_ptr, input_size, output_ptr, output_size, stream))) {
- break;
- }
- }
-
- tsk_safeobj_unlock(dispatcher);
-
-
- /*
- * STREAM case. FIXME:Because I'm a lazy man I only support 0xFF00 case
- */
- if(stream){
- uint8_t* escapedBuffer;
- tsk_size_t i, j;
- tsk_size_t escapedBufferSize = (*output_size + 2); /* 2 = strlen(0xffff) */
-
- for(i = 0; i < *output_size ; i++) {
- escapedBufferSize += ((uint8_t*)output_ptr)[i] == 0xff ? 1 : 0;
- }
- escapedBuffer = (uint8_t*)tsk_calloc(escapedBufferSize, sizeof(uint8_t));
-
- for(i = 0, j = 0; i < *output_size; i++, j++){
- escapedBuffer[j] = ((uint8_t*)output_ptr)[i];
- if(escapedBuffer[j] == 0xff) {
- escapedBuffer[++j] = 0x00;
- }
- }
-
- /* End stream */
- escapedBuffer[escapedBufferSize-1] = escapedBuffer[escapedBufferSize-2] = 0xff;
- memcpy(output_ptr, escapedBuffer, escapedBufferSize);
-
- *output_size = escapedBufferSize; /* Update size */
- TSK_FREE(escapedBuffer); /* free */
- }
-
- /*
- * NACK
- */
- if(ret && TCOMP_NACK_SUPPORTED){
- /* store nack for later retrieval in case of errors */
- uint8_t nackId[TSK_SHA1_DIGEST_SIZE];
- tsk_sha1context_t sha;
-
- tsk_sha1reset(&sha);
- tsk_sha1input(&sha, (const uint8_t*)output_ptr, *output_size);
- tsk_sha1result(&sha, (uint8_t*)nackId);
- tcomp_compartment_addNack(lpCompartment, nackId);
- }
-
- return ret;
+ tsk_bool_t ret = tsk_true;
+ int i = 0;
+
+ /* For each compartment id create/retrieve one compressor instance */
+ tcomp_compartment_t *lpCompartment = tcomp_statehandler_getCompartment(dispatcher->stateHandler, compartmentId);
+
+ if(!lpCompartment) {
+ TSK_DEBUG_ERROR("You must provide a valid compartment to perform compression.");
+ return tsk_false;
+ }
+
+
+ /*
+ * Performs compression.
+ */
+ tsk_safeobj_lock(dispatcher);
+
+ for( i = 0; (i < TCOMP_MAX_COMPRESSORS && dispatcher->compressors[i]); i++ ) {
+ if((ret = dispatcher->compressors[i](lpCompartment, input_ptr, input_size, output_ptr, output_size, stream))) {
+ break;
+ }
+ }
+
+ tsk_safeobj_unlock(dispatcher);
+
+
+ /*
+ * STREAM case. FIXME:Because I'm a lazy man I only support 0xFF00 case
+ */
+ if(stream) {
+ uint8_t* escapedBuffer;
+ tsk_size_t i, j;
+ tsk_size_t escapedBufferSize = (*output_size + 2); /* 2 = strlen(0xffff) */
+
+ for(i = 0; i < *output_size ; i++) {
+ escapedBufferSize += ((uint8_t*)output_ptr)[i] == 0xff ? 1 : 0;
+ }
+ escapedBuffer = (uint8_t*)tsk_calloc(escapedBufferSize, sizeof(uint8_t));
+
+ for(i = 0, j = 0; i < *output_size; i++, j++) {
+ escapedBuffer[j] = ((uint8_t*)output_ptr)[i];
+ if(escapedBuffer[j] == 0xff) {
+ escapedBuffer[++j] = 0x00;
+ }
+ }
+
+ /* End stream */
+ escapedBuffer[escapedBufferSize-1] = escapedBuffer[escapedBufferSize-2] = 0xff;
+ memcpy(output_ptr, escapedBuffer, escapedBufferSize);
+
+ *output_size = escapedBufferSize; /* Update size */
+ TSK_FREE(escapedBuffer); /* free */
+ }
+
+ /*
+ * NACK
+ */
+ if(ret && TCOMP_NACK_SUPPORTED) {
+ /* store nack for later retrieval in case of errors */
+ uint8_t nackId[TSK_SHA1_DIGEST_SIZE];
+ tsk_sha1context_t sha;
+
+ tsk_sha1reset(&sha);
+ tsk_sha1input(&sha, (const uint8_t*)output_ptr, *output_size);
+ tsk_sha1result(&sha, (uint8_t*)nackId);
+ tcomp_compartment_addNack(lpCompartment, nackId);
+ }
+
+ return ret;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Adds new compressor the list of the compressors.
+/// Adds new compressor the list of the compressors.
///
///
-/// @param [in,out] dispatcher The compressor dispatcher.
-/// @param compressor A function pointer to the new compressor.
+/// @param [in,out] dispatcher The compressor dispatcher.
+/// @param compressor A function pointer to the new compressor.
////////////////////////////////////////////////////////////////////////////////////////////////////
int tcomp_compressordisp_addCompressor(tcomp_compressordisp_t *dispatcher, tcomp_compressor_compress_f compressor)
{
- tsk_size_t i;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- for(i = 0; i < TCOMP_MAX_COMPRESSORS; i++){
- if(!dispatcher->compressors[i]){
- dispatcher->compressors[i] = compressor;
- return 0;
- }
- }
- return -2;
+ tsk_size_t i;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ for(i = 0; i < TCOMP_MAX_COMPRESSORS; i++) {
+ if(!dispatcher->compressors[i]) {
+ dispatcher->compressors[i] = compressor;
+ return 0;
+ }
+ }
+ return -2;
}
/** Removes a compressor
*/
int tcomp_compressordisp_removeCompressor(tcomp_compressordisp_t *dispatcher, tcomp_compressor_compress_f compressor)
{
- tsk_size_t i;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- for(i = 0; i < TCOMP_MAX_COMPRESSORS; i++){
- if(dispatcher->compressors[i] == compressor){
- dispatcher->compressors[i] = tsk_null;
- return 0;
- }
- }
- return -2;
+ tsk_size_t i;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ for(i = 0; i < TCOMP_MAX_COMPRESSORS; i++) {
+ if(dispatcher->compressors[i] == compressor) {
+ dispatcher->compressors[i] = tsk_null;
+ return 0;
+ }
+ }
+ return -2;
}
@@ -192,46 +192,45 @@ int tcomp_compressordisp_removeCompressor(tcomp_compressordisp_t *dispatcher, tc
//
static tsk_object_t* tcomp_compressordisp_ctor(tsk_object_t * self, va_list * app)
{
- tcomp_compressordisp_t *compressordisp = self;
- if(compressordisp){
- int i = 0;
- compressordisp->stateHandler = va_arg(*app, const tcomp_statehandler_t*);
-
- compressordisp->compressors[0] = tcomp_compressor_deflate_compress; /* If you don't want deflate compressor then remove this line. */
- compressordisp->compressors[1] = tcomp_compressor_dummy_compress; /* RFC 4896 [11. Uncompressed Bytecode]. */
-
- /* Initialize safeobject */
- tsk_safeobj_init(compressordisp);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new compressor dispatcher.");
- }
-
- return self;
+ tcomp_compressordisp_t *compressordisp = self;
+ if(compressordisp) {
+ int i = 0;
+ compressordisp->stateHandler = va_arg(*app, const tcomp_statehandler_t*);
+
+ compressordisp->compressors[0] = tcomp_compressor_deflate_compress; /* If you don't want deflate compressor then remove this line. */
+ compressordisp->compressors[1] = tcomp_compressor_dummy_compress; /* RFC 4896 [11. Uncompressed Bytecode]. */
+
+ /* Initialize safeobject */
+ tsk_safeobj_init(compressordisp);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new compressor dispatcher.");
+ }
+
+ return self;
}
static tsk_object_t* tcomp_compressordisp_dtor(tsk_object_t *self)
{
- tcomp_compressordisp_t *compressordisp = self;
- if(compressordisp){
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(compressordisp);
-
- memset(compressordisp->compressors, 0 , sizeof(compressordisp->compressors));
- compressordisp->stateHandler = tsk_null; // not owner
- }
- else{
- TSK_DEBUG_ERROR("Null dispatcher.");
- }
-
- return self;
+ tcomp_compressordisp_t *compressordisp = self;
+ if(compressordisp) {
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(compressordisp);
+
+ memset(compressordisp->compressors, 0 , sizeof(compressordisp->compressors));
+ compressordisp->stateHandler = tsk_null; // not owner
+ }
+ else {
+ TSK_DEBUG_ERROR("Null dispatcher.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_compressordisp_def_s =
-{
- sizeof(tcomp_compressordisp_t),
- tcomp_compressordisp_ctor,
- tcomp_compressordisp_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_compressordisp_def_s = {
+ sizeof(tcomp_compressordisp_t),
+ tcomp_compressordisp_ctor,
+ tcomp_compressordisp_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_compressordisp_def_t = &tcomp_compressordisp_def_s;
diff --git a/tinySIGCOMP/src/tcomp_compressordisp.h b/tinySIGCOMP/src/tcomp_compressordisp.h
index 17146f5..d52cbbd 100755
--- a/tinySIGCOMP/src/tcomp_compressordisp.h
+++ b/tinySIGCOMP/src/tcomp_compressordisp.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -49,14 +49,13 @@ TCOMP_BEGIN_DECLS
/**Compressor dispatcher.
*/
-typedef struct tcomp_compressordisp_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_compressordisp_s {
+ TSK_DECLARE_OBJECT;
- tcomp_compressor_compress_f compressors[TCOMP_MAX_COMPRESSORS];
- const tcomp_statehandler_t* stateHandler;
+ tcomp_compressor_compress_f compressors[TCOMP_MAX_COMPRESSORS];
+ const tcomp_statehandler_t* stateHandler;
- TSK_DECLARE_SAFEOBJ;
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_compressordisp_t;
diff --git a/tinySIGCOMP/src/tcomp_decompressordisp.c b/tinySIGCOMP/src/tcomp_decompressordisp.c
index fbf6192..a1c17f8 100755
--- a/tinySIGCOMP/src/tcomp_decompressordisp.c
+++ b/tinySIGCOMP/src/tcomp_decompressordisp.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -44,282 +44,286 @@
*/
static int pred_find_streambuffer_by_id(const tsk_list_item_t *item, const void *id)
{
- if(item && item->data)
- {
- tcomp_stream_buffer_t *streambuffer = item->data;
- int64_t res = (streambuffer->id - *((int64_t*)id));
- return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
- }
- return -1;
+ if(item && item->data) {
+ tcomp_stream_buffer_t *streambuffer = item->data;
+ int64_t res = (streambuffer->id - *((int64_t*)id));
+ return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
+ }
+ return -1;
}
tcomp_stream_buffer_t* tcomp_stream_buffer_create(uint64_t id)
{
- return tsk_object_new(tcomp_stream_buffer_def_t, id);
+ return tsk_object_new(tcomp_stream_buffer_def_t, id);
}
tcomp_decompressordisp_t* tcomp_decompressordisp_create(const tcomp_statehandler_t* statehandler)
{
- return tsk_object_new(tcomp_decompressordisp_def_t, statehandler);
+ return tsk_object_new(tcomp_decompressordisp_def_t, statehandler);
}
/**Decompress a message.
*/
tsk_bool_t tcomp_decompressordisp_decompress(tcomp_decompressordisp_t *dispatcher, const void* input_ptr, tsk_size_t input_size, tcomp_result_t *lpResult)
{
- tsk_bool_t ret = tsk_true;
- uint64_t streamId = 0;
- const tsk_list_item_t *item_const;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_false;
- }
-
- /*
- * Check if transport type changed.
- */
- if(lpResult->isStreamBased){
- if(!dispatcher->streamBuffers){
- dispatcher->streamBuffers = tsk_list_create();
- }
-
- streamId = lpResult->streamId;
- ret = tcomp_decompressordisp_appendStream(dispatcher, input_ptr, input_size, streamId);
- if(!ret){
- TSK_DEBUG_ERROR("Failed to append new stream buffer.");
- return 0;
- }
- }
-
- if(lpResult->isStreamBased){
- tsk_size_t size = 0;
- uint32_t discard_count = 0;
- tcomp_stream_buffer_t *lpBuffer;
-
- item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
- if(!item_const || !(lpBuffer = item_const->data)){
- TSK_DEBUG_ERROR("Failed to find stream buffer by id %llu.", streamId);
- return 0;
- }
-
- if(ret && tcomp_decompressordisp_getNextStreamMsg(dispatcher, streamId, &discard_count, &size)){
- ret &= tcomp_decompressordisp_internalDecompress(dispatcher, tcomp_buffer_getBuffer(lpBuffer->buffer), size, &lpResult);
-
- /* remove buffer and discard */
- tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
- ret &= tcomp_buffer_removeBuff(lpBuffer->buffer, 0, size);
- }
- if(discard_count){
- tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
- }
- if(size){
- //ret&= lpBuffer->removeBuff(0, (size));
- }
- }
- else{
- ret &= tcomp_decompressordisp_internalDecompress(dispatcher, input_ptr, input_size, &lpResult);
- }
-
- return ret;
+ tsk_bool_t ret = tsk_true;
+ uint64_t streamId = 0;
+ const tsk_list_item_t *item_const;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_false;
+ }
+
+ /*
+ * Check if transport type changed.
+ */
+ if(lpResult->isStreamBased) {
+ if(!dispatcher->streamBuffers) {
+ dispatcher->streamBuffers = tsk_list_create();
+ }
+
+ streamId = lpResult->streamId;
+ ret = tcomp_decompressordisp_appendStream(dispatcher, input_ptr, input_size, streamId);
+ if(!ret) {
+ TSK_DEBUG_ERROR("Failed to append new stream buffer.");
+ return 0;
+ }
+ }
+
+ if(lpResult->isStreamBased) {
+ tsk_size_t size = 0;
+ uint32_t discard_count = 0;
+ tcomp_stream_buffer_t *lpBuffer;
+
+ item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
+ if(!item_const || !(lpBuffer = item_const->data)) {
+ TSK_DEBUG_ERROR("Failed to find stream buffer by id %llu.", streamId);
+ return 0;
+ }
+
+ if(ret && tcomp_decompressordisp_getNextStreamMsg(dispatcher, streamId, &discard_count, &size)) {
+ ret &= tcomp_decompressordisp_internalDecompress(dispatcher, tcomp_buffer_getBuffer(lpBuffer->buffer), size, &lpResult);
+
+ /* remove buffer and discard */
+ tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
+ ret &= tcomp_buffer_removeBuff(lpBuffer->buffer, 0, size);
+ }
+ if(discard_count) {
+ tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
+ }
+ if(size) {
+ //ret&= lpBuffer->removeBuff(0, (size));
+ }
+ }
+ else {
+ ret &= tcomp_decompressordisp_internalDecompress(dispatcher, input_ptr, input_size, &lpResult);
+ }
+
+ return ret;
}
/**Gets the next message from the queue.
*/
tsk_bool_t tcomp_decompressordisp_getNextMessage(tcomp_decompressordisp_t *dispatcher, tcomp_result_t *lpResult)
{
- tsk_bool_t ret = tsk_true;
- tsk_size_t size=0;
- uint32_t discard_count = 0;
- uint64_t streamId;
- tcomp_stream_buffer_t *lpBuffer;
- const tsk_list_item_t *item_const;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_false;
- }
-
- streamId = lpResult->streamId;
-
- item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
- if(!item_const || !(lpBuffer = item_const->data)){
- TSK_DEBUG_ERROR("Failed to find stream buffer by id %llu.", streamId);
- return tsk_false;
- }
-
- if(ret && tcomp_decompressordisp_getNextStreamMsg(dispatcher, streamId, &discard_count, &size)){
- ret &= tcomp_decompressordisp_internalDecompress(dispatcher, tcomp_buffer_getBuffer(lpBuffer->buffer), size, &lpResult);
-
- /* remove buffer and discard */
- tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
- ret &= tcomp_buffer_removeBuff(lpBuffer->buffer, 0, size);
- }
- else {
- ret = tsk_false; /* Is it right? */
- }
-
- if(discard_count){
- tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
- }
- return ret;
+ tsk_bool_t ret = tsk_true;
+ tsk_size_t size=0;
+ uint32_t discard_count = 0;
+ uint64_t streamId;
+ tcomp_stream_buffer_t *lpBuffer;
+ const tsk_list_item_t *item_const;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_false;
+ }
+
+ streamId = lpResult->streamId;
+
+ item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
+ if(!item_const || !(lpBuffer = item_const->data)) {
+ TSK_DEBUG_ERROR("Failed to find stream buffer by id %llu.", streamId);
+ return tsk_false;
+ }
+
+ if(ret && tcomp_decompressordisp_getNextStreamMsg(dispatcher, streamId, &discard_count, &size)) {
+ ret &= tcomp_decompressordisp_internalDecompress(dispatcher, tcomp_buffer_getBuffer(lpBuffer->buffer), size, &lpResult);
+
+ /* remove buffer and discard */
+ tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
+ ret &= tcomp_buffer_removeBuff(lpBuffer->buffer, 0, size);
+ }
+ else {
+ ret = tsk_false; /* Is it right? */
+ }
+
+ if(discard_count) {
+ tcomp_buffer_discardLastBytes(lpBuffer->buffer, discard_count);
+ }
+ return ret;
}
/**Decompress a message.
*/
tsk_bool_t tcomp_decompressordisp_internalDecompress(tcomp_decompressordisp_t *dispatcher, const void* input_ptr, const tsk_size_t input_size, tcomp_result_t **lpResult)
{
- tcomp_message_t *sigCompMessage = tsk_null;
- tcomp_udvm_t *sigCompUDVM = tsk_null;
- tsk_bool_t ret = tsk_false;
- int32_t nack_code = NACK_NONE;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter.");
- goto bail;
- }
-
- sigCompMessage = tcomp_message_create(input_ptr, input_size, (*lpResult)->isStreamBased, &nack_code);
- if(!sigCompMessage || !sigCompMessage->isOK){
- TSK_DEBUG_ERROR("Failed to create new sigcomp message");
- if(nack_code != NACK_NONE && ((*lpResult)->isNack = TCOMP_NACK_SUPPORTED(dispatcher))){
- tcomp_nackinfo_write_3((*lpResult)->nack_info,
- nack_code,
- input_ptr, input_size);
- }
- goto bail;
- }
- else if(sigCompMessage->isNack && TCOMP_NACK_SUPPORTED(dispatcher)){
- /* Remote party send us a NACK --> handle it */
- tcomp_statehandler_handleNack((tcomp_statehandler_t*)dispatcher->stateHandler, (const tcomp_nackinfo_t*)sigCompMessage->nack_info);
- (*lpResult)->isNack = tsk_true;
-
- goto bail;
- }
-
- /* Create new UDVM entity for each SigComp message */
- sigCompUDVM = tcomp_udvm_create(sigCompMessage, (tcomp_statehandler_t*)dispatcher->stateHandler, *lpResult);
-
- /* Decompress message */
- ret = tcomp_udvm_decompress(sigCompUDVM);
-
- /* decompression failed --> returns nack if supported */
- if(!ret){
- /* Decompression failed --> return NACK message to the application layer */
- (*lpResult)->isNack = TCOMP_NACK_SUPPORTED(dispatcher);
- }
-
+ tcomp_message_t *sigCompMessage = tsk_null;
+ tcomp_udvm_t *sigCompUDVM = tsk_null;
+ tsk_bool_t ret = tsk_false;
+ int32_t nack_code = NACK_NONE;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ goto bail;
+ }
+
+ sigCompMessage = tcomp_message_create(input_ptr, input_size, (*lpResult)->isStreamBased, &nack_code);
+ if(!sigCompMessage || !sigCompMessage->isOK) {
+ TSK_DEBUG_ERROR("Failed to create new sigcomp message");
+ if(nack_code != NACK_NONE && ((*lpResult)->isNack = TCOMP_NACK_SUPPORTED(dispatcher))) {
+ tcomp_nackinfo_write_3((*lpResult)->nack_info,
+ nack_code,
+ input_ptr, input_size);
+ }
+ goto bail;
+ }
+ else if(sigCompMessage->isNack && TCOMP_NACK_SUPPORTED(dispatcher)) {
+ /* Remote party send us a NACK --> handle it */
+ tcomp_statehandler_handleNack((tcomp_statehandler_t*)dispatcher->stateHandler, (const tcomp_nackinfo_t*)sigCompMessage->nack_info);
+ (*lpResult)->isNack = tsk_true;
+
+ goto bail;
+ }
+
+ /* Create new UDVM entity for each SigComp message */
+ sigCompUDVM = tcomp_udvm_create(sigCompMessage, (tcomp_statehandler_t*)dispatcher->stateHandler, *lpResult);
+
+ /* Decompress message */
+ ret = tcomp_udvm_decompress(sigCompUDVM);
+
+ /* decompression failed --> returns nack if supported */
+ if(!ret) {
+ /* Decompression failed --> return NACK message to the application layer */
+ (*lpResult)->isNack = TCOMP_NACK_SUPPORTED(dispatcher);
+ }
+
bail:
- /* Delete Message */
- TSK_OBJECT_SAFE_FREE(sigCompMessage);
+ /* Delete Message */
+ TSK_OBJECT_SAFE_FREE(sigCompMessage);
- /* Delete UDVM entity */
- TSK_OBJECT_SAFE_FREE(sigCompUDVM);
+ /* Delete UDVM entity */
+ TSK_OBJECT_SAFE_FREE(sigCompUDVM);
- return ret;
+ return ret;
}
/**Appends stream buffer.
*/
tsk_bool_t tcomp_decompressordisp_appendStream(tcomp_decompressordisp_t *dispatcher, const void* input_ptr, tsk_size_t input_size, uint64_t streamId)
{
- tcomp_stream_buffer_t* lpBuffer = tsk_null;
- const tsk_list_item_t *item_const;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_false;
- }
-
- item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
- if(!item_const || !(lpBuffer = item_const->data)){
- /* First time we get this stream ID */
- tcomp_buffer_handle_t *newbuf = tcomp_stream_buffer_create(streamId);
- if(newbuf){
- lpBuffer = newbuf;
- lpBuffer->buffer = tcomp_buffer_create_null();
- tsk_list_push_back_data(dispatcher->streamBuffers, ((void**) &newbuf));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new stream buffer.");
- return tsk_false;
- }
- }
-
- /* Check if buffer is too large */
- if(lpBuffer->buffer && (tcomp_buffer_getSize(lpBuffer->buffer) + input_size) > TCOMP_MAX_STREAM_BUFFER_SIZE){
- tcomp_buffer_freeBuff(lpBuffer->buffer);
- return tsk_false;
- }
-
- /* append new buffer */
- if(!tcomp_buffer_appendBuff(lpBuffer->buffer, input_ptr, input_size)){
- TSK_DEBUG_ERROR("Failed to append new buffer.");
- tcomp_buffer_freeBuff(lpBuffer->buffer);
- return tsk_false;
- }
-
- return tsk_true;
+ tcomp_stream_buffer_t* lpBuffer = tsk_null;
+ const tsk_list_item_t *item_const;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_false;
+ }
+
+ item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
+ if(!item_const || !(lpBuffer = item_const->data)) {
+ /* First time we get this stream ID */
+ tcomp_buffer_handle_t *newbuf = tcomp_stream_buffer_create(streamId);
+ if(newbuf) {
+ lpBuffer = newbuf;
+ lpBuffer->buffer = tcomp_buffer_create_null();
+ tsk_list_push_back_data(dispatcher->streamBuffers, ((void**) &newbuf));
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new stream buffer.");
+ return tsk_false;
+ }
+ }
+
+ /* Check if buffer is too large */
+ if(lpBuffer->buffer && (tcomp_buffer_getSize(lpBuffer->buffer) + input_size) > TCOMP_MAX_STREAM_BUFFER_SIZE) {
+ tcomp_buffer_freeBuff(lpBuffer->buffer);
+ return tsk_false;
+ }
+
+ /* append new buffer */
+ if(!tcomp_buffer_appendBuff(lpBuffer->buffer, input_ptr, input_size)) {
+ TSK_DEBUG_ERROR("Failed to append new buffer.");
+ tcomp_buffer_freeBuff(lpBuffer->buffer);
+ return tsk_false;
+ }
+
+ return tsk_true;
}
/**Gets the next message from the queue.
*/
tsk_bool_t tcomp_decompressordisp_getNextStreamMsg(tcomp_decompressordisp_t *dispatcher, uint64_t streamId, uint32_t *discard_count, tsk_size_t *size)
{
- tcomp_stream_buffer_t *lpBuffer;
- const tsk_list_item_t *item_const;
-
- uint8_t quote_count = 0;
- uint8_t* start;
- uint8_t* end;
-
- if(!dispatcher){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_false;
- }
-
- /*
- * RFC 3320 - 4.2.1. Decompressor Dispatcher Strategies [strategie 1]
- */
- item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
- if(!item_const || !(lpBuffer = item_const->data)){
- TSK_DEBUG_ERROR("Failed to find stream buffer by id %llu.", streamId);
- return tsk_false;
- }
-
- *size = 0;
- *discard_count = 0;
-
- quote_count = 0;
- start = tcomp_buffer_getBuffer(lpBuffer->buffer);
- end = (start + tcomp_buffer_getSize(lpBuffer->buffer));
-
- while(start<end){
- if(*start==0xff){
- start++;
- if(*start==0xff)
- { /* end message */
- if(*size) return tsk_true;
- else /* message is empty --> delete this empty message(length=2) */
- {
- start--;
- memcpy(start, (start+2), (end-start));
- (*discard_count)+=2;
- end-=2;
- continue;
- }
- }
-
- quote_count = *start;
- memcpy((start), (start+1), (end-start));
- end--;
- (*discard_count)++;
- start+=(quote_count);
- (*size)+=(1+quote_count);
- }else { start++; (*size)++; }
- }
-
- return tsk_false;
+ tcomp_stream_buffer_t *lpBuffer;
+ const tsk_list_item_t *item_const;
+
+ uint8_t quote_count = 0;
+ uint8_t* start;
+ uint8_t* end;
+
+ if(!dispatcher) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_false;
+ }
+
+ /*
+ * RFC 3320 - 4.2.1. Decompressor Dispatcher Strategies [strategie 1]
+ */
+ item_const = tsk_list_find_item_by_pred(dispatcher->streamBuffers, pred_find_streambuffer_by_id, &streamId);
+ if(!item_const || !(lpBuffer = item_const->data)) {
+ TSK_DEBUG_ERROR("Failed to find stream buffer by id %llu.", streamId);
+ return tsk_false;
+ }
+
+ *size = 0;
+ *discard_count = 0;
+
+ quote_count = 0;
+ start = tcomp_buffer_getBuffer(lpBuffer->buffer);
+ end = (start + tcomp_buffer_getSize(lpBuffer->buffer));
+
+ while(start<end) {
+ if(*start==0xff) {
+ start++;
+ if(*start==0xff) {
+ /* end message */
+ if(*size) {
+ return tsk_true;
+ }
+ else { /* message is empty --> delete this empty message(length=2) */
+ start--;
+ memcpy(start, (start+2), (end-start));
+ (*discard_count)+=2;
+ end-=2;
+ continue;
+ }
+ }
+
+ quote_count = *start;
+ memcpy((start), (start+1), (end-start));
+ end--;
+ (*discard_count)++;
+ start+=(quote_count);
+ (*size)+=(1+quote_count);
+ }
+ else {
+ start++;
+ (*size)++;
+ }
+ }
+
+ return tsk_false;
}
@@ -336,42 +340,41 @@ tsk_bool_t tcomp_decompressordisp_getNextStreamMsg(tcomp_decompressordisp_t *dis
//
static tsk_object_t* tcomp_decompressordisp_ctor(tsk_object_t* self, va_list * app)
{
- tcomp_decompressordisp_t *decompressordisp = self;
- if(decompressordisp){
- decompressordisp->stateHandler = va_arg(*app, const tcomp_statehandler_t*);
-
- /* Initialize safeobject */
- tsk_safeobj_init(decompressordisp);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new decompressor dispatcher.");
- }
-
- return self;
+ tcomp_decompressordisp_t *decompressordisp = self;
+ if(decompressordisp) {
+ decompressordisp->stateHandler = va_arg(*app, const tcomp_statehandler_t*);
+
+ /* Initialize safeobject */
+ tsk_safeobj_init(decompressordisp);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new decompressor dispatcher.");
+ }
+
+ return self;
}
static tsk_object_t* tcomp_decompressordisp_dtor(tsk_object_t *self)
{
- tcomp_decompressordisp_t *decompressordisp = self;
- if(decompressordisp){
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(decompressordisp);
-
- TSK_OBJECT_SAFE_FREE(decompressordisp->streamBuffers);
- }
- else{
- TSK_DEBUG_ERROR("Null dispatcher.");
- }
-
- return self;
+ tcomp_decompressordisp_t *decompressordisp = self;
+ if(decompressordisp) {
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(decompressordisp);
+
+ TSK_OBJECT_SAFE_FREE(decompressordisp->streamBuffers);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null dispatcher.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_decompressordisp_def_s =
-{
- sizeof(tcomp_decompressordisp_t),
- tcomp_decompressordisp_ctor,
- tcomp_decompressordisp_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_decompressordisp_def_s = {
+ sizeof(tcomp_decompressordisp_t),
+ tcomp_decompressordisp_ctor,
+ tcomp_decompressordisp_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_decompressordisp_def_t = &tcomp_decompressordisp_def_s;
@@ -384,35 +387,34 @@ const tsk_object_def_t *tcomp_decompressordisp_def_t = &tcomp_decompressordisp_d
static tsk_object_t* tcomp_stream_buffer_ctor(tsk_object_t* self, va_list * app)
{
- tcomp_stream_buffer_t *stream_buffer = self;
- if(stream_buffer){
- stream_buffer->id = va_arg(*app, uint64_t);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new stream buffer.");
- }
-
- return self;
+ tcomp_stream_buffer_t *stream_buffer = self;
+ if(stream_buffer) {
+ stream_buffer->id = va_arg(*app, uint64_t);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new stream buffer.");
+ }
+
+ return self;
}
static tsk_object_t* tcomp_stream_buffer_dtor(tsk_object_t* self)
{
- tcomp_stream_buffer_t *stream_buffer = self;
- if(stream_buffer){
- TSK_OBJECT_SAFE_FREE(stream_buffer->buffer);
- }
- else{
- TSK_DEBUG_ERROR("Null stream buffer.");
- }
-
- return self;
+ tcomp_stream_buffer_t *stream_buffer = self;
+ if(stream_buffer) {
+ TSK_OBJECT_SAFE_FREE(stream_buffer->buffer);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null stream buffer.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_stream_buffer_def_s =
-{
- sizeof(tcomp_stream_buffer_t),
- tcomp_stream_buffer_ctor,
- tcomp_stream_buffer_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_stream_buffer_def_s = {
+ sizeof(tcomp_stream_buffer_t),
+ tcomp_stream_buffer_ctor,
+ tcomp_stream_buffer_dtor,
+ tsk_null
};
const tsk_object_def_t* tcomp_stream_buffer_def_t = &tcomp_stream_buffer_def_s;
diff --git a/tinySIGCOMP/src/tcomp_decompressordisp.h b/tinySIGCOMP/src/tcomp_decompressordisp.h
index 79bb635..9916a62 100755
--- a/tinySIGCOMP/src/tcomp_decompressordisp.h
+++ b/tinySIGCOMP/src/tcomp_decompressordisp.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -42,25 +42,23 @@
TCOMP_BEGIN_DECLS
-typedef struct tcomp_stream_buffer_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_stream_buffer_s {
+ TSK_DECLARE_OBJECT;
- uint64_t id; /**< Buffer identifier */
- tcomp_buffer_handle_t *buffer; /**< Buffer handle */
+ uint64_t id; /**< Buffer identifier */
+ tcomp_buffer_handle_t *buffer; /**< Buffer handle */
- TSK_DECLARE_SAFEOBJ;
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_stream_buffer_t;
-typedef struct tcomp_decompressordisp_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_decompressordisp_s {
+ TSK_DECLARE_OBJECT;
- const tcomp_statehandler_t* stateHandler;
- tcomp_stream_buffer_L_t *streamBuffers;
+ const tcomp_statehandler_t* stateHandler;
+ tcomp_stream_buffer_L_t *streamBuffers;
- TSK_DECLARE_SAFEOBJ;
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_decompressordisp_t;
diff --git a/tinySIGCOMP/src/tcomp_deflatedata.c b/tinySIGCOMP/src/tcomp_deflatedata.c
index 12a8fdd..02ea2d9 100755
--- a/tinySIGCOMP/src/tcomp_deflatedata.c
+++ b/tinySIGCOMP/src/tcomp_deflatedata.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -33,36 +33,36 @@
tcomp_deflatedata_t* tcomp_deflatedata_create_2(tsk_bool_t isStream, int z_level, int z_windowBits)
{
- tcomp_deflatedata_t *deflatedata;
- if((deflatedata = tsk_object_new(tcomp_deflatedata_def_t))){
- deflatedata->isStream = isStream;
- deflatedata->zLevel = z_level;
- deflatedata->zWindowBits = z_windowBits;
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp defalte data.");
- }
-
- return deflatedata;
+ tcomp_deflatedata_t *deflatedata;
+ if((deflatedata = tsk_object_new(tcomp_deflatedata_def_t))) {
+ deflatedata->isStream = isStream;
+ deflatedata->zLevel = z_level;
+ deflatedata->zWindowBits = z_windowBits;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp defalte data.");
+ }
+
+ return deflatedata;
}
tcomp_deflatedata_t* tcomp_deflatedata_create(tsk_bool_t isStream, tsk_bool_t useOnlyACKedStates)
{
- tcomp_deflatedata_t* deflatedata;
- if((deflatedata = tcomp_deflatedata_create_2(isStream, Z_BEST_COMPRESSION, Z_DEFAULT_WINDOW_BITS))){
- deflatedata->useOnlyACKedStates = useOnlyACKedStates;
- }
- return deflatedata;
+ tcomp_deflatedata_t* deflatedata;
+ if((deflatedata = tcomp_deflatedata_create_2(isStream, Z_BEST_COMPRESSION, Z_DEFAULT_WINDOW_BITS))) {
+ deflatedata->useOnlyACKedStates = useOnlyACKedStates;
+ }
+ return deflatedata;
}
tsk_bool_t tcomp_deflatedata_isStateful(tcomp_deflatedata_t *deflatedata)
{
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return tsk_false;
- }
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return tsk_false;
+ }
- return deflatedata->stream_acked.stateful;
+ return deflatedata->stream_acked.stateful;
}
@@ -78,38 +78,37 @@ tsk_bool_t tcomp_deflatedata_isStateful(tcomp_deflatedata_t *deflatedata)
static void* tcomp_deflatedata_ctor(void * self, va_list * app)
{
- tcomp_deflatedata_t *deflatedata = self;
- if(deflatedata){
- /* Initialize safeobject */
- tsk_safeobj_init(deflatedata);
- }
+ tcomp_deflatedata_t *deflatedata = self;
+ if(deflatedata) {
+ /* Initialize safeobject */
+ tsk_safeobj_init(deflatedata);
+ }
- return self;
+ return self;
}
static void* tcomp_deflatedata_dtor(void *self)
{
- tcomp_deflatedata_t *deflatedata = self;
- if(deflatedata){
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(deflatedata);
-
- TSK_OBJECT_SAFE_FREE(deflatedata->ghostState);
-
- tcomp_deflatedata_zUnInit(deflatedata);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp defalte data.");
- }
-
- return self;
+ tcomp_deflatedata_t *deflatedata = self;
+ if(deflatedata) {
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(deflatedata);
+
+ TSK_OBJECT_SAFE_FREE(deflatedata->ghostState);
+
+ tcomp_deflatedata_zUnInit(deflatedata);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp defalte data.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tsk_deflatedata_def_s =
-{
- sizeof(tcomp_deflatedata_t),
- tcomp_deflatedata_ctor,
- tcomp_deflatedata_dtor,
- tsk_null,
+static const tsk_object_def_t tsk_deflatedata_def_s = {
+ sizeof(tcomp_deflatedata_t),
+ tcomp_deflatedata_ctor,
+ tcomp_deflatedata_dtor,
+ tsk_null,
};
const tsk_object_def_t *tcomp_deflatedata_def_t = &tsk_deflatedata_def_s;
diff --git a/tinySIGCOMP/src/tcomp_deflatedata.ghost.c b/tinySIGCOMP/src/tcomp_deflatedata.ghost.c
index bfcb927..2446b6e 100755
--- a/tinySIGCOMP/src/tcomp_deflatedata.ghost.c
+++ b/tinySIGCOMP/src/tcomp_deflatedata.ghost.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -77,26 +77,25 @@ I suppose we would like to compress this message "libsigcomp":
#define GHOST_BYTECODE1_SIZE (GHOST_VERSION_INDEX + 1)
-static const char* DeflateData_deflate_bytecode1_ghost =
-{
- "\xff\xff" // Circular buffer Size (CBS)
- "\xff\xff" // State Memory Size (DMS)
- "\x00\x05" // See 'libsigcomp/asm/deflate.asm'
- "\xff\xff" // (CBS + strlen(input))
-
- "\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\x09\x00\x00"
- "\x00\x0a\x00\x01\x00\x0b\x00\x01\x00\x0d\x00\x01\x00\x0f\x00\x01\x00\x11\x00\x02\x00\x13\x00\x02\x00\x17\x00\x02\x00\x1b"
- "\x00\x02\x00\x1f\x00\x03\x00\x23\x00\x03\x00\x2b\x00\x03\x00\x33\x00\x03\x00\x3b\x00\x04\x00\x43\x00\x04\x00\x53\x00\x04"
- "\x00\x63\x00\x04\x00\x73\x00\x05\x00\x83\x00\x05\x00\xa3\x00\x05\x00\xc3\x00\x05\x00\xe3\x00\x00\x01\x02\x00\x00\x00\x01"
- "\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x01\x00\x05\x00\x01\x00\x07\x00\x02\x00\x09\x00\x02\x00\x0d\x00\x03"
- "\x00\x11\x00\x03\x00\x19\x00\x04\x00\x21\x00\x04\x00\x31\x00\x05\x00\x41\x00\x05\x00\x61\x00\x06\x00\x81\x00\x06\x00\xc1"
- "\x00\x07\x01\x01\x00\x07\x01\x81\x00\x08\x02\x01\x00\x08\x03\x01\x00\x09\x04\x01\x00\x09\x06\x01\x00\x0a\x08\x01\x00\x0a"
- "\x0c\x01\x00\x0b\x10\x01\x00\x0b\x18\x01\x00\x0c\x20\x01\x00\x0c\x30\x01\x00\x0d\x40\x01\x00\x0d\x60\x01"
-
- "\xff\xff" // HASH_LEN
- "\xff\xff" // SMS
- "\xff" // [CPB+DMS+SMS]
- "\xff" // SigComp Version
+static const char* DeflateData_deflate_bytecode1_ghost = {
+ "\xff\xff" // Circular buffer Size (CBS)
+ "\xff\xff" // State Memory Size (DMS)
+ "\x00\x05" // See 'libsigcomp/asm/deflate.asm'
+ "\xff\xff" // (CBS + strlen(input))
+
+ "\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\x09\x00\x00"
+ "\x00\x0a\x00\x01\x00\x0b\x00\x01\x00\x0d\x00\x01\x00\x0f\x00\x01\x00\x11\x00\x02\x00\x13\x00\x02\x00\x17\x00\x02\x00\x1b"
+ "\x00\x02\x00\x1f\x00\x03\x00\x23\x00\x03\x00\x2b\x00\x03\x00\x33\x00\x03\x00\x3b\x00\x04\x00\x43\x00\x04\x00\x53\x00\x04"
+ "\x00\x63\x00\x04\x00\x73\x00\x05\x00\x83\x00\x05\x00\xa3\x00\x05\x00\xc3\x00\x05\x00\xe3\x00\x00\x01\x02\x00\x00\x00\x01"
+ "\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x01\x00\x05\x00\x01\x00\x07\x00\x02\x00\x09\x00\x02\x00\x0d\x00\x03"
+ "\x00\x11\x00\x03\x00\x19\x00\x04\x00\x21\x00\x04\x00\x31\x00\x05\x00\x41\x00\x05\x00\x61\x00\x06\x00\x81\x00\x06\x00\xc1"
+ "\x00\x07\x01\x01\x00\x07\x01\x81\x00\x08\x02\x01\x00\x08\x03\x01\x00\x09\x04\x01\x00\x09\x06\x01\x00\x0a\x08\x01\x00\x0a"
+ "\x0c\x01\x00\x0b\x10\x01\x00\x0b\x18\x01\x00\x0c\x20\x01\x00\x0c\x30\x01\x00\x0d\x40\x01\x00\x0d\x60\x01"
+
+ "\xff\xff" // HASH_LEN
+ "\xff\xff" // SMS
+ "\xff" // [CPB+DMS+SMS]
+ "\xff" // SigComp Version
};
@@ -109,36 +108,36 @@ static const char* DeflateData_deflate_bytecode1_ghost =
*/
void tcomp_deflatedata_createGhost(tcomp_deflatedata_t *deflatedata, uint32_t state_length, tcomp_params_t *params)
{
- uint8_t *ghostvalue_ptr = 0;
+ uint8_t *ghostvalue_ptr = 0;
#define GHOSTVALUE_AT(position) (ghostvalue_ptr + position)
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return;
- }
-
- if(deflatedata->ghostState){
- TSK_DEBUG_ERROR("The defalte data already have a ghost state. This MUST never happen.");
- return;
- }
-
- tsk_safeobj_lock(deflatedata);
-
- deflatedata->ghostState = tcomp_state_create(state_length, GHOST_STATE_ADDRESS, GHOST_STATE_INSTRUCTION, GHOST_STATE_MIN_ACCESS_LEN, GHOST_STATE_RETENTION_PRIORITY);
- tcomp_buffer_allocBuff(deflatedata->ghostState->value, state_length);
- ghostvalue_ptr = tcomp_buffer_getBuffer(deflatedata->ghostState->value);
-
- memcpy(ghostvalue_ptr, DeflateData_deflate_bytecode1_ghost, GHOST_BYTECODE1_SIZE);
-
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_START_INDEX), DEFLATE_UDVM_CIRCULAR_START_INDEX );
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_DMS_INDEX), state_length+GHOST_STATE_ADDRESS );
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_END_INDEX), (DEFLATE_UDVM_CIRCULAR_START_INDEX + 0/*input_size*/) );
- // ......
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_HASH_LEN_INDEX), (state_length+8) );
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_SMS_INDEX), state_length );
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CPB_DMS_SMS_INDEX), tcomp_params_getParameters(params) ); // [cpb+dms+sms]+[version]
-
- // ------------------------------------------------------------
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return;
+ }
+
+ if(deflatedata->ghostState) {
+ TSK_DEBUG_ERROR("The defalte data already have a ghost state. This MUST never happen.");
+ return;
+ }
+
+ tsk_safeobj_lock(deflatedata);
+
+ deflatedata->ghostState = tcomp_state_create(state_length, GHOST_STATE_ADDRESS, GHOST_STATE_INSTRUCTION, GHOST_STATE_MIN_ACCESS_LEN, GHOST_STATE_RETENTION_PRIORITY);
+ tcomp_buffer_allocBuff(deflatedata->ghostState->value, state_length);
+ ghostvalue_ptr = tcomp_buffer_getBuffer(deflatedata->ghostState->value);
+
+ memcpy(ghostvalue_ptr, DeflateData_deflate_bytecode1_ghost, GHOST_BYTECODE1_SIZE);
+
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_START_INDEX), DEFLATE_UDVM_CIRCULAR_START_INDEX );
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_DMS_INDEX), state_length+GHOST_STATE_ADDRESS );
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_END_INDEX), (DEFLATE_UDVM_CIRCULAR_START_INDEX + 0/*input_size*/) );
+ // ......
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_HASH_LEN_INDEX), (state_length+8) );
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_SMS_INDEX), state_length );
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CPB_DMS_SMS_INDEX), tcomp_params_getParameters(params) ); // [cpb+dms+sms]+[version]
+
+ // ------------------------------------------------------------
#define GHOST_DICT_CODE_INDEX (GHOST_BYTECODE1_SIZE)
#define GHOST_DICT_WORDS_INDEX (GHOST_DICT_CODE_INDEX + 2)
@@ -148,23 +147,25 @@ void tcomp_deflatedata_createGhost(tcomp_deflatedata_t *deflatedata, uint32_t st
# define GHOST_FIXME2_INDEX (GHOST_DICT_WORDS_INDEX + 0)
#endif
#define GHOST_DEFLATE_BYTECODE_INDEX (GHOST_FIXME2_INDEX + 4)
-#define GHOST_INPUT_INDEX (GHOST_DEFLATE_BYTECODE_INDEX + DEFLATE_BYTECODE_LEN)
+#define GHOST_INPUT_INDEX (GHOST_DEFLATE_BYTECODE_INDEX + DEFLATE_BYTECODE_LEN)
#if USE_DICTS_FOR_COMPRESSION
- BINARY_SET_2BYTES( ghostState->getStateValue()->getBuffer(GHOST_DICT_CODE_INDEX), DEFLATE_FIXME_DICT );
- if( DEFLATE_FIXME_DICT == DEFLATE_NO_DICT ){
- // Nothing to append
- }else{
- if(DEFLATE_FIXME_DICT == DEFLATE_SIP_DICT_ONLY){
- ::memmove( ghostState->getStateValue()->getBuffer(GHOST_DICT_WORDS_INDEX), RFC3485_DICTIONARY_SIP_IDENTIFIER, 4 );
- }else{
- assert(1==0);
- }
- }
+ BINARY_SET_2BYTES( ghostState->getStateValue()->getBuffer(GHOST_DICT_CODE_INDEX), DEFLATE_FIXME_DICT );
+ if( DEFLATE_FIXME_DICT == DEFLATE_NO_DICT ) {
+ // Nothing to append
+ }
+ else {
+ if(DEFLATE_FIXME_DICT == DEFLATE_SIP_DICT_ONLY) {
+ ::memmove( ghostState->getStateValue()->getBuffer(GHOST_DICT_WORDS_INDEX), RFC3485_DICTIONARY_SIP_IDENTIFIER, 4 );
+ }
+ else {
+ assert(1==0);
+ }
+ }
#endif
- memcpy( GHOSTVALUE_AT(GHOST_DEFLATE_BYTECODE_INDEX), (const char*)DEFLATEDATA_DEFLATE_BYTECODE, DEFLATE_BYTECODE_LEN );
+ memcpy( GHOSTVALUE_AT(GHOST_DEFLATE_BYTECODE_INDEX), (const char*)DEFLATEDATA_DEFLATE_BYTECODE, DEFLATE_BYTECODE_LEN );
- tsk_safeobj_unlock(deflatedata);
+ tsk_safeobj_unlock(deflatedata);
#undef GHOSTVALUE_AT
}
@@ -173,78 +174,78 @@ void tcomp_deflatedata_createGhost(tcomp_deflatedata_t *deflatedata, uint32_t st
*/
void tcomp_deflatedata_ackGhost(tcomp_compressordata_t *data, const tcomp_buffer_handle_t *stateid)
{
- tcomp_deflatedata_t *deflatedata = data;
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return;
- }
-
- tsk_safeobj_lock(deflatedata);
-
- if(deflatedata->ghostState){
- /* Update ghost */
- if(tcomp_buffer_startsWith(deflatedata->ghostState->identifier, stateid)){
- /* END() + COPY() */
- tcomp_deflateStream_end(&(deflatedata->stream_acked));
- tcomp_deflateStream_copy(&(deflatedata->stream_acked), &(deflatedata->stream_1));
- deflatedata->stream_acked.stateful = 1;
- deflatedata->stream_acked.dataWaitingAck = 0;
- TSK_DEBUG_INFO("SigComp - ACKed State id=");
- tcomp_buffer_print(stateid);
- }
- }
-
- tsk_safeobj_unlock(deflatedata);
+ tcomp_deflatedata_t *deflatedata = data;
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return;
+ }
+
+ tsk_safeobj_lock(deflatedata);
+
+ if(deflatedata->ghostState) {
+ /* Update ghost */
+ if(tcomp_buffer_startsWith(deflatedata->ghostState->identifier, stateid)) {
+ /* END() + COPY() */
+ tcomp_deflateStream_end(&(deflatedata->stream_acked));
+ tcomp_deflateStream_copy(&(deflatedata->stream_acked), &(deflatedata->stream_1));
+ deflatedata->stream_acked.stateful = 1;
+ deflatedata->stream_acked.dataWaitingAck = 0;
+ TSK_DEBUG_INFO("SigComp - ACKed State id=");
+ tcomp_buffer_print(stateid);
+ }
+ }
+
+ tsk_safeobj_unlock(deflatedata);
}
/**Updates a Ghost state.
*/
void tcomp_deflatedata_updateGhost(tcomp_deflatedata_t *deflatedata, const uint8_t *input_ptr, tsk_size_t input_size)
{
- uint32_t i;
- uint8_t *ghostvalue_ptr = 0;
+ uint32_t i;
+ uint8_t *ghostvalue_ptr = 0;
#define GHOSTVALUE_AT(position) (ghostvalue_ptr + position)
-
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return;
- }
- if(!deflatedata->ghostState){
- TSK_DEBUG_ERROR("NULL ghost state.");
- return;
- }
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return;
+ }
- tsk_safeobj_lock(deflatedata);
+ if(!deflatedata->ghostState) {
+ TSK_DEBUG_ERROR("NULL ghost state.");
+ return;
+ }
- ghostvalue_ptr = tcomp_buffer_getBuffer(deflatedata->ghostState->value);
+ tsk_safeobj_lock(deflatedata);
+
+ ghostvalue_ptr = tcomp_buffer_getBuffer(deflatedata->ghostState->value);
#define ZBUFF_LEN (0x0001 << deflatedata->zWindowBits)
- for(i = 0; i < input_size; i++){
+ for(i = 0; i < input_size; i++) {
#if 0
- *GHOSTVALUE_AT(GHOST_INPUT_INDEX + ghost_copy_offset) = 0x00;
+ *GHOSTVALUE_AT(GHOST_INPUT_INDEX + ghost_copy_offset) = 0x00;
#else
- *GHOSTVALUE_AT(GHOST_INPUT_INDEX + deflatedata->ghost_copy_offset) = input_ptr[i];
+ *GHOSTVALUE_AT(GHOST_INPUT_INDEX + deflatedata->ghost_copy_offset) = input_ptr[i];
#endif
- deflatedata->ghost_copy_offset = (deflatedata->ghost_copy_offset + 1) % ZBUFF_LEN;
- }
-
- /* Update Circular Buffer Index */
- TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_END_INDEX), (DEFLATE_UDVM_CIRCULAR_START_INDEX + deflatedata->ghost_copy_offset) );
-
- /* Compute State Identifier (20 bytes) */
- tcomp_state_makeValid(deflatedata->ghostState);
- // new state identifer not acked yet
- if(deflatedata->useOnlyACKedStates){
- deflatedata->stream_acked.stateful = 0;
- deflatedata->stream_acked.dataWaitingAck = 1;
- }
-
- TSK_DEBUG_INFO("SigComp - Making Ghost state valid with id = ");
- tcomp_buffer_print(deflatedata->ghostState->identifier);
-
- tsk_safeobj_unlock(deflatedata);
+ deflatedata->ghost_copy_offset = (deflatedata->ghost_copy_offset + 1) % ZBUFF_LEN;
+ }
+
+ /* Update Circular Buffer Index */
+ TSK_BINARY_SET_2BYTES( GHOSTVALUE_AT(GHOST_CB_END_INDEX), (DEFLATE_UDVM_CIRCULAR_START_INDEX + deflatedata->ghost_copy_offset) );
+
+ /* Compute State Identifier (20 bytes) */
+ tcomp_state_makeValid(deflatedata->ghostState);
+ // new state identifer not acked yet
+ if(deflatedata->useOnlyACKedStates) {
+ deflatedata->stream_acked.stateful = 0;
+ deflatedata->stream_acked.dataWaitingAck = 1;
+ }
+
+ TSK_DEBUG_INFO("SigComp - Making Ghost state valid with id = ");
+ tcomp_buffer_print(deflatedata->ghostState->identifier);
+
+ tsk_safeobj_unlock(deflatedata);
#undef GHOSTVALUE_AT
}
@@ -252,21 +253,21 @@ void tcomp_deflatedata_updateGhost(tcomp_deflatedata_t *deflatedata, const uint8
uint32_t* tcomp_deflatedata_getGhostCopyOffset(tcomp_deflatedata_t *deflatedata)
{
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return 0;
- }
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return 0;
+ }
- return &(deflatedata->ghost_copy_offset);
+ return &(deflatedata->ghost_copy_offset);
}
void tcomp_deflatedata_freeGhostState(tcomp_compressordata_t *data)
{
- tcomp_deflatedata_t *deflatedata = data;
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return;
- }
+ tcomp_deflatedata_t *deflatedata = data;
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return;
+ }
- TSK_OBJECT_SAFE_FREE(deflatedata->ghostState);
+ TSK_OBJECT_SAFE_FREE(deflatedata->ghostState);
}
diff --git a/tinySIGCOMP/src/tcomp_deflatedata.h b/tinySIGCOMP/src/tcomp_deflatedata.h
index d266572..87d2f06 100755
--- a/tinySIGCOMP/src/tcomp_deflatedata.h
+++ b/tinySIGCOMP/src/tcomp_deflatedata.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -116,11 +116,10 @@ TCOMP_BEGIN_DECLS
#endif /* USE_DICTS_FOR_COMPRESSION */
-typedef struct tcomp_deflateStream_s
-{
- z_stream zs;
- unsigned dataWaitingAck:1;
- unsigned stateful:1;
+typedef struct tcomp_deflateStream_s {
+ z_stream zs;
+ unsigned dataWaitingAck:1;
+ unsigned stateful:1;
}
tcomp_deflateStream_t;
@@ -128,25 +127,24 @@ tsk_bool_t tcomp_deflateStream_end(tcomp_deflateStream_t *stream);
tsk_bool_t tcomp_deflateStream_copy(tcomp_deflateStream_t *stream, tcomp_deflateStream_t *source);
-typedef struct tcomp_deflatedata_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_deflatedata_s {
+ TSK_DECLARE_OBJECT;
+
+ tcomp_deflateStream_t stream_1;
+ tcomp_deflateStream_t stream_acked;
+ int zLevel;
+ int zWindowBits;
+
+ tsk_bool_t isInitialized;
- tcomp_deflateStream_t stream_1;
- tcomp_deflateStream_t stream_acked;
- int zLevel;
- int zWindowBits;
-
- tsk_bool_t isInitialized;
-
- uint32_t ghost_copy_offset;
- tcomp_state_t *ghostState;
+ uint32_t ghost_copy_offset;
+ tcomp_state_t *ghostState;
- tsk_bool_t isStream;
+ tsk_bool_t isStream;
- tsk_bool_t useOnlyACKedStates;
+ tsk_bool_t useOnlyACKedStates;
- TSK_DECLARE_SAFEOBJ;
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_deflatedata_t;
diff --git a/tinySIGCOMP/src/tcomp_deflatedata.zlib.c b/tinySIGCOMP/src/tcomp_deflatedata.zlib.c
index 6d8c628..1219c15 100755
--- a/tinySIGCOMP/src/tcomp_deflatedata.zlib.c
+++ b/tinySIGCOMP/src/tcomp_deflatedata.zlib.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -33,185 +33,183 @@
tsk_bool_t tcomp_deflateStream_end(tcomp_deflateStream_t *stream)
{
- if(!stream){
- TSK_DEBUG_ERROR("NULL defalte stream.");
- return tsk_false;
- }
+ if(!stream) {
+ TSK_DEBUG_ERROR("NULL defalte stream.");
+ return tsk_false;
+ }
- return deflateEnd(&(stream->zs));
+ return deflateEnd(&(stream->zs));
}
tsk_bool_t tcomp_deflateStream_copy(tcomp_deflateStream_t *stream, tcomp_deflateStream_t *source)
{
- if(!stream){
- TSK_DEBUG_ERROR("NULL defalte stream.");
- return tsk_false;
- }
+ if(!stream) {
+ TSK_DEBUG_ERROR("NULL defalte stream.");
+ return tsk_false;
+ }
- return deflateCopy(&(stream->zs), &(source->zs));
+ return deflateCopy(&(stream->zs), &(source->zs));
}
tsk_bool_t tcomp_deflatedata_zInit(tcomp_deflatedata_t *deflatedata)
{
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return tsk_false;
- }
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return tsk_false;
+ }
- /* Already initialized? */
- if(deflatedata->isInitialized) {
- return tsk_true;
- }
+ /* Already initialized? */
+ if(deflatedata->isInitialized) {
+ return tsk_true;
+ }
- /* allocate deflate state */
+ /* allocate deflate state */
deflatedata->stream_1.zs.zalloc = deflatedata->stream_acked.zs.zalloc = Z_NULL;
deflatedata->stream_1.zs.zfree = deflatedata->stream_acked.zs.zfree = Z_NULL;
deflatedata->stream_1.zs.opaque = deflatedata->stream_acked.zs.opaque = Z_NULL;
#ifndef __SYMBIAN32__
- deflatedata->stream_1.zs.data_type = deflatedata->stream_acked.zs.data_type = Z_TEXT;
+ deflatedata->stream_1.zs.data_type = deflatedata->stream_acked.zs.data_type = Z_TEXT;
#endif
//bool ret = (deflateInit(&this->zStream, this->zLevel) == Z_OK);
- if( deflateInit2(&deflatedata->stream_1.zs, deflatedata->zLevel, Z_DEFLATED, -deflatedata->zWindowBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK
- || deflateInit2(&deflatedata->stream_acked.zs, deflatedata->zLevel, Z_DEFLATED, -deflatedata->zWindowBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK )
- {
- return tsk_false;
- }
+ if( deflateInit2(&deflatedata->stream_1.zs, deflatedata->zLevel, Z_DEFLATED, -deflatedata->zWindowBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK
+ || deflateInit2(&deflatedata->stream_acked.zs, deflatedata->zLevel, Z_DEFLATED, -deflatedata->zWindowBits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK ) {
+ return tsk_false;
+ }
#if USE_DICTS_FOR_COMPRESSION
- if( deflateSetDictionary(this->stream_1.zs, (const Bytef*)RFC3485_DICTIONARY_SIP_VALUE, RFC3485_DICTIONARY_SIP_VALUE_LENGTH) != Z_OK
- || deflateSetDictionary(this->stream_acked.zs, (const Bytef*)RFC3485_DICTIONARY_SIP_VALUE, RFC3485_DICTIONARY_SIP_VALUE_LENGTH) != Z_OK )
- {
- return false;
- }
+ if( deflateSetDictionary(this->stream_1.zs, (const Bytef*)RFC3485_DICTIONARY_SIP_VALUE, RFC3485_DICTIONARY_SIP_VALUE_LENGTH) != Z_OK
+ || deflateSetDictionary(this->stream_acked.zs, (const Bytef*)RFC3485_DICTIONARY_SIP_VALUE, RFC3485_DICTIONARY_SIP_VALUE_LENGTH) != Z_OK ) {
+ return false;
+ }
#endif
- deflatedata->stream_1.stateful = deflatedata->stream_acked.stateful = 0;
- deflatedata->stream_1.dataWaitingAck = deflatedata->stream_acked.dataWaitingAck = 0;
- deflatedata->isInitialized = tsk_true;
+ deflatedata->stream_1.stateful = deflatedata->stream_acked.stateful = 0;
+ deflatedata->stream_1.dataWaitingAck = deflatedata->stream_acked.dataWaitingAck = 0;
+ deflatedata->isInitialized = tsk_true;
- return tsk_true;
+ return tsk_true;
}
tsk_bool_t tcomp_deflatedata_zUnInit(tcomp_deflatedata_t *deflatedata)
{
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return tsk_false;
- }
-
- if(deflatedata->isInitialized){
- deflatedata->isInitialized = tsk_false;
-
- deflatedata->stream_1.dataWaitingAck = deflatedata->stream_acked.dataWaitingAck = 0;
- deflatedata->stream_1.stateful = deflatedata->stream_acked.stateful = 0;
-
- return (tcomp_deflateStream_end(&deflatedata->stream_1) != Z_STREAM_ERROR) && (tcomp_deflateStream_end(&deflatedata->stream_acked) != Z_STREAM_ERROR);
- }
- return tsk_true;
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return tsk_false;
+ }
+
+ if(deflatedata->isInitialized) {
+ deflatedata->isInitialized = tsk_false;
+
+ deflatedata->stream_1.dataWaitingAck = deflatedata->stream_acked.dataWaitingAck = 0;
+ deflatedata->stream_1.stateful = deflatedata->stream_acked.stateful = 0;
+
+ return (tcomp_deflateStream_end(&deflatedata->stream_1) != Z_STREAM_ERROR) && (tcomp_deflateStream_end(&deflatedata->stream_acked) != Z_STREAM_ERROR);
+ }
+ return tsk_true;
}
tsk_bool_t tcomp_deflatedata_zReset(tcomp_deflatedata_t *deflatedata)
{
- tsk_bool_t ret;
+ tsk_bool_t ret;
+
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("NULL defalte data.");
+ return tsk_false;
+ }
- if(!deflatedata){
- TSK_DEBUG_ERROR("NULL defalte data.");
- return tsk_false;
- }
+ ret = deflatedata->isInitialized ? tcomp_deflatedata_zUnInit(deflatedata) : tsk_true;
+ ret &= tcomp_deflatedata_zInit(deflatedata);
- ret = deflatedata->isInitialized ? tcomp_deflatedata_zUnInit(deflatedata) : tsk_true;
- ret &= tcomp_deflatedata_zInit(deflatedata);
-
- return ret;
+ return ret;
}
tsk_bool_t tcomp_deflatedata_zCompress(tcomp_deflatedata_t *deflatedata, const void* in, tsk_size_t inLen, void* out, tsk_size_t* outLen, tsk_bool_t *stateChanged)
{
- int ret = tsk_false;
-/*
- Two streams [1] and [2]
-
- * ZINIT/ZUNINIT/ZRESET
- XXX([1])
- XXX([2])
-
- * COMPRESSION
- [1]->END()
- [1]<-COPY-[2]
- [1]->COMPRESS()
-
- * ACK
- [2]->END()
- [2]<-COPY-[1]
- updateGhost([1])
-*/
- if(!deflatedata){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_false;
- }
-
- tsk_safeobj_lock(deflatedata);
-
- /* Initialized? */
- if(!deflatedata->isInitialized){
- if(!tcomp_deflatedata_zInit(deflatedata)){
- TSK_DEBUG_ERROR("Failed to initialize zlib resources..");
- tsk_safeobj_unlock(deflatedata);
- return tsk_false;
- }
- }
-
- if(deflatedata->useOnlyACKedStates){
- if(!deflatedata->stream_acked.dataWaitingAck){
- deflatedata->stream_acked.dataWaitingAck = 1;
- *stateChanged = tsk_true;
- }
- else{
- *stateChanged = tsk_false;
- }
-
- /* END() + COPY() ==> use acked state */
- tcomp_deflateStream_end(&(deflatedata->stream_1));
- tcomp_deflateStream_copy(&(deflatedata->stream_1), &(deflatedata->stream_acked));
- }
- else{
- *stateChanged = tsk_true;
- }
-
- // IN
- deflatedata->stream_1.zs.next_in = (Bytef*)in;
+ int ret = tsk_false;
+ /*
+ Two streams [1] and [2]
+
+ * ZINIT/ZUNINIT/ZRESET
+ XXX([1])
+ XXX([2])
+
+ * COMPRESSION
+ [1]->END()
+ [1]<-COPY-[2]
+ [1]->COMPRESS()
+
+ * ACK
+ [2]->END()
+ [2]<-COPY-[1]
+ updateGhost([1])
+ */
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return tsk_false;
+ }
+
+ tsk_safeobj_lock(deflatedata);
+
+ /* Initialized? */
+ if(!deflatedata->isInitialized) {
+ if(!tcomp_deflatedata_zInit(deflatedata)) {
+ TSK_DEBUG_ERROR("Failed to initialize zlib resources..");
+ tsk_safeobj_unlock(deflatedata);
+ return tsk_false;
+ }
+ }
+
+ if(deflatedata->useOnlyACKedStates) {
+ if(!deflatedata->stream_acked.dataWaitingAck) {
+ deflatedata->stream_acked.dataWaitingAck = 1;
+ *stateChanged = tsk_true;
+ }
+ else {
+ *stateChanged = tsk_false;
+ }
+
+ /* END() + COPY() ==> use acked state */
+ tcomp_deflateStream_end(&(deflatedata->stream_1));
+ tcomp_deflateStream_copy(&(deflatedata->stream_1), &(deflatedata->stream_acked));
+ }
+ else {
+ *stateChanged = tsk_true;
+ }
+
+ // IN
+ deflatedata->stream_1.zs.next_in = (Bytef*)in;
deflatedata->stream_1.zs.avail_in = (uInt)inLen;
-
- // OUT
- deflatedata->stream_1.zs.next_out = (Bytef*)out;
+
+ // OUT
+ deflatedata->stream_1.zs.next_out = (Bytef*)out;
deflatedata->stream_1.zs.avail_out = (uInt)*outLen;
-
- ret = deflate(&(deflatedata->stream_1.zs), Z_SYNC_FLUSH);
-
- *outLen -= deflatedata->stream_1.zs.avail_out;
-
- tsk_safeobj_unlock(deflatedata);
-
- return (ret == Z_OK);
+
+ ret = deflate(&(deflatedata->stream_1.zs), Z_SYNC_FLUSH);
+
+ *outLen -= deflatedata->stream_1.zs.avail_out;
+
+ tsk_safeobj_unlock(deflatedata);
+
+ return (ret == Z_OK);
}
int tcomp_deflatedata_zGetWindowBits(tcomp_deflatedata_t *deflatedata)
{
- if(!deflatedata){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
- return deflatedata->zWindowBits;
+ return deflatedata->zWindowBits;
}
void tcomp_deflatedata_zSetWindowBits(tcomp_deflatedata_t *deflatedata, int windowSize)
{
- if(!deflatedata){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
+ if(!deflatedata) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
- deflatedata->zWindowBits = windowSize;
+ deflatedata->zWindowBits = windowSize;
}
diff --git a/tinySIGCOMP/src/tcomp_dicts.c b/tinySIGCOMP/src/tcomp_dicts.c
index b5e11ca..9242d2b 100755
--- a/tinySIGCOMP/src/tcomp_dicts.c
+++ b/tinySIGCOMP/src/tcomp_dicts.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -39,58 +39,58 @@
*/
tcomp_dictionary_t* tcomp_dicts_create_presence_dict()
{
- static const char *pres_dict_data = RFC5112_DICTIONARY_PRESENCE_VALUE;
- static tcomp_dictionary_t * pres_dict = tsk_null;
+ static const char *pres_dict_data = RFC5112_DICTIONARY_PRESENCE_VALUE;
+ static tcomp_dictionary_t * pres_dict = tsk_null;
- if(!pres_dict){
- pres_dict = tcomp_state_create(
- RFC5112_DICTIONARY_PRESENCE_VALUE_LENGTH,
- RFC5112_DICTIONARY_PRESENCE_STATE_ADDRESS,
- RFC5112_DICTIONARY_PRESENCE_STATE_INSTRUCTION,
- RFC5112_DICTIONARY_PRESENCE_MINIMUM_ACCESS_LENGTH,
- 65535);
+ if(!pres_dict) {
+ pres_dict = tcomp_state_create(
+ RFC5112_DICTIONARY_PRESENCE_VALUE_LENGTH,
+ RFC5112_DICTIONARY_PRESENCE_STATE_ADDRESS,
+ RFC5112_DICTIONARY_PRESENCE_STATE_INSTRUCTION,
+ RFC5112_DICTIONARY_PRESENCE_MINIMUM_ACCESS_LENGTH,
+ 65535);
- if(pres_dict){
- tcomp_buffer_referenceBuff(pres_dict->value, (uint8_t*)pres_dict_data, RFC5112_DICTIONARY_PRESENCE_VALUE_LENGTH);
- tcomp_state_makeValid(pres_dict);
- TSK_DEBUG_INFO("SigComp - Presence dict State id=");
- tcomp_buffer_print(pres_dict->identifier);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create Presence dictionary.");
- }
- }
+ if(pres_dict) {
+ tcomp_buffer_referenceBuff(pres_dict->value, (uint8_t*)pres_dict_data, RFC5112_DICTIONARY_PRESENCE_VALUE_LENGTH);
+ tcomp_state_makeValid(pres_dict);
+ TSK_DEBUG_INFO("SigComp - Presence dict State id=");
+ tcomp_buffer_print(pres_dict->identifier);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create Presence dictionary.");
+ }
+ }
- return tsk_object_ref(pres_dict);
+ return tsk_object_ref(pres_dict);
}
/**The Session Initiation Protocol (SIP) and Session Description Protocol (SDP) Static Dictionary for Signaling Compression as per RFC 3485.
*/
tcomp_dictionary_t* tcomp_dicts_create_sip_dict()
{
-
- static const char *sip_dict_data = RFC3485_DICTIONARY_SIP_VALUE;
- static tcomp_dictionary_t *sip_dict = tsk_null;
- if(!sip_dict){
- sip_dict = tcomp_state_create(
- RFC3485_DICTIONARY_SIP_VALUE_LENGTH,
- RFC3485_DICTIONARY_SIP_STATE_ADDRESS,
- RFC3485_DICTIONARY_SIP_STATE_INSTRUCTION,
- RFC3485_DICTIONARY_SIP_MINIMUM_ACCESS_LENGTH,
- 65535);
-
- if(sip_dict){
- tcomp_buffer_referenceBuff(sip_dict->value, (uint8_t*)sip_dict_data, RFC3485_DICTIONARY_SIP_VALUE_LENGTH);
- tcomp_state_makeValid(sip_dict);
- TSK_DEBUG_INFO("SigComp - SIP dict State id=");
- tcomp_buffer_print(sip_dict->identifier);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create SIP/SDP dictionary.");
- }
- }
+ static const char *sip_dict_data = RFC3485_DICTIONARY_SIP_VALUE;
+ static tcomp_dictionary_t *sip_dict = tsk_null;
+
+ if(!sip_dict) {
+ sip_dict = tcomp_state_create(
+ RFC3485_DICTIONARY_SIP_VALUE_LENGTH,
+ RFC3485_DICTIONARY_SIP_STATE_ADDRESS,
+ RFC3485_DICTIONARY_SIP_STATE_INSTRUCTION,
+ RFC3485_DICTIONARY_SIP_MINIMUM_ACCESS_LENGTH,
+ 65535);
+
+ if(sip_dict) {
+ tcomp_buffer_referenceBuff(sip_dict->value, (uint8_t*)sip_dict_data, RFC3485_DICTIONARY_SIP_VALUE_LENGTH);
+ tcomp_state_makeValid(sip_dict);
+ TSK_DEBUG_INFO("SigComp - SIP dict State id=");
+ tcomp_buffer_print(sip_dict->identifier);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create SIP/SDP dictionary.");
+ }
+ }
- return tsk_object_ref(sip_dict);
+ return tsk_object_ref(sip_dict);
}
diff --git a/tinySIGCOMP/src/tcomp_dicts.h b/tinySIGCOMP/src/tcomp_dicts.h
index dab3d88..472261c 100755
--- a/tinySIGCOMP/src/tcomp_dicts.h
+++ b/tinySIGCOMP/src/tcomp_dicts.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_headers_index.h b/tinySIGCOMP/src/tcomp_headers_index.h
index 0402deb..2067465 100755
--- a/tinySIGCOMP/src/tcomp_headers_index.h
+++ b/tinySIGCOMP/src/tcomp_headers_index.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -65,7 +65,7 @@
| byte_copy_right | 66 - 67
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| input_bit_order | 68 - 69
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| stack_location | 70 - 71
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
diff --git a/tinySIGCOMP/src/tcomp_instructions.h b/tinySIGCOMP/src/tcomp_instructions.h
index ae2c5b4..c2b6e29 100755
--- a/tinySIGCOMP/src/tcomp_instructions.h
+++ b/tinySIGCOMP/src/tcomp_instructions.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -71,51 +71,49 @@
#define TCOMP_UDVM_INST__OUTPUT 34 //1 + output_length
#define TCOMP_UDVM_INST__END_MESSAGE 35 //1 + state_length
-typedef struct tcomp_inst_desc_s
-{
- int32_t code;
- const char* desc;
+typedef struct tcomp_inst_desc_s {
+ int32_t code;
+ const char* desc;
}
tcomp_inst_desc_t;
-static const tcomp_inst_desc_t TCOMP_INST_DESCRIPTIONS[] =
-{
- { TCOMP_UDVM_INST__DECOMPRESSION_FAILURE, "DECOMPRESSION_FAILURE"},
- { TCOMP_UDVM_INST__AND, "AND"},
- { TCOMP_UDVM_INST__OR, "OR"},
- { TCOMP_UDVM_INST__NOT, "NOT"},
- { TCOMP_UDVM_INST__LSHIFT, "LSHIFT"},
- { TCOMP_UDVM_INST__RSHIFT, "RSHIFT"},
- { TCOMP_UDVM_INST__ADD, "ADD"},
- { TCOMP_UDVM_INST__SUBTRACT, "SUBTRACT"},
- { TCOMP_UDVM_INST__MULTIPLY, "MULTIPLY"},
- { TCOMP_UDVM_INST__DIVIDE, "DIVIDE"},
- { TCOMP_UDVM_INST__REMAINDER, "REMAINDER"},
- { TCOMP_UDVM_INST__SORT_ASCENDING, "SORT-ASCENDING"},
- { TCOMP_UDVM_INST__SORT_DESCENDING, "SORT-DESCENDING"},
- { TCOMP_UDVM_INST__SHA_1, "SHA-1"},
- { TCOMP_UDVM_INST__LOAD, "LOAD"},
- { TCOMP_UDVM_INST__MULTILOAD, "MULTILOAD"},
- { TCOMP_UDVM_INST__PUSH, "PUSH"},
- { TCOMP_UDVM_INST__POP, "POP"},
- { TCOMP_UDVM_INST__COPY, "COPY"},
- { TCOMP_UDVM_INST__COPY_LITERAL, "COPY-LITERAL"},
- { TCOMP_UDVM_INST__COPY_OFFSET, "COPY-OFFSET"},
- { TCOMP_UDVM_INST__MEMSET, "MEMSET"},
- { TCOMP_UDVM_INST__JUMP, "JUMP"},
- { TCOMP_UDVM_INST__COMPARE, "COMPARE"},
- { TCOMP_UDVM_INST__CALL, "CALL"},
- { TCOMP_UDVM_INST__RETURN, "RETURN"},
- { TCOMP_UDVM_INST__SWITCH, "SWITCH"},
- { TCOMP_UDVM_INST__CRC, "CRC"},
- { TCOMP_UDVM_INST__INPUT_BYTES, "INPUT-BYTES"},
- { TCOMP_UDVM_INST__INPUT_BITS, "INPUT-BITS"},
- { TCOMP_UDVM_INST__INPUT_HUFFMAN, "INPUT-HUFFMAN"},
- { TCOMP_UDVM_INST__STATE_ACCESS, "STATE-ACCESS"},
- { TCOMP_UDVM_INST__STATE_CREATE, "STATE-CREATE"},
- { TCOMP_UDVM_INST__STATE_FREE, "STATE-FREE"},
- { TCOMP_UDVM_INST__OUTPUT, "OUTPUT"},
- { TCOMP_UDVM_INST__END_MESSAGE, "END-MESSAGE"},
+static const tcomp_inst_desc_t TCOMP_INST_DESCRIPTIONS[] = {
+ { TCOMP_UDVM_INST__DECOMPRESSION_FAILURE, "DECOMPRESSION_FAILURE"},
+ { TCOMP_UDVM_INST__AND, "AND"},
+ { TCOMP_UDVM_INST__OR, "OR"},
+ { TCOMP_UDVM_INST__NOT, "NOT"},
+ { TCOMP_UDVM_INST__LSHIFT, "LSHIFT"},
+ { TCOMP_UDVM_INST__RSHIFT, "RSHIFT"},
+ { TCOMP_UDVM_INST__ADD, "ADD"},
+ { TCOMP_UDVM_INST__SUBTRACT, "SUBTRACT"},
+ { TCOMP_UDVM_INST__MULTIPLY, "MULTIPLY"},
+ { TCOMP_UDVM_INST__DIVIDE, "DIVIDE"},
+ { TCOMP_UDVM_INST__REMAINDER, "REMAINDER"},
+ { TCOMP_UDVM_INST__SORT_ASCENDING, "SORT-ASCENDING"},
+ { TCOMP_UDVM_INST__SORT_DESCENDING, "SORT-DESCENDING"},
+ { TCOMP_UDVM_INST__SHA_1, "SHA-1"},
+ { TCOMP_UDVM_INST__LOAD, "LOAD"},
+ { TCOMP_UDVM_INST__MULTILOAD, "MULTILOAD"},
+ { TCOMP_UDVM_INST__PUSH, "PUSH"},
+ { TCOMP_UDVM_INST__POP, "POP"},
+ { TCOMP_UDVM_INST__COPY, "COPY"},
+ { TCOMP_UDVM_INST__COPY_LITERAL, "COPY-LITERAL"},
+ { TCOMP_UDVM_INST__COPY_OFFSET, "COPY-OFFSET"},
+ { TCOMP_UDVM_INST__MEMSET, "MEMSET"},
+ { TCOMP_UDVM_INST__JUMP, "JUMP"},
+ { TCOMP_UDVM_INST__COMPARE, "COMPARE"},
+ { TCOMP_UDVM_INST__CALL, "CALL"},
+ { TCOMP_UDVM_INST__RETURN, "RETURN"},
+ { TCOMP_UDVM_INST__SWITCH, "SWITCH"},
+ { TCOMP_UDVM_INST__CRC, "CRC"},
+ { TCOMP_UDVM_INST__INPUT_BYTES, "INPUT-BYTES"},
+ { TCOMP_UDVM_INST__INPUT_BITS, "INPUT-BITS"},
+ { TCOMP_UDVM_INST__INPUT_HUFFMAN, "INPUT-HUFFMAN"},
+ { TCOMP_UDVM_INST__STATE_ACCESS, "STATE-ACCESS"},
+ { TCOMP_UDVM_INST__STATE_CREATE, "STATE-CREATE"},
+ { TCOMP_UDVM_INST__STATE_FREE, "STATE-FREE"},
+ { TCOMP_UDVM_INST__OUTPUT, "OUTPUT"},
+ { TCOMP_UDVM_INST__END_MESSAGE, "END-MESSAGE"},
};
#endif /* TCOMP_INSTRUCTIONS_H */
diff --git a/tinySIGCOMP/src/tcomp_manager.c b/tinySIGCOMP/src/tcomp_manager.c
index 0818439..f741bf4 100755
--- a/tinySIGCOMP/src/tcomp_manager.c
+++ b/tinySIGCOMP/src/tcomp_manager.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -46,15 +46,14 @@
/**SigComp manager.
*/
-typedef struct tcomp_manager_s
-{
- TSK_DECLARE_OBJECT;
-
- tcomp_compressordisp_t *dispatcher_compressor;
- tcomp_decompressordisp_t *dispatcher_decompressor;
- tcomp_statehandler_t *stateHandler;
-
- TSK_DECLARE_SAFEOBJ;
+typedef struct tcomp_manager_s {
+ TSK_DECLARE_OBJECT;
+
+ tcomp_compressordisp_t *dispatcher_compressor;
+ tcomp_decompressordisp_t *dispatcher_decompressor;
+ tcomp_statehandler_t *stateHandler;
+
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_manager_t;
@@ -63,120 +62,119 @@ tcomp_manager_t;
*/
tcomp_manager_handle_t* tcomp_manager_create()
{
- return tsk_object_new(tcomp_manager_def_t);
+ return tsk_object_new(tcomp_manager_def_t);
}
/** Defines whether the compressor must only use ACKed states (should be false)
*/
int tcomp_manager_setUseOnlyACKedStates(tcomp_manager_handle_t* self, tsk_bool_t useOnlyACKedStates)
{
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
- return tcomp_statehandler_setUseOnlyACKedStates(((tcomp_manager_t*)self)->stateHandler, useOnlyACKedStates);
+ if(!self) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+ return tcomp_statehandler_setUseOnlyACKedStates(((tcomp_manager_t*)self)->stateHandler, useOnlyACKedStates);
}
/**@ingroup tcomp_manager_group
*/
tsk_size_t tcomp_manager_compress(tcomp_manager_handle_t *handle, const void* compartmentId, tsk_size_t compartmentIdSize, const void* input_ptr, tsk_size_t input_size, void* output_ptr, tsk_size_t output_size, tsk_bool_t stream)
{
- tcomp_manager_t *manager = handle;
- tsk_size_t ret_size = output_size;
-
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
-
- if(tcomp_compressordisp_compress(manager->dispatcher_compressor, tcomp_buffer_createHash(compartmentId, compartmentIdSize),
- input_ptr, input_size, output_ptr, &ret_size, stream))
- {
- return ret_size;
- }
-
- return 0;
+ tcomp_manager_t *manager = handle;
+ tsk_size_t ret_size = output_size;
+
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+
+ if(tcomp_compressordisp_compress(manager->dispatcher_compressor, tcomp_buffer_createHash(compartmentId, compartmentIdSize),
+ input_ptr, input_size, output_ptr, &ret_size, stream)) {
+ return ret_size;
+ }
+
+ return 0;
}
/**@ingroup tcomp_manager_group
*/
tsk_size_t tcomp_manager_decompress(tcomp_manager_handle_t *handle, const void* input_ptr, tsk_size_t input_size, tcomp_result_t *lpResult)
{
- tcomp_manager_t *manager = handle;
-
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
-
- if(!lpResult || !lpResult->output_buffer){
- TSK_DEBUG_ERROR("You MUST initialize the sigcomp result and set a valid output buffer.");
- return 0;
- }
-
- /* Reset previous values */
- tcomp_result_reset(lpResult);
-
- if(tcomp_decompressordisp_decompress(manager->dispatcher_decompressor, input_ptr, input_size, lpResult)){
- return *tcomp_buffer_getIndexBytes(lpResult->output_buffer);
- }
-
- return 0;
+ tcomp_manager_t *manager = handle;
+
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+
+ if(!lpResult || !lpResult->output_buffer) {
+ TSK_DEBUG_ERROR("You MUST initialize the sigcomp result and set a valid output buffer.");
+ return 0;
+ }
+
+ /* Reset previous values */
+ tcomp_result_reset(lpResult);
+
+ if(tcomp_decompressordisp_decompress(manager->dispatcher_decompressor, input_ptr, input_size, lpResult)) {
+ return *tcomp_buffer_getIndexBytes(lpResult->output_buffer);
+ }
+
+ return 0;
}
/**@ingroup tcomp_manager_group
*/
tsk_size_t tcomp_manager_getNextStreamMessage(tcomp_manager_handle_t *handle, tcomp_result_t *lpResult)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
-
- if(!lpResult || !tcomp_buffer_getSize(lpResult->output_buffer)){
- TSK_DEBUG_ERROR("Invalid result.");
- return 0;
- }
-
- if(!lpResult->isStreamBased){
- TSK_DEBUG_ERROR("You MUST provide stream buffer.");
- return 0;
- }
-
- _tcomp_result_reset(lpResult, tsk_false, tsk_false);
-
- if(tcomp_decompressordisp_getNextMessage(manager->dispatcher_decompressor, lpResult)){
- return *tcomp_buffer_getIndexBytes(lpResult->output_buffer);
- }
-
- return 0;
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+
+ if(!lpResult || !tcomp_buffer_getSize(lpResult->output_buffer)) {
+ TSK_DEBUG_ERROR("Invalid result.");
+ return 0;
+ }
+
+ if(!lpResult->isStreamBased) {
+ TSK_DEBUG_ERROR("You MUST provide stream buffer.");
+ return 0;
+ }
+
+ _tcomp_result_reset(lpResult, tsk_false, tsk_false);
+
+ if(tcomp_decompressordisp_getNextMessage(manager->dispatcher_decompressor, lpResult)) {
+ return *tcomp_buffer_getIndexBytes(lpResult->output_buffer);
+ }
+
+ return 0;
}
/**@ingroup tcomp_manager_group
*/
void tcomp_manager_provideCompartmentId(tcomp_manager_handle_t *handle, tcomp_result_t *lpResult)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
- tcomp_statehandler_handleResult(manager->stateHandler, &lpResult);
+ tcomp_statehandler_handleResult(manager->stateHandler, &lpResult);
}
/**@ingroup tcomp_manager_group
*/
void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, const void *compartmentId, tsk_size_t compartmentIdSize)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
- tcomp_statehandler_deleteCompartment(manager->stateHandler, tcomp_buffer_createHash(compartmentId, compartmentIdSize));
+ tcomp_statehandler_deleteCompartment(manager->stateHandler, tcomp_buffer_createHash(compartmentId, compartmentIdSize));
}
/**@ingroup tcomp_manager_group
@@ -187,13 +185,13 @@ void tcomp_manager_closeCompartment(tcomp_manager_handle_t *handle, const void *
*/
int tcomp_manager_setDecompression_Memory_Size(tcomp_manager_handle_t *handle, uint32_t dms)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- return tcomp_params_setDmsValue(manager->stateHandler->sigcomp_parameters, (dms > MAX_DMS ? MAX_DMS : dms));
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ return tcomp_params_setDmsValue(manager->stateHandler->sigcomp_parameters, (dms > MAX_DMS ? MAX_DMS : dms));
}
/**@ingroup tcomp_manager_group
@@ -203,14 +201,14 @@ int tcomp_manager_setDecompression_Memory_Size(tcomp_manager_handle_t *handle, u
*/
uint32_t tcomp_manager_getDecompression_Memory_Size(tcomp_manager_handle_t *handle)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
- return (manager->stateHandler && manager->stateHandler->sigcomp_parameters)
- ? manager->stateHandler->sigcomp_parameters->dmsValue
- : 0;
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+ return (manager->stateHandler && manager->stateHandler->sigcomp_parameters)
+ ? manager->stateHandler->sigcomp_parameters->dmsValue
+ : 0;
}
/**@ingroup tcomp_manager_group
@@ -221,13 +219,13 @@ uint32_t tcomp_manager_getDecompression_Memory_Size(tcomp_manager_handle_t *hand
*/
int tcomp_manager_setState_Memory_Size(tcomp_manager_handle_t *handle, uint32_t sms)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
- return tcomp_params_setSmsValue(manager->stateHandler->sigcomp_parameters, (sms > MAX_SMS ? MAX_SMS : sms));
+ return tcomp_params_setSmsValue(manager->stateHandler->sigcomp_parameters, (sms > MAX_SMS ? MAX_SMS : sms));
}
/**@ingroup tcomp_manager_group
@@ -238,13 +236,13 @@ int tcomp_manager_setState_Memory_Size(tcomp_manager_handle_t *handle, uint32_t
*/
int tcomp_manager_setCycles_Per_Bit(tcomp_manager_handle_t *handle, uint8_t cpb)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
- return tcomp_params_setCpbValue(manager->stateHandler->sigcomp_parameters, (cpb > MAX_CPB ? MAX_CPB : cpb));
+ return tcomp_params_setCpbValue(manager->stateHandler->sigcomp_parameters, (cpb > MAX_CPB ? MAX_CPB : cpb));
}
/**@ingroup tcomp_manager_group
@@ -255,14 +253,14 @@ int tcomp_manager_setCycles_Per_Bit(tcomp_manager_handle_t *handle, uint8_t cpb)
*/
int tcomp_manager_setSigComp_Version(tcomp_manager_handle_t *handle, uint8_t version)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- manager->stateHandler->sigcomp_parameters->SigComp_version = version;
- return 0;
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ manager->stateHandler->sigcomp_parameters->SigComp_version = version;
+ return 0;
}
/**@ingroup tcomp_manager_group
@@ -273,13 +271,13 @@ int tcomp_manager_setSigComp_Version(tcomp_manager_handle_t *handle, uint8_t ver
*/
int tcomp_manager_addCompressor(tcomp_manager_handle_t *handle, tcomp_compressor_compress_f compressor)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
- return tcomp_compressordisp_addCompressor(manager->dispatcher_compressor, compressor);
+ return tcomp_compressordisp_addCompressor(manager->dispatcher_compressor, compressor);
}
/**@ingroup tcomp_manager_group
@@ -290,13 +288,13 @@ int tcomp_manager_addCompressor(tcomp_manager_handle_t *handle, tcomp_compressor
*/
int tcomp_manager_removeCompressor(tcomp_manager_handle_t *handle, tcomp_compressor_compress_f compressor)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
- return tcomp_compressordisp_removeCompressor(manager->dispatcher_compressor, compressor);
+ return tcomp_compressordisp_removeCompressor(manager->dispatcher_compressor, compressor);
}
/**@ingroup tcomp_manager_group
@@ -306,13 +304,13 @@ int tcomp_manager_removeCompressor(tcomp_manager_handle_t *handle, tcomp_compres
*/
int tcomp_manager_addSipSdpDictionary(tcomp_manager_handle_t *handle)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
- return tcomp_statehandler_addSipSdpDictionary(manager->stateHandler);
+ return tcomp_statehandler_addSipSdpDictionary(manager->stateHandler);
}
/**@ingroup tcomp_manager_group
@@ -322,13 +320,13 @@ int tcomp_manager_addSipSdpDictionary(tcomp_manager_handle_t *handle)
*/
int tcomp_manager_addPresenceDictionary(tcomp_manager_handle_t *handle)
{
- tcomp_manager_t *manager = handle;
- if(!manager){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ tcomp_manager_t *manager = handle;
+ if(!manager) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
- return tcomp_statehandler_addPresenceDictionary(manager->stateHandler);
+ return tcomp_statehandler_addPresenceDictionary(manager->stateHandler);
}
@@ -347,46 +345,44 @@ int tcomp_manager_addPresenceDictionary(tcomp_manager_handle_t *handle)
static void* tcomp_manager_ctor(void * self, va_list * app)
{
- tcomp_manager_t *manager = self;
- if(manager)
- {
- manager->stateHandler = tcomp_statehandler_create();
- manager->dispatcher_compressor = tcomp_compressordisp_create(manager->stateHandler);
- manager->dispatcher_decompressor = tcomp_decompressordisp_create(manager->stateHandler);
-
- /* Initialize safeobject */
- tsk_safeobj_init(manager);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new manager.");
- }
-
- return self;
+ tcomp_manager_t *manager = self;
+ if(manager) {
+ manager->stateHandler = tcomp_statehandler_create();
+ manager->dispatcher_compressor = tcomp_compressordisp_create(manager->stateHandler);
+ manager->dispatcher_decompressor = tcomp_decompressordisp_create(manager->stateHandler);
+
+ /* Initialize safeobject */
+ tsk_safeobj_init(manager);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new manager.");
+ }
+
+ return self;
}
static void* tcomp_manager_dtor(void *self)
{
- tcomp_manager_t *manager = self;
- if(manager){
- TSK_OBJECT_SAFE_FREE(manager->stateHandler);
- TSK_OBJECT_SAFE_FREE(manager->dispatcher_compressor);
- TSK_OBJECT_SAFE_FREE(manager->dispatcher_decompressor);
-
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(manager);
- }
- else{
- TSK_DEBUG_ERROR("Null manager.");
- }
-
- return self;
+ tcomp_manager_t *manager = self;
+ if(manager) {
+ TSK_OBJECT_SAFE_FREE(manager->stateHandler);
+ TSK_OBJECT_SAFE_FREE(manager->dispatcher_compressor);
+ TSK_OBJECT_SAFE_FREE(manager->dispatcher_decompressor);
+
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(manager);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null manager.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_manager_def_s =
-{
- sizeof(tcomp_manager_t),
- tcomp_manager_ctor,
- tcomp_manager_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_manager_def_s = {
+ sizeof(tcomp_manager_t),
+ tcomp_manager_ctor,
+ tcomp_manager_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_manager_def_t = &tcomp_manager_def_s;
diff --git a/tinySIGCOMP/src/tcomp_manager.h b/tinySIGCOMP/src/tcomp_manager.h
index 477c438..01e31ca 100755
--- a/tinySIGCOMP/src/tcomp_manager.h
+++ b/tinySIGCOMP/src/tcomp_manager.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -48,7 +48,7 @@ TINYSIGCOMP_API int tcomp_manager_setUseOnlyACKedStates(tcomp_manager_handle_t*
//
TINYSIGCOMP_API tsk_size_t tcomp_manager_compress(tcomp_manager_handle_t *handle, const void* compartmentId, tsk_size_t compartmentIdSize, const void* input_ptr, tsk_size_t input_size, void* output_ptr, tsk_size_t output_size, tsk_bool_t stream);
#define tcomp_manager_compressUDP(handle, compartmentId, compartmentIdSize, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (const void*) compartmentId, (tsk_size_t) compartmentIdSize, (const void*) input_ptr, (tsk_size_t) input_size, (void*) output_ptr, (tsk_size_t) output_size, tsk_false)
-#define tcomp_manager_compressTCP(handle, compartmentId, compartmentIdSize, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (const void*) compartmentId, (tsk_size_t) compartmentIdSize, (const void*) input_ptr, (tsk_size_t) input_size, (void*) output_ptr, (tsk_size_t) output_size, tsk_true)
+#define tcomp_manager_compressTCP(handle, compartmentId, compartmentIdSize, input_ptr, input_size, output_ptr, output_size) tcomp_manager_compress((tcomp_manager_handle_t *)handle, (const void*) compartmentId, (tsk_size_t) compartmentIdSize, (const void*) input_ptr, (tsk_size_t) input_size, (void*) output_ptr, (tsk_size_t) output_size, tsk_true)
#define tcomp_manager_compressSCTP compressTCP
TINYSIGCOMP_API tsk_size_t tcomp_manager_decompress(tcomp_manager_handle_t *handle, const void* input_ptr, tsk_size_t input_size, tcomp_result_t *lpResult);
diff --git a/tinySIGCOMP/src/tcomp_message.c b/tinySIGCOMP/src/tcomp_message.c
index 6cecb79..2048c3f 100755
--- a/tinySIGCOMP/src/tcomp_message.c
+++ b/tinySIGCOMP/src/tcomp_message.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -54,109 +54,108 @@ static void initStateful(tcomp_message_t *message, uint8_t** start_ptr, uint8_t*
static void initStateless(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_ptr, int32_t *nack_code);
static void initNack(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_ptr, int32_t* nack_code);
-/*
+/*
Creates new SigComp message.
*/
tcomp_message_t* tcomp_message_create(const void* input_ptr, tsk_size_t input_size, tsk_bool_t stream, int32_t* nack_code)
{
- tcomp_message_t *message;
-
- if(!nack_code){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_null;
- }
-
- if(!input_ptr){
- TSK_DEBUG_ERROR("Invalid parameter");
- *nack_code = NACK_INTERNAL_ERROR;
- return tsk_null;
- }
-
- if(input_size < MIN_LEN){
- TSK_DEBUG_ERROR("MESSAGE_TOO_SHORT");
- *nack_code = NACK_MESSAGE_TOO_SHORT;
- return tsk_null;
- }
-
- if((message = tsk_object_new(tcomp_message_def_t))){
- uint8_t *dummy_ptr, *end_ptr;
- uint8_t state_len;
-
- message->startPtr = input_ptr;
- message->stateId = tcomp_buffer_create_null();
- message->remaining_sigcomp_buffer = tcomp_buffer_create_null();
- message->uploaded_UDVM_buffer = tcomp_buffer_create_null();
- message->ret_feedback_buffer= tcomp_buffer_create_null();
-
- message->isNack = 0;
- dummy_ptr = ((uint8_t*)input_ptr);
- end_ptr = (dummy_ptr + input_size);
-
- //
- message->totalSize = input_size;
- message->stream_based = stream;
- message->bytecodes_destination = 0;
-
- /* Get sigcomp header */
- message->headerSigComp = *dummy_ptr;
- dummy_ptr++;
-
- /* Check message validity --> magic code (11111)? */
- message->isOK = HEADER_IS_VALID(message);
- if(!message->isOK){
- TSK_DEBUG_ERROR("SigComp Message not valid (magic code mismatch)");
- *nack_code = NACK_INTERNAL_ERROR;
- goto bail;
- }
-
- /* Feedback item */
- if((HEADER_GET_T(message)!=0)){
- initFeedbackItem(message, &dummy_ptr);
- if(!message->isOK){
- goto bail;
- }
- }
-
- /*
- * If the len field is non-zero, then the SigComp message contains a state identifier
- * to access a state item at the receiving endpoint.
- */
- state_len = HEADER_GET_STATE_LENGTH( HEADER_GET_LEN(message) );
- if(state_len){
- initStateId(message, &dummy_ptr, state_len);
- initStateful(message, &dummy_ptr, end_ptr);
- TSK_DEBUG_INFO("SigComp - Decompressing stateful message with state id =");
- tcomp_buffer_print(message->stateId);
- }
- else
- {
- if( !*dummy_ptr && !(*(dummy_ptr+1)&0xf0) ){
- // "code_len" field of zero --> it's a nack
- initNack(message, &dummy_ptr, end_ptr, nack_code);
- }
- else{
- initStateless(message, &dummy_ptr, end_ptr, nack_code);
- }
- }
-
- /*
- * The fields (RFC 3320 section 7) except for the "remaining SigComp message" are referred to
- * as the "SigComp header" (note that this may include the uploaded UDVM bytecode).
- */
- if(message->isOK){
- message->header_size = ( message->totalSize - tcomp_buffer_getSize(message->remaining_sigcomp_buffer));
- }
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new SigComp message");
- }
+ tcomp_message_t *message;
+
+ if(!nack_code) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return tsk_null;
+ }
+
+ if(!input_ptr) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ *nack_code = NACK_INTERNAL_ERROR;
+ return tsk_null;
+ }
+
+ if(input_size < MIN_LEN) {
+ TSK_DEBUG_ERROR("MESSAGE_TOO_SHORT");
+ *nack_code = NACK_MESSAGE_TOO_SHORT;
+ return tsk_null;
+ }
+
+ if((message = tsk_object_new(tcomp_message_def_t))) {
+ uint8_t *dummy_ptr, *end_ptr;
+ uint8_t state_len;
+
+ message->startPtr = input_ptr;
+ message->stateId = tcomp_buffer_create_null();
+ message->remaining_sigcomp_buffer = tcomp_buffer_create_null();
+ message->uploaded_UDVM_buffer = tcomp_buffer_create_null();
+ message->ret_feedback_buffer= tcomp_buffer_create_null();
+
+ message->isNack = 0;
+ dummy_ptr = ((uint8_t*)input_ptr);
+ end_ptr = (dummy_ptr + input_size);
+
+ //
+ message->totalSize = input_size;
+ message->stream_based = stream;
+ message->bytecodes_destination = 0;
+
+ /* Get sigcomp header */
+ message->headerSigComp = *dummy_ptr;
+ dummy_ptr++;
+
+ /* Check message validity --> magic code (11111)? */
+ message->isOK = HEADER_IS_VALID(message);
+ if(!message->isOK) {
+ TSK_DEBUG_ERROR("SigComp Message not valid (magic code mismatch)");
+ *nack_code = NACK_INTERNAL_ERROR;
+ goto bail;
+ }
+
+ /* Feedback item */
+ if((HEADER_GET_T(message)!=0)) {
+ initFeedbackItem(message, &dummy_ptr);
+ if(!message->isOK) {
+ goto bail;
+ }
+ }
+
+ /*
+ * If the len field is non-zero, then the SigComp message contains a state identifier
+ * to access a state item at the receiving endpoint.
+ */
+ state_len = HEADER_GET_STATE_LENGTH( HEADER_GET_LEN(message) );
+ if(state_len) {
+ initStateId(message, &dummy_ptr, state_len);
+ initStateful(message, &dummy_ptr, end_ptr);
+ TSK_DEBUG_INFO("SigComp - Decompressing stateful message with state id =");
+ tcomp_buffer_print(message->stateId);
+ }
+ else {
+ if( !*dummy_ptr && !(*(dummy_ptr+1)&0xf0) ) {
+ // "code_len" field of zero --> it's a nack
+ initNack(message, &dummy_ptr, end_ptr, nack_code);
+ }
+ else {
+ initStateless(message, &dummy_ptr, end_ptr, nack_code);
+ }
+ }
+
+ /*
+ * The fields (RFC 3320 section 7) except for the "remaining SigComp message" are referred to
+ * as the "SigComp header" (note that this may include the uploaded UDVM bytecode).
+ */
+ if(message->isOK) {
+ message->header_size = ( message->totalSize - tcomp_buffer_getSize(message->remaining_sigcomp_buffer));
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new SigComp message");
+ }
bail:
- if(message && !message->isOK){
- TSK_OBJECT_SAFE_FREE(message);
- }
+ if(message && !message->isOK) {
+ TSK_OBJECT_SAFE_FREE(message);
+ }
- return message;
+ return message;
}
/*
@@ -164,24 +163,24 @@ Iniatizes the feedback item field.
*/
static void initFeedbackItem(tcomp_message_t *message, uint8_t** start_ptr)
{
- /*
+ /*
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
- +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
- | 0 | returned_feedback_field | | 1 | returned_feedback_length |
- +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
+ +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
+ | 0 | returned_feedback_field | | 1 | returned_feedback_length |
+ +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
| |
: returned_feedback_field :
| |
+---+---+---+---+---+---+---+---+
- */
- if((**start_ptr) <= 128){
- tcomp_buffer_referenceBuff(message->ret_feedback_buffer, *start_ptr, 1);
- (void)(*start_ptr++);
- }
- else{
- tcomp_buffer_referenceBuff(message->ret_feedback_buffer, *start_ptr, 1+(**start_ptr&0x7f));
- *start_ptr += tcomp_buffer_getSize(message->ret_feedback_buffer);
- }
+ */
+ if((**start_ptr) <= 128) {
+ tcomp_buffer_referenceBuff(message->ret_feedback_buffer, *start_ptr, 1);
+ (void)(*start_ptr++);
+ }
+ else {
+ tcomp_buffer_referenceBuff(message->ret_feedback_buffer, *start_ptr, 1+(**start_ptr&0x7f));
+ *start_ptr += tcomp_buffer_getSize(message->ret_feedback_buffer);
+ }
}
/*
@@ -189,8 +188,8 @@ Initializes the state identifier field.
*/
static void initStateId(tcomp_message_t *message, uint8_t** start_ptr, uint8_t state_len)
{
- tcomp_buffer_referenceBuff(message->stateId, *start_ptr, state_len);
- *start_ptr += state_len;
+ tcomp_buffer_referenceBuff(message->stateId, *start_ptr, state_len);
+ *start_ptr += state_len;
}
/*
@@ -198,94 +197,97 @@ Initializes a stateful SigComp message.
*/
static void initStateful(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_ptr)
{
- /*
- +---+---+---+---+---+---+---+---+
- | |
- : partial state identifier :
- | |
- +---+---+---+---+---+---+---+---+
- | |
- : remaining SigComp message :
- | |
- +---+---+---+---+---+---+---+---+
- */
- message->isOK &= (*start_ptr<=end_ptr);
- if(message->isOK){
- tcomp_buffer_referenceBuff(message->remaining_sigcomp_buffer, *start_ptr,
- ((end_ptr-*start_ptr)));
- }
+ /*
+ +---+---+---+---+---+---+---+---+
+ | |
+ : partial state identifier :
+ | |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : remaining SigComp message :
+ | |
+ +---+---+---+---+---+---+---+---+
+ */
+ message->isOK &= (*start_ptr<=end_ptr);
+ if(message->isOK) {
+ tcomp_buffer_referenceBuff(message->remaining_sigcomp_buffer, *start_ptr,
+ ((end_ptr-*start_ptr)));
+ }
}
-
+
/*
Initializes a stateless SigComp message.
*/
static void initStateless(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_ptr, int32_t *nack_code)
{
- int has_bytecode = (HEADER_GET_LEN(message) == 0); // No state ==> message contains udvm bytecode
- message->isOK &= has_bytecode;
- if(!message->isOK) return;
-
- /*
- +---+---+---+---+---+---+---+---+
- | code_len |
- +---+---+---+---+---+---+---+---+
- | code_len | destination |
- +---+---+---+---+---+---+---+---+
- | |
- : uploaded UDVM bytecode :
- | |
- +---+---+---+---+---+---+---+---+
- | |
- : remaining SigComp message :
- | |
- +---+---+---+---+---+---+---+---+
- */
- {
- uint32_t code_len1, bytecodes_len;
- uint8_t code_len2, destination, *bytecodes_uploaded_udvm, *remaining_SigComp_message;
-
- uint8_t* dummy_ptr = ((uint8_t*)*start_ptr);
-
- /* Code_len --> 12bits [8+4] */
- code_len1 = *dummy_ptr; dummy_ptr++; /* skip first code_len 8bits */
- code_len2 = (*dummy_ptr) & 0xf0; /* code_len 4 remaining bits */
- destination = (*dummy_ptr) & 0x0f; /* 4bits after code_len */
- dummy_ptr++; /* skip code_len 4bits + destination 4bits ==> 1-byte */
-
- /* Get bytecodes length (12bits) */
- bytecodes_len = ( (code_len1<<4)|(code_len2>>4) );
-
- /* Starting memory address (code destination address). In UDVM. */
- message->bytecodes_destination = HEADER_GET_DEST_VALUE(destination);
- if((message->bytecodes_destination < 128) || (message->bytecodes_destination > 1024)){
- TSK_DEBUG_ERROR("INVALID_CODE_LOCATION");
- *nack_code = NACK_INVALID_CODE_LOCATION;
- message->isOK = 0;
- return;
- }
-
- /* Uploaded UDVM pointer */
- bytecodes_uploaded_udvm = dummy_ptr; /* SigComp header, feedback_item, code_len and destination have been skipped */
-
- /* Skip uploaded udvm */
- dummy_ptr += bytecodes_len;
-
- /* remaining SigComp message */
- remaining_SigComp_message = dummy_ptr;
-
- /* check that remaining sigcomp message is valide */
- if( !(message->isOK &= (remaining_SigComp_message <= end_ptr )) ){
- TSK_DEBUG_ERROR("MESSAGE_TOO_SHORT");
- *nack_code = NACK_MESSAGE_TOO_SHORT;
- return;
- }
-
- //
- // Setting buffers
- //
- tcomp_buffer_referenceBuff(message->uploaded_UDVM_buffer, bytecodes_uploaded_udvm, bytecodes_len);
- tcomp_buffer_referenceBuff(message->remaining_sigcomp_buffer, remaining_SigComp_message, ((end_ptr-remaining_SigComp_message)));
- }
+ int has_bytecode = (HEADER_GET_LEN(message) == 0); // No state ==> message contains udvm bytecode
+ message->isOK &= has_bytecode;
+ if(!message->isOK) {
+ return;
+ }
+
+ /*
+ +---+---+---+---+---+---+---+---+
+ | code_len |
+ +---+---+---+---+---+---+---+---+
+ | code_len | destination |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : uploaded UDVM bytecode :
+ | |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : remaining SigComp message :
+ | |
+ +---+---+---+---+---+---+---+---+
+ */
+ {
+ uint32_t code_len1, bytecodes_len;
+ uint8_t code_len2, destination, *bytecodes_uploaded_udvm, *remaining_SigComp_message;
+
+ uint8_t* dummy_ptr = ((uint8_t*)*start_ptr);
+
+ /* Code_len --> 12bits [8+4] */
+ code_len1 = *dummy_ptr;
+ dummy_ptr++; /* skip first code_len 8bits */
+ code_len2 = (*dummy_ptr) & 0xf0; /* code_len 4 remaining bits */
+ destination = (*dummy_ptr) & 0x0f; /* 4bits after code_len */
+ dummy_ptr++; /* skip code_len 4bits + destination 4bits ==> 1-byte */
+
+ /* Get bytecodes length (12bits) */
+ bytecodes_len = ( (code_len1<<4)|(code_len2>>4) );
+
+ /* Starting memory address (code destination address). In UDVM. */
+ message->bytecodes_destination = HEADER_GET_DEST_VALUE(destination);
+ if((message->bytecodes_destination < 128) || (message->bytecodes_destination > 1024)) {
+ TSK_DEBUG_ERROR("INVALID_CODE_LOCATION");
+ *nack_code = NACK_INVALID_CODE_LOCATION;
+ message->isOK = 0;
+ return;
+ }
+
+ /* Uploaded UDVM pointer */
+ bytecodes_uploaded_udvm = dummy_ptr; /* SigComp header, feedback_item, code_len and destination have been skipped */
+
+ /* Skip uploaded udvm */
+ dummy_ptr += bytecodes_len;
+
+ /* remaining SigComp message */
+ remaining_SigComp_message = dummy_ptr;
+
+ /* check that remaining sigcomp message is valide */
+ if( !(message->isOK &= (remaining_SigComp_message <= end_ptr )) ) {
+ TSK_DEBUG_ERROR("MESSAGE_TOO_SHORT");
+ *nack_code = NACK_MESSAGE_TOO_SHORT;
+ return;
+ }
+
+ //
+ // Setting buffers
+ //
+ tcomp_buffer_referenceBuff(message->uploaded_UDVM_buffer, bytecodes_uploaded_udvm, bytecodes_len);
+ tcomp_buffer_referenceBuff(message->remaining_sigcomp_buffer, remaining_SigComp_message, ((end_ptr-remaining_SigComp_message)));
+ }
}
/*
@@ -293,55 +295,57 @@ Initializes a NACK message as per RFC 4077.
*/
static void initNack(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end_ptr, int32_t* nack_code)
{
- /*
- +---+---+---+---+---+---+---+---+
- | code_len = 0 |
- +---+---+---+---+---+---+---+---+
- | code_len = 0 | version = 1 |
- +---+---+---+---+---+---+---+---+
- | Reason Code |
- +---+---+---+---+---+---+---+---+
- | OPCODE of failed instruction |
- +---+---+---+---+---+---+---+---+
- | PC of failed instruction |
- | |
- +---+---+---+---+---+---+---+---+
- | |
- : SHA-1 Hash of failed message :
- | |
- +---+---+---+---+---+---+---+---+
- | |
- : Error Details :
- | |
- +---+---+---+---+---+---+---+---+*/
-
- uint8_t* dummy_ptr;
- message->isNack = 1;
- if( (end_ptr - *start_ptr)<25 ){
- *nack_code = NACK_MESSAGE_TOO_SHORT;
- TSK_DEBUG_ERROR("MESSAGE_TOO_SHORT");
- message->isOK = 0;
- return;
- }
-
- dummy_ptr = ((uint8_t*)*start_ptr);
- dummy_ptr++; /* skip first code_len byte */
- if(!(message->isOK = (*dummy_ptr++ == NACK_VERSION))) {
- return;
- }
-
- if(!message->nack_info){
- message->nack_info = tcomp_nackinfo_create();
- }
-
- message->nack_info->reasonCode = *dummy_ptr++;
- message->nack_info->opcode = *dummy_ptr++;
- message->nack_info->pc = TSK_BINARY_GET_2BYTES(dummy_ptr); dummy_ptr+=2;
- memcpy(message->nack_info->sha1, dummy_ptr, TSK_SHA1_DIGEST_SIZE); dummy_ptr += TSK_SHA1_DIGEST_SIZE;
- if(dummy_ptr < end_ptr){
- /* Has error details */
- tcomp_buffer_appendBuff(message->nack_info->details, dummy_ptr, (end_ptr-dummy_ptr));
- }
+ /*
+ +---+---+---+---+---+---+---+---+
+ | code_len = 0 |
+ +---+---+---+---+---+---+---+---+
+ | code_len = 0 | version = 1 |
+ +---+---+---+---+---+---+---+---+
+ | Reason Code |
+ +---+---+---+---+---+---+---+---+
+ | OPCODE of failed instruction |
+ +---+---+---+---+---+---+---+---+
+ | PC of failed instruction |
+ | |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : SHA-1 Hash of failed message :
+ | |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : Error Details :
+ | |
+ +---+---+---+---+---+---+---+---+*/
+
+ uint8_t* dummy_ptr;
+ message->isNack = 1;
+ if( (end_ptr - *start_ptr)<25 ) {
+ *nack_code = NACK_MESSAGE_TOO_SHORT;
+ TSK_DEBUG_ERROR("MESSAGE_TOO_SHORT");
+ message->isOK = 0;
+ return;
+ }
+
+ dummy_ptr = ((uint8_t*)*start_ptr);
+ dummy_ptr++; /* skip first code_len byte */
+ if(!(message->isOK = (*dummy_ptr++ == NACK_VERSION))) {
+ return;
+ }
+
+ if(!message->nack_info) {
+ message->nack_info = tcomp_nackinfo_create();
+ }
+
+ message->nack_info->reasonCode = *dummy_ptr++;
+ message->nack_info->opcode = *dummy_ptr++;
+ message->nack_info->pc = TSK_BINARY_GET_2BYTES(dummy_ptr);
+ dummy_ptr+=2;
+ memcpy(message->nack_info->sha1, dummy_ptr, TSK_SHA1_DIGEST_SIZE);
+ dummy_ptr += TSK_SHA1_DIGEST_SIZE;
+ if(dummy_ptr < end_ptr) {
+ /* Has error details */
+ tcomp_buffer_appendBuff(message->nack_info->details, dummy_ptr, (end_ptr-dummy_ptr));
+ }
}
@@ -354,37 +358,36 @@ static void initNack(tcomp_message_t *message, uint8_t** start_ptr, uint8_t* end
static tsk_object_t* tcomp_message_ctor(tsk_object_t *self, va_list * app)
{
- tcomp_message_t *message = self;
+ tcomp_message_t *message = self;
- if(message){
- }
+ if(message) {
+ }
- return self;
+ return self;
}
static tsk_object_t* tcomp_message_dtor(tsk_object_t *self)
{
- tcomp_message_t *message = self;
-
- if(message){
- TSK_OBJECT_SAFE_FREE(message->stateId);
- TSK_OBJECT_SAFE_FREE(message->remaining_sigcomp_buffer);
- TSK_OBJECT_SAFE_FREE(message->uploaded_UDVM_buffer);
- TSK_OBJECT_SAFE_FREE(message->ret_feedback_buffer);
- TSK_OBJECT_SAFE_FREE(message->nack_info);
- }
- else{
- TSK_DEBUG_WARN("NULL SigComp message.");
- }
-
- return self;
+ tcomp_message_t *message = self;
+
+ if(message) {
+ TSK_OBJECT_SAFE_FREE(message->stateId);
+ TSK_OBJECT_SAFE_FREE(message->remaining_sigcomp_buffer);
+ TSK_OBJECT_SAFE_FREE(message->uploaded_UDVM_buffer);
+ TSK_OBJECT_SAFE_FREE(message->ret_feedback_buffer);
+ TSK_OBJECT_SAFE_FREE(message->nack_info);
+ }
+ else {
+ TSK_DEBUG_WARN("NULL SigComp message.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_message_def_s =
-{
- sizeof(tcomp_message_t),
- tcomp_message_ctor,
- tcomp_message_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_message_def_s = {
+ sizeof(tcomp_message_t),
+ tcomp_message_ctor,
+ tcomp_message_dtor,
+ tsk_null
};
const tsk_object_def_t* tcomp_message_def_t = &tcomp_message_def_s;
diff --git a/tinySIGCOMP/src/tcomp_message.h b/tinySIGCOMP/src/tcomp_message.h
index 9d5b41d..70c56d3 100755
--- a/tinySIGCOMP/src/tcomp_message.h
+++ b/tinySIGCOMP/src/tcomp_message.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -41,27 +41,26 @@ TCOMP_BEGIN_DECLS
/**
* SigComp Message Format as per RFC 3320 subclause 7.
*/
-typedef struct tcomp_message_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_message_s {
+ TSK_DECLARE_OBJECT;
+
+ uint8_t headerSigComp; /**< SigComp header */
+
+ unsigned isOK:1; /**< Message validity. */
+ unsigned isNack:1; /**< If it's a NACK message. */
+ unsigned stream_based:1; /**< If it's stream message (e.g. TCP) */
+ const uint8_t* startPtr; /**< Message pointer. */
+ tsk_size_t totalSize; /**< The total message size. */
+ tsk_size_t header_size; /**< The size of the message header */
+
+ tcomp_buffer_handle_t* stateId; /**< */
- uint8_t headerSigComp; /**< SigComp header */
+ uint32_t bytecodes_destination; /**< */
+ tcomp_buffer_handle_t* remaining_sigcomp_buffer; /**< */
+ tcomp_buffer_handle_t* uploaded_UDVM_buffer; /**< */
+ tcomp_buffer_handle_t* ret_feedback_buffer; /**< */
- unsigned isOK:1; /**< Message validity. */
- unsigned isNack:1; /**< If it's a NACK message. */
- unsigned stream_based:1; /**< If it's stream message (e.g. TCP) */
- const uint8_t* startPtr; /**< Message pointer. */
- tsk_size_t totalSize; /**< The total message size. */
- tsk_size_t header_size; /**< The size of the message header */
-
- tcomp_buffer_handle_t* stateId; /**< */
-
- uint32_t bytecodes_destination; /**< */
- tcomp_buffer_handle_t* remaining_sigcomp_buffer; /**< */
- tcomp_buffer_handle_t* uploaded_UDVM_buffer; /**< */
- tcomp_buffer_handle_t* ret_feedback_buffer; /**< */
-
- tcomp_nackinfo_t* nack_info; /**< */
+ tcomp_nackinfo_t* nack_info; /**< */
}
tcomp_message_t;
diff --git a/tinySIGCOMP/src/tcomp_nack_codes.h b/tinySIGCOMP/src/tcomp_nack_codes.h
index 76eb33f..20fa12e 100755
--- a/tinySIGCOMP/src/tcomp_nack_codes.h
+++ b/tinySIGCOMP/src/tcomp_nack_codes.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -95,41 +95,39 @@
#define NACK_FRAMING_ERROR 25
-typedef struct tcomp_nack_desc_s
-{
- int32_t code;
- const char* desc;
+typedef struct tcomp_nack_desc_s {
+ int32_t code;
+ const char* desc;
}
tcomp_nack_desc_t;
-static const tcomp_nack_desc_t TCOMP_NACK_DESCRIPTIONS[] =
-{
- { NACK_NONE, "NONE" },
- { NACK_STATE_NOT_FOUND, "STATE_NOT_FOUND" },
- { NACK_CYCLES_EXHAUSTED, "CYCLES_EXHAUSTED" },
- { NACK_USER_REQUESTED, "USER_REQUESTED" },
- { NACK_SEGFAULT, "SEGFAULT" },
- { NACK_TOO_MANY_STATE_REQUESTS, "TOO_MANY_STATE_REQUESTS" },
- { NACK_INVALID_STATE_ID_LENGTH, "INVALID_STATE_ID_LENGTH" },
- { NACK_INVALID_STATE_PRIORITY, "INVALID_STATE_PRIORITY" },
- { NACK_OUTPUT_OVERFLOW, "OUTPUT_OVERFLOW" },
- { NACK_STACK_UNDERFLOW, "STACK_UNDERFLOW" },
- { NACK_BAD_INPUT_BITORDER, "BAD_INPUT_BITORDER" },
- { NACK_DIV_BY_ZERO, "DIV_BY_ZERO" },
- { NACK_SWITCH_VALUE_TOO_HIGH, "SWITCH_VALUE_TOO_HIGH" },
- { NACK_TOO_MANY_BITS_REQUESTED, "TOO_MANY_BITS_REQUESTED" },
- { NACK_INVALID_OPERAND, "INVALID_OPERAND" },
- { NACK_HUFFMAN_NO_MATCH, "HUFFMAN_NO_MATCH" },
- { NACK_MESSAGE_TOO_SHORT, "MESSAGE_TOO_SHORT" },
- { NACK_INVALID_CODE_LOCATION, "INVALID_CODE_LOCATION" },
- { NACK_BYTECODES_TOO_LARGE, "BYTECODES_TOO_LARGE" },
- { NACK_INVALID_OPCODE, "INVALID_OPCODE" },
- { NACK_INVALID_STATE_PROBE, "INVALID_STATE_PROBE" },
- { NACK_ID_NOT_UNIQUE, "ID_NOT_UNIQUE" },
- { NACK_MULTILOAD_OVERWRITTEN, "MULTILOAD_OVERWRITTEN" },
- { NACK_STATE_TOO_SHORT, "STATE_TOO_SHORT" },
- { NACK_INTERNAL_ERROR, "INTERNAL_ERROR" },
- { NACK_FRAMING_ERROR, "FRAMING_ERROR" }
+static const tcomp_nack_desc_t TCOMP_NACK_DESCRIPTIONS[] = {
+ { NACK_NONE, "NONE" },
+ { NACK_STATE_NOT_FOUND, "STATE_NOT_FOUND" },
+ { NACK_CYCLES_EXHAUSTED, "CYCLES_EXHAUSTED" },
+ { NACK_USER_REQUESTED, "USER_REQUESTED" },
+ { NACK_SEGFAULT, "SEGFAULT" },
+ { NACK_TOO_MANY_STATE_REQUESTS, "TOO_MANY_STATE_REQUESTS" },
+ { NACK_INVALID_STATE_ID_LENGTH, "INVALID_STATE_ID_LENGTH" },
+ { NACK_INVALID_STATE_PRIORITY, "INVALID_STATE_PRIORITY" },
+ { NACK_OUTPUT_OVERFLOW, "OUTPUT_OVERFLOW" },
+ { NACK_STACK_UNDERFLOW, "STACK_UNDERFLOW" },
+ { NACK_BAD_INPUT_BITORDER, "BAD_INPUT_BITORDER" },
+ { NACK_DIV_BY_ZERO, "DIV_BY_ZERO" },
+ { NACK_SWITCH_VALUE_TOO_HIGH, "SWITCH_VALUE_TOO_HIGH" },
+ { NACK_TOO_MANY_BITS_REQUESTED, "TOO_MANY_BITS_REQUESTED" },
+ { NACK_INVALID_OPERAND, "INVALID_OPERAND" },
+ { NACK_HUFFMAN_NO_MATCH, "HUFFMAN_NO_MATCH" },
+ { NACK_MESSAGE_TOO_SHORT, "MESSAGE_TOO_SHORT" },
+ { NACK_INVALID_CODE_LOCATION, "INVALID_CODE_LOCATION" },
+ { NACK_BYTECODES_TOO_LARGE, "BYTECODES_TOO_LARGE" },
+ { NACK_INVALID_OPCODE, "INVALID_OPCODE" },
+ { NACK_INVALID_STATE_PROBE, "INVALID_STATE_PROBE" },
+ { NACK_ID_NOT_UNIQUE, "ID_NOT_UNIQUE" },
+ { NACK_MULTILOAD_OVERWRITTEN, "MULTILOAD_OVERWRITTEN" },
+ { NACK_STATE_TOO_SHORT, "STATE_TOO_SHORT" },
+ { NACK_INTERNAL_ERROR, "INTERNAL_ERROR" },
+ { NACK_FRAMING_ERROR, "FRAMING_ERROR" }
};
#endif /* TCOMP_NACKCODES_H */
diff --git a/tinySIGCOMP/src/tcomp_nackinfo.c b/tinySIGCOMP/src/tcomp_nackinfo.c
index fb7b58c..64515df 100755
--- a/tinySIGCOMP/src/tcomp_nackinfo.c
+++ b/tinySIGCOMP/src/tcomp_nackinfo.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -49,139 +49,139 @@ field is set to 0.
/** Creates new NACK object */
tcomp_nackinfo_t* tcomp_nackinfo_create()
{
- tcomp_nackinfo_t *nackinfo;
- if((nackinfo = tsk_object_new(tcomp_nackinfo_def_t))){
- nackinfo->version = NACK_VERSION;
- nackinfo->details = tcomp_buffer_create_null();
- }
- return nackinfo;
+ tcomp_nackinfo_t *nackinfo;
+ if((nackinfo = tsk_object_new(tcomp_nackinfo_def_t))) {
+ nackinfo->version = NACK_VERSION;
+ nackinfo->details = tcomp_buffer_create_null();
+ }
+ return nackinfo;
}
-int tcomp_nackinfo_write(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- uint8_t opCode,
- int16_t memory_address_of_instruction,
- const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize,
- tcomp_buffer_handle_t* lpDetails,
- uint16_t udvm_size,
- uint8_t cpbValue)
+int tcomp_nackinfo_write(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ uint8_t opCode,
+ int16_t memory_address_of_instruction,
+ const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize,
+ tcomp_buffer_handle_t* lpDetails,
+ uint16_t udvm_size,
+ uint8_t cpbValue)
{
- tsk_sha1context_t sha;
- uint8_t *nackbuffer_ptr;
-
- if(!buffer || !sigCompMessagePtr || !sigCompMessageSize){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- tcomp_buffer_allocBuff(buffer, INDEX_NACK_SHA1 + TSK_SHA1_DIGEST_SIZE);
- if(!(nackbuffer_ptr = tcomp_buffer_getBuffer(buffer))){
- TSK_DEBUG_ERROR("NACK buffer is null");
- return -2;
- }
-
- nackbuffer_ptr[INDEX_NACK_HEADER] = 0xf8;
- nackbuffer_ptr[INDEX_NACK_VERSION] = NACK_VERSION;
- nackbuffer_ptr[INDEX_NACK_REASON_CODE] = reasonCode;
- nackbuffer_ptr[INDEX_NACK_OPCODE] = opCode;
- nackbuffer_ptr[INDEX_NACK_PC] = (memory_address_of_instruction >> 8);
- nackbuffer_ptr[INDEX_NACK_PC + 1] = (memory_address_of_instruction & 0x00ff);
-
- // SHA-1(message) computation
- tsk_sha1reset(&sha);
- tsk_sha1input(&sha, sigCompMessagePtr, sigCompMessageSize);
- tsk_sha1result(&sha, &nackbuffer_ptr[INDEX_NACK_SHA1]);
-
+ tsk_sha1context_t sha;
+ uint8_t *nackbuffer_ptr;
+
+ if(!buffer || !sigCompMessagePtr || !sigCompMessageSize) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ tcomp_buffer_allocBuff(buffer, INDEX_NACK_SHA1 + TSK_SHA1_DIGEST_SIZE);
+ if(!(nackbuffer_ptr = tcomp_buffer_getBuffer(buffer))) {
+ TSK_DEBUG_ERROR("NACK buffer is null");
+ return -2;
+ }
+
+ nackbuffer_ptr[INDEX_NACK_HEADER] = 0xf8;
+ nackbuffer_ptr[INDEX_NACK_VERSION] = NACK_VERSION;
+ nackbuffer_ptr[INDEX_NACK_REASON_CODE] = reasonCode;
+ nackbuffer_ptr[INDEX_NACK_OPCODE] = opCode;
+ nackbuffer_ptr[INDEX_NACK_PC] = (memory_address_of_instruction >> 8);
+ nackbuffer_ptr[INDEX_NACK_PC + 1] = (memory_address_of_instruction & 0x00ff);
+
+ // SHA-1(message) computation
+ tsk_sha1reset(&sha);
+ tsk_sha1input(&sha, sigCompMessagePtr, sigCompMessageSize);
+ tsk_sha1result(&sha, &nackbuffer_ptr[INDEX_NACK_SHA1]);
+
#if 0
- {
- int i;
- TSK_DEBUG_INFO("Create NACK with id:");
- for(i = 0; i < TSK_SHA1_DIGEST_SIZE; ++i){
- printf("%x ", nackbuffer_ptr[INDEX_NACK_SHA1 + i]);
- }
- printf("\n");
- }
+ {
+ int i;
+ TSK_DEBUG_INFO("Create NACK with id:");
+ for(i = 0; i < TSK_SHA1_DIGEST_SIZE; ++i) {
+ printf("%x ", nackbuffer_ptr[INDEX_NACK_SHA1 + i]);
+ }
+ printf("\n");
+ }
#endif
- // Details
- if(lpDetails && tcomp_buffer_getSize(lpDetails)){
- tcomp_buffer_appendBuff(buffer, tcomp_buffer_getBuffer(lpDetails), tcomp_buffer_getSize(lpDetails));
- }
- else if(reasonCode == NACK_BYTECODES_TOO_LARGE){
- tcomp_buffer_appendBuff(buffer, &udvm_size, 2);
- }
- else if(reasonCode == NACK_CYCLES_EXHAUSTED){
- tcomp_buffer_appendBuff(buffer, &cpbValue, 1);
- }
+ // Details
+ if(lpDetails && tcomp_buffer_getSize(lpDetails)) {
+ tcomp_buffer_appendBuff(buffer, tcomp_buffer_getBuffer(lpDetails), tcomp_buffer_getSize(lpDetails));
+ }
+ else if(reasonCode == NACK_BYTECODES_TOO_LARGE) {
+ tcomp_buffer_appendBuff(buffer, &udvm_size, 2);
+ }
+ else if(reasonCode == NACK_CYCLES_EXHAUSTED) {
+ tcomp_buffer_appendBuff(buffer, &cpbValue, 1);
+ }
- return 0;
+ return 0;
}
-int tcomp_nackinfo_write_2(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- uint8_t opCode,
- int16_t memory_address_of_instruction,
- const tcomp_message_t* sigCompMessage,
- tcomp_buffer_handle_t* lpDetails,
- uint16_t udvm_size,
- uint8_t cpbValue)
+int tcomp_nackinfo_write_2(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ uint8_t opCode,
+ int16_t memory_address_of_instruction,
+ const tcomp_message_t* sigCompMessage,
+ tcomp_buffer_handle_t* lpDetails,
+ uint16_t udvm_size,
+ uint8_t cpbValue)
{
- return tcomp_nackinfo_write(buffer,
- reasonCode,
- opCode,
- memory_address_of_instruction,
- sigCompMessage->startPtr, sigCompMessage->totalSize,
- lpDetails,
- udvm_size,
- cpbValue);
+ return tcomp_nackinfo_write(buffer,
+ reasonCode,
+ opCode,
+ memory_address_of_instruction,
+ sigCompMessage->startPtr, sigCompMessage->totalSize,
+ lpDetails,
+ udvm_size,
+ cpbValue);
}
-int tcomp_nackinfo_write_3(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize)
+int tcomp_nackinfo_write_3(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize)
{
- return tcomp_nackinfo_write(buffer,
- reasonCode,
- OPCODE_UNKNOWN,
- PC_UNKNOWN,
- sigCompMessagePtr, sigCompMessageSize,
- tsk_null,
- 0,
- 0);
+ return tcomp_nackinfo_write(buffer,
+ reasonCode,
+ OPCODE_UNKNOWN,
+ PC_UNKNOWN,
+ sigCompMessagePtr, sigCompMessageSize,
+ tsk_null,
+ 0,
+ 0);
}
-int tcomp_nackinfo_write_4(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- const tcomp_message_t* sigCompMessage)
+int tcomp_nackinfo_write_4(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ const tcomp_message_t* sigCompMessage)
{
- return tcomp_nackinfo_write_2(buffer,
- reasonCode,
- OPCODE_UNKNOWN,
- PC_UNKNOWN,
- sigCompMessage,
- tsk_null,
- 0,
- 0);
+ return tcomp_nackinfo_write_2(buffer,
+ reasonCode,
+ OPCODE_UNKNOWN,
+ PC_UNKNOWN,
+ sigCompMessage,
+ tsk_null,
+ 0,
+ 0);
}
const char* tcomp_nackinfo_get_description(const tcomp_buffer_handle_t* buffer)
{
- uint8_t reasonCode;
- if(!buffer){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_null;
- }
- if(tcomp_buffer_getSize(buffer) < 3){
- TSK_DEBUG_ERROR("Too short");
- return tsk_null;
- }
- reasonCode = *((const uint8_t*)tcomp_buffer_getBufferAtPos(buffer, 3));
- if(reasonCode >= (sizeof(TCOMP_NACK_DESCRIPTIONS)/sizeof(TCOMP_NACK_DESCRIPTIONS[0]))){
- TSK_DEBUG_ERROR("%d not valid as reasonCode", (int32_t)reasonCode);
- return tsk_null;
- }
- return TCOMP_NACK_DESCRIPTIONS[reasonCode].desc;
+ uint8_t reasonCode;
+ if(!buffer) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return tsk_null;
+ }
+ if(tcomp_buffer_getSize(buffer) < 3) {
+ TSK_DEBUG_ERROR("Too short");
+ return tsk_null;
+ }
+ reasonCode = *((const uint8_t*)tcomp_buffer_getBufferAtPos(buffer, 3));
+ if(reasonCode >= (sizeof(TCOMP_NACK_DESCRIPTIONS)/sizeof(TCOMP_NACK_DESCRIPTIONS[0]))) {
+ TSK_DEBUG_ERROR("%d not valid as reasonCode", (int32_t)reasonCode);
+ return tsk_null;
+ }
+ return TCOMP_NACK_DESCRIPTIONS[reasonCode].desc;
}
//========================================================
@@ -195,10 +195,10 @@ const char* tcomp_nackinfo_get_description(const tcomp_buffer_handle_t* buffer)
*/
static tsk_object_t* tcomp_nackinfo_ctor(tsk_object_t *self, va_list* app)
{
- tcomp_nackinfo_t *nackinfo = self;
- if(nackinfo){
- }
- return self;
+ tcomp_nackinfo_t *nackinfo = self;
+ if(nackinfo) {
+ }
+ return self;
}
/*
@@ -208,20 +208,19 @@ static tsk_object_t* tcomp_nackinfo_ctor(tsk_object_t *self, va_list* app)
*/
static tsk_object_t* tcomp_nackinfo_dtor(tsk_object_t* self)
{
- tcomp_nackinfo_t *nackinfo = self;
- if(nackinfo){
- TSK_OBJECT_SAFE_FREE(nackinfo->details);
- }
- return self;
+ tcomp_nackinfo_t *nackinfo = self;
+ if(nackinfo) {
+ TSK_OBJECT_SAFE_FREE(nackinfo->details);
+ }
+ return self;
}
-static const tsk_object_def_t tcomp_nackinfo_def_s =
-{
- sizeof(tcomp_nackinfo_t),
- tcomp_nackinfo_ctor,
- tcomp_nackinfo_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_nackinfo_def_s = {
+ sizeof(tcomp_nackinfo_t),
+ tcomp_nackinfo_ctor,
+ tcomp_nackinfo_dtor,
+ tsk_null
};
const tsk_object_def_t* tcomp_nackinfo_def_t = &tcomp_nackinfo_def_s;
diff --git a/tinySIGCOMP/src/tcomp_nackinfo.h b/tinySIGCOMP/src/tcomp_nackinfo.h
index 5a1e427..e7dd0e7 100755
--- a/tinySIGCOMP/src/tcomp_nackinfo.h
+++ b/tinySIGCOMP/src/tcomp_nackinfo.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -65,42 +65,41 @@ struct tcomp_message_s;
/**NACK info as per rfc 4077 subclause 3.1.
* You MUST use @ref tcomp_nackinfo_create() to create new nackinfo object.
*/
-typedef struct tcomp_nackinfo_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_nackinfo_s {
+ TSK_DECLARE_OBJECT;
- uint8_t version; /**< Gives the version of the NACK mechanism being employed. */
- uint8_t reasonCode; /**< The Reason Code is a one-byte value that indicates the nature of the decompression failure. */
- uint8_t opcode; /**< The "OPCODE of failed instruction" is a one-byte field that includes the opcode to which the PC was pointing when the failure occurred */
- uint32_t pc; /**< "PC of failed instruction" is a two-byte field containing the value of the program counter when failure occurred (i.e., the memory address of the failed UDVM instruction) */
- uint8_t sha1[TSK_SHA1_DIGEST_SIZE]; /**<"SHA-1 Hash of failed message" contains the full 20-byte SHA-1 hash of the SigComp message that could not be decompressed */
- tcomp_buffer_handle_t *details; /**< "Error Details" provides additional information that might be useful in correcting the problem that caused decompression failure.*/
+ uint8_t version; /**< Gives the version of the NACK mechanism being employed. */
+ uint8_t reasonCode; /**< The Reason Code is a one-byte value that indicates the nature of the decompression failure. */
+ uint8_t opcode; /**< The "OPCODE of failed instruction" is a one-byte field that includes the opcode to which the PC was pointing when the failure occurred */
+ uint32_t pc; /**< "PC of failed instruction" is a two-byte field containing the value of the program counter when failure occurred (i.e., the memory address of the failed UDVM instruction) */
+ uint8_t sha1[TSK_SHA1_DIGEST_SIZE]; /**<"SHA-1 Hash of failed message" contains the full 20-byte SHA-1 hash of the SigComp message that could not be decompressed */
+ tcomp_buffer_handle_t *details; /**< "Error Details" provides additional information that might be useful in correcting the problem that caused decompression failure.*/
}
tcomp_nackinfo_t;
tcomp_nackinfo_t* tcomp_nackinfo_create();
-int tcomp_nackinfo_write(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- uint8_t opCode,
- int16_t memory_address_of_instruction,
- const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize,
- tcomp_buffer_handle_t* lpDetails,
- uint16_t udvm_size,
- uint8_t cpbValue);
-int tcomp_nackinfo_write_2(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- uint8_t opCode,
- int16_t memory_address_of_instruction,
- const struct tcomp_message_s* sigCompMessage,
- tcomp_buffer_handle_t* lpDetails,
- uint16_t udvm_size,
- uint8_t cpbValue);
-int tcomp_nackinfo_write_3(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize);
-int tcomp_nackinfo_write_4(tcomp_buffer_handle_t* buffer,
- uint8_t reasonCode,
- const struct tcomp_message_s* sigCompMessage);
+int tcomp_nackinfo_write(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ uint8_t opCode,
+ int16_t memory_address_of_instruction,
+ const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize,
+ tcomp_buffer_handle_t* lpDetails,
+ uint16_t udvm_size,
+ uint8_t cpbValue);
+int tcomp_nackinfo_write_2(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ uint8_t opCode,
+ int16_t memory_address_of_instruction,
+ const struct tcomp_message_s* sigCompMessage,
+ tcomp_buffer_handle_t* lpDetails,
+ uint16_t udvm_size,
+ uint8_t cpbValue);
+int tcomp_nackinfo_write_3(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ const void* sigCompMessagePtr, tsk_size_t sigCompMessageSize);
+int tcomp_nackinfo_write_4(tcomp_buffer_handle_t* buffer,
+ uint8_t reasonCode,
+ const struct tcomp_message_s* sigCompMessage);
TINYSIGCOMP_API const char* tcomp_nackinfo_get_description(const tcomp_buffer_handle_t* buffer);
diff --git a/tinySIGCOMP/src/tcomp_operands.h b/tinySIGCOMP/src/tcomp_operands.h
index 985391a..2798642 100755
--- a/tinySIGCOMP/src/tcomp_operands.h
+++ b/tinySIGCOMP/src/tcomp_operands.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_params.c b/tinySIGCOMP/src/tcomp_params.c
index c7d7c54..ac79414 100755
--- a/tinySIGCOMP/src/tcomp_params.c
+++ b/tinySIGCOMP/src/tcomp_params.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -34,7 +34,7 @@
tcomp_params_t* tcomp_params_create()
{
- return tsk_object_new(tcomp_params_def_t);
+ return tsk_object_new(tcomp_params_def_t);
}
/**
@@ -44,14 +44,14 @@ tcomp_params_t* tcomp_params_create()
*/
tsk_bool_t tcomp_params_hasCpbDmsSms(tcomp_params_t* params)
{
- if(params){
- return (params->cpbCode || params->dmsCode || params->smsCode) ? tsk_true : tsk_false;
- }
- else{
- TSK_DEBUG_WARN("Invalid parameter.");
- }
-
- return tsk_false;
+ if(params) {
+ return (params->cpbCode || params->dmsCode || params->smsCode) ? tsk_true : tsk_false;
+ }
+ else {
+ TSK_DEBUG_WARN("Invalid parameter.");
+ }
+
+ return tsk_false;
}
/**
@@ -62,13 +62,13 @@ tsk_bool_t tcomp_params_hasCpbDmsSms(tcomp_params_t* params)
*/
void tcomp_params_setCpbCode(tcomp_params_t* params, uint8_t cpbCode)
{
- if(params){
- params->cpbCode = cpbCode;
- params->cpbValue = sigcomp_encoding_cpb[cpbCode];
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- }
+ if(params) {
+ params->cpbCode = cpbCode;
+ params->cpbValue = sigcomp_encoding_cpb[cpbCode];
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ }
}
/**
@@ -79,22 +79,21 @@ void tcomp_params_setCpbCode(tcomp_params_t* params, uint8_t cpbCode)
*/
int tcomp_params_setCpbValue(tcomp_params_t* params, uint8_t cpbValue)
{
- if(params)
- {
- uint8_t code;
- for(code=0; code<4; code++){
- if( cpbValue <= sigcomp_encoding_cpb[code]){
- params->cpbCode = code;
- break;
- }
- }
- params->cpbValue = cpbValue;
- return 0;
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- return -1;
- }
+ if(params) {
+ uint8_t code;
+ for(code=0; code<4; code++) {
+ if( cpbValue <= sigcomp_encoding_cpb[code]) {
+ params->cpbCode = code;
+ break;
+ }
+ }
+ params->cpbValue = cpbValue;
+ return 0;
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return -1;
+ }
}
/**
@@ -105,13 +104,13 @@ int tcomp_params_setCpbValue(tcomp_params_t* params, uint8_t cpbValue)
*/
void tcomp_params_setDmsCode(tcomp_params_t* params, uint8_t dmsCode)
{
- if(params){
- params->dmsCode = dmsCode;
- params->dmsValue = sigcomp_encoding_dms[dmsCode];
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- }
+ if(params) {
+ params->dmsCode = dmsCode;
+ params->dmsValue = sigcomp_encoding_dms[dmsCode];
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ }
}
/**
@@ -122,21 +121,21 @@ void tcomp_params_setDmsCode(tcomp_params_t* params, uint8_t dmsCode)
*/
int tcomp_params_setDmsValue(tcomp_params_t* params, uint32_t dmsValue)
{
- if(params){
- uint8_t code;
- for(code=1; code<8; code++){
- if(dmsValue <= sigcomp_encoding_dms[code]){
- params->dmsCode = code;
- break;
- }
- }
- params->dmsValue = dmsValue;
- return 0;
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- return -1;
- }
+ if(params) {
+ uint8_t code;
+ for(code=1; code<8; code++) {
+ if(dmsValue <= sigcomp_encoding_dms[code]) {
+ params->dmsCode = code;
+ break;
+ }
+ }
+ params->dmsValue = dmsValue;
+ return 0;
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return -1;
+ }
}
/**
@@ -147,13 +146,13 @@ int tcomp_params_setDmsValue(tcomp_params_t* params, uint32_t dmsValue)
*/
void tcomp_params_setSmsCode(tcomp_params_t* params, uint8_t smsCode)
{
- if(params){
- params->smsCode = smsCode;
- params->smsValue = sigcomp_encoding_sms[smsCode];
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- }
+ if(params) {
+ params->smsCode = smsCode;
+ params->smsValue = sigcomp_encoding_sms[smsCode];
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ }
}
/**
@@ -164,21 +163,21 @@ void tcomp_params_setSmsCode(tcomp_params_t* params, uint8_t smsCode)
*/
int tcomp_params_setSmsValue(tcomp_params_t* params, uint32_t smsValue)
{
- if(params){
- uint8_t code;
- for(code = 0; code < 8; code++){
- if(smsValue <= sigcomp_encoding_sms[code]){
- params->smsCode = code;
- break;
- }
- }
- params->smsValue = smsValue;
- return 0;
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- return -1;
- }
+ if(params) {
+ uint8_t code;
+ for(code = 0; code < 8; code++) {
+ if(smsValue <= sigcomp_encoding_sms[code]) {
+ params->smsCode = code;
+ break;
+ }
+ }
+ params->smsValue = smsValue;
+ return 0;
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return -1;
+ }
}
/**
@@ -189,23 +188,23 @@ int tcomp_params_setSmsValue(tcomp_params_t* params, uint32_t smsValue)
*/
uint32_t tcomp_params_getParameters(tcomp_params_t* params)
{
- if(params){
- /*
- +---+---+---+---+---+---+---+---+
- | cpb | dms | sms |
- +---+---+---+---+---+---+---+---+
- | SigComp_version |
- +---+---+---+---+---+---+---+---+
- */
- uint32_t result = ((params->cpbCode<<6)|(params->dmsCode<<3)|params->smsCode);
- result <<=8;
- return (result | params->SigComp_version);
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- }
+ if(params) {
+ /*
+ +---+---+---+---+---+---+---+---+
+ | cpb | dms | sms |
+ +---+---+---+---+---+---+---+---+
+ | SigComp_version |
+ +---+---+---+---+---+---+---+---+
+ */
+ uint32_t result = ((params->cpbCode<<6)|(params->dmsCode<<3)|params->smsCode);
+ result <<=8;
+ return (result | params->SigComp_version);
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ }
- return 0;
+ return 0;
}
/**
@@ -216,22 +215,22 @@ uint32_t tcomp_params_getParameters(tcomp_params_t* params)
*/
void tcomp_params_setParameters(tcomp_params_t* params, uint32_t sigCompParameters)
{
- if(params){
- /*
- +---+---+---+---+---+---+---+---+
- | cpb | dms | sms |
- +---+---+---+---+---+---+---+---+
- | SigComp_version |
- +---+---+---+---+---+---+---+---+
- */
- tcomp_params_setCpbCode( params, (sigCompParameters>>14) );
- tcomp_params_setDmsCode( params, ((sigCompParameters>>11) & 0x07) );
- tcomp_params_setSmsCode( params, ((sigCompParameters>>8) & 0x07) );
- params->SigComp_version = ( (sigCompParameters & 0x00ff) );
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- }
+ if(params) {
+ /*
+ +---+---+---+---+---+---+---+---+
+ | cpb | dms | sms |
+ +---+---+---+---+---+---+---+---+
+ | SigComp_version |
+ +---+---+---+---+---+---+---+---+
+ */
+ tcomp_params_setCpbCode( params, (sigCompParameters>>14) );
+ tcomp_params_setDmsCode( params, ((sigCompParameters>>11) & 0x07) );
+ tcomp_params_setSmsCode( params, ((sigCompParameters>>8) & 0x07) );
+ params->SigComp_version = ( (sigCompParameters & 0x00ff) );
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ }
}
/**
@@ -240,15 +239,15 @@ void tcomp_params_setParameters(tcomp_params_t* params, uint32_t sigCompParamete
*/
void tcomp_params_reset(tcomp_params_t* params)
{
- if(params){
- params->cpbCode = params->dmsCode = params->smsCode = params->SigComp_version = 0;
- params->cpbValue = params->dmsValue = params->smsValue = 0;
-
- tsk_list_clear_items(params->returnedStates);
- }
- else{
- TSK_DEBUG_WARN("Invalid parameter.");
- }
+ if(params) {
+ params->cpbCode = params->dmsCode = params->smsCode = params->SigComp_version = 0;
+ params->cpbValue = params->dmsValue = params->smsValue = 0;
+
+ tsk_list_clear_items(params->returnedStates);
+ }
+ else {
+ TSK_DEBUG_WARN("Invalid parameter.");
+ }
}
@@ -263,35 +262,34 @@ void tcomp_params_reset(tcomp_params_t* params)
//
static tsk_object_t* tcomp_params_ctor(tsk_object_t *self, va_list * app)
{
- tcomp_params_t *params = self;
- if(params){
- //tcomp_params_reset(params);
- params->returnedStates = tsk_list_create();
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new sigcomp params.");
- }
-
- return self;
+ tcomp_params_t *params = self;
+ if(params) {
+ //tcomp_params_reset(params);
+ params->returnedStates = tsk_list_create();
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new sigcomp params.");
+ }
+
+ return self;
}
static tsk_object_t* tcomp_params_dtor(tsk_object_t *self)
{
- tcomp_params_t *params = self;
- if(params){
- TSK_OBJECT_SAFE_FREE(params->returnedStates);
- }
- else{
- TSK_DEBUG_WARN("NULL sigcomp parameters.");
- }
+ tcomp_params_t *params = self;
+ if(params) {
+ TSK_OBJECT_SAFE_FREE(params->returnedStates);
+ }
+ else {
+ TSK_DEBUG_WARN("NULL sigcomp parameters.");
+ }
- return self;
+ return self;
}
-static const tsk_object_def_t tcomp_params_def_s =
-{
- sizeof(tcomp_params_t),
- tcomp_params_ctor,
- tcomp_params_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_params_def_s = {
+ sizeof(tcomp_params_t),
+ tcomp_params_ctor,
+ tcomp_params_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_params_def_t = &tcomp_params_def_s;
diff --git a/tinySIGCOMP/src/tcomp_params.h b/tinySIGCOMP/src/tcomp_params.h
index 85d96dc..031af2d 100755
--- a/tinySIGCOMP/src/tcomp_params.h
+++ b/tinySIGCOMP/src/tcomp_params.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -41,27 +41,26 @@
TCOMP_BEGIN_DECLS
-typedef struct tcomp_params_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_params_s {
+ TSK_DECLARE_OBJECT;
- uint8_t cpbCode; /**< 'Cycles Per Bit' binary code. You MUST use @ref tcomp_params_setCpbCode to set this value. */
- uint8_t dmsCode; /**< 'Decompression Memory' Size binary code. You MUST use @ref tcomp_params_setDmsCode to set this value. */
- uint8_t smsCode; /**< 'State Memory Size' binary code. You MUST use @ref tcomp_params_setSmsCode to set this value. */
+ uint8_t cpbCode; /**< 'Cycles Per Bit' binary code. You MUST use @ref tcomp_params_setCpbCode to set this value. */
+ uint8_t dmsCode; /**< 'Decompression Memory' Size binary code. You MUST use @ref tcomp_params_setDmsCode to set this value. */
+ uint8_t smsCode; /**< 'State Memory Size' binary code. You MUST use @ref tcomp_params_setSmsCode to set this value. */
- uint8_t cpbValue; /**< 'Cycles Per Bit' value. You MUST use @ref tcomp_params_setCpbValue to set this value. */
- uint32_t dmsValue; /**< 'Decompression Memory Size' value. You MUST use @ref tcomp_params_setDmsValue to set this value. */
- uint32_t smsValue; /**< 'State Memory Size' value You MUST use @ref tcomp_params_setSmsValue to set this value. */
+ uint8_t cpbValue; /**< 'Cycles Per Bit' value. You MUST use @ref tcomp_params_setCpbValue to set this value. */
+ uint32_t dmsValue; /**< 'Decompression Memory Size' value. You MUST use @ref tcomp_params_setDmsValue to set this value. */
+ uint32_t smsValue; /**< 'State Memory Size' value You MUST use @ref tcomp_params_setSmsValue to set this value. */
- uint8_t SigComp_version; /**< SigComp version. */
- tcomp_buffers_L_t* returnedStates; /**< List of the returned states. */
+ uint8_t SigComp_version; /**< SigComp version. */
+ tcomp_buffers_L_t* returnedStates; /**< List of the returned states. */
}
tcomp_params_t;
tcomp_params_t* tcomp_params_create();
tsk_bool_t tcomp_params_hasCpbDmsSms(tcomp_params_t*);
-
+
void tcomp_params_setCpbCode(tcomp_params_t*, uint8_t _cpbCode);
int tcomp_params_setCpbValue(tcomp_params_t*, uint8_t _cpbValue);
diff --git a/tinySIGCOMP/src/tcomp_reqfeed.c b/tinySIGCOMP/src/tcomp_reqfeed.c
index 0969c04..a186620 100755
--- a/tinySIGCOMP/src/tcomp_reqfeed.c
+++ b/tinySIGCOMP/src/tcomp_reqfeed.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -37,7 +37,7 @@
*/
tcomp_reqfeed_t* tcomp_reqfeed_create()
{
- return tsk_object_new(tcomp_reqfeed_def_t);
+ return tsk_object_new(tcomp_reqfeed_def_t);
}
/**
@@ -46,15 +46,15 @@ tcomp_reqfeed_t* tcomp_reqfeed_create()
*/
void tcomp_reqfeed_reset(tcomp_reqfeed_t* feedback)
{
- if(feedback){
- tcomp_buffer_freeBuff(feedback->item);
- tcomp_buffer_reset(feedback->item);
-
- feedback->Q = feedback->S = feedback->I = 0;
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter.");
- }
+ if(feedback) {
+ tcomp_buffer_freeBuff(feedback->item);
+ tcomp_buffer_reset(feedback->item);
+
+ feedback->Q = feedback->S = feedback->I = 0;
+ }
+ else {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ }
}
@@ -65,33 +65,32 @@ void tcomp_reqfeed_reset(tcomp_reqfeed_t* feedback)
//
static void* tcomp_reqfeed_ctor(void * self, va_list * app)
{
- tcomp_reqfeed_t *feedback = self;
- if(feedback){
- feedback->item = tcomp_buffer_create_null();
- }
- else{
- TSK_DEBUG_WARN("NULL feedback");
- }
+ tcomp_reqfeed_t *feedback = self;
+ if(feedback) {
+ feedback->item = tcomp_buffer_create_null();
+ }
+ else {
+ TSK_DEBUG_WARN("NULL feedback");
+ }
- return self;
+ return self;
}
static void* tcomp_reqfeed_dtor(void* self)
{
- tcomp_reqfeed_t *feedback = self;
- if(feedback){
- TSK_OBJECT_SAFE_FREE(feedback->item);
- }
- else{
- TSK_DEBUG_WARN("NULL feedback");
- }
- return self;
+ tcomp_reqfeed_t *feedback = self;
+ if(feedback) {
+ TSK_OBJECT_SAFE_FREE(feedback->item);
+ }
+ else {
+ TSK_DEBUG_WARN("NULL feedback");
+ }
+ return self;
}
-static const tsk_object_def_t tcomp_reqfeed_def_s =
-{
- sizeof(tcomp_reqfeed_t),
- tcomp_reqfeed_ctor,
- tcomp_reqfeed_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_reqfeed_def_s = {
+ sizeof(tcomp_reqfeed_t),
+ tcomp_reqfeed_ctor,
+ tcomp_reqfeed_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_reqfeed_def_t = &tcomp_reqfeed_def_s;
diff --git a/tinySIGCOMP/src/tcomp_reqfeed.h b/tinySIGCOMP/src/tcomp_reqfeed.h
index a3f9089..6821f85 100755
--- a/tinySIGCOMP/src/tcomp_reqfeed.h
+++ b/tinySIGCOMP/src/tcomp_reqfeed.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -49,18 +49,17 @@ TCOMP_BEGIN_DECLS
/** SigComp Requested feedback item as per RFC 3320 subclause 9.4.9.
*/
-typedef struct tcomp_reqfeed_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_reqfeed_s {
+ TSK_DECLARE_OBJECT;
- unsigned Q:1; /**< The Q-bit indicates whether a requested feedback item is present or not.*/
- unsigned S:1; /**< The compressor sets the S-bit to 1 if it does not wish (or no longer
+ unsigned Q:1; /**< The Q-bit indicates whether a requested feedback item is present or not.*/
+ unsigned S:1; /**< The compressor sets the S-bit to 1 if it does not wish (or no longer
wishes) to save state information at the receiving endpoint and also
does not wish to access state information that it has previously saved.*/
- unsigned I:1; /**< Similarly the compressor sets the I-bit to 1 if it does not wish (or
+ unsigned I:1; /**< Similarly the compressor sets the I-bit to 1 if it does not wish (or
no longer wishes) to access any of the locally available state items
offered by the receiving endpoint.*/
- tcomp_buffer_handle_t *item; /**< The requested item feedback data */
+ tcomp_buffer_handle_t *item; /**< The requested item feedback data */
}
tcomp_reqfeed_t;
diff --git a/tinySIGCOMP/src/tcomp_result.c b/tinySIGCOMP/src/tcomp_result.c
index 457ba65..111a9dc 100755
--- a/tinySIGCOMP/src/tcomp_result.c
+++ b/tinySIGCOMP/src/tcomp_result.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -35,141 +35,141 @@
*/
tcomp_result_t* tcomp_result_create()
{
- return tsk_object_new(tcomp_result_def_t);
+ return tsk_object_new(tcomp_result_def_t);
}
tcomp_tempstate_to_free_t* tcomp_tempstate_to_free_create()
{
- return tsk_object_new(tcomp_tempstate_to_free_def_t);
+ return tsk_object_new(tcomp_tempstate_to_free_def_t);
}
/**Resets the result.
*/
void _tcomp_result_reset(tcomp_result_t *result, tsk_bool_t isDestructor, tsk_bool_t isResetOutput)
{
- if(result){
- uint8_t i;
- for(i = 0; i < result->statesToCreateIndex; i++){
- TSK_OBJECT_SAFE_FREE(result->statesToCreate[i]);
- }
-
- for(i = 0; i < result->statesToFreeIndex; i++){
- TSK_OBJECT_SAFE_FREE(result->statesToFree[i]);
- }
-
- if(!isDestructor){
- result->statesToCreateIndex = 0;
- result->statesToFreeIndex = 0;
- result->consumed_cycles = 0;
-
- tcomp_params_reset(result->remote_parameters);
-
- if(isResetOutput){
- tcomp_buffer_reset(result->output_buffer);
- }
-
- tcomp_reqfeed_reset(result->req_feedback);
- tcomp_buffer_freeBuff(result->ret_feedback);
-
- result->isNack = 0;
- tcomp_buffer_freeBuff(result->nack_info);
- }
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
+ if(result) {
+ uint8_t i;
+ for(i = 0; i < result->statesToCreateIndex; i++) {
+ TSK_OBJECT_SAFE_FREE(result->statesToCreate[i]);
+ }
+
+ for(i = 0; i < result->statesToFreeIndex; i++) {
+ TSK_OBJECT_SAFE_FREE(result->statesToFree[i]);
+ }
+
+ if(!isDestructor) {
+ result->statesToCreateIndex = 0;
+ result->statesToFreeIndex = 0;
+ result->consumed_cycles = 0;
+
+ tcomp_params_reset(result->remote_parameters);
+
+ if(isResetOutput) {
+ tcomp_buffer_reset(result->output_buffer);
+ }
+
+ tcomp_reqfeed_reset(result->req_feedback);
+ tcomp_buffer_freeBuff(result->ret_feedback);
+
+ result->isNack = 0;
+ tcomp_buffer_freeBuff(result->nack_info);
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
}
/**Sets the output buffer.
*/
void tcomp_result_setOutputBuffer(tcomp_result_t *result, void *output_ptr, tsk_size_t output_size, tsk_bool_t isStream, uint64_t streamId)
{
- if(result){
- tcomp_buffer_referenceBuff(result->output_buffer, (uint8_t*)output_ptr, output_size);
- result->isStreamBased = isStream;
- result->streamId = streamId;
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
+ if(result) {
+ tcomp_buffer_referenceBuff(result->output_buffer, (uint8_t*)output_ptr, output_size);
+ result->isStreamBased = isStream;
+ result->streamId = streamId;
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
}
/**Sets the compartment identifier.
*/
void tcomp_result_setCompartmentId(tcomp_result_t *result, const void *id, tsk_size_t len)
{
- if(result){
- result->compartmentId = tcomp_buffer_createHash(id, len);
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
+ if(result) {
+ result->compartmentId = tcomp_buffer_createHash(id, len);
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
}
/**Adds temporary state.
*/
void tcomp_result_addTempStateToCreate(tcomp_result_t *result, tcomp_state_t* lpState)
{
- if(result){
- /*
- * Note that there is a maximum limit of four state creation requests per instance of the UDVM.
- */
- if(result->statesToCreateIndex >= MAX_TEMP_SATES) {
- TSK_DEBUG_ERROR("Maximum limit for %d state creation requests reached", MAX_TEMP_SATES);
- return;
- }
-
- // Add state
- result->statesToCreate[result->statesToCreateIndex++] = lpState;
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
+ if(result) {
+ /*
+ * Note that there is a maximum limit of four state creation requests per instance of the UDVM.
+ */
+ if(result->statesToCreateIndex >= MAX_TEMP_SATES) {
+ TSK_DEBUG_ERROR("Maximum limit for %d state creation requests reached", MAX_TEMP_SATES);
+ return;
+ }
+
+ // Add state
+ result->statesToCreate[result->statesToCreateIndex++] = lpState;
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
}
/**Gets the number of temporary state (to be created).
*/
uint8_t tcomp_result_getTempStatesToCreateSize(const tcomp_result_t *result)
{
- if(result){
- return result->statesToCreateIndex;
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
- return 0;
+ if(result) {
+ return result->statesToCreateIndex;
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
+ return 0;
}
/**Adds temporary state (to be freed).
*/
void tcomp_result_addTempStateToFree(tcomp_result_t *result, tcomp_tempstate_to_free_t* lpDesc)
{
- if(result){
- /*
- * Decompression failure MUST occur if more than four state free
- * requests are made before the END-MESSAGE instruction is encountered.
- */
- if(result->statesToFreeIndex >= MAX_TEMP_SATES) {
- return;
- }
- result->statesToFree[result->statesToFreeIndex++] = lpDesc;
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
+ if(result) {
+ /*
+ * Decompression failure MUST occur if more than four state free
+ * requests are made before the END-MESSAGE instruction is encountered.
+ */
+ if(result->statesToFreeIndex >= MAX_TEMP_SATES) {
+ return;
+ }
+ result->statesToFree[result->statesToFreeIndex++] = lpDesc;
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
}
/**Gets the number of temporary state (to be be freed).
*/
uint8_t tcomp_result_getTempStatesToFreeSize(const tcomp_result_t *result)
{
- if(result){
- return result->statesToFreeIndex;
- }
- else{
- TSK_DEBUG_ERROR("NULL SigComp result.");
- }
- return 0;
+ if(result) {
+ return result->statesToFreeIndex;
+ }
+ else {
+ TSK_DEBUG_ERROR("NULL SigComp result.");
+ }
+ return 0;
}
@@ -182,51 +182,50 @@ uint8_t tcomp_result_getTempStatesToFreeSize(const tcomp_result_t *result)
static tsk_object_t* tcomp_result_ctor(tsk_object_t *self, va_list * app)
{
- tcomp_result_t* result = self;
+ tcomp_result_t* result = self;
- if(result){
- result->output_buffer = tcomp_buffer_create_null();
- result->ret_feedback = tcomp_buffer_create_null();
- result->nack_info = tcomp_buffer_create_null();
+ if(result) {
+ result->output_buffer = tcomp_buffer_create_null();
+ result->ret_feedback = tcomp_buffer_create_null();
+ result->nack_info = tcomp_buffer_create_null();
- result->remote_parameters = tcomp_params_create();
+ result->remote_parameters = tcomp_params_create();
- result->req_feedback = tcomp_reqfeed_create();
- }
- else{
- TSK_DEBUG_ERROR("Null result object");
- }
+ result->req_feedback = tcomp_reqfeed_create();
+ }
+ else {
+ TSK_DEBUG_ERROR("Null result object");
+ }
- return self;
+ return self;
}
static tsk_object_t* tcomp_result_dtor(tsk_object_t * self)
{
- tcomp_result_t* result = self;
+ tcomp_result_t* result = self;
- if(result){
- _tcomp_result_reset(result, tsk_true, tsk_true);
- TSK_OBJECT_SAFE_FREE(result->output_buffer);
- TSK_OBJECT_SAFE_FREE(result->ret_feedback);
- TSK_OBJECT_SAFE_FREE(result->nack_info);
+ if(result) {
+ _tcomp_result_reset(result, tsk_true, tsk_true);
+ TSK_OBJECT_SAFE_FREE(result->output_buffer);
+ TSK_OBJECT_SAFE_FREE(result->ret_feedback);
+ TSK_OBJECT_SAFE_FREE(result->nack_info);
- TSK_OBJECT_SAFE_FREE(result->remote_parameters);
+ TSK_OBJECT_SAFE_FREE(result->remote_parameters);
- TSK_OBJECT_SAFE_FREE(result->req_feedback);
- }
- else{
- TSK_DEBUG_ERROR("Null result object");
- }
+ TSK_OBJECT_SAFE_FREE(result->req_feedback);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null result object");
+ }
- return self;
+ return self;
}
-static const tsk_object_def_t tcomp_result_def_s =
-{
- sizeof(tcomp_result_t),
- tcomp_result_ctor,
- tcomp_result_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_result_def_s = {
+ sizeof(tcomp_result_t),
+ tcomp_result_ctor,
+ tcomp_result_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_result_def_t = &tcomp_result_def_s;
@@ -237,37 +236,36 @@ const tsk_object_def_t *tcomp_result_def_t = &tcomp_result_def_s;
static tsk_object_t* tcomp_tempstate_to_free_ctor(tsk_object_t* self, va_list * app)
{
- tcomp_tempstate_to_free_t* tempstate_to_free = self;
+ tcomp_tempstate_to_free_t* tempstate_to_free = self;
- if(tempstate_to_free){
- tempstate_to_free->identifier = tcomp_buffer_create_null();
- }
- else{
- TSK_DEBUG_ERROR("Null object");
- }
+ if(tempstate_to_free) {
+ tempstate_to_free->identifier = tcomp_buffer_create_null();
+ }
+ else {
+ TSK_DEBUG_ERROR("Null object");
+ }
- return self;
+ return self;
}
static tsk_object_t* tcomp_tempstate_to_free_dtor(tsk_object_t* self)
{
- tcomp_tempstate_to_free_t* tempstate_to_free = self;
+ tcomp_tempstate_to_free_t* tempstate_to_free = self;
- if(tempstate_to_free){
- TSK_OBJECT_SAFE_FREE(tempstate_to_free->identifier);
- }
- else{
- TSK_DEBUG_ERROR("Null object");
- }
+ if(tempstate_to_free) {
+ TSK_OBJECT_SAFE_FREE(tempstate_to_free->identifier);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null object");
+ }
- return self;
+ return self;
}
-static const tsk_object_def_t tcomp_tempstate_to_free_def_s =
-{
- sizeof(tcomp_tempstate_to_free_t),
- tcomp_tempstate_to_free_ctor,
- tcomp_tempstate_to_free_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_tempstate_to_free_def_s = {
+ sizeof(tcomp_tempstate_to_free_t),
+ tcomp_tempstate_to_free_ctor,
+ tcomp_tempstate_to_free_dtor,
+ tsk_null
};
const tsk_object_def_t* tcomp_tempstate_to_free_def_t = &tcomp_tempstate_to_free_def_s;
diff --git a/tinySIGCOMP/src/tcomp_result.h b/tinySIGCOMP/src/tcomp_result.h
index 3a44249..6e3b770 100755
--- a/tinySIGCOMP/src/tcomp_result.h
+++ b/tinySIGCOMP/src/tcomp_result.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -43,15 +43,14 @@ TCOMP_BEGIN_DECLS
#define MAX_TEMP_SATES 4
-typedef struct tcomp_tempstate_to_free_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_tempstate_to_free_s {
+ TSK_DECLARE_OBJECT;
- // Operands
- uint32_t partial_identifier_start;
- uint32_t partial_identifier_length;
- // identifier
- tcomp_buffer_handle_t *identifier;
+ // Operands
+ uint32_t partial_identifier_start;
+ uint32_t partial_identifier_length;
+ // identifier
+ tcomp_buffer_handle_t *identifier;
}
tcomp_tempstate_to_free_t;
@@ -59,29 +58,28 @@ TINYSIGCOMP_GEXTERN const tsk_object_def_t *tcomp_tempstate_to_free_def_t;
/**SigComp decompression result.
*/
-typedef struct tcomp_result_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tcomp_result_s {
+ TSK_DECLARE_OBJECT;
- uint64_t compartmentId;
- tcomp_state_t* statesToCreate[MAX_TEMP_SATES];
- uint8_t statesToCreateIndex;
+ uint64_t compartmentId;
+ tcomp_state_t* statesToCreate[MAX_TEMP_SATES];
+ uint8_t statesToCreateIndex;
- tcomp_tempstate_to_free_t* statesToFree[MAX_TEMP_SATES];
- uint8_t statesToFreeIndex;
+ tcomp_tempstate_to_free_t* statesToFree[MAX_TEMP_SATES];
+ uint8_t statesToFreeIndex;
- uint64_t streamId;
- unsigned isStreamBased:1;
- tcomp_buffer_handle_t *output_buffer;
+ uint64_t streamId;
+ unsigned isStreamBased:1;
+ tcomp_buffer_handle_t *output_buffer;
- tcomp_reqfeed_t *req_feedback;
- tcomp_params_t *remote_parameters;
- tcomp_buffer_handle_t *ret_feedback;
+ tcomp_reqfeed_t *req_feedback;
+ tcomp_params_t *remote_parameters;
+ tcomp_buffer_handle_t *ret_feedback;
- unsigned isNack:1;
- tcomp_buffer_handle_t *nack_info;
+ unsigned isNack:1;
+ tcomp_buffer_handle_t *nack_info;
- uint64_t consumed_cycles;
+ uint64_t consumed_cycles;
}
tcomp_result_t;
diff --git a/tinySIGCOMP/src/tcomp_rfc3485_dictionary_sip.h b/tinySIGCOMP/src/tcomp_rfc3485_dictionary_sip.h
index e1fdbc1..427e2c3 100755
--- a/tinySIGCOMP/src/tcomp_rfc3485_dictionary_sip.h
+++ b/tinySIGCOMP/src/tcomp_rfc3485_dictionary_sip.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_rfc5049_sip.h b/tinySIGCOMP/src/tcomp_rfc5049_sip.h
index 581e837..8c930e4 100755
--- a/tinySIGCOMP/src/tcomp_rfc5049_sip.h
+++ b/tinySIGCOMP/src/tcomp_rfc5049_sip.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -49,6 +49,6 @@ Applying Signaling Compression (SigComp)
// 4.5. locally available state (LAS) for SIP/SigComp
// Minimum LAS for SIP/SigComp: the SIP/SDP static dictionary as defined
- //in [RFC3485].
+//in [RFC3485].
#endif /* _TINYSIGCOMPP_RFC5049_H_ */
diff --git a/tinySIGCOMP/src/tcomp_rfc5112_dictionary_presence.h b/tinySIGCOMP/src/tcomp_rfc5112_dictionary_presence.h
index b4ee068..71328c0 100755
--- a/tinySIGCOMP/src/tcomp_rfc5112_dictionary_presence.h
+++ b/tinySIGCOMP/src/tcomp_rfc5112_dictionary_presence.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_state.c b/tinySIGCOMP/src/tcomp_state.c
index af9be22..0ec49ce 100755
--- a/tinySIGCOMP/src/tcomp_state.c
+++ b/tinySIGCOMP/src/tcomp_state.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -36,21 +36,21 @@
*/
tcomp_state_t* tcomp_state_create(uint32_t length, uint32_t address, uint32_t instruction, uint32_t minimum_access_length, uint32_t retention_priority)
{
- tcomp_state_t *state;
- if((state = tsk_object_new(tcomp_state_def_t))){
- state->length = length;
- state->address = address;
- state->instruction = instruction;
- state->minimum_access_length = minimum_access_length;
- state->retention_priority = retention_priority;
-
- state->value = tcomp_buffer_create_null();
- state->identifier = tcomp_buffer_create_null();
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new state.");
- }
- return state;
+ tcomp_state_t *state;
+ if((state = tsk_object_new(tcomp_state_def_t))) {
+ state->length = length;
+ state->address = address;
+ state->instruction = instruction;
+ state->minimum_access_length = minimum_access_length;
+ state->retention_priority = retention_priority;
+
+ state->value = tcomp_buffer_create_null();
+ state->identifier = tcomp_buffer_create_null();
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new state.");
+ }
+ return state;
}
/** Compares two sigomp states.
@@ -60,12 +60,15 @@ tcomp_state_t* tcomp_state_create(uint32_t length, uint32_t address, uint32_t in
*/
int tcomp_state_equals(const tcomp_state_t *state1, const tcomp_state_t *state2)
{
- if(state1 && state2)
- {
- return tcomp_buffer_equals(state1->identifier, state2->identifier);
- }
- else if(!state1 && !state2) return 1;
- else return 0;
+ if(state1 && state2) {
+ return tcomp_buffer_equals(state1->identifier, state2->identifier);
+ }
+ else if(!state1 && !state2) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
/**Computes the state identifier by calculating a 20-byte SHA-1 hash [RFC-3174] over the
@@ -75,74 +78,73 @@ int tcomp_state_equals(const tcomp_state_t *state1, const tcomp_state_t *state2)
*/
void tcomp_state_makeValid(tcomp_state_t* state)
{
- tsk_sha1context_t sha;
-
- if(!state){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
-
- /* Lock */
- tsk_safeobj_lock(state);
-
- tcomp_buffer_allocBuff(state->identifier, TSK_SHA1_DIGEST_SIZE);
-
- /*=============
- * Calculates a 20-byte SHA-1 hash [RFC-3174] over the byte string formed by concatenating the state_length, state_address,
- * state_instruction, minimum_access_length and state_value (in the order given). This is the state_identifier.
- */
- {
- uint8_t i;
- int32_t err = tsk_sha1reset(&sha);
- uint8_t firstPart[8];
-
+ tsk_sha1context_t sha;
+
+ if(!state) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
+
+ /* Lock */
+ tsk_safeobj_lock(state);
+
+ tcomp_buffer_allocBuff(state->identifier, TSK_SHA1_DIGEST_SIZE);
+
+ /*=============
+ * Calculates a 20-byte SHA-1 hash [RFC-3174] over the byte string formed by concatenating the state_length, state_address,
+ * state_instruction, minimum_access_length and state_value (in the order given). This is the state_identifier.
+ */
+ {
+ uint8_t i;
+ int32_t err = tsk_sha1reset(&sha);
+ uint8_t firstPart[8];
+
#ifdef __SYMBIAN32__
- uint32_t values[4];
- values[0] = state->length,
- values[1] = state->address,
- values[2] = state->instruction,
- values[3] = state->minimum_access_length;
-
+ uint32_t values[4];
+ values[0] = state->length,
+ values[1] = state->address,
+ values[2] = state->instruction,
+ values[3] = state->minimum_access_length;
+
+#else
+ uint32_t values[4] = { state->length, state->address, state->instruction, state->minimum_access_length };
+#endif
+
+ for(i=0; i<4; i++) {
+#if 0 /*BIG_ENDIAN*/// Do not change this (it's for my own tests)
+ firstPart[i] = (values[i] & 0xff);
+ firstPart[i+1] = (values[i] >> 8);
#else
- uint32_t values[4] = { state->length, state->address, state->instruction, state->minimum_access_length };
+ firstPart[2*i] = (values[i] >> 8);
+ firstPart[2*i+1] = (values[i]& 0xff);
#endif
-
- for(i=0; i<4; i++)
- {
- #if 0 /*BIG_ENDIAN*/// Do not change this (it's for my own tests)
- firstPart[i] = (values[i] & 0xff);
- firstPart[i+1] = (values[i] >> 8);
- #else
- firstPart[2*i] = (values[i] >> 8);
- firstPart[2*i+1] = (values[i]& 0xff);
- #endif
- }
-
- tsk_sha1input(&sha, firstPart, 8);
- tsk_sha1input(&sha, tcomp_buffer_getBuffer(state->value), tcomp_buffer_getSize(state->value));
- err = tsk_sha1result(&sha, (uint8_t*)tcomp_buffer_getBuffer(state->identifier));
- }
-
- /* unlock */
- tsk_safeobj_unlock(state);
+ }
+
+ tsk_sha1input(&sha, firstPart, 8);
+ tsk_sha1input(&sha, tcomp_buffer_getBuffer(state->value), tcomp_buffer_getSize(state->value));
+ err = tsk_sha1result(&sha, (uint8_t*)tcomp_buffer_getBuffer(state->identifier));
+ }
+
+ /* unlock */
+ tsk_safeobj_unlock(state);
}
int32_t tcomp_state_inc_usage_count(tcomp_state_t* self)
{
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
- return ++self->usage_count;
+ if(!self) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+ return ++self->usage_count;
}
int32_t tcomp_state_dec_usage_count(tcomp_state_t* self)
{
- if(!self || self->usage_count <= 0){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
- return --self->usage_count;
+ if(!self || self->usage_count <= 0) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+ return --self->usage_count;
}
@@ -152,56 +154,59 @@ int32_t tcomp_state_dec_usage_count(tcomp_state_t* self)
//
static tsk_object_t* tcomp_state_ctor(tsk_object_t * self, va_list * app)
{
- tcomp_state_t *state = self;
- if(state){
- /* Initialize safeobject */
- tsk_safeobj_init(state);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new state.");
- }
- return state;
+ tcomp_state_t *state = self;
+ if(state) {
+ /* Initialize safeobject */
+ tsk_safeobj_init(state);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new state.");
+ }
+ return state;
}
static tsk_object_t* tcomp_state_dtor(tsk_object_t *self)
{
- tcomp_state_t *state = self;
- if(state){
- TSK_DEBUG_INFO("==SigComp - Free state with id=");
- tcomp_buffer_print(state->identifier);
-
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(state);
-
- TSK_OBJECT_SAFE_FREE(state->identifier);
- TSK_OBJECT_SAFE_FREE(state->value);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp state.");
- }
-
- return self;
+ tcomp_state_t *state = self;
+ if(state) {
+ TSK_DEBUG_INFO("==SigComp - Free state with id=");
+ tcomp_buffer_print(state->identifier);
+
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(state);
+
+ TSK_OBJECT_SAFE_FREE(state->identifier);
+ TSK_OBJECT_SAFE_FREE(state->value);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp state.");
+ }
+
+ return self;
}
static int tcomp_state_cmp(const void *obj1, const void *obj2)
{
- const tcomp_state_t *state1 = obj1;
- const tcomp_state_t *state2 = obj2;
-
- if(state1 && state2){
- return tcomp_buffer_equals(state1->identifier, state2->identifier) ? 0 : -1;
- }
- else if(!state1 && !state2) return 0;
- else return -1;
+ const tcomp_state_t *state1 = obj1;
+ const tcomp_state_t *state2 = obj2;
+
+ if(state1 && state2) {
+ return tcomp_buffer_equals(state1->identifier, state2->identifier) ? 0 : -1;
+ }
+ else if(!state1 && !state2) {
+ return 0;
+ }
+ else {
+ return -1;
+ }
}
-static const tsk_object_def_t tcomp_state_def_s =
-{
- sizeof(tcomp_state_t),
- tcomp_state_ctor,
- tcomp_state_dtor,
- tcomp_state_cmp
+static const tsk_object_def_t tcomp_state_def_s = {
+ sizeof(tcomp_state_t),
+ tcomp_state_ctor,
+ tcomp_state_dtor,
+ tcomp_state_cmp
};
const tsk_object_def_t *tcomp_state_def_t = &tcomp_state_def_s;
diff --git a/tinySIGCOMP/src/tcomp_state.h b/tinySIGCOMP/src/tcomp_state.h
index 1e7ef70..342e38b 100755
--- a/tinySIGCOMP/src/tcomp_state.h
+++ b/tinySIGCOMP/src/tcomp_state.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -47,22 +47,21 @@ TCOMP_BEGIN_DECLS
/**SigComp state.
*/
-typedef struct tcomp_state_s
-{
- TSK_DECLARE_OBJECT;
-
- tcomp_buffer_handle_t *value; /**< State's value. */
- tcomp_buffer_handle_t *identifier; /**< State's identifier. */
-
- uint32_t length; /**< State's length. */
- uint32_t address; /**< State's address. */
- uint32_t instruction; /**< State's instruction. */
- uint32_t minimum_access_length; /**< State's minimum access length. */
- uint32_t retention_priority; /**< State's retention priority. */
-
- int32_t usage_count; /**< State's usage count (to avoid duplication). */
-
- TSK_DECLARE_SAFEOBJ;
+typedef struct tcomp_state_s {
+ TSK_DECLARE_OBJECT;
+
+ tcomp_buffer_handle_t *value; /**< State's value. */
+ tcomp_buffer_handle_t *identifier; /**< State's identifier. */
+
+ uint32_t length; /**< State's length. */
+ uint32_t address; /**< State's address. */
+ uint32_t instruction; /**< State's instruction. */
+ uint32_t minimum_access_length; /**< State's minimum access length. */
+ uint32_t retention_priority; /**< State's retention priority. */
+
+ int32_t usage_count; /**< State's usage count (to avoid duplication). */
+
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_state_t;
diff --git a/tinySIGCOMP/src/tcomp_statehandler.c b/tinySIGCOMP/src/tcomp_statehandler.c
index 596fdf9..51dbd9a 100755
--- a/tinySIGCOMP/src/tcomp_statehandler.c
+++ b/tinySIGCOMP/src/tcomp_statehandler.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -23,7 +23,7 @@
/**@file tcomp_statehandler.c
* @brief SigComp state handler.
* Entity responsible for accessing and storing state information once permission is granted by the application.
- *
+ *
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
@@ -38,381 +38,375 @@
static int pred_find_compartment_by_id(const tsk_list_item_t *item, const void *id)
{
- if(item && item->data){
- tcomp_compartment_t *compartment = item->data;
- int64_t res = (compartment->identifier - *((int64_t*)id));
- return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
- }
- return -1;
+ if(item && item->data) {
+ tcomp_compartment_t *compartment = item->data;
+ int64_t res = (compartment->identifier - *((int64_t*)id));
+ return res > 0 ? (int)1 : (res < 0 ? (int)-1 : (int)0);
+ }
+ return -1;
}
/**Creates new SigComp state handler.
*/
tcomp_statehandler_t* tcomp_statehandler_create()
{
- tcomp_statehandler_t* statehandler;
- if((statehandler = tsk_object_new(tcomp_statehandler_def_t))){
- /* RFC 3320 - 3.3. SigComp Parameters */
- statehandler->sigcomp_parameters = tcomp_params_create();
- tcomp_params_setDmsValue(statehandler->sigcomp_parameters, SIP_RFC5049_DECOMPRESSION_MEMORY_SIZE);
- tcomp_params_setSmsValue(statehandler->sigcomp_parameters, SIP_RFC5049_STATE_MEMORY_SIZE);
- tcomp_params_setCpbValue(statehandler->sigcomp_parameters, SIP_RFC5049_CYCLES_PER_BIT);
-
- if(!(statehandler->dictionaries = tsk_list_create())){
- TSK_OBJECT_SAFE_FREE(statehandler);
- goto bail;
- }
- if(!(statehandler->compartments = tsk_list_create())){
- TSK_OBJECT_SAFE_FREE(statehandler);
- goto bail;
- }
- statehandler->sigcomp_parameters->SigComp_version = SIP_RFC5049_SIGCOMP_VERSION;
+ tcomp_statehandler_t* statehandler;
+ if((statehandler = tsk_object_new(tcomp_statehandler_def_t))) {
+ /* RFC 3320 - 3.3. SigComp Parameters */
+ statehandler->sigcomp_parameters = tcomp_params_create();
+ tcomp_params_setDmsValue(statehandler->sigcomp_parameters, SIP_RFC5049_DECOMPRESSION_MEMORY_SIZE);
+ tcomp_params_setSmsValue(statehandler->sigcomp_parameters, SIP_RFC5049_STATE_MEMORY_SIZE);
+ tcomp_params_setCpbValue(statehandler->sigcomp_parameters, SIP_RFC5049_CYCLES_PER_BIT);
+
+ if(!(statehandler->dictionaries = tsk_list_create())) {
+ TSK_OBJECT_SAFE_FREE(statehandler);
+ goto bail;
+ }
+ if(!(statehandler->compartments = tsk_list_create())) {
+ TSK_OBJECT_SAFE_FREE(statehandler);
+ goto bail;
+ }
+ statehandler->sigcomp_parameters->SigComp_version = SIP_RFC5049_SIGCOMP_VERSION;
#if TCOMP_USE_ONLY_ACKED_STATES
- statehandler->useOnlyACKedStates = tsk_true;
+ statehandler->useOnlyACKedStates = tsk_true;
#endif
- }
+ }
bail:
- return statehandler;
+ return statehandler;
}
int tcomp_statehandler_setUseOnlyACKedStates(tcomp_statehandler_t* self, tsk_bool_t useOnlyACKedStates)
{
- tsk_list_item_t* item;
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
- self->useOnlyACKedStates = useOnlyACKedStates;
-
- tsk_safeobj_lock(self);
- tsk_list_foreach(item, self->compartments){
- tcomp_compartment_setUseOnlyACKedStates((tcomp_compartment_t*)item->data, self->useOnlyACKedStates);
- }
- tsk_safeobj_unlock(self);
-
- return 0;
+ tsk_list_item_t* item;
+ if(!self) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+ self->useOnlyACKedStates = useOnlyACKedStates;
+
+ tsk_safeobj_lock(self);
+ tsk_list_foreach(item, self->compartments) {
+ tcomp_compartment_setUseOnlyACKedStates((tcomp_compartment_t*)item->data, self->useOnlyACKedStates);
+ }
+ tsk_safeobj_unlock(self);
+
+ return 0;
}
tcomp_compartment_t *tcomp_statehandler_getCompartment(const tcomp_statehandler_t *statehandler, uint64_t id)
{
- tcomp_compartment_t *result = tsk_null;
- tcomp_compartment_t* newcomp = tsk_null;
- const tsk_list_item_t *item_const;
+ tcomp_compartment_t *result = tsk_null;
+ tcomp_compartment_t* newcomp = tsk_null;
+ const tsk_list_item_t *item_const;
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
- tsk_safeobj_lock(statehandler);
+ tsk_safeobj_lock(statehandler);
- item_const = tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id);
- if(!item_const || !(result = item_const->data)){
- newcomp = tcomp_compartment_create(id, tcomp_params_getParameters(statehandler->sigcomp_parameters), statehandler->useOnlyACKedStates);
- result = newcomp;
- tsk_list_push_back_data(statehandler->compartments, ((void**) &newcomp));
- }
+ item_const = tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id);
+ if(!item_const || !(result = item_const->data)) {
+ newcomp = tcomp_compartment_create(id, tcomp_params_getParameters(statehandler->sigcomp_parameters), statehandler->useOnlyACKedStates);
+ result = newcomp;
+ tsk_list_push_back_data(statehandler->compartments, ((void**) &newcomp));
+ }
- tsk_safeobj_unlock(statehandler);
+ tsk_safeobj_unlock(statehandler);
- return result;
+ return result;
}
void tcomp_statehandler_deleteCompartment(tcomp_statehandler_t *statehandler, uint64_t id)
{
- tcomp_compartment_t *compartment;
- const tsk_list_item_t *item_const;
+ tcomp_compartment_t *compartment;
+ const tsk_list_item_t *item_const;
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
- tsk_safeobj_lock(statehandler);
+ tsk_safeobj_lock(statehandler);
- item_const = tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id);
- if(item_const && (compartment = item_const->data)){
- TSK_DEBUG_INFO("SigComp - Delete compartment %lld", id);
- tsk_list_remove_item_by_data(statehandler->compartments, compartment);
- }
+ item_const = tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id);
+ if(item_const && (compartment = item_const->data)) {
+ TSK_DEBUG_INFO("SigComp - Delete compartment %lld", id);
+ tsk_list_remove_item_by_data(statehandler->compartments, compartment);
+ }
- tsk_safeobj_unlock(statehandler);
+ tsk_safeobj_unlock(statehandler);
}
tsk_bool_t tcomp_statehandler_compartmentExist(tcomp_statehandler_t *statehandler, uint64_t id)
{
- tsk_bool_t exist;
+ tsk_bool_t exist;
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_false;
- }
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return tsk_false;
+ }
- tsk_safeobj_lock(statehandler);
- exist = (tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id) ? 1 : 0);
- tsk_safeobj_unlock(statehandler);
+ tsk_safeobj_lock(statehandler);
+ exist = (tsk_list_find_item_by_pred(statehandler->compartments, pred_find_compartment_by_id, &id) ? 1 : 0);
+ tsk_safeobj_unlock(statehandler);
- return exist;
+ return exist;
}
uint32_t tcomp_statehandler_findState(tcomp_statehandler_t *statehandler, const tcomp_buffer_handle_t *partial_identifier, tcomp_state_t** lpState)
{
- uint32_t count = 0;
- tsk_list_item_t *item;
-
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return 0;
- }
-
- tsk_safeobj_lock(statehandler);
-
- //
- // Compartments
- //
- tsk_list_foreach(item, statehandler->compartments){
- tcomp_compartment_t *compartment = item->data;
- count += tcomp_compartment_findState(compartment, partial_identifier, lpState);
- }
-
- if(count){
- goto bail;
- }
-
- //
- // Dictionaries
- //
- tsk_list_foreach(item, statehandler->dictionaries){
- tcomp_dictionary_t *dictionary = item->data;
- if(tcomp_buffer_startsWith(dictionary->identifier, partial_identifier)){
- *lpState = dictionary;
- count++;
- }
- }
+ uint32_t count = 0;
+ tsk_list_item_t *item;
+
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return 0;
+ }
+
+ tsk_safeobj_lock(statehandler);
+
+ //
+ // Compartments
+ //
+ tsk_list_foreach(item, statehandler->compartments) {
+ tcomp_compartment_t *compartment = item->data;
+ count += tcomp_compartment_findState(compartment, partial_identifier, lpState);
+ }
+
+ if(count) {
+ goto bail;
+ }
+
+ //
+ // Dictionaries
+ //
+ tsk_list_foreach(item, statehandler->dictionaries) {
+ tcomp_dictionary_t *dictionary = item->data;
+ if(tcomp_buffer_startsWith(dictionary->identifier, partial_identifier)) {
+ *lpState = dictionary;
+ count++;
+ }
+ }
bail:
- tsk_safeobj_unlock(statehandler);
+ tsk_safeobj_unlock(statehandler);
- return count;
+ return count;
}
void tcomp_statehandler_handleResult(tcomp_statehandler_t *statehandler, tcomp_result_t **lpResult)
{
- tcomp_compartment_t *lpCompartment;
- uint32_t compartment_total_size;
- uint8_t i;
-
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return;
- }
-
- /*== Do not lock --> all functions are thread-safe. */
- //tsk_safeobj_lock(statehandler);
-
- /*
- * The compressor does not wish (or no longer wishes) to save state information?
- */
- if((*lpResult)->ret_feedback && (*lpResult)->req_feedback->S){
- if(tcomp_statehandler_compartmentExist(statehandler, (*lpResult)->compartmentId)){
- tcomp_statehandler_deleteCompartment(statehandler, (*lpResult)->compartmentId);
- }
- return;
- }
-
- /*
- * Find corresponding compartment (only if !S)
- */
- if((lpCompartment = tcomp_statehandler_getCompartment(statehandler, (*lpResult)->compartmentId))){
- compartment_total_size = lpCompartment->total_memory_size;
- }
- else{
- goto bail;
- }
+ tcomp_compartment_t *lpCompartment;
+ uint32_t compartment_total_size;
+ uint8_t i;
+
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return;
+ }
+
+ /*== Do not lock --> all functions are thread-safe. */
+ //tsk_safeobj_lock(statehandler);
+
+ /*
+ * The compressor does not wish (or no longer wishes) to save state information?
+ */
+ if((*lpResult)->ret_feedback && (*lpResult)->req_feedback->S) {
+ if(tcomp_statehandler_compartmentExist(statehandler, (*lpResult)->compartmentId)) {
+ tcomp_statehandler_deleteCompartment(statehandler, (*lpResult)->compartmentId);
+ }
+ return;
+ }
+
+ /*
+ * Find corresponding compartment (only if !S)
+ */
+ if((lpCompartment = tcomp_statehandler_getCompartment(statehandler, (*lpResult)->compartmentId))) {
+ compartment_total_size = lpCompartment->total_memory_size;
+ }
+ else {
+ goto bail;
+ }
//compartment_create_states:
- /*
- * Request state creation now we have the corresponding compartement.
- */
- if(tcomp_result_getTempStatesToCreateSize(*lpResult)){
- uint8_t count;
- /* Check compartment allocated size*/
- if(!compartment_total_size){
- goto compartment_free_states;
- }
-
- count = tcomp_result_getTempStatesToCreateSize(*lpResult);
-
- // FIXME: lock
- for (i = 0; i < count; i++)
- {
- tcomp_state_t **lpState = &((*lpResult)->statesToCreate[i]);
- if(!lpState || !*lpState){
- continue;
- }
-
- /*
- * If the state creation request needs more state memory than the
- * total state_memory_size for the compartment, the state handler
- * deletes all but the first (state_memory_size - 64) bytes from the state_value.
- */
- if(TCOMP_GET_STATE_SIZE(*lpState) > compartment_total_size){
- tsk_size_t oldSize, newSize;
- tcomp_compartment_clearStates(lpCompartment);
- oldSize = tcomp_buffer_getSize((*lpState)->value);
- newSize = (compartment_total_size - 64);
- tcomp_buffer_removeBuff((*lpState)->value, newSize, (oldSize-newSize));
- (*lpState)->length = newSize;
-
- tcomp_compartment_addState(lpCompartment, lpState);
- }
-
- /*
- * If the state creation request exceeds the state memory allocated
- * to the compartment, sufficient items of state created by the same
- * compartment are freed until enough memory is available to
- * accommodate the new state.
- */
- else{
- while(lpCompartment->total_memory_left < TCOMP_GET_STATE_SIZE(*lpState)){
- tcomp_compartment_freeStateByPriority(lpCompartment);
- }
- tcomp_compartment_addState(lpCompartment, lpState);
- }
- }
- }
+ /*
+ * Request state creation now we have the corresponding compartement.
+ */
+ if(tcomp_result_getTempStatesToCreateSize(*lpResult)) {
+ uint8_t count;
+ /* Check compartment allocated size*/
+ if(!compartment_total_size) {
+ goto compartment_free_states;
+ }
+
+ count = tcomp_result_getTempStatesToCreateSize(*lpResult);
+
+ // FIXME: lock
+ for (i = 0; i < count; i++) {
+ tcomp_state_t **lpState = &((*lpResult)->statesToCreate[i]);
+ if(!lpState || !*lpState) {
+ continue;
+ }
+
+ /*
+ * If the state creation request needs more state memory than the
+ * total state_memory_size for the compartment, the state handler
+ * deletes all but the first (state_memory_size - 64) bytes from the state_value.
+ */
+ if(TCOMP_GET_STATE_SIZE(*lpState) > compartment_total_size) {
+ tsk_size_t oldSize, newSize;
+ tcomp_compartment_clearStates(lpCompartment);
+ oldSize = tcomp_buffer_getSize((*lpState)->value);
+ newSize = (compartment_total_size - 64);
+ tcomp_buffer_removeBuff((*lpState)->value, newSize, (oldSize-newSize));
+ (*lpState)->length = newSize;
+
+ tcomp_compartment_addState(lpCompartment, lpState);
+ }
+
+ /*
+ * If the state creation request exceeds the state memory allocated
+ * to the compartment, sufficient items of state created by the same
+ * compartment are freed until enough memory is available to
+ * accommodate the new state.
+ */
+ else {
+ while(lpCompartment->total_memory_left < TCOMP_GET_STATE_SIZE(*lpState)) {
+ tcomp_compartment_freeStateByPriority(lpCompartment);
+ }
+ tcomp_compartment_addState(lpCompartment, lpState);
+ }
+ }
+ }
compartment_free_states:
- /*
- * Request state free now we have the correponding comprtement
- */
- if(tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)*lpResult)){
- tcomp_compartment_freeStates(lpCompartment, (*lpResult)->statesToFree, tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)*lpResult));
- }
+ /*
+ * Request state free now we have the correponding comprtement
+ */
+ if(tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)*lpResult)) {
+ tcomp_compartment_freeStates(lpCompartment, (*lpResult)->statesToFree, tcomp_result_getTempStatesToFreeSize((const tcomp_result_t*)*lpResult));
+ }
//compartment_remote_params:
- /*
- * Set remote -compressor- parameters.
- */
- tcomp_compartment_setRemoteParams(lpCompartment, (*lpResult)->remote_parameters);
+ /*
+ * Set remote -compressor- parameters.
+ */
+ tcomp_compartment_setRemoteParams(lpCompartment, (*lpResult)->remote_parameters);
//feedbacks:
- /*
- * Set both Returned and Requested feedbacks.
- */
-
- if(tcomp_buffer_getSize((*lpResult)->req_feedback->item)){
- tcomp_compartment_setReqFeedback(lpCompartment, (*lpResult)->req_feedback->item);
- }
- if(tcomp_buffer_getSize((*lpResult)->ret_feedback)){
- tcomp_compartment_setRetFeedback(lpCompartment, (*lpResult)->ret_feedback);
- }
-
-bail: ;
- //--tsk_safeobj_unlock(lpCompartment);
- //--tsk_safeobj_unlock(statehandler);
+ /*
+ * Set both Returned and Requested feedbacks.
+ */
+
+ if(tcomp_buffer_getSize((*lpResult)->req_feedback->item)) {
+ tcomp_compartment_setReqFeedback(lpCompartment, (*lpResult)->req_feedback->item);
+ }
+ if(tcomp_buffer_getSize((*lpResult)->ret_feedback)) {
+ tcomp_compartment_setRetFeedback(lpCompartment, (*lpResult)->ret_feedback);
+ }
+
+bail:
+ ;
+ //--tsk_safeobj_unlock(lpCompartment);
+ //--tsk_safeobj_unlock(statehandler);
}
tsk_bool_t tcomp_statehandler_handleNack(tcomp_statehandler_t *statehandler, const tcomp_nackinfo_t * nackinfo)
{
- tcomp_buffer_handle_t* sha_id;
- tsk_list_item_t *item;
- tsk_bool_t found = tsk_false;
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_false;
- }
-
- if(!(sha_id = tcomp_buffer_create_null())){
- TSK_DEBUG_ERROR("Failed to create buffer handle");
- return tsk_false;
- }
-
- tcomp_buffer_referenceBuff(sha_id, ((tcomp_nackinfo_t*)nackinfo)->sha1, TSK_SHA1_DIGEST_SIZE);
-
- tsk_list_foreach(item, statehandler->compartments)
- {
- tcomp_compartment_t* lpCompartement = item->data;
- if(tcomp_compartment_hasNack(lpCompartement, sha_id))
- {
- // this compartment is responsible for this nack
- switch(nackinfo->reasonCode)
- {
- case NACK_STATE_NOT_FOUND:
- {
- // Next commented because in this version remote state ids are never saved.
- // Only the ghost has information on last partial state id to use --> reset the ghost
- //SigCompState* lpState = NULL;
- //lpCompartement->findState(&nack_info->details, &lpState);
- //if(lpState)
- //{
- // lpCompartement->freeState(lpState);
- //}
- tcomp_compartment_freeGhostState(lpCompartement);
- }
- break;
-
- default:
- {
- tcomp_compartment_freeGhostState(lpCompartement);
- tcomp_compartment_clearStates(lpCompartement);
- }
- break;
- }
- TSK_DEBUG_INFO("Compartment has NACK :)");
- tcomp_buffer_print(sha_id);
- found = tsk_true;
- }
- }
-
- if(!found)
- {
- TSK_DEBUG_ERROR("Compartments do not have NACK with id=");
- tcomp_buffer_print(sha_id);
- }
-
- TSK_OBJECT_SAFE_FREE(sha_id);
-
- return found;
+ tcomp_buffer_handle_t* sha_id;
+ tsk_list_item_t *item;
+ tsk_bool_t found = tsk_false;
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return tsk_false;
+ }
+
+ if(!(sha_id = tcomp_buffer_create_null())) {
+ TSK_DEBUG_ERROR("Failed to create buffer handle");
+ return tsk_false;
+ }
+
+ tcomp_buffer_referenceBuff(sha_id, ((tcomp_nackinfo_t*)nackinfo)->sha1, TSK_SHA1_DIGEST_SIZE);
+
+ tsk_list_foreach(item, statehandler->compartments) {
+ tcomp_compartment_t* lpCompartement = item->data;
+ if(tcomp_compartment_hasNack(lpCompartement, sha_id)) {
+ // this compartment is responsible for this nack
+ switch(nackinfo->reasonCode) {
+ case NACK_STATE_NOT_FOUND: {
+ // Next commented because in this version remote state ids are never saved.
+ // Only the ghost has information on last partial state id to use --> reset the ghost
+ //SigCompState* lpState = NULL;
+ //lpCompartement->findState(&nack_info->details, &lpState);
+ //if(lpState)
+ //{
+ // lpCompartement->freeState(lpState);
+ //}
+ tcomp_compartment_freeGhostState(lpCompartement);
+ }
+ break;
+
+ default: {
+ tcomp_compartment_freeGhostState(lpCompartement);
+ tcomp_compartment_clearStates(lpCompartement);
+ }
+ break;
+ }
+ TSK_DEBUG_INFO("Compartment has NACK :)");
+ tcomp_buffer_print(sha_id);
+ found = tsk_true;
+ }
+ }
+
+ if(!found) {
+ TSK_DEBUG_ERROR("Compartments do not have NACK with id=");
+ tcomp_buffer_print(sha_id);
+ }
+
+ TSK_OBJECT_SAFE_FREE(sha_id);
+
+ return found;
}
int tcomp_statehandler_addSipSdpDictionary(tcomp_statehandler_t *statehandler)
{
- if(!statehandler){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- tsk_safeobj_lock(statehandler);
-
- if(!statehandler->hasSipSdpDictionary){
- tcomp_dictionary_t* sip_dict = tcomp_dicts_create_sip_dict();
- tsk_list_push_back_data(statehandler->dictionaries, ((void**) &sip_dict));
- statehandler->hasSipSdpDictionary = 1;
- }
-
- tsk_safeobj_unlock(statehandler);
- return 0;
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ tsk_safeobj_lock(statehandler);
+
+ if(!statehandler->hasSipSdpDictionary) {
+ tcomp_dictionary_t* sip_dict = tcomp_dicts_create_sip_dict();
+ tsk_list_push_back_data(statehandler->dictionaries, ((void**) &sip_dict));
+ statehandler->hasSipSdpDictionary = 1;
+ }
+
+ tsk_safeobj_unlock(statehandler);
+ return 0;
}
int tcomp_statehandler_addPresenceDictionary(tcomp_statehandler_t *statehandler)
{
- if(!statehandler){
- TSK_DEBUG_ERROR("NULL SigComp state handler.");
- return -1;
- }
+ if(!statehandler) {
+ TSK_DEBUG_ERROR("NULL SigComp state handler.");
+ return -1;
+ }
- tsk_safeobj_lock(statehandler);
+ tsk_safeobj_lock(statehandler);
- if(!statehandler->hasPresenceDictionary){
- tcomp_dictionary_t* pres_dict = tcomp_dicts_create_presence_dict();
- tsk_list_push_back_data(statehandler->dictionaries, ((void**) &pres_dict));
- statehandler->hasPresenceDictionary = 1;
- }
+ if(!statehandler->hasPresenceDictionary) {
+ tcomp_dictionary_t* pres_dict = tcomp_dicts_create_presence_dict();
+ tsk_list_push_back_data(statehandler->dictionaries, ((void**) &pres_dict));
+ statehandler->hasPresenceDictionary = 1;
+ }
- tsk_safeobj_unlock(statehandler);
- return 0;
+ tsk_safeobj_unlock(statehandler);
+ return 0;
}
@@ -427,42 +421,41 @@ int tcomp_statehandler_addPresenceDictionary(tcomp_statehandler_t *statehandler)
static tsk_object_t* tcomp_statehandler_ctor(tsk_object_t * self, va_list * app)
{
- tcomp_statehandler_t *statehandler = self;
- if(statehandler){
- /* Initialize safeobject */
- tsk_safeobj_init(statehandler);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp state handler.");
- }
-
- return self;
+ tcomp_statehandler_t *statehandler = self;
+ if(statehandler) {
+ /* Initialize safeobject */
+ tsk_safeobj_init(statehandler);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp state handler.");
+ }
+
+ return self;
}
static void* tcomp_statehandler_dtor(tsk_object_t *self)
{
- tcomp_statehandler_t *statehandler = self;
- if(statehandler){
- /* Deinitialize safeobject */
- tsk_safeobj_deinit(statehandler);
+ tcomp_statehandler_t *statehandler = self;
+ if(statehandler) {
+ /* Deinitialize safeobject */
+ tsk_safeobj_deinit(statehandler);
- TSK_OBJECT_SAFE_FREE(statehandler->sigcomp_parameters);
+ TSK_OBJECT_SAFE_FREE(statehandler->sigcomp_parameters);
- TSK_OBJECT_SAFE_FREE(statehandler->dictionaries);
- TSK_OBJECT_SAFE_FREE(statehandler->compartments);
- }
- else{
- TSK_DEBUG_ERROR("Null SigComp state handler.");
- }
+ TSK_OBJECT_SAFE_FREE(statehandler->dictionaries);
+ TSK_OBJECT_SAFE_FREE(statehandler->compartments);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null SigComp state handler.");
+ }
- return self;
+ return self;
}
-static const tsk_object_def_t tsk_statehandler_def_s =
-{
- sizeof(tcomp_statehandler_t),
- tcomp_statehandler_ctor,
- tcomp_statehandler_dtor,
- tsk_null
+static const tsk_object_def_t tsk_statehandler_def_s = {
+ sizeof(tcomp_statehandler_t),
+ tcomp_statehandler_ctor,
+ tcomp_statehandler_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_statehandler_def_t = &tsk_statehandler_def_s;
diff --git a/tinySIGCOMP/src/tcomp_statehandler.h b/tinySIGCOMP/src/tcomp_statehandler.h
index 23dd494..f5427b4 100755
--- a/tinySIGCOMP/src/tcomp_statehandler.h
+++ b/tinySIGCOMP/src/tcomp_statehandler.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -47,19 +47,18 @@ TCOMP_BEGIN_DECLS
/**State handler.
*/
-typedef struct tcomp_statehandler_s
-{
- TSK_DECLARE_OBJECT;
-
- tcomp_compartments_L_t *compartments;
- tcomp_params_t *sigcomp_parameters;
-
- tcomp_dictionaries_L_t *dictionaries;
- tsk_bool_t hasSipSdpDictionary;
- tsk_bool_t hasPresenceDictionary;
- tsk_bool_t useOnlyACKedStates;
-
- TSK_DECLARE_SAFEOBJ;
+typedef struct tcomp_statehandler_s {
+ TSK_DECLARE_OBJECT;
+
+ tcomp_compartments_L_t *compartments;
+ tcomp_params_t *sigcomp_parameters;
+
+ tcomp_dictionaries_L_t *dictionaries;
+ tsk_bool_t hasSipSdpDictionary;
+ tsk_bool_t hasPresenceDictionary;
+ tsk_bool_t useOnlyACKedStates;
+
+ TSK_DECLARE_SAFEOBJ;
}
tcomp_statehandler_t;
diff --git a/tinySIGCOMP/src/tcomp_types.h b/tinySIGCOMP/src/tcomp_types.h
index 0cb48c9..dcc50c9 100755
--- a/tinySIGCOMP/src/tcomp_types.h
+++ b/tinySIGCOMP/src/tcomp_types.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/src/tcomp_udvm.bytecopy.c b/tinySIGCOMP/src/tcomp_udvm.bytecopy.c
index 246b25c..edc1c56 100755
--- a/tinySIGCOMP/src/tcomp_udvm.bytecopy.c
+++ b/tinySIGCOMP/src/tcomp_udvm.bytecopy.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -40,37 +40,35 @@ From UDVM to UDVM
*/
tsk_bool_t tcomp_udvm_bytecopy_self(tcomp_udvm_t *udvm, uint32_t *destination, uint32_t source, uint32_t tsk_size_tocopy)
{
- uint32_t byte_copy_left, byte_copy_right;
- uint8_t* destination_ptr;
-
- //if (*destination == TCOMP_UDVM_GET_SIZE() || source == TCOMP_UDVM_GET_SIZE())
- if (*destination >= TCOMP_UDVM_GET_SIZE() || source >= TCOMP_UDVM_GET_SIZE())
- {
- /* SEGFAULT */
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
-
- /*
- * The string of bytes is copied in ascending order of memory address,
- * respecting the bounds set by byte_copy_left and byte_copy_right.
- */
- byte_copy_left = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX);
- byte_copy_right = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX);
-
- // string of bytes is copied one byte at a time
- while((tsk_size_tocopy--))
- {
- if(!(destination_ptr = TCOMP_UDVM_GET_BUFFER_AT((*destination)++))){
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- *destination_ptr = *TCOMP_UDVM_GET_BUFFER_AT(source++);
- *destination = (*destination == byte_copy_right)? byte_copy_left : *destination;
- source = (source == byte_copy_right)? byte_copy_left : source;
- }
-
- return tsk_true;
+ uint32_t byte_copy_left, byte_copy_right;
+ uint8_t* destination_ptr;
+
+ //if (*destination == TCOMP_UDVM_GET_SIZE() || source == TCOMP_UDVM_GET_SIZE())
+ if (*destination >= TCOMP_UDVM_GET_SIZE() || source >= TCOMP_UDVM_GET_SIZE()) {
+ /* SEGFAULT */
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+
+ /*
+ * The string of bytes is copied in ascending order of memory address,
+ * respecting the bounds set by byte_copy_left and byte_copy_right.
+ */
+ byte_copy_left = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX);
+ byte_copy_right = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX);
+
+ // string of bytes is copied one byte at a time
+ while((tsk_size_tocopy--)) {
+ if(!(destination_ptr = TCOMP_UDVM_GET_BUFFER_AT((*destination)++))) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ *destination_ptr = *TCOMP_UDVM_GET_BUFFER_AT(source++);
+ *destination = (*destination == byte_copy_right)? byte_copy_left : *destination;
+ source = (source == byte_copy_right)? byte_copy_left : source;
+ }
+
+ return tsk_true;
}
/**RFC3320-Setction_8.4. Byte copying
@@ -78,35 +76,33 @@ From EXTERNAL to UDVM
*/
tsk_bool_t tcomp_udvm_bytecopy_to(tcomp_udvm_t *udvm, uint32_t destination, const uint8_t* source, uint32_t tsk_size_tocopy)
{
- uint32_t byte_copy_left, byte_copy_right;
- uint8_t* destination_ptr;
-
- if(destination == TCOMP_UDVM_GET_SIZE())
- {
- /* SEGFAULT */
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
-
- /*
- * The string of bytes is copied in ascending order of memory address,
- * respecting the bounds set by byte_copy_left and byte_copy_right.
- */
- byte_copy_left = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX);
- byte_copy_right = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX);
-
- // string of bytes is copied one byte at a time
- while((tsk_size_tocopy--))
- {
- if(!(destination_ptr = TCOMP_UDVM_GET_BUFFER_AT(destination++))){
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- *destination_ptr = *(source++);
- destination = (destination == byte_copy_right)? byte_copy_left : destination;
- }
-
- return tsk_true;
+ uint32_t byte_copy_left, byte_copy_right;
+ uint8_t* destination_ptr;
+
+ if(destination == TCOMP_UDVM_GET_SIZE()) {
+ /* SEGFAULT */
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+
+ /*
+ * The string of bytes is copied in ascending order of memory address,
+ * respecting the bounds set by byte_copy_left and byte_copy_right.
+ */
+ byte_copy_left = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX);
+ byte_copy_right = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX);
+
+ // string of bytes is copied one byte at a time
+ while((tsk_size_tocopy--)) {
+ if(!(destination_ptr = TCOMP_UDVM_GET_BUFFER_AT(destination++))) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ *destination_ptr = *(source++);
+ destination = (destination == byte_copy_right)? byte_copy_left : destination;
+ }
+
+ return tsk_true;
}
/**RFC3320-Setction_8.4. Byte copying
@@ -114,32 +110,32 @@ From UDVM to EXTERNAL
*/
tsk_bool_t tcomp_udvm_bytecopy_from(tcomp_udvm_t *udvm, uint8_t* destination, uint32_t source, uint32_t tsk_size_tocopy)
{
- uint32_t byte_copy_left, byte_copy_right;
- uint8_t* source_ptr;
-
- if(source >= TCOMP_UDVM_GET_SIZE()){
- TSK_DEBUG_ERROR("SEGFAULT");
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
-
- /*
- * The string of bytes is copied in ascending order of memory address,
- * respecting the bounds set by byte_copy_left and byte_copy_right.
- */
- byte_copy_left = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX);
- byte_copy_right = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX);
-
-
- // string of bytes is copied one byte at a time
- while((tsk_size_tocopy--)){
- if(!(source_ptr = TCOMP_UDVM_GET_BUFFER_AT(source++))){
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- *(destination++) = *source_ptr;
- source = (source == byte_copy_right)? byte_copy_left : source;
- }
-
- return tsk_true;
+ uint32_t byte_copy_left, byte_copy_right;
+ uint8_t* source_ptr;
+
+ if(source >= TCOMP_UDVM_GET_SIZE()) {
+ TSK_DEBUG_ERROR("SEGFAULT");
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+
+ /*
+ * The string of bytes is copied in ascending order of memory address,
+ * respecting the bounds set by byte_copy_left and byte_copy_right.
+ */
+ byte_copy_left = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX);
+ byte_copy_right = TCOMP_UDVM_GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX);
+
+
+ // string of bytes is copied one byte at a time
+ while((tsk_size_tocopy--)) {
+ if(!(source_ptr = TCOMP_UDVM_GET_BUFFER_AT(source++))) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ *(destination++) = *source_ptr;
+ source = (source == byte_copy_right)? byte_copy_left : source;
+ }
+
+ return tsk_true;
}
diff --git a/tinySIGCOMP/src/tcomp_udvm.c b/tinySIGCOMP/src/tcomp_udvm.c
index 6a7607f..728d974 100755
--- a/tinySIGCOMP/src/tcomp_udvm.c
+++ b/tinySIGCOMP/src/tcomp_udvm.c
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop
* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -33,469 +33,429 @@
tcomp_udvm_t* tcomp_udvm_create(tcomp_message_t* _sigCompMessage, tcomp_statehandler_t* stateHandler, tcomp_result_t* lpResult)
{
- tcomp_udvm_t *udvm;
- if((udvm = tsk_object_new(tcomp_udvm_def_t))){
- /* RFC 3320 - 7. SigComp Message Format */
- udvm->sigCompMessage = tsk_object_ref(_sigCompMessage);
- udvm->stateHandler = tsk_object_ref(stateHandler);
- udvm->lpResult = tsk_object_ref(lpResult);
-
- udvm->isOK = tsk_true;
- udvm->maximum_UDVM_cycles = 0; /* RFC 3320 subclause 8.6 */
- udvm->consumed_cycles = 0;
- udvm->memory = tcomp_buffer_create_null();
-
- /* Alloc UDVM memory */
- if(udvm->sigCompMessage->stream_based){
- /*
- * If the transport is stream-based however, then a fixed-size input buffer is required to accommodate the stream, independently of the
- * size of each SigComp message. So, for simplicity, the UDVM memory size is set to (decompression_memory_size / 2).
- */
-
- tcomp_buffer_allocBuff(udvm->memory, udvm->stateHandler->sigcomp_parameters->dmsValue/2);
- }
- else{
- /*
- * If the transport is message-based then sufficient memory must be available
- * to buffer the entire SigComp message before it is passed to the UDVM. So if the message is n bytes long, then the UDVM memory size is set
- * to (decompression_memory_size - n), up to a maximum of 65536 bytes.
- */
- tcomp_buffer_allocBuff(udvm->memory, (udvm->stateHandler->sigcomp_parameters->dmsValue-udvm->sigCompMessage->totalSize));
- }
-
- /*
- * Has feedback with my state id?
- */
- if(tcomp_buffer_getSize(udvm->sigCompMessage->ret_feedback_buffer)){
- tsk_size_t size = tcomp_buffer_getSize(udvm->sigCompMessage->ret_feedback_buffer);
- tcomp_buffer_allocBuff(udvm->lpResult->ret_feedback, size);
- memcpy(tcomp_buffer_getBuffer(udvm->lpResult->ret_feedback), tcomp_buffer_getBuffer(udvm->sigCompMessage->ret_feedback_buffer), size);
- }
-
- /*
- * Has state?
- */
- if(tcomp_buffer_getSize(udvm->sigCompMessage->stateId)){
- /* Find the provided state */
- tcomp_state_t* lpState = NULL;
- uint32_t match_count = tcomp_statehandler_findState(udvm->stateHandler, udvm->sigCompMessage->stateId, &lpState);
- if( (match_count != 1 || !lpState)
- || (lpState->minimum_access_length > tcomp_buffer_getSize(udvm->sigCompMessage->stateId))
- || ((tsk_size_t)(lpState->address + lpState->length) > TCOMP_UDVM_GET_SIZE()) )
- {
- TSK_DEBUG_ERROR("NACK_STATE_NOT_FOUND for id = ");
- tcomp_buffer_print(udvm->sigCompMessage->stateId);
- tcomp_udvm_createNackInfo(udvm, NACK_STATE_NOT_FOUND, udvm->sigCompMessage->stateId, 0);
- udvm->isOK = tsk_false;
- goto bail;
- }
- /*
- * Copy bytecodes to UDVM memory
- */
- if( (tsk_size_t)(lpState->address + lpState->length) >= TCOMP_UDVM_GET_SIZE() ){
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- udvm->isOK = tsk_false;
- goto bail;
- }
- memcpy( TCOMP_UDVM_GET_BUFFER_AT(lpState->address),
- tcomp_buffer_getBuffer(lpState->value),
- tcomp_buffer_getSize(lpState->value) );
-
- //RFC 3320 - 7.2. Accessing Stored State (Useful values)
- TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_PARTIAL_STATE_ID_LENGTH_INDEX, tcomp_buffer_getSize(udvm->sigCompMessage->stateId));
- TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_STATE_LENGTH_INDEX, tcomp_buffer_getSize(lpState->value));
-
- udvm->executionPointer = lpState->instruction;
- }
- else // DON'T HAVE STATE
- {
- /*
- * Copy bytecodes to UDVM memory
- */
- tsk_size_t bytecodes_destination = udvm->sigCompMessage->bytecodes_destination;
- if( (bytecodes_destination + tcomp_buffer_getSize(udvm->sigCompMessage->uploaded_UDVM_buffer)) >= TCOMP_UDVM_GET_SIZE() ){
- tcomp_udvm_createNackInfo2(udvm, NACK_BYTECODES_TOO_LARGE);
- udvm->isOK = tsk_false;
- goto bail;
- }
- memcpy( TCOMP_UDVM_GET_BUFFER_AT(bytecodes_destination),
- tcomp_buffer_getBuffer(udvm->sigCompMessage->uploaded_UDVM_buffer),
- tcomp_buffer_getSize(udvm->sigCompMessage->uploaded_UDVM_buffer));
-
- // Set pointer indicating execution index
- udvm->executionPointer = bytecodes_destination;
- }
-
- /* RFC 3320-Section_8.6. UDVM Cycles
- *
- * the maximum number of UDVM cycles available for processing an n-byte SigComp message is given by the formula
- * maximum_UDVM_cycles = (8 * n + 1000) * cycles_per_bit
- */
- udvm->maximum_UDVM_cycles = ( (8 * udvm->sigCompMessage->header_size + 1000) * udvm->stateHandler->sigcomp_parameters->cpbValue );
-
- //
- // RFC 3320 - 7.2. Useful values
- //
- TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_UDVM_MEMORY_SIZE_INDEX, TCOMP_UDVM_GET_SIZE());
- TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_CYCLES_PER_BIT_INDEX, udvm->stateHandler->sigcomp_parameters->cpbValue);
- TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_SIGCOMP_VERSION_INDEX, udvm->stateHandler->sigcomp_parameters->SigComp_version);
- memset(TCOMP_UDVM_GET_BUFFER_AT(TCOMP_UDVM_HEADER_RESERVED_INDEX), 0, TCOMP_UDVM_HEADER_RESERVED_SIZE);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new udvm machine.");
- }
+ tcomp_udvm_t *udvm;
+ if((udvm = tsk_object_new(tcomp_udvm_def_t))) {
+ /* RFC 3320 - 7. SigComp Message Format */
+ udvm->sigCompMessage = tsk_object_ref(_sigCompMessage);
+ udvm->stateHandler = tsk_object_ref(stateHandler);
+ udvm->lpResult = tsk_object_ref(lpResult);
+
+ udvm->isOK = tsk_true;
+ udvm->maximum_UDVM_cycles = 0; /* RFC 3320 subclause 8.6 */
+ udvm->consumed_cycles = 0;
+ udvm->memory = tcomp_buffer_create_null();
+
+ /* Alloc UDVM memory */
+ if(udvm->sigCompMessage->stream_based) {
+ /*
+ * If the transport is stream-based however, then a fixed-size input buffer is required to accommodate the stream, independently of the
+ * size of each SigComp message. So, for simplicity, the UDVM memory size is set to (decompression_memory_size / 2).
+ */
+
+ tcomp_buffer_allocBuff(udvm->memory, udvm->stateHandler->sigcomp_parameters->dmsValue/2);
+ }
+ else {
+ /*
+ * If the transport is message-based then sufficient memory must be available
+ * to buffer the entire SigComp message before it is passed to the UDVM. So if the message is n bytes long, then the UDVM memory size is set
+ * to (decompression_memory_size - n), up to a maximum of 65536 bytes.
+ */
+ tcomp_buffer_allocBuff(udvm->memory, (udvm->stateHandler->sigcomp_parameters->dmsValue-udvm->sigCompMessage->totalSize));
+ }
+
+ /*
+ * Has feedback with my state id?
+ */
+ if(tcomp_buffer_getSize(udvm->sigCompMessage->ret_feedback_buffer)) {
+ tsk_size_t size = tcomp_buffer_getSize(udvm->sigCompMessage->ret_feedback_buffer);
+ tcomp_buffer_allocBuff(udvm->lpResult->ret_feedback, size);
+ memcpy(tcomp_buffer_getBuffer(udvm->lpResult->ret_feedback), tcomp_buffer_getBuffer(udvm->sigCompMessage->ret_feedback_buffer), size);
+ }
+
+ /*
+ * Has state?
+ */
+ if(tcomp_buffer_getSize(udvm->sigCompMessage->stateId)) {
+ /* Find the provided state */
+ tcomp_state_t* lpState = NULL;
+ uint32_t match_count = tcomp_statehandler_findState(udvm->stateHandler, udvm->sigCompMessage->stateId, &lpState);
+ if( (match_count != 1 || !lpState)
+ || (lpState->minimum_access_length > tcomp_buffer_getSize(udvm->sigCompMessage->stateId))
+ || ((tsk_size_t)(lpState->address + lpState->length) > TCOMP_UDVM_GET_SIZE()) ) {
+ TSK_DEBUG_ERROR("NACK_STATE_NOT_FOUND for id = ");
+ tcomp_buffer_print(udvm->sigCompMessage->stateId);
+ tcomp_udvm_createNackInfo(udvm, NACK_STATE_NOT_FOUND, udvm->sigCompMessage->stateId, 0);
+ udvm->isOK = tsk_false;
+ goto bail;
+ }
+ /*
+ * Copy bytecodes to UDVM memory
+ */
+ if( (tsk_size_t)(lpState->address + lpState->length) >= TCOMP_UDVM_GET_SIZE() ) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ udvm->isOK = tsk_false;
+ goto bail;
+ }
+ memcpy( TCOMP_UDVM_GET_BUFFER_AT(lpState->address),
+ tcomp_buffer_getBuffer(lpState->value),
+ tcomp_buffer_getSize(lpState->value) );
+
+ //RFC 3320 - 7.2. Accessing Stored State (Useful values)
+ TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_PARTIAL_STATE_ID_LENGTH_INDEX, tcomp_buffer_getSize(udvm->sigCompMessage->stateId));
+ TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_STATE_LENGTH_INDEX, tcomp_buffer_getSize(lpState->value));
+
+ udvm->executionPointer = lpState->instruction;
+ }
+ else { // DON'T HAVE STATE
+ /*
+ * Copy bytecodes to UDVM memory
+ */
+ tsk_size_t bytecodes_destination = udvm->sigCompMessage->bytecodes_destination;
+ if( (bytecodes_destination + tcomp_buffer_getSize(udvm->sigCompMessage->uploaded_UDVM_buffer)) >= TCOMP_UDVM_GET_SIZE() ) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_BYTECODES_TOO_LARGE);
+ udvm->isOK = tsk_false;
+ goto bail;
+ }
+ memcpy( TCOMP_UDVM_GET_BUFFER_AT(bytecodes_destination),
+ tcomp_buffer_getBuffer(udvm->sigCompMessage->uploaded_UDVM_buffer),
+ tcomp_buffer_getSize(udvm->sigCompMessage->uploaded_UDVM_buffer));
+
+ // Set pointer indicating execution index
+ udvm->executionPointer = bytecodes_destination;
+ }
+
+ /* RFC 3320-Section_8.6. UDVM Cycles
+ *
+ * the maximum number of UDVM cycles available for processing an n-byte SigComp message is given by the formula
+ * maximum_UDVM_cycles = (8 * n + 1000) * cycles_per_bit
+ */
+ udvm->maximum_UDVM_cycles = ( (8 * udvm->sigCompMessage->header_size + 1000) * udvm->stateHandler->sigcomp_parameters->cpbValue );
+
+ //
+ // RFC 3320 - 7.2. Useful values
+ //
+ TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_UDVM_MEMORY_SIZE_INDEX, TCOMP_UDVM_GET_SIZE());
+ TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_CYCLES_PER_BIT_INDEX, udvm->stateHandler->sigcomp_parameters->cpbValue);
+ TCOMP_UDVM_SET_2BYTES_VAL(TCOMP_UDVM_HEADER_SIGCOMP_VERSION_INDEX, udvm->stateHandler->sigcomp_parameters->SigComp_version);
+ memset(TCOMP_UDVM_GET_BUFFER_AT(TCOMP_UDVM_HEADER_RESERVED_INDEX), 0, TCOMP_UDVM_HEADER_RESERVED_SIZE);
+ }
+ else {
+ TSK_DEBUG_ERROR("Failed to create new udvm machine.");
+ }
bail:
- return udvm;
+ return udvm;
}
/**Executes the bytecode.
*/
static tsk_bool_t tcomp_udvm_runByteCode(tcomp_udvm_t *udvm)
{
- uint32_t operand_1, operand_2, operand_3, operand_4, operand_5, operand_6, operand_7;
- tsk_bool_t excution_failed = tsk_false, end_message = tsk_false;
- if(!udvm->isOK) {
- TSK_DEBUG_ERROR("Cannot run()/execute() invalid bytecode");
- return tsk_false;
- }
-
- // LOOP - EXCUTE all bytecode
- while( !excution_failed && !end_message )
- {
- uint8_t udvm_instruction = * (TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer));
- udvm->last_memory_address_of_instruction = udvm->executionPointer;
- udvm->executionPointer++; /* Skip the 1-byte [INSTRUCTION]. */
-
- switch(udvm_instruction)
- {
- case TCOMP_UDVM_INST__DECOMPRESSION_FAILURE:
- {
- TCOMP_UDVM_EXEC_INST__DECOMPRESSION_FAILURE(udvm);
- excution_failed = tsk_true;
- break;
- }
-
- case TCOMP_UDVM_INST__AND:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__AND(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__OR:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__OR(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__NOT:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__NOT(udvm, operand_1);
- break;
- }
-
- case TCOMP_UDVM_INST__LSHIFT:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__LSHIFT(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__RSHIFT:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__RSHIFT(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__ADD:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__ADD(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__SUBTRACT:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__SUBTRACT(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__MULTIPLY:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__MULTIPLY(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__DIVIDE:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__DIVIDE(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__REMAINDER:
- {
- operand_1 = tcomp_udvm_opget_reference_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__REMAINDER(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__SORT_ASCENDING:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__SORT_ASCENDING(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__SORT_DESCENDING:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__SORT_DESCENDING(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__SHA_1:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__SHA_1(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__LOAD:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__LOAD(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__MULTILOAD:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_literal_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__MULTILOAD(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__PUSH:
- {
- excution_failed = !TCOMP_UDVM_EXEC_INST__PUSH2(udvm);
- break;
- }
-
- case TCOMP_UDVM_INST__POP:
- {
- excution_failed = !TCOMP_UDVM_EXEC_INST__POP2(udvm);
- break;
- }
-
- case TCOMP_UDVM_INST__COPY:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__COPY(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__COPY_LITERAL:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_reference_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__COPY_LITERAL(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__COPY_OFFSET:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_reference_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__COPY_OFFSET(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__MEMSET:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- operand_4 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__MEMSET(udvm, operand_1, operand_2, operand_3, operand_4);
- break;
- }
-
- case TCOMP_UDVM_INST__JUMP:
- {
- excution_failed = !TCOMP_UDVM_EXEC_INST__JUMP2(udvm);
- break;
- }
-
- case TCOMP_UDVM_INST__COMPARE:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- operand_4 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- operand_5 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- excution_failed = !TCOMP_UDVM_EXEC_INST__COMPARE(udvm, operand_1, operand_2, operand_3, operand_4, operand_5);
- break;
- }
-
- case TCOMP_UDVM_INST__CALL:
- {
- operand_1 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- excution_failed = !TCOMP_UDVM_EXEC_INST__CALL(udvm, operand_1);
- break;
- }
-
- case TCOMP_UDVM_INST__RETURN:
- {
- excution_failed = !TCOMP_UDVM_EXEC_INST__RETURN(udvm);
- break;
- }
-
- case TCOMP_UDVM_INST__SWITCH:
- {
- operand_1 = tcomp_udvm_opget_literal_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__SWITCH(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__CRC:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- operand_4 = tcomp_udvm_opget_reference_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__CRC(udvm, operand_1, operand_2, operand_3, operand_4);
- break;
- }
-
- case TCOMP_UDVM_INST__INPUT_BYTES:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- excution_failed = !TCOMP_UDVM_EXEC_INST__INPUT_BYTES(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__INPUT_BITS:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- excution_failed = !TCOMP_UDVM_EXEC_INST__INPUT_BITS(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__INPUT_HUFFMAN:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- operand_3 = tcomp_udvm_opget_literal_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__INPUT_HUFFMAN(udvm, operand_1, operand_2, operand_3);
- break;
- }
-
- case TCOMP_UDVM_INST__STATE_ACCESS:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- operand_4 = tcomp_udvm_opget_multitype_param(udvm);
- operand_5 = tcomp_udvm_opget_multitype_param(udvm);
- operand_6 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__STATE_ACCESS(udvm, operand_1, operand_2, operand_3, operand_4, operand_5, operand_6);
- break;
- }
-
- case TCOMP_UDVM_INST__STATE_CREATE:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- operand_4 = tcomp_udvm_opget_multitype_param(udvm);
- operand_5 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__STATE_CREATE(udvm, operand_1, operand_2, operand_3, operand_4, operand_5);
- break;
- }
-
- case TCOMP_UDVM_INST__STATE_FREE:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__STATE_FREE(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__OUTPUT:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__OUTPUT(udvm, operand_1, operand_2);
- break;
- }
-
- case TCOMP_UDVM_INST__END_MESSAGE:
- {
- operand_1 = tcomp_udvm_opget_multitype_param(udvm);
- operand_2 = tcomp_udvm_opget_multitype_param(udvm);
- operand_3 = tcomp_udvm_opget_multitype_param(udvm);
- operand_4 = tcomp_udvm_opget_multitype_param(udvm);
- operand_5 = tcomp_udvm_opget_multitype_param(udvm);
- operand_6 = tcomp_udvm_opget_multitype_param(udvm);
- operand_7 = tcomp_udvm_opget_multitype_param(udvm);
- excution_failed = !TCOMP_UDVM_EXEC_INST__END_MESSAGE(udvm, operand_1, operand_2, operand_3, operand_4, operand_5, operand_6, operand_7);
- end_message = 1;
- break;
- }
-
- default:
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPCODE);
- goto bail;
- }
-
- if(excution_failed){
- TSK_DEBUG_ERROR("Execution failed for instruction = %s", TCOMP_INST_DESCRIPTIONS[udvm_instruction].desc);
- }
- //TCOMP_UDVM_DEBUG_PRINT(200);
- }
+ uint32_t operand_1, operand_2, operand_3, operand_4, operand_5, operand_6, operand_7;
+ tsk_bool_t excution_failed = tsk_false, end_message = tsk_false;
+ if(!udvm->isOK) {
+ TSK_DEBUG_ERROR("Cannot run()/execute() invalid bytecode");
+ return tsk_false;
+ }
+
+ // LOOP - EXCUTE all bytecode
+ while( !excution_failed && !end_message ) {
+ uint8_t udvm_instruction = * (TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer));
+ udvm->last_memory_address_of_instruction = udvm->executionPointer;
+ udvm->executionPointer++; /* Skip the 1-byte [INSTRUCTION]. */
+
+ switch(udvm_instruction) {
+ case TCOMP_UDVM_INST__DECOMPRESSION_FAILURE: {
+ TCOMP_UDVM_EXEC_INST__DECOMPRESSION_FAILURE(udvm);
+ excution_failed = tsk_true;
+ break;
+ }
+
+ case TCOMP_UDVM_INST__AND: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__AND(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__OR: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__OR(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__NOT: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__NOT(udvm, operand_1);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__LSHIFT: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__LSHIFT(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__RSHIFT: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__RSHIFT(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__ADD: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__ADD(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__SUBTRACT: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__SUBTRACT(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__MULTIPLY: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__MULTIPLY(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__DIVIDE: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__DIVIDE(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__REMAINDER: {
+ operand_1 = tcomp_udvm_opget_reference_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__REMAINDER(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__SORT_ASCENDING: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__SORT_ASCENDING(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__SORT_DESCENDING: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__SORT_DESCENDING(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__SHA_1: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__SHA_1(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__LOAD: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__LOAD(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__MULTILOAD: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_literal_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__MULTILOAD(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__PUSH: {
+ excution_failed = !TCOMP_UDVM_EXEC_INST__PUSH2(udvm);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__POP: {
+ excution_failed = !TCOMP_UDVM_EXEC_INST__POP2(udvm);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__COPY: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__COPY(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__COPY_LITERAL: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_reference_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__COPY_LITERAL(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__COPY_OFFSET: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_reference_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__COPY_OFFSET(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__MEMSET: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_4 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__MEMSET(udvm, operand_1, operand_2, operand_3, operand_4);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__JUMP: {
+ excution_failed = !TCOMP_UDVM_EXEC_INST__JUMP2(udvm);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__COMPARE: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ operand_4 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ operand_5 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__COMPARE(udvm, operand_1, operand_2, operand_3, operand_4, operand_5);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__CALL: {
+ operand_1 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__CALL(udvm, operand_1);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__RETURN: {
+ excution_failed = !TCOMP_UDVM_EXEC_INST__RETURN(udvm);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__SWITCH: {
+ operand_1 = tcomp_udvm_opget_literal_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__SWITCH(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__CRC: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_4 = tcomp_udvm_opget_reference_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__CRC(udvm, operand_1, operand_2, operand_3, operand_4);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__INPUT_BYTES: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__INPUT_BYTES(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__INPUT_BITS: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__INPUT_BITS(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__INPUT_HUFFMAN: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ operand_3 = tcomp_udvm_opget_literal_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__INPUT_HUFFMAN(udvm, operand_1, operand_2, operand_3);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__STATE_ACCESS: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_4 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_5 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_6 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__STATE_ACCESS(udvm, operand_1, operand_2, operand_3, operand_4, operand_5, operand_6);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__STATE_CREATE: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_4 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_5 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__STATE_CREATE(udvm, operand_1, operand_2, operand_3, operand_4, operand_5);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__STATE_FREE: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__STATE_FREE(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__OUTPUT: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__OUTPUT(udvm, operand_1, operand_2);
+ break;
+ }
+
+ case TCOMP_UDVM_INST__END_MESSAGE: {
+ operand_1 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_2 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_3 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_4 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_5 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_6 = tcomp_udvm_opget_multitype_param(udvm);
+ operand_7 = tcomp_udvm_opget_multitype_param(udvm);
+ excution_failed = !TCOMP_UDVM_EXEC_INST__END_MESSAGE(udvm, operand_1, operand_2, operand_3, operand_4, operand_5, operand_6, operand_7);
+ end_message = 1;
+ break;
+ }
+
+ default:
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPCODE);
+ goto bail;
+ }
+
+ if(excution_failed) {
+ TSK_DEBUG_ERROR("Execution failed for instruction = %s", TCOMP_INST_DESCRIPTIONS[udvm_instruction].desc);
+ }
+ //TCOMP_UDVM_DEBUG_PRINT(200);
+ }
bail:
- udvm->lpResult->consumed_cycles = udvm->consumed_cycles;
- return (!excution_failed);
+ udvm->lpResult->consumed_cycles = udvm->consumed_cycles;
+ return (!excution_failed);
}
/**Decompress the bytecode.
*/
tsk_bool_t tcomp_udvm_decompress(tcomp_udvm_t *udvm)
{
- return tcomp_udvm_runByteCode(udvm);
+ return tcomp_udvm_runByteCode(udvm);
}
@@ -522,36 +482,35 @@ tsk_bool_t tcomp_udvm_decompress(tcomp_udvm_t *udvm)
//
static tsk_object_t* tcomp_udvm_ctor(tsk_object_t * self, va_list * app)
{
- tcomp_udvm_t *udvm = self;
- if(udvm){
+ tcomp_udvm_t *udvm = self;
+ if(udvm) {
- }
- return self;
+ }
+ return self;
}
static tsk_object_t* tcomp_udvm_dtor(tsk_object_t *self)
{
- tcomp_udvm_t *udvm = self;
- if(udvm){
- TSK_OBJECT_SAFE_FREE(udvm->memory);
- TSK_OBJECT_SAFE_FREE(udvm->sigCompMessage);
- TSK_OBJECT_SAFE_FREE(udvm->stateHandler);
- TSK_OBJECT_SAFE_FREE(udvm->lpResult);
-
- TSK_FREE(udvm->tmp_buff.ptr);
- }
- else{
- TSK_DEBUG_ERROR("Null udvm machine.");
- }
-
- return self;
+ tcomp_udvm_t *udvm = self;
+ if(udvm) {
+ TSK_OBJECT_SAFE_FREE(udvm->memory);
+ TSK_OBJECT_SAFE_FREE(udvm->sigCompMessage);
+ TSK_OBJECT_SAFE_FREE(udvm->stateHandler);
+ TSK_OBJECT_SAFE_FREE(udvm->lpResult);
+
+ TSK_FREE(udvm->tmp_buff.ptr);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null udvm machine.");
+ }
+
+ return self;
}
-static const tsk_object_def_t tcomp_udvm_def_s =
-{
- sizeof(tcomp_udvm_t),
- tcomp_udvm_ctor,
- tcomp_udvm_dtor,
- tsk_null
+static const tsk_object_def_t tcomp_udvm_def_s = {
+ sizeof(tcomp_udvm_t),
+ tcomp_udvm_ctor,
+ tcomp_udvm_dtor,
+ tsk_null
};
const tsk_object_def_t *tcomp_udvm_def_t = &tcomp_udvm_def_s;
diff --git a/tinySIGCOMP/src/tcomp_udvm.h b/tinySIGCOMP/src/tcomp_udvm.h
index cea9616..736d777 100755
--- a/tinySIGCOMP/src/tcomp_udvm.h
+++ b/tinySIGCOMP/src/tcomp_udvm.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -59,28 +59,27 @@ TCOMP_BEGIN_DECLS
#define TCOMP_UDVM_GET_BUFFER() tcomp_buffer_getBuffer(udvm->memory)
#define TCOMP_UDVM_GET_BUFFER_AT(position) tcomp_buffer_getBufferAtPos(udvm->memory, position)
-typedef struct tcomp_udvm_s
-{
- TSK_DECLARE_OBJECT;
-
- unsigned isOK:1;
- tcomp_message_t *sigCompMessage;
- tcomp_statehandler_t *stateHandler;
- tcomp_result_t *lpResult;
-
- uint64_t maximum_UDVM_cycles; // RFC3320-Section_8.6
- uint64_t consumed_cycles;
-
- tcomp_buffer_handle_t *memory;
- //header_udvm_memory memoryHeader; // RFC3320-Section_7.2 - // Default constructor will initial values (sip default)
-
- uint32_t executionPointer;
- uint32_t last_memory_address_of_instruction;
-
- struct{
- void* ptr;
- tsk_size_t size;
- } tmp_buff;
+typedef struct tcomp_udvm_s {
+ TSK_DECLARE_OBJECT;
+
+ unsigned isOK:1;
+ tcomp_message_t *sigCompMessage;
+ tcomp_statehandler_t *stateHandler;
+ tcomp_result_t *lpResult;
+
+ uint64_t maximum_UDVM_cycles; // RFC3320-Section_8.6
+ uint64_t consumed_cycles;
+
+ tcomp_buffer_handle_t *memory;
+ //header_udvm_memory memoryHeader; // RFC3320-Section_7.2 - // Default constructor will initial values (sip default)
+
+ uint32_t executionPointer;
+ uint32_t last_memory_address_of_instruction;
+
+ struct {
+ void* ptr;
+ tsk_size_t size;
+ } tmp_buff;
}
tcomp_udvm_t;
@@ -107,8 +106,8 @@ tsk_bool_t tcomp_udvm_bytecopy_from(tcomp_udvm_t *udvm, uint8_t* destination, ui
* State Management
*/
int tcomp_udvm_byteCopy_TempStates(tcomp_udvm_t *udvm);
-int tcomp_udvm_createTempState(tcomp_udvm_t *udvm, uint32_t state_length, uint32_t state_address, uint32_t state_instruction,
- uint32_t minimum_access_length, uint32_t state_retention_priority, int end_msg);
+int tcomp_udvm_createTempState(tcomp_udvm_t *udvm, uint32_t state_length, uint32_t state_address, uint32_t state_instruction,
+ uint32_t minimum_access_length, uint32_t state_retention_priority, int end_msg);
/*
* Nack creation
diff --git a/tinySIGCOMP/src/tcomp_udvm.instructions.c b/tinySIGCOMP/src/tcomp_udvm.instructions.c
index 64b20b5..61724ee 100755
--- a/tinySIGCOMP/src/tcomp_udvm.instructions.c
+++ b/tinySIGCOMP/src/tcomp_udvm.instructions.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -68,7 +68,7 @@
return tsk_false; \
}\
TCOMP_UDVM_SET_2BYTES_VAL(position, value);\
-
+
#define GET_2BYTES_VAL(position, ret_val) \
if(((position) + 1) >= TCOMP_UDVM_GET_SIZE()) \
{ \
@@ -82,31 +82,30 @@
/**
This structure is used to keep index-value pairs after sorting.
*/
-typedef struct IndexValuePair_s
-{
- uint16_t index;
- uint16_t value;
+typedef struct IndexValuePair_s {
+ uint16_t index;
+ uint16_t value;
}
IndexValuePair_t;
////////////////////////////////////////////////////////////////////////////////////////////////////
-/// @brief Predicate to sort integers in ascending order.
+/// @brief Predicate to sort integers in ascending order.
///
-/// @param [in,out] a First integer.
-/// @param [in,out] b Second integer.
+/// @param [in,out] a First integer.
+/// @param [in,out] b Second integer.
///
-/// @retval Zero if @a a == @a b; negative if @a a < @a b and positive otherwise..
+/// @retval Zero if @a a == @a b; negative if @a a < @a b and positive otherwise..
////////////////////////////////////////////////////////////////////////////////////////////////////
static int SortAscendingPredicate(const void *a, const void *b)
{
- const IndexValuePair_t *el1 = a;
- const IndexValuePair_t *el2 = b;
-
- /* If values are equal the original ordering of the integers must be preserved
- * ==> We cannot use normal comparaison because the ANSI C implementation of qsort could swap values even if they are equal.
- */
- return (el2->value == el1->value) ? (el1->index - el2->index) : (el1->value - el2->value);
+ const IndexValuePair_t *el1 = a;
+ const IndexValuePair_t *el2 = b;
+
+ /* If values are equal the original ordering of the integers must be preserved
+ * ==> We cannot use normal comparaison because the ANSI C implementation of qsort could swap values even if they are equal.
+ */
+ return (el2->value == el1->value) ? (el1->index - el2->index) : (el1->value - el2->value);
}
/**
@@ -115,21 +114,21 @@ static int SortAscendingPredicate(const void *a, const void *b)
////////////////////////////////////////////////////////////////////////////////////////////////////
///
-/// @brief Predicate to sort integers in descending order.
-/// @param [in,out] a First integer.
-/// @param [in,out] b Second integer.
+/// @brief Predicate to sort integers in descending order.
+/// @param [in,out] a First integer.
+/// @param [in,out] b Second integer.
///
/// @retval Zero if @a a == @a b; negative if @a a > @a b and positive otherwise.
////////////////////////////////////////////////////////////////////////////////////////////////////
static int SortDescendingPredicate(const void *a, const void *b)
{
- const IndexValuePair_t *el1 = a;
- const IndexValuePair_t *el2 = b;
+ const IndexValuePair_t *el1 = a;
+ const IndexValuePair_t *el2 = b;
- /* If values are equal the original ordering of the integers must be preserved.
- * ==> We cannot use normal comparaison because the ANSI C implementation of qsort could swap values even if they are equal.
- */
- return (el2->value == el1->value) ? (el1->index - el2->index) : (el2->value - el1->value);
+ /* If values are equal the original ordering of the integers must be preserved.
+ * ==> We cannot use normal comparaison because the ANSI C implementation of qsort could swap values even if they are equal.
+ */
+ return (el2->value == el1->value) ? (el1->index - el2->index) : (el2->value - el1->value);
};
@@ -142,15 +141,15 @@ static int SortDescendingPredicate(const void *a, const void *b)
/// cannot successfully decompress the message (e.g., by using the CRC instruction).
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__DECOMPRESSION_FAILURE(tcomp_udvm_t *udvm)
{
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_USER_REQUESTED].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_USER_REQUESTED);
- return tsk_false;
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_USER_REQUESTED].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_USER_REQUESTED);
+ return tsk_false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -158,26 +157,26 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__DECOMPRESSION_FAILURE(tcomp_udvm_t *udvm)
///
/// @brief AND ($operand_1, %operand_2)
/// Reference: RFC3320 Section 9.1.1
-/// Formula: [operand_1 := operand_1 & operand_2].
+/// Formula: [operand_1 := operand_1 & operand_2].
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
-/// @param operand_2 The second operand.
+/// this operand is overwritten with the result.
+/// @param operand_2 The second operand.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__AND(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
+
+ CONSUME_CYCLES(1);
- CONSUME_CYCLES(1);
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL( operand_1, (_2bytes & operand_2) );
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL( operand_1, (_2bytes & operand_2) );
-
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -185,26 +184,26 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__AND(tcomp_udvm_t *udvm, uint32_t operand_1, uin
///
/// @brief OR ($operand_1, %operand_2)
/// Reference: RFC3320 Section 9.1.1
-/// Formula: [operand_1 := operand_1 | operand_2].
+/// Formula: [operand_1 := operand_1 | operand_2].
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
-/// @param operand_2 The second operand.
+/// this operand is overwritten with the result.
+/// @param operand_2 The second operand.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__OR(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL( operand_1, (_2bytes | operand_2) );
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL( operand_1, (_2bytes | operand_2) );
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -214,23 +213,23 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__OR(tcomp_udvm_t *udvm, uint32_t operand_1, uint
/// Reference: RFC3320 Section 9.1.1<br>
/// Formula: [operand_1 := ~operand_1]. <br>
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
+/// this operand is overwritten with the result.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__NOT(tcomp_udvm_t *udvm, uint32_t operand_1)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL( operand_1, ~( _2bytes ) );
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL( operand_1, ~( _2bytes ) );
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -240,27 +239,27 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__NOT(tcomp_udvm_t *udvm, uint32_t operand_1)
/// Reference: RFC3320 Section 9.1.1<br>
/// Formula: [LSHIFT (m, n) := m * 2^n (modulo 2^16)]. <br>
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
-/// @param operand_2 2-byte value encoded by the operand.
+/// this operand is overwritten with the result.
+/// @param operand_2 2-byte value encoded by the operand.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__LSHIFT(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- // (m * 2^n) == (m<<n)
- // (2^16) === 65536
+ // (m * 2^n) == (m<<n)
+ // (2^16) === 65536
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL( operand_1, (_2bytes << operand_2) );
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL( operand_1, (_2bytes << operand_2) );
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -270,25 +269,25 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__LSHIFT(tcomp_udvm_t *udvm, uint32_t operand_1,
/// Reference: RFC3320 Section 9.1.1<br>
/// Formula: [RSHIFT (m, n) := floor(m / 2^n)]. <br>
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-// this operand is overwritten with the result.
-/// @param operand_2 2-byte value encoded by the operand.
+// this operand is overwritten with the result.
+/// @param operand_2 2-byte value encoded by the operand.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__RSHIFT(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
+
+ CONSUME_CYCLES(1);
- CONSUME_CYCLES(1);
-
- // floor(m / 2^n) == (m>>n)
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL(operand_1, (_2bytes >> operand_2) );
+ // floor(m / 2^n) == (m>>n)
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL(operand_1, (_2bytes >> operand_2) );
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -299,23 +298,23 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__RSHIFT(tcomp_udvm_t *udvm, uint32_t operand_1,
/// Formula: [ADD (m, n) := m + n (modulo 2^16)]<br>
///
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
-/// @param operand_2 2-byte value encoded by the operand.
+/// this operand is overwritten with the result.
+/// @param operand_2 2-byte value encoded by the operand.
///
/// @retval True if succeed, otherwise return false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__ADD(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
+
+ CONSUME_CYCLES(1);
- CONSUME_CYCLES(1);
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL(operand_1, (_2bytes + operand_2) );
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL(operand_1, (_2bytes + operand_2) );
-
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -325,7 +324,7 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__ADD(tcomp_udvm_t *udvm, uint32_t operand_1, uin
/// Reference: RFC3320 Section 9.1.2<br>
/// Formula: [SUBTRACT (m, n) := m - n (modulo 2^16)]<br>
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
/// this operand is overwritten with the result.
/// @param operand_2 2-byte value encoded by the operand.
@@ -334,14 +333,14 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__ADD(tcomp_udvm_t *udvm, uint32_t operand_1, uin
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__SUBTRACT(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL(operand_1, (_2bytes - operand_2) );
-
- return tsk_true;
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL(operand_1, (_2bytes - operand_2) );
+
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -351,23 +350,23 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__SUBTRACT(tcomp_udvm_t *udvm, uint32_t operand_1
/// Reference: RFC3320 Section 9.1.2<br>
/// Formula: [MULTIPLY (m, n) := m * n (modulo 2^16)]<br>
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
-/// @param operand_2 2-byte value encoded by the operand.
+/// this operand is overwritten with the result.
+/// @param operand_2 2-byte value encoded by the operand.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__MULTIPLY(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
+
+ CONSUME_CYCLES(1);
- CONSUME_CYCLES(1);
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL(operand_1, (_2bytes * operand_2) );
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL(operand_1, (_2bytes * operand_2) );
-
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -378,29 +377,29 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__MULTIPLY(tcomp_udvm_t *udvm, uint32_t operand_1
/// Formula: [DIVIDE (m, n) := floor(m / n)]<br>
///
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
/// this operand is overwritten with the result.
-/// @param operand_2 2-byte value encoded by the operand. Decompression failure occurs if this operand is zero.
+/// @param operand_2 2-byte value encoded by the operand. Decompression failure occurs if this operand is zero.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__DIVIDE(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
+ uint16_t _2bytes;
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- if(!operand_2){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_DIV_BY_ZERO].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_DIV_BY_ZERO);
- return tsk_false;
- }
+ if(!operand_2) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_DIV_BY_ZERO].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_DIV_BY_ZERO);
+ return tsk_false;
+ }
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL(operand_1, (_2bytes / operand_2) );
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL(operand_1, (_2bytes / operand_2) );
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -411,28 +410,28 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__DIVIDE(tcomp_udvm_t *udvm, uint32_t operand_1,
/// Formula: [REMAINDER (m, n) := m - n * floor(m / n)]<br>
///
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param operand_1 2-byte value encoded by the operand. After the operation is complete, the 2-byte word at the memory address specified by
-/// this operand is overwritten with the result.
+/// this operand is overwritten with the result.
/// @param operand_2 2-byte value encoded by the operand. Decompression failure occurs if this operand is zero.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__REMAINDER(tcomp_udvm_t *udvm, uint32_t operand_1, uint32_t operand_2)
{
- uint16_t _2bytes;
- CONSUME_CYCLES(1);
+ uint16_t _2bytes;
+ CONSUME_CYCLES(1);
- if(!operand_2){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_DIV_BY_ZERO].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_DIV_BY_ZERO);
- return tsk_false;
- }
+ if(!operand_2) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_DIV_BY_ZERO].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_DIV_BY_ZERO);
+ return tsk_false;
+ }
- GET_2BYTES_VAL(operand_1, _2bytes);
- SET_2BYTES_VAL(operand_1, (_2bytes % operand_2) );
+ GET_2BYTES_VAL(operand_1, _2bytes);
+ SET_2BYTES_VAL(operand_1, (_2bytes % operand_2) );
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -443,66 +442,71 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__REMAINDER(tcomp_udvm_t *udvm, uint32_t operand_
///
/// This instruction sort lists of 2-byte words in ascending order.
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param start The starting memory address of the block of data to be sorted.
-/// @param n Number of lists.
-/// @param k Lists length (2-byte words).
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param start The starting memory address of the block of data to be sorted.
+/// @param n Number of lists.
+/// @param k Lists length (2-byte words).
///
/// @retval True if succeed, otherwise return false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__SORT_ASCENDING(tcomp_udvm_t *udvm, uint32_t start, uint32_t n, uint32_t k)
{
- tsk_bool_t segfault = tsk_false;
- uint16_t* list_temp = tsk_null;
- IndexValuePair_t *list1_values = tsk_null;
- uint32_t list_index, list_el;
- uint32_t j, pos;
-
- CONSUME_CYCLES(( 1 + k *(CEILLINGLOG2(k) + n) )); /* 1 + k * (ceiling(log2(k)) + n) */
-
- if(TCOMP_UDVM_GET_SIZE() <= (tsk_size_t)(start+(n*k*2)) ){
- segfault = tsk_true;
- goto __SEGFAULT;
- };
-
- //
- // Create FirstList with key-value pairs
- //
- list1_values = (IndexValuePair_t*)tsk_calloc(k, sizeof(IndexValuePair_t));
- if(!list1_values) { segfault = tsk_true; goto __SEGFAULT; };
- for(j=0, pos=0; pos<k; j+=2,pos++){
- list1_values[pos].index = pos;
- GET_2BYTES_VAL((start+j), list1_values[pos].value);
- }
-
- /*
- * Sort Fisrt List Values
- */
- qsort(list1_values, k, sizeof(IndexValuePair_t), SortAscendingPredicate);
-
- /* Sort all lists */
- list_temp = tsk_calloc(k, sizeof(uint32_t));
- if(!list1_values) { segfault = tsk_true; goto __SEGFAULT; };
- for(list_index = 0; list_index < n; list_index++){
- uint16_t* list_start = (uint16_t*)TCOMP_UDVM_GET_BUFFER_AT( start + (list_index*k*2) );
- memcpy(list_temp, list_start, k*2);
- for(list_el=0; list_el<k; list_el++){
- list_start[(list_el)] = list_temp[ list1_values[list_el].index ];
- }
- }
+ tsk_bool_t segfault = tsk_false;
+ uint16_t* list_temp = tsk_null;
+ IndexValuePair_t *list1_values = tsk_null;
+ uint32_t list_index, list_el;
+ uint32_t j, pos;
+
+ CONSUME_CYCLES(( 1 + k *(CEILLINGLOG2(k) + n) )); /* 1 + k * (ceiling(log2(k)) + n) */
+
+ if(TCOMP_UDVM_GET_SIZE() <= (tsk_size_t)(start+(n*k*2)) ) {
+ segfault = tsk_true;
+ goto __SEGFAULT;
+ };
+
+ //
+ // Create FirstList with key-value pairs
+ //
+ list1_values = (IndexValuePair_t*)tsk_calloc(k, sizeof(IndexValuePair_t));
+ if(!list1_values) {
+ segfault = tsk_true;
+ goto __SEGFAULT;
+ };
+ for(j=0, pos=0; pos<k; j+=2,pos++) {
+ list1_values[pos].index = pos;
+ GET_2BYTES_VAL((start+j), list1_values[pos].value);
+ }
+
+ /*
+ * Sort Fisrt List Values
+ */
+ qsort(list1_values, k, sizeof(IndexValuePair_t), SortAscendingPredicate);
+
+ /* Sort all lists */
+ list_temp = tsk_calloc(k, sizeof(uint32_t));
+ if(!list1_values) {
+ segfault = tsk_true;
+ goto __SEGFAULT;
+ };
+ for(list_index = 0; list_index < n; list_index++) {
+ uint16_t* list_start = (uint16_t*)TCOMP_UDVM_GET_BUFFER_AT( start + (list_index*k*2) );
+ memcpy(list_temp, list_start, k*2);
+ for(list_el=0; list_el<k; list_el++) {
+ list_start[(list_el)] = list_temp[ list1_values[list_el].index ];
+ }
+ }
__SEGFAULT:
- TSK_FREE(list_temp);
- TSK_FREE(list1_values);
-
- if(segfault)
- {
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
+ TSK_FREE(list_temp);
+ TSK_FREE(list1_values);
+
+ if(segfault) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -513,61 +517,70 @@ __SEGFAULT:
///
/// This instruction sort lists of 2-byte words in descending order.
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param start The starting memory address of the block of data to be sorted.
-/// @param n Number of lists.
-/// @param k Lists length (2-byte words).
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param start The starting memory address of the block of data to be sorted.
+/// @param n Number of lists.
+/// @param k Lists length (2-byte words).
///
/// @retval True if succeed, otherwise return false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__SORT_DESCENDING(tcomp_udvm_t *udvm, uint32_t start, uint32_t n, uint32_t k)
{
- tsk_bool_t segfault = tsk_false;
- uint16_t* list_temp = tsk_null;
- IndexValuePair_t *list1_values = tsk_null;
- uint32_t list_index, list_el;
- uint32_t j, pos;
-
- CONSUME_CYCLES(( 1 + k *(CEILLINGLOG2(k) + n) )); // 1 + k * (ceiling(log2(k)) + n)
-
- if(TCOMP_UDVM_GET_SIZE() <= (tsk_size_t)(start+(n*k*2)) ){ segfault = tsk_true; goto __SEGFAULT; };
-
- //
- // Create FirstList with key-value pairs.
- //
- list1_values = (IndexValuePair_t*)tsk_calloc(k, sizeof(IndexValuePair_t));
- if(!list1_values) { segfault = tsk_true; goto __SEGFAULT; };
- for(j=0, pos=0; pos<k; j+=2,pos++){
- list1_values[pos].index = pos;
- GET_2BYTES_VAL((start+j), list1_values[pos].value);
- }
-
- // Sort Fisrt List Values.
- qsort(list1_values, k, sizeof(IndexValuePair_t), SortDescendingPredicate);
-
-
- // Sort all lists
- list_temp = tsk_calloc(k, sizeof(uint16_t));
- if(!list1_values) { segfault = tsk_true; goto __SEGFAULT; };
- for(list_index = 0; list_index < n; list_index++){
- uint16_t* list_start = (uint16_t*)TCOMP_UDVM_GET_BUFFER_AT(start + (list_index*k*2));
- memcpy(list_temp, list_start, k*2);
- for(list_el=0; list_el<k; list_el++){
- list_start[(list_el)] = list_temp[ list1_values[list_el].index ];
- }
- }
+ tsk_bool_t segfault = tsk_false;
+ uint16_t* list_temp = tsk_null;
+ IndexValuePair_t *list1_values = tsk_null;
+ uint32_t list_index, list_el;
+ uint32_t j, pos;
+
+ CONSUME_CYCLES(( 1 + k *(CEILLINGLOG2(k) + n) )); // 1 + k * (ceiling(log2(k)) + n)
+
+ if(TCOMP_UDVM_GET_SIZE() <= (tsk_size_t)(start+(n*k*2)) ) {
+ segfault = tsk_true;
+ goto __SEGFAULT;
+ };
+
+ //
+ // Create FirstList with key-value pairs.
+ //
+ list1_values = (IndexValuePair_t*)tsk_calloc(k, sizeof(IndexValuePair_t));
+ if(!list1_values) {
+ segfault = tsk_true;
+ goto __SEGFAULT;
+ };
+ for(j=0, pos=0; pos<k; j+=2,pos++) {
+ list1_values[pos].index = pos;
+ GET_2BYTES_VAL((start+j), list1_values[pos].value);
+ }
+
+ // Sort Fisrt List Values.
+ qsort(list1_values, k, sizeof(IndexValuePair_t), SortDescendingPredicate);
+
+
+ // Sort all lists
+ list_temp = tsk_calloc(k, sizeof(uint16_t));
+ if(!list1_values) {
+ segfault = tsk_true;
+ goto __SEGFAULT;
+ };
+ for(list_index = 0; list_index < n; list_index++) {
+ uint16_t* list_start = (uint16_t*)TCOMP_UDVM_GET_BUFFER_AT(start + (list_index*k*2));
+ memcpy(list_temp, list_start, k*2);
+ for(list_el=0; list_el<k; list_el++) {
+ list_start[(list_el)] = list_temp[ list1_values[list_el].index ];
+ }
+ }
__SEGFAULT:
- TSK_FREE(list_temp);
- TSK_FREE(list1_values);
+ TSK_FREE(list_temp);
+ TSK_FREE(list1_values);
- if(segfault){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
+ if(segfault) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -577,7 +590,7 @@ __SEGFAULT:
/// Reference: RFC3320 Section 9.1.4<br>
/// This instruction calculates a 20-byte SHA-1 hash [RFC-3174] over the specified area of UDVM memory.
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param position The starting memory address.
/// @param length The length of the byte string over which the SHA-1 hash is calculated.
/// @param destination The starting address to which the resulting 20-byte hash will be copied.
@@ -586,56 +599,56 @@ __SEGFAULT:
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__SHA_1(tcomp_udvm_t *udvm, uint32_t position, uint32_t length, uint32_t destination)
{
- tsk_bool_t ok = tsk_false;
- tsk_sha1context_t sha;
- int32_t err;
- uint8_t Message_Digest[TSK_SHA1_DIGEST_SIZE];
-
- // only check length
- // (destination + length) could be > sizeof(udvm_memory) as copying is done byte by byte and could wrap
- if(!length){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- goto bail;
- }
-
- CONSUME_CYCLES(1 + length);
-
- // The SHA-1 instruction calculates a 20-byte SHA-1 hash [RFC-3174] over the specified area of UDVM memory
- if(udvm->tmp_buff.size < length){
- if(!(udvm->tmp_buff.ptr = tsk_realloc(udvm->tmp_buff.ptr, length))){
- udvm->tmp_buff.size = 0;
- goto bail;
- }
- udvm->tmp_buff.size = length;
- }
-
- if(!(ok = tcomp_udvm_bytecopy_from(udvm, udvm->tmp_buff.ptr, position, length))){
- goto bail;
- }
-
- // Compute SHA-1
- if(!(ok = ((err = tsk_sha1reset(&sha)) == 0))){
- TSK_DEBUG_ERROR("%s: %d", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc, err);
- tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
- goto bail;
- }
- if(!(ok = ((err = tsk_sha1input(&sha, udvm->tmp_buff.ptr, length)) == 0))){
- TSK_DEBUG_ERROR("%s : %d", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc, err);
- tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
- goto bail;
- }
- if(!(ok = ((err = tsk_sha1result(&sha, (uint8_t*)Message_Digest)) == 0))){
- TSK_DEBUG_ERROR("%s : %d", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc, ok);
- tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
- goto bail;
- }
-
- //Copy sha1 result to udvm memory
- ok &= tcomp_udvm_bytecopy_to(udvm, destination, Message_Digest, TSK_SHA1_DIGEST_SIZE);
+ tsk_bool_t ok = tsk_false;
+ tsk_sha1context_t sha;
+ int32_t err;
+ uint8_t Message_Digest[TSK_SHA1_DIGEST_SIZE];
+
+ // only check length
+ // (destination + length) could be > sizeof(udvm_memory) as copying is done byte by byte and could wrap
+ if(!length) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ goto bail;
+ }
+
+ CONSUME_CYCLES(1 + length);
+
+ // The SHA-1 instruction calculates a 20-byte SHA-1 hash [RFC-3174] over the specified area of UDVM memory
+ if(udvm->tmp_buff.size < length) {
+ if(!(udvm->tmp_buff.ptr = tsk_realloc(udvm->tmp_buff.ptr, length))) {
+ udvm->tmp_buff.size = 0;
+ goto bail;
+ }
+ udvm->tmp_buff.size = length;
+ }
+
+ if(!(ok = tcomp_udvm_bytecopy_from(udvm, udvm->tmp_buff.ptr, position, length))) {
+ goto bail;
+ }
+
+ // Compute SHA-1
+ if(!(ok = ((err = tsk_sha1reset(&sha)) == 0))) {
+ TSK_DEBUG_ERROR("%s: %d", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc, err);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
+ goto bail;
+ }
+ if(!(ok = ((err = tsk_sha1input(&sha, udvm->tmp_buff.ptr, length)) == 0))) {
+ TSK_DEBUG_ERROR("%s : %d", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc, err);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
+ goto bail;
+ }
+ if(!(ok = ((err = tsk_sha1result(&sha, (uint8_t*)Message_Digest)) == 0))) {
+ TSK_DEBUG_ERROR("%s : %d", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc, ok);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
+ goto bail;
+ }
+
+ //Copy sha1 result to udvm memory
+ ok &= tcomp_udvm_bytecopy_to(udvm, destination, Message_Digest, TSK_SHA1_DIGEST_SIZE);
bail:
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -646,25 +659,25 @@ bail:
/// This instruction sets a 2-byte word to a certain specified value
/// As usual, MSBs are stored before LSBs in the UDVM memory.
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param address Specifies the starting address of a 2-byte word.
-/// @param value Specifies the value to be loaded into this word.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param address Specifies the starting address of a 2-byte word.
+/// @param value Specifies the value to be loaded into this word.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__LOAD(tcomp_udvm_t *udvm, uint32_t address, uint32_t value)
{
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- if( address >= TCOMP_UDVM_GET_SIZE() ){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
+ if( address >= TCOMP_UDVM_GET_SIZE() ) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
- SET_2BYTES_VAL(address, value);
+ SET_2BYTES_VAL(address, value);
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -676,21 +689,21 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__LOAD(tcomp_udvm_t *udvm, uint32_t address, uint
/// value_0 through to value_n-1 specify the values to load into these words (in the same order as
/// they appear in the instruction).
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param address Starting address of the contiguous 2-byte words.
-/// @param n Number of 2-bytes values to load.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param address Starting address of the contiguous 2-byte words.
+/// @param n Number of 2-bytes values to load.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__MULTILOAD(tcomp_udvm_t *udvm, uint32_t address, uint32_t n)
{
- uint32_t index, _address;
- uint32_t overlap_start = udvm->last_memory_address_of_instruction;
- #define overlap_end udvm->executionPointer
- uint32_t write_start = address;
- uint32_t write_end = (address + (n << 1));
+ uint32_t index, _address;
+ uint32_t overlap_start = udvm->last_memory_address_of_instruction;
+#define overlap_end udvm->executionPointer
+ uint32_t write_start = address;
+ uint32_t write_end = (address + (n << 1));
- CONSUME_CYCLES(1 + n);
+ CONSUME_CYCLES(1 + n);
#define CHECK_MULTILOAD_OVERWRITTEN(__start, __address, __end) \
if(( (__start) <= (__address) && (__address) <= (__end) ) || ( (__start) <= ((__address) + 1) && ((__address) + 1) <= (__end) )){ \
@@ -699,18 +712,18 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__MULTILOAD(tcomp_udvm_t *udvm, uint32_t address,
return tsk_false; \
}
- // tcomp_udvm_opget_multitype_param() will move the execPtr => make the test before the for loop
- CHECK_MULTILOAD_OVERWRITTEN(overlap_start, address, overlap_end);
- CHECK_MULTILOAD_OVERWRITTEN(write_start, udvm->executionPointer, write_end);
-
- for(index = 0, _address = address; index < n; index++ , _address += 2){
- uint32_t value_n = tcomp_udvm_opget_multitype_param(udvm);
- CHECK_MULTILOAD_OVERWRITTEN(overlap_start, _address, overlap_end);
- CHECK_MULTILOAD_OVERWRITTEN(write_start, udvm->executionPointer, write_end);
- SET_2BYTES_VAL(_address, value_n);
- }
+ // tcomp_udvm_opget_multitype_param() will move the execPtr => make the test before the for loop
+ CHECK_MULTILOAD_OVERWRITTEN(overlap_start, address, overlap_end);
+ CHECK_MULTILOAD_OVERWRITTEN(write_start, udvm->executionPointer, write_end);
+
+ for(index = 0, _address = address; index < n; index++ , _address += 2) {
+ uint32_t value_n = tcomp_udvm_opget_multitype_param(udvm);
+ CHECK_MULTILOAD_OVERWRITTEN(overlap_start, _address, overlap_end);
+ CHECK_MULTILOAD_OVERWRITTEN(write_start, udvm->executionPointer, write_end);
+ SET_2BYTES_VAL(_address, value_n);
+ }
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -718,41 +731,41 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__MULTILOAD(tcomp_udvm_t *udvm, uint32_t address,
///
/// @brief <i>PUSH (%value)</i><br><br>
/// Reference: RFC3320 Section 9.2.3<br>
-/// This instruction pushes the value specified by its operand on the stack..
+/// This instruction pushes the value specified by its operand on the stack..
///
/// @date 11/27/2009
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param value 2-byte word to push.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param value 2-byte word to push.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__PUSH(tcomp_udvm_t *udvm, int16_t value)
{
- tsk_bool_t callback = (value>=0);
- uint32_t stack_location, stack_fill;
- if(!callback){
- value = tcomp_udvm_opget_multitype_param(udvm);
- }
+ tsk_bool_t callback = (value>=0);
+ uint32_t stack_location, stack_fill;
+ if(!callback) {
+ value = tcomp_udvm_opget_multitype_param(udvm);
+ }
- CONSUME_CYCLES(callback ? 0 : 1);
+ CONSUME_CYCLES(callback ? 0 : 1);
-
- GET_2BYTES_VAL(TCOMP_UDVM_HEADER_STACK_LOCATION_INDEX, stack_location);
- GET_2BYTES_VAL(stack_location, stack_fill);
- /*
- * copying the value to stack[stack_fill]
- * stack[n] = stack_location+2*n+2
- */
- SET_2BYTES_VAL((stack_location+(2*stack_fill)+2), value);
+ GET_2BYTES_VAL(TCOMP_UDVM_HEADER_STACK_LOCATION_INDEX, stack_location);
+ GET_2BYTES_VAL(stack_location, stack_fill);
- /* increasing stack_fill by 1*/
- SET_2BYTES_VAL(stack_location, (stack_fill+1));
+ /*
+ * copying the value to stack[stack_fill]
+ * stack[n] = stack_location+2*n+2
+ */
+ SET_2BYTES_VAL((stack_location+(2*stack_fill)+2), value);
- return tsk_true;
+ /* increasing stack_fill by 1*/
+ SET_2BYTES_VAL(stack_location, (stack_fill+1));
+
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -760,57 +773,57 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__PUSH(tcomp_udvm_t *udvm, int16_t value)
///
/// @brief <i>POP (%address)</i><br><br>
/// Reference: RFC3320 Section 9.2.3<br>
-/// This instruction pops a value from the stack and then copies the value to the specified memory address..
+/// This instruction pops a value from the stack and then copies the value to the specified memory address..
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param [in,out] value 2-byte word to pop from the stack.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] value 2-byte word to pop from the stack.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__POP(tcomp_udvm_t *udvm, uint32_t* value)
{
- uint32_t address;
- uint32_t stack_location, stack_fill, _value = 0;
-
- tsk_bool_t callback = (value != 0);
-
- CONSUME_CYCLES(callback?0:1);
-
- address = callback ? 0 : tcomp_udvm_opget_multitype_param(udvm);
-
- GET_2BYTES_VAL(TCOMP_UDVM_HEADER_STACK_LOCATION_INDEX, stack_location);
- GET_2BYTES_VAL(stack_location, stack_fill);
-
- /*
- * Decompression failure occurs if stack_fill is
- * zero at the commencement of a popping operation. POP and RETURN pop
- * values from the stack.
- */
- if(stack_fill == 0){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- _value = 0;
- goto end;
- }
-
- /*
- * "Popping" a value from the stack is an abbreviation for decreasing
- * stack_fill by 1, and then using the value stored in stack[stack_fill].
- */
- --stack_fill;
- SET_2BYTES_VAL(stack_location, stack_fill);
- /* stack[n] = stack_location+2*n+2 */
- GET_2BYTES_VAL((stack_location + (2*stack_fill) + 2), _value);
+ uint32_t address;
+ uint32_t stack_location, stack_fill, _value = 0;
+
+ tsk_bool_t callback = (value != 0);
+
+ CONSUME_CYCLES(callback?0:1);
+
+ address = callback ? 0 : tcomp_udvm_opget_multitype_param(udvm);
+
+ GET_2BYTES_VAL(TCOMP_UDVM_HEADER_STACK_LOCATION_INDEX, stack_location);
+ GET_2BYTES_VAL(stack_location, stack_fill);
+
+ /*
+ * Decompression failure occurs if stack_fill is
+ * zero at the commencement of a popping operation. POP and RETURN pop
+ * values from the stack.
+ */
+ if(stack_fill == 0) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ _value = 0;
+ goto end;
+ }
+
+ /*
+ * "Popping" a value from the stack is an abbreviation for decreasing
+ * stack_fill by 1, and then using the value stored in stack[stack_fill].
+ */
+ --stack_fill;
+ SET_2BYTES_VAL(stack_location, stack_fill);
+ /* stack[n] = stack_location+2*n+2 */
+ GET_2BYTES_VAL((stack_location + (2*stack_fill) + 2), _value);
end:
- if(callback){
- *value = _value;
- }
- else{
- SET_2BYTES_VAL(address, _value);
- }
-
- return tsk_true;
+ if(callback) {
+ *value = _value;
+ }
+ else {
+ SET_2BYTES_VAL(address, _value);
+ }
+
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -820,32 +833,32 @@ end:
/// Reference: RFC3320 Section 9.2.4<br>
/// This instruction is used to copy a string of bytes from one part of the UDVM memory to another.
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param position Specifies the memory address of the first byte in the string to be copied.
-/// @param length Specifies the number of bytes to be copied.
-/// @param destination Gives the address to which the first byte in the string will be copied.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param position Specifies the memory address of the first byte in the string to be copied.
+/// @param length Specifies the number of bytes to be copied.
+/// @param destination Gives the address to which the first byte in the string will be copied.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__COPY(tcomp_udvm_t *udvm, uint32_t position, uint32_t length, uint32_t destination)
{
- tsk_bool_t ok = tsk_true;
-
- CONSUME_CYCLES(1+length);
-
- if( (position + length) > (int32_t)TCOMP_UDVM_GET_SIZE() || (destination + length) > (int32_t)TCOMP_UDVM_GET_SIZE() ){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
+ tsk_bool_t ok = tsk_true;
+
+ CONSUME_CYCLES(1+length);
+
+ if( (position + length) > (int32_t)TCOMP_UDVM_GET_SIZE() || (destination + length) > (int32_t)TCOMP_UDVM_GET_SIZE() ) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
- /*
- * The COPY instruction is used to copy a string of bytes from one part
- * of the UDVM memory to another.
- */
- ok &= tcomp_udvm_bytecopy_self(udvm, &destination, position, length);
+ /*
+ * The COPY instruction is used to copy a string of bytes from one part
+ * of the UDVM memory to another.
+ */
+ ok &= tcomp_udvm_bytecopy_self(udvm, &destination, position, length);
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -855,30 +868,30 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__COPY(tcomp_udvm_t *udvm, uint32_t position, uin
/// Reference: RFC3320 Section 9.2.5<br>
/// The COPY-LITERAL instruction behaves as a COPY instruction except
/// that after copying is completed, the value of the destination operand
-/// is replaced by the address to which the next byte of data would be copied..
+/// is replaced by the address to which the next byte of data would be copied..
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param position Specifies the memory address of the first byte in the string to be copied.
-/// @param length Specifies the number of bytes to be copied.
-/// @param destination Gives the address to which the first byte in the string will be copied.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param position Specifies the memory address of the first byte in the string to be copied.
+/// @param length Specifies the number of bytes to be copied.
+/// @param destination Gives the address to which the first byte in the string will be copied.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__COPY_LITERAL(tcomp_udvm_t *udvm, uint32_t position, uint32_t length, uint32_t destination)
{
- tsk_bool_t ok;
- uint32_t destination_index;
-
- CONSUME_CYCLES(1+length);
-
- GET_2BYTES_VAL(destination, destination_index);
- ok = tcomp_udvm_bytecopy_self(udvm, &destination_index, position, length);
- if(ok){
- /* set next byte */
- SET_2BYTES_VAL(destination, destination_index);
- }
-
- return ok;
+ tsk_bool_t ok;
+ uint32_t destination_index;
+
+ CONSUME_CYCLES(1+length);
+
+ GET_2BYTES_VAL(destination, destination_index);
+ ok = tcomp_udvm_bytecopy_self(udvm, &destination_index, position, length);
+ if(ok) {
+ /* set next byte */
+ SET_2BYTES_VAL(destination, destination_index);
+ }
+
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -887,90 +900,90 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__COPY_LITERAL(tcomp_udvm_t *udvm, uint32_t posit
/// @brief <i>COPY-OFFSET(%offset, %length, $destination)</i><br><br>
/// Reference: RFC3320 Section 9.2.6<br>
/// This instruction behaves as a COPY-LITERAL instruction
-/// except that an offset operand is given instead of a position operand..
+/// except that an offset operand is given instead of a position operand..
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param offset The offset value.
-/// @param length Specifies the number of bytes to be copied.
-/// @param destination Gives the address to which the first byte in the string will be copied.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param offset The offset value.
+/// @param length Specifies the number of bytes to be copied.
+/// @param destination Gives the address to which the first byte in the string will be copied.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__COPY_OFFSET(tcomp_udvm_t *udvm, uint32_t offset, uint32_t length, uint32_t destination)
{
- uint32_t DEST, LEFT, RIGTH;
- int32_t position = -1;
- uint32_t destination_index;
-
- int32_t D, T;
- int32_t O;
-
- CONSUME_CYCLES(1+length);
-
- GET_2BYTES_VAL(destination, DEST);
- GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX, LEFT);
- GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX, RIGTH);
-
- /*
- DEST: ses
- D: distance between LEFT and DEST
- O: offset
- T: total size between LEFT and RIGTH
-
- [*****
- case 1:
- -----LEFT--------DEST------------RIGTH----
- <-----D---->
- <--O->
- <---------------T------------>
- ****]
- [*****
- case 2:
- -----LEFT--------DEST------------RIGTH----
- <-----D---->
- <--------O-------->
- <---------------T------------>
- ****]
- [*****
- case 3:
- -------DEST-----LEFT-------------RIGTH----
- ****]
- */
- D = (DEST - LEFT);
- T = (RIGTH - LEFT);
- O = offset;
-
- if( D>=0 && O<=D ){
- /* case 1: easy case */
- position = (DEST-O);
- }
- else if( D>=0 && O>D ){
- /* case 2: */
- double PAD = (D + ((ceil(((double)O-(double)D)/(double)T))*T))-O;
- position = LEFT+(int32_t)PAD;
- }
- else if( D<0 ){
- /* case 3: */
- position = DEST-O;
- }
-
- /* Check position */
- if(position<0){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
-
- /* EXEC_INST__COPY_LITERAL */
- GET_2BYTES_VAL(destination, destination_index);
- if(tcomp_udvm_bytecopy_self(udvm, &destination_index, position, length) == tsk_true){
- SET_2BYTES_VAL(destination, destination_index);
- }
- else{
- return tsk_false;
- }
-
- return tsk_true;
+ uint32_t DEST, LEFT, RIGTH;
+ int32_t position = -1;
+ uint32_t destination_index;
+
+ int32_t D, T;
+ int32_t O;
+
+ CONSUME_CYCLES(1+length);
+
+ GET_2BYTES_VAL(destination, DEST);
+ GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_LEFT_INDEX, LEFT);
+ GET_2BYTES_VAL(TCOMP_UDVM_HEADER_BYTE_COPY_RIGHT_INDEX, RIGTH);
+
+ /*
+ DEST: ses
+ D: distance between LEFT and DEST
+ O: offset
+ T: total size between LEFT and RIGTH
+
+ [*****
+ case 1:
+ -----LEFT--------DEST------------RIGTH----
+ <-----D---->
+ <--O->
+ <---------------T------------>
+ ****]
+ [*****
+ case 2:
+ -----LEFT--------DEST------------RIGTH----
+ <-----D---->
+ <--------O-------->
+ <---------------T------------>
+ ****]
+ [*****
+ case 3:
+ -------DEST-----LEFT-------------RIGTH----
+ ****]
+ */
+ D = (DEST - LEFT);
+ T = (RIGTH - LEFT);
+ O = offset;
+
+ if( D>=0 && O<=D ) {
+ /* case 1: easy case */
+ position = (DEST-O);
+ }
+ else if( D>=0 && O>D ) {
+ /* case 2: */
+ double PAD = (D + ((ceil(((double)O-(double)D)/(double)T))*T))-O;
+ position = LEFT+(int32_t)PAD;
+ }
+ else if( D<0 ) {
+ /* case 3: */
+ position = DEST-O;
+ }
+
+ /* Check position */
+ if(position<0) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+
+ /* EXEC_INST__COPY_LITERAL */
+ GET_2BYTES_VAL(destination, destination_index);
+ if(tcomp_udvm_bytecopy_self(udvm, &destination_index, position, length) == tsk_true) {
+ SET_2BYTES_VAL(destination, destination_index);
+ }
+ else {
+ return tsk_false;
+ }
+
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -984,46 +997,46 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__COPY_OFFSET(tcomp_udvm_t *udvm, uint32_t offset
/// @date 11/27/2009
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param address The destination address.
-/// @param length The number of 1-byte values to set.
-/// @param start_value The starting value.
-/// @param offset The offset used for computation.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param address The destination address.
+/// @param length The number of 1-byte values to set.
+/// @param start_value The starting value.
+/// @param offset The offset used for computation.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__MEMSET(tcomp_udvm_t *udvm, uint32_t address, uint32_t length, uint32_t start_value, uint32_t offset)
{
- uint8_t* seqs_temp;
- uint32_t n;
- tsk_bool_t ok;
-
- CONSUME_CYCLES(1+length);
-
- /*
- * The values Seq[0] to Seq[length - 1] inclusive are each interpreted
- * as a single byte, and then concatenated to form a byte string where
- * the first byte has value Seq[0], the second byte has value Seq[1] and
- * so on up to the last byte which has value Seq[length - 1].
- */
- seqs_temp = tsk_calloc(length, sizeof(uint8_t));
- if(!seqs_temp){
- return tsk_false;
- }
-
- for(n=0; n < length; n++){
- seqs_temp[n] = (start_value + n * offset)%256;
- }
- /*
- * The string is then byte copied into the UDVM memory beginning at the
- * memory address specified as an operand to the MEMSET instruction,
- * obeying the rules of Section 8.4.
- */
- ok = tcomp_udvm_bytecopy_to(udvm, address, seqs_temp, length);
-
- TSK_FREE(seqs_temp);
-
- return ok;
+ uint8_t* seqs_temp;
+ uint32_t n;
+ tsk_bool_t ok;
+
+ CONSUME_CYCLES(1+length);
+
+ /*
+ * The values Seq[0] to Seq[length - 1] inclusive are each interpreted
+ * as a single byte, and then concatenated to form a byte string where
+ * the first byte has value Seq[0], the second byte has value Seq[1] and
+ * so on up to the last byte which has value Seq[length - 1].
+ */
+ seqs_temp = tsk_calloc(length, sizeof(uint8_t));
+ if(!seqs_temp) {
+ return tsk_false;
+ }
+
+ for(n=0; n < length; n++) {
+ seqs_temp[n] = (start_value + n * offset)%256;
+ }
+ /*
+ * The string is then byte copied into the UDVM memory beginning at the
+ * memory address specified as an operand to the MEMSET instruction,
+ * obeying the rules of Section 8.4.
+ */
+ ok = tcomp_udvm_bytecopy_to(udvm, address, seqs_temp, length);
+
+ TSK_FREE(seqs_temp);
+
+ return ok;
}
/**
@@ -1032,27 +1045,27 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__MEMSET(tcomp_udvm_t *udvm, uint32_t address, ui
* This instruction moves program execution to the specified memory address.
* Decompression failure occurs if the value of the address operand lies
* beyond the overall UDVM memory size.
-* @param [in,out] udvm The udvm state machine entity.
+* @param [in,out] udvm The udvm state machine entity.
* @param address defines the address to jump to
* @retval 1 if succeed, otherwise returns 0
*/
tsk_bool_t TCOMP_UDVM_EXEC_INST__JUMP(tcomp_udvm_t *udvm, int16_t address)
{
- int callback = (address >=0 );
- CONSUME_CYCLES(callback?0:1);
+ int callback = (address >=0 );
+ CONSUME_CYCLES(callback?0:1);
- if(!callback){
- address = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- }
-
- if(address > (int32_t)TCOMP_UDVM_GET_SIZE()){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- udvm->executionPointer = address;
+ if(!callback) {
+ address = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ }
+
+ if(address > (int32_t)TCOMP_UDVM_GET_SIZE()) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ udvm->executionPointer = address;
- return tsk_true;
+ return tsk_true;
}
@@ -1060,45 +1073,45 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__JUMP(tcomp_udvm_t *udvm, int16_t address)
*
* @brief <i>COMPARE(%value_1, %value_2, \@address_1, \@address_2, \@address_3)</i><br><br>
* Reference: RFC3320 Section 9.3.2<br>
- *
+ *
* This instruction compares two operands and then jumps to one of three specified
* memory addresses depending on the result.<br>
* if(value_1 < value_2) --> address_1<br>
* elif(value_1 = value_2) --> address_2<br>
- * elif(value_1 > value_2) --> address_3. <br>
+ * elif(value_1 > value_2) --> address_3. <br>
*
*
- * @param [in,out] udvm The udvm state machine entity.
- * @param value_1 The first value to compare.
- * @param value_2 The second value to compare.
- * @param address_1 The address to jump to if (value_1 < value_2).
- * @param address_2 The address to jump to if (value_1 = value_2).
- * @param address_3 address to jump to if (value_1 > value_2).
+ * @param [in,out] udvm The udvm state machine entity.
+ * @param value_1 The first value to compare.
+ * @param value_2 The second value to compare.
+ * @param address_1 The address to jump to if (value_1 < value_2).
+ * @param address_2 The address to jump to if (value_1 = value_2).
+ * @param address_3 address to jump to if (value_1 > value_2).
* @retval 1 if succeed, otherwise returns 0.
**/
tsk_bool_t TCOMP_UDVM_EXEC_INST__COMPARE(tcomp_udvm_t *udvm, uint32_t value_1, uint32_t value_2, uint32_t address_1, uint32_t address_2, uint32_t address_3)
{
- tsk_bool_t ok = 1;
+ tsk_bool_t ok = 1;
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- if(value_1 < value_2){
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address_1);
- goto end;
- }
+ if(value_1 < value_2) {
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address_1);
+ goto end;
+ }
- if(value_1 == value_2){
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address_2);
- goto end;
- }
+ if(value_1 == value_2) {
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address_2);
+ goto end;
+ }
- if(value_1 > value_2){
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address_3);
- goto end;
- }
+ if(value_1 > value_2) {
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address_3);
+ goto end;
+ }
end:
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1106,21 +1119,21 @@ end:
///
/// @brief <i>CALL(\@address)</i><br><br>
/// Reference: RFC3320 Section 9.3.3<br>
-/// This instruction finds the memory address of the instruction immediately following
-/// the CALL instruction and pushes this 2-byte value on the stack, ready for later retrieval.
-/// It then continues instruction execution at the memory address specified by the address operand..
+/// This instruction finds the memory address of the instruction immediately following
+/// the CALL instruction and pushes this 2-byte value on the stack, ready for later retrieval.
+/// It then continues instruction execution at the memory address specified by the address operand..
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param address The next address.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param address The next address.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__CALL(tcomp_udvm_t *udvm, uint32_t address)
{
- CONSUME_CYCLES(1);
+ CONSUME_CYCLES(1);
- return TCOMP_UDVM_EXEC_INST__PUSH(udvm, udvm->executionPointer)
- && TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
+ return TCOMP_UDVM_EXEC_INST__PUSH(udvm, udvm->executionPointer)
+ && TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1128,25 +1141,25 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__CALL(tcomp_udvm_t *udvm, uint32_t address)
///
/// @brief <i>RETURN</i><br><br>
/// Reference: RFC3320 Section 9.3.3<br>
-/// This instruction pops a value from the stack and then continues instruction
-/// execution at the memory address just popped..
+/// This instruction pops a value from the stack and then continues instruction
+/// execution at the memory address just popped..
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
///
-/// @retval True if succeed, otherwise return false .
+/// @retval True if succeed, otherwise return false .
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__RETURN(tcomp_udvm_t *udvm)
{
- uint32_t value = 0;
- tsk_bool_t ok = tsk_true;
+ uint32_t value = 0;
+ tsk_bool_t ok = tsk_true;
- CONSUME_CYCLES(1);
-
- if( (ok = TCOMP_UDVM_EXEC_INST__POP(udvm, &value)) ){
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, value);
- }
+ CONSUME_CYCLES(1);
+
+ if( (ok = TCOMP_UDVM_EXEC_INST__POP(udvm, &value)) ) {
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, value);
+ }
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1156,40 +1169,40 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__RETURN(tcomp_udvm_t *udvm)
/// Reference: RFC3320 Section 9.3.4<br>
/// This instruction performs a conditional jump based on the value of one of its operands.
/// Decompression failure occurs if j specifies a value of n or more, or
-/// if the address lies beyond the overall UDVM memory size..
+/// if the address lies beyond the overall UDVM memory size..
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param n The number of possibilities.
-/// @param j The possibility.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param n The number of possibilities.
+/// @param j The possibility.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__SWITCH(tcomp_udvm_t *udvm, uint32_t n, uint32_t j)
{
- uint32_t next = 0;
- tsk_bool_t ok = tsk_true;
+ uint32_t next = 0;
+ tsk_bool_t ok = tsk_true;
- CONSUME_CYCLES(1+n);
+ CONSUME_CYCLES(1+n);
- /* Decompression failure occurs if j specifies a value of n or more. */
- if(j >= n){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SWITCH_VALUE_TOO_HIGH].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SWITCH_VALUE_TOO_HIGH);
- ok = tsk_false;
- goto end;
- }
+ /* Decompression failure occurs if j specifies a value of n or more. */
+ if(j >= n) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SWITCH_VALUE_TOO_HIGH].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SWITCH_VALUE_TOO_HIGH);
+ ok = tsk_false;
+ goto end;
+ }
- do{
- next = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
- }
- while(j--);
+ do {
+ next = tcomp_udvm_opget_address_param(udvm, udvm->last_memory_address_of_instruction);
+ }
+ while(j--);
end:
- if(ok){
- ok = TCOMP_UDVM_EXEC_INST__JUMP(udvm, next);
- }
+ if(ok) {
+ ok = TCOMP_UDVM_EXEC_INST__JUMP(udvm, next);
+ }
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1198,9 +1211,9 @@ end:
/// @brief <i>CRC(%value, %position, %length, \@address)</i><br><br>
/// Reference: RFC3320 Section 9.3.5<br>
/// This instruction verifies a string of bytes using a 2-byte CRC.
-/// The CRC value is computed exactly as defined for the 16-bit FCS calculation in [RFC-1662]..
+/// The CRC value is computed exactly as defined for the 16-bit FCS calculation in [RFC-1662]..
///
-/// @param [in,out] udvm The udvm state machine entity.
+/// @param [in,out] udvm The udvm state machine entity.
/// @param value Contains the expected integer value of the 2-byte CRC.
/// @param position Defines the position of the string of bytes over which the CRC is evaluated.
/// @param length Defines the length of the string of bytes over which the CRC is evaluated.
@@ -1210,42 +1223,42 @@ end:
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__CRC(tcomp_udvm_t *udvm, uint32_t value, uint32_t position, uint32_t length, uint32_t address)
{
- uint32_t crc_value;
-
- CONSUME_CYCLES(1 + length);
-
- if(udvm->tmp_buff.size < length){
- if(!(udvm->tmp_buff.ptr = tsk_realloc(udvm->tmp_buff.ptr, length))){
- udvm->tmp_buff.size = 0;
- tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc);
- return tsk_false;
- }
- udvm->tmp_buff.size = length;
- }
-
- /* copy data */
- if(!tcomp_udvm_bytecopy_from(udvm, udvm->tmp_buff.ptr, position, length)){
- return tsk_false;
- }
-
- /*
- * The CRC value is computed exactly as defined for the 16-bit FCS
- * calculation in [RFC-1662]
- */
- crc_value = tsk_pppfcs16(TSK_PPPINITFCS16, udvm->tmp_buff.ptr, length);
-
- /*
- * If the calculated CRC matches the expected value then the UDVM
- * continues instruction execution at the following instruction.
- * Otherwise the UDVM jumps to the memory address specified by the
- * address operand.
- */
- if(value != crc_value){
- TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
- }
-
- return tsk_true;
+ uint32_t crc_value;
+
+ CONSUME_CYCLES(1 + length);
+
+ if(udvm->tmp_buff.size < length) {
+ if(!(udvm->tmp_buff.ptr = tsk_realloc(udvm->tmp_buff.ptr, length))) {
+ udvm->tmp_buff.size = 0;
+ tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc);
+ return tsk_false;
+ }
+ udvm->tmp_buff.size = length;
+ }
+
+ /* copy data */
+ if(!tcomp_udvm_bytecopy_from(udvm, udvm->tmp_buff.ptr, position, length)) {
+ return tsk_false;
+ }
+
+ /*
+ * The CRC value is computed exactly as defined for the 16-bit FCS
+ * calculation in [RFC-1662]
+ */
+ crc_value = tsk_pppfcs16(TSK_PPPINITFCS16, udvm->tmp_buff.ptr, length);
+
+ /*
+ * If the calculated CRC matches the expected value then the UDVM
+ * continues instruction execution at the following instruction.
+ * Otherwise the UDVM jumps to the memory address specified by the
+ * address operand.
+ */
+ if(value != crc_value) {
+ TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
+ }
+
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1253,51 +1266,51 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__CRC(tcomp_udvm_t *udvm, uint32_t value, uint32_
///
/// @brief <i>INPUT-BYTES (%length, %destination, \@address)</i><br><br>
/// Reference: RFC3320 Section 9.4.2<br>
-/// This instruction requests a certain number of bytes of compressed data from the decompressor dispatcher.
+/// This instruction requests a certain number of bytes of compressed data from the decompressor dispatcher.
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param length Indicates the requested number of bytes of compressed data.
-/// @param destination Specifies the starting memory address to which they should be copied.
-/// @param address Defines the address to jump to if the instruction requests data that lies beyond the end of the SigComp message.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param length Indicates the requested number of bytes of compressed data.
+/// @param destination Specifies the starting memory address to which they should be copied.
+/// @param address Defines the address to jump to if the instruction requests data that lies beyond the end of the SigComp message.
///
/// @retval True if succeed, otherwise return false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__INPUT_BYTES(tcomp_udvm_t *udvm, uint32_t length, uint32_t destination, uint32_t address)
{
- tsk_bool_t ok = tsk_true;
- const uint8_t* compressedDataAddress;
- uint8_t* destinationAddress;
-
- CONSUME_CYCLES(1+length);
-
- /*
- * If the INPUT-BYTES is encountered after an INPUT-BITS or an INPUT-
- * HUFFMAN instruction has been used, and the dispatcher currently holds
- * a fraction of a byte, then the fraction MUST be discarded before any
- * data is passed to the UDVM. The first byte to be passed is the byte
- * immediately following the discarded data.
- */
- tcomp_buffer_discardBits(udvm->sigCompMessage->remaining_sigcomp_buffer);
-
- compressedDataAddress = tcomp_buffer_readBytes(udvm->sigCompMessage->remaining_sigcomp_buffer, length);
- destinationAddress = TCOMP_UDVM_GET_BUFFER_AT(destination);
- if(compressedDataAddress){
- ok &= tcomp_udvm_bytecopy_to(udvm, destination, compressedDataAddress, length);
- if(ok){
- /* FIXME: (8 * n + 1000) * cycles_per_bit */
- udvm->maximum_UDVM_cycles += ((8 * length /*+ 1000*/) * udvm->stateHandler->sigcomp_parameters->cpbValue);
- }
- }
- else{
- /*
- * If the instruction requests data that lies beyond the end of the
- * SigComp message, no data is returned. Instead the UDVM moves program
- * execution to the address specified by the address operand.
- */
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
- }
-
- return ok;
+ tsk_bool_t ok = tsk_true;
+ const uint8_t* compressedDataAddress;
+ uint8_t* destinationAddress;
+
+ CONSUME_CYCLES(1+length);
+
+ /*
+ * If the INPUT-BYTES is encountered after an INPUT-BITS or an INPUT-
+ * HUFFMAN instruction has been used, and the dispatcher currently holds
+ * a fraction of a byte, then the fraction MUST be discarded before any
+ * data is passed to the UDVM. The first byte to be passed is the byte
+ * immediately following the discarded data.
+ */
+ tcomp_buffer_discardBits(udvm->sigCompMessage->remaining_sigcomp_buffer);
+
+ compressedDataAddress = tcomp_buffer_readBytes(udvm->sigCompMessage->remaining_sigcomp_buffer, length);
+ destinationAddress = TCOMP_UDVM_GET_BUFFER_AT(destination);
+ if(compressedDataAddress) {
+ ok &= tcomp_udvm_bytecopy_to(udvm, destination, compressedDataAddress, length);
+ if(ok) {
+ /* FIXME: (8 * n + 1000) * cycles_per_bit */
+ udvm->maximum_UDVM_cycles += ((8 * length /*+ 1000*/) * udvm->stateHandler->sigcomp_parameters->cpbValue);
+ }
+ }
+ else {
+ /*
+ * If the instruction requests data that lies beyond the end of the
+ * SigComp message, no data is returned. Instead the UDVM moves program
+ * execution to the address specified by the address operand.
+ */
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
+ }
+
+ return ok;
}
/**
@@ -1308,7 +1321,7 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__INPUT_BYTES(tcomp_udvm_t *udvm, uint32_t length
* compressed data from the decompressor dispatcher.
*
*
- * @param [in,out] udvm The udvm state machine entity.
+ * @param [in,out] udvm The udvm state machine entity.
* @param length The length operand indicates the requested number of bits.
Decompression failure occurs if this operand does not lie between 0
and 16 inclusive.
@@ -1317,109 +1330,109 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__INPUT_BYTES(tcomp_udvm_t *udvm, uint32_t length
interpreted as a 2-byte integer ranging from 0 to 2^length - 1, as
explained in Section 8.2.
- * @param address The address of the destination.
+ * @param address The address of the destination.
*
- * @retval 1 if succeed, otherwise returns 0.
+ * @retval 1 if succeed, otherwise returns 0.
**/
tsk_bool_t TCOMP_UDVM_EXEC_INST__INPUT_BITS(tcomp_udvm_t *udvm, uint32_t length, uint32_t destination, uint32_t address)
{
- tsk_bool_t ok = tsk_true;
- uint32_t input_bit_order, reserved;
- uint8_t F_BIT, P_BIT;
- uint8_t* old_P_BIT;
-
- /*
- The input_bit_order register contains the following three flags:
- 0 7 8 15
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | reserved |F|H|P| 68 - 69
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- CONSUME_CYCLES(1);
-
- GET_2BYTES_VAL(TCOMP_UDVM_HEADER_INPUT_BIT_ORDER_INDEX, input_bit_order);
- reserved = (input_bit_order & 0xf8);
- /*
- * Decompression failure occurs if an INPUT-BITS or an INPUT-HUFFMAN
- * instruction is encountered and the input_bit_order register does not
- * lie between 0 and 7 inclusive.
- */
- if(reserved){
- /* MUST BE ZEROS --> Only 3bits --> [0-7] */
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_BAD_INPUT_BITORDER].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_BAD_INPUT_BITORDER);
- return tsk_false;
- }
-
- /* F and P BITS */
- F_BIT = (input_bit_order & 0x0004) ? 1 : 0;
- P_BIT = (input_bit_order & 0x0001);
-
- /*
- * Decompression failure occurs if this operand (length) does not lie between 0
- * and 16 inclusive.
- */
- if(/*length<0 ||*/ length>16){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_OPERAND].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
- return tsk_false;
- }
-
- /*
- * P:The P-bit controls the order in which bits are passed from the
- * dispatcher to the INPUT instructions
- * P=0 --> MSB_TO_LSB
- * P=1 --> LSB_TO_MSB
- */
- old_P_BIT = tcomp_buffer_getP_BIT(udvm->sigCompMessage->remaining_sigcomp_buffer);
- if(*old_P_BIT != P_BIT){
- /*
- * If the P-bit has changed since the last INPUT instruction, any fraction of a
- * byte still held by the dispatcher MUST be discarded (even if the
- * INPUT instruction requests zero bits)
- */
- tcomp_buffer_discardBits(udvm->sigCompMessage->remaining_sigcomp_buffer);
- *old_P_BIT = P_BIT;
- }
-
- /*
- * If the instruction requests data that lies beyond the end of the
- * SigComp message, no data is returned. Instead the UDVM moves program
- * execution to the address specified by the address operand.
- */
- if( (length) > tcomp_buffer_getRemainingBits(udvm->sigCompMessage->remaining_sigcomp_buffer) ){
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
- goto end;
- }
-
- /*
- * If the F-bit is set to 0, the INPUT-BITS instruction interprets the
- * received bits as arriving MSBs first, and if it is set to 1, it interprets the bits as arriving LSBs first.
- * F=0 --> MSB_TO_LSB
- * F=1 --> LSB_TO_MSB
- */
- if(P_BIT == TCOMP_P_BIT_MSB_TO_LSB){
- /* MSB_TO_LSB */
- uint32_t value = tcomp_buffer_readMsbToLsb(udvm->sigCompMessage->remaining_sigcomp_buffer, length);
- if(F_BIT == F_BIT_LSB_TO_MSB){
- value = (TSK_BINARY_REVERSE_2BYTE(value)>>(16-length));
- }
- SET_2BYTES_VAL(destination, value);
- }
- else{
- /* LSB_TO_MSB */
- uint32_t value = tcomp_buffer_readLsbToMsb(udvm->sigCompMessage->remaining_sigcomp_buffer, length);
- if(F_BIT == F_BIT_LSB_TO_MSB) {
- value = (TSK_BINARY_REVERSE_2BYTE(value)>>(16-length));
- }
- SET_2BYTES_VAL(destination, value);
- }
+ tsk_bool_t ok = tsk_true;
+ uint32_t input_bit_order, reserved;
+ uint8_t F_BIT, P_BIT;
+ uint8_t* old_P_BIT;
+
+ /*
+ The input_bit_order register contains the following three flags:
+ 0 7 8 15
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | reserved |F|H|P| 68 - 69
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ CONSUME_CYCLES(1);
+
+ GET_2BYTES_VAL(TCOMP_UDVM_HEADER_INPUT_BIT_ORDER_INDEX, input_bit_order);
+ reserved = (input_bit_order & 0xf8);
+ /*
+ * Decompression failure occurs if an INPUT-BITS or an INPUT-HUFFMAN
+ * instruction is encountered and the input_bit_order register does not
+ * lie between 0 and 7 inclusive.
+ */
+ if(reserved) {
+ /* MUST BE ZEROS --> Only 3bits --> [0-7] */
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_BAD_INPUT_BITORDER].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_BAD_INPUT_BITORDER);
+ return tsk_false;
+ }
+
+ /* F and P BITS */
+ F_BIT = (input_bit_order & 0x0004) ? 1 : 0;
+ P_BIT = (input_bit_order & 0x0001);
+
+ /*
+ * Decompression failure occurs if this operand (length) does not lie between 0
+ * and 16 inclusive.
+ */
+ if(/*length<0 ||*/ length>16) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_OPERAND].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
+ return tsk_false;
+ }
+
+ /*
+ * P:The P-bit controls the order in which bits are passed from the
+ * dispatcher to the INPUT instructions
+ * P=0 --> MSB_TO_LSB
+ * P=1 --> LSB_TO_MSB
+ */
+ old_P_BIT = tcomp_buffer_getP_BIT(udvm->sigCompMessage->remaining_sigcomp_buffer);
+ if(*old_P_BIT != P_BIT) {
+ /*
+ * If the P-bit has changed since the last INPUT instruction, any fraction of a
+ * byte still held by the dispatcher MUST be discarded (even if the
+ * INPUT instruction requests zero bits)
+ */
+ tcomp_buffer_discardBits(udvm->sigCompMessage->remaining_sigcomp_buffer);
+ *old_P_BIT = P_BIT;
+ }
+
+ /*
+ * If the instruction requests data that lies beyond the end of the
+ * SigComp message, no data is returned. Instead the UDVM moves program
+ * execution to the address specified by the address operand.
+ */
+ if( (length) > tcomp_buffer_getRemainingBits(udvm->sigCompMessage->remaining_sigcomp_buffer) ) {
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
+ goto end;
+ }
+
+ /*
+ * If the F-bit is set to 0, the INPUT-BITS instruction interprets the
+ * received bits as arriving MSBs first, and if it is set to 1, it interprets the bits as arriving LSBs first.
+ * F=0 --> MSB_TO_LSB
+ * F=1 --> LSB_TO_MSB
+ */
+ if(P_BIT == TCOMP_P_BIT_MSB_TO_LSB) {
+ /* MSB_TO_LSB */
+ uint32_t value = tcomp_buffer_readMsbToLsb(udvm->sigCompMessage->remaining_sigcomp_buffer, length);
+ if(F_BIT == F_BIT_LSB_TO_MSB) {
+ value = (TSK_BINARY_REVERSE_2BYTE(value)>>(16-length));
+ }
+ SET_2BYTES_VAL(destination, value);
+ }
+ else {
+ /* LSB_TO_MSB */
+ uint32_t value = tcomp_buffer_readLsbToMsb(udvm->sigCompMessage->remaining_sigcomp_buffer, length);
+ if(F_BIT == F_BIT_LSB_TO_MSB) {
+ value = (TSK_BINARY_REVERSE_2BYTE(value)>>(16-length));
+ }
+ SET_2BYTES_VAL(destination, value);
+ }
end:
-
- udvm->maximum_UDVM_cycles += (length * udvm->stateHandler->sigcomp_parameters->cpbValue);
- return ok;
+
+ udvm->maximum_UDVM_cycles += (length * udvm->stateHandler->sigcomp_parameters->cpbValue);
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1427,170 +1440,170 @@ end:
///
/// @brief <i>INPUT-HUFFMAN(%destination, \@address, \#n, %bits_1, %lower_bound_1, %upper_bound_1, %uncompressed_1, ... , %bits_n, %lower_bound_n, %upper_bound_n, %uncompressed_n)</i><br><br>
/// Reference: RFC3320 Section 9.4.4<br>
-///
+///
/// This instruction requests a variable number of bits of compressed data from the decompressor dispatcher. The instruction
/// initially requests a small number of bits and compares the result against a certain criterion; if the criterion is not met, then
-/// additional bits are requested until the criterion is achieved.
+/// additional bits are requested until the criterion is achieved.
///
-/// @param [in,out] udvm The udvm state machine entity.
-/// @param destination The udvm destination address.
-/// @param address Address to jump to if data is requested that lies beyond the end of the SigComp message.
-/// @param n Additional sets of operands count.
+/// @param [in,out] udvm The udvm state machine entity.
+/// @param destination The udvm destination address.
+/// @param address Address to jump to if data is requested that lies beyond the end of the SigComp message.
+/// @param n Additional sets of operands count.
///
-/// @retval True if succeed, otherwise return false.
+/// @retval True if succeed, otherwise return false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__INPUT_HUFFMAN(tcomp_udvm_t *udvm, uint32_t destination, uint32_t address, uint32_t n)
{
- /*
- The input_bit_order register contains the following three flags:
- 0 7 8 15
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | reserved |F|H|P| 68 - 69
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- tsk_bool_t ok = tsk_true;
- uint32_t input_bit_order, reserved;
- uint8_t H_BIT, P_BIT, *old_P_BIT;
-
- uint32_t bits_j, lower_bound_j, upper_bound_j, uncompressed_j;
- uint32_t bits_total = 0, k = 0, H, J;
- tsk_bool_t criterion_ok = tsk_false;
-
- CONSUME_CYCLES(1+n);
-
- /*Note that if n = 0 then the INPUT-HUFFMAN instruction is ignored and
- program execution resumes at the following instruction.*/
- if(n == 0){
- //goto end;
- return ok;
- }
-
- GET_2BYTES_VAL(TCOMP_UDVM_HEADER_INPUT_BIT_ORDER_INDEX, input_bit_order);
- reserved = (input_bit_order & 0xf8);
- /*
- * Decompression failure occurs if an INPUT-BITS or an INPUT-HUFFMAN
- * instruction is encountered and the input_bit_order register does not
- * lie between 0 and 7 inclusive.
- */
- if(reserved){
- /* MUST BE ZEROS --> Only 3bits --> [0-7] */
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_BAD_INPUT_BITORDER].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_BAD_INPUT_BITORDER);
- return tsk_false;
- }
-
- /* H and P */
- H_BIT = (input_bit_order & 0x0002)?1:0;
- P_BIT = (input_bit_order & 0x0001);
-
- /*
- * P:The P-bit controls the order in which bits are passed from the
- * dispatcher to the INPUT instructions
- * P=0 --> MSB_TO_LSB
- * P=1 --> LSB_TO_MSB
- */
- old_P_BIT = tcomp_buffer_getP_BIT(udvm->sigCompMessage->remaining_sigcomp_buffer);
- if( *old_P_BIT != P_BIT ){
- /*
- * If the P-bit has changed since the last INPUT instruction, any fraction of a
- * byte still held by the dispatcher MUST be discarded (even if the
- * INPUT instruction requests zero bits)
- */
- tcomp_buffer_discardBits(udvm->sigCompMessage->remaining_sigcomp_buffer);
- *old_P_BIT = P_BIT;
- }
-
- /*
- * HUFFMAN COMPUTATION
- */
-
- /* 1. Set j := 1 and set H := 0. */
- for(J = 1, H = 0; J<=n; J++){
- /*
- * Request bits_j compressed bits. Interpret the returned bits as an
- * integer k from 0 to 2^bits_j - 1, as explained in Section 8.2.
- */
- bits_j = tcomp_udvm_opget_multitype_param(udvm);
- lower_bound_j = tcomp_udvm_opget_multitype_param(udvm);
- upper_bound_j = tcomp_udvm_opget_multitype_param(udvm);
- uncompressed_j = tcomp_udvm_opget_multitype_param(udvm);
- bits_total += bits_j;
-
- /*Decompression failure occurs if (bits_1 + ... + bits_n) > 16.*/
- if(bits_total > 16){
- ok = tsk_false;
- // FIXME: DECOMPRESSION failure TOO_MANY_BITS_REQUESTED
- goto end;
- }
-
- if(criterion_ok){
- continue;
- }
+ /*
+ The input_bit_order register contains the following three flags:
+ 0 7 8 15
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | reserved |F|H|P| 68 - 69
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ tsk_bool_t ok = tsk_true;
+ uint32_t input_bit_order, reserved;
+ uint8_t H_BIT, P_BIT, *old_P_BIT;
+
+ uint32_t bits_j, lower_bound_j, upper_bound_j, uncompressed_j;
+ uint32_t bits_total = 0, k = 0, H, J;
+ tsk_bool_t criterion_ok = tsk_false;
+
+ CONSUME_CYCLES(1+n);
+
+ /*Note that if n = 0 then the INPUT-HUFFMAN instruction is ignored and
+ program execution resumes at the following instruction.*/
+ if(n == 0) {
+ //goto end;
+ return ok;
+ }
+
+ GET_2BYTES_VAL(TCOMP_UDVM_HEADER_INPUT_BIT_ORDER_INDEX, input_bit_order);
+ reserved = (input_bit_order & 0xf8);
+ /*
+ * Decompression failure occurs if an INPUT-BITS or an INPUT-HUFFMAN
+ * instruction is encountered and the input_bit_order register does not
+ * lie between 0 and 7 inclusive.
+ */
+ if(reserved) {
+ /* MUST BE ZEROS --> Only 3bits --> [0-7] */
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_BAD_INPUT_BITORDER].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_BAD_INPUT_BITORDER);
+ return tsk_false;
+ }
+
+ /* H and P */
+ H_BIT = (input_bit_order & 0x0002)?1:0;
+ P_BIT = (input_bit_order & 0x0001);
+
+ /*
+ * P:The P-bit controls the order in which bits are passed from the
+ * dispatcher to the INPUT instructions
+ * P=0 --> MSB_TO_LSB
+ * P=1 --> LSB_TO_MSB
+ */
+ old_P_BIT = tcomp_buffer_getP_BIT(udvm->sigCompMessage->remaining_sigcomp_buffer);
+ if( *old_P_BIT != P_BIT ) {
+ /*
+ * If the P-bit has changed since the last INPUT instruction, any fraction of a
+ * byte still held by the dispatcher MUST be discarded (even if the
+ * INPUT instruction requests zero bits)
+ */
+ tcomp_buffer_discardBits(udvm->sigCompMessage->remaining_sigcomp_buffer);
+ *old_P_BIT = P_BIT;
+ }
+
+ /*
+ * HUFFMAN COMPUTATION
+ */
+
+ /* 1. Set j := 1 and set H := 0. */
+ for(J = 1, H = 0; J<=n; J++) {
+ /*
+ * Request bits_j compressed bits. Interpret the returned bits as an
+ * integer k from 0 to 2^bits_j - 1, as explained in Section 8.2.
+ */
+ bits_j = tcomp_udvm_opget_multitype_param(udvm);
+ lower_bound_j = tcomp_udvm_opget_multitype_param(udvm);
+ upper_bound_j = tcomp_udvm_opget_multitype_param(udvm);
+ uncompressed_j = tcomp_udvm_opget_multitype_param(udvm);
+ bits_total += bits_j;
+
+ /*Decompression failure occurs if (bits_1 + ... + bits_n) > 16.*/
+ if(bits_total > 16) {
+ ok = tsk_false;
+ // FIXME: DECOMPRESSION failure TOO_MANY_BITS_REQUESTED
+ goto end;
+ }
+
+ if(criterion_ok) {
+ continue;
+ }
//==step_4:
- /*
- * 4.If data is requested that lies beyond the end of the SigComp
- * message, terminate the INPUT-HUFFMAN instruction and move program
- * execution to the memory address specified by the address operand.
- */
- if( (bits_j) > tcomp_buffer_getRemainingBits(udvm->sigCompMessage->remaining_sigcomp_buffer) ){
- ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
- goto end;
- }
+ /*
+ * 4.If data is requested that lies beyond the end of the SigComp
+ * message, terminate the INPUT-HUFFMAN instruction and move program
+ * execution to the memory address specified by the address operand.
+ */
+ if( (bits_j) > tcomp_buffer_getRemainingBits(udvm->sigCompMessage->remaining_sigcomp_buffer) ) {
+ ok &= TCOMP_UDVM_EXEC_INST__JUMP(udvm, address);
+ goto end;
+ }
//==step_2:
- /*
- * 2. Request bits_j compressed bits. Interpret the returned bits as an
- * integer k from 0 to 2^bits_j - 1, as explained in Section 8.2.
- */
- if(P_BIT == TCOMP_P_BIT_MSB_TO_LSB){
- k = tcomp_buffer_readMsbToLsb(udvm->sigCompMessage->remaining_sigcomp_buffer, bits_j);
- if(H_BIT == H_BIT_LSB_TO_MSB) {
- k = (TSK_BINARY_REVERSE_2BYTE(k)>>(16-bits_j));
- }
- }
- else{
- k = tcomp_buffer_readLsbToMsb(udvm->sigCompMessage->remaining_sigcomp_buffer, bits_j);
- if(H_BIT == H_BIT_LSB_TO_MSB){
- k = (TSK_BINARY_REVERSE_2BYTE(k)>>(16-bits_j));
- }
- }
+ /*
+ * 2. Request bits_j compressed bits. Interpret the returned bits as an
+ * integer k from 0 to 2^bits_j - 1, as explained in Section 8.2.
+ */
+ if(P_BIT == TCOMP_P_BIT_MSB_TO_LSB) {
+ k = tcomp_buffer_readMsbToLsb(udvm->sigCompMessage->remaining_sigcomp_buffer, bits_j);
+ if(H_BIT == H_BIT_LSB_TO_MSB) {
+ k = (TSK_BINARY_REVERSE_2BYTE(k)>>(16-bits_j));
+ }
+ }
+ else {
+ k = tcomp_buffer_readLsbToMsb(udvm->sigCompMessage->remaining_sigcomp_buffer, bits_j);
+ if(H_BIT == H_BIT_LSB_TO_MSB) {
+ k = (TSK_BINARY_REVERSE_2BYTE(k)>>(16-bits_j));
+ }
+ }
//==step_3:
- /* 3. Set H := H * 2^bits_j + k */
- H = H * (uint32_t)pow(2.0, bits_j) + k;
+ /* 3. Set H := H * 2^bits_j + k */
+ H = H * (uint32_t)pow(2.0, bits_j) + k;
//==step_5:
- /*
- * 5. If (H < lower_bound_j) or (H > upper_bound_j) then set j := j + 1.
- * Then go back to Step 2, unless j > n in which case decompression
- * failure occurs.
- */
- if( (H < lower_bound_j) || (H > upper_bound_j) ){
- continue;
- //goto step_2;
- }
- else{
- /*
- * Copy (H + uncompressed_j - lower_bound_j) modulo 2^16 to the
- * memory address specified by the destination operand.
- */
- H = (H + uncompressed_j - lower_bound_j) % 65536;
- criterion_ok = 1;
- }
- }
-
- if(!criterion_ok){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_HUFFMAN_NO_MATCH].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_HUFFMAN_NO_MATCH);
- ok = tsk_false;
- goto end;
- }
- else if(ok){
- SET_2BYTES_VAL(destination, H);
- udvm->maximum_UDVM_cycles += (bits_total * udvm->stateHandler->sigcomp_parameters->cpbValue);
- }
+ /*
+ * 5. If (H < lower_bound_j) or (H > upper_bound_j) then set j := j + 1.
+ * Then go back to Step 2, unless j > n in which case decompression
+ * failure occurs.
+ */
+ if( (H < lower_bound_j) || (H > upper_bound_j) ) {
+ continue;
+ //goto step_2;
+ }
+ else {
+ /*
+ * Copy (H + uncompressed_j - lower_bound_j) modulo 2^16 to the
+ * memory address specified by the destination operand.
+ */
+ H = (H + uncompressed_j - lower_bound_j) % 65536;
+ criterion_ok = 1;
+ }
+ }
+
+ if(!criterion_ok) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_HUFFMAN_NO_MATCH].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_HUFFMAN_NO_MATCH);
+ ok = tsk_false;
+ goto end;
+ }
+ else if(ok) {
+ SET_2BYTES_VAL(destination, H);
+ udvm->maximum_UDVM_cycles += (bits_total * udvm->stateHandler->sigcomp_parameters->cpbValue);
+ }
end:
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1598,119 +1611,119 @@ end:
///
/// @brief <i>STATE-ACCESS(%partial_identifier_start, %partial_identifier_length, %state_begin, %state_length, %state_address, %state_instruction)</i><br><br>
/// Reference: RFC3320 Section 9.4.5<br>
-/// This instruction retrieves some previously stored state information..
+/// This instruction retrieves some previously stored state information..
-/// @param [in,out] udvm If non-null, the udvm.
-/// @param partial_identifier_start Specifies the location of the partial state identifier used to retrieve the state information.
-/// @param partial_identifier_length Specifies the length of the partial state identifier used to retrieve the state information.
-/// @param state_begin Defines the starting byte to copy from the state_value contained in the returned item of state.
-/// @param state_length Defines the number of bytes to copy from the state_value contained in the returned item of state.
-/// @param state_address Contains a UDVM memory address.
-/// @param state_instruction Next instruction to jump to.
+/// @param [in,out] udvm If non-null, the udvm.
+/// @param partial_identifier_start Specifies the location of the partial state identifier used to retrieve the state information.
+/// @param partial_identifier_length Specifies the length of the partial state identifier used to retrieve the state information.
+/// @param state_begin Defines the starting byte to copy from the state_value contained in the returned item of state.
+/// @param state_length Defines the number of bytes to copy from the state_value contained in the returned item of state.
+/// @param state_address Contains a UDVM memory address.
+/// @param state_instruction Next instruction to jump to.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__STATE_ACCESS(tcomp_udvm_t *udvm, uint32_t partial_identifier_start, uint32_t partial_identifier_length, uint32_t state_begin, uint32_t state_length, uint32_t state_address, uint32_t state_instruction)
{
- tcomp_state_t* lpState = NULL;
- tcomp_buffer_handle_t* partial_id;
- uint32_t match_count;
-
- /*
- * Decompression failure occurs if partial_identifier_length does not
- * lie between 6 and 20 inclusive.
- */
- if(partial_identifier_length<6 || partial_identifier_length>20){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_STATE_ID_LENGTH].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_ID_LENGTH);
- return tsk_false;
- }
- /*
- * decompression failure will always occur if the state_length operand
- * is set to 0 but the state_begin operand is non-zero.
- */
- if(!state_length && state_begin){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_STATE_PROBE].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_PROBE);
- return tsk_false;
- }
-
- /*
- * Find matching state
- */
- partial_id = tcomp_buffer_create_null();
- tcomp_buffer_referenceBuff(partial_id, TCOMP_UDVM_GET_BUFFER_AT(partial_identifier_start), partial_identifier_length);
- match_count = tcomp_statehandler_findState(udvm->stateHandler, partial_id, &lpState);
-
- /*
- * Decompression failure occurs if no state item matching the partial state identifier can be found, if
- * more than one state item matches the partial identifier.
- */
- if(!lpState || match_count != 1){
- int32_t nack_code = (match_count > 1) ? NACK_ID_NOT_UNIQUE : NACK_STATE_NOT_FOUND;
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[nack_code].desc);
- tcomp_udvm_createNackInfo3(udvm, nack_code, partial_id);
- TSK_OBJECT_SAFE_FREE(partial_id);
- return tsk_false;
- }
- else if(partial_identifier_length < lpState->minimum_access_length){
- /*
- * Decompression failure occurs if partial_identifier_length is less than the minimum_access_length of
- * the matched state item.
- */
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_STATE_NOT_FOUND].desc);
- tcomp_udvm_createNackInfo3(udvm, NACK_STATE_NOT_FOUND, partial_id);
- TSK_OBJECT_SAFE_FREE(partial_id);
- return tsk_false;
- }
- TSK_OBJECT_SAFE_FREE(partial_id);
-
- /*
- * If any of the operands state_address, state_instruction or
- * state_length is set to 0 then its value is taken from the returned
- * item of state instead.
- */
- if(!state_address) {
- state_address = lpState->address;
- }
- if(!state_instruction) {
- state_instruction = lpState->instruction;
- }
- if(!state_length) {
- state_length = lpState->length;
- }
-
- CONSUME_CYCLES(1+state_length);
-
- /* Decompression failure occurs if bytes are copied from beyond the end of the state_value. */
- if((tsk_size_t)(state_begin + state_length) > tcomp_buffer_getSize(lpState->value)){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_STATE_TOO_SHORT].desc);
- tcomp_udvm_createNackInfo3(udvm, NACK_STATE_TOO_SHORT, partial_id);
- return tsk_false;
- }
-
- /*
- * The state_address operand contains a UDVM memory address. The
- * requested portion of the state_value is byte copied to this memory
- * address using the rules of Section 8.4.
- */
- if(tcomp_udvm_bytecopy_to(udvm, state_address, tcomp_buffer_getBufferAtPos(lpState->value, state_begin), state_length) != tsk_true){
- return tsk_false;
- }
-
- /*
- * Program execution then resumes at the memory address specified by
- * state_instruction, unless this address is 0 in which case program
- * execution resumes at the next instruction following the STATE-ACCESS
- * instruction.
- */
- if(state_instruction){
- if(!TCOMP_UDVM_EXEC_INST__JUMP(udvm, state_instruction)){
- return tsk_false;
- }
- }
-
- return tsk_true;
+ tcomp_state_t* lpState = NULL;
+ tcomp_buffer_handle_t* partial_id;
+ uint32_t match_count;
+
+ /*
+ * Decompression failure occurs if partial_identifier_length does not
+ * lie between 6 and 20 inclusive.
+ */
+ if(partial_identifier_length<6 || partial_identifier_length>20) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_STATE_ID_LENGTH].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_ID_LENGTH);
+ return tsk_false;
+ }
+ /*
+ * decompression failure will always occur if the state_length operand
+ * is set to 0 but the state_begin operand is non-zero.
+ */
+ if(!state_length && state_begin) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_STATE_PROBE].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_PROBE);
+ return tsk_false;
+ }
+
+ /*
+ * Find matching state
+ */
+ partial_id = tcomp_buffer_create_null();
+ tcomp_buffer_referenceBuff(partial_id, TCOMP_UDVM_GET_BUFFER_AT(partial_identifier_start), partial_identifier_length);
+ match_count = tcomp_statehandler_findState(udvm->stateHandler, partial_id, &lpState);
+
+ /*
+ * Decompression failure occurs if no state item matching the partial state identifier can be found, if
+ * more than one state item matches the partial identifier.
+ */
+ if(!lpState || match_count != 1) {
+ int32_t nack_code = (match_count > 1) ? NACK_ID_NOT_UNIQUE : NACK_STATE_NOT_FOUND;
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[nack_code].desc);
+ tcomp_udvm_createNackInfo3(udvm, nack_code, partial_id);
+ TSK_OBJECT_SAFE_FREE(partial_id);
+ return tsk_false;
+ }
+ else if(partial_identifier_length < lpState->minimum_access_length) {
+ /*
+ * Decompression failure occurs if partial_identifier_length is less than the minimum_access_length of
+ * the matched state item.
+ */
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_STATE_NOT_FOUND].desc);
+ tcomp_udvm_createNackInfo3(udvm, NACK_STATE_NOT_FOUND, partial_id);
+ TSK_OBJECT_SAFE_FREE(partial_id);
+ return tsk_false;
+ }
+ TSK_OBJECT_SAFE_FREE(partial_id);
+
+ /*
+ * If any of the operands state_address, state_instruction or
+ * state_length is set to 0 then its value is taken from the returned
+ * item of state instead.
+ */
+ if(!state_address) {
+ state_address = lpState->address;
+ }
+ if(!state_instruction) {
+ state_instruction = lpState->instruction;
+ }
+ if(!state_length) {
+ state_length = lpState->length;
+ }
+
+ CONSUME_CYCLES(1+state_length);
+
+ /* Decompression failure occurs if bytes are copied from beyond the end of the state_value. */
+ if((tsk_size_t)(state_begin + state_length) > tcomp_buffer_getSize(lpState->value)) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_STATE_TOO_SHORT].desc);
+ tcomp_udvm_createNackInfo3(udvm, NACK_STATE_TOO_SHORT, partial_id);
+ return tsk_false;
+ }
+
+ /*
+ * The state_address operand contains a UDVM memory address. The
+ * requested portion of the state_value is byte copied to this memory
+ * address using the rules of Section 8.4.
+ */
+ if(tcomp_udvm_bytecopy_to(udvm, state_address, tcomp_buffer_getBufferAtPos(lpState->value, state_begin), state_length) != tsk_true) {
+ return tsk_false;
+ }
+
+ /*
+ * Program execution then resumes at the memory address specified by
+ * state_instruction, unless this address is 0 in which case program
+ * execution resumes at the next instruction following the STATE-ACCESS
+ * instruction.
+ */
+ if(state_instruction) {
+ if(!TCOMP_UDVM_EXEC_INST__JUMP(udvm, state_instruction)) {
+ return tsk_false;
+ }
+ }
+
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1718,30 +1731,30 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__STATE_ACCESS(tcomp_udvm_t *udvm, uint32_t parti
///
/// @brief <i>STATE-CREATE (%state_length, %state_address, %state_instruction, %minimum_access_length, %state_retention_priority)</i><br><br>
/// Reference: RFC3320 Section 9.4.6<br>
-/// This instruction requests the creation of a state item at the receiving endpoint..
+/// This instruction requests the creation of a state item at the receiving endpoint..
-/// @param [in,out] udvm If non-null, the udvm.
-/// @param state_length Defines the length of the state to create.
-/// @param state_address Defines the udvm address of the state to create.
-/// @param state_instruction Defines the state instruction.
-/// @param minimum_access_length Defines the minimun access length.
-/// @param state_retention_priority Defines the state retenion priority.
+/// @param [in,out] udvm If non-null, the udvm.
+/// @param state_length Defines the length of the state to create.
+/// @param state_address Defines the udvm address of the state to create.
+/// @param state_instruction Defines the state instruction.
+/// @param minimum_access_length Defines the minimun access length.
+/// @param state_retention_priority Defines the state retenion priority.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__STATE_CREATE(tcomp_udvm_t *udvm, uint32_t state_length, uint32_t state_address, uint32_t state_instruction, uint32_t minimum_access_length, uint32_t state_retention_priority)
{
- CONSUME_CYCLES(1 + state_length);
-
- /*
- * Create temporary state?
- */
- if(!tcomp_udvm_createTempState(udvm, state_length, state_address, state_instruction,
- minimum_access_length, state_retention_priority, 0)){
- return tsk_false;
- }
+ CONSUME_CYCLES(1 + state_length);
+
+ /*
+ * Create temporary state?
+ */
+ if(!tcomp_udvm_createTempState(udvm, state_length, state_address, state_instruction,
+ minimum_access_length, state_retention_priority, 0)) {
+ return tsk_false;
+ }
- return tsk_true;
+ return tsk_true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1749,86 +1762,86 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__STATE_CREATE(tcomp_udvm_t *udvm, uint32_t state
///
/// @brief <i>STATE-FREE(%partial_identifier_start, %partial_identifier_length)</i><br><br>
/// Reference: RFC3320 Section 9.4.7<br>
-/// This instruction informs the receiving endpoint that the sender no longer wishes to use a particular state item..
+/// This instruction informs the receiving endpoint that the sender no longer wishes to use a particular state item..
-/// @param [in,out] udvm If non-null, the udvm.
-/// @param partial_identifier_start Defines the first byte address of partial start identifier.
-/// @param partial_identifier_length Defines the partial identifier length.
+/// @param [in,out] udvm If non-null, the udvm.
+/// @param partial_identifier_start Defines the first byte address of partial start identifier.
+/// @param partial_identifier_length Defines the partial identifier length.
///
-/// @retval True if succeed, otherwise return false .
+/// @retval True if succeed, otherwise return false .
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__STATE_FREE(tcomp_udvm_t *udvm, uint32_t partial_identifier_start, uint32_t partial_identifier_length)
{
- tcomp_tempstate_to_free_t *lpDesc;
-
- CONSUME_CYCLES(1);
-
- /*
- * Decompression failure MUST occur if more than four state free
- * requests are made before the END-MESSAGE instruction is encountered.
- */
- if(tcomp_result_getTempStatesToFreeSize(udvm->lpResult) >=4){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_TOO_MANY_STATE_REQUESTS].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_TOO_MANY_STATE_REQUESTS);
- return tsk_false;
- }
-
- /*
- * Decompression failure also occurs if partial_identifier_length does
- * not lie between 6 and 20 inclusive.
- */
- if(partial_identifier_length<6 || partial_identifier_length>20){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_STATE_ID_LENGTH].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_ID_LENGTH);
- return tsk_false;
- }
-
- lpDesc = tcomp_tempstate_to_free_create();
- lpDesc->partial_identifier_length = partial_identifier_length;
- lpDesc->partial_identifier_start = partial_identifier_start;
- tcomp_result_addTempStateToFree(udvm->lpResult, lpDesc);
-
- /*** Do not ByteCopy data, wait for END_MESSAGE --> see RFC 3320 subclause 9.4.9 **/
-
- return tsk_true;
+ tcomp_tempstate_to_free_t *lpDesc;
+
+ CONSUME_CYCLES(1);
+
+ /*
+ * Decompression failure MUST occur if more than four state free
+ * requests are made before the END-MESSAGE instruction is encountered.
+ */
+ if(tcomp_result_getTempStatesToFreeSize(udvm->lpResult) >=4) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_TOO_MANY_STATE_REQUESTS].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_TOO_MANY_STATE_REQUESTS);
+ return tsk_false;
+ }
+
+ /*
+ * Decompression failure also occurs if partial_identifier_length does
+ * not lie between 6 and 20 inclusive.
+ */
+ if(partial_identifier_length<6 || partial_identifier_length>20) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INVALID_STATE_ID_LENGTH].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_ID_LENGTH);
+ return tsk_false;
+ }
+
+ lpDesc = tcomp_tempstate_to_free_create();
+ lpDesc->partial_identifier_length = partial_identifier_length;
+ lpDesc->partial_identifier_start = partial_identifier_start;
+ tcomp_result_addTempStateToFree(udvm->lpResult, lpDesc);
+
+ /*** Do not ByteCopy data, wait for END_MESSAGE --> see RFC 3320 subclause 9.4.9 **/
+
+ return tsk_true;
}
/**
* @brief <i>OUTPUT (%output_start, %output_length)</i><br><br>
* Reference: RFC3320 Section 9.4.8<br>
* This instruction provides successfully decompressed data to the dispatcher.
-* @param [in,out] udvm The udvm state machine entity.
+* @param [in,out] udvm The udvm state machine entity.
* @param output_start defines the starting memory address of the byte string to be provided to the dispatcher
* @param output_length defines the length of the byte string to be provided to the dispatcher
* @retval 1 if succeed, otherwise returns 0
*/
tsk_bool_t TCOMP_UDVM_EXEC_INST__OUTPUT(tcomp_udvm_t *udvm, uint32_t output_start, uint32_t output_length)
{
- tsk_bool_t ok;
- tsk_size_t *outputbuffer_size;
-
- CONSUME_CYCLES(1+output_length);
-
- outputbuffer_size = tcomp_buffer_getIndexBytes(udvm->lpResult->output_buffer);
- if( (*outputbuffer_size + output_length) > 65536 ){
- /*
- * Decompression failure occurs if the cumulative number of bytes
- * provided to the dispatcher exceeds 65536 bytes.
- */
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_OUTPUT_OVERFLOW].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_OUTPUT_OVERFLOW);
- return tsk_false;
- }
-
- // FIXME: do it once?
- if((ok = tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBufferAtPos(udvm->lpResult->output_buffer, *outputbuffer_size), output_start, output_length))){
- *outputbuffer_size += output_length;
- }
+ tsk_bool_t ok;
+ tsk_size_t *outputbuffer_size;
+
+ CONSUME_CYCLES(1+output_length);
+
+ outputbuffer_size = tcomp_buffer_getIndexBytes(udvm->lpResult->output_buffer);
+ if( (*outputbuffer_size + output_length) > 65536 ) {
+ /*
+ * Decompression failure occurs if the cumulative number of bytes
+ * provided to the dispatcher exceeds 65536 bytes.
+ */
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_OUTPUT_OVERFLOW].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_OUTPUT_OVERFLOW);
+ return tsk_false;
+ }
+
+ // FIXME: do it once?
+ if((ok = tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBufferAtPos(udvm->lpResult->output_buffer, *outputbuffer_size), output_start, output_length))) {
+ *outputbuffer_size += output_length;
+ }
#if DEBUG || _DEBUG
- //tcomp_buffer_nprint(udvm->lpResult->output_buffer, *outputbuffer_size);
+ //tcomp_buffer_nprint(udvm->lpResult->output_buffer, *outputbuffer_size);
#endif
- return ok;
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1840,171 +1853,171 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__OUTPUT(tcomp_udvm_t *udvm, uint32_t output_star
/// handler together with any supplied feedback data.
///
/// @param [in,out] udvm Defines the requested feedback location.
-/// @param requested_feedback_location The requested feedback location.
+/// @param requested_feedback_location The requested feedback location.
/// @param returned_parameters_location Defines the returned parameters location which contains remote party capabilities.
/// @param state_length Length of the state to create.
/// @param state_address UDVM memory address of the state to create.
/// @param state_instruction Defines the state instruction.
/// @param minimum_access_length Defines the state's minimum access length.
-/// @param state_retention_priority Determines the order in which state will be deleted when the compartment exceeds its allocated state memory.
+/// @param state_retention_priority Determines the order in which state will be deleted when the compartment exceeds its allocated state memory.
///
-/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
+/// @retval @a tsk_true if succeed, otherwise returns @a tsk_false.
////////////////////////////////////////////////////////////////////////////////////////////////////
tsk_bool_t TCOMP_UDVM_EXEC_INST__END_MESSAGE(tcomp_udvm_t *udvm, uint32_t requested_feedback_location, uint32_t returned_parameters_location, uint32_t state_length, uint32_t state_address, uint32_t state_instruction, uint32_t minimum_access_length, uint32_t state_retention_priority)
{
- tsk_size_t udvm_size;
-
- CONSUME_CYCLES(1+state_length);
-
- udvm_size = TCOMP_UDVM_GET_SIZE();
-
- /*
- * Create temporary state provided by END_MESSAGE?
- */
- if(!tcomp_udvm_createTempState(udvm, state_length, state_address, state_instruction, minimum_access_length, state_retention_priority, 1)){
- return tsk_false;
- }
-
- /*
- * Byte copy all waiting STATE-FREE/STATE-CREATE/END-MESSAGE states
- */
- if(!tcomp_udvm_byteCopy_TempStates(udvm)){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
- return tsk_false;
- }
-
- /*
- * Feedback has been requested?
- */
- if(requested_feedback_location){
- uint8_t r_f_l;
- if(requested_feedback_location >= udvm_size){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- /*
- 0 1 2 3 4 5 6 7
- +---+---+---+---+---+---+---+---+
- | reserved | Q | S | I | requested_feedback_location
- +---+---+---+---+---+---+---+---+
- | |
- : requested feedback item : if Q = 1
- | |
- +---+---+---+---+---+---+---+---+
- */
- r_f_l = *TCOMP_UDVM_GET_BUFFER_AT(requested_feedback_location);
- udvm->lpResult->req_feedback->I = (r_f_l & 0x01);
- udvm->lpResult->req_feedback->S = (r_f_l & 0x02) ? 1 : 0;
- udvm->lpResult->req_feedback->Q = (r_f_l & 0x04) ? 1 : 0;
-
- requested_feedback_location++; /* skip 1-byte header */
- if(udvm->lpResult->req_feedback->Q){
- /* we have a requested feedback item */
- uint8_t r_f_i = *TCOMP_UDVM_GET_BUFFER_AT(requested_feedback_location);
- uint8_t length = 1; /* [1-128] */
- if(r_f_i & 0x80){
- /* case 2 */
- length += (r_f_i & 0x7f); /* seven last bits */
- }
-
- if(requested_feedback_location >= TCOMP_UDVM_GET_SIZE()){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- /* copy from udvm */
- // FIXME: use realloc
- tcomp_buffer_freeBuff(udvm->lpResult->req_feedback->item);
- tcomp_buffer_allocBuff(udvm->lpResult->req_feedback->item, length);
- if(!tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(udvm->lpResult->req_feedback->item), requested_feedback_location, length)){
- return tsk_false;
- }
- }
- }
-
- //
- // SigComp parameters have been returned?
- //
- if(returned_parameters_location){
- uint8_t r_p_l, SigComp_version;
- uint32_t index;
- tcomp_buffer_handle_t *partial_id;
-
- /*
- 0 1 2 3 4 5 6 7
- +---+---+---+---+---+---+---+---+
- | cpb | dms | sms | returned_parameters_location
- +---+---+---+---+---+---+---+---+
- | SigComp_version |
- +---+---+---+---+---+---+---+---+
- | length_of_partial_state_ID_1 |
- +---+---+---+---+---+---+---+---+
- | |
- : partial_state_identifier_1 :
- | |
- +---+---+---+---+---+---+---+---+
- : :
- +---+---+---+---+---+---+---+---+
- | length_of_partial_state_ID_n |
- +---+---+---+---+---+---+---+---+
- | |
- : partial_state_identifier_n :
- | |
- +---+---+---+---+---+---+---+---+
- */
-
- if(returned_parameters_location >= udvm_size){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
-
- /* cpb+dms+sms */
- r_p_l = *TCOMP_UDVM_GET_BUFFER_AT(returned_parameters_location);
- returned_parameters_location++;
- if(r_p_l){
- tcomp_params_setCpbCode(udvm->lpResult->remote_parameters, ((r_p_l & 0xc0)>>6));
- tcomp_params_setDmsCode(udvm->lpResult->remote_parameters, ((r_p_l & 0x38)>>3));
- tcomp_params_setSmsCode(udvm->lpResult->remote_parameters, (r_p_l & 0x07));
- }
- /* sigcomp version */
- SigComp_version = *TCOMP_UDVM_GET_BUFFER_AT(returned_parameters_location);
- returned_parameters_location++;
- if(SigComp_version){
- udvm->lpResult->remote_parameters->SigComp_version = SigComp_version;
- }
- /* state items */
- for(index = returned_parameters_location; index <(udvm_size-1); ){
- uint8_t length, *length_ptr = TCOMP_UDVM_GET_BUFFER_AT(index);
- if(!length_ptr){
- return tsk_false;
- }
- length = *length_ptr; // 1-byte
- if(length<6 || length>20){
- break;
- }
- index++;
- if((index+length) >= (uint32_t)udvm_size){
- TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
- tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
- return tsk_false;
- }
- partial_id = tcomp_buffer_create_null();
- tcomp_buffer_allocBuff(partial_id, length);
- if(!tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(partial_id), index, length)){
- return tsk_false;
- }
- if(!udvm->lpResult->remote_parameters->returnedStates){
- udvm->lpResult->remote_parameters->returnedStates = tsk_list_create();
- }
- tsk_list_push_back_data(udvm->lpResult->remote_parameters->returnedStates, (void**)&partial_id);
- index += length;
- }
- }
-
- return tsk_true;
+ tsk_size_t udvm_size;
+
+ CONSUME_CYCLES(1+state_length);
+
+ udvm_size = TCOMP_UDVM_GET_SIZE();
+
+ /*
+ * Create temporary state provided by END_MESSAGE?
+ */
+ if(!tcomp_udvm_createTempState(udvm, state_length, state_address, state_instruction, minimum_access_length, state_retention_priority, 1)) {
+ return tsk_false;
+ }
+
+ /*
+ * Byte copy all waiting STATE-FREE/STATE-CREATE/END-MESSAGE states
+ */
+ if(!tcomp_udvm_byteCopy_TempStates(udvm)) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_INTERNAL_ERROR].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
+ return tsk_false;
+ }
+
+ /*
+ * Feedback has been requested?
+ */
+ if(requested_feedback_location) {
+ uint8_t r_f_l;
+ if(requested_feedback_location >= udvm_size) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ /*
+ 0 1 2 3 4 5 6 7
+ +---+---+---+---+---+---+---+---+
+ | reserved | Q | S | I | requested_feedback_location
+ +---+---+---+---+---+---+---+---+
+ | |
+ : requested feedback item : if Q = 1
+ | |
+ +---+---+---+---+---+---+---+---+
+ */
+ r_f_l = *TCOMP_UDVM_GET_BUFFER_AT(requested_feedback_location);
+ udvm->lpResult->req_feedback->I = (r_f_l & 0x01);
+ udvm->lpResult->req_feedback->S = (r_f_l & 0x02) ? 1 : 0;
+ udvm->lpResult->req_feedback->Q = (r_f_l & 0x04) ? 1 : 0;
+
+ requested_feedback_location++; /* skip 1-byte header */
+ if(udvm->lpResult->req_feedback->Q) {
+ /* we have a requested feedback item */
+ uint8_t r_f_i = *TCOMP_UDVM_GET_BUFFER_AT(requested_feedback_location);
+ uint8_t length = 1; /* [1-128] */
+ if(r_f_i & 0x80) {
+ /* case 2 */
+ length += (r_f_i & 0x7f); /* seven last bits */
+ }
+
+ if(requested_feedback_location >= TCOMP_UDVM_GET_SIZE()) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ /* copy from udvm */
+ // FIXME: use realloc
+ tcomp_buffer_freeBuff(udvm->lpResult->req_feedback->item);
+ tcomp_buffer_allocBuff(udvm->lpResult->req_feedback->item, length);
+ if(!tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(udvm->lpResult->req_feedback->item), requested_feedback_location, length)) {
+ return tsk_false;
+ }
+ }
+ }
+
+ //
+ // SigComp parameters have been returned?
+ //
+ if(returned_parameters_location) {
+ uint8_t r_p_l, SigComp_version;
+ uint32_t index;
+ tcomp_buffer_handle_t *partial_id;
+
+ /*
+ 0 1 2 3 4 5 6 7
+ +---+---+---+---+---+---+---+---+
+ | cpb | dms | sms | returned_parameters_location
+ +---+---+---+---+---+---+---+---+
+ | SigComp_version |
+ +---+---+---+---+---+---+---+---+
+ | length_of_partial_state_ID_1 |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : partial_state_identifier_1 :
+ | |
+ +---+---+---+---+---+---+---+---+
+ : :
+ +---+---+---+---+---+---+---+---+
+ | length_of_partial_state_ID_n |
+ +---+---+---+---+---+---+---+---+
+ | |
+ : partial_state_identifier_n :
+ | |
+ +---+---+---+---+---+---+---+---+
+ */
+
+ if(returned_parameters_location >= udvm_size) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+
+ /* cpb+dms+sms */
+ r_p_l = *TCOMP_UDVM_GET_BUFFER_AT(returned_parameters_location);
+ returned_parameters_location++;
+ if(r_p_l) {
+ tcomp_params_setCpbCode(udvm->lpResult->remote_parameters, ((r_p_l & 0xc0)>>6));
+ tcomp_params_setDmsCode(udvm->lpResult->remote_parameters, ((r_p_l & 0x38)>>3));
+ tcomp_params_setSmsCode(udvm->lpResult->remote_parameters, (r_p_l & 0x07));
+ }
+ /* sigcomp version */
+ SigComp_version = *TCOMP_UDVM_GET_BUFFER_AT(returned_parameters_location);
+ returned_parameters_location++;
+ if(SigComp_version) {
+ udvm->lpResult->remote_parameters->SigComp_version = SigComp_version;
+ }
+ /* state items */
+ for(index = returned_parameters_location; index <(udvm_size-1); ) {
+ uint8_t length, *length_ptr = TCOMP_UDVM_GET_BUFFER_AT(index);
+ if(!length_ptr) {
+ return tsk_false;
+ }
+ length = *length_ptr; // 1-byte
+ if(length<6 || length>20) {
+ break;
+ }
+ index++;
+ if((index+length) >= (uint32_t)udvm_size) {
+ TSK_DEBUG_ERROR("%s", TCOMP_NACK_DESCRIPTIONS[NACK_SEGFAULT].desc);
+ tcomp_udvm_createNackInfo2(udvm, NACK_SEGFAULT);
+ return tsk_false;
+ }
+ partial_id = tcomp_buffer_create_null();
+ tcomp_buffer_allocBuff(partial_id, length);
+ if(!tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(partial_id), index, length)) {
+ return tsk_false;
+ }
+ if(!udvm->lpResult->remote_parameters->returnedStates) {
+ udvm->lpResult->remote_parameters->returnedStates = tsk_list_create();
+ }
+ tsk_list_push_back_data(udvm->lpResult->remote_parameters->returnedStates, (void**)&partial_id);
+ index += length;
+ }
+ }
+
+ return tsk_true;
}
diff --git a/tinySIGCOMP/src/tcomp_udvm.nack.c b/tinySIGCOMP/src/tcomp_udvm.nack.c
index a195a41..53a9d49 100755
--- a/tinySIGCOMP/src/tcomp_udvm.nack.c
+++ b/tinySIGCOMP/src/tcomp_udvm.nack.c
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop
* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -29,28 +29,27 @@
int tcomp_udvm_createNackInfo(tcomp_udvm_t *udvm, uint8_t reasonCode, tcomp_buffer_handle_t* lpDetails, int16_t memory_address_of_instruction)
{
- uint32_t mem_add_instruction;
- int ret;
-
- if(!udvm){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
+ uint32_t mem_add_instruction;
+ int ret;
+
+ if(!udvm) {
+ TSK_DEBUG_ERROR("Invalid parameter");
+ return -1;
+ }
+
+ tcomp_buffer_allocBuff(udvm->lpResult->nack_info, INDEX_NACK_SHA1 + TSK_SHA1_DIGEST_SIZE);
+ mem_add_instruction = (memory_address_of_instruction >=0) ? memory_address_of_instruction : udvm->last_memory_address_of_instruction;
- tcomp_buffer_allocBuff(udvm->lpResult->nack_info, INDEX_NACK_SHA1 + TSK_SHA1_DIGEST_SIZE);
- mem_add_instruction = (memory_address_of_instruction >=0) ? memory_address_of_instruction : udvm->last_memory_address_of_instruction;
+ if((ret = tcomp_nackinfo_write_2(udvm->lpResult->nack_info,
+ reasonCode,
+ *TCOMP_UDVM_GET_BUFFER_AT(mem_add_instruction),
+ mem_add_instruction,
+ udvm->sigCompMessage,
+ lpDetails,
+ TCOMP_UDVM_GET_SIZE(),
+ udvm->stateHandler->sigcomp_parameters->cpbValue)) == 0) {
+ udvm->lpResult->isNack = 1;
+ }
- if((ret = tcomp_nackinfo_write_2(udvm->lpResult->nack_info,
- reasonCode,
- *TCOMP_UDVM_GET_BUFFER_AT(mem_add_instruction),
- mem_add_instruction,
- udvm->sigCompMessage,
- lpDetails,
- TCOMP_UDVM_GET_SIZE(),
- udvm->stateHandler->sigcomp_parameters->cpbValue)) == 0)
- {
- udvm->lpResult->isNack = 1;
- }
-
- return ret;
+ return ret;
} \ No newline at end of file
diff --git a/tinySIGCOMP/src/tcomp_udvm.operands.c b/tinySIGCOMP/src/tcomp_udvm.operands.c
index 4d15d8c..7f3afba 100755
--- a/tinySIGCOMP/src/tcomp_udvm.operands.c
+++ b/tinySIGCOMP/src/tcomp_udvm.operands.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -44,41 +44,36 @@ literal (#)<br>
*/
uint32_t tcomp_udvm_opget_literal_param(tcomp_udvm_t *udvm)
{
- uint32_t result = 0;
- const uint8_t* memory_ptr = TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer);
-
- switch( *memory_ptr & 0xc0) // 2 first bits
- {
- case 0x00: // 0nnnnnnn N 0 - 127
- case 0x40: // 0nnnnnnn N 0 - 127
- {
- result = *(memory_ptr);
- udvm->executionPointer++;
- }
- break;
-
- case 0x80: // 10nnnnnn nnnnnnnn N 0 - 16383
- {
- result = TSK_BINARY_GET_2BYTES(memory_ptr)&0x3fff; // All except 2 first bits
- udvm->executionPointer+=2;
- }
- break;
-
- case 0xc0: // 11000000 nnnnnnnn nnnnnnnn N 0 - 65535
- {
- result = TSK_BINARY_GET_2BYTES((memory_ptr+1));
- udvm->executionPointer+=3;
- }
- break;
-
- default:
- {
- TSK_DEBUG_ERROR("Invalide opcode: %u", *memory_ptr);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
- }
- break;
- }
- return result;
+ uint32_t result = 0;
+ const uint8_t* memory_ptr = TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer);
+
+ switch( *memory_ptr & 0xc0) { // 2 first bits
+ case 0x00: // 0nnnnnnn N 0 - 127
+ case 0x40: { // 0nnnnnnn N 0 - 127
+ result = *(memory_ptr);
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 0x80: { // 10nnnnnn nnnnnnnn N 0 - 16383
+ result = TSK_BINARY_GET_2BYTES(memory_ptr)&0x3fff; // All except 2 first bits
+ udvm->executionPointer+=2;
+ }
+ break;
+
+ case 0xc0: { // 11000000 nnnnnnnn nnnnnnnn N 0 - 65535
+ result = TSK_BINARY_GET_2BYTES((memory_ptr+1));
+ udvm->executionPointer+=3;
+ }
+ break;
+
+ default: {
+ TSK_DEBUG_ERROR("Invalide opcode: %u", *memory_ptr);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
+ }
+ break;
+ }
+ return result;
}
/**
@@ -92,45 +87,40 @@ reference ($)<br>
*/
uint32_t tcomp_udvm_opget_reference_param(tcomp_udvm_t *udvm)
{
- const uint8_t* memory_ptr = TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer);
- uint32_t result = 0;
-
- switch( *memory_ptr & 0xc0) // 2 first bits
- {
- case 0x00: // 0nnnnnnn memory[2 * N] 0 - 65535
- case 0x40: // 0nnnnnnn memory[2 * N] 0 - 65535
- {
- uint8_t N = (*(memory_ptr) & 0x7f); // no effect first bit is already nil
- result = 2*N;
- udvm->executionPointer++;
- }
- break;
-
- case 0x80: // 10nnnnnn nnnnnnnn memory[2 * N] 0 - 65535
- {
- uint32_t N = (TSK_BINARY_GET_2BYTES(memory_ptr) & 0x3fff);
- result = 2*N;
- udvm->executionPointer+=2;
- }
- break;
-
- case 0xc0: // 11000000 nnnnnnnn nnnnnnnn memory[N] 0 - 65535
- {
- uint32_t N = TSK_BINARY_GET_2BYTES(memory_ptr+1);
- result = N;
- udvm->executionPointer+=3;
- }
- break;
-
- default:
- {
- TSK_DEBUG_ERROR("Invalide opcode: %u", *memory_ptr);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
- }
- break;
- }
-
- return result;
+ const uint8_t* memory_ptr = TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer);
+ uint32_t result = 0;
+
+ switch( *memory_ptr & 0xc0) { // 2 first bits
+ case 0x00: // 0nnnnnnn memory[2 * N] 0 - 65535
+ case 0x40: { // 0nnnnnnn memory[2 * N] 0 - 65535
+ uint8_t N = (*(memory_ptr) & 0x7f); // no effect first bit is already nil
+ result = 2*N;
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 0x80: { // 10nnnnnn nnnnnnnn memory[2 * N] 0 - 65535
+ uint32_t N = (TSK_BINARY_GET_2BYTES(memory_ptr) & 0x3fff);
+ result = 2*N;
+ udvm->executionPointer+=2;
+ }
+ break;
+
+ case 0xc0: { // 11000000 nnnnnnnn nnnnnnnn memory[N] 0 - 65535
+ uint32_t N = TSK_BINARY_GET_2BYTES(memory_ptr+1);
+ result = N;
+ udvm->executionPointer+=3;
+ }
+ break;
+
+ default: {
+ TSK_DEBUG_ERROR("Invalide opcode: %u", *memory_ptr);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
+ }
+ break;
+ }
+
+ return result;
}
/**
@@ -151,96 +141,84 @@ multitype(%)<br>
*/
uint32_t tcomp_udvm_opget_multitype_param(tcomp_udvm_t *udvm)
{
- const uint8_t* memory_ptr = TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer);
- int8_t index = operand_multitype_indexes[*memory_ptr];
- uint32_t result = 0;
-
- switch(index)
- {
- case 1: // 00nnnnnn N 0 - 63
- {
- result = *(memory_ptr);
- udvm->executionPointer++;
- }
- break;
-
- case 2: // 01nnnnnn memory[2 * N] 0 - 65535
- {
- uint8_t N = (*(memory_ptr) & 0x3f);
- result = TSK_BINARY_GET_2BYTES( TCOMP_UDVM_GET_BUFFER_AT(2*N) );
- udvm->executionPointer++;
- }
- break;
-
- case 3: // 1000011n 2 ^ (N + 6) 64 , 128
- {
- uint8_t N = (*(memory_ptr) & 0x01);
- result = (uint32_t)pow( (double)2, (N + 6) );
- udvm->executionPointer++;
- }
- break;
-
- case 4: // 10001nnn 2 ^ (N + 8) 256 , ... , 32768
- {
- uint8_t N = (*(memory_ptr) & 0x07);
- result = (uint32_t)pow( (double)2, (N + 8) );
- udvm->executionPointer++;
- }
- break;
-
- case 5: // 111nnnnn N + 65504 65504 - 65535
- {
- result = ((*(memory_ptr) & 0x1f) + 65504 );
- udvm->executionPointer++;
- }
- break;
-
- case 6: // 1001nnnn nnnnnnnn N + 61440 61440 - 65535
- {
- result = (TSK_BINARY_GET_2BYTES(memory_ptr) & 0x0fff) + 61440;
- udvm->executionPointer+=2;
- }
- break;
-
- case 7: // 101nnnnn nnnnnnnn N 0 - 8191
- {
- result = (TSK_BINARY_GET_2BYTES(memory_ptr) & 0x1fff);
- udvm->executionPointer+=2;
- }
- break;
-
- case 8: // 110nnnnn nnnnnnnn memory[N] 0 - 65535
- {
- uint32_t N = TSK_BINARY_GET_2BYTES(memory_ptr) & 0x1fff;
- result = TSK_BINARY_GET_2BYTES( TCOMP_UDVM_GET_BUFFER_AT(N) );
- udvm->executionPointer+=2;
- }
- break;
-
- case 9: // 10000000 nnnnnnnn nnnnnnnn N 0 - 65535
- {
- result = TSK_BINARY_GET_2BYTES(memory_ptr+1);
- udvm->executionPointer+=3;
- }
- break;
-
- case 10: // 10000001 nnnnnnnn nnnnnnnn memory[N] 0 - 65535
- {
- uint32_t N = TSK_BINARY_GET_2BYTES(memory_ptr+1);
- result = TSK_BINARY_GET_2BYTES( TCOMP_UDVM_GET_BUFFER_AT(N) );
- udvm->executionPointer+=3;
- }
- break;
-
- default: // -1
- {
- TSK_DEBUG_ERROR("Invalide opcode: %u", *memory_ptr);
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
- }
- break;
- }
-
- return result;
+ const uint8_t* memory_ptr = TCOMP_UDVM_GET_BUFFER_AT(udvm->executionPointer);
+ int8_t index = operand_multitype_indexes[*memory_ptr];
+ uint32_t result = 0;
+
+ switch(index) {
+ case 1: { // 00nnnnnn N 0 - 63
+ result = *(memory_ptr);
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 2: { // 01nnnnnn memory[2 * N] 0 - 65535
+ uint8_t N = (*(memory_ptr) & 0x3f);
+ result = TSK_BINARY_GET_2BYTES( TCOMP_UDVM_GET_BUFFER_AT(2*N) );
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 3: { // 1000011n 2 ^ (N + 6) 64 , 128
+ uint8_t N = (*(memory_ptr) & 0x01);
+ result = (uint32_t)pow( (double)2, (N + 6) );
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 4: { // 10001nnn 2 ^ (N + 8) 256 , ... , 32768
+ uint8_t N = (*(memory_ptr) & 0x07);
+ result = (uint32_t)pow( (double)2, (N + 8) );
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 5: { // 111nnnnn N + 65504 65504 - 65535
+ result = ((*(memory_ptr) & 0x1f) + 65504 );
+ udvm->executionPointer++;
+ }
+ break;
+
+ case 6: { // 1001nnnn nnnnnnnn N + 61440 61440 - 65535
+ result = (TSK_BINARY_GET_2BYTES(memory_ptr) & 0x0fff) + 61440;
+ udvm->executionPointer+=2;
+ }
+ break;
+
+ case 7: { // 101nnnnn nnnnnnnn N 0 - 8191
+ result = (TSK_BINARY_GET_2BYTES(memory_ptr) & 0x1fff);
+ udvm->executionPointer+=2;
+ }
+ break;
+
+ case 8: { // 110nnnnn nnnnnnnn memory[N] 0 - 65535
+ uint32_t N = TSK_BINARY_GET_2BYTES(memory_ptr) & 0x1fff;
+ result = TSK_BINARY_GET_2BYTES( TCOMP_UDVM_GET_BUFFER_AT(N) );
+ udvm->executionPointer+=2;
+ }
+ break;
+
+ case 9: { // 10000000 nnnnnnnn nnnnnnnn N 0 - 65535
+ result = TSK_BINARY_GET_2BYTES(memory_ptr+1);
+ udvm->executionPointer+=3;
+ }
+ break;
+
+ case 10: { // 10000001 nnnnnnnn nnnnnnnn memory[N] 0 - 65535
+ uint32_t N = TSK_BINARY_GET_2BYTES(memory_ptr+1);
+ result = TSK_BINARY_GET_2BYTES( TCOMP_UDVM_GET_BUFFER_AT(N) );
+ udvm->executionPointer+=3;
+ }
+ break;
+
+ default: { // -1
+ TSK_DEBUG_ERROR("Invalide opcode: %u", *memory_ptr);
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_OPERAND);
+ }
+ break;
+ }
+
+ return result;
}
/**
@@ -255,7 +233,7 @@ calculated as follows:
*/
uint32_t tcomp_udvm_opget_address_param(tcomp_udvm_t *udvm, uint32_t memory_address_of_instruction)
{
- uint32_t D = tcomp_udvm_opget_multitype_param(udvm);
- // (2^16) => 65536;
- return ( (memory_address_of_instruction + D)%65536 );
+ uint32_t D = tcomp_udvm_opget_multitype_param(udvm);
+ // (2^16) => 65536;
+ return ( (memory_address_of_instruction + D)%65536 );
}
diff --git a/tinySIGCOMP/src/tcomp_udvm.statemanagment.c b/tinySIGCOMP/src/tcomp_udvm.statemanagment.c
index 2644c54..daeca8c 100755
--- a/tinySIGCOMP/src/tcomp_udvm.statemanagment.c
+++ b/tinySIGCOMP/src/tcomp_udvm.statemanagment.c
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -32,103 +32,99 @@
int tcomp_udvm_byteCopy_TempStates(tcomp_udvm_t *udvm)
{
- int ok = 1;
- uint8_t i;
- uint8_t tocreate_size = tcomp_result_getTempStatesToCreateSize(udvm->lpResult);
- uint8_t tofree_size = tcomp_result_getTempStatesToFreeSize(udvm->lpResult);
-
-
- /*
- * State Create
- */
- for(i = 0; i < tocreate_size && ok; i++)
- {
- /*
- * The UDVM byte copies a string of state_length bytes from the UDVM
- * memory beginning at state_address (obeying the rules of Section 8.4).
- * This is the state_value.
- */
- tcomp_state_t* lpState = udvm->lpResult->statesToCreate[i];
- if(lpState->length){
- tcomp_buffer_allocBuff(lpState->value, lpState->length);
- }
+ int ok = 1;
+ uint8_t i;
+ uint8_t tocreate_size = tcomp_result_getTempStatesToCreateSize(udvm->lpResult);
+ uint8_t tofree_size = tcomp_result_getTempStatesToFreeSize(udvm->lpResult);
+
+
+ /*
+ * State Create
+ */
+ for(i = 0; i < tocreate_size && ok; i++) {
+ /*
+ * The UDVM byte copies a string of state_length bytes from the UDVM
+ * memory beginning at state_address (obeying the rules of Section 8.4).
+ * This is the state_value.
+ */
+ tcomp_state_t* lpState = udvm->lpResult->statesToCreate[i];
+ if(lpState->length) {
+ tcomp_buffer_allocBuff(lpState->value, lpState->length);
+ }
+
+ ok &= tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(lpState->value), lpState->address, lpState->length);
+ }
- ok &= tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(lpState->value), lpState->address, lpState->length);
- }
-
- /*
- * State Free
- */
- for(i = 0; i<tofree_size && ok; i++){
- tcomp_tempstate_to_free_t *lpDesc = udvm->lpResult->statesToFree[i];
- tcomp_buffer_allocBuff(lpDesc->identifier, lpDesc->partial_identifier_length);
- ok &= tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(lpDesc->identifier), lpDesc->partial_identifier_start, lpDesc->partial_identifier_length);
- }
- return ok;
+ /*
+ * State Free
+ */
+ for(i = 0; i<tofree_size && ok; i++) {
+ tcomp_tempstate_to_free_t *lpDesc = udvm->lpResult->statesToFree[i];
+ tcomp_buffer_allocBuff(lpDesc->identifier, lpDesc->partial_identifier_length);
+ ok &= tcomp_udvm_bytecopy_from(udvm, tcomp_buffer_getBuffer(lpDesc->identifier), lpDesc->partial_identifier_start, lpDesc->partial_identifier_length);
+ }
+ return ok;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// @brief Creates temporary state.
///
-/// @param [in,out] udvm If non-null, the udvm.
-/// @param state_length Length of the state.
-/// @param state_address The state address.
-/// @param state_instruction The state instruction.
-/// @param minimum_access_length Length of the minimum access.
-/// @param state_retention_priority The state retention priority.
-/// @param end_msg Message describing the end.
+/// @param [in,out] udvm If non-null, the udvm.
+/// @param state_length Length of the state.
+/// @param state_address The state address.
+/// @param state_instruction The state instruction.
+/// @param minimum_access_length Length of the minimum access.
+/// @param state_retention_priority The state retention priority.
+/// @param end_msg Message describing the end.
///
/// @return 1 if succeed an zero otherwise.
////////////////////////////////////////////////////////////////////////////////////////////////////
-int tcomp_udvm_createTempState(tcomp_udvm_t *udvm, uint32_t state_length, uint32_t state_address, uint32_t state_instruction,
- uint32_t minimum_access_length, uint32_t state_retention_priority, int end_msg)
+int tcomp_udvm_createTempState(tcomp_udvm_t *udvm, uint32_t state_length, uint32_t state_address, uint32_t state_instruction,
+ uint32_t minimum_access_length, uint32_t state_retention_priority, int end_msg)
{
- /*
- * If the specified minimum_access_length does not lie between 6 and 20 inclusive, or if
- * the state_retention_priority is 65535 then the END-MESSAGE
- * instruction fails to make a state creation request of its own
- * (however decompression failure does not occur and the state creation
- * requests made by the STATE-CREATE instruction are still valid).
- */
- int is_ok = ( (6<=minimum_access_length && minimum_access_length<=20) && state_retention_priority!=65535 );
+ /*
+ * If the specified minimum_access_length does not lie between 6 and 20 inclusive, or if
+ * the state_retention_priority is 65535 then the END-MESSAGE
+ * instruction fails to make a state creation request of its own
+ * (however decompression failure does not occur and the state creation
+ * requests made by the STATE-CREATE instruction are still valid).
+ */
+ int is_ok = ( (6<=minimum_access_length && minimum_access_length<=20) && state_retention_priority!=65535 );
- // if not ok and not END_MESSAGE --> decompression failure MUST occurs
- if(!is_ok)
- {
- if(end_msg) return 1;
+ // if not ok and not END_MESSAGE --> decompression failure MUST occurs
+ if(!is_ok) {
+ if(end_msg) {
+ return 1;
+ }
- if(state_retention_priority == 65535)
- {
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_PRIORITY);
- }
- else
- {
- tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_ID_LENGTH);
- }
- return 0;
- }
+ if(state_retention_priority == 65535) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_PRIORITY);
+ }
+ else {
+ tcomp_udvm_createNackInfo2(udvm, NACK_INVALID_STATE_ID_LENGTH);
+ }
+ return 0;
+ }
- /*
- * decompression failure occurs if the END-MESSAGE instruction makes a state creation request and four
- * instances of the STATE-CREATE instruction have already been encountered.
- */
- if(tcomp_result_getTempStatesToCreateSize(udvm->lpResult) >= MAX_TEMP_SATES)
- {
- tcomp_udvm_createNackInfo2(udvm, NACK_TOO_MANY_STATE_REQUESTS);
- return 0;
- }
+ /*
+ * decompression failure occurs if the END-MESSAGE instruction makes a state creation request and four
+ * instances of the STATE-CREATE instruction have already been encountered.
+ */
+ if(tcomp_result_getTempStatesToCreateSize(udvm->lpResult) >= MAX_TEMP_SATES) {
+ tcomp_udvm_createNackInfo2(udvm, NACK_TOO_MANY_STATE_REQUESTS);
+ return 0;
+ }
- /*
- * Is there a state to create?
- */
- if(is_ok)
- {
- // no byte copy ()
- tcomp_state_t *lpState = tcomp_state_create(state_length, state_address, state_instruction, minimum_access_length, state_retention_priority);
- tcomp_result_addTempStateToCreate(udvm->lpResult, lpState);
- }
+ /*
+ * Is there a state to create?
+ */
+ if(is_ok) {
+ // no byte copy ()
+ tcomp_state_t *lpState = tcomp_state_create(state_length, state_address, state_instruction, minimum_access_length, state_retention_priority);
+ tcomp_result_addTempStateToCreate(udvm->lpResult, lpState);
+ }
- return 1;
+ return 1;
}
diff --git a/tinySIGCOMP/src/tinysigcomp_config.h b/tinySIGCOMP/src/tinysigcomp_config.h
index 833b7b2..63fd963 100755
--- a/tinySIGCOMP/src/tinysigcomp_config.h
+++ b/tinySIGCOMP/src/tinysigcomp_config.h
@@ -2,19 +2,19 @@
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -46,13 +46,13 @@
# define TINYSIGCOMP_GEXTERN extern
#endif
-/* Guards against C++ name mangling
+/* Guards against C++ name mangling
*/
#ifdef __cplusplus
# define TCOMP_BEGIN_DECLS extern "C" {
# define TCOMP_END_DECLS }
#else
-# define TCOMP_BEGIN_DECLS
+# define TCOMP_BEGIN_DECLS
# define TCOMP_END_DECLS
#endif
@@ -93,13 +93,13 @@
#elif defined(__GNUC__) && !defined(__APPLE__)
# define TCOMP_INLINE __inline
#else
-# define TCOMP_INLINE
+# define TCOMP_INLINE
#endif
#include <stdint.h>
#if HAVE_CONFIG_H
- #include <config.h>
+#include <config.h>
#endif
#endif // TINYSIGCOMP_CONFIG_H
diff --git a/tinySIGCOMP/src/trees.c b/tinySIGCOMP/src/trees.c
index fe8eda7..201b01d 100755
--- a/tinySIGCOMP/src/trees.c
+++ b/tinySIGCOMP/src/trees.c
@@ -60,16 +60,16 @@
/* repeat a zero length 11-138 times (7 bits of repeat count) */
local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
+ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
local const int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
+ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
local const uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
+ = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
/* The lengths of the bit length codes are sent in order of decreasing
* probability, to avoid transmitting the lengths for unused bit length codes.
*/
@@ -166,7 +166,7 @@ local void gen_trees_header OF((void));
#ifndef DEBUG
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
+/* Send a code of the given tree. c and tree must not have side effects */
#else /* DEBUG */
# define send_code(s, c, tree) \
@@ -191,9 +191,9 @@ local void gen_trees_header OF((void));
local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
+deflate_state *s;
+int value; /* value to send */
+int length; /* number of bits */
{
Tracevv((stderr," l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
@@ -208,7 +208,8 @@ local void send_bits(s, value, length)
put_short(s, s->bi_buf);
s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
s->bi_valid += length - Buf_size;
- } else {
+ }
+ else {
s->bi_buf |= value << s->bi_valid;
s->bi_valid += length;
}
@@ -248,7 +249,9 @@ local void tr_static_init()
ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
- if (static_init_done) return;
+ if (static_init_done) {
+ return;
+ }
/* For some embedded targets, global variables are not initialized: */
static_l_desc.static_tree = static_ltree;
@@ -291,12 +294,22 @@ local void tr_static_init()
Assert (dist == 256, "tr_static_init: 256+dist != 512");
/* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
+ for (bits = 0; bits <= MAX_BITS; bits++) {
+ bl_count[bits] = 0;
+ }
n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
+ while (n <= 143) {
+ static_ltree[n++].Len = 8, bl_count[8]++;
+ }
+ while (n <= 255) {
+ static_ltree[n++].Len = 9, bl_count[9]++;
+ }
+ while (n <= 279) {
+ static_ltree[n++].Len = 7, bl_count[7]++;
+ }
+ while (n <= 287) {
+ static_ltree[n++].Len = 8, bl_count[8]++;
+ }
/* Codes 286 and 287 do not exist, but we must include them in the
* tree construction to get a canonical Huffman tree (longest code
* all ones)
@@ -381,7 +394,7 @@ void gen_trees_header()
* Initialize the tree data structures for a new zlib stream.
*/
void _tr_init(s)
- deflate_state *s;
+deflate_state *s;
{
tr_static_init();
@@ -410,14 +423,20 @@ void _tr_init(s)
* Initialize a new block.
*/
local void init_block(s)
- deflate_state *s;
+deflate_state *s;
{
int n; /* iterates over tree elements */
/* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
+ for (n = 0; n < L_CODES; n++) {
+ s->dyn_ltree[n].Freq = 0;
+ }
+ for (n = 0; n < D_CODES; n++) {
+ s->dyn_dtree[n].Freq = 0;
+ }
+ for (n = 0; n < BL_CODES; n++) {
+ s->bl_tree[n].Freq = 0;
+ }
s->dyn_ltree[END_BLOCK].Freq = 1;
s->opt_len = s->static_len = 0L;
@@ -454,23 +473,26 @@ local void init_block(s)
* two sons).
*/
local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
+deflate_state *s;
+ct_data *tree; /* the tree to restore */
+int k; /* node to move down */
{
int v = s->heap[k];
int j = k << 1; /* left son of k */
while (j <= s->heap_len) {
/* Set j to the smallest of the two sons: */
if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
+ smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
j++;
}
/* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
+ if (smaller(tree, v, s->heap[j], s->depth)) {
+ break;
+ }
/* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
+ s->heap[k] = s->heap[j];
+ k = j;
/* And continue down the tree, setting j to the left son of k */
j <<= 1;
@@ -489,8 +511,8 @@ local void pqdownheap(s, tree, k)
* not null.
*/
local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
+deflate_state *s;
+tree_desc *desc; /* the tree descriptor */
{
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
@@ -505,7 +527,9 @@ local void gen_bitlen(s, desc)
ush f; /* frequency */
int overflow = 0; /* number of elements with bit length too large */
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
+ for (bits = 0; bits <= MAX_BITS; bits++) {
+ s->bl_count[bits] = 0;
+ }
/* In a first pass, compute the optimal bit lengths (which may
* overflow in the case of the bit length tree).
@@ -515,20 +539,30 @@ local void gen_bitlen(s, desc)
for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
n = s->heap[h];
bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
+ if (bits > max_length) {
+ bits = max_length, overflow++;
+ }
tree[n].Len = (ush)bits;
/* We overwrite tree[n].Dad which is no longer needed */
- if (n > max_code) continue; /* not a leaf node */
+ if (n > max_code) {
+ continue; /* not a leaf node */
+ }
s->bl_count[bits]++;
xbits = 0;
- if (n >= base) xbits = extra[n-base];
+ if (n >= base) {
+ xbits = extra[n-base];
+ }
f = tree[n].Freq;
s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
+ if (stree) {
+ s->static_len += (ulg)f * (stree[n].Len + xbits);
+ }
+ }
+ if (overflow == 0) {
+ return;
}
- if (overflow == 0) return;
Trace((stderr,"\nbit length overflow\n"));
/* This happens for example on obj2 and pic of the Calgary corpus */
@@ -536,7 +570,9 @@ local void gen_bitlen(s, desc)
/* Find the first bit length which could increase: */
do {
bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
+ while (s->bl_count[bits] == 0) {
+ bits--;
+ }
s->bl_count[bits]--; /* move one leaf down the tree */
s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
s->bl_count[max_length]--;
@@ -544,7 +580,8 @@ local void gen_bitlen(s, desc)
* but this does not affect bl_count[max_length]
*/
overflow -= 2;
- } while (overflow > 0);
+ }
+ while (overflow > 0);
/* Now recompute all bit lengths, scanning in increasing frequency.
* h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
@@ -555,7 +592,9 @@ local void gen_bitlen(s, desc)
n = s->bl_count[bits];
while (n != 0) {
m = s->heap[--h];
- if (m > max_code) continue;
+ if (m > max_code) {
+ continue;
+ }
if ((unsigned) tree[m].Len != (unsigned) bits) {
Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
s->opt_len += ((long)bits - (long)tree[m].Len)
@@ -576,9 +615,9 @@ local void gen_bitlen(s, desc)
* zero code length.
*/
local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
+ct_data *tree; /* the tree to decorate */
+int max_code; /* largest code with non zero frequency */
+ushf *bl_count; /* number of codes at each bit length */
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
ush code = 0; /* running code value */
@@ -600,12 +639,14 @@ local void gen_codes (tree, max_code, bl_count)
for (n = 0; n <= max_code; n++) {
int len = tree[n].Len;
- if (len == 0) continue;
+ if (len == 0) {
+ continue;
+ }
/* Now reverse the bits */
tree[n].Code = bi_reverse(next_code[len]++, len);
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
+ n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
}
}
@@ -618,8 +659,8 @@ local void gen_codes (tree, max_code, bl_count)
* also updated if stree is not null. The field max_code is set.
*/
local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
+deflate_state *s;
+tree_desc *desc; /* the tree descriptor */
{
ct_data *tree = desc->dyn_tree;
const ct_data *stree = desc->stat_desc->static_tree;
@@ -638,7 +679,8 @@ local void build_tree(s, desc)
if (tree[n].Freq != 0) {
s->heap[++(s->heap_len)] = max_code = n;
s->depth[n] = 0;
- } else {
+ }
+ else {
tree[n].Len = 0;
}
}
@@ -652,7 +694,10 @@ local void build_tree(s, desc)
node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
tree[node].Freq = 1;
s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
+ s->opt_len--;
+ if (stree) {
+ s->static_len -= stree[node].Len;
+ }
/* node is 0 or 1 so it does not have extra bits */
}
desc->max_code = max_code;
@@ -660,7 +705,9 @@ local void build_tree(s, desc)
/* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
* establish sub-heaps of increasing lengths:
*/
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
+ for (n = s->heap_len/2; n >= 1; n--) {
+ pqdownheap(s, tree, n);
+ }
/* Construct the Huffman tree by repeatedly combining the least two
* frequent nodes.
@@ -688,7 +735,8 @@ local void build_tree(s, desc)
s->heap[SMALLEST] = node++;
pqdownheap(s, tree, SMALLEST);
- } while (s->heap_len >= 2);
+ }
+ while (s->heap_len >= 2);
s->heap[--(s->heap_max)] = s->heap[SMALLEST];
@@ -706,9 +754,9 @@ local void build_tree(s, desc)
* in the bit length tree.
*/
local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
+deflate_state *s;
+ct_data *tree; /* the tree to be scanned */
+int max_code; /* and its largest code of non zero frequency */
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
@@ -718,29 +766,41 @@ local void scan_tree (s, tree, max_code)
int max_count = 7; /* max repeat count */
int min_count = 4; /* min repeat count */
- if (nextlen == 0) max_count = 138, min_count = 3;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ }
tree[max_code+1].Len = (ush)0xffff; /* guard */
for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
+ curlen = nextlen;
+ nextlen = tree[n+1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
- } else if (count < min_count) {
+ }
+ else if (count < min_count) {
s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
+ }
+ else if (curlen != 0) {
+ if (curlen != prevlen) {
+ s->bl_tree[curlen].Freq++;
+ }
s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
+ }
+ else if (count <= 10) {
s->bl_tree[REPZ_3_10].Freq++;
- } else {
+ }
+ else {
s->bl_tree[REPZ_11_138].Freq++;
}
- count = 0; prevlen = curlen;
+ count = 0;
+ prevlen = curlen;
if (nextlen == 0) {
max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
+ }
+ else if (curlen == nextlen) {
max_count = 6, min_count = 3;
- } else {
+ }
+ else {
max_count = 7, min_count = 4;
}
}
@@ -751,9 +811,9 @@ local void scan_tree (s, tree, max_code)
* bl_tree.
*/
local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
+deflate_state *s;
+ct_data *tree; /* the tree to be scanned */
+int max_code; /* and its largest code of non zero frequency */
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
@@ -764,34 +824,51 @@ local void send_tree (s, tree, max_code)
int min_count = 4; /* min repeat count */
/* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ }
for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
+ curlen = nextlen;
+ nextlen = tree[n+1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
+ }
+ else if (count < min_count) {
+ do {
+ send_code(s, curlen, s->bl_tree);
+ }
+ while (--count != 0);
- } else if (curlen != 0) {
+ }
+ else if (curlen != 0) {
if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
+ send_code(s, curlen, s->bl_tree);
+ count--;
}
Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
+ send_code(s, REP_3_6, s->bl_tree);
+ send_bits(s, count-3, 2);
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
+ }
+ else if (count <= 10) {
+ send_code(s, REPZ_3_10, s->bl_tree);
+ send_bits(s, count-3, 3);
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
}
- count = 0; prevlen = curlen;
+ else {
+ send_code(s, REPZ_11_138, s->bl_tree);
+ send_bits(s, count-11, 7);
+ }
+ count = 0;
+ prevlen = curlen;
if (nextlen == 0) {
max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
+ }
+ else if (curlen == nextlen) {
max_count = 6, min_count = 3;
- } else {
+ }
+ else {
max_count = 7, min_count = 4;
}
}
@@ -802,7 +879,7 @@ local void send_tree (s, tree, max_code)
* bl_order of the last bit length code to send.
*/
local int build_bl_tree(s)
- deflate_state *s;
+deflate_state *s;
{
int max_blindex; /* index of last bit length code of non zero freq */
@@ -821,7 +898,9 @@ local int build_bl_tree(s)
* 3 but the actual value used is 4.)
*/
for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
+ if (s->bl_tree[bl_order[max_blindex]].Len != 0) {
+ break;
+ }
}
/* Update opt_len to include the bit length tree and counts */
s->opt_len += 3*(max_blindex+1) + 5+5+4;
@@ -837,8 +916,8 @@ local int build_bl_tree(s)
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
*/
local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
+deflate_state *s;
+int lcodes, dcodes, blcodes; /* number of codes for each tree */
{
int rank; /* index in bl_order */
@@ -866,10 +945,10 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
* Send a stored block
*/
void _tr_stored_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
+deflate_state *s;
+charf *buf; /* input block */
+ulg stored_len; /* length of input block */
+int eof; /* true if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
#ifdef DEBUG
@@ -891,7 +970,7 @@ void _tr_stored_block(s, buf, stored_len, eof)
* on one bit only.
*/
void _tr_align(s)
- deflate_state *s;
+deflate_state *s;
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
@@ -920,10 +999,10 @@ void _tr_align(s)
* trees or store, and output the encoded block to the zip file.
*/
void _tr_flush_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
+deflate_state *s;
+charf *buf; /* input block, or NULL if too old */
+ulg stored_len; /* length of input block */
+int eof; /* true if this is the last block for a file */
{
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
int max_blindex = 0; /* index of last bit length code of non zero freq */
@@ -932,8 +1011,9 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (s->level > 0) {
/* Check if the file is binary or text */
- if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
+ if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) {
set_data_type(s);
+ }
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
@@ -960,9 +1040,12 @@ void _tr_flush_block(s, buf, stored_len, eof)
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
s->last_lit));
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
+ if (static_lenb <= opt_lenb) {
+ opt_lenb = static_lenb;
+ }
- } else {
+ }
+ else {
Assert(buf != (char*)0, "lost buf");
opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
}
@@ -971,7 +1054,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (buf != (char*)0) { /* force stored block */
#else
if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
+ /* 4: two words for the lengths */
#endif
/* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
* Otherwise we can't have processed more than WSIZE input bytes since
@@ -982,16 +1065,19 @@ void _tr_flush_block(s, buf, stored_len, eof)
_tr_stored_block(s, buf, stored_len, eof);
#ifdef FORCE_STATIC
- } else if (static_lenb >= 0) { /* force static trees */
+ }
+ else if (static_lenb >= 0) { /* force static trees */
#else
- } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
+ }
+ else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
#endif
send_bits(s, (STATIC_TREES<<1)+eof, 3);
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->static_len;
#endif
- } else {
+ }
+ else {
send_bits(s, (DYN_TREES<<1)+eof, 3);
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1);
@@ -1013,7 +1099,7 @@ void _tr_flush_block(s, buf, stored_len, eof)
#endif
}
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*eof));
+ s->compressed_len-7*eof));
}
/* ===========================================================================
@@ -1021,16 +1107,17 @@ void _tr_flush_block(s, buf, stored_len, eof)
* the current block must be flushed.
*/
int _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
+deflate_state *s;
+unsigned dist; /* distance of matched string */
+unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
{
s->d_buf[s->last_lit] = (ush)dist;
s->l_buf[s->last_lit++] = (uch)lc;
if (dist == 0) {
/* lc is the unmatched char */
s->dyn_ltree[lc].Freq++;
- } else {
+ }
+ else {
s->matches++;
/* Here, lc is the match length - MIN_MATCH */
dist--; /* dist = match distance - 1 */
@@ -1051,13 +1138,15 @@ int _tr_tally (s, dist, lc)
int dcode;
for (dcode = 0; dcode < D_CODES; dcode++) {
out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
+ (5L+extra_dbits[dcode]);
}
out_length >>= 3;
Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
+ s->last_lit, in_length, out_length,
+ 100L - out_length*100L/in_length));
+ if (s->matches < s->last_lit/2 && out_length < in_length/2) {
+ return 1;
+ }
}
#endif
return (s->last_lit == s->lit_bufsize-1);
@@ -1071,9 +1160,9 @@ int _tr_tally (s, dist, lc)
* Send the block data compressed using the given Huffman trees
*/
local void compress_block(s, ltree, dtree)
- deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
+deflate_state *s;
+ct_data *ltree; /* literal tree */
+ct_data *dtree; /* distance tree */
{
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
@@ -1082,37 +1171,39 @@ local void compress_block(s, ltree, dtree)
int extra; /* number of extra bits to send */
if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = _length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
+ dist = s->d_buf[lx];
+ lc = s->l_buf[lx++];
+ if (dist == 0) {
+ send_code(s, lc, ltree); /* send a literal byte */
+ Tracecv(isgraph(lc), (stderr," '%c' ", lc));
}
- } /* literal or match pair ? */
+ else {
+ /* Here, lc is the match length - MIN_MATCH */
+ code = _length_code[lc];
+ send_code(s, code+LITERALS+1, ltree); /* send the length code */
+ extra = extra_lbits[code];
+ if (extra != 0) {
+ lc -= base_length[code];
+ send_bits(s, lc, extra); /* send the extra length bits */
+ }
+ dist--; /* dist is now the match distance - 1 */
+ code = d_code(dist);
+ Assert (code < D_CODES, "bad d_code");
+
+ send_code(s, code, dtree); /* send the distance code */
+ extra = extra_dbits[code];
+ if (extra != 0) {
+ dist -= base_dist[code];
+ send_bits(s, dist, extra); /* send the extra distance bits */
+ }
+ } /* literal or match pair ? */
+
+ /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
+ Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
+ "pendingBuf overflow");
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
- "pendingBuf overflow");
-
- } while (lx < s->last_lit);
+ }
+ while (lx < s->last_lit);
send_code(s, END_BLOCK, ltree);
s->last_eob_len = ltree[END_BLOCK].Len;
@@ -1125,17 +1216,19 @@ local void compress_block(s, ltree, dtree)
* IN assertion: the fields Freq of dyn_ltree are set.
*/
local void set_data_type(s)
- deflate_state *s;
+deflate_state *s;
{
int n;
for (n = 0; n < 9; n++)
- if (s->dyn_ltree[n].Freq != 0)
+ if (s->dyn_ltree[n].Freq != 0) {
break;
+ }
if (n == 9)
for (n = 14; n < 32; n++)
- if (s->dyn_ltree[n].Freq != 0)
+ if (s->dyn_ltree[n].Freq != 0) {
break;
+ }
s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
}
@@ -1145,14 +1238,15 @@ local void set_data_type(s)
* IN assertion: 1 <= len <= 15
*/
local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
+unsigned code; /* the value to invert */
+int len; /* its bit length */
{
register unsigned res = 0;
do {
res |= code & 1;
code >>= 1, res <<= 1;
- } while (--len > 0);
+ }
+ while (--len > 0);
return res >> 1;
}
@@ -1160,13 +1254,14 @@ local unsigned bi_reverse(code, len)
* Flush the bit buffer, keeping at most 7 bits in it.
*/
local void bi_flush(s)
- deflate_state *s;
+deflate_state *s;
{
if (s->bi_valid == 16) {
put_short(s, s->bi_buf);
s->bi_buf = 0;
s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
+ }
+ else if (s->bi_valid >= 8) {
put_byte(s, (Byte)s->bi_buf);
s->bi_buf >>= 8;
s->bi_valid -= 8;
@@ -1177,11 +1272,12 @@ local void bi_flush(s)
* Flush the bit buffer and align the output on a byte boundary
*/
local void bi_windup(s)
- deflate_state *s;
+deflate_state *s;
{
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
+ }
+ else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf);
}
s->bi_buf = 0;
@@ -1196,10 +1292,10 @@ local void bi_windup(s)
* one's complement if requested.
*/
local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
+deflate_state *s;
+charf *buf; /* the input data */
+unsigned len; /* its length */
+int header; /* true if block header must be written */
{
bi_windup(s); /* align on byte boundary */
s->last_eob_len = 8; /* enough lookahead for inflate */
diff --git a/tinySIGCOMP/src/trees.h b/tinySIGCOMP/src/trees.h
index f8ce546..4a28457 100755
--- a/tinySIGCOMP/src/trees.h
+++ b/tinySIGCOMP/src/trees.h
@@ -2,129 +2,129 @@
/* header created automatically with -DGEN_TREES_H */
local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
-{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
-{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
-{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
-{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
-{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
-{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
-{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
-{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
-{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
-{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
-{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
-{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
-{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
-{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
-{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
-{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
-{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
-{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
-{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
-{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
-{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
-{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
-{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
-{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
-{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
-{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
-{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
-{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
-{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
-{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
-{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
-{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
-{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
-{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
-{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
-{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
-{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
-{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
-{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
-{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
-{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
-{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
-{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
-{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
-{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
-{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
-{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
-{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
-{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
-{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
-{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
-{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
-{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
-{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
-{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
-{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
-{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
+ {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
+ {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
+ {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
+ {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
+ {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
+ {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
+ {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
+ {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
+ {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
+ {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
+ {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
+ {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
+ {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
+ {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
+ {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
+ {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
+ {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
+ {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
+ {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
+ {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
+ {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
+ {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
+ {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
+ {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
+ {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
+ {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
+ {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
+ {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
+ {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
+ {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
+ {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
+ {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
+ {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
+ {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
+ {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
+ {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
+ {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
+ {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
+ {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
+ {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
+ {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
+ {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
+ {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
+ {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
+ {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
+ {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
+ {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
+ {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
+ {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
+ {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
+ {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
+ {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
+ {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
+ {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
+ {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
+ {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
+ {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
+ {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
};
local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
+ {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
+ {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
+ {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
+ {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
+ {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
+ {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
};
const uch _dist_code[DIST_CODE_LEN] = {
- 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
-10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
+ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
+ 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
+ 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+ 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
};
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
-13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
-17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
+ 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
+ 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
+ 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
};
local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
+ 64, 80, 96, 112, 128, 160, 192, 224, 0
};
local const int base_dist[D_CODES] = {
0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
- 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
- 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
+ 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
+ 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
};
#endif // HAS_ZLIB
diff --git a/tinySIGCOMP/src/zconf.h b/tinySIGCOMP/src/zconf.h
index 789f0ed..d2f765f 100755
--- a/tinySIGCOMP/src/zconf.h
+++ b/tinySIGCOMP/src/zconf.h
@@ -164,7 +164,7 @@
for small objects.
*/
- /* Type declarations */
+/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
@@ -182,7 +182,7 @@
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
+/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
@@ -191,7 +191,7 @@
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
+/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
@@ -202,9 +202,9 @@
#endif
#if defined(WINDOWS) || defined(WIN32) || defined(__SYMBIAN32__)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
+/* If building or using zlib as a DLL, define ZLIB_DLL.
+ * This is not mandatory, but it offers a little performance increase.
+ */
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
@@ -214,17 +214,17 @@
# endif
# endif
# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
+/* If building or using zlib with the WINAPI/WINAPIV calling convention,
+ * define ZLIB_WINAPI.
+ * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+ */
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+/* No need for _export, use ZLIB.DEF instead. */
+/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
@@ -267,10 +267,10 @@ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
- typedef Byte FAR Bytef;
+typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
@@ -278,13 +278,13 @@ typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
+typedef void const *voidpc;
+typedef void FAR *voidpf;
+typedef void *voidp;
#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
+typedef Byte const *voidpc;
+typedef Byte FAR *voidpf;
+typedef Byte *voidp;
#endif
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
diff --git a/tinySIGCOMP/src/zlib.h b/tinySIGCOMP/src/zlib.h
index 33ed30f..c68bf08 100755
--- a/tinySIGCOMP/src/zlib.h
+++ b/tinySIGCOMP/src/zlib.h
@@ -158,7 +158,7 @@ typedef gz_header FAR *gz_headerp;
a single step).
*/
- /* constants */
+/* constants */
#define Z_NO_FLUSH 0
#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
@@ -208,7 +208,7 @@ typedef gz_header FAR *gz_headerp;
#define zlib_version zlibVersion()
/* for compatibility with versions < 1.0.2 */
- /* basic functions */
+/* basic functions */
ZEXTERN const char * ZEXPORT zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
@@ -471,7 +471,7 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
static string (which must not be deallocated).
*/
- /* Advanced functions */
+/* Advanced functions */
/*
The following functions are needed only in some special applications.
@@ -537,8 +537,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
*/
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
+ const Bytef *dictionary,
+ uInt dictLength));
/*
Initializes the compression dictionary from the given byte sequence
without producing any compressed output. This function must be called
@@ -668,7 +668,7 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
*/
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
- gz_headerp head));
+ gz_headerp head));
/*
deflateSetHeader() provides gzip header information for when a gzip
stream is requested by deflateInit2(). deflateSetHeader() may be called
@@ -735,8 +735,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
*/
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
+ const Bytef *dictionary,
+ uInt dictLength));
/*
Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate,
@@ -814,7 +814,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
*/
ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
- gz_headerp head));
+ gz_headerp head));
/*
inflateGetHeader() requests that gzip header information be stored in the
provided gz_header structure. inflateGetHeader() may be called after
@@ -997,7 +997,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
*/
- /* utility functions */
+/* utility functions */
/*
The following utility functions are implemented on top of the
@@ -1250,7 +1250,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
file that is being written concurrently.
*/
- /* checksum functions */
+/* checksum functions */
/*
These functions are not related to compression but are exported
@@ -1275,7 +1275,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
*/
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
- z_off_t len2));
+ z_off_t len2));
/*
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
@@ -1310,7 +1310,7 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
*/
- /* various hacks, don't look :) */
+/* various hacks, don't look :) */
/* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream:
@@ -1326,9 +1326,9 @@ ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size));
ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
+ unsigned char FAR *window,
+ const char *version,
+ int stream_size));
#define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
#define inflateInit(strm) \
@@ -1344,7 +1344,9 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
+struct internal_state {
+ int dummy;
+}; /* hack for buggy compilers */
#endif
ZEXTERN const char * ZEXPORT zError OF((int));
diff --git a/tinySIGCOMP/src/zutil.c b/tinySIGCOMP/src/zutil.c
index dab7e2f..49b430e 100755
--- a/tinySIGCOMP/src/zutil.c
+++ b/tinySIGCOMP/src/zutil.c
@@ -9,20 +9,23 @@
#include "zutil.h"
#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
+struct internal_state {
+ int dummy;
+}; /* for buggy compilers */
#endif
const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
+ "need dictionary", /* Z_NEED_DICT 2 */
+ "stream end", /* Z_STREAM_END 1 */
+ "", /* Z_OK 0 */
+ "file error", /* Z_ERRNO (-1) */
+ "stream error", /* Z_STREAM_ERROR (-2) */
+ "data error", /* Z_DATA_ERROR (-3) */
+ "insufficient memory", /* Z_MEM_ERROR (-4) */
+ "buffer error", /* Z_BUF_ERROR (-5) */
+ "incompatible version",/* Z_VERSION_ERROR (-6) */
+ ""
+};
const char * ZEXPORT zlibVersion()
@@ -36,28 +39,52 @@ uLong ZEXPORT zlibCompileFlags()
flags = 0;
switch (sizeof(uInt)) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
+ case 2:
+ break;
+ case 4:
+ flags += 1;
+ break;
+ case 8:
+ flags += 2;
+ break;
+ default:
+ flags += 3;
}
switch (sizeof(uLong)) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
+ case 2:
+ break;
+ case 4:
+ flags += 1 << 2;
+ break;
+ case 8:
+ flags += 2 << 2;
+ break;
+ default:
+ flags += 3 << 2;
}
switch (sizeof(voidpf)) {
- case 2: break;
- case 4: flags += 1 << 4; break;
- case 8: flags += 2 << 4; break;
- default: flags += 3 << 4;
+ case 2:
+ break;
+ case 4:
+ flags += 1 << 4;
+ break;
+ case 8:
+ flags += 2 << 4;
+ break;
+ default:
+ flags += 3 << 4;
}
switch (sizeof(z_off_t)) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
+ case 2:
+ break;
+ case 4:
+ flags += 1 << 6;
+ break;
+ case 8:
+ flags += 2 << 6;
+ break;
+ default:
+ flags += 3 << 6;
}
#ifdef DEBUG
flags += 1 << 8;
@@ -88,25 +115,25 @@ uLong ZEXPORT zlibCompileFlags()
#endif
#ifdef STDC
# ifdef NO_vsnprintf
- flags += 1L << 25;
+ flags += 1L << 25;
# ifdef HAS_vsprintf_void
- flags += 1L << 26;
+ flags += 1L << 26;
# endif
# else
# ifdef HAS_vsnprintf_void
- flags += 1L << 26;
+ flags += 1L << 26;
# endif
# endif
#else
- flags += 1L << 24;
+ flags += 1L << 24;
# ifdef NO_snprintf
- flags += 1L << 25;
+ flags += 1L << 25;
# ifdef HAS_sprintf_void
- flags += 1L << 26;
+ flags += 1L << 26;
# endif
# else
# ifdef HAS_snprintf_void
- flags += 1L << 26;
+ flags += 1L << 26;
# endif
# endif
#endif
@@ -121,7 +148,7 @@ uLong ZEXPORT zlibCompileFlags()
int z_verbose = verbose;
void z_error (m)
- char *m;
+char *m;
{
fprintf(stderr, "%s\n", m);
exit(1);
@@ -132,53 +159,61 @@ void z_error (m)
* uncompress()
*/
const char * ZEXPORT zError(err)
- int err;
+int err;
{
return ERR_MSG(err);
}
#if defined(_WIN32_WCE)
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used.
- */
- int errno = 0;
+/* The Microsoft C Run-Time Library for Windows CE doesn't have
+ * errno. We define it as a global variable to simplify porting.
+ * Its value is always 0 and should not be used.
+ */
+int errno = 0;
#endif
#ifndef HAVE_MEMCPY
void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
+Bytef* dest;
+const Bytef* source;
+uInt len;
{
- if (len == 0) return;
+ if (len == 0) {
+ return;
+ }
do {
*dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
+ }
+ while (--len != 0);
}
int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
+const Bytef* s1;
+const Bytef* s2;
+uInt len;
{
uInt j;
for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
+ if (s1[j] != s2[j]) {
+ return 2*(s1[j] > s2[j])-1;
+ }
}
return 0;
}
void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
+Bytef* dest;
+uInt len;
{
- if (len == 0) return;
+ if (len == 0) {
+ return;
+ }
do {
*dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
+ }
+ while (--len != 0);
}
#endif
@@ -224,11 +259,16 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
*/
if (bsize < 65520L) {
buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
+ if (*(ush*)&buf != 0) {
+ return buf;
+ }
+ }
+ else {
buf = farmalloc(bsize + 16L);
}
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
+ if (buf == NULL || next_ptr >= MAX_PTR) {
+ return NULL;
+ }
table[next_ptr].org_ptr = buf;
/* Normalize the pointer to seg:0 */
@@ -247,7 +287,9 @@ void zcfree (voidpf opaque, voidpf ptr)
}
/* Find the original pointer */
for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
+ if (ptr != table[n].new_ptr) {
+ continue;
+ }
farfree(table[n].org_ptr);
while (++n < next_ptr) {
@@ -275,13 +317,17 @@ void zcfree (voidpf opaque, voidpf ptr)
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
- if (opaque) opaque = 0; /* to make compiler happy */
+ if (opaque) {
+ opaque = 0; /* to make compiler happy */
+ }
return _halloc((long)items, size);
}
void zcfree (voidpf opaque, voidpf ptr)
{
- if (opaque) opaque = 0; /* to make compiler happy */
+ if (opaque) {
+ opaque = 0; /* to make compiler happy */
+ }
_hfree(ptr);
}
@@ -299,21 +345,25 @@ extern void free OF((voidpf ptr));
#endif
voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
+voidpf opaque;
+unsigned items;
+unsigned size;
{
- if (opaque) items += size - size; /* make compiler happy */
+ if (opaque) {
+ items += size - size; /* make compiler happy */
+ }
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
+ (voidpf)calloc(items, size);
}
void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
+voidpf opaque;
+voidpf ptr;
{
free(ptr);
- if (opaque) return; /* make compiler happy */
+ if (opaque) {
+ return; /* make compiler happy */
+ }
}
#endif /* MY_ZCALLOC */
diff --git a/tinySIGCOMP/src/zutil.h b/tinySIGCOMP/src/zutil.h
index 3761182..f6990b9 100755
--- a/tinySIGCOMP/src/zutil.h
+++ b/tinySIGCOMP/src/zutil.h
@@ -26,14 +26,14 @@
#endif
#ifdef NO_ERRNO_H
# ifdef _WIN32_WCE
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used. We rename it to
- * avoid conflict with other libraries that use the same workaround.
- */
+/* The Microsoft C Run-Time Library for Windows CE doesn't have
+ * errno. We define it as a global variable to simplify porting.
+ * Its value is always 0 and should not be used. We rename it to
+ * avoid conflict with other libraries that use the same workaround.
+ */
# define errno z_errno
# endif
- extern int errno;
+extern int errno;
#else
# ifndef _WIN32_WCE
# include <errno.h>
@@ -60,7 +60,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
- /* common constants */
+/* common constants */
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS
@@ -85,15 +85,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
- /* target dependencies */
+/* target dependencies */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
+/* Allow compilation with ANSI keywords only enabled */
+void _Cdecl farfree( void *block );
+void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# endif
@@ -119,7 +119,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
- #include <malloc.h>
+#include <malloc.h>
# endif
#endif
@@ -156,7 +156,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
+typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# else
@@ -164,7 +164,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif
- /* common defaults */
+/* common defaults */
#ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */
@@ -174,7 +174,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define F_OPEN(name, mode) fopen((name), (mode))
#endif
- /* functions */
+/* functions */
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
# ifndef HAVE_VSNPRINTF
@@ -188,15 +188,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
- /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
+/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
+ but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
- /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
+/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# define vsnprintf _vsnprintf
# endif
@@ -213,10 +213,10 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
+/* Use our own functions for small and medium model with MSC <= 5.0.
+ * You may have to use the same strategy for Borland C (untested).
+ * The __SC__ check is for Symantec.
+ */
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
@@ -233,16 +233,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
+extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
+extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
+extern void zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
# include <stdio.h>
- extern int z_verbose;
- extern void z_error OF((char *m));
+extern int z_verbose;
+extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
diff --git a/tinySIGCOMP/test/rfc4465_torture_tests.h b/tinySIGCOMP/test/rfc4465_torture_tests.h
index 11d9437..891611a 100755
--- a/tinySIGCOMP/test/rfc4465_torture_tests.h
+++ b/tinySIGCOMP/test/rfc4465_torture_tests.h
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -21,16 +21,18 @@
#ifndef _RFC4465_TORTURE_TESTS_H_
#define _RFC4465_TORTURE_TESTS_H_
-typedef struct rfc4465_struct_torture_test
-{
- const char* section_name;
- const char* bytecode;
- size_t bytecode_size;
- struct{ tsk_size_t size; const char* ptr; } xoutput; // Excepted output
- signed xcycles; // Excepted cycles
- int stream;
- int xfail;
- const char* comp_id;
+typedef struct rfc4465_struct_torture_test {
+ const char* section_name;
+ const char* bytecode;
+ size_t bytecode_size;
+ struct {
+ tsk_size_t size;
+ const char* ptr;
+ } xoutput; // Excepted output
+ signed xcycles; // Excepted cycles
+ int stream;
+ int xfail;
+ const char* comp_id;
}
struct_torture_test, *lpstruct_torture_test;
@@ -66,7 +68,7 @@ struct_torture_test, *lpstruct_torture_test;
*/
#define RFC4465_A_1_4__SHA1 \
"\xf8\x08\x71\x0d\xa0\xc3\x03\xa0\x44\x22\xa0\x44\x14\x0d\xa0\xc6\x38\xa0\x44\x22\xa0\x44\x14\x0e\x86\xa0\xfe\x0e\xa0\x42\xa0\xff\x0d\xa0\xfe\x8e\xa0\x44\x22\xa0\x44\x14\x0e\x86\xa0\xff\x0e\xa0\x42\xa1\x07\x0d\xa0\xff\xa2\x80\xa0\xff\x22\xa0\xff\x14\x23\x00\x00\x00\x00\x00\x00\x00\x61\x62\x63\x61\x62\x63\x64\x62\x63\x64\x65\x63\x64\x65\x66\x64\x65\x66\x67\x65\x66\x67\x68\x66\x67\x68\x69\x67\x68\x69\x6a\x68\x69\x6a\x6b\x69\x6a\x6b\x6c\x6a\x6b\x6c\x6d\x6b\x6c\x6d\x6e\x6c\x6d\x6e\x6f\x6d\x6e\x6f\x70\x6e\x6f\x70\x71\x61\x30\x31\x32\x33\x34\x35\x36\x37"
-
+
/*************************************************************
*** A.1.5. LOAD and MULTILOAD
@@ -86,21 +88,21 @@ struct_torture_test, *lpstruct_torture_test;
*/
#define RFC4465_A_1_6__COPY \
"\xf8\x03\x91\x0e\x20\x8e\x0e\x86\x86\x0e\xa0\x42\x87\x12\x20\x87\x21\x0e\x86\x80\x41\x00\x12\x86\xa0\x55\xa0\x41\x22\x20\xa0\x77\x0e\x86\x20\x0e\xa0\x42\x30\x15\x20\x04\xa0\x41\x01\x12\x20\x04\x30\x22\x30\x04\x12\x30\x04\x2e\x22\x20\x02\x23"
-
+
/*************************************************************
*** A.1.7. COPY-LITERAL and COPY-OFFSET
*/
#define RFC4465_A_1_7__COPY_LITERAL_and_COPY_OFFSET \
"\xf8\x06\x11\x0e\x20\x80\x41\x00\x0e\x86\x86\x0e\xa0\x42\x87\x0e\xa0\x44\x21\x13\x20\x87\x22\x22\x86\x08\x0e\xa0\x44\xa0\x9c\x13\x20\x02\x22\x22\xa0\x9c\x02\x0e\x86\xa0\x48\x0e\xa0\x42\xa0\x52\x0e\xa0\x44\xa0\x52\x15\xa0\x48\x0a\xa0\x41\x01\x14\x02\x06\x22\x0e\xa0\x46\x06\x14\x63\x04\x22\x22\x61\x0a\x0e\xa0\x44\xa0\x50\x14\x04\x04\x22\x22\xa0\x44\x02\x14\x05\x04\x22\x22\xa0\x44\x02\x22\x60\x0a\x23"
-
+
/*************************************************************
*** A.1.8. MEMSET
*/
#define RFC4465_A_1_8__MEMSET \
"\xf8\x01\x81\x0e\x86\x87\x0e\xa0\x42\xa0\x81\x15\x86\xa0\x81\x00\x01\x15\xa0\x81\x0f\x86\x0f\x22\x87\x10\x23"
-
+
/*************************************************************
*** A.1.9. CRC
@@ -111,7 +113,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_9__CRC_2 \
"\xf8\x01\x81\x15\xa0\x46\x18\x01\x01\x15\xa0\x5e\x14\x87\x01\x1c\x02\xa0\x44\x13\x1b\x62\xa0\x46\x2c\x0e\x23"\
"\xab\xcb"
-
+
/*************************************************************
*** A.1.10. INPUT-BITS
@@ -119,7 +121,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_10__INPUT_BITS \
"\xf8\x01\x51\x1d\x62\xa0\x46\x14\x22\xa0\x46\x02\x06\x22\x01\x0a\x22\x07\x06\x22\x01\x16\xee\x23"\
"\x93\x2e\xac\x71"
-
+
/*************************************************************
*** A.1.11. INPUT-HUFFMAN
@@ -127,7 +129,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_11__INPUT_HUFFMAN \
"\xf8\x01\xd1\x1e\xa0\x46\x1c\x02\x62\x00\x62\x62\x62\x00\xff\x00\x22\xa0\x46\x02\x06\x22\x01\x0a\x22\x07\x06\x22\x01\x16\xe6\x23"\
"\x93\x2e\xac\x71\x66\xd8\x6f"
-
+
/*************************************************************
@@ -136,21 +138,21 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_12__INPUT_BYTES \
"\xf8\x02\x71\x0e\x86\xa0\x48\x0e\xa0\x42\xa0\x4c\x1d\x62\xa0\x46\x1d\x22\xa0\x46\x02\x06\x22\x02\x0a\x22\x07\x1c\x62\xa0\x48\x0e\x22\xa0\x48\x62\x06\x22\x01\x16\xe5\x23"\
"\x93\x2e\xac\x71\x66\xd8\x6f\xb1\x59\x2b\xdc\x9a\x97\x34\xd8\x47\xa7\x33\x87\x4e\x1b\xcb\xcd\x51\xb5\xdc\x96\x59\x9d\x6a"
-
+
/*************************************************************
*** A.1.13. Stack Manipulation
*/
#define RFC4465_A_1_13__Stack_Manipulation \
"\xf8\x14\x11\x0e\xa0\x46\x86\x10\x02\x10\x60\x10\xa0\x42\x22\x86\x08\x11\x86\x11\x63\x11\xa0\x46\x22\x86\x08\x16\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\xa0\x46\x20\x0e\xa0\x48\xa1\x40\x07\x24\x88\x18\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x64\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\xa0\x46\xa1\x7f\x0e\xa1\x7f\x1a\x0f\xa1\xb0\x03\x01\x80\xc0\x01\x8f\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23"
-
+
/*************************************************************
*** A.1.14. Program Flow
*/
#define RFC4465_A_1_14__Program_Flow \
"\xf8\x03\xf1\x0e\xa0\x44\x04\x0e\x86\xa0\x92\x07\x20\xa0\x90\x22\xa0\x43\x01\x16\x60\x06\x21\x01\x0e\x86\xa0\x84\x07\x20\xa0\xa1\x22\xa0\x43\x01\x17\x61\x06\x60\xf1\x06\x07\x22\x01\x0e\x86\xa0\x84\x07\x20\xa0\xb6\x22\xa0\x43\x01\x1a\x04\x62\x08\x60\x9f\xdc\xf1\x23"
-
+
/*************************************************************
*** A.1.15. State Creation_1
@@ -158,7 +160,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_1 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x01"
-
+
/*************************************************************
*** A.1.15. State Creation_2
@@ -166,7 +168,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_2 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x02"
-
+
/*************************************************************
*** A.1.15. State Creation_3
@@ -174,7 +176,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_3 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x03"
-
+
/*************************************************************
*** A.1.15. State Creation_4
@@ -182,7 +184,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_4 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x04\x05"
-
+
/*************************************************************
*** A.1.15. State Creation_5
@@ -190,7 +192,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_5 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x04\x15"
-
+
/*************************************************************
*** A.1.15. State Creation_6
@@ -198,7 +200,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_6 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x04\x06"
-
+
/*************************************************************
*** A.1.15. State Creation_7
@@ -206,7 +208,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_7 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x09"
-
+
/*************************************************************
*** A.1.15. State Creation_8
@@ -214,7 +216,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_8 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x1e\x06"
-
+
/*************************************************************
*** A.1.15. State Creation_9
@@ -222,7 +224,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_9 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x1e\x07"
-
+
/*************************************************************
*** A.1.15. State Creation_10
@@ -230,7 +232,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_15__State_Creation_10 \
"\xf8\x09\x41\x1c\x01\xa0\x45\xff\x04\x22\x0b\x17\x62\x8f\x0d\x06\x06\x20\x0a\xa1\x0a\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x0c\x06\x06\x20\x0a\x88\x00\x14\x00\x04\x22\x01\x17\x62\x8f\x16\x06\x06\x1c\x01\xa0\x47\x9f\xd2\x21\xa0\x48\x63\x12\xa0\xe3\x63\xa0\x48\x04\x22\x01\x17\x62\x8f\x0a\x06\x06\x21\xa0\xe3\x06\x04\x22\x01\x17\x62\x8f\x0e\x06\x06\x23\x00\x00\x0a\x88\x00\x14\x00\x23\x00\x00\x00\x00\x00\x00\x00\x43\x7a\xe8\x0a\x0f\xdc\x1e\x6a\x87\xc1\xb6\x2a\x76\x76\xb9\x73\x31\x8c\x0e\xf5\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xcc\x3f\xee\x79\xbc\xfc\x8f\xd1\x08\x65\xe8\x03\x52\xee\x29\x77\x17\xdf\x57"\
"\x1e\14"
-
+
/*************************************************************
*** A.1.16. STATE-ACCESS Set up bytecode}
@@ -238,7 +240,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_16__STATE_ACCESS__SETUP \
"\xf8\x19\x01\x23\x00\x00\x10\x89\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x22\xa2\x0c\x04\x23\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74"\
""
-
+
/*************************************************************
*** A.1.16. STATE-ACCESS_1
@@ -246,7 +248,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_16__STATE_ACCESS_1 \
"\xf8\x19\x41\x1c\x01\xa0\x45\xff\x17\x62\x01\x06\x0d\x1c\x1f\x89\x14\x00\x00\x00\x89\x1f\x89\x14\x0c\x04\xa0\x46\x00\x22\xa0\x46\x04\x16\xa1\x46\x17\x62\x03\x06\x10\x1b\x1f\x87\x14\x00\x00\x00\x00\x16\xa1\x36\x1f\x89\x13\x06\x04\xa0\x46\x00\x16\xa1\x2b\x1f\x89\x14\x0c\x05\xa0\x46\x00\x16\xa1\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5d\xf8\xbc\x3e\x20\x93\xb5\xab\xe1\xf1\x70\x13\x42\x4c\xe7\xfe\x05\xe0\x69\x39"\
"\x00"
-
+
/*************************************************************
*** A.1.16. STATE-ACCESS_2
@@ -254,7 +256,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_16__STATE_ACCESS_2 \
"\xf8\x19\x41\x1c\x01\xa0\x45\xff\x17\x62\x01\x06\x0d\x1c\x1f\x89\x14\x00\x00\x00\x89\x1f\x89\x14\x0c\x04\xa0\x46\x00\x22\xa0\x46\x04\x16\xa1\x46\x17\x62\x03\x06\x10\x1b\x1f\x87\x14\x00\x00\x00\x00\x16\xa1\x36\x1f\x89\x13\x06\x04\xa0\x46\x00\x16\xa1\x2b\x1f\x89\x14\x0c\x05\xa0\x46\x00\x16\xa1\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5d\xf8\xbc\x3e\x20\x93\xb5\xab\xe1\xf1\x70\x13\x42\x4c\xe7\xfe\x05\xe0\x69\x39"\
"\x01"
-
+
/*************************************************************
*** A.1.16. STATE-ACCESS_3
@@ -262,7 +264,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_16__STATE_ACCESS_3 \
"\xf8\x19\x41\x1c\x01\xa0\x45\xff\x17\x62\x01\x06\x0d\x1c\x1f\x89\x14\x00\x00\x00\x89\x1f\x89\x14\x0c\x04\xa0\x46\x00\x22\xa0\x46\x04\x16\xa1\x46\x17\x62\x03\x06\x10\x1b\x1f\x87\x14\x00\x00\x00\x00\x16\xa1\x36\x1f\x89\x13\x06\x04\xa0\x46\x00\x16\xa1\x2b\x1f\x89\x14\x0c\x05\xa0\x46\x00\x16\xa1\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5d\xf8\xbc\x3e\x20\x93\xb5\xab\xe1\xf1\x70\x13\x42\x4c\xe7\xfe\x05\xe0\x69\x39"\
"\x02"
-
+
/*************************************************************
*** A.1.16. STATE-ACCESS_4
@@ -270,7 +272,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_16__STATE_ACCESS_4 \
"\xf8\x19\x41\x1c\x01\xa0\x45\xff\x17\x62\x01\x06\x0d\x1c\x1f\x89\x14\x00\x00\x00\x89\x1f\x89\x14\x0c\x04\xa0\x46\x00\x22\xa0\x46\x04\x16\xa1\x46\x17\x62\x03\x06\x10\x1b\x1f\x87\x14\x00\x00\x00\x00\x16\xa1\x36\x1f\x89\x13\x06\x04\xa0\x46\x00\x16\xa1\x2b\x1f\x89\x14\x0c\x05\xa0\x46\x00\x16\xa1\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5d\xf8\xbc\x3e\x20\x93\xb5\xab\xe1\xf1\x70\x13\x42\x4c\xe7\xfe\x05\xe0\x69\x39"\
"\x03"
-
+
/*************************************************************
*** A.1.16. STATE-ACCESS_5
@@ -278,11 +280,11 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_1_16__STATE_ACCESS_5 \
"\xf8\x19\x41\x1c\x01\xa0\x45\xff\x17\x62\x01\x06\x0d\x1c\x1f\x89\x14\x00\x00\x00\x89\x1f\x89\x14\x0c\x04\xa0\x46\x00\x22\xa0\x46\x04\x16\xa1\x46\x17\x62\x03\x06\x10\x1b\x1f\x87\x14\x00\x00\x00\x00\x16\xa1\x36\x1f\x89\x13\x06\x04\xa0\x46\x00\x16\xa1\x2b\x1f\x89\x14\x0c\x05\xa0\x46\x00\x16\xa1\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5d\xf8\xbc\x3e\x20\x93\xb5\xab\xe1\xf1\x70\x13\x42\x4c\xe7\xfe\x05\xe0\x69\x39"\
"\x04"
-
+
/*************************************************************
*** A.2.1. Useful Values_1 (NOT from rfc4465)
-*/
+*/
#define RFC4465_A_2_1__Useful_Values_1 \
"\xf8\x05\xa1\x0e\x86\x20\x0e\xa0\x42\x21\x17\x42\x02\xf8\x06\xf8\x17\x43\x00\xf2\x06\x0c\x17\x44\x00\xec"\
"\x3f\xec\x17\x44\xa3\xc0\xe6\x07\xe6\x1c\x01\xa0\x47\x9f\xdf\x06\x23\x40\x07\x23\x01\x12\x20\x01\x63\x1c"\
@@ -295,7 +297,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_1__Useful_Values_2 \
"\xf9\x46\x84\x75\x55\xd9\x2d"\
"\x00\x00"
-
+
/*************************************************************
*** A.2.1. Useful Values_3 (NOT from rfc4465)
@@ -303,7 +305,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_1__Useful_Values_3 \
"\xf9\x46\x84\x75\x55\xd9\x2d"\
"\x00\x01"
-
+
/*************************************************************
*** A.2.1. Useful Values_4
@@ -311,7 +313,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_1__Useful_Values_4 \
"\xf9\x46\x84\x75\x55\xd9\x2d"\
"x01\x00"
-
+
/*************************************************************
*** A.2.2. Cycles Checking
@@ -319,7 +321,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_2__Cycles_Checking \
"\xf8\x01\xa1\x0f\x86\x04\x20\x29\x00\x22\x12\xa0\x44\x02\x60\x14\x02\xa0\x64\x23\x22\xa0\x44\x02\x06\x22\x01\x16\xef"\
""
-
+
/*************************************************************
*** A.2.3. Message-based Transport
@@ -327,7 +329,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_3_Message_based_Transport_1 \
"\xf8"\
""
-
+
/*************************************************************
*** A.2.3. Message-based Transport
@@ -335,7 +337,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_3_Message_based_Transport_2 \
"\xf8\x00"\
""
-
+
/*************************************************************
*** A.2.3. Message-based Transport
@@ -343,7 +345,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_3_Message_based_Transport_3 \
"\xf8\x00\xe1\x06\x00\x11\x22\x00\x02\x23\x00\x00\x00\x00\x00\x00\x01"\
""
-
+
/*************************************************************
*** A.2.3. Message-based Transport
@@ -351,7 +353,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_3_Message_based_Transport_4 \
"\xf8\x00\xf1\x06\x00\x11\x22\x00\x02\x23\x00\x00\x00\x00\x00\x00\x01"\
""
-
+
/*************************************************************
*** A.2.3. Message-based Transport
@@ -359,7 +361,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_3_Message_based_Transport_5 \
"\xf8\x00\xe0\x06\x00\x11\x22\x00\x02\x23\x00\x00\x00\x00\x00\x00\x01"\
""
-
+
/*************************************************************
*** A.2.3. Message-based Transport
@@ -367,7 +369,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_3_Message_based_Transport_6 \
"\xf8\x00\xee\x06\x00\x11\x22\x00\x02\x23\x00\x00\x00\x00\x00\x00\x01"\
""
-
+
/*************************************************************
*** A.2.4. Stream-based Transport_1 (Outputs 2 messages. This why "RFC4465_A_2_4_Stream_based_Transport_2" is missing)
@@ -375,7 +377,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_4_Stream_based_Transport_1\
"\xff\xff\xf8\x01\x71\x08\x00\x02\x22\x00\x02\x22\xa0\x92\x05\x23\x00\x00\x00\x00\x00\x00\x00\xff\x00\xff\x03\xff\xff\xff\xff\xff\xff\xff\xf8\x01\x7e\x08\x00\x02\x22\x00\x02\x22\xa3\xd2\x05\x23\x00\x00\x00\x00\x00\x00\x00\xff\x04\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"\
""
-
+
/*************************************************************
*** A.2.4. Stream-based Transport_3
@@ -383,7 +385,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_4_Stream_based_Transport_3\
"\xf8\xff\xff"\
""
-
+
/*************************************************************
*** A.2.4. Stream-based Transport_4
@@ -391,7 +393,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_4_Stream_based_Transport_4\
"\xf8\x00\xff\xff"\
""
-
+
/*************************************************************
*** A.2.4. Stream-based Transport_5
@@ -399,7 +401,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_4_Stream_based_Transport_5\
"\xf8\x01\x81\x08\x00\x02\x22\x00\x02\x22\xa0\x92\x05\x23\xff\xff\x00\x00\x00\x00\x00\x00\x00\xff\x00\xff\x03\xff\xff\xff"\
""
-
+
/*************************************************************
*** A.2.4. Stream-based Transport_6
@@ -407,7 +409,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_4_Stream_based_Transport_6\
"\xf8\x01\x70\x08\x00\x02\x22\x00\x02\x22\xa0\x92\x05\x23\xff\xff\x00\x00\x00\x00\x00\x00\x00\xff\x04\xff\xff\xff\xff"\
""
-
+
/*************************************************************
@@ -416,7 +418,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_5__Input_Past_the_End_of_a_Message_1\
"\xf8\x03\x21\x0e\x86\xa0\x46\x0e\xa0\x42\xa0\x4d\x1d\x09\xa0\x46\x0a\x1c\x07\xa0\x46\x06\x00\x1d\x07\xa0\x46\xff\x1c\x02\xa0\x46\xfa\x22\xa0\x46\x02\x1d\x10\xa0\x46\x06\x00\x1d\x08\xa0\x46\xff\x22\xa0\x47\x01\x23"\
"\xff\xfa\x00\x68\x69\x21"
-
+
/*************************************************************
*** A.2.5. Input Past the End of a Message_2
@@ -424,7 +426,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_2_5__Input_Past_the_End_of_a_Message_2\
"\xf8\x03\x21\x0e\x86\xa0\x46\x0e\xa0\x42\xa0\x4d\x1d\x09\xa0\x46\x0a\x1c\x07\xa0\x46\x06\x00\x1d\x07\xa0\x46\xff\x1c\x02\xa0\x46\xfa\x22\xa0\x46\x02\x1d\x10\xa0\x46\x06\x00\x1d\x08\xa0\x46\xff\x22\xa0\x47\x01\x23"\
"\xff\xfa\x00\x68\x69"
-
+
/*************************************************************
@@ -433,7 +435,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_1__SigComp_Feedback_Mechanism_1\
"\xf8\x05\x03\x1c\x01\xa0\x41\xa0\x55\x17\x60\x01\x07\x0e\xa0\x4f\x0e\xa0\x42\xa4\x7f\x16\x0e\x0e\xa0\x42\xa4\xff\x15\xa0\x44\xa0\x7f\x01\x01\x0e\xa0\xc3\xa8\x01\x0e\xa0\xc5\xa6\x00\x0e\xa0\xcc\xac\x00\x0e\xa0\xd9\xb4\x00\x0e\xa0\xee\xb5\x00\x15\xa0\xc6\x06\x00\x01\x15\xa0\xcd\x0c\x00\x01\x15\xa0\xda\x14\x00\x01\x23\xa0\x42\xa0\xc3"\
"\x00"
-
+
/*************************************************************
*** A.3.1. SigComp Feedback Mechanism_2
@@ -441,7 +443,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_1__SigComp_Feedback_Mechanism_2\
"\xf8\x05\x03\x1c\x01\xa0\x41\xa0\x55\x17\x60\x01\x07\x0e\xa0\x4f\x0e\xa0\x42\xa4\x7f\x16\x0e\x0e\xa0\x42\xa4\xff\x15\xa0\x44\xa0\x7f\x01\x01\x0e\xa0\xc3\xa8\x01\x0e\xa0\xc5\xa6\x00\x0e\xa0\xcc\xac\x00\x0e\xa0\xd9\xb4\x00\x0e\xa0\xee\xb5\x00\x15\xa0\xc6\x06\x00\x01\x15\xa0\xcd\x0c\x00\x01\x15\xa0\xda\x14\x00\x01\x23\xa0\x42\xa0\xc3"\
"\x01"
-
+
/*************************************************************
*** A.3.2. State Memory Management_1
@@ -449,7 +451,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_1\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x00"
-
+
/*************************************************************
*** A.3.2. State Memory Management_2
@@ -457,7 +459,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_2\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x01"
-
+
/*************************************************************
*** A.3.2. State Memory Management_3
@@ -465,7 +467,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_3\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x02"
-
+
/*************************************************************
*** A.3.2. State Memory Management_4
@@ -473,7 +475,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_4\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x03"
-
+
/*************************************************************
*** A.3.2. State Memory Management_5
@@ -481,7 +483,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_5\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x04"
-
+
/*************************************************************
*** A.3.2. State Memory Management_6
@@ -489,7 +491,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_6\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x05"
-
+
/*************************************************************
*** A.3.2. State Memory Management_7
@@ -497,7 +499,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_2__State_Memory_Management_7\
"\xf8\x1b\xa1\x0f\x86\x02\x89\xa2\x04\x1c\x01\xa0\x47\xf9\x17\x63\x05\x08\xa0\x68\xa0\x70\x17\x63\x03\x07\x34\xa0\x56\x08\x23\x06\x06\x23\xa2\x04\x0e\xa0\x44\x63\x06\x23\x06\x12\x62\x02\xa0\x4a\x17\x62\x63\x08\xa0\x58\x9f\xd2\x0e\xa0\x48\x65\x08\x24\x88\x20\x64\x89\x00\x06\x65\x06\x22\x02\x16\xe3\x1f\xa2\x16\x06\x00\x00\x00\x00\x1f\xa2\x1c\x06\x00\x00\x00\x00\x1f\xa2\x22\x06\x00\x00\x00\x00\x1f\xa2\x2e\x06\x00\x00\x00\x00\x16\x1e\x1f\xa2\x28\x06\x00\x00\x00\x00\x16\x14\x20\x8b\x89\x00\x06\x00\x16\x0c\x1f\xa2\x34\x06\x00\x00\x00\x00\x16\x02\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x74\x65\x73\x74\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x8e\xea\x4b\x43\xa7\x87\xf9\x01\x0e\xef\x56\x7b\x23\x9a\x34\x6b\x15\xa6\xb4\x0f\xc0\xe4\x4d\x2c\xd4\xa2\x21\x47\xe6\x0a\xef\xf2\xbc\x0f\xb6\xaf"\
"\x06"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_1
@@ -505,7 +507,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_1\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x00"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_2
@@ -513,7 +515,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_2\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x01"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_3
@@ -521,7 +523,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_3\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x02"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_4
@@ -529,7 +531,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_4\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x03"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_5
@@ -537,7 +539,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_5\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x04"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_6
@@ -545,7 +547,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_6\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x05"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_7
@@ -553,7 +555,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_7\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x06"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_8
@@ -561,7 +563,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_8\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x07"
-
+
/*************************************************************
*** A.3.3. Multiple Compartments_9
@@ -569,7 +571,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_3__Multiple_Compartments_9\
"\xf8\x1b\x11\x0f\x86\x02\x89\xa2\x07\x1c\x01\xa0\x45\xf9\x17\x62\x03\x0d\x3d\x06\x17\x62\x05\x37\x86\xa0\x68\x06\x22\x89\x20\xa1\xc0\x62\x00\x06\x00\x06\x22\x03\x20\xa1\xc0\x62\x00\x06\x00\x07\x22\xa2\x02\x0a\x22\x03\x06\x22\xa2\x03\x20\xa1\xc0\x62\x00\x06\x00\x20\xa1\xc0\xa2\x06\x00\x06\x62\x16\x2b\x20\xa7\xc0\x20\x00\x06\x00\x16\x22\x1f\xa2\x13\x06\x00\x00\x00\x00\x1f\xa2\x19\x06\x00\x00\x00\x00\x1f\xa2\x25\x06\x00\x00\x00\x00\x1f\xa2\x2b\x06\x00\x00\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x17\x62\x07\x06\x10\x1a\x1f\xa2\x07\x06\x00\x00\x00\x00\x16\xea\x1f\xa2\x0d\x06\x00\x00\x00\x00\x16\xe0\x1f\xa2\x1f\x06\x00\x00\x00\x00\x16\x9f\xd6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\xac\xa6\x0b\x8e\xb2\x83\x9d\xbf\xaf\xc6\x3d\xd2\x34\xc5\xd9\x1d\x53\x61\xbd\xd6\xba\x2a\xc6\x5a\x47\xc2\x18\x14\xee\x07\xc2\x75\x94\x1d\xd7\xa1\x48\x87\x9c\x8d\xe9\x0e"\
"\x08"
-
+
/*************************************************************
*** A.3.4. Accessing RFC 3485 State
@@ -577,7 +579,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_4__Accessing_RFC_3485_State\
"\xf8\x03\xa1\x1f\xa0\xa6\x14\xac\xfe\x01\x20\x00\x1f\xa0\xa6\x06\xac\xff\x01\x21\x00\x1f\xa0\xa6\x0c\xad\x00\x01\x22\x00\x22\x20\x03\x23\x00\x00\x00\x00\x00\x00\x00\xfb\xe5\x07\xdf\xe5\xe6\xaa\x5a\xf2\xab\xb9\x14\xce\xaa\x05\xf9\x9c\xe6\x1b\xa5"\
""
-
+
/*************************************************************
*** A.3.5. Bytecode State Creation_1
@@ -585,7 +587,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_5__Bytecode_State_Creation_1\
"\xf8\x04\x61\x12\xa0\xbe\x08\x1e\x20\x08\x1e\x21\x06\x0a\x0e\x23\xbe\x03\x12\xa0\xbe\x08\xa0\x50\x20\x08\xa0\x50\xa0\x53\x14\x0a\x20\x08\xa0\x50\xa0\x53\x0c\x0a\x16\x06\x00\x4f\x4b\x31\x1c\x01\xa0\xb3\xfc\x22\xa0\xa8\x03\x23\x00\x00\x0d\xa0\xa8\xa0\xab\x06\x0a\x4f\x4b\x32\x22\xa0\x50\x03\x23\x02"\
""
-
+
/*************************************************************
*** A.3.5. Bytecode State Creation_2
@@ -593,7 +595,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_5__Bytecode_State_Creation_2\
"\xf9\x05\xb8\x8c\xe7\x2c\x91\x03"\
""
-
+
/*************************************************************
*** A.3.5. Bytecode State Creation_3
@@ -601,7 +603,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_5__Bytecode_State_Creation_3\
"\xfb\x24\x63\xcd\xff\x5c\xf8\xc7\x6d\xf6\xa2\x89\xff"\
""
-
+
/*************************************************************
*** A.3.5. Bytecode State Creation_4
@@ -609,7 +611,7 @@ struct_torture_test, *lpstruct_torture_test;
#define RFC4465_A_3_5__Bytecode_State_Creation_4\
"\xf9\x5b\x4b\x43\xd5\x67\x83"\
""
-
+
/*************************************************************
*** A.3.5. Bytecode State Creation_5
diff --git a/tinySIGCOMP/test/stdafx.c b/tinySIGCOMP/test/stdafx.c
index c303ba3..b773e42 100755
--- a/tinySIGCOMP/test/stdafx.c
+++ b/tinySIGCOMP/test/stdafx.c
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/test/stdafx.h b/tinySIGCOMP/test/stdafx.h
index 0ad4eea..c3468b1 100755
--- a/tinySIGCOMP/test/stdafx.h
+++ b/tinySIGCOMP/test/stdafx.h
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/test/targetver.h b/tinySIGCOMP/test/targetver.h
index 4631d99..936c7e0 100755
--- a/tinySIGCOMP/test/targetver.h
+++ b/tinySIGCOMP/test/targetver.h
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -23,8 +23,8 @@
#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
diff --git a/tinySIGCOMP/test/test.c b/tinySIGCOMP/test/test.c
index b18c325..f4bf971 100755
--- a/tinySIGCOMP/test/test.c
+++ b/tinySIGCOMP/test/test.c
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -44,18 +44,18 @@ int main()
#endif
{
#if TEST_TORTURES
- test_tortures();
+ test_tortures();
#endif
#if TEST_MANAGER
- test_manager();
+ test_manager();
#endif
#if TEST_OSC
- test_osc();
+ test_osc();
#endif
-
- getchar();
- return 0;
+ getchar();
+
+ return 0;
}
diff --git a/tinySIGCOMP/test/test_manager.h b/tinySIGCOMP/test/test_manager.h
index bfcdfea..bd2f287 100755
--- a/tinySIGCOMP/test/test_manager.h
+++ b/tinySIGCOMP/test/test_manager.h
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -32,12 +32,11 @@
#define USE_ONLY_ACKED_STATES tsk_false // Should be false unless you know what you're doing
-typedef struct sigcomp_test_s
-{
- const char* description;
- const char* msg;
- tsk_bool_t is_client;
- tsk_bool_t tobe_lost;
+typedef struct sigcomp_test_s {
+ const char* description;
+ const char* msg;
+ tsk_bool_t is_client;
+ tsk_bool_t tobe_lost;
}
sigcomp_test_t;
@@ -46,233 +45,231 @@ sigcomp_test_t;
#define TOBE_LOST_YES tsk_true
#define TOBE_LOST_NO tsk_false
-static const sigcomp_test_t SIGCOMP_TESTS_CALL[]=
-{
- {
- "REGISTER (client -> server)",
- "REGISTER sip:doubango.org SIP/2.0\r\n"
- "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357158829;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
- "From: <sip:001@doubango.org>;tag=357151115\r\n"
- "To: <sip:001@doubango.org>\r\n"
- "Contact: <sip:001@192.168.0.11:64549;transport=udp;sigcomp-id=urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b>;expires=3600;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Call-ID: 0473e8ff-2cd6-fada-70ab-ce8c9523db8c\r\n"
- "CSeq: 5493 REGISTER\r\n"
- "Content-Length: 0\r\n"
- "Max-Forwards: 70\r\n"
- "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
- "Privacy: none\r\n"
- "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
- "User-Agent: IM-client/OMA1.0 Boghe/v2.0.121.757\r\n"
- "P-Preferred-Identity: <sip:001@doubango.org>\r\n"
- "Supported: path\r\n"
- "\r\n",
- IS_CLIENT_YES,
- TOBE_LOST_NO
- },
- {
- "200 REGISTER (server -> client)",
- "SIP/2.0 200 OK\r\n"
- "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357158829;rport=64549;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
- "Contact: <sip:001@192.168.0.11:54027;transport=udp;sigcomp-id=\"urn:uuid:7556d001-9ca7-41a3-80b0-5b7725a91cc4\">;expires=2761;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Contact: <sip:001@192.168.0.11:50417;transport=udp;sigcomp-id=\"urn:uuid:6a8b493e-7dd8-45fb-b104-085723cbfb7b\">;expires=3025;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Contact: <sip:001@192.168.0.11:50464;transport=udp;sigcomp-id=\"urn:uuid:c5534343-0fb1-41a8-b4bc-612f04913d2a\">;expires=3409;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Contact: <sip:001@192.168.0.11:64547;transport=udp;sigcomp-id=\"urn:uuid:40ce6b6c-90b3-487d-8768-ae180a8153b1\">;expires=3487;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Contact: <sip:001@192.168.0.11:64549;transport=udp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\">;expires=3600;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "To: <sip:001@doubango.org>;tag=4345c04e\r\n"
- "From: <sip:001@doubango.org>;tag=357151115\r\n"
- "Call-ID: 0473e8ff-2cd6-fada-70ab-ce8c9523db8c\r\n"
- "CSeq: 5493 REGISTER\r\n"
- "Content-Length: 0\r\n"
- "\r\n",
- IS_CLIENT_NO,
- TOBE_LOST_NO
- },
- {
- "INVITE (client -> server)",
- "INVITE sip:13131313@sip2sip.info SIP/2.0\r\n"
- "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
- "From: <sip:001@doubango.org>;tag=357203612\r\n"
- "To: <sip:13131313@sip2sip.info>\r\n"
- "Contact: <sip:001@192.168.0.11:64549;transport=udp;sigcomp-id=urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b>;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"\r\n"
- "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
- "CSeq: 14727 INVITE\r\n"
- "Content-Type: application/sdp\r\n"
- "Content-Length: 989\r\n"
- "Max-Forwards: 70\r\n"
- "Accept-Contact: *;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"\r\n"
- "P-Preferred-Service: urn:urn-7:3gpp-service.ims.icsi.mmtel\r\n"
- "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
- "Privacy: none\r\n"
- "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
- "User-Agent: IM-client/OMA1.0 Boghe/v2.0.121.757\r\n"
- "Supported: 100rel\r\n"
- "\r\n"
- "v=0\r\n"
- "o=doubango 1983 678901 IN IP4 192.168.0.11\r\n"
- "s=-\r\n"
- "c=IN IP4 192.168.0.11\r\n"
- "t=0 0\r\n"
- "m=audio 64550 RTP/SAVPF 0 8 97 101\r\n"
- "c=IN IP4 192.168.0.11\r\n"
- "a=ptime:20\r\n"
- "a=silenceSupp:off - - - -\r\n"
- "a=rtpmap:0 PCMU/8000/1\r\n"
- "a=rtpmap:8 PCMA/8000/1\r\n"
- "a=rtpmap:97 SPEEX/8000/1\r\n"
- "a=rtpmap:101 telephone-event/8000/1\r\n"
- "a=fmtp:101 0-16\r\n"
- "a=sendrecv\r\n"
- "a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:JaJaTgwhqSd2A7yQ842YPXASomulb95aX/Wa96T7\r\n"
- "a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:T3yTUA2dVXTr6v0jb+E1TR3Btj4xP3mPeaAtQbeC\r\n"
- "a=rtcp-mux\r\n"
- "a=ssrc:3301897658 cname:ldjWoB60jbyQlR6e\r\n"
- "a=ssrc:3301897658 mslabel:6994f7d1-6ce9-4fbd-acfd-84e5131ca2e2\r\n"
- "a=ssrc:3301897658 label:Doubango\r\n"
- "a=ice-ufrag:zNevtNKAGk6h7gJ\r\n"
- "a=ice-pwd:YaOV3FlWUkBmifZ87SP51\r\n"
- "a=mid:audio\r\n"
- "a=candidate:CuNeg0Keh 1 udp 2130706431 192.168.0.11 64550 typ host\r\n"
- "a=candidate:CuNeg0Keh 2 udp 2130706430 192.168.0.11 64551 typ host\r\n"
- "a=candidate:srflxCuNe 1 udp 1694498815 88.179.39.5 64550 typ srflx\r\n"
- "a=candidate:srflxCuNe 2 udp 1694498814 88.179.39.5 64551 typ srflx\r\n"
- "\r\n",
- IS_CLIENT_YES,
- TOBE_LOST_NO
- },
- {
- "100 TRYING (server -> client)",
- "SIP/2.0 100 Trying\r\n"
- "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport=64549;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
- "To: <sip:13131313@sip2sip.info>\r\n"
- "From: <sip:001@doubango.org>;tag=357203612\r\n"
- "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
- "CSeq: 14727 INVITE\r\n"
- "Content-Length: 0\r\n"
- "\r\n",
- IS_CLIENT_NO,
- TOBE_LOST_NO
- },
- {
- "488 Not acceptable (server -> client)",
- "SIP/2.0 488 Not acceptable here\r\n"
- "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport=64549;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
- "To: <sip:13131313@sip2sip.info>;tag=as6edf9ce2\r\n"
- "From: <sip:001@doubango.org>;tag=357203612\r\n"
- "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
- "CSeq: 14727 INVITE\r\n"
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH\r\n"
- "Server: Asterisk PBX\r\n"
- "Supported: replaces, timer\r\n"
- "Content-Length: 0\r\n"
- "\r\n",
- IS_CLIENT_NO,
- TOBE_LOST_NO
- },
- {
- "ACK (client -> server)",
- "ACK sip:13131313@sip2sip.info SIP/2.0\r\n"
- "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
- "From: <sip:001@doubango.org>;tag=357203612\r\n"
- "To: <sip:13131313@sip2sip.info>;tag=as6edf9ce2\r\n"
- "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
- "CSeq: 14727 ACK\r\n"
- "Content-Length: 0\r\n"
- "Max-Forwards: 70\r\n"
- "\r\n",
- IS_CLIENT_YES,
- TOBE_LOST_NO
- }
+static const sigcomp_test_t SIGCOMP_TESTS_CALL[]= {
+ {
+ "REGISTER (client -> server)",
+ "REGISTER sip:doubango.org SIP/2.0\r\n"
+ "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357158829;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
+ "From: <sip:001@doubango.org>;tag=357151115\r\n"
+ "To: <sip:001@doubango.org>\r\n"
+ "Contact: <sip:001@192.168.0.11:64549;transport=udp;sigcomp-id=urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b>;expires=3600;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Call-ID: 0473e8ff-2cd6-fada-70ab-ce8c9523db8c\r\n"
+ "CSeq: 5493 REGISTER\r\n"
+ "Content-Length: 0\r\n"
+ "Max-Forwards: 70\r\n"
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
+ "Privacy: none\r\n"
+ "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
+ "User-Agent: IM-client/OMA1.0 Boghe/v2.0.121.757\r\n"
+ "P-Preferred-Identity: <sip:001@doubango.org>\r\n"
+ "Supported: path\r\n"
+ "\r\n",
+ IS_CLIENT_YES,
+ TOBE_LOST_NO
+ },
+ {
+ "200 REGISTER (server -> client)",
+ "SIP/2.0 200 OK\r\n"
+ "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357158829;rport=64549;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
+ "Contact: <sip:001@192.168.0.11:54027;transport=udp;sigcomp-id=\"urn:uuid:7556d001-9ca7-41a3-80b0-5b7725a91cc4\">;expires=2761;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Contact: <sip:001@192.168.0.11:50417;transport=udp;sigcomp-id=\"urn:uuid:6a8b493e-7dd8-45fb-b104-085723cbfb7b\">;expires=3025;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Contact: <sip:001@192.168.0.11:50464;transport=udp;sigcomp-id=\"urn:uuid:c5534343-0fb1-41a8-b4bc-612f04913d2a\">;expires=3409;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Contact: <sip:001@192.168.0.11:64547;transport=udp;sigcomp-id=\"urn:uuid:40ce6b6c-90b3-487d-8768-ae180a8153b1\">;expires=3487;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Contact: <sip:001@192.168.0.11:64549;transport=udp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\">;expires=3600;language=\"en,fr\";+g.oma.sip-im;+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "To: <sip:001@doubango.org>;tag=4345c04e\r\n"
+ "From: <sip:001@doubango.org>;tag=357151115\r\n"
+ "Call-ID: 0473e8ff-2cd6-fada-70ab-ce8c9523db8c\r\n"
+ "CSeq: 5493 REGISTER\r\n"
+ "Content-Length: 0\r\n"
+ "\r\n",
+ IS_CLIENT_NO,
+ TOBE_LOST_NO
+ },
+ {
+ "INVITE (client -> server)",
+ "INVITE sip:13131313@sip2sip.info SIP/2.0\r\n"
+ "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
+ "From: <sip:001@doubango.org>;tag=357203612\r\n"
+ "To: <sip:13131313@sip2sip.info>\r\n"
+ "Contact: <sip:001@192.168.0.11:64549;transport=udp;sigcomp-id=urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b>;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"\r\n"
+ "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
+ "CSeq: 14727 INVITE\r\n"
+ "Content-Type: application/sdp\r\n"
+ "Content-Length: 989\r\n"
+ "Max-Forwards: 70\r\n"
+ "Accept-Contact: *;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"\r\n"
+ "P-Preferred-Service: urn:urn-7:3gpp-service.ims.icsi.mmtel\r\n"
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
+ "Privacy: none\r\n"
+ "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
+ "User-Agent: IM-client/OMA1.0 Boghe/v2.0.121.757\r\n"
+ "Supported: 100rel\r\n"
+ "\r\n"
+ "v=0\r\n"
+ "o=doubango 1983 678901 IN IP4 192.168.0.11\r\n"
+ "s=-\r\n"
+ "c=IN IP4 192.168.0.11\r\n"
+ "t=0 0\r\n"
+ "m=audio 64550 RTP/SAVPF 0 8 97 101\r\n"
+ "c=IN IP4 192.168.0.11\r\n"
+ "a=ptime:20\r\n"
+ "a=silenceSupp:off - - - -\r\n"
+ "a=rtpmap:0 PCMU/8000/1\r\n"
+ "a=rtpmap:8 PCMA/8000/1\r\n"
+ "a=rtpmap:97 SPEEX/8000/1\r\n"
+ "a=rtpmap:101 telephone-event/8000/1\r\n"
+ "a=fmtp:101 0-16\r\n"
+ "a=sendrecv\r\n"
+ "a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:JaJaTgwhqSd2A7yQ842YPXASomulb95aX/Wa96T7\r\n"
+ "a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:T3yTUA2dVXTr6v0jb+E1TR3Btj4xP3mPeaAtQbeC\r\n"
+ "a=rtcp-mux\r\n"
+ "a=ssrc:3301897658 cname:ldjWoB60jbyQlR6e\r\n"
+ "a=ssrc:3301897658 mslabel:6994f7d1-6ce9-4fbd-acfd-84e5131ca2e2\r\n"
+ "a=ssrc:3301897658 label:Doubango\r\n"
+ "a=ice-ufrag:zNevtNKAGk6h7gJ\r\n"
+ "a=ice-pwd:YaOV3FlWUkBmifZ87SP51\r\n"
+ "a=mid:audio\r\n"
+ "a=candidate:CuNeg0Keh 1 udp 2130706431 192.168.0.11 64550 typ host\r\n"
+ "a=candidate:CuNeg0Keh 2 udp 2130706430 192.168.0.11 64551 typ host\r\n"
+ "a=candidate:srflxCuNe 1 udp 1694498815 88.179.39.5 64550 typ srflx\r\n"
+ "a=candidate:srflxCuNe 2 udp 1694498814 88.179.39.5 64551 typ srflx\r\n"
+ "\r\n",
+ IS_CLIENT_YES,
+ TOBE_LOST_NO
+ },
+ {
+ "100 TRYING (server -> client)",
+ "SIP/2.0 100 Trying\r\n"
+ "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport=64549;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
+ "To: <sip:13131313@sip2sip.info>\r\n"
+ "From: <sip:001@doubango.org>;tag=357203612\r\n"
+ "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
+ "CSeq: 14727 INVITE\r\n"
+ "Content-Length: 0\r\n"
+ "\r\n",
+ IS_CLIENT_NO,
+ TOBE_LOST_NO
+ },
+ {
+ "488 Not acceptable (server -> client)",
+ "SIP/2.0 488 Not acceptable here\r\n"
+ "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport=64549;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
+ "To: <sip:13131313@sip2sip.info>;tag=as6edf9ce2\r\n"
+ "From: <sip:001@doubango.org>;tag=357203612\r\n"
+ "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
+ "CSeq: 14727 INVITE\r\n"
+ "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH\r\n"
+ "Server: Asterisk PBX\r\n"
+ "Supported: replaces, timer\r\n"
+ "Content-Length: 0\r\n"
+ "\r\n",
+ IS_CLIENT_NO,
+ TOBE_LOST_NO
+ },
+ {
+ "ACK (client -> server)",
+ "ACK sip:13131313@sip2sip.info SIP/2.0\r\n"
+ "Via: SIP/2.0/UDP 192.168.0.11:64549;branch=z9hG4bK357179240;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:d343a50a-2961-4a25-93d8-4e0677b68e6b\"\r\n"
+ "From: <sip:001@doubango.org>;tag=357203612\r\n"
+ "To: <sip:13131313@sip2sip.info>;tag=as6edf9ce2\r\n"
+ "Call-ID: da91debf-0033-dd9e-9c8d-e9018f825c8f\r\n"
+ "CSeq: 14727 ACK\r\n"
+ "Content-Length: 0\r\n"
+ "Max-Forwards: 70\r\n"
+ "\r\n",
+ IS_CLIENT_YES,
+ TOBE_LOST_NO
+ }
};
-static const sigcomp_test_t SIGCOMP_TESTS_SUBSCRIBE[]=
-{
- {
- "REGISTER (client -> server)",
- "REGISTER sip:test.3gpp.com SIP/2.0\r\n"
- "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403432184;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
- "From: <sip:johndoe@test.3gpp.com>;tag=1403421024\r\n"
- "To: <sip:johndoe@test.3gpp.com>\r\n"
- "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;expires=600000;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Call-ID: afac1d20-b998-2720-6407-7bbbc77ace9b\r\n"
- "CSeq: 27335 REGISTER\r\n"
- "Content-Length: 0\r\n"
- "Max-Forwards: 70\r\n"
- "Authorization: Digest username=\"johndoe@test.3gpp.com\",realm=\"test.3gpp.com\",nonce=\"\",uri=\"sip:test.3gpp.com\",response=\"\"\r\n"
- "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
- "Privacy: none\r\n"
- "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
- "User-Agent: IM-client/OMA1.0 Boghe/v2.0.132.808\r\n"
- "P-Preferred-Identity: <sip:johndoe@test.3gpp.com>\r\n"
- "Supported: path\r\n"
- "\r\n",
- IS_CLIENT_YES,
- TOBE_LOST_NO
- },
- {
- "200 REGISTER (server -> client)",
- "SIP/2.0 200 OK\r\n"
- "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403432184;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
- "From: <sip:johndoe@test.3gpp.com>;tag=1403421024\r\n"
- "To: <sip:johndoe@test.3gpp.com>;tag=T91612B6\r\n"
- "Call-ID: afac1d20-b998-2720-6407-7bbbc77ace9b\r\n"
- "CSeq: 27335 REGISTER\r\n"
- "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;q=0.500;expires = 600000;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
- "Content-Length: 0\r\n"
- "Date: Fri, 25 Jan 2013 09:20:31 GMT\r\n"
- "P-Associated-URI: <sip:johndoe@test.3gpp.com>\r\n"
- "Server: Agilent_IMS-SIP_Server/4.11.0.0\r\n"
- "\r\n",
- IS_CLIENT_NO,
- TOBE_LOST_NO
- },
- {
- "SUBSCRIBE-1 (client -> server)",
- "SUBSCRIBE sip:johndoe@test.3gpp.com SIP/2.0\r\n"
- "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403431204;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
- "From: <sip:johndoe@test.3gpp.com>;tag=1403442750\r\n"
- "To: <sip:johndoe@test.3gpp.com>\r\n"
- "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;+g.oma.sip-im;language=\"en,fr\"\r\n"
- "Call-ID: 8c1a2260-c6e7-d415-2492-88493471d6fd\r\n"
- "CSeq: 24466 SUBSCRIBE\r\n"
- "Expires: 600000\r\n"
- "Content-Length: 0\r\n"
- "Max-Forwards: 70\r\n"
- "Event: reg\r\n"
- "Accept: application/reginfo+xml\r\n"
- "Allow-Events: refer, presence, presence.winfo, xcap-diff, conference\r\n"
- "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
- "Privacy: none\r\n"
- "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
- "User-Agent: IM-client/OMA1.0 Boghe/v2.0.132.808\r\n"
- "P-Preferred-Identity: <sip:johndoe@test.3gpp.com>\r\n"
- "\r\n",
- IS_CLIENT_YES,
- TOBE_LOST_NO
- },
- {
- "SUBSCRIBE-2 (client -> server)",
- "SUBSCRIBE sip:johndoe@test.3gpp.com SIP/2.0\r\n"
- "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403422374;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
- "From: <sip:johndoe@test.3gpp.com>;tag=1403431575\r\n"
- "To: <sip:johndoe@test.3gpp.com>\r\n"
- "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;+g.oma.sip-im;language=\"en,fr\"\r\n"
- "Call-ID: 05952487-8f39-ddbd-ebac-72a3f33eaf8d\r\n"
- "CSeq: 32393 SUBSCRIBE\r\n"
- "Expires: 600000\r\n"
- "Content-Length: 0\r\n"
- "Max-Forwards: 70\r\n"
- "Event: message-summary\r\n"
- "Accept: application/simple-message-summary\r\n"
- "Allow-Events: refer, presence, presence.winfo, xcap-diff, conference\r\n"
- "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
- "Privacy: none\r\n"
- "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
- "User-Agent: IM-client/OMA1.0 Boghe/v2.0.132.808\r\n"
- "P-Preferred-Identity: <sip:johndoe@test.3gpp.com>\r\n"
- "\r\n",
- IS_CLIENT_YES,
- TOBE_LOST_NO
- },
+static const sigcomp_test_t SIGCOMP_TESTS_SUBSCRIBE[]= {
+ {
+ "REGISTER (client -> server)",
+ "REGISTER sip:test.3gpp.com SIP/2.0\r\n"
+ "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403432184;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
+ "From: <sip:johndoe@test.3gpp.com>;tag=1403421024\r\n"
+ "To: <sip:johndoe@test.3gpp.com>\r\n"
+ "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;expires=600000;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Call-ID: afac1d20-b998-2720-6407-7bbbc77ace9b\r\n"
+ "CSeq: 27335 REGISTER\r\n"
+ "Content-Length: 0\r\n"
+ "Max-Forwards: 70\r\n"
+ "Authorization: Digest username=\"johndoe@test.3gpp.com\",realm=\"test.3gpp.com\",nonce=\"\",uri=\"sip:test.3gpp.com\",response=\"\"\r\n"
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
+ "Privacy: none\r\n"
+ "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
+ "User-Agent: IM-client/OMA1.0 Boghe/v2.0.132.808\r\n"
+ "P-Preferred-Identity: <sip:johndoe@test.3gpp.com>\r\n"
+ "Supported: path\r\n"
+ "\r\n",
+ IS_CLIENT_YES,
+ TOBE_LOST_NO
+ },
+ {
+ "200 REGISTER (server -> client)",
+ "SIP/2.0 200 OK\r\n"
+ "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403432184;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
+ "From: <sip:johndoe@test.3gpp.com>;tag=1403421024\r\n"
+ "To: <sip:johndoe@test.3gpp.com>;tag=T91612B6\r\n"
+ "Call-ID: afac1d20-b998-2720-6407-7bbbc77ace9b\r\n"
+ "CSeq: 27335 REGISTER\r\n"
+ "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;q=0.500;expires = 600000;+g.oma.sip-im;language=\"en,fr\";+g.3gpp.smsip;+g.oma.sip-im.large-message;audio;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\";+g.3gpp.cs-voice\r\n"
+ "Content-Length: 0\r\n"
+ "Date: Fri, 25 Jan 2013 09:20:31 GMT\r\n"
+ "P-Associated-URI: <sip:johndoe@test.3gpp.com>\r\n"
+ "Server: Agilent_IMS-SIP_Server/4.11.0.0\r\n"
+ "\r\n",
+ IS_CLIENT_NO,
+ TOBE_LOST_NO
+ },
+ {
+ "SUBSCRIBE-1 (client -> server)",
+ "SUBSCRIBE sip:johndoe@test.3gpp.com SIP/2.0\r\n"
+ "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403431204;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
+ "From: <sip:johndoe@test.3gpp.com>;tag=1403442750\r\n"
+ "To: <sip:johndoe@test.3gpp.com>\r\n"
+ "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;+g.oma.sip-im;language=\"en,fr\"\r\n"
+ "Call-ID: 8c1a2260-c6e7-d415-2492-88493471d6fd\r\n"
+ "CSeq: 24466 SUBSCRIBE\r\n"
+ "Expires: 600000\r\n"
+ "Content-Length: 0\r\n"
+ "Max-Forwards: 70\r\n"
+ "Event: reg\r\n"
+ "Accept: application/reginfo+xml\r\n"
+ "Allow-Events: refer, presence, presence.winfo, xcap-diff, conference\r\n"
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
+ "Privacy: none\r\n"
+ "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
+ "User-Agent: IM-client/OMA1.0 Boghe/v2.0.132.808\r\n"
+ "P-Preferred-Identity: <sip:johndoe@test.3gpp.com>\r\n"
+ "\r\n",
+ IS_CLIENT_YES,
+ TOBE_LOST_NO
+ },
+ {
+ "SUBSCRIBE-2 (client -> server)",
+ "SUBSCRIBE sip:johndoe@test.3gpp.com SIP/2.0\r\n"
+ "Via: SIP/2.0/TCP 156.141.115.182:62493;branch=z9hG4bK1403422374;rport;comp=sigcomp;sigcomp-id=\"urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4\"\r\n"
+ "From: <sip:johndoe@test.3gpp.com>;tag=1403431575\r\n"
+ "To: <sip:johndoe@test.3gpp.com>\r\n"
+ "Contact: <sip:johndoe@156.141.115.182:62493;transport=tcp;sigcomp-id=urn:uuid:41147e2b-d2b9-47c1-a698-c732f6f036f4>;+g.oma.sip-im;language=\"en,fr\"\r\n"
+ "Call-ID: 05952487-8f39-ddbd-ebac-72a3f33eaf8d\r\n"
+ "CSeq: 32393 SUBSCRIBE\r\n"
+ "Expires: 600000\r\n"
+ "Content-Length: 0\r\n"
+ "Max-Forwards: 70\r\n"
+ "Event: message-summary\r\n"
+ "Accept: application/simple-message-summary\r\n"
+ "Allow-Events: refer, presence, presence.winfo, xcap-diff, conference\r\n"
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n"
+ "Privacy: none\r\n"
+ "P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n"
+ "User-Agent: IM-client/OMA1.0 Boghe/v2.0.132.808\r\n"
+ "P-Preferred-Identity: <sip:johndoe@test.3gpp.com>\r\n"
+ "\r\n",
+ IS_CLIENT_YES,
+ TOBE_LOST_NO
+ },
};
@@ -280,123 +277,118 @@ static const sigcomp_test_t SIGCOMP_TESTS_SUBSCRIBE[]=
static int handle_nack(tcomp_result_t *nack, tcomp_manager_handle_t* manager)
{
- if(nack->isNack){
- tsk_size_t nack_info_size;
- if(nack->nack_info && (nack_info_size = tcomp_buffer_getSize(nack->nack_info))){
- char buff[MAX_BUFFER_SIZE];
- tcomp_result_t* result = tcomp_result_create();
- tcomp_result_setOutputBuffer(result, buff, sizeof(buff), IS_STREAM, STREAM_ID);
- tcomp_manager_decompress(manager, tcomp_buffer_getBuffer(nack->nack_info), nack_info_size, result);
- TSK_OBJECT_SAFE_FREE(result);
- return 0;
- }
- }
- return -1;
+ if(nack->isNack) {
+ tsk_size_t nack_info_size;
+ if(nack->nack_info && (nack_info_size = tcomp_buffer_getSize(nack->nack_info))) {
+ char buff[MAX_BUFFER_SIZE];
+ tcomp_result_t* result = tcomp_result_create();
+ tcomp_result_setOutputBuffer(result, buff, sizeof(buff), IS_STREAM, STREAM_ID);
+ tcomp_manager_decompress(manager, tcomp_buffer_getBuffer(nack->nack_info), nack_info_size, result);
+ TSK_OBJECT_SAFE_FREE(result);
+ return 0;
+ }
+ }
+ return -1;
}
static int test_manager()
{
- size_t i, j;
- size_t outLen;
- const sigcomp_test_t* test;
+ size_t i, j;
+ size_t outLen;
+ const sigcomp_test_t* test;
+
+ tcomp_manager_handle_t *client = tsk_null, *server = tsk_null;
+ tcomp_result_t *result_client = tsk_null, *result_server = tsk_null;
+
+ /* temporary buffers --> will hold compression/decompression results */
+ char buff_client[MAX_BUFFER_SIZE];
+ char buff_server[MAX_BUFFER_SIZE];
+
+ /* Managers */
+ client = tcomp_manager_create();
+ server = tcomp_manager_create();
- tcomp_manager_handle_t *client = tsk_null, *server = tsk_null;
- tcomp_result_t *result_client = tsk_null, *result_server = tsk_null;
+ /* Add SIP/Presence dictionnaries */
+ tcomp_manager_addSipSdpDictionary(client);
+ tcomp_manager_addPresenceDictionary(client);
+ tcomp_manager_addSipSdpDictionary(server);
+ tcomp_manager_addPresenceDictionary(server);
- /* temporary buffers --> will hold compression/decompression results */
- char buff_client[MAX_BUFFER_SIZE];
- char buff_server[MAX_BUFFER_SIZE];
-
- /* Managers */
- client = tcomp_manager_create();
- server = tcomp_manager_create();
+ /* Results --> it is recomanded to use one result struct for each manager */
+ result_client = tcomp_result_create();
+ result_server = tcomp_result_create();
- /* Add SIP/Presence dictionnaries */
- tcomp_manager_addSipSdpDictionary(client);
- tcomp_manager_addPresenceDictionary(client);
- tcomp_manager_addSipSdpDictionary(server);
- tcomp_manager_addPresenceDictionary(server);
-
- /* Results --> it is recomanded to use one result struct for each manager */
- result_client = tcomp_result_create();
- result_server = tcomp_result_create();
+ /* Sets compartment Ids */
+ tcomp_result_setCompartmentId(result_client, COMPARTMENT_ID_CLIENT, strlen(COMPARTMENT_ID_CLIENT));
+ tcomp_result_setCompartmentId(result_server, COMPARTMENT_ID_SERVER, strlen(COMPARTMENT_ID_SERVER));
- /* Sets compartment Ids */
- tcomp_result_setCompartmentId(result_client, COMPARTMENT_ID_CLIENT, strlen(COMPARTMENT_ID_CLIENT));
- tcomp_result_setCompartmentId(result_server, COMPARTMENT_ID_SERVER, strlen(COMPARTMENT_ID_SERVER));
+ /* Set DMS and SMS */
+ tcomp_manager_setDecompression_Memory_Size(client, SIGCOMP_DMS);
+ tcomp_manager_setDecompression_Memory_Size(server, SIGCOMP_DMS);
+ tcomp_manager_setCycles_Per_Bit(client, SIGCOMP_CPB);
+ tcomp_manager_setCycles_Per_Bit(server, SIGCOMP_CPB);
+ tcomp_manager_setState_Memory_Size(client, SIGCOMP_SMS);
+ tcomp_manager_setState_Memory_Size(server, SIGCOMP_SMS);
- /* Set DMS and SMS */
- tcomp_manager_setDecompression_Memory_Size(client, SIGCOMP_DMS);
- tcomp_manager_setDecompression_Memory_Size(server, SIGCOMP_DMS);
- tcomp_manager_setCycles_Per_Bit(client, SIGCOMP_CPB);
- tcomp_manager_setCycles_Per_Bit(server, SIGCOMP_CPB);
- tcomp_manager_setState_Memory_Size(client, SIGCOMP_SMS);
- tcomp_manager_setState_Memory_Size(server, SIGCOMP_SMS);
+ /* Set wehther to use only ACKed states (should be false) */
+ tcomp_manager_setUseOnlyACKedStates(client, USE_ONLY_ACKED_STATES);
+ tcomp_manager_setUseOnlyACKedStates(server, USE_ONLY_ACKED_STATES);
- /* Set wehther to use only ACKed states (should be false) */
- tcomp_manager_setUseOnlyACKedStates(client, USE_ONLY_ACKED_STATES);
- tcomp_manager_setUseOnlyACKedStates(server, USE_ONLY_ACKED_STATES);
+ tcomp_result_setOutputBuffer(result_client, buff_client, sizeof(buff_client), IS_STREAM, STREAM_ID);
+ tcomp_result_setOutputBuffer(result_server, buff_server, sizeof(buff_server), IS_STREAM, STREAM_ID);
- tcomp_result_setOutputBuffer(result_client, buff_client, sizeof(buff_client), IS_STREAM, STREAM_ID);
- tcomp_result_setOutputBuffer(result_server, buff_server, sizeof(buff_server), IS_STREAM, STREAM_ID);
-
- for(j = 0; j < SIGCOMP_LOOP_COUNT; ++j)
- {
- for(i = 0; i < sizeof(SIGCOMP_TESTS)/sizeof(SIGCOMP_TESTS[0]); ++i)
- {
- test = &SIGCOMP_TESTS[i];
+ for(j = 0; j < SIGCOMP_LOOP_COUNT; ++j) {
+ for(i = 0; i < sizeof(SIGCOMP_TESTS)/sizeof(SIGCOMP_TESTS[0]); ++i) {
+ test = &SIGCOMP_TESTS[i];
- // compress
- outLen = tcomp_manager_compress(
- test->is_client ? client : server,
- test->is_client ? COMPARTMENT_ID_CLIENT : COMPARTMENT_ID_SERVER,
- tsk_strlen((test->is_client ? COMPARTMENT_ID_CLIENT : COMPARTMENT_ID_SERVER)),
- test->msg,
- tsk_strlen(test->msg),
- test->is_client ? buff_client : buff_server,
- test->is_client ? sizeof(buff_client) : sizeof(buff_server),
- IS_STREAM);
- if(!outLen)
- {
- TSK_DEBUG_ERROR("Failed to compress %s message", test->description);
- goto bail;
- }
- TSK_DEBUG_INFO("==%s compression ratio = %f%%==", test->description, ((float)tsk_strlen(test->msg) / (float)outLen) * 100.f);
+ // compress
+ outLen = tcomp_manager_compress(
+ test->is_client ? client : server,
+ test->is_client ? COMPARTMENT_ID_CLIENT : COMPARTMENT_ID_SERVER,
+ tsk_strlen((test->is_client ? COMPARTMENT_ID_CLIENT : COMPARTMENT_ID_SERVER)),
+ test->msg,
+ tsk_strlen(test->msg),
+ test->is_client ? buff_client : buff_server,
+ test->is_client ? sizeof(buff_client) : sizeof(buff_server),
+ IS_STREAM);
+ if(!outLen) {
+ TSK_DEBUG_ERROR("Failed to compress %s message", test->description);
+ goto bail;
+ }
+ TSK_DEBUG_INFO("==%s compression ratio = %f%%==", test->description, ((float)tsk_strlen(test->msg) / (float)outLen) * 100.f);
- // decompress
- if(!test->tobe_lost)
- {
- tsk_bool_t server_decompress = test->is_client; // decompress using server manager if compressed using client mgr
- memset(server_decompress ? buff_server : buff_client, '\0', server_decompress ? sizeof(buff_server) : sizeof(buff_client));
- outLen = tcomp_manager_decompress(server_decompress ? server : client, server_decompress ? buff_client : buff_server, outLen, server_decompress ? result_server : result_client);
- if(!outLen)
- {
- TSK_DEBUG_ERROR("Failed to decompress %s message", test->description);
- // pass NACK to remote peer (sendto())
- if(handle_nack(server_decompress ? result_server : result_client, server_decompress ? client : server) != 0){
- goto bail;
- }
- }
- tcomp_manager_provideCompartmentId(server_decompress ? server : client, server_decompress ? result_server : result_client); // save states
- TSK_DEBUG_INFO("Decompressed message:\n%s = %s", test->description, server_decompress ? buff_server : buff_client);
- }
- }// for (i < count(SIGCOMP_TESTS))
- } // for (j < SIGCOMP_LOOP_COUNT)
+ // decompress
+ if(!test->tobe_lost) {
+ tsk_bool_t server_decompress = test->is_client; // decompress using server manager if compressed using client mgr
+ memset(server_decompress ? buff_server : buff_client, '\0', server_decompress ? sizeof(buff_server) : sizeof(buff_client));
+ outLen = tcomp_manager_decompress(server_decompress ? server : client, server_decompress ? buff_client : buff_server, outLen, server_decompress ? result_server : result_client);
+ if(!outLen) {
+ TSK_DEBUG_ERROR("Failed to decompress %s message", test->description);
+ // pass NACK to remote peer (sendto())
+ if(handle_nack(server_decompress ? result_server : result_client, server_decompress ? client : server) != 0) {
+ goto bail;
+ }
+ }
+ tcomp_manager_provideCompartmentId(server_decompress ? server : client, server_decompress ? result_server : result_client); // save states
+ TSK_DEBUG_INFO("Decompressed message:\n%s = %s", test->description, server_decompress ? buff_server : buff_client);
+ }
+ }// for (i < count(SIGCOMP_TESTS))
+ } // for (j < SIGCOMP_LOOP_COUNT)
bail:
- // Close compartments
- tcomp_manager_closeCompartment(client, COMPARTMENT_ID_CLIENT, tsk_strlen(COMPARTMENT_ID_CLIENT));
- tcomp_manager_closeCompartment(server, COMPARTMENT_ID_SERVER, tsk_strlen(COMPARTMENT_ID_SERVER));
+ // Close compartments
+ tcomp_manager_closeCompartment(client, COMPARTMENT_ID_CLIENT, tsk_strlen(COMPARTMENT_ID_CLIENT));
+ tcomp_manager_closeCompartment(server, COMPARTMENT_ID_SERVER, tsk_strlen(COMPARTMENT_ID_SERVER));
- // Delete Results
- TSK_OBJECT_SAFE_FREE(result_client);
- TSK_OBJECT_SAFE_FREE(result_server);
+ // Delete Results
+ TSK_OBJECT_SAFE_FREE(result_client);
+ TSK_OBJECT_SAFE_FREE(result_server);
- // Delete managers
- TSK_OBJECT_SAFE_FREE(client);
- TSK_OBJECT_SAFE_FREE(server);
+ // Delete managers
+ TSK_OBJECT_SAFE_FREE(client);
+ TSK_OBJECT_SAFE_FREE(server);
- return 0;
+ return 0;
}
#endif /* TEST_TINYSIGCOMP_MANAGER_H */
diff --git a/tinySIGCOMP/test/test_osc.h b/tinySIGCOMP/test/test_osc.h
index d63ba5b..e4a3416 100755
--- a/tinySIGCOMP/test/test_osc.h
+++ b/tinySIGCOMP/test/test_osc.h
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
diff --git a/tinySIGCOMP/test/test_tortures.h b/tinySIGCOMP/test/test_tortures.h
index c1222b6..3e04bbe 100755
--- a/tinySIGCOMP/test/test_tortures.h
+++ b/tinySIGCOMP/test/test_tortures.h
@@ -1,19 +1,19 @@
/*
* Copyright (C) 2009 Mamadou Diop.
* Copyright (C) 2012 Doubango Telecom <http://doubango.org>.
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
@@ -47,983 +47,998 @@
#include <assert.h>
-struct_torture_test tests[] =
-{
- { //*** 0***
- "A.1.1. Bit Manipulation",
- RFC4465_A_1_1__Bit_Manipulation,
- 170,
- {8, "\x01\x50\x00\x00\xfe\xbf\x00\x00"},
- 22,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- { //*** 1***
- "A.1.2(.1) Arithmetic",
- RFC4465_A_1_2__Arithmetic_1,
- 174,
- {8, "\x00\x00\x00\x00\x00\x00\x00\x04"},
- 25,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- { //*** 2***
- "A.1.2(.2) Arithmetic",
- RFC4465_A_1_2__Arithmetic_2,
- 174,
- {11, "DIV_BY_ZERO"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- { //*** 3***
- "A.1.2(.3) Arithmetic",
- RFC4465_A_1_2__Arithmetic_3,
- 174,
- {11, "DIV_BY_ZERO"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //*** 4***
- "A.1.3. Sorting",
- RFC4465_A_1_3__Sorting,
- 223,
- {45, "\x46\x6f\x72\x64\x2c\x20\x79\x6f\x75\x27\x72\x65\x20\x74\x75\x72\x6e\x69\x6e\x67"
- "\x20\x69\x6e\x74\x6f\x20\x61\x20\x70\x65\x6e\x67\x75\x69\x6e\x2e\x20\x53\x74\x6f"
- "\x70\x20\x69\x74\x2e"},
- 371,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //*** 5**
- "A.1.4. SHA-1",
- RFC4465_A_1_4__SHA1,
- 138,
- {40, "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e\x25\x71\x78\x50\xc2\x6c\x9c\xd0\xd8\x9d"
- "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1"
- "\x12\xff\x34\x7b\x4f\x27\xd6\x9e\x1f\x32\x8e\x6f\x4b\x55\x73\xe3\x66\x6e\x12\x2f"
- "\x4f\x46\x04\x52\xeb\xb5\x63\x93\x4f\x46\x04\x52\xeb\xb5\x63\x93\x4f\x46\x04\x52"},
- 17176,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //*** 6**
- "A.1.5.(1) LOAD and MULTILOAD",
- RFC4465_A_1_5__LOAD_and_MULTILOAD_1,
- 58,
- {16, "\x00\x84\x00\x84\x00\x86\x00\x86\x00\x2a\x00\x80\x00\x2a\x00\x2a"},
- 36,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //*** 7**
- "A.1.5.(2) LOAD and MULTILOAD",
- RFC4465_A_1_5__LOAD_and_MULTILOAD_2,
- 58,
- {21, "MULTILOAD_OVERWRITTEN"},
- 36,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //*** 8**
- "A.1.5.(3) LOAD and MULTILOAD",
- RFC4465_A_1_5__LOAD_and_MULTILOAD_3,
- 58,
- {21, "MULTILOAD_OVERWRITTEN"},
- 36,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 9**
- "A.1.6. COPY",
- RFC4465_A_1_6__COPY,
- 60,
- {125, "\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40"
- "\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x41\x41\x41\x41\x41\x41\x41\x41"
- "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
- "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
- "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
- "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x55\x41"
- "\x42\x43\x44\x43\x44"},
- 365,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 10**
- "A.1.7. COPY-LITERAL and COPY-OFFSET",
- RFC4465_A_1_7__COPY_LITERAL_and_COPY_OFFSET,
- 100,
- {34, "\x41\x41\x41\x41\x00\x61\x41\x41\x41\x41\x49\x4a\x41\x42\x43\x44\x49\x4a\x41\x42"
- "\x00\x4a\x00\x4e\x47\x48\x48\x45\x46\x47\x47\x48\x45\x46"},
- 216,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 11**
- "A.1.8. MEMSET",
- RFC4465_A_1_8__MEMSET,
- 27,
- {16, "\x80\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9\xb8\xc7\xd6\xe5\xf4\x03\x12"},
- 166,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 12**
- "A.1.9.(1) CRC",
- RFC4465_A_1_9__CRC_1,
- 29,
- {0, ""},
- 95,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 13**
- "A.1.9.(2) CRC",
- RFC4465_A_1_9__CRC_2,
- 29,
- {14, "USER_REQUESTED"},
- 95,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 14**
- "A.1.10. INPUT-BITS",
- RFC4465_A_1_10__INPUT_BITS,
- 28,
- {16, "\x00\x00\x00\x02\x00\x02\x00\x13\x00\x00\x00\x03\x00\x1a\x00\x38"},
- 66,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 15**
- "A.1.11. INPUT-HUFFMAN",
- RFC4465_A_1_11__INPUT_HUFFMAN,
- 39,
- {16, "\x00\x00\x00\x03\x00\x08\x04\xd7\x00\x02\x00\x03\x03\x99\x30\xfe"},
- 84,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 16**
- "A.1.12. INPUT-BYTES",
- RFC4465_A_1_12__INPUT_BYTES,
- 72,
- {39, "\x00\x00\x93\x2e\x00\x01\xb1\x66\xd8\x6f\xb1\x00\x1a\x2b\x00\x03\x9a\x97\x34\xd8"
- "\x00\x07\x00\x01\x33\x87\x4e\x00\x08\xdc\x96\x51\xb5\xdc\x96\x00\x59\x9d\x6a"},
- 130,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 17**
- "A.1.13. Stack Manipulation",
- RFC4465_A_1_13__Stack_Manipulation,
- 324,
- {16, "\x00\x03\x00\x02\x00\x01\x00\x42\x00\x42\x00\x00\x00\x01\x00\x01"},
- 40,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 18**
- "A.1.14. Program Flow",
- RFC4465_A_1_14__Program_Flow,
- 66,
- {20, "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x07\x07\x07\x08\x08\x08\x09\x09"},
- 131,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 19**
- "A.1.15.(1) State Creation",
- RFC4465_A_1_15__State_Creation_1,
- 152,
- {0, ""},
- 23,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 20 (requires previsous test)**
- "A.1.15.(2) State Creation",
- RFC4465_A_1_15__State_Creation_2,
- 152,
- {0, ""},
- 14,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 21 (requires previsous test)**
- "A.1.15.(3) State Creation",
- RFC4465_A_1_15__State_Creation_3,
- 152,
- {0, ""},
- 24,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 22 (requires previsous test)**
- "A.1.15.(4) State Creation", // FAIL
- RFC4465_A_1_15__State_Creation_4,
- 153,
- {23, "INVALID_STATE_ID_LENGTH"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 23 (requires previsous test)**
- "A.1.15.(5) State Creation", // FAIL
- RFC4465_A_1_15__State_Creation_5,
- 153,
- {23, "INVALID_STATE_ID_LENGTH"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 24 (requires previsous test)**
- "A.1.15.(6) State Creation",
- RFC4465_A_1_15__State_Creation_6,
- 153,
- {0, ""},
- 23,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 25 (requires previsous test)**
- "A.1.15.(7) State Creation",
- RFC4465_A_1_15__State_Creation_7,
- 152,
- {0, ""},
- 34,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 26 (requires previsous test)**
- "A.1.15.(8) State Creation",
- RFC4465_A_1_15__State_Creation_8,
- 153,
- {0, ""},
- 46,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 27 (requires previsous test)**
- "A.1.15.(9) State Creation",
- RFC4465_A_1_15__State_Creation_9,
- 153,
- {0, ""},
- 47,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
+struct_torture_test tests[] = {
+ {
+ //*** 0***
+ "A.1.1. Bit Manipulation",
+ RFC4465_A_1_1__Bit_Manipulation,
+ 170,
+ {8, "\x01\x50\x00\x00\xfe\xbf\x00\x00"},
+ 22,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 1***
+ "A.1.2(.1) Arithmetic",
+ RFC4465_A_1_2__Arithmetic_1,
+ 174,
+ {8, "\x00\x00\x00\x00\x00\x00\x00\x04"},
+ 25,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 2***
+ "A.1.2(.2) Arithmetic",
+ RFC4465_A_1_2__Arithmetic_2,
+ 174,
+ {11, "DIV_BY_ZERO"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 3***
+ "A.1.2(.3) Arithmetic",
+ RFC4465_A_1_2__Arithmetic_3,
+ 174,
+ {11, "DIV_BY_ZERO"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 4***
+ "A.1.3. Sorting",
+ RFC4465_A_1_3__Sorting,
+ 223,
+ {
+ 45, "\x46\x6f\x72\x64\x2c\x20\x79\x6f\x75\x27\x72\x65\x20\x74\x75\x72\x6e\x69\x6e\x67"
+ "\x20\x69\x6e\x74\x6f\x20\x61\x20\x70\x65\x6e\x67\x75\x69\x6e\x2e\x20\x53\x74\x6f"
+ "\x70\x20\x69\x74\x2e"
+ },
+ 371,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 5**
+ "A.1.4. SHA-1",
+ RFC4465_A_1_4__SHA1,
+ 138,
+ {
+ 40, "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e\x25\x71\x78\x50\xc2\x6c\x9c\xd0\xd8\x9d"
+ "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1"
+ "\x12\xff\x34\x7b\x4f\x27\xd6\x9e\x1f\x32\x8e\x6f\x4b\x55\x73\xe3\x66\x6e\x12\x2f"
+ "\x4f\x46\x04\x52\xeb\xb5\x63\x93\x4f\x46\x04\x52\xeb\xb5\x63\x93\x4f\x46\x04\x52"
+ },
+ 17176,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 6**
+ "A.1.5.(1) LOAD and MULTILOAD",
+ RFC4465_A_1_5__LOAD_and_MULTILOAD_1,
+ 58,
+ {16, "\x00\x84\x00\x84\x00\x86\x00\x86\x00\x2a\x00\x80\x00\x2a\x00\x2a"},
+ 36,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 7**
+ "A.1.5.(2) LOAD and MULTILOAD",
+ RFC4465_A_1_5__LOAD_and_MULTILOAD_2,
+ 58,
+ {21, "MULTILOAD_OVERWRITTEN"},
+ 36,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //*** 8**
+ "A.1.5.(3) LOAD and MULTILOAD",
+ RFC4465_A_1_5__LOAD_and_MULTILOAD_3,
+ 58,
+ {21, "MULTILOAD_OVERWRITTEN"},
+ 36,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 9**
+ "A.1.6. COPY",
+ RFC4465_A_1_6__COPY,
+ 60,
+ {
+ 125, "\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40"
+ "\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x40\x41\x41\x41\x41\x41\x41\x41\x41"
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x55\x41"
+ "\x42\x43\x44\x43\x44"
+ },
+ 365,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 10**
+ "A.1.7. COPY-LITERAL and COPY-OFFSET",
+ RFC4465_A_1_7__COPY_LITERAL_and_COPY_OFFSET,
+ 100,
+ {
+ 34, "\x41\x41\x41\x41\x00\x61\x41\x41\x41\x41\x49\x4a\x41\x42\x43\x44\x49\x4a\x41\x42"
+ "\x00\x4a\x00\x4e\x47\x48\x48\x45\x46\x47\x47\x48\x45\x46"
+ },
+ 216,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 11**
+ "A.1.8. MEMSET",
+ RFC4465_A_1_8__MEMSET,
+ 27,
+ {16, "\x80\x40\x4f\x5e\x6d\x7c\x8b\x9a\xa9\xb8\xc7\xd6\xe5\xf4\x03\x12"},
+ 166,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 12**
+ "A.1.9.(1) CRC",
+ RFC4465_A_1_9__CRC_1,
+ 29,
+ {0, ""},
+ 95,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 13**
+ "A.1.9.(2) CRC",
+ RFC4465_A_1_9__CRC_2,
+ 29,
+ {14, "USER_REQUESTED"},
+ 95,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 14**
+ "A.1.10. INPUT-BITS",
+ RFC4465_A_1_10__INPUT_BITS,
+ 28,
+ {16, "\x00\x00\x00\x02\x00\x02\x00\x13\x00\x00\x00\x03\x00\x1a\x00\x38"},
+ 66,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 15**
+ "A.1.11. INPUT-HUFFMAN",
+ RFC4465_A_1_11__INPUT_HUFFMAN,
+ 39,
+ {16, "\x00\x00\x00\x03\x00\x08\x04\xd7\x00\x02\x00\x03\x03\x99\x30\xfe"},
+ 84,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 16**
+ "A.1.12. INPUT-BYTES",
+ RFC4465_A_1_12__INPUT_BYTES,
+ 72,
+ {
+ 39, "\x00\x00\x93\x2e\x00\x01\xb1\x66\xd8\x6f\xb1\x00\x1a\x2b\x00\x03\x9a\x97\x34\xd8"
+ "\x00\x07\x00\x01\x33\x87\x4e\x00\x08\xdc\x96\x51\xb5\xdc\x96\x00\x59\x9d\x6a"
+ },
+ 130,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 17**
+ "A.1.13. Stack Manipulation",
+ RFC4465_A_1_13__Stack_Manipulation,
+ 324,
+ {16, "\x00\x03\x00\x02\x00\x01\x00\x42\x00\x42\x00\x00\x00\x01\x00\x01"},
+ 40,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 18**
+ "A.1.14. Program Flow",
+ RFC4465_A_1_14__Program_Flow,
+ 66,
+ {20, "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x07\x07\x07\x08\x08\x08\x09\x09"},
+ 131,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 19**
+ "A.1.15.(1) State Creation",
+ RFC4465_A_1_15__State_Creation_1,
+ 152,
+ {0, ""},
+ 23,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 20 (requires previsous test)**
+ "A.1.15.(2) State Creation",
+ RFC4465_A_1_15__State_Creation_2,
+ 152,
+ {0, ""},
+ 14,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 21 (requires previsous test)**
+ "A.1.15.(3) State Creation",
+ RFC4465_A_1_15__State_Creation_3,
+ 152,
+ {0, ""},
+ 24,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 22 (requires previsous test)**
+ "A.1.15.(4) State Creation", // FAIL
+ RFC4465_A_1_15__State_Creation_4,
+ 153,
+ {23, "INVALID_STATE_ID_LENGTH"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 23 (requires previsous test)**
+ "A.1.15.(5) State Creation", // FAIL
+ RFC4465_A_1_15__State_Creation_5,
+ 153,
+ {23, "INVALID_STATE_ID_LENGTH"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 24 (requires previsous test)**
+ "A.1.15.(6) State Creation",
+ RFC4465_A_1_15__State_Creation_6,
+ 153,
+ {0, ""},
+ 23,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 25 (requires previsous test)**
+ "A.1.15.(7) State Creation",
+ RFC4465_A_1_15__State_Creation_7,
+ 152,
+ {0, ""},
+ 34,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 26 (requires previsous test)**
+ "A.1.15.(8) State Creation",
+ RFC4465_A_1_15__State_Creation_8,
+ 153,
+ {0, ""},
+ 46,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 27 (requires previsous test)**
+ "A.1.15.(9) State Creation",
+ RFC4465_A_1_15__State_Creation_9,
+ 153,
+ {0, ""},
+ 47,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
#if 0 // FIXME: http://code.google.com/p/doubango/issues/detail?id=181
- ,
- {
- //** 23 (requires previsous test)**
- "A.1.15.(10) State Creation",
- RFC4465_A_1_15__State_Creation_10,
- 153,
- {0, ""},
- 60,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
+ ,
+ {
+ //** 23 (requires previsous test)**
+ "A.1.15.(10) State Creation",
+ RFC4465_A_1_15__State_Creation_10,
+ 153,
+ {0, ""},
+ 60,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
#endif
- ,
- {
- //** 28**
- "A.1.16.(0) STATE-ACCESS {Set up bytecode}",
- RFC4465_A_1_16__STATE_ACCESS__SETUP,
- 403,
- {0, ""},
- 17,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 29 (requires previous test)**
- "A.1.16.(1) STATE-ACCESS",
- RFC4465_A_1_16__STATE_ACCESS_1,
- 408,
- {4, "\x74\x65\x73\x74"},
- 26,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 30 (requires previous test)**
- "A.1.16.(2) STATE-ACCESS",
- RFC4465_A_1_16__STATE_ACCESS_2,
- 408,
- {4, "\x74\x65\x73\x74"},
- 15,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 31 (requires previous test)**
- "A.1.16.(3) STATE-ACCESS",
- RFC4465_A_1_16__STATE_ACCESS_3,
- 408,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 32 (requires previous test)**
- "A.1.16.(4) STATE-ACCESS",
- RFC4465_A_1_16__STATE_ACCESS_4,
- 408,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 33 (requires previous test)**
- "A.1.16.(5) STATE-ACCESS",
- RFC4465_A_1_16__STATE_ACCESS_5,
- 408,
- {15, "STATE_TOO_SHORT"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 34**
- "A.2.1.(1) Useful Values",
- RFC4465_A_2_1__Useful_Values_1,
- 93,
- {0, ""},
- 966,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 35 (Requires previous test)**
- "A.2.1.(2) Useful Values",
- RFC4465_A_2_1__Useful_Values_2,
- 9,
- {0, ""},
- (1072 << 4),
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 36 (Requires previous test)**
- "A.2.1.(3) Useful Values",
- RFC4465_A_2_1__Useful_Values_3,
- 9,
- {16, "CYCLES_EXHAUSTED"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 37 (Requires previous test)**
- "A.2.1.(4) Useful Values",
- RFC4465_A_2_1__Useful_Values_4,
- 9,
- {8, "SEGFAULT"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 38**
- "A.2.2. Cycles Checking",
- RFC4465_A_2_2__Cycles_Checking,
- 29,
- {16, "CYCLES_EXHAUSTED"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 39**
- "A.2.3.(1) Message-based Transport",
- RFC4465_A_2_3_Message_based_Transport_1,
- 1,
- {17, "MESSAGE_TOO_SHORT"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 40**
- "A.2.3.(2) Message-based Transport",
- RFC4465_A_2_3_Message_based_Transport_2,
- 2,
- {17, "MESSAGE_TOO_SHORT"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 41**
- "A.2.3.(3) Message-based Transport",
- RFC4465_A_2_3_Message_based_Transport_3,
- 17,
- {25, "decompression_memory_size"},
- 5,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 42**
- "A.2.3.(4) Message-based Transport",
- RFC4465_A_2_3_Message_based_Transport_4,
- 17,
- {17, "MESSAGE_TOO_SHORT"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 43**
- "A.2.3.(5) Message-based Transport",
- RFC4465_A_2_3_Message_based_Transport_5,
- 17,
- {21, "INVALID_CODE_LOCATION"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 44**
- "A.2.3.(6) Message-based Transport",
- RFC4465_A_2_3_Message_based_Transport_6,
- 17,
- {25, "decompression_memory_size"},
- 5,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 45**
- "A.2.4.(1&2) Stream-based Transport",
- RFC4465_A_2_4_Stream_based_Transport_1,
- 67,
- {25, "decompression_memory_size"},
- 11,
- IS_STREAM_YES,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 46**
- "A.2.4.(3) Stream-based Transport",
- RFC4465_A_2_4_Stream_based_Transport_3,
- 3,
- {17, "MESSAGE_TOO_SHORT"},
- 0,
- IS_STREAM_YES,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 47**
- "A.2.4.(4) Stream-based Transport",
- RFC4465_A_2_4_Stream_based_Transport_4,
- 4,
- {17, "MESSAGE_TOO_SHORT"},
- 0,
- IS_STREAM_YES,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 48**
- "A.2.4.(5) Stream-based Transport",
- RFC4465_A_2_4_Stream_based_Transport_5,
- 30,
- {17, "MESSAGE_TOO_SHORT"},
- 0,
- IS_STREAM_YES,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 49**
- "A.2.4.(5.1) Stream-based Transport (cleanup)",
- "\xff\xff",
- 2,
- {14, "INTERNAL_ERROR"},
- 0,
- IS_STREAM_YES,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 50**
- "A.2.4.(6) Stream-based Transport",
- RFC4465_A_2_4_Stream_based_Transport_6,
- 29,
- {21, "INVALID_CODE_LOCATION"},
- 0,
- IS_STREAM_YES,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 51**
- "A.2.4.(6.1) Stream-based Transport (cleanup)",
- "\xff\xff",
- 2,
- {14, "INTERNAL_ERROR"},
- 0,
- IS_STREAM_YES,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 52**
- "A.2.5.(1) Input Past the End of a Message",
- RFC4465_A_2_5__Input_Past_the_End_of_a_Message_1,
- 59,
- {3, "\x68\x69\x21"},
- 23,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 53**
- "A.2.5.(2) Input Past the End of a Message",
- RFC4465_A_2_5__Input_Past_the_End_of_a_Message_2,
- 58,
- {14, "USER_REQUESTED"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 54**
- "A.3.1.(1) SigComp Feedback Mechanism",
- RFC4465_A_3_1__SigComp_Feedback_Mechanism_1,
- 84,
- {0, ""},
- 52,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 55**
- "A.3.1.(2) SigComp Feedback Mechanism",
- RFC4465_A_3_1__SigComp_Feedback_Mechanism_2,
- 84,
- {0, ""},
- 179,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 56 (SMS MUST be 2048)**
- "A.3.2.(1) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_1,
- 446,
- {0, ""},
- 811,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 57 (Requires previous test)**
- "A.3.2.(2) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_2,
- 446,
- {0, ""},
- 2603,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 58 (Requires previous test)**
- "A.3.2.(3) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_3,
- 446,
- {0, ""},
- 811,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 59 (Requires previous test)**
- "A.3.2.(4) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_4,
- 446,
- {0, ""},
- 1805,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 60 (Requires previous test)**
- "A.3.2.(5) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_5,
- 446,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID
- }
- ,
- {
- //** 61 (Requires previous test)**
- "A.3.2.(6) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_6,
- 446,
- {0, ""},
- 2057,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 62 (Requires previous test)**
- "A.3.2.(7) State Memory Management",
- RFC4465_A_3_2__State_Memory_Management_7,
- 446,
- {0, ""},
- 1993,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 63**
- "A.3.3.(1) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_1,
- 437,
- {0, ""},
- 1809,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID_0
- }
- ,
- {
- //** 64 (requires previsous test)**
- "A.3.3.(2) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_2,
- 437,
- {0, ""},
- 1809,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID_1
- }
- ,
- {
- //** 65 (requires previsous test)**
- "A.3.3.(3) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_3,
- 437,
- {0, ""},
- 1809,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID_2
- }
- ,
- {
- //** 66 (requires previsous test)**
- "A.3.3.(4) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_4,
- 437,
- {0, ""},
- 1993,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID_0
- }
- ,
- {
- //** 67 (requires previsous test)**
- "A.3.3.(5) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_5,
- 437,
- {0, ""},
- 1994,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID_1
- }
- ,
- {
- //** 68 (requires previsous test)**
- "A.3.3.(6) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_6,
- 437,
- {0, ""},
- 1804,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID_2
- }
- ,
- {
- //** 69 (requires previsous test)**
- "A.3.3.(7) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_7,
- 437,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID_0
- }
- ,
- {
- //** 70 (requires previsous test)**
- "A.3.3.(8) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_8,
- 437,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID_1
- }
- ,
- {
- //** 71 (requires previsous test)**
- "A.3.3.(9) Multiple Compartments",
- RFC4465_A_3_3__Multiple_Compartments_9,
- 437,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- COMPARTMENT_ID_2
- }
- ,
- {
- //** 72**
- "A.3.4. Accessing RFC 3485 State",
- RFC4465_A_3_4__Accessing_RFC_3485_State,
- 61,
- {3, "\x53\x49\x50"},
- 11,
- IS_STREAM_NO,
- XFAIL_NO,
- COMPARTMENT_ID
- }
- ,
- {
- //** 73**
- "A.3.5.(1) Bytecode State Creation",
- RFC4465_A_3_5__Bytecode_State_Creation_1,
- 74,
- {2, "\x4f\x4b"},
- 66,
- IS_STREAM_NO,
- XFAIL_NO,
- "Comp-id:A.3.5. Bytecode State Creation"
- }
- ,
- {
- //** 74**
- "A.3.5.(2) Bytecode State Creation",
- RFC4465_A_3_5__Bytecode_State_Creation_2,
- 8,
- {3, "\x4f\x4b\x31"},
- 7,
- IS_STREAM_NO,
- XFAIL_NO,
- "Comp-id:A.3.5. Bytecode State Creation"
- }
- ,
- {
- //** 75**
- "A.3.5.(3) Bytecode State Creation",
- RFC4465_A_3_5__Bytecode_State_Creation_3,
- 13,
- {3, "\x4f\x4b\x32"},
- 5,
- IS_STREAM_NO,
- XFAIL_NO,
- "Comp-id:A.3.5. Bytecode State Creation"
- }
- ,
- {
- //** 76**
- "A.3.5.(4) Bytecode State Creation",
- RFC4465_A_3_5__Bytecode_State_Creation_4,
- 7,
- {3, "\x00\x00\x32"},
- 5,
- IS_STREAM_NO,
- XFAIL_NO,
- "Comp-id:A.3.5. Bytecode State Creation"
- }
- ,
- {
- //** 77**
- "A.3.5.(5) Bytecode State Creation",
- RFC4465_A_3_5__Bytecode_State_Creation_5,
- 7,
- {15, "STATE_NOT_FOUND"},
- 0,
- IS_STREAM_NO,
- XFAIL_YES,
- "Comp-id:A.3.5. Bytecode State Creation"
- }
+ ,
+ {
+ //** 28**
+ "A.1.16.(0) STATE-ACCESS {Set up bytecode}",
+ RFC4465_A_1_16__STATE_ACCESS__SETUP,
+ 403,
+ {0, ""},
+ 17,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 29 (requires previous test)**
+ "A.1.16.(1) STATE-ACCESS",
+ RFC4465_A_1_16__STATE_ACCESS_1,
+ 408,
+ {4, "\x74\x65\x73\x74"},
+ 26,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 30 (requires previous test)**
+ "A.1.16.(2) STATE-ACCESS",
+ RFC4465_A_1_16__STATE_ACCESS_2,
+ 408,
+ {4, "\x74\x65\x73\x74"},
+ 15,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 31 (requires previous test)**
+ "A.1.16.(3) STATE-ACCESS",
+ RFC4465_A_1_16__STATE_ACCESS_3,
+ 408,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 32 (requires previous test)**
+ "A.1.16.(4) STATE-ACCESS",
+ RFC4465_A_1_16__STATE_ACCESS_4,
+ 408,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 33 (requires previous test)**
+ "A.1.16.(5) STATE-ACCESS",
+ RFC4465_A_1_16__STATE_ACCESS_5,
+ 408,
+ {15, "STATE_TOO_SHORT"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 34**
+ "A.2.1.(1) Useful Values",
+ RFC4465_A_2_1__Useful_Values_1,
+ 93,
+ {0, ""},
+ 966,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 35 (Requires previous test)**
+ "A.2.1.(2) Useful Values",
+ RFC4465_A_2_1__Useful_Values_2,
+ 9,
+ {0, ""},
+ (1072 << 4),
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 36 (Requires previous test)**
+ "A.2.1.(3) Useful Values",
+ RFC4465_A_2_1__Useful_Values_3,
+ 9,
+ {16, "CYCLES_EXHAUSTED"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 37 (Requires previous test)**
+ "A.2.1.(4) Useful Values",
+ RFC4465_A_2_1__Useful_Values_4,
+ 9,
+ {8, "SEGFAULT"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 38**
+ "A.2.2. Cycles Checking",
+ RFC4465_A_2_2__Cycles_Checking,
+ 29,
+ {16, "CYCLES_EXHAUSTED"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 39**
+ "A.2.3.(1) Message-based Transport",
+ RFC4465_A_2_3_Message_based_Transport_1,
+ 1,
+ {17, "MESSAGE_TOO_SHORT"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 40**
+ "A.2.3.(2) Message-based Transport",
+ RFC4465_A_2_3_Message_based_Transport_2,
+ 2,
+ {17, "MESSAGE_TOO_SHORT"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 41**
+ "A.2.3.(3) Message-based Transport",
+ RFC4465_A_2_3_Message_based_Transport_3,
+ 17,
+ {25, "decompression_memory_size"},
+ 5,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 42**
+ "A.2.3.(4) Message-based Transport",
+ RFC4465_A_2_3_Message_based_Transport_4,
+ 17,
+ {17, "MESSAGE_TOO_SHORT"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 43**
+ "A.2.3.(5) Message-based Transport",
+ RFC4465_A_2_3_Message_based_Transport_5,
+ 17,
+ {21, "INVALID_CODE_LOCATION"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 44**
+ "A.2.3.(6) Message-based Transport",
+ RFC4465_A_2_3_Message_based_Transport_6,
+ 17,
+ {25, "decompression_memory_size"},
+ 5,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 45**
+ "A.2.4.(1&2) Stream-based Transport",
+ RFC4465_A_2_4_Stream_based_Transport_1,
+ 67,
+ {25, "decompression_memory_size"},
+ 11,
+ IS_STREAM_YES,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 46**
+ "A.2.4.(3) Stream-based Transport",
+ RFC4465_A_2_4_Stream_based_Transport_3,
+ 3,
+ {17, "MESSAGE_TOO_SHORT"},
+ 0,
+ IS_STREAM_YES,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 47**
+ "A.2.4.(4) Stream-based Transport",
+ RFC4465_A_2_4_Stream_based_Transport_4,
+ 4,
+ {17, "MESSAGE_TOO_SHORT"},
+ 0,
+ IS_STREAM_YES,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 48**
+ "A.2.4.(5) Stream-based Transport",
+ RFC4465_A_2_4_Stream_based_Transport_5,
+ 30,
+ {17, "MESSAGE_TOO_SHORT"},
+ 0,
+ IS_STREAM_YES,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 49**
+ "A.2.4.(5.1) Stream-based Transport (cleanup)",
+ "\xff\xff",
+ 2,
+ {14, "INTERNAL_ERROR"},
+ 0,
+ IS_STREAM_YES,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 50**
+ "A.2.4.(6) Stream-based Transport",
+ RFC4465_A_2_4_Stream_based_Transport_6,
+ 29,
+ {21, "INVALID_CODE_LOCATION"},
+ 0,
+ IS_STREAM_YES,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 51**
+ "A.2.4.(6.1) Stream-based Transport (cleanup)",
+ "\xff\xff",
+ 2,
+ {14, "INTERNAL_ERROR"},
+ 0,
+ IS_STREAM_YES,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 52**
+ "A.2.5.(1) Input Past the End of a Message",
+ RFC4465_A_2_5__Input_Past_the_End_of_a_Message_1,
+ 59,
+ {3, "\x68\x69\x21"},
+ 23,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 53**
+ "A.2.5.(2) Input Past the End of a Message",
+ RFC4465_A_2_5__Input_Past_the_End_of_a_Message_2,
+ 58,
+ {14, "USER_REQUESTED"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 54**
+ "A.3.1.(1) SigComp Feedback Mechanism",
+ RFC4465_A_3_1__SigComp_Feedback_Mechanism_1,
+ 84,
+ {0, ""},
+ 52,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 55**
+ "A.3.1.(2) SigComp Feedback Mechanism",
+ RFC4465_A_3_1__SigComp_Feedback_Mechanism_2,
+ 84,
+ {0, ""},
+ 179,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 56 (SMS MUST be 2048)**
+ "A.3.2.(1) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_1,
+ 446,
+ {0, ""},
+ 811,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 57 (Requires previous test)**
+ "A.3.2.(2) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_2,
+ 446,
+ {0, ""},
+ 2603,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 58 (Requires previous test)**
+ "A.3.2.(3) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_3,
+ 446,
+ {0, ""},
+ 811,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 59 (Requires previous test)**
+ "A.3.2.(4) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_4,
+ 446,
+ {0, ""},
+ 1805,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 60 (Requires previous test)**
+ "A.3.2.(5) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_5,
+ 446,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 61 (Requires previous test)**
+ "A.3.2.(6) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_6,
+ 446,
+ {0, ""},
+ 2057,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 62 (Requires previous test)**
+ "A.3.2.(7) State Memory Management",
+ RFC4465_A_3_2__State_Memory_Management_7,
+ 446,
+ {0, ""},
+ 1993,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 63**
+ "A.3.3.(1) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_1,
+ 437,
+ {0, ""},
+ 1809,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID_0
+ }
+ ,
+ {
+ //** 64 (requires previsous test)**
+ "A.3.3.(2) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_2,
+ 437,
+ {0, ""},
+ 1809,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID_1
+ }
+ ,
+ {
+ //** 65 (requires previsous test)**
+ "A.3.3.(3) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_3,
+ 437,
+ {0, ""},
+ 1809,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID_2
+ }
+ ,
+ {
+ //** 66 (requires previsous test)**
+ "A.3.3.(4) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_4,
+ 437,
+ {0, ""},
+ 1993,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID_0
+ }
+ ,
+ {
+ //** 67 (requires previsous test)**
+ "A.3.3.(5) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_5,
+ 437,
+ {0, ""},
+ 1994,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID_1
+ }
+ ,
+ {
+ //** 68 (requires previsous test)**
+ "A.3.3.(6) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_6,
+ 437,
+ {0, ""},
+ 1804,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID_2
+ }
+ ,
+ {
+ //** 69 (requires previsous test)**
+ "A.3.3.(7) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_7,
+ 437,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID_0
+ }
+ ,
+ {
+ //** 70 (requires previsous test)**
+ "A.3.3.(8) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_8,
+ 437,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID_1
+ }
+ ,
+ {
+ //** 71 (requires previsous test)**
+ "A.3.3.(9) Multiple Compartments",
+ RFC4465_A_3_3__Multiple_Compartments_9,
+ 437,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ COMPARTMENT_ID_2
+ }
+ ,
+ {
+ //** 72**
+ "A.3.4. Accessing RFC 3485 State",
+ RFC4465_A_3_4__Accessing_RFC_3485_State,
+ 61,
+ {3, "\x53\x49\x50"},
+ 11,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ COMPARTMENT_ID
+ }
+ ,
+ {
+ //** 73**
+ "A.3.5.(1) Bytecode State Creation",
+ RFC4465_A_3_5__Bytecode_State_Creation_1,
+ 74,
+ {2, "\x4f\x4b"},
+ 66,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ "Comp-id:A.3.5. Bytecode State Creation"
+ }
+ ,
+ {
+ //** 74**
+ "A.3.5.(2) Bytecode State Creation",
+ RFC4465_A_3_5__Bytecode_State_Creation_2,
+ 8,
+ {3, "\x4f\x4b\x31"},
+ 7,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ "Comp-id:A.3.5. Bytecode State Creation"
+ }
+ ,
+ {
+ //** 75**
+ "A.3.5.(3) Bytecode State Creation",
+ RFC4465_A_3_5__Bytecode_State_Creation_3,
+ 13,
+ {3, "\x4f\x4b\x32"},
+ 5,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ "Comp-id:A.3.5. Bytecode State Creation"
+ }
+ ,
+ {
+ //** 76**
+ "A.3.5.(4) Bytecode State Creation",
+ RFC4465_A_3_5__Bytecode_State_Creation_4,
+ 7,
+ {3, "\x00\x00\x32"},
+ 5,
+ IS_STREAM_NO,
+ XFAIL_NO,
+ "Comp-id:A.3.5. Bytecode State Creation"
+ }
+ ,
+ {
+ //** 77**
+ "A.3.5.(5) Bytecode State Creation",
+ RFC4465_A_3_5__Bytecode_State_Creation_5,
+ 7,
+ {15, "STATE_NOT_FOUND"},
+ 0,
+ IS_STREAM_NO,
+ XFAIL_YES,
+ "Comp-id:A.3.5. Bytecode State Creation"
+ }
};
-int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t size2)
+int startsWith(const char* buffer1, size_t size1, const char* buffer2, size_t size2)
{
- size_t i;
+ size_t i;
- if(!size2) return 1;
- if(size1 < size2) return 0;
+ if(!size2) {
+ return 1;
+ }
+ if(size1 < size2) {
+ return 0;
+ }
- for(i = 0; i< size2; i++)
- {
- if(buffer1[i] != buffer2[i])
- {
- return 0;
- }
- }
- return 1;
+ for(i = 0; i< size2; i++) {
+ if(buffer1[i] != buffer2[i]) {
+ return 0;
+ }
+ }
+ return 1;
}
static const int16_t wordForEndianess = 0x4321;
@@ -1031,116 +1046,116 @@ static tsk_bool_t isBigEndian;
static TCOMP_INLINE uint16_t HostToNetworkShort(uint16_t x)
{
- return isBigEndian ? (x) : ((((uint16_t)(x) & 0xff00) >> 8) |
- (((uint16_t)(x) & 0x00ff) << 8));
+ return isBigEndian ? (x) : ((((uint16_t)(x) & 0xff00) >> 8) |
+ (((uint16_t)(x) & 0x00ff) << 8));
}
static void checkResult(const struct_torture_test* test, const tcomp_result_t *result, const void* output_ptr, tsk_size_t output_size)
{
- tsk_bool_t ok_cycles = (result->consumed_cycles == test->xcycles);
- tsk_bool_t ok_output = tsk_true;
+ tsk_bool_t ok_cycles = (result->consumed_cycles == test->xcycles);
+ tsk_bool_t ok_output = tsk_true;
- if(tsk_striequals(test->xoutput.ptr, "decompression_memory_size")){
- printf("xoutput (decompression_memory_size): %s\n", (HostToNetworkShort(DMS) == *((uint16_t*)output_ptr)) ? "YES" : "NO");
- }
- else{
- ok_output = startsWith(output_ptr, output_size, test->xoutput.ptr, test->xoutput.size);
- printf("xoutput: %s\n", ok_output ? "YES" : "NO");
- }
- printf("xcycles: %s\n", ok_cycles ? "YES" : "NO");
- if(!ok_cycles || !ok_output){
- assert(test->xfail && result->isNack); // failure must be expected and NACK have to be present
- assert(tsk_strequals(test->xoutput.ptr, tcomp_nackinfo_get_description(result->nack_info))); // returned NACK and expected one must be equal
- }
+ if(tsk_striequals(test->xoutput.ptr, "decompression_memory_size")) {
+ printf("xoutput (decompression_memory_size): %s\n", (HostToNetworkShort(DMS) == *((uint16_t*)output_ptr)) ? "YES" : "NO");
+ }
+ else {
+ ok_output = startsWith(output_ptr, output_size, test->xoutput.ptr, test->xoutput.size);
+ printf("xoutput: %s\n", ok_output ? "YES" : "NO");
+ }
+ printf("xcycles: %s\n", ok_cycles ? "YES" : "NO");
+ if(!ok_cycles || !ok_output) {
+ assert(test->xfail && result->isNack); // failure must be expected and NACK have to be present
+ assert(tsk_strequals(test->xoutput.ptr, tcomp_nackinfo_get_description(result->nack_info))); // returned NACK and expected one must be equal
+ }
}
static int test_tortures()
{
- size_t i, start, end;
- size_t res_size = 0;
- char buffer[OUTPUT_BUFFER_SIZE];
+ size_t i, start, end;
+ size_t res_size = 0;
+ char buffer[OUTPUT_BUFFER_SIZE];
#if RUN_TEST_LOOP
- for(;;)
+ for(;;)
#endif
- {
- tcomp_manager_handle_t *manager = tcomp_manager_create();
- tcomp_result_t *result = tcomp_result_create();
+ {
+ tcomp_manager_handle_t *manager = tcomp_manager_create();
+ tcomp_result_t *result = tcomp_result_create();
- isBigEndian = ((*(int8_t *)&wordForEndianess) != 0x21);
+ isBigEndian = ((*(int8_t *)&wordForEndianess) != 0x21);
- /* Add SIP dictionary. */
- tcomp_manager_addSipSdpDictionary(manager);
+ /* Add SIP dictionary. */
+ tcomp_manager_addSipSdpDictionary(manager);
- /* Add Presence dictionary. */
- tcomp_manager_addPresenceDictionary(manager);
+ /* Add Presence dictionary. */
+ tcomp_manager_addPresenceDictionary(manager);
- /* Set decompression size. */
- tcomp_manager_setDecompression_Memory_Size(manager, DMS);
- /* Set state memory size. */
- tcomp_manager_setState_Memory_Size(manager, SMS);
- /* Set Cycles Per Bit */
- tcomp_manager_setCycles_Per_Bit(manager, CPB);
+ /* Set decompression size. */
+ tcomp_manager_setDecompression_Memory_Size(manager, DMS);
+ /* Set state memory size. */
+ tcomp_manager_setState_Memory_Size(manager, SMS);
+ /* Set Cycles Per Bit */
+ tcomp_manager_setCycles_Per_Bit(manager, CPB);
#if RUN_TEST_ALL
- start = 0, end = sizeof(tests)/sizeof(tests[0]);
+ start = 0, end = sizeof(tests)/sizeof(tests[0]);
#else
- start = RUN_TEST_NO, end = RUN_TEST_NO + 1;
+ start = RUN_TEST_NO, end = RUN_TEST_NO + 1;
#endif
- for(i = start; i<end; i++){
- printf("=== Testing %s ===\n\n", tests[i].section_name);
+ for(i = start; i<end; i++) {
+ printf("=== Testing %s ===\n\n", tests[i].section_name);
- if(tests[i].stream){
- tcomp_result_setOutputTCPBuffer(result, buffer, OUTPUT_BUFFER_SIZE, STREAM_ID);
- }
- else{
- tcomp_result_setOutputUDPBuffer(result, buffer, OUTPUT_BUFFER_SIZE);
- }
+ if(tests[i].stream) {
+ tcomp_result_setOutputTCPBuffer(result, buffer, OUTPUT_BUFFER_SIZE, STREAM_ID);
+ }
+ else {
+ tcomp_result_setOutputUDPBuffer(result, buffer, OUTPUT_BUFFER_SIZE);
+ }
- /* Performs decompression */
- res_size = tcomp_manager_decompress(manager, tests[i].bytecode, tests[i].bytecode_size, result);
- if(result->isNack){
- printf("\n==WE GOT A NACK\n\n");
- //sendto(tcomp_buffer_getBuffer(result->nack_info), tcomp_buffer_getSize(result->nack_info));
- }
- else{
- tcomp_result_setCompartmentId(result, tests[i].comp_id, strlen(tests[i].comp_id));
- tcomp_manager_provideCompartmentId(manager, result);
- }
+ /* Performs decompression */
+ res_size = tcomp_manager_decompress(manager, tests[i].bytecode, tests[i].bytecode_size, result);
+ if(result->isNack) {
+ printf("\n==WE GOT A NACK\n\n");
+ //sendto(tcomp_buffer_getBuffer(result->nack_info), tcomp_buffer_getSize(result->nack_info));
+ }
+ else {
+ tcomp_result_setCompartmentId(result, tests[i].comp_id, strlen(tests[i].comp_id));
+ tcomp_manager_provideCompartmentId(manager, result);
+ }
- /* Checks result */
- checkResult(&tests[i], result, buffer, sizeof(buffer));
+ /* Checks result */
+ checkResult(&tests[i], result, buffer, sizeof(buffer));
- /* Get sub-sequent stream messages */
- if(tests[i].stream && (res_size || result->isNack)){
- uint64_t consumed_cycles = result->consumed_cycles; // save "consumed_cycles" (shared by all sub-sequent messages)
- for(;;){
- res_size = tcomp_manager_getNextStreamMessage(manager, result);
- if(!res_size && !result->isNack){
- break;
- }
- else if(res_size){
- tcomp_result_setCompartmentId(result, tests[i].comp_id, strlen(tests[i].comp_id));
- tcomp_manager_provideCompartmentId(manager, result);
- }
- else{
- printf("\n==WE GOT A NACK\n\n");
- //sendto(tcomp_buffer_getBuffer(result->nack_info), tcomp_buffer_getSize(result->nack_info));
- }
- result->consumed_cycles = consumed_cycles; // restore cycles just for checking. Had been cleared by "tcomp_manager_getNextStreamMessage()"
- checkResult(&tests[i], result, buffer, sizeof(buffer));
- }
- }
- }
+ /* Get sub-sequent stream messages */
+ if(tests[i].stream && (res_size || result->isNack)) {
+ uint64_t consumed_cycles = result->consumed_cycles; // save "consumed_cycles" (shared by all sub-sequent messages)
+ for(;;) {
+ res_size = tcomp_manager_getNextStreamMessage(manager, result);
+ if(!res_size && !result->isNack) {
+ break;
+ }
+ else if(res_size) {
+ tcomp_result_setCompartmentId(result, tests[i].comp_id, strlen(tests[i].comp_id));
+ tcomp_manager_provideCompartmentId(manager, result);
+ }
+ else {
+ printf("\n==WE GOT A NACK\n\n");
+ //sendto(tcomp_buffer_getBuffer(result->nack_info), tcomp_buffer_getSize(result->nack_info));
+ }
+ result->consumed_cycles = consumed_cycles; // restore cycles just for checking. Had been cleared by "tcomp_manager_getNextStreamMessage()"
+ checkResult(&tests[i], result, buffer, sizeof(buffer));
+ }
+ }
+ }
- /* Free previously allocated resources. */
- TSK_OBJECT_SAFE_FREE(result);
- TSK_OBJECT_SAFE_FREE(manager);
+ /* Free previously allocated resources. */
+ TSK_OBJECT_SAFE_FREE(result);
+ TSK_OBJECT_SAFE_FREE(manager);
- }/* LOOP */
+ }/* LOOP */
- return 0;
+ return 0;
}
#endif /* TEST_TINYSIGCOMP_TORTURES_H */
OpenPOWER on IntegriCloud