2 * Routines for ETSI Distribution & Communication Protocol
3 * Copyright 2006, British Broadcasting Corporation
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * Ref: ETSI DCP (ETSI TS 102 821)
33 #include <epan/packet.h>
34 #include <epan/reassemble.h>
35 #include <wsutil/crcdrm.h>
36 #include <epan/reedsolomon.h>
37 #include <epan/emem.h>
40 /* forward reference */
42 static gboolean dissect_dcp_etsi (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
43 static void dissect_af (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
44 static void dissect_pft (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
45 static void dissect_tpl(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
47 static dissector_table_t dcp_dissector_table;
48 static dissector_table_t af_dissector_table;
49 static dissector_table_t tpl_dissector_table;
51 static int proto_dcp_etsi = -1;
52 static int proto_af = -1;
53 static int proto_pft = -1;
54 static int proto_tpl = -1;
55 static int hf_edcp_sync = -1;
56 static int hf_edcp_len = -1;
57 static int hf_edcp_seq = -1;
58 static int hf_edcp_crcflag = -1;
59 static int hf_edcp_maj = -1;
60 static int hf_edcp_min = -1;
61 static int hf_edcp_pt = -1;
62 static int hf_edcp_crc = -1;
63 static int hf_edcp_crc_ok = -1;
64 static int hf_edcp_pft_pt = -1;
65 static int hf_edcp_pseq = -1;
66 static int hf_edcp_findex = -1;
67 static int hf_edcp_fcount = -1;
68 static int hf_edcp_fecflag = -1;
69 static int hf_edcp_addrflag = -1;
70 static int hf_edcp_plen = -1;
71 static int hf_edcp_rsk = -1;
72 static int hf_edcp_rsz = -1;
73 static int hf_edcp_source = -1;
74 static int hf_edcp_dest = -1;
75 static int hf_edcp_hcrc = -1;
76 static int hf_edcp_hcrc_ok = -1;
77 static int hf_edcp_c_max = -1;
78 static int hf_edcp_rx_min = -1;
79 static int hf_edcp_rs_corrected = -1;
80 static int hf_edcp_rs_ok = -1;
81 static int hf_edcp_pft_payload = -1;
83 static int hf_tpl_tlv = -1;
84 static int hf_tpl_ptr = -1;
86 static int hf_edcp_fragments = -1;
87 static int hf_edcp_fragment = -1;
88 static int hf_edcp_fragment_overlap = -1;
89 static int hf_edcp_fragment_overlap_conflicts = -1;
90 static int hf_edcp_fragment_multiple_tails = -1;
91 static int hf_edcp_fragment_too_long_fragment = -1;
92 static int hf_edcp_fragment_error = -1;
93 static int hf_edcp_fragment_count = -1;
94 static int hf_edcp_reassembled_in = -1;
95 static int hf_edcp_reassembled_length = -1;
97 /* Initialize the subtree pointers */
98 static gint ett_edcp = -1;
99 static gint ett_af = -1;
100 static gint ett_pft = -1;
101 static gint ett_tpl = -1;
102 static gint ett_edcp_fragment = -1;
103 static gint ett_edcp_fragments = -1;
105 static GHashTable *dcp_fragment_table = NULL;
106 static GHashTable *dcp_reassembled_table = NULL;
108 static const fragment_items dcp_frag_items = {
109 /* Fragment subtrees */
112 /* Fragment fields */
115 &hf_edcp_fragment_overlap,
116 &hf_edcp_fragment_overlap_conflicts,
117 &hf_edcp_fragment_multiple_tails,
118 &hf_edcp_fragment_too_long_fragment,
119 &hf_edcp_fragment_error,
120 &hf_edcp_fragment_count,
121 /* Reassembled in field */
122 &hf_edcp_reassembled_in,
123 /* Reassembled length field */
124 &hf_edcp_reassembled_length,
129 /** initialise the DCP protocol. Details follow
133 dcp_init_protocol(void)
135 fragment_table_init (&dcp_fragment_table);
136 reassembled_table_init (&dcp_reassembled_table);
140 /** Dissect a DCP packet. Details follow
142 * \param[in,out] tvb The buffer containing the packet
143 * \param[in,out] pinfo The packet info structure
144 * \param[in,out] tree The structure containing the details which will be displayed, filtered, etc.
148 dissect_dcp_etsi (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
151 proto_tree *dcp_tree = NULL;
153 /* 6.1 AF packet structure
157 * 2 bytes 4 bytes 2 bytes 1 byte 1 byte
159 * SYNC: two-byte ASCII representation of "AF".
160 * LEN: length of the payload, in bytes.
161 * SEQ: sequence number
162 * AR: AF protocol Revision - a field combining the CF, MAJ and MIN fields
163 * CF: CRC Flag, 0 if the CRC field is not used
164 * MAJ: major revision of the AF protocol in use, see clause 6.2.
165 * MIN: minor revision of the AF protocol in use, see clause 6.2.
166 * Protocol Type (PT): single byte encoding the protocol of the data carried in the payload. For TAG Packets, the value
167 * shall be the ASCII representation of "T".
169 * 7.1 PFT fragment structure
171 * 14, 16, 18 or 20 bytes (depending on options) Optional present if FEC=1 Optional present if Addr = 1
172 * Psync Pseq Findex Fcount FEC HCRC Addr Plen | RSk RSz | Source Dest
173 * 16 bits 16 bits 24 bits 24 bits 1 bit 16 bits 1 bit 14 bits | 8 bits 8 bits | 16 bits 16 bits
175 * Psync: the ASCII string "PF" is used as the synchronization word for the PFT Layer
177 * Don't accept this packet unless at least a full AF header present(10 bytes).
178 * It should be possible to strengthen the heuristic further if need be.
180 if(tvb_length(tvb) < 11)
183 sync = tvb_get_ephemeral_string (tvb, 0, 2);
184 if((sync[0]!='A' && sync[0]!='P') || sync[1]!='F')
187 pinfo->current_proto = "DCP (ETSI)";
189 /* Clear out stuff in the info column */
190 col_clear(pinfo->cinfo, COL_INFO);
191 col_set_str (pinfo->cinfo, COL_PROTOCOL, "DCP (ETSI)");
192 /*col_append_fstr (pinfo->cinfo, COL_INFO, " tvb %d", tvb_length(tvb));*/
195 proto_item *ti = NULL;
196 ti = proto_tree_add_item (tree, proto_dcp_etsi, tvb, 0, -1, ENC_NA);
197 dcp_tree = proto_item_add_subtree (ti, ett_edcp);
200 dissector_try_string(dcp_dissector_table, (char*)sync, tvb, pinfo, dcp_tree);
204 #define PFT_RS_N_MAX 207
206 #define PFT_RS_P (PFT_RS_K - PFT_RS_N_MAX)
210 void rs_deinterleave(const guint8 *input, guint8 *output, guint16 plen, guint32 fcount)
213 for(fidx=0; fidx<fcount; fidx++)
216 for (r=0; r<plen; r++)
218 output[fidx+r*fcount] = input[fidx*plen+r];
224 gboolean rs_correct_data(guint8 *deinterleaved, guint8 *output,
225 guint32 c_max, guint16 rsk, guint16 rsz _U_)
227 guint32 i, index_coded = 0, index_out = 0;
229 for (i=0; i<c_max; i++)
231 memcpy(output+index_out, deinterleaved+index_coded, rsk);
233 memcpy(output+index_out+PFT_RS_N_MAX, deinterleaved+index_coded, PFT_RS_P);
234 index_coded += PFT_RS_P;
235 err_corr = eras_dec_rs(output+index_out, NULL, 0);
244 /* Don't attempt reassembly if we have a huge number of fragments. */
245 #define MAX_FRAGMENTS ((1 * 1024 * 1024) / sizeof(guint32))
248 dissect_pft_fec_detailed(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
260 guint16 decoded_size;
263 tvbuff_t *new_tvb=NULL;
265 if (fcount > MAX_FRAGMENTS) {
267 proto_tree_add_text(tree, tvb , 0, -1, "[Reassembly of %d fragments not attempted]", fcount);
271 decoded_size = fcount*plen;
272 c_max = fcount*plen/(rsk+PFT_RS_P); /* rounded down */
273 rx_min = c_max*rsk/plen;
274 if(rx_min*plen<c_max*rsk)
277 new_tvb = process_reassembled_data (tvb, offset, pinfo,
278 "Reassembled DCP (ETSI)",
279 fdx, &dcp_frag_items,
285 fragment_data *fd_head;
288 proto_tree_add_text (tree, tvb, 0, -1, "want %d, got %d need %d",
289 fcount, fragments, rx_min
291 got = ep_alloc(fcount*sizeof(guint32));
293 /* make a list of the findex (offset) numbers of the fragments we have */
294 fd = fragment_get(pinfo, seq, dcp_fragment_table);
295 for (fd_head = fd; fd_head != NULL; fd_head = fd_head->next) {
297 got[fragments++] = fd_head->offset; /* this is the findex of the fragment */
300 /* put a sentinel at the end */
301 got[fragments++] = fcount;
302 /* have we got enough for Reed Solomon to try to correct ? */
303 if(fragments>=rx_min) { /* yes, in theory */
304 guint i,current_findex;
305 fragment_data *frag=NULL;
306 guint8 *dummy_data = (guint8*) ep_alloc0 (plen);
307 tvbuff_t *dummytvb = tvb_new_real_data(dummy_data, plen, plen);
308 /* try and decode with missing fragments */
310 proto_tree_add_text (tree, tvb, 0, -1, "want %d, got %d need %d",
311 fcount, fragments, rx_min
313 /* fill the fragment table with empty fragments */
315 for(i=0; i<fragments; i++) {
316 guint next_fragment_we_have = got[i];
317 if (next_fragment_we_have > MAX_FRAGMENTS) {
319 proto_tree_add_text(tree, tvb , 0, -1, "[Reassembly of %d fragments not attempted]", next_fragment_we_have);
322 for(; current_findex<next_fragment_we_have; current_findex++) {
323 frag = fragment_add_seq_check (dummytvb, 0, pinfo, seq,
324 dcp_fragment_table, dcp_reassembled_table,
325 current_findex, plen, (current_findex+1!=fcount));
327 current_findex++; /* skip over the fragment we have */
330 new_tvb = process_reassembled_data (tvb, offset, pinfo,
331 "Reassembled DCP (ETSI)",
332 frag, &dcp_frag_items,
337 gboolean decoded = TRUE;
338 tvbuff_t *dtvb = NULL;
339 const guint8 *input = tvb_get_ptr(new_tvb, 0, -1);
340 guint16 reassembled_size = tvb_length(new_tvb);
341 guint8 *deinterleaved = (guint8*) g_malloc (reassembled_size);
342 guint8 *output = (guint8*) g_malloc (decoded_size);
343 rs_deinterleave(input, deinterleaved, plen, fcount);
345 dtvb = tvb_new_child_real_data(tvb, deinterleaved, reassembled_size, reassembled_size);
346 add_new_data_source(pinfo, dtvb, "Deinterleaved");
347 tvb_set_free_cb(dtvb, g_free);
349 decoded = rs_correct_data(deinterleaved, output, c_max, rsk, rsz);
351 proto_tree_add_boolean (tree, hf_edcp_rs_ok, tvb, offset, 2, decoded);
353 new_tvb = tvb_new_child_real_data(dtvb, output, decoded_size, decoded_size);
354 add_new_data_source(pinfo, new_tvb, "RS Error Corrected Data");
355 tvb_set_free_cb(new_tvb, g_free);
361 /** Handle a PFT packet which has the fragmentation header. This uses the
362 * standard wireshark methods for reassembling fragments. If FEC is used,
363 * the FEC is handled too. For the moment, all the fragments must be
364 * available but this could be improved.
365 * \param[in,out] tvb The buffer containing the current fragment
366 * \param[in,out] pinfo The packet info structure
367 * \param[in,out] tree The structure containing the details which will be displayed, filtered, etc.
368 * \param[in] findex the fragment count
369 * \param[in] fcount the number of fragments
370 * \param[in] seq the sequence number of the reassembled packet
371 * \param[in] offset the offset into the tvb of the fragment
372 * \param[in] plen the length of each fragment
373 * \param[in] fec is fec used
374 * \param[in] rsk the number of useful bytes in each chunk
375 * \param[in] rsz the number of padding bytes in each chunk
378 dissect_pft_fragmented(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
389 gboolean first, last;
390 tvbuff_t *new_tvb=NULL;
391 fragment_data *frag_edcp = NULL;
392 pinfo->fragmented = TRUE;
394 last = fcount == (findex+1);
395 frag_edcp = fragment_add_seq_check (
398 dcp_fragment_table, dcp_reassembled_table,
403 new_tvb = dissect_pft_fec_detailed(
404 tvb, pinfo, tree, findex, fcount, seq, offset, plen, fec, rsk, rsz, frag_edcp
407 new_tvb = process_reassembled_data (tvb, offset, pinfo,
408 "Reassembled DCP (ETSI)",
409 frag_edcp, &dcp_frag_items,
413 col_append_str (pinfo->cinfo, COL_INFO, " (Message Reassembled)");
416 col_append_str (pinfo->cinfo, COL_INFO, " (Message Reassembly failure)");
418 col_append_fstr (pinfo->cinfo, COL_INFO, " (Message fragment %u)", findex);
422 col_append_str (pinfo->cinfo, COL_INFO, " (first)");
424 col_append_str (pinfo->cinfo, COL_INFO, " (last)");
428 /** Dissect a PFT packet. Details follow
430 * \param[in,out] tvb The buffer containing the packet
431 * \param[in,out] pinfo The packet info structure
432 * \param[in,out] tree The structure containing the details which will be displayed, filtered, etc.
435 dissect_pft(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
439 guint16 seq, payload_len;
440 guint32 findex, fcount;
441 proto_tree *pft_tree = NULL;
442 proto_item *ti = NULL, *li = NULL;
443 tvbuff_t *next_tvb = NULL;
444 gboolean fec = FALSE;
445 guint16 rsk=0, rsz=0;
447 pinfo->current_proto = "DCP-PFT";
448 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DCP-PFT");
450 if (tree) { /* we are being asked for details */
451 ti = proto_tree_add_item (tree, proto_pft, tvb, 0, -1, ENC_NA);
452 pft_tree = proto_item_add_subtree (ti, ett_pft);
453 proto_tree_add_item (pft_tree, hf_edcp_sync, tvb, offset, 2, ENC_ASCII|ENC_NA);
456 seq = tvb_get_ntohs (tvb, offset);
458 proto_tree_add_item (pft_tree, hf_edcp_pseq, tvb, offset, 2, ENC_BIG_ENDIAN);
461 findex = tvb_get_ntoh24 (tvb, offset);
463 proto_tree_add_item (pft_tree, hf_edcp_findex, tvb, offset, 3, ENC_BIG_ENDIAN);
466 fcount = tvb_get_ntoh24 (tvb, offset);
468 proto_tree_add_item (pft_tree, hf_edcp_fcount, tvb, offset, 3, ENC_BIG_ENDIAN);
471 plen = tvb_get_ntohs (tvb, offset);
472 payload_len = plen & 0x3fff;
474 proto_tree_add_item (pft_tree, hf_edcp_fecflag, tvb, offset, 2, ENC_BIG_ENDIAN);
475 proto_tree_add_item (pft_tree, hf_edcp_addrflag, tvb, offset, 2, ENC_BIG_ENDIAN);
476 li = proto_tree_add_item (pft_tree, hf_edcp_plen, tvb, offset, 2, ENC_BIG_ENDIAN);
481 rsk = tvb_get_guint8 (tvb, offset);
483 proto_tree_add_item (pft_tree, hf_edcp_rsk, tvb, offset, 1, ENC_BIG_ENDIAN);
485 rsz = tvb_get_guint8 (tvb, offset);
487 proto_tree_add_item (pft_tree, hf_edcp_rsz, tvb, offset, 1, ENC_BIG_ENDIAN);
492 proto_tree_add_item (pft_tree, hf_edcp_source, tvb, offset, 2, ENC_BIG_ENDIAN);
495 proto_tree_add_item (pft_tree, hf_edcp_dest, tvb, offset, 2, ENC_BIG_ENDIAN);
499 proto_item *ci = NULL;
500 guint header_len = offset+2;
501 const char *crc_buf = (const char *) tvb_get_ptr(tvb, 0, header_len);
502 unsigned long c = crc_drm(crc_buf, header_len, 16, 0x11021, 1);
503 ci = proto_tree_add_item (pft_tree, hf_edcp_hcrc, tvb, offset, 2, ENC_BIG_ENDIAN);
504 proto_item_append_text(ci, " (%s)", (c==0xe2f0)?"Ok":"bad");
505 proto_tree_add_boolean(pft_tree, hf_edcp_hcrc_ok, tvb, offset, 2, c==0xe2f0);
508 if (fcount > 1) { /* fragmented*/
509 gboolean save_fragmented = pinfo->fragmented;
510 guint16 real_len = tvb_length(tvb)-offset;
511 proto_tree_add_item (pft_tree, hf_edcp_pft_payload, tvb, offset, real_len, ENC_NA);
512 if(real_len != payload_len) {
514 proto_item_append_text(li, " (length error (%d))", real_len);
516 next_tvb = dissect_pft_fragmented(tvb, pinfo, pft_tree,
517 findex, fcount, seq, offset, real_len,
520 pinfo->fragmented = save_fragmented;
522 next_tvb = tvb_new_subset_remaining (tvb, offset);
525 dissect_af(next_tvb, pinfo, tree);
529 /** Dissect an AF Packet. Parse an AF packet, checking the CRC if the CRC valid
530 * flag is set and calling any registered sub dissectors on the payload type.
531 * Currently only a payload type 'T' is defined which is the tag packet layer.
532 * If any others are defined then they can register themselves.
533 * \param[in,out] tvb The buffer containing the packet
534 * \param[in,out] pinfo The packet info structure
535 * \param[in,out] tree The structure containing the details which will be displayed, filtered, etc.
538 dissect_af (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
541 proto_item *ti = NULL;
542 proto_item *li = NULL;
543 proto_item *ci = NULL;
544 proto_tree *af_tree = NULL;
547 tvbuff_t *next_tvb = NULL;
549 pinfo->current_proto = "DCP-AF";
550 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DCP-AF");
552 if (tree) { /* we are being asked for details */
553 ti = proto_tree_add_item (tree, proto_af, tvb, 0, -1, ENC_NA);
554 af_tree = proto_item_add_subtree (ti, ett_af);
555 proto_tree_add_item (af_tree, hf_edcp_sync, tvb, offset, 2, ENC_ASCII|ENC_NA);
558 payload_len = tvb_get_ntohl(tvb, offset);
560 guint32 real_payload_len = tvb_length(tvb)-12;
561 li = proto_tree_add_item (af_tree, hf_edcp_len, tvb, offset, 4, ENC_BIG_ENDIAN);
562 if(real_payload_len < payload_len) {
563 proto_item_append_text (li, " (wrong len claims %d is %d)",
564 payload_len, real_payload_len
566 } else if(real_payload_len > payload_len) {
567 proto_item_append_text (li, " (%d bytes in packet after end of AF frame)",
568 real_payload_len-payload_len
574 proto_tree_add_item (af_tree, hf_edcp_seq, tvb, offset, 2, ENC_BIG_ENDIAN);
576 ver = tvb_get_guint8 (tvb, offset);
578 proto_tree_add_item (af_tree, hf_edcp_crcflag, tvb, offset, 1, ENC_BIG_ENDIAN);
579 proto_tree_add_item (af_tree, hf_edcp_maj, tvb, offset, 1, ENC_BIG_ENDIAN);
580 proto_tree_add_item (af_tree, hf_edcp_min, tvb, offset, 1, ENC_BIG_ENDIAN);
583 pt = tvb_get_guint8 (tvb, offset);
585 proto_tree_add_item (af_tree, hf_edcp_pt, tvb, offset, 1, ENC_ASCII|ENC_NA);
587 next_tvb = tvb_new_subset (tvb, offset, payload_len, -1);
588 offset += payload_len;
590 ci = proto_tree_add_item (af_tree, hf_edcp_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
591 if (ver & 0x80) { /* crc valid */
592 guint len = offset+2;
593 const char *crc_buf = (const char *) tvb_get_ptr(tvb, 0, len);
594 unsigned long c = crc_drm(crc_buf, len, 16, 0x11021, 1);
596 proto_item_append_text(ci, " (%s)", (c==0xe2f0)?"Ok":"bad");
597 proto_tree_add_boolean(af_tree, hf_edcp_crc_ok, tvb, offset, 2, c==0xe2f0);
601 dissector_try_uint(af_dissector_table, pt, next_tvb, pinfo, tree);
604 /** Dissect the Tag Packet Layer.
605 * Split the AF packet into its tag items. Each tag item has a 4 character
606 * tag, a length in bits and a value. The *ptr tag is dissected in the routine.
607 * All other tags are listed and may be handled by other dissectors.
608 * Child dissectors are tied to the parent tree, not to this tree, so that
609 * they appear at the same level as DCP.
610 * \param[in,out] tvb The buffer containing the packet
611 * \param[in,out] pinfo The packet info structure
612 * \param[in,out] tree The structure containing the details which will be displayed, filtered, etc.
615 dissect_tpl(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
617 proto_tree *tpl_tree = NULL;
622 pinfo->current_proto = "DCP-TPL";
623 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DCP-TPL");
626 proto_item *ti = NULL;
627 ti = proto_tree_add_item (tree, proto_tpl, tvb, 0, -1, ENC_NA);
628 tpl_tree = proto_item_add_subtree (ti, ett_tpl);
630 while(offset<tvb_length(tvb)) {
633 char *tag = (char*)tvb_get_ephemeral_string (tvb, offset, 4); offset += 4;
634 bits = tvb_get_ntohl(tvb, offset); offset += 4;
639 if(strcmp(tag, "*ptr")==0) {
640 prot = (char*)tvb_get_ephemeral_string (tvb, offset, 4);
641 maj = tvb_get_ntohs(tvb, offset+4);
642 min = tvb_get_ntohs(tvb, offset+6);
643 proto_tree_add_bytes_format(tpl_tree, hf_tpl_tlv, tvb,
644 offset-8, bytes+8, tvb_get_ptr(tvb, offset, bytes),
645 "%s %s rev %d.%d", tag, prot, maj, min);
647 proto_tree_add_bytes_format(tpl_tree, hf_tpl_tlv, tvb,
648 offset-8, bytes+8, tvb_get_ptr(tvb, offset, bytes),
649 "%s (%u bits)", tag, bits);
654 if(prot) { /* prot is non-NULL only if we have our tree. */
655 dissector_try_string(tpl_dissector_table, prot, tvb, pinfo, tree->parent);
660 proto_reg_handoff_dcp_etsi (void)
662 dissector_handle_t af_handle;
663 dissector_handle_t pft_handle;
664 dissector_handle_t tpl_handle;
666 af_handle = create_dissector_handle(dissect_af, proto_af);
667 pft_handle = create_dissector_handle(dissect_pft, proto_pft);
668 tpl_handle = create_dissector_handle(dissect_tpl, proto_tpl);
669 heur_dissector_add("udp", dissect_dcp_etsi, proto_dcp_etsi);
670 dissector_add_string("dcp-etsi.sync", "AF", af_handle);
671 dissector_add_string("dcp-etsi.sync", "PF", pft_handle);
672 /* if there are ever other payload types ...*/
673 dissector_add_uint("dcp-af.pt", 'T', tpl_handle);
677 proto_register_dcp_etsi (void)
679 static hf_register_info hf_edcp[] = {
681 {"sync", "dcp-etsi.sync",
682 FT_STRING, BASE_NONE, NULL, 0,
686 static hf_register_info hf_af[] = {
688 {"length", "dcp-af.len",
689 FT_UINT32, BASE_DEC, NULL, 0,
690 "length in bytes of the payload", HFILL}
693 {"frame count", "dcp-af.seq",
694 FT_UINT16, BASE_DEC, NULL, 0,
695 "Logical Frame Number", HFILL}
698 {"crc flag", "dcp-af.crcflag",
699 FT_BOOLEAN, 8, NULL, 0x80,
700 "Frame is protected by CRC", HFILL}
703 {"Major Revision", "dcp-af.maj",
704 FT_UINT8, BASE_DEC, NULL, 0x70,
705 "Major Protocol Revision", HFILL}
708 {"Minor Revision", "dcp-af.min",
709 FT_UINT8, BASE_DEC, NULL, 0x0f,
710 "Minor Protocol Revision", HFILL}
713 {"Payload Type", "dcp-af.pt",
714 FT_STRING, BASE_NONE, NULL, 0,
715 "T means Tag Packets, all other values reserved", HFILL}
718 {"CRC", "dcp-af.crc",
719 FT_UINT16, BASE_HEX, NULL, 0,
723 {"CRC OK", "dcp-af.crc_ok",
724 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
729 static hf_register_info hf_pft[] = {
731 {"Sub-protocol", "dcp-pft.pt",
732 FT_UINT8, BASE_DEC, NULL, 0,
736 {"Sequence No", "dcp-pft.seq",
737 FT_UINT16, BASE_DEC, NULL, 0,
738 "PFT Sequence No", HFILL}
741 {"Fragment Index", "dcp-pft.findex",
742 FT_UINT24, BASE_DEC, NULL, 0,
743 "Index of the fragment within one AF Packet", HFILL}
746 {"Fragment Count", "dcp-pft.fcount",
747 FT_UINT24, BASE_DEC, NULL, 0,
748 "Number of fragments produced from this AF Packet", HFILL}
751 {"FEC", "dcp-pft.fec",
752 FT_BOOLEAN, 16, NULL, 0x8000,
753 "When set the optional RS header is present", HFILL}
756 {"Addr", "dcp-pft.addr",
757 FT_BOOLEAN, 16, NULL, 0x4000,
758 "When set the optional transport header is present", HFILL}
761 {"fragment length", "dcp-pft.len",
762 FT_UINT16, BASE_DEC, NULL, 0x3fff,
763 "length in bytes of the payload of this fragment", HFILL}
766 {"RSk", "dcp-pft.rsk",
767 FT_UINT8, BASE_DEC, NULL, 0,
768 "The length of the Reed Solomon data word", HFILL}
771 {"RSz", "dcp-pft.rsz",
772 FT_UINT8, BASE_DEC, NULL, 0,
773 "The number of padding bytes in the last Reed Solomon block", HFILL}
776 {"source addr", "dcp-pft.source",
777 FT_UINT16, BASE_DEC, NULL, 0,
778 "PFT source identifier", HFILL}
781 {"dest addr", "dcp-pft.dest",
782 FT_UINT16, BASE_DEC, NULL, 0,
783 "PFT destination identifier", HFILL}
786 {"header CRC", "dcp-pft.crc",
787 FT_UINT16, BASE_HEX, NULL, 0,
788 "PFT Header CRC", HFILL}
791 {"PFT CRC OK", "dcp-pft.crc_ok",
792 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
793 "PFT Header CRC OK", HFILL}
796 {"Message fragments", "dcp-pft.fragments",
797 FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL}},
799 {"Message fragment", "dcp-pft.fragment",
800 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL}},
801 {&hf_edcp_fragment_overlap,
802 {"Message fragment overlap", "dcp-pft.fragment.overlap",
803 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}},
804 {&hf_edcp_fragment_overlap_conflicts,
805 {"Message fragment overlapping with conflicting data",
806 "dcp-pft.fragment.overlap.conflicts",
807 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}},
808 {&hf_edcp_fragment_multiple_tails,
809 {"Message has multiple tail fragments",
810 "dcp-pft.fragment.multiple_tails",
811 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}},
812 {&hf_edcp_fragment_too_long_fragment,
813 {"Message fragment too long", "dcp-pft.fragment.too_long_fragment",
814 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}},
815 {&hf_edcp_fragment_error,
816 {"Message defragmentation error", "dcp-pft.fragment.error",
817 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL}},
818 {&hf_edcp_fragment_count,
819 {"Message fragment count", "dcp-pft.fragment.count",
820 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
821 {&hf_edcp_reassembled_in,
822 {"Reassembled in", "dcp-pft.reassembled.in",
823 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
824 {&hf_edcp_reassembled_length,
825 {"Reassembled DCP (ETSI) length", "dcp-pft.reassembled.length",
826 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
828 {"C max", "dcp-pft.cmax",
829 FT_UINT16, BASE_DEC, NULL, 0,
830 "Maximum number of RS chunks sent", HFILL}
833 {"Rx min", "dcp-pft.rxmin",
834 FT_UINT16, BASE_DEC, NULL, 0,
835 "Minimum number of fragments needed for RS decode", HFILL}
837 {&hf_edcp_rs_corrected,
838 {"RS Symbols Corrected", "dcp-pft.rs_corrected",
839 FT_INT16, BASE_DEC, NULL, 0,
840 "Number of symbols corrected by RS decode or -1 for failure", HFILL}
843 {"RS decode OK", "dcp-pft.rs_ok",
844 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
845 "successfully decoded RS blocks", HFILL}
847 {&hf_edcp_pft_payload,
848 {"payload", "dcp-pft.payload",
849 FT_BYTES, BASE_NONE, NULL, 0,
850 "PFT Payload", HFILL}
854 static hf_register_info hf_tpl[] = {
856 {"tag", "dcp-tpl.tlv",
857 FT_BYTES, BASE_NONE, NULL, 0,
861 {"Type", "dcp-tpl.ptr",
862 FT_STRING, BASE_NONE, NULL, 0,
863 "Protocol Type & Revision", HFILL}
867 /* Setup protocol subtree array */
868 static gint *ett[] = {
877 proto_dcp_etsi = proto_register_protocol ("ETSI Distribution & Communication Protocol (for DRM)", /* name */
878 "DCP (ETSI)", /* short name */
879 "dcp-etsi" /* abbrev */
881 proto_af = proto_register_protocol ("DCP Application Framing Layer", "DCP-AF", "dcp-af");
882 proto_pft = proto_register_protocol ("DCP Protection, Fragmentation & Transport Layer", "DCP-PFT", "dcp-pft");
883 proto_tpl = proto_register_protocol ("DCP Tag Packet Layer", "DCP-TPL", "dcp-tpl");
885 proto_register_field_array (proto_dcp_etsi, hf_edcp, array_length (hf_edcp));
886 proto_register_field_array (proto_af, hf_af, array_length (hf_af));
887 proto_register_field_array (proto_pft, hf_pft, array_length (hf_pft));
888 proto_register_field_array (proto_tpl, hf_tpl, array_length (hf_tpl));
889 proto_register_subtree_array (ett, array_length (ett));
891 /* subdissector code */
892 dcp_dissector_table = register_dissector_table("dcp-etsi.sync",
893 "DCP Sync", FT_STRING, BASE_NONE);
894 af_dissector_table = register_dissector_table("dcp-af.pt",
895 "AF Payload Type", FT_UINT8, BASE_DEC);
897 tpl_dissector_table = register_dissector_table("dcp-tpl.ptr",
898 "AF Payload Type", FT_STRING, BASE_NONE);
900 register_init_routine(dcp_init_protocol);