{
guint8 ui8 = tvb_get_bits8(tvb, bit_offset, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
- *pui8 = ui8 + (guint8)(guint32)pDescr->descr;
+ *pui8 = ui8 + (guint8)pDescr->descr.value;
item = proto_tree_add_text(tree, tvb, bit_offset>>3, (no_of_bits>>3)+1, "%s %s",
decode_bits_in_field(bit_offset, no_of_bits, ui8),
{
guint16 ui16 = tvb_get_bits16(tvb, bit_offset, no_of_bits, FALSE);
pui16 = pui16DATA(data, pDescr->offset);
- *pui16 = ui16 + (guint16)(guint32)pDescr->descr;
+ *pui16 = ui16 + (guint16)pDescr->descr.value;
item = proto_tree_add_text(tree, tvb, bit_offset>>3, (no_of_bits>>3)+1, "%s %s",
decode_bits_in_field(bit_offset, no_of_bits, ui16),
{
guint32 ui32 = tvb_get_bits32(tvb, bit_offset, no_of_bits, FALSE);
pui32 = pui32DATA(data, pDescr->offset);
- *pui32 = ui32 + (guint16)(guint32)pDescr->descr;
+ *pui32 = ui32 + (guint16)pDescr->descr.value;
item = proto_tree_add_text(tree, tvb, bit_offset>>3, (no_of_bits>>3)+1, "%s %s",
decode_bits_in_field(bit_offset, no_of_bits, ui32),
case CSN_UINT_ARRAY:
{
guint8 no_of_bits = (guint8) pDescr->i;
- guint16 nCount = (guint16)(guint32)pDescr->descr; /* nCount supplied by value i.e. M_UINT_ARRAY(...) */
+ guint16 nCount = (guint16)pDescr->descr.value; /* nCount supplied by value i.e. M_UINT_ARRAY(...) */
int i =0;
if (pDescr->serialize != 0)
test_tree = proto_item_add_subtree(ti, ett_csn1);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDissector(test_tree, &arT, pDescr->descr, tvb, pui8, ett_csn1);
+ Status = csnStreamDissector(test_tree, &arT, pDescr->descr.ptr, tvb, pui8, ett_csn1);
if (Status >= 0)
{
pui8 += nSize;
test_tree = proto_item_add_subtree(ti, ett_csn1);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDissector(test_tree, &arT, pDescr->descr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
+ Status = csnStreamDissector(test_tree, &arT, pDescr->descr.ptr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
if (Status >= 0)
{
{
gint16 count = pDescr->i;
guint8 i = 0;
- CSN_ChoiceElement_t* pChoice = pDescr->descr;
+ CSN_ChoiceElement_t* pChoice = (CSN_ChoiceElement_t*) pDescr->descr.ptr;
while (count > 0)
{
{
guint8 ui8 = tvb_get_bits8(tvb, bit_offset, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
- *pui8 = ui8 + (guint8)(guint32)pDescr->descr;
+ *pui8 = ui8 + (guint8)pDescr->descr.value;
item = proto_tree_add_text(tree, tvb, bit_offset>>3, (no_of_bits>>3)+1, "%s %s",
decode_bits_in_field(bit_offset, no_of_bits, ui8),
pDescr->sz);
{
guint16 ui16 = tvb_get_bits16(tvb, bit_offset, no_of_bits, FALSE);
pui16 = pui16DATA(data, pDescr->offset);
- *pui16 = ui16 + (guint16)(guint32)pDescr->descr;
+ *pui16 = ui16 + (guint16)pDescr->descr.value;
item = proto_tree_add_text(tree, tvb, bit_offset>>3, (no_of_bits>>3)+1, "%s %s",
decode_bits_in_field(bit_offset, no_of_bits, ui16),
pDescr->sz);
{
guint32 ui32 = tvb_get_bits32(tvb, bit_offset, no_of_bits, FALSE);
pui32 = pui32DATA(data, pDescr->offset);
- *pui32 = ui32 + (guint16)(guint32)pDescr->descr;
+ *pui32 = ui32 + (guint16)pDescr->descr.value;
item = proto_tree_add_text(tree, tvb, bit_offset>>3, (no_of_bits>>3)+1, "%s %s",
decode_bits_in_field(bit_offset, no_of_bits, ui32),
pDescr->sz);
case CSN_UINT_ARRAY:
{
guint8 no_of_bits = (guint8) pDescr->i;
- guint16 nCount = (guint16)(guint32)pDescr->descr; /* nCount supplied by value i.e. M_UINT_ARRAY(...) */
+ guint16 nCount = (guint16)pDescr->descr.value; /* nCount supplied by value i.e. M_UINT_ARRAY(...) */
gint i = 0;
if (pDescr->serialize != 0)
test_tree = proto_item_add_subtree(ti, ett_csn1);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDissector(test_tree, &arT, pDescr->descr, tvb, pui8, ett_csn1);
+ Status = csnStreamDissector(test_tree, &arT, pDescr->descr.ptr, tvb, pui8, ett_csn1);
if (Status >= 0)
{
pui8 += nSize;
test_tree = proto_item_add_subtree(ti, ett_csn1);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDissector(test_tree, &arT, pDescr->descr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
+ Status = csnStreamDissector(test_tree, &arT, pDescr->descr.ptr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
if (Status >= 0)
{
proto_item_set_len(ti,((arT.bit_offset - bit_offset)>>3)+1);
pui8 = pui8DATA(data, pDescr->offset);
/* this if-statement represents the M_NEXT_EXIST_OR_NULL description element */
- if ((pDescr->descr != 0) && (remaining_bits_len == 0))
+ if ((pDescr->descr.ptr != NULL) && (remaining_bits_len == 0))
{ /* no more bits to decode is fine here - end of message detected and allowed */
/* Skip i entries + this entry */
pui8 = pui8DATA(data, pDescr->offset);
/* this if-statement represents the M_NEXT_EXIST_OR_NULL_LH description element */
- if ((pDescr->descr != 0) && (remaining_bits_len == 0))
+ if ((pDescr->descr.ptr != NULL) && (remaining_bits_len == 0))
{ /* no more bits to decode is fine here - end of message detected and allowed */
/* skip 'i' entries + this entry */
{ /* substract one more bit from remaining_bits_len to make the "not enough bits" error to be triggered */
remaining_bits_len--;
}
-
+
/* set the data member to "not exist" */
*pui8 = 0;
break;
case CSN_VARIABLE_BITMAP_1:
{ /* Bitmap from here and to the end of message */
- *pui8DATA(data, (gint16)(gint32)pDescr->descr) = (guint8) remaining_bits_len; /* length of bitmap == remaining bits */
+ *pui8DATA(data, (gint16)pDescr->descr.value) = (guint8) remaining_bits_len; /* length of bitmap == remaining bits */
/*no break -
* with a length set we have a regular variable length bitmap so we continue */
* Bit array with length (in bits) specified in parameter (pDescr->descr)
* The result is right aligned!
*/
- gint16 no_of_bits = *pui8DATA(data, (gint16)(gint32)pDescr->descr);
+ gint16 no_of_bits = *pui8DATA(data, (gint16)pDescr->descr.value);
no_of_bits += pDescr->i; /* adjusted by offset */
case CSN_LEFT_ALIGNED_VAR_BMP_1:
{ /* Bitmap from here and to the end of message */
- *pui8DATA(data, (gint16)(gint32)pDescr->descr) = (guint8) remaining_bits_len; /* length of bitmap == remaining bits */
+ *pui8DATA(data, (gint16)pDescr->descr.value) = (guint8) remaining_bits_len; /* length of bitmap == remaining bits */
/* no break -
* with a length set we have a regular left aligned variable length bitmap so we continue
* <N: bit (5)> <bitmap: bit(N + offset)>
* bit array with length (in bits) specified in parameter (pDescr->descr)
*/
- gint16 no_of_bits = *pui8DATA(data, (gint16)(gint32)pDescr->descr);/* Size of bitmap */
+ gint16 no_of_bits = *pui8DATA(data, (gint16)pDescr->descr.value);/* Size of bitmap */
no_of_bits += pDescr->i;/* size adjusted by offset */
* <count: bit (x)>
* <list: octet(count + offset)>
*/
- gint16 count = *pui8DATA(data, (gint16)(gint32)pDescr->descr);
+ gint16 count = *pui8DATA(data, (gint16)pDescr->descr.value);
count += pDescr->i; /* Adjusted by offset */
bit_offset++;
/* Store the counted number of elements of the array */
- *pui8DATA(data, (gint16)(gint32)pDescr->descr) = ElementCount;
+ *pui8DATA(data, (gint16)pDescr->descr.value) = ElementCount;
pDescr++;
break;
test_tree = proto_item_add_subtree(ti, ett_csn1);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDissector(test_tree, &arT, pDescr->descr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
+ Status = csnStreamDissector(test_tree, &arT, pDescr->descr.ptr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
if (Status >= 0)
{ /* successful completion */
test_tree = proto_item_add_subtree(ti, ett_csn1);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDissector(test_tree, &arT, pDescr->descr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
+ Status = csnStreamDissector(test_tree, &arT, pDescr->descr.ptr, tvb, pvDATA(data, pDescr->offset), ett_csn1);
if (Status >= 0)
{ /* successful completion */
typedef gint16 (*StreamSerializeFcn_t)(proto_tree *tree, csnStream_t* ar, tvbuff_t *tvb, void* data, int ett_csn1);
-typedef struct
-{
- gint16 type;
- gint16 i;
- void* descr;
- size_t offset;
- const char* sz;
- StreamSerializeFcn_t 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: csnStreamDissector
-* 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 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, tvbuff_t *tvb, void* data, int ett_csn1);
-
enum
{
CSN_END = 0,
CSN_TRAP_ERROR
};
+/******************************************************************************************
+ * 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;
+ StreamSerializeFcn_t 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: csnStreamDissector
+* 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 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, tvbuff_t *tvb, void* data, int ett_csn1);
+
/* CSN struct macro's */
#define CSN_DESCR_BEGIN(_STRUCT)\
CSN_DESCR CSNDESCR_##_STRUCT[] = {
const
CSN_DESCR_BEGIN(PCID_Pattern_t)
M_UINT (PCID_Pattern_t, PCID_Pattern_length, 3),
- M_VAR_BITMAP (PCID_Pattern_t, PCID_Pattern, PCID_Pattern_length, 1), /* offset 1, 44.060 12.57 */
+ M_VAR_BITMAP (PCID_Pattern_t, PCID_Pattern, PCID_Pattern_length, 1), // offset 1, 44.060 12.57
M_UINT (PCID_Pattern_t, PCID_Pattern_sense, 1),
CSN_DESCR_END (PCID_Pattern_t)
proto_item *ti;
proto_tree *rlcmac_tree = NULL;
guint8 payload_type = tvb_get_bits8(tvb, 0, 2);
- RlcMacUplink_t * data = (RlcMacUplink_t *)ep_alloc(sizeof(RlcMacUplink_t));
+ RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t));
if (payload_type == PAYLOAD_TYPE_DATA)
{
ti = proto_tree_add_text(tree, tvb, 0, 1, "%s (Uplink)", MT_UL_TextGet(data->u.MESSAGE_TYPE_v));
rlcmac_tree = proto_item_add_subtree(ti, ett_gsm_rlcmac);
- col_add_str(pinfo->cinfo, COL_INFO, MT_UL_TextGet(data->u.MESSAGE_TYPE_v));
+ if (check_col(pinfo->cinfo, COL_INFO))
+ {
+ col_add_str(pinfo->cinfo, COL_INFO, MT_UL_TextGet(data->u.MESSAGE_TYPE_v));
+ }
switch (data->u.MESSAGE_TYPE_v)
{
ret = -1;
break;
}
+ free(data);
}
static void
csnStream_t ar;
proto_item *ti;
proto_tree *rlcmac_tree = NULL;
- RlcMacDownlink_t * data =(RlcMacDownlink_t *) ep_alloc(sizeof(RlcMacDownlink_t));
+ RlcMacDownlink_t * data =(RlcMacDownlink_t *) malloc(sizeof(RlcMacDownlink_t));
MSGGPRS_Status_t ret;
/* See RLC/MAC downlink control block structure in TS 44.060 / 10.3.1 */
ti = proto_tree_add_text(tree, tvb, 0, 1, "%s (downlink)", MT_DL_TextGet(data->u.MESSAGE_TYPE_v));
rlcmac_tree = proto_item_add_subtree(ti, ett_gsm_rlcmac);
- col_add_str(pinfo->cinfo, COL_INFO, MT_DL_TextGet(data->u.MESSAGE_TYPE_v));
+ if (check_col(pinfo->cinfo, COL_INFO))
+ {
+ col_add_str(pinfo->cinfo, COL_INFO, MT_DL_TextGet(data->u.MESSAGE_TYPE_v));
+ }
/* Dissect the MAC header */
proto_tree_add_bits_item(rlcmac_tree, hf_dl_ctrl_payload_type, tvb, 0, 2, FALSE);
default: ret = -1;
break;
}
+ free(data);
}
{ "Payload Type",
"gsm_rlcmac_dl.pt",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "Payload Type", HFILL
}
},
{ &hf_dl_ctrl_rrbp,
{ "RRBP",
"gsm_rlcmac_dl.rrbp",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "RRBP", HFILL
}
},
{ &hf_dl_ctrl_s_p,
{ "S/P",
"gsm_rlcmac_dl.s_p",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- NULL, HFILL
+ "S/P", HFILL
}
},
{ &hf_dl_ctrl_usf,
{ "USF",
"gsm_rlcmac_dl.usf",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "USF", HFILL
}
},
{ &hf_dl_ctrl_rbsn,
{ "RBSN",
"gsm_rlcmac_dl.rbsn",
FT_BOOLEAN,BASE_NONE, NULL, 0x0,
- NULL, HFILL
+ "RBSN", HFILL
}
},
{ &hf_dl_ctrl_rti,
{ "RTI",
"gsm_rlcmac_dl.rti",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "RTI", HFILL
}
},
{ &hf_dl_ctrl_fs,
{ "FS",
"gsm_rlcmac_dl.fs",
FT_BOOLEAN,BASE_NONE, NULL, 0x0,
- NULL, HFILL
+ "FS", HFILL
}
},
{ &hf_dl_ctrl_ac,
{ "AC",
"gsm_rlcmac_dl.ac",
FT_BOOLEAN,BASE_NONE, NULL, 0x0,
- NULL, HFILL
+ "AC", HFILL
}
},
{ &hf_dl_ctrl_pr,
{ "PR",
"gsm_rlcmac_dl.pr",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "PR", HFILL
}
},
{ &hf_dl_ctrl_tfi,
{ "TFI",
"gsm_rlcmac_dl.tfi",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "TFI", HFILL
}
},
{ &hf_dl_ctrl_d,
{ "D",
"gsm_rlcmac_dl.d",
FT_BOOLEAN,BASE_NONE, NULL, 0x0,
- NULL, HFILL
+ "D", HFILL
}
},
{ &hf_dl_ctrl_rbsn_e,
{ "RBSNe",
"gsm_rlcmac_dl.rbsn_e",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "RBSNe", HFILL
}
},
{ &hf_dl_ctrl_fs_e,
{ "FSe",
"gsm_rlcmac_dl.fs_e",
FT_BOOLEAN,BASE_NONE, NULL, 0x0,
- NULL, HFILL
+ "FSe", HFILL
}
},
{ &hf_dl_ctrl_spare,
{ "spare",
"gsm_rlcmac_dl.spare",
FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL
+ "spare", HFILL
}
},
};