The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
compressframe.c File Reference

Implements CompressFrame Object - the comprssion frame. More...

#include <glib.h>
#include <fcntl.h>
#include <memory.h>
#include <malloc.h>
#include <compressframe.h>
#include <frameset.h>
#include <generic_tlv_min.h>
#include <tlvhelper.h>
#include <stdio.h>
Include dependency graph for compressframe.c:

Go to the source code of this file.

Data Structures

struct  compression_types
 Set of all known compression methods.
 

Macros

#define KBYTES(n)   ((n)*1024)
 
#define MAXUNCOMPRESSEDSIZE   KBYTES(1024)
 In practice, our max JSON decompressed size is under 325K, so 1M seems safe more or less not matter what compression method one uses – on JSON... More...
 
#define ZLIB_CONSTANT(e)   ((guint8*)(GSIZE_TO_POINTER(GPOINTER_TO_SIZE(e))))
 
#define COMPFRAMESIZE   4
 
#define COMPRESSFRAMEMIN   4
 

Functions

FSTATIC void _compressframe_finalize (AssimObj *self)
 
FSTATIC void _compressframe_setvalue (Frame *, gpointer, guint32, GDestroyNotify valnotify)
 
FSTATIC void _compressframe_updatedata (Frame *f,gpointer tlvstart,gconstpointer pktend,FrameSet *fs)
 We update the data in the packet from our CompressFrame object AND ALSO have the side-effect of compressing all the frames already put into the packet. More...
 
FSTATIC gboolean _compressframe_isvalid (const Frame *fself, gconstpointer tlvstart, gconstpointer pktend)
 Return TRUE if this is a valid CompressFrame - either an object or on-the-wire version. More...
 
FSTATIC int _compressframe_findmethod (int method)
 
FSTATIC gchar * _compressframe_toString (gconstpointer)
 
FSTATIC void assim_dump_bytes (char *prefix, gconstpointer p, int len)
 
CompressFramecompressframe_new (guint16 frame_type, guint16 compression_method)
 
CompressFramecompressframe_new_string (guint16 frame_type, const char *compression_name)
 
FSTATIC Framecompressframe_tlvconstructor (gpointer tlvstart, gconstpointer pktend, gpointer *newpacket, gpointer *newpacketend)
 

Variables

 DEBUGDECLARATIONS
 

Detailed Description

Implements CompressFrame Object - the comprssion frame.

Implements the CompressFrame object for on-the-wire compression and decompression. This includes the code to link to the available compression libraries - currently only zlib (-lz).

Author
Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh - Copyright © 2013 - Assimilation Systems Limited Free support is available from the Assimilation Project community - http://assimproj.org Paid support is available from Assimilation Systems Limited - http://assimilationsystems.com


This file is part of the Assimilation Project. The Assimilation software 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.

The Assimilation software 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 the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file compressframe.c.

Macro Definition Documentation

#define COMPFRAMESIZE   4

Definition at line 72 of file compressframe.c.

Referenced by _compressframe_updatedata(), and compressframe_new().

#define COMPRESSFRAMEMIN   4

Definition at line 272 of file compressframe.c.

Referenced by compressframe_tlvconstructor().

#define KBYTES (   n)    ((n)*1024)

Definition at line 35 of file compressframe.c.

#define MAXUNCOMPRESSEDSIZE   KBYTES(1024)

In practice, our max JSON decompressed size is under 325K, so 1M seems safe more or less not matter what compression method one uses – on JSON...

Definition at line 38 of file compressframe.c.

Referenced by compressframe_tlvconstructor().

#define ZLIB_CONSTANT (   e)    ((guint8*)(GSIZE_TO_POINTER(GPOINTER_TO_SIZE(e))))

Definition at line 59 of file compressframe.c.

Function Documentation

FSTATIC void _compressframe_finalize ( AssimObj self)

Referenced by compressframe_new().

Here is the caller graph for this function:

FSTATIC int _compressframe_findmethod ( int  method)

Definition at line 108 of file compressframe.c.

References DIMOF.

Referenced by _compressframe_isvalid(), compressframe_new(), and compressframe_tlvconstructor().

Here is the caller graph for this function:

FSTATIC gboolean _compressframe_isvalid ( const Frame fself,
gconstpointer  tlvstart,
gconstpointer  pktend 
)

Return TRUE if this is a valid CompressFrame - either an object or on-the-wire version.

Definition at line 166 of file compressframe.c.

References _compressframe_findmethod(), CASTTOCONSTCLASS, DIMOF, get_generic_tlv_len(), get_generic_tlv_value(), tlv_get_guint24(), and tlv_get_guint8().

Referenced by compressframe_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _compressframe_setvalue ( Frame f,
gpointer  value,
guint32  len,
GDestroyNotify  valnotify 
)

Definition at line 191 of file compressframe.c.

References __FUNCTION__.

Referenced by compressframe_new().

Here is the caller graph for this function:

FSTATIC gchar * _compressframe_toString ( gconstpointer  aself)

Definition at line 201 of file compressframe.c.

References CASTTOCONSTCLASS.

Referenced by compressframe_new().

Here is the caller graph for this function:

FSTATIC void _compressframe_updatedata ( Frame f,
gpointer  tlvstart,
gconstpointer  pktend,
FrameSet fs 
)

We update the data in the packet from our CompressFrame object AND ALSO have the side-effect of compressing all the frames already put into the packet.

Note that this only works because we always construct the packet from the end back to the beginning.

Definition at line 222 of file compressframe.c.

References __FUNCTION__, CASTTOCLASS, COMPFRAMESIZE, FRAME_INITSIZE, FREE, get_generic_tlv_nonconst_value(), MAXUDPSIZE, _FrameSet::packet, _FrameSet::pktend, set_generic_tlv_len(), set_generic_tlv_type(), tlv_set_guint24(), tlv_set_guint8(), and _Frame::type.

Referenced by compressframe_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void assim_dump_bytes ( char *  prefix,
gconstpointer  p,
int  len 
)

Definition at line 95 of file compressframe.c.

CompressFrame* compressframe_new_string ( guint16  frame_type,
const char *  compression_name 
)

Definition at line 154 of file compressframe.c.

References compressframe_new(), DIMOF, and cma.store::name.

Here is the call graph for this function:

FSTATIC Frame* compressframe_tlvconstructor ( gpointer  tlvstart,
gconstpointer  pktend,
gpointer *  newpacket,
gpointer *  newpacketend 
)

< Start of compessed data

< Pointer to TLV Value

< Compressed packet size

< Type of compression from Value

< Size after decompression (from Value)

< Size after decompression (from decompression)

< Which compression method are we using? This is an index into allcompressions

< Frametype of this frame - TLV Type

< Return value

Parameters
[in]tlvstartStart of the compression frame
[in]pktendFirst byte past the end of the packet
[out]newpacketreplacement packet
[out]newpacketendend of replacement packet

Definition at line 274 of file compressframe.c.

References _compressframe_findmethod(), _CompressFrame::baseclass, compressframe_new(), COMPRESSFRAMEMIN, _CompressFrame::decompressed_size, get_generic_tlv_type(), get_generic_tlv_value(), MAXUNCOMPRESSEDSIZE, tlv_get_guint24(), and tlv_get_guint8().

Here is the call graph for this function:

Variable Documentation

DEBUGDECLARATIONS

Definition at line 62 of file compressframe.c.