/* split out some common FEC handling */ static guint dissect_feccode(struct _norm *norm, struct _fec_ptr *f, proto_tree *tree, tvbuff_t *tvb, guint offset, packet_info *pinfo, gint reserved) { f->fec = &norm->fec; f->hf = &hf.fec; f->ett = &ett.fec; f->prefs = &preferences.fec; norm->fec.encoding_id = tvb_get_guint8(tvb, offset); norm->fec.encoding_id_present = 1; proto_tree_add_item(tree, hf.fec.encoding_id, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; if (reserved) { proto_tree_add_item(tree, hf.reserved, tvb, offset, 1, ENC_NA); offset++; } proto_tree_add_item(tree, hf.object_transport_id, tvb, offset, 2, ENC_BIG_ENDIAN); offset+=2; if (norm->fec.encoding_id_present && tvb_reported_length_remaining(tvb, offset) > 0) { fec_dissector(*f, tvb, tree, &offset); if (check_col(pinfo->cinfo, COL_INFO)) fec_info_column(f->fec, pinfo); } return offset; }
static void dissect_alc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Logical packet representation */ struct _alc alc; /* Offset for subpacket dissection */ guint offset; /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; proto_tree *alc_tree; /* Flute or not */ tvbuff_t *new_tvb; gboolean is_flute = FALSE; /* Structures and variables initialization */ offset = 0; memset(&alc, 0, sizeof(struct _alc)); /* Update packet info */ pinfo->current_proto = "ALC"; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "ALC"); col_clear(pinfo->cinfo, COL_INFO); /* ALC header dissection */ /* --------------------- */ alc.version = hi_nibble(tvb_get_guint8(tvb, offset)); if (tree) { /* Create subtree for the ALC protocol */ ti = proto_tree_add_item(tree, proto, tvb, offset, -1, ENC_NA); alc_tree = proto_item_add_subtree(ti, ett.main); /* Fill the ALC subtree */ proto_tree_add_uint(alc_tree, hf.version, tvb, offset, 1, alc.version); } else alc_tree = NULL; /* This dissector supports only ALCv1 packets. * If alc.version > 1 print only version field and quit. */ if (alc.version == 1) { struct _lct_ptr l; struct _fec_ptr f; l.lct = &alc.lct; l.hf = &hf.lct; l.ett = &ett.lct; l.prefs = &preferences.lct; f.fec = &alc.fec; f.hf = &hf.fec; f.ett = &ett.fec; f.prefs = &preferences.fec; /* LCT header dissection */ /* --------------------- */ is_flute = lct_dissector(l, f, tvb, alc_tree, &offset); /* FEC header dissection */ /* --------------------- */ /* Only if it's present and if LCT dissector has determined FEC Encoding ID * FEC dissector should be called with fec->encoding_id* and fec->instance_id* filled */ if (alc.fec.encoding_id_present && tvb_length(tvb) > offset) fec_dissector(f, tvb, alc_tree, &offset); /* Add the Payload item */ if (tvb_length(tvb) > offset){ if(is_flute){ new_tvb = tvb_new_subset_remaining(tvb,offset); call_dissector(xml_handle, new_tvb, pinfo, alc_tree); }else{ proto_tree_add_none_format(alc_tree, hf.payload, tvb, offset, -1, "Payload (%u bytes)", tvb_length(tvb) - offset); } } /* Complete entry in Info column on summary display */ /* ------------------------------------------------ */ if (check_col(pinfo->cinfo, COL_INFO)) { lct_info_column(&alc.lct, pinfo); fec_info_column(&alc.fec, pinfo); } /* Free g_allocated memory */ lct_dissector_free(&alc.lct); fec_dissector_free(&alc.fec); } else { if (tree) proto_tree_add_text(alc_tree, tvb, 0, -1, "Sorry, this dissector supports ALC version 1 only"); /* Complete entry in Info column on summary display */ if (check_col(pinfo->cinfo, COL_INFO)) col_add_fstr(pinfo->cinfo, COL_INFO, "Version: %u (not supported)", alc.version); } }