Moved CSN1 and RLC/MAC code to new GPRS directory.
commit
487a141b9d
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# Copyright 2008, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This software is distributed under the terms of the GNU Public License.
|
||||
# See the COPYING file in the main directory for details.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
include $(top_srcdir)/Makefile.common
|
||||
|
||||
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
|
||||
AM_CXXFLAGS = -Wall -ldl -pthread
|
||||
|
||||
noinst_LTLIBRARIES = libgprs.la
|
||||
|
||||
libgprs_la_SOURCES = \
|
||||
csn1.cpp \
|
||||
gsm_rlcmac.cpp
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
RLCMACTest
|
||||
|
||||
noinst_HEADERS = \
|
||||
csn1.h \
|
||||
gsm_rlcmac.h
|
||||
|
||||
RLCMACTest_SOURCES = RLCMACTest.cpp
|
||||
RLCMACTest_LDADD = $(COMMON_LA)
|
||||
#MOSTLYCLEANFILES += testSource testDestination
|
||||
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
/* RLCMACTest.cpp
|
||||
*
|
||||
* Copyright (C) 2011 Ivan Klyuchnikov
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include <BitVector.h>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include "csn1.h"
|
||||
#include "gsm_rlcmac.h"
|
||||
using namespace std;
|
||||
|
||||
void printSizeofRLCMAC()
|
||||
{
|
||||
cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl;
|
||||
cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl;
|
||||
cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl;
|
||||
cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl;
|
||||
cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl;
|
||||
cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl;
|
||||
cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl;
|
||||
cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl;
|
||||
cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl;
|
||||
cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl;
|
||||
cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl;
|
||||
cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl;
|
||||
cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl;
|
||||
cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl;
|
||||
cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl;
|
||||
|
||||
cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl;
|
||||
cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl;
|
||||
cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl;
|
||||
cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl;
|
||||
cout << "sizeof Packet_Measurement_Order_Reduced_t " << sizeof(Packet_Measurement_Order_Reduced_t) << endl;
|
||||
cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl;
|
||||
cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl;
|
||||
cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl;
|
||||
cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl;
|
||||
cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl;
|
||||
cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl;
|
||||
cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl;
|
||||
cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl;
|
||||
cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl;
|
||||
cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl;
|
||||
cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl;
|
||||
cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl;
|
||||
cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl;
|
||||
cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl;
|
||||
cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl;
|
||||
cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl;
|
||||
cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl;
|
||||
cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl;
|
||||
cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl;
|
||||
cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl;
|
||||
cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl;
|
||||
cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl;
|
||||
cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl;
|
||||
}
|
||||
|
||||
void testRlcMacDownlink()
|
||||
{
|
||||
BitVector resultVector(23*8);
|
||||
resultVector.unhex("2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
|
||||
|
||||
std::string testData[] = {
|
||||
"4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment
|
||||
"48282407a6a074227201000b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment
|
||||
"47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack
|
||||
"47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b" // Packet Uplink Assignment
|
||||
};
|
||||
|
||||
int testDataSize = sizeof(testData)/sizeof(testData[0]);
|
||||
BitVector vector[testDataSize];
|
||||
|
||||
unsigned char origin[23];
|
||||
unsigned char result[23];
|
||||
|
||||
cout << " DOWNLINK " << endl;
|
||||
for (int i = 0; i < testDataSize; i++)
|
||||
{
|
||||
vector[i].resize(23*8);
|
||||
vector[i].unhex(testData[i].c_str());
|
||||
RlcMacDownlink_t * data = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t));
|
||||
cout << "=========Start DECODE===========" << endl;
|
||||
decode_gsm_rlcmac_downlink(&vector[i], data);
|
||||
cout << "+++++++++Finish DECODE++++++++++" << endl;
|
||||
cout << "=========Start ENCODE=============" << endl;
|
||||
encode_gsm_rlcmac_downlink(&resultVector, data);
|
||||
cout << "+++++++++Finish ENCODE+++++++++++" << endl;
|
||||
cout << "vector1 = " << vector[i] << endl;
|
||||
cout << "vector2 = " << resultVector << endl;
|
||||
vector[i].pack(origin);
|
||||
resultVector.pack(result);
|
||||
if (memcmp(origin, result, 23) == 0)
|
||||
{
|
||||
cout << "vector1 == vector2 : TRUE" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "vector1 == vector2 : FALSE" << endl;
|
||||
}
|
||||
resultVector.unhex("2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testRlcMacUplink()
|
||||
{
|
||||
BitVector resultVector(23*8);
|
||||
resultVector.unhex("2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
|
||||
|
||||
std::string testData[] = {
|
||||
"400e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block
|
||||
"400b8020000000000000002480e00b2b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack
|
||||
"4016713dc094270ca2ae57ef909006aa0fc0001f80222b" // Packet Resource Request
|
||||
};
|
||||
|
||||
int testDataSize = sizeof(testData)/sizeof(testData[0]);
|
||||
BitVector vector[testDataSize];
|
||||
|
||||
unsigned char origin[23];
|
||||
unsigned char result[23];
|
||||
|
||||
cout << " UPLINK " << endl;
|
||||
for (int i = 0; i < testDataSize; i++)
|
||||
{
|
||||
vector[i].resize(23*8);
|
||||
vector[i].unhex(testData[i].c_str());
|
||||
RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t));
|
||||
cout << "=========Start DECODE===========" << endl;
|
||||
decode_gsm_rlcmac_uplink(&vector[i], data);
|
||||
cout << "+++++++++Finish DECODE++++++++++" << endl;
|
||||
cout << "=========Start ENCODE=============" << endl;
|
||||
encode_gsm_rlcmac_uplink(&resultVector, data);
|
||||
cout << "+++++++++Finish ENCODE+++++++++++" << endl;
|
||||
cout << "vector1 = " << vector[i] << endl;
|
||||
cout << "vector2 = " << resultVector << endl;
|
||||
vector[i].pack(origin);
|
||||
resultVector.pack(result);
|
||||
if (memcmp(origin, result, 23) == 0)
|
||||
{
|
||||
cout << "vector1 == vector2 : TRUE" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "vector1 == vector2 : FALSE" << endl;
|
||||
}
|
||||
resultVector.unhex("2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//printSizeofRLCMAC();
|
||||
testRlcMacDownlink();
|
||||
testRlcMacUplink();
|
||||
|
||||
}
|
|
@ -0,0 +1,574 @@
|
|||
/* csn1.h
|
||||
* Declarations and types for CSN1 dissection in wireshark.
|
||||
* By Vincent Helfre, based on original code by Jari Sassi
|
||||
* with the gracious authorization of STE
|
||||
* Copyright (c) 2011 ST-Ericsson
|
||||
*
|
||||
* $Id: packet-csn1.h 36306 2011-03-24 09:20:14Z etxrab $
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <BitVector.h>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#ifndef _PACKET_CSN1_H_
|
||||
#define _PACKET_CSN1_H_
|
||||
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
//#define max(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
/* Error codes */
|
||||
#define CSN_OK 0
|
||||
#define CSN_ERROR_GENERAL -1
|
||||
#define CSN_ERROR_DATA_NOT_VALID -2
|
||||
#define CSN_ERROR_IN_SCRIPT -3
|
||||
#define CSN_ERROR_INVALID_UNION_INDEX -4
|
||||
#define CSN_ERROR_NEED_MORE_BITS_TO_UNPACK -5
|
||||
#define CSN_ERROR_ILLEGAL_BIT_VALUE -6
|
||||
#define CSN_ERROR_INTERNAL -7
|
||||
#define CSN_ERROR_STREAM_NOT_SUPPORTED -8
|
||||
#define CSN_ERROR_MESSAGE_TOO_LONG -9
|
||||
#define CSN_ERROR_ -10
|
||||
|
||||
#define FALSE (0)
|
||||
typedef signed int gint32;
|
||||
typedef signed short gint16;
|
||||
typedef int gint;
|
||||
typedef gint gboolean;
|
||||
typedef unsigned char guint8;
|
||||
typedef unsigned short guint16;
|
||||
typedef unsigned int guint32;
|
||||
typedef unsigned long guint64;
|
||||
/* CallBack return status */
|
||||
typedef gint16 CSN_CallBackStatus_t;
|
||||
|
||||
#define CSNCBS_OK 0
|
||||
#define CSNCBS_NOT_OK -10
|
||||
#define CSNCBS_NOT_TO_US -11
|
||||
#define CSNCBS_NOT_COMPLETE -12
|
||||
|
||||
#define CSNCBS_REVISION_LIMIT_STOP -20 /* Stop packing/unpacking - revision limit */
|
||||
#define CSNCBS_NOT_SUPPORTED_IE -21 /* Handling of the unpacked IE is not supported by MS-software */
|
||||
|
||||
|
||||
|
||||
#ifndef ElementsOf
|
||||
#define ElementsOf(array) (sizeof(array) / sizeof(array[0]))
|
||||
#endif
|
||||
|
||||
/* Context holding CSN1 parameters */
|
||||
typedef struct
|
||||
{
|
||||
gint remaining_bits_len; /* IN to an csn stream operation */
|
||||
gint bit_offset; /* IN/OUT to an csn stream operation */
|
||||
gint direction; /* 0 - decode; 1 - encode */
|
||||
} csnStream_t;
|
||||
|
||||
typedef gint16 (*StreamSerializeFcn_t)(csnStream_t* ar, BitVector *vector, size_t& readIndex, void* data);
|
||||
typedef enum
|
||||
{
|
||||
CSN_END = 0,
|
||||
CSN_BIT,
|
||||
CSN_UINT,
|
||||
CSN_TYPE,
|
||||
CSN_CHOICE,
|
||||
CSN_UNION,
|
||||
CSN_UNION_LH,
|
||||
CSN_UINT_ARRAY,
|
||||
CSN_TYPE_ARRAY,
|
||||
CSN_BITMAP, /* Bitmap with constant: <bitmap: bit(64)> */
|
||||
CSN_VARIABLE_BITMAP, /* <N: bit (5)> <bitmap: bit(N + offset)> */
|
||||
CSN_VARIABLE_BITMAP_1, /* <bitmap: bit**> i.e. to the end of message (R99) */
|
||||
CSN_LEFT_ALIGNED_VAR_BMP, /* As variable bitmap but the result is left aligned (R99) */
|
||||
CSN_LEFT_ALIGNED_VAR_BMP_1,/* As above only size is to the end of message (R99) */
|
||||
CSN_VARIABLE_ARRAY, /* Array with length specified in parameter: <N: bit(4)> <list: octet(N + offset)> */
|
||||
CSN_VARIABLE_TARRAY, /* Type Array with length specified in parameter: <N: bit(x)> <Type>*N */
|
||||
CSN_VARIABLE_TARRAY_OFFSET,/* As above but with offset. The offset is stored as third parameter of CSN_DESCR (descr.value) */
|
||||
CSN_RECURSIVE_ARRAY, /* Recursive way to specify an array of uint: <list> ::= {1 <number: bit(4) <list>|0}; */
|
||||
CSN_RECURSIVE_TARRAY, /* Recursive way to specify an array of type: <list> ::= {1 <type>} ** 0 ; */
|
||||
CSN_RECURSIVE_TARRAY_1, /* same as above but first element always exist:<list> ::= <type> {1 <type>} ** 0 ; */
|
||||
CSN_RECURSIVE_TARRAY_2, /* same as above but with reversed separators :<lists> ::= <type> { 0 <type> } ** 1 ; */
|
||||
CSN_EXIST,
|
||||
CSN_EXIST_LH,
|
||||
CSN_NEXT_EXIST,
|
||||
CSN_NEXT_EXIST_LH,
|
||||
CSN_NULL,
|
||||
CSN_FIXED,
|
||||
CSN_CALLBACK,
|
||||
CSN_UINT_OFFSET, /* unpack will add offset, inverse pack will subtract offset */
|
||||
CSN_UINT_LH, /* Low High extraction of int */
|
||||
CSN_SERIALIZE,
|
||||
CSN_TRAP_ERROR
|
||||
} csn_type_t;
|
||||
|
||||
/******************************************************************************************
|
||||
* CSN_DESCR structure:
|
||||
*
|
||||
* type:
|
||||
* This is the CSN type. All existing types are specified in the section above.
|
||||
*
|
||||
* i:
|
||||
* Depending on the contents of the type parameter, the parameter "i" may have following meaning:
|
||||
* - specifies the number of bits for the CSN_UINT type
|
||||
* - the offset for an array size by which the size is incremented
|
||||
* for the CSN_VAR_ARRAY type
|
||||
* - the length of each element of an array for the CSN_REC_ARRAY type
|
||||
* - the number of the elements in an array for the CSN_TYPE_ARRAY type
|
||||
* - the offset to the variable keeping the number of elements of an array for in the CSN_VAR_TARRAY type
|
||||
* - the number of different data types in a union for the CSN_UNION, CSN_UNION_LH, and for the CSN_CHOICE types
|
||||
* - the length in bits of the fixed number defined for the CSN_FIXED type
|
||||
* - the number of lines to skip in the CSN_DESCR type specified for the CSN_NEXT_EXIST, CSN_NEXT_EXIST_LH,
|
||||
* CSN_NEXT_EXIST_OR_NULL, and CSN_NEXT_EXIST_OR_NULL_LH types
|
||||
* - the number of bits in a bitmap for the CSN_BITMAP type
|
||||
* - the value by which the number of bits in a bitmap has to be incremented or decremented for the
|
||||
* CSN_VAR_BITMAP, CSN_LEFT_VAR_BMP, and CSN_LEFT_BMP_1 types
|
||||
* - the offset to param1 for the CSN_CALLBACK type
|
||||
* - ERRORCODE used by the CSN_ERROR type
|
||||
*
|
||||
* descr
|
||||
* This parameter has different meaning depending on the value of the type parameter:
|
||||
* - the offset for the CSN_UINT_OFFSET type
|
||||
* - the number of the elements in an array of the CSN_UINT_ARRAY type
|
||||
* - the offset to the parameter where the size of the array has to be stored for the CSN_REC_ARRAY type
|
||||
* - the address of the internal structure, describing the member type (by means of the CSN_DESCR type) in the
|
||||
* CSN_TYPE_ARRAY, CSN_VAR_TARRAY, and CSN_TYPE types
|
||||
* - the address of the variable of type CSN_ChoiceElement_t describing all elements in the CSN_CHOICE type union
|
||||
* - the offset to the variable where the number of bits has to be or is stored for the CSN_VAR_BITMAP,
|
||||
* CSN_LEFT_VAR_BMP, and CSN_LEFT_BMP_1 types
|
||||
* - the function number (case number) for the CSN_CALLBACK and CSN_CALLBACK_NO_ARGS types
|
||||
* - the free text used by the CSN_TRAP_ERROR
|
||||
*
|
||||
* offset
|
||||
* This is an offset to the _MEMBER parameter counting from the beginning of struct
|
||||
* where the unpacked or packed value shall be stored or fetched. The meaning of the _MEMBER parameter
|
||||
* varies depending on the type which is specified and so is the meaning of the offset parameter.
|
||||
* Some types (and corresponding macros) do not have the _MEMBER parameter and then the offset parameter
|
||||
* is not used or is different from the offset to the _MEMBER.
|
||||
* - the fixed value for the CSN_FIXED type
|
||||
* - an offset to the variable UnionType for CSN_UNION and CSN_UNION_LH types
|
||||
* - an offset to the variable Exist for CSN_NEXT_EXIST and CSN_NEXT_EXIST_LH types
|
||||
* - an offset to param2 in the CSN_CALLBACK type
|
||||
*
|
||||
* sz
|
||||
* - is the name of the parameter within the descr where their unpacked or packed value shall be stored or fetched.
|
||||
* This paramater is pointed out by the offset parameter in the same CSN_DESCR variable as the sz.
|
||||
* - the free text used by the CSN_TRAP_ERROR (the same as parameter "i")
|
||||
*
|
||||
* serialize
|
||||
* - stores the size of _MEMBER type in case of the M_TYPE_ARRAY and M_VAR_TARRAY,
|
||||
* - the address of the function which is provided by the M_SERIALIZE type.
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint16 type;
|
||||
gint16 i;
|
||||
union
|
||||
{
|
||||
void* ptr;
|
||||
guint32 value;
|
||||
} descr;
|
||||
size_t offset;
|
||||
const char* sz;
|
||||
union
|
||||
{
|
||||
StreamSerializeFcn_t fcn;
|
||||
guint32 value;
|
||||
int* hf_ptr;
|
||||
} serialize;
|
||||
} CSN_DESCR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint8 bits;
|
||||
guint8 value;
|
||||
CSN_DESCR descr;
|
||||
} CSN_ChoiceElement_t;
|
||||
|
||||
void csnStreamInit(csnStream_t* ar,gint BitOffset,gint BitCount);
|
||||
|
||||
/******************************************************************************
|
||||
* FUNCTION: csnStreamDecoder
|
||||
* DESCRIPTION:
|
||||
* UnPacks data from bit stream. According to CSN description.
|
||||
* ARGS:
|
||||
* ar stream will hold the parameters to the pack function
|
||||
* ar->remaining_bits_len [IN] Number of bits to unpack [OUT] number of bits left to unpack.
|
||||
* ar->bit_offset [IN/OUT] is the current bit where to proceed with the next bit to unpack.
|
||||
|
||||
* pDescr CSN description.
|
||||
* tvb buffer containing the bit stream to unpack.
|
||||
* data unpacked data.
|
||||
* ett_csn1 tree
|
||||
*
|
||||
* RETURNS: int Number of bits left to be unpacked. Negative Error code if failed to unpack all bits
|
||||
******************************************************************************/
|
||||
|
||||
gint16 csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, BitVector *vector, size_t& readIndex, void* data);
|
||||
|
||||
gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, BitVector *vector, size_t& readIndex, void* data);
|
||||
|
||||
/* CSN struct macro's */
|
||||
#define CSN_DESCR_BEGIN(_STRUCT)\
|
||||
CSN_DESCR CSNDESCR_##_STRUCT[] = {
|
||||
|
||||
#define CSN_DESCR_END(_STRUCT)\
|
||||
{CSN_END, 0, {0}, 0, "", {(StreamSerializeFcn_t)0}} };
|
||||
|
||||
/******************************************************************************
|
||||
* CSN_ERROR(Par1, Par2, Par3)
|
||||
* May be called at any time when an abort of packing or unpacking of a message
|
||||
* is desired
|
||||
* Par1: C structure name
|
||||
* Par2: free text which will appear in the error handler
|
||||
* Par3: Error code
|
||||
*****************************************************************************/
|
||||
#define CSN_ERROR(_STRUCT, _Text, _ERRCODE)\
|
||||
{CSN_TRAP_ERROR, _ERRCODE, {(void*)_Text}, 0, _Text, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_BIT(Par1, Par2)
|
||||
* Defines one bit element in the CSN1 syntax.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
*****************************************************************************/
|
||||
#define M_BIT(_STRUCT, _MEMBER)\
|
||||
{CSN_BIT, 0, {0}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_NEXT_EXIST(Par1, Par2, Par3)
|
||||
* Indicates whether the next element or a group of elements defined in the
|
||||
* structure is present or not.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: number of lines to skip in the CSN_DESCR type specified if the
|
||||
* element(s) does not exist
|
||||
*****************************************************************************/
|
||||
#define M_NEXT_EXIST(_STRUCT, _MEMBER, _NoOfExisting)\
|
||||
{CSN_NEXT_EXIST, _NoOfExisting, {0}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_NEXT_EXIST_LH(Par1, Par2, Par3)
|
||||
* similar to the M_NEXT_EXIST except that instead of bit 0/1 which is fetched
|
||||
* from the message in order to find out whether the next element/elements are
|
||||
* present in the message, the logical operation XOR with the background
|
||||
* pattern 0x2B is performed on the read bit before the decision is made.
|
||||
*****************************************************************************/
|
||||
#define M_NEXT_EXIST_LH(_STRUCT, _MEMBER, _NoOfExisting)\
|
||||
{CSN_NEXT_EXIST_LH, _NoOfExisting, {0}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_NEXT_EXIST_OR_NULL(Par1, Par2, Par3)
|
||||
* Similar to the M_NEXT_EXIST except that not only bit 0 or 1 but also the end
|
||||
* of the message may be encountered when looking for the next element in the
|
||||
* message.
|
||||
* Covers the case {null | 0 | 1 < IE >}
|
||||
*****************************************************************************/
|
||||
#define M_NEXT_EXIST_OR_NULL(_STRUCT, _MEMBER, _NoOfExisting)\
|
||||
{CSN_NEXT_EXIST, _NoOfExisting, {(void*)1}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_NEXT_EXIST_OR_NULL_LH(Par1, Par2, Par3)
|
||||
* Similar to the M_NEXT_EXIST_LH except that not only bit 0 or 1 but also the
|
||||
* end of the message may be encountered when looking for the next element in
|
||||
* the message.
|
||||
* Covers the case {null | L | H < IE >}
|
||||
*****************************************************************************/
|
||||
#define M_NEXT_EXIST_OR_NULL_LH(_STRUCT, _MEMBER, _NoOfExisting)\
|
||||
{CSN_NEXT_EXIST_LH, _NoOfExisting, {(void*)1}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_UINT(Par1, Par2, Par3)
|
||||
* Defines an integer number.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: number of bits used to code the element (between 1 and 32)
|
||||
*****************************************************************************/
|
||||
#define M_UINT(_STRUCT, _MEMBER, _BITS)\
|
||||
{CSN_UINT, _BITS, {(void*)1}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_UINT(Par1, Par2, Par3)
|
||||
* This macro has the same functionality as M_UINT except that in addition the
|
||||
* logical "exclusive or" operation with the background value "0x2B" is
|
||||
* performed before the final value of the integer number is delivered from the
|
||||
* received CSN.1 message
|
||||
*****************************************************************************/
|
||||
#define M_UINT_LH(_STRUCT, _MEMBER, _BITS)\
|
||||
{CSN_UINT_LH, _BITS, {(void*)1}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_UINT_OFFSET(Par1, Par2, Par3, Par4)
|
||||
* Defines an integer number.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: number of bits used to code the element (between 1 and 32)
|
||||
* Par4: value added to the returned integer (offset)
|
||||
*****************************************************************************/
|
||||
#define M_UINT_OFFSET(_STRUCT, _MEMBER, _BITS, _OFFSET)\
|
||||
{CSN_UINT_OFFSET, _BITS, {(void*)_OFFSET}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_UINT_ARRAY(Par1, Par2, Par3, Par4)
|
||||
* Defines an array of integer numbers. The size of the array is fixed.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: number of bits used to code the each integer element (between 1 and 32)
|
||||
* Par4: number of elements in the array (fixed integer value)
|
||||
*****************************************************************************/
|
||||
#define M_UINT_ARRAY(_STRUCT, _MEMBER, _BITS, _ElementCount)\
|
||||
{CSN_UINT_ARRAY, _BITS, {(void*)_ElementCount}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_VAR_UINT_ARRAY(Par1, Par2, Par3, Par4)
|
||||
* Defines an array of integer numbers. The size of the array is variable.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: number of bits used to code the each integer element (between 1 and 32)
|
||||
* Par4: number of elements in the array supplied by reference to the
|
||||
* structure member holding the length value
|
||||
*****************************************************************************/
|
||||
#define M_VAR_UINT_ARRAY(_STRUCT, _MEMBER, _BITS, _ElementCountField)\
|
||||
{CSN_UINT_ARRAY, _BITS, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)1}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_VAR_ARRAY(Par1, Par2, Par3, Par4)
|
||||
* Defines an array of 8 bit large integer numbers. The size of the array is variable.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: name of the structure member holding the size of the array
|
||||
* Par4: offset that is added to the Par3 to get the actual size of the array
|
||||
*****************************************************************************/
|
||||
#define M_VAR_ARRAY(_STRUCT, _MEMBER, _ElementCountField, _OFFSET)\
|
||||
{CSN_VARIABLE_ARRAY, _OFFSET, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_VAR_TARRAY(Par1, Par2, Par3, Par4)
|
||||
* Similar to M_TYPE_ARRAY except that the size of the array is variable.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: the type of each element of the array
|
||||
* Par4: name of the structure member holding the size of the array
|
||||
*****************************************************************************/
|
||||
#define M_VAR_TARRAY(_STRUCT, _MEMBER, _MEMBER_TYPE, _ElementCountField)\
|
||||
{CSN_VARIABLE_TARRAY, offsetof(_STRUCT, _ElementCountField), {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)sizeof(_MEMBER_TYPE)}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_VAR_TARRAY_OFFSET(Par1, Par2, Par3, Par4)
|
||||
* Same as M_VAR_TARRAY with offset
|
||||
*****************************************************************************/
|
||||
#define M_VAR_TARRAY_OFFSET(_STRUCT, _MEMBER, _MEMBER_TYPE, _ElementCountField)\
|
||||
{CSN_VARIABLE_TARRAY_OFFSET, offsetof(_STRUCT, _ElementCountField), {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)sizeof(_MEMBER_TYPE)}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_REC_ARRAY(Par1, Par2, Par3, Par4)
|
||||
* similar to the M_VAR_ARRAY. The difference is that the size of the array is
|
||||
* not known in advance and it has to be calculated during unpacking. Its value
|
||||
* is stored in a variable which belongs to the same structure as the array.
|
||||
* A zero element terminates the array. The CSN.1 syntax describes it
|
||||
* recursively as:
|
||||
* <array> ::={1 <element> <array>| 0}
|
||||
*
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: name of the structure member where the calculated the size of the
|
||||
* array will be stored
|
||||
* Par4: length of each element in bits
|
||||
*****************************************************************************/
|
||||
#define M_REC_ARRAY(_STRUCT, _MEMBER, _ElementCountField, _BITS)\
|
||||
{CSN_RECURSIVE_ARRAY, _BITS, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_VAR_TYPE_ARRAY(Par1, Par2, Par3, Par4)
|
||||
* Defines an array of structures. The size of the array is variable.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: name of the structure
|
||||
* Par4: number of elements in the array (fixed integer value)
|
||||
*****************************************************************************/
|
||||
#define M_TYPE_ARRAY(_STRUCT, _MEMBER, _MEMBER_TYPE, _ElementCount)\
|
||||
{CSN_TYPE_ARRAY, _ElementCount, {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)sizeof(_MEMBER_TYPE)}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_REC_TARRAY(Par1, Par2, Par3, Par4)
|
||||
* Defines an recursive array of structures. The size of the array is variable.
|
||||
* <list> ::= {1 <type>} ** 0 ;
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: name of the structure
|
||||
* Par4: will hold the number of element in the array after unpacking
|
||||
*****************************************************************************/
|
||||
#define M_REC_TARRAY(_STRUCT, _MEMBER, _MEMBER_TYPE, _ElementCountField)\
|
||||
{CSN_RECURSIVE_TARRAY, offsetof(_STRUCT, _ElementCountField), {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)sizeof(_MEMBER_TYPE)}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_REC_TARRAY1(Par1, Par2, Par3, Par4)
|
||||
* Same as M_REC_TARRAY but first element always exist:
|
||||
* <list> ::= <type> {1 <type>} ** 0 ;
|
||||
*****************************************************************************/
|
||||
#define M_REC_TARRAY_1(_STRUCT, _MEMBER, _MEMBER_TYPE, _ElementCountField)\
|
||||
{CSN_RECURSIVE_TARRAY_1, offsetof(_STRUCT, _ElementCountField), {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)sizeof(_MEMBER_TYPE)}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_REC_TARRAY2(Par1, Par2, Par3, Par4)
|
||||
* Same as M_REC_TARRAY but with reversed separators :
|
||||
* <lists> ::= <type> { 0 <type> } ** 1 ;
|
||||
*****************************************************************************/
|
||||
#define M_REC_TARRAY_2(_STRUCT, _MEMBER, _MEMBER_TYPE, _ElementCountField)\
|
||||
{CSN_RECURSIVE_TARRAY_2, offsetof(_STRUCT, _ElementCountField), {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)sizeof(_MEMBER_TYPE)}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_TYPE(Par1, Par2, Par3)
|
||||
* Defines a reference to a structure which is described elsewhere
|
||||
* <list> ::= {1 <type>} ** 0 ;
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: type of member
|
||||
*****************************************************************************/
|
||||
#define M_TYPE(_STRUCT, _MEMBER, _MEMBER_TYPE)\
|
||||
{CSN_TYPE, 0, {(void*)CSNDESCR_##_MEMBER_TYPE}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_UNION(Par1, Par2)
|
||||
* Informs the CSN.1 library that a union follows and how many possible choices
|
||||
* there are in the union. The actual value of the choice, which points out the
|
||||
* chosen element of the union is stored in the uint8 variable and is usually
|
||||
* called UnionType. The elements of the union have to be listed directly after
|
||||
* the M_UNION statement.
|
||||
* Par1: C structure name
|
||||
* Par2: number of possible choice in the union
|
||||
*****************************************************************************/
|
||||
#define M_UNION(_STRUCT, _COUNT)\
|
||||
{CSN_UNION, _COUNT, {0}, offsetof(_STRUCT, UnionType), "UnionType", {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_UNION_LH(Par1, Par2)
|
||||
* Same as M_UNION but masked with background value 0x2B
|
||||
*****************************************************************************/
|
||||
#define M_UNION_LH(_STRUCT, _COUNT)\
|
||||
{CSN_UNION_LH, _COUNT, {0}, offsetof(_STRUCT, UnionType), "UnionType", {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_CHOICE(Par1, Par2, Par3, Par4)
|
||||
* Similar to the M_UNION. In the M_UNION the selected element of all possible
|
||||
* choices in the union is referred as a sequential numbers, i.e., the first
|
||||
* choice is addressed as choice 0 the second as choice 1, the third as choice
|
||||
* 2 and so on, both in the encoded message and in the variable UnionType which
|
||||
* is the part of the message. In the CSN_CHOICE case, this rule does not
|
||||
* apply. There is free but predefined mapping of the element of the union and
|
||||
* the value which addresses this element.
|
||||
* The value of the address is called a selector.
|
||||
* After unpacking, this value is then converted to the sequential number of the
|
||||
* element in the union and stored in the UnionType variable.
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: address of an array of type CSN_ChoiceElement_t where all possible
|
||||
* values of the selector are provided, together with the selector
|
||||
* length expressed in bits and the address of the CSN_DESCR type
|
||||
* where the element is defined. For every element in the union
|
||||
* there is one line in the Choice variable. These lines have to
|
||||
* appear in the _CHOICE in the same order as the elements in the
|
||||
* union. The element of the union selected in the message through
|
||||
* the _CHOICE parameter is after unpacking translated to the
|
||||
* corresponding sequential number of this element and stored in
|
||||
* the variable pointed out by the _MEMBER
|
||||
* Par4: number of possible choices in the union
|
||||
*****************************************************************************/
|
||||
#define M_CHOICE(_STRUCT, _MEMBER, _CHOICE, _ElementCount)\
|
||||
{CSN_CHOICE, _ElementCount, {(void*)_CHOICE}, offsetof(_STRUCT, _MEMBER), #_CHOICE, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_FIXED(Par1, Par2, Par3)
|
||||
* Defines a fixed value of type integer which should be fetched from or stored
|
||||
* in the message
|
||||
* Par1: C structure name
|
||||
* Par2: gives the length of the fixed number in bits.
|
||||
* Par3: the value of the number. If the expected value is not present in
|
||||
* the message the unpacking procedure is aborted
|
||||
*****************************************************************************/
|
||||
#define M_FIXED(_STRUCT, _BITS, _BITVALUE)\
|
||||
{CSN_FIXED, _BITS, {0}, _BITVALUE, #_BITVALUE, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_SERIALIZE(Par1, Par2, Par3)
|
||||
* Allows using a complete free format of data being encoded or decoded.
|
||||
* When the M_SERIALIZE is uncounted during encoding or decoding of a message
|
||||
* the CSNstream program passes the control over to the specified function
|
||||
* together with all necessary parameters about the current position within
|
||||
* the message being unpacked or packed. When transferring of "serialized"
|
||||
* data to or from the message is finished by the function the CSNstream gets
|
||||
* back control over the data stream and continues to work with the message.
|
||||
*****************************************************************************/
|
||||
#define M_SERIALIZE(_STRUCT, _MEMBER, _SERIALIZEFCN)\
|
||||
{CSN_SERIALIZE, 1, {0}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {_SERIALIZEFCN}}
|
||||
|
||||
#define M_CALLBACK(_STRUCT, _CSNCALLBACKFCN, _PARAM1, _PARAM2)\
|
||||
{CSN_CALLBACK, offsetof(_STRUCT, _PARAM1), {_CSNCALLBACKFCN}, offsetof(_STRUCT, _PARAM2), "CallBack_"#_CSNCALLBACKFCN, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/******************************************************************************
|
||||
* M_BITMAP(Par1, Par2, Par3)
|
||||
* Defines a type which consists of a bitmap. The size of the bitmap in bits
|
||||
* is fixed and provided by the parameter Par3
|
||||
* Par1: C structure name
|
||||
* Par2: C structure element name
|
||||
* Par3: length of the bitmap expressed in bits
|
||||
*****************************************************************************/
|
||||
#define M_BITMAP(_STRUCT, _MEMBER, _BITS)\
|
||||
{CSN_BITMAP, _BITS, {0}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/* variable length, right aligned bitmap i.e. _ElementCountField = 11 => 00000111 11111111 */
|
||||
#define M_VAR_BITMAP(_STRUCT, _MEMBER, _ElementCountField, _OFFSET)\
|
||||
{CSN_VARIABLE_BITMAP, _OFFSET, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/* variable length, right aligned bitmap filling the rest of message
|
||||
* - when unpacking the _ElementCountField will be set in runtime
|
||||
* - when packing _ElementCountField contains the size of bitmap
|
||||
*/
|
||||
#define M_VAR_BITMAP_1(_STRUCT, _MEMBER, _ElementCountField, _OFFSET)\
|
||||
{CSN_VARIABLE_BITMAP_1, _OFFSET, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/* variable length, left aligned bitmap i.e. _ElementCountField = 11 => 11111111 11100000 */
|
||||
#define M_LEFT_VAR_BMP(_STRUCT, _MEMBER, _ElementCountField, _OFFSET)\
|
||||
{CSN_LEFT_ALIGNED_VAR_BMP, _OFFSET, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/* variable length, left aligned bitmap filling the rest of message
|
||||
*- when unpacking the _ElementCountField will be set in runtime
|
||||
* - when packing _ElementCountField contains the size of bitmap
|
||||
*/
|
||||
#define M_LEFT_VAR_BMP_1(_STRUCT, _MEMBER, _ElementCountField, _OFFSET)\
|
||||
{CSN_LEFT_ALIGNED_VAR_BMP_1, _OFFSET, {(void*)offsetof(_STRUCT, _ElementCountField)}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
#define M_NULL(_STRUCT, _MEMBER)\
|
||||
{CSN_NULL, 0, {0}, offsetof(_STRUCT, _MEMBER), #_MEMBER, {(StreamSerializeFcn_t)0}}
|
||||
|
||||
#define M_THIS_EXIST(_STRUCT)\
|
||||
{CSN_EXIST, 0, {0}, offsetof(_STRUCT, Exist), "Exist", {(StreamSerializeFcn_t)0}}
|
||||
|
||||
#define M_THIS_EXIST_LH(_STRUCT)\
|
||||
{CSN_EXIST_LH, 0, {0}, offsetof(_STRUCT, Exist), "Exist", {(StreamSerializeFcn_t)0}}
|
||||
|
||||
/* return value 0 if ok else discontionue the unpacking */
|
||||
typedef gint16 (*CsnCallBackFcn_t)(void* pv ,...);
|
||||
|
||||
#define CSNDESCR(_FuncType) CSNDESCR_##_FuncType
|
||||
|
||||
#endif /*_PACKET_CSN1_H_*/
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue