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 <compressframe.h>
#include <frameset.h>
#include <generic_tlv_min.h>
#include <tlvhelper.h>
Include dependency graph for compressframe.c:

Go to the source code of this file.

Data Structures

struct  compression_types
 Set of all know 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 COMPFRAMESIZE   4
 
#define COMPRESSFRAMEMIN   4
 

Functions

FSTATIC void _compressframe_finalize (AssimObj *self)
 
FSTATIC gsize _compressframe_dataspace (const Frame *f)
 
FSTATIC void _compressframe_setvalue (Frame *, gpointer, guint16, 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)
 
CompressFramecompressframe_new (guint16 frame_type, guint16 compression_method)
 
FSTATIC Framecompressframe_tlvconstructor (gconstpointer 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 167 of file compressframe.c.

Referenced by _compressframe_updatedata().

#define COMPRESSFRAMEMIN   4

Definition at line 211 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_isvalid(), and compressframe_tlvconstructor().

Function Documentation

FSTATIC gsize _compressframe_dataspace ( const Frame f)

Definition at line 152 of file compressframe.c.

References _Frame::length.

Referenced by compressframe_new().

Here is the caller graph for this function:

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 81 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 125 of file compressframe.c.

References _compressframe_findmethod(), CASTTOCONSTCLASS, DIMOF, get_generic_tlv_len(), get_generic_tlv_value(), MAXUNCOMPRESSEDSIZE, 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,
guint16  len,
GDestroyNotify  valnotify 
)

Definition at line 158 of file compressframe.c.

References __FUNCTION__.

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 175 of file compressframe.c.

References __FUNCTION__, CASTTOCLASS, COMPFRAMESIZE, get_generic_tlv_nonconst_value(), MAXUDPSIZE, _FrameSet::packet, 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:

CompressFrame* compressframe_new ( guint16  frame_type,
guint16  compression_method 
)
FSTATIC Frame* compressframe_tlvconstructor ( gconstpointer  tlvstart,
gconstpointer  pktend,
gpointer *  newpacket,
gpointer *  newpacketend 
)
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 213 of file compressframe.c.

References _compressframe_findmethod(), 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 53 of file compressframe.c.