2 * Routines for DVB Dynamic Mode Adaption dissection
4 * http://satlabs.org/pdf/sl_561_Mode_Adaptation_Input_and_Output_Interfaces_for_DVB-S2_Equipment_v1.3.pdf
7 * ETSI EN 302 307 - Digital Video Broadcasting (DVB) - Framing Structure
8 * ETSI TS 102 606 - Digital Video Broadcasting (DVB) - Generic Stream Encapsulation (GSE) Protocol
10 * Copyright 2012, Tobias Rutz <tobias.rutz@work-microwave.de>
14 * Wireshark - Network traffic analyzer
15 * By Gerald Combs <gerald@wireshark.org>
16 * Copyright 1998 Gerald Combs
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 #include <epan/packet.h>
37 #include <epan/prefs.h>
38 #include <epan/etypes.h>
40 #define BIT_IS_SET(var, bit) ((var) & (1 << (bit)))
41 #define BIT_IS_CLEAR(var, bit) !BIT_IS_SET(var, bit)
43 #define DVB_S2_MODEADAPT_MINSIZE (DVB_S2_MODEADAPT_OUTSIZE + DVB_S2_BB_OFFS_CRC + 1)
44 #define DVB_S2_MODEADAPT_INSIZE 2
45 #define DVB_S2_MODEADAPT_OUTSIZE 4
47 /* CRC table crc-8, poly=0xD5 */
48 static guint8 crc8_table
[256] = {
49 0x00, 0xD5, 0x7F, 0xAA, 0xFE, 0x2B, 0x81, 0x54, 0x29, 0xFC, 0x56, 0x83, 0xD7, 0x02, 0xA8, 0x7D,
50 0x52, 0x87, 0x2D, 0xF8, 0xAC, 0x79, 0xD3, 0x06, 0x7B, 0xAE, 0x04, 0xD1, 0x85, 0x50, 0xFA, 0x2F,
51 0xA4, 0x71, 0xDB, 0x0E, 0x5A, 0x8F, 0x25, 0xF0, 0x8D, 0x58, 0xF2, 0x27, 0x73, 0xA6, 0x0C, 0xD9,
52 0xF6, 0x23, 0x89, 0x5C, 0x08, 0xDD, 0x77, 0xA2, 0xDF, 0x0A, 0xA0, 0x75, 0x21, 0xF4, 0x5E, 0x8B,
53 0x9D, 0x48, 0xE2, 0x37, 0x63, 0xB6, 0x1C, 0xC9, 0xB4, 0x61, 0xCB, 0x1E, 0x4A, 0x9F, 0x35, 0xE0,
54 0xCF, 0x1A, 0xB0, 0x65, 0x31, 0xE4, 0x4E, 0x9B, 0xE6, 0x33, 0x99, 0x4C, 0x18, 0xCD, 0x67, 0xB2,
55 0x39, 0xEC, 0x46, 0x93, 0xC7, 0x12, 0xB8, 0x6D, 0x10, 0xC5, 0x6F, 0xBA, 0xEE, 0x3B, 0x91, 0x44,
56 0x6B, 0xBE, 0x14, 0xC1, 0x95, 0x40, 0xEA, 0x3F, 0x42, 0x97, 0x3D, 0xE8, 0xBC, 0x69, 0xC3, 0x16,
57 0xEF, 0x3A, 0x90, 0x45, 0x11, 0xC4, 0x6E, 0xBB, 0xC6, 0x13, 0xB9, 0x6C, 0x38, 0xED, 0x47, 0x92,
58 0xBD, 0x68, 0xC2, 0x17, 0x43, 0x96, 0x3C, 0xE9, 0x94, 0x41, 0xEB, 0x3E, 0x6A, 0xBF, 0x15, 0xC0,
59 0x4B, 0x9E, 0x34, 0xE1, 0xB5, 0x60, 0xCA, 0x1F, 0x62, 0xB7, 0x1D, 0xC8, 0x9C, 0x49, 0xE3, 0x36,
60 0x19, 0xCC, 0x66, 0xB3, 0xE7, 0x32, 0x98, 0x4D, 0x30, 0xE5, 0x4F, 0x9A, 0xCE, 0x1B, 0xB1, 0x64,
61 0x72, 0xA7, 0x0D, 0xD8, 0x8C, 0x59, 0xF3, 0x26, 0x5B, 0x8E, 0x24, 0xF1, 0xA5, 0x70, 0xDA, 0x0F,
62 0x20, 0xF5, 0x5F, 0x8A, 0xDE, 0x0B, 0xA1, 0x74, 0x09, 0xDC, 0x76, 0xA3, 0xF7, 0x22, 0x88, 0x5D,
63 0xD6, 0x03, 0xA9, 0x7C, 0x28, 0xFD, 0x57, 0x82, 0xFF, 0x2A, 0x80, 0x55, 0x01, 0xD4, 0x7E, 0xAB,
64 0x84, 0x51, 0xFB, 0x2E, 0x7A, 0xAF, 0x05, 0xD0, 0xAD, 0x78, 0xD2, 0x07, 0x53, 0x86, 0x2C, 0xF9
68 static dissector_handle_t ip_handle
;
69 static dissector_handle_t ipv6_handle
;
71 void proto_register_dvb_s2_modeadapt(void);
72 void proto_reg_handoff_dvb_s2_modeadapt(void);
75 static gboolean dvb_s2_enable
= FALSE
;
76 static gboolean dvb_s2_full_dissection
= FALSE
;
78 /* Initialize the protocol and registered fields */
79 static int proto_dvb_s2_modeadapt
= -1;
80 static int hf_dvb_s2_modeadapt_sync
= -1;
81 static int hf_dvb_s2_modeadapt_acm
= -1;
82 static int hf_dvb_s2_modeadapt_acm_fecframe
= -1;
83 static int hf_dvb_s2_modeadapt_acm_pilot
= -1;
84 static int hf_dvb_s2_modeadapt_acm_modcod
= -1;
85 static int hf_dvb_s2_modeadapt_cni
= -1;
86 static int hf_dvb_s2_modeadapt_frameno
= -1;
88 static int proto_dvb_s2_bb
= -1;
89 static int hf_dvb_s2_bb_matype1
= -1;
90 static int hf_dvb_s2_bb_matype1_gs
= -1;
91 static int hf_dvb_s2_bb_matype1_mis
= -1;
92 static int hf_dvb_s2_bb_matype1_acm
= -1;
93 static int hf_dvb_s2_bb_matype1_issyi
= -1;
94 static int hf_dvb_s2_bb_matype1_npd
= -1;
95 static int hf_dvb_s2_bb_matype1_ro
= -1;
96 static int hf_dvb_s2_bb_matype2
= -1;
97 static int hf_dvb_s2_bb_upl
= -1;
98 static int hf_dvb_s2_bb_dfl
= -1;
99 static int hf_dvb_s2_bb_sync
= -1;
100 static int hf_dvb_s2_bb_syncd
= -1;
101 static int hf_dvb_s2_bb_crc
= -1;
103 static int proto_dvb_s2_gse
= -1;
104 static int hf_dvb_s2_gse_hdr
= -1;
105 static int hf_dvb_s2_gse_hdr_start
= -1;
106 static int hf_dvb_s2_gse_hdr_stop
= -1;
107 static int hf_dvb_s2_gse_hdr_labeltype
= -1;
108 static int hf_dvb_s2_gse_hdr_length
= -1;
109 static int hf_dvb_s2_gse_proto
= -1;
110 static int hf_dvb_s2_gse_label6
= -1;
111 static int hf_dvb_s2_gse_label3
= -1;
112 static int hf_dvb_s2_gse_fragid
= -1;
113 static int hf_dvb_s2_gse_totlength
= -1;
114 static int hf_dvb_s2_gse_exthdr
= -1;
115 static int hf_dvb_s2_gse_data
= -1;
116 static int hf_dvb_s2_gse_crc32
= -1;
118 /* Initialize the subtree pointers */
119 static gint ett_dvb_s2_modeadapt
= -1;
120 static gint ett_dvb_s2_modeadapt_acm
= -1;
122 static gint ett_dvb_s2_bb
= -1;
123 static gint ett_dvb_s2_bb_matype1
= -1;
125 static gint ett_dvb_s2_gse
= -1;
126 static gint ett_dvb_s2_gse_hdr
= -1;
128 /* *** DVB-S2 Modeadaption Header *** */
131 #define DVB_S2_MODEADAPT_OFFS_SYNCBYTE 0
132 #define DVB_S2_MODEADAPT_SYNCBYTE 0xB8
135 #define DVB_S2_MODEADAPT_OFFS_ACMBYTE 1
136 #define DVB_S2_MODEADAPT_MODCODS_MASK 0x1F
137 static const value_string modeadapt_modcods
[] = {
138 { 0, "DUMMY PLFRAME"},
172 static value_string_ext modeadapt_modcods_ext
= VALUE_STRING_EXT_INIT(modeadapt_modcods
);
174 #define DVB_S2_MODEADAPT_PILOTS_MASK 0x20
175 static const true_false_string tfs_modeadapt_pilots
= {
180 #define DVB_S2_MODEADAPT_FECFRAME_MASK 0x40
181 static const true_false_string tfs_modeadapt_fecframe
= {
187 #define DVB_S2_MODEADAPT_OFFS_CNI 2
188 static const value_string modeadapt_esno
[] = {
189 { 0, "modem unlocked, SNR not available"},
447 static value_string_ext modeadapt_esno_ext
= VALUE_STRING_EXT_INIT(modeadapt_esno
);
450 #define DVB_S2_MODEADAPT_OFFS_FNO 3
452 /* *** DVB-S2 Base-Band Frame *** */
454 #define DVB_S2_BB_HEADER_LEN 10
456 #define DVB_S2_BB_OFFS_MATYPE1 0
457 #define DVB_S2_BB_GS_MASK 0xC0
458 static const value_string bb_gs
[] = {
459 {0, "Generic Packetized (GSE)"},
460 {1, "Generic continuous (GSE)"},
462 {3, "Transport (TS)"},
466 #define DVB_S2_BB_MIS_POS 5
467 #define DVB_S2_BB_MIS_MASK 0x20
468 static const true_false_string tfs_bb_mis
= {
473 #define DVB_S2_BB_ACM_MASK 0x10
474 static const true_false_string tfs_bb_acm
= {
479 #define DVB_S2_BB_ISSYI_MASK 0x08
480 static const true_false_string tfs_bb_issyi
= {
485 #define DVB_S2_BB_NPD_MASK 0x04
486 static const true_false_string tfs_bb_npd
= {
491 #define DVB_S2_BB_RO_MASK 0x03
492 static const value_string bb_ro
[] = {
496 {3, "<0,20 / reserved"},
500 #define DVB_S2_BB_OFFS_MATYPE2 1
501 #define DVB_S2_BB_OFFS_UPL 2
502 #define DVB_S2_BB_OFFS_DFL 4
503 #define DVB_S2_BB_OFFS_SYNC 6
504 #define DVB_S2_BB_OFFS_SYNCD 7
505 #define DVB_S2_BB_OFFS_CRC 9
507 /* *** DVB-S2 GSE Frame *** */
509 #define DVB_S2_GSE_MINSIZE 2
511 #define DVB_S2_GSE_OFFS_HDR 0
512 #define DVB_S2_GSE_HDR_START_MASK 0x8000
513 #define DVB_S2_GSE_HDR_START_POS 15
514 #define DVB_S2_GSE_HDR_STOP_MASK 0x4000
515 #define DVB_S2_GSE_HDR_STOP_POS 14
516 static const true_false_string tfs_gse_ss
= {
521 #define DVB_S2_GSE_HDR_LABELTYPE_MASK 0x3000
522 #define DVB_S2_GSE_HDR_LABELTYPE_POS1 13
523 #define DVB_S2_GSE_HDR_LABELTYPE_POS2 12
524 static const value_string gse_labeltype
[] = {
527 {2, "0 byte (Broadcast)"},
528 {3, "re-use last label"},
532 #define DVB_S2_GSE_HDR_LENGTH_MASK 0x0FFF
534 static const range_string gse_proto_str
[] = {
535 {0x0000 , 0x00FF , "not implemented"},
536 {0x0100 , 0x05FF , "not implemented"},
537 {0x0600 , 0x07FF , "not implemented"},
538 {ETHERTYPE_IP
, ETHERTYPE_IP
, "IPv4 Payload" },
539 {0x0801 , 0x86DC , "not implemented"},
540 {ETHERTYPE_IPv6
, ETHERTYPE_IPv6
, "IPv6 Payload" },
541 {0x86DE , 0xFFFF , "not implemented"},
545 #define DVB_S2_GSE_CRC32_LEN 4
547 /* *** helper functions *** */
548 static gboolean
check_crc8(tvbuff_t
*p
, guint8 len
, guint8 offset
, guint8 received_fcs
)
553 for (i
= 0; i
< len
; i
++) {
554 tmp
= tvb_get_guint8(p
, offset
++);
555 crc
= crc8_table
[crc
^ tmp
];
557 if (received_fcs
== crc
)
563 /* *** Code to actually dissect the packets *** */
564 static int dissect_dvb_s2_gse(tvbuff_t
*tvb
, int cur_off
, proto_tree
*tree
, packet_info
*pinfo
)
568 guint16 gse_hdr
, data_len
, gse_proto
= 0;
571 proto_tree
*dvb_s2_gse_tree
, *dvb_s2_gse_hdr_tree
;
575 col_append_str(pinfo
->cinfo
, COL_INFO
, "GSE");
577 /* get header and determine length */
578 gse_hdr
= tvb_get_ntohs(tvb
, cur_off
+ DVB_S2_GSE_OFFS_HDR
);
580 frag_len
= (gse_hdr
& DVB_S2_GSE_HDR_LENGTH_MASK
)+2;
582 ti
= proto_tree_add_item(tree
, proto_dvb_s2_gse
, tvb
, cur_off
, frag_len
, ENC_NA
);
583 dvb_s2_gse_tree
= proto_item_add_subtree(ti
, ett_dvb_s2_gse
);
585 tf
= proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_hdr
, tvb
, cur_off
+ DVB_S2_GSE_OFFS_HDR
, 2, gse_hdr
);
587 dvb_s2_gse_hdr_tree
= proto_item_add_subtree(tf
, ett_dvb_s2_gse_hdr
);
588 proto_tree_add_item(dvb_s2_gse_hdr_tree
, hf_dvb_s2_gse_hdr_start
, tvb
, cur_off
+ DVB_S2_GSE_OFFS_HDR
, 2, ENC_BIG_ENDIAN
);
589 proto_tree_add_item(dvb_s2_gse_hdr_tree
, hf_dvb_s2_gse_hdr_stop
, tvb
, cur_off
+ DVB_S2_GSE_OFFS_HDR
, 2, ENC_BIG_ENDIAN
);
590 proto_tree_add_item(dvb_s2_gse_hdr_tree
, hf_dvb_s2_gse_hdr_labeltype
, tvb
,
591 cur_off
+ DVB_S2_GSE_OFFS_HDR
, 2, ENC_BIG_ENDIAN
);
592 proto_tree_add_item(dvb_s2_gse_hdr_tree
, hf_dvb_s2_gse_hdr_length
, tvb
, cur_off
+ DVB_S2_GSE_OFFS_HDR
, 2, ENC_BIG_ENDIAN
);
594 if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_START_POS
) &&
595 BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
) &&
596 BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_LABELTYPE_POS1
) && BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_LABELTYPE_POS2
)) {
597 col_append_str(pinfo
->cinfo
, COL_INFO
, " ");
600 if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_START_POS
) || BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
)) {
602 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_fragid
, tvb
, cur_off
+ new_off
, 1, ENC_BIG_ENDIAN
);
606 if (BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_START_POS
) && BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
)) {
608 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_totlength
, tvb
, cur_off
+ new_off
, 2, ENC_BIG_ENDIAN
);
609 col_append_str(pinfo
->cinfo
, COL_INFO
, "(frag) ");
613 if (BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_START_POS
)) {
614 gse_proto
= tvb_get_ntohs(tvb
, cur_off
+ new_off
);
616 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_proto
, tvb
, cur_off
+ new_off
, 2, ENC_BIG_ENDIAN
);
620 if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_LABELTYPE_POS1
) && BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_LABELTYPE_POS2
)) {
622 if (BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
))
623 col_append_str(pinfo
->cinfo
, COL_INFO
, "6 ");
625 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_label6
, tvb
, cur_off
+ new_off
, 6, ENC_NA
);
628 } else if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_LABELTYPE_POS1
) &&
629 BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_LABELTYPE_POS2
)) {
631 if (BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
))
632 col_append_str(pinfo
->cinfo
, COL_INFO
, "3 ");
634 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_label3
, tvb
, cur_off
+ new_off
, 3, ENC_NA
);
639 if (BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
))
640 col_append_str(pinfo
->cinfo
, COL_INFO
, "0 ");
642 if (gse_proto
< 0x0600 && gse_proto
>= 0x100) {
643 /* Only display optional extension headers */
644 /* TODO: needs to be tested */
646 /* TODO: implementation needs to be checked (len of ext-header??) */
647 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_exthdr
, tvb
, cur_off
+ new_off
, 1, ENC_BIG_ENDIAN
);
655 col_append_str(pinfo
->cinfo
, COL_INFO
, "(frag) ");
658 next_tvb
= tvb_new_subset_remaining(tvb
, cur_off
+ new_off
);
660 if (dvb_s2_full_dissection
)
664 new_off
+= call_dissector(ip_handle
, next_tvb
, pinfo
, tree
);
667 new_off
+= call_dissector(ipv6_handle
, next_tvb
, pinfo
, tree
);
670 if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_START_POS
) && BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
)) {
671 data_len
= (gse_hdr
& DVB_S2_GSE_HDR_LENGTH_MASK
) - (new_off
- DVB_S2_GSE_MINSIZE
) - DVB_S2_GSE_CRC32_LEN
;
673 data_len
= (gse_hdr
& DVB_S2_GSE_HDR_LENGTH_MASK
) - (new_off
- DVB_S2_GSE_MINSIZE
);
675 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_data
, tvb
, cur_off
+ new_off
, data_len
, ENC_NA
);
682 if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_START_POS
) && BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
)) {
683 data_len
= (gse_hdr
& DVB_S2_GSE_HDR_LENGTH_MASK
) - (new_off
- DVB_S2_GSE_MINSIZE
) - DVB_S2_GSE_CRC32_LEN
;
685 data_len
= (gse_hdr
& DVB_S2_GSE_HDR_LENGTH_MASK
) - (new_off
- DVB_S2_GSE_MINSIZE
);
687 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_data
, tvb
, cur_off
+ new_off
, data_len
, ENC_NA
);
691 /* add crc32 if last fragment */
692 if (BIT_IS_CLEAR(gse_hdr
, DVB_S2_GSE_HDR_START_POS
) && BIT_IS_SET(gse_hdr
, DVB_S2_GSE_HDR_STOP_POS
)) {
693 proto_tree_add_item(dvb_s2_gse_tree
, hf_dvb_s2_gse_crc32
, tvb
, cur_off
+ new_off
, DVB_S2_GSE_CRC32_LEN
, ENC_NA
);
694 new_off
+= DVB_S2_GSE_CRC32_LEN
;
701 static gboolean
test_dvb_s2_crc(tvbuff_t
*tvb
, guint offset
) {
705 /* only check BB Header and return */
706 if (tvb_length(tvb
) < (offset
+ DVB_S2_BB_HEADER_LEN
))
709 input8
= tvb_get_guint8(tvb
, offset
+ DVB_S2_BB_OFFS_CRC
);
711 if (!check_crc8(tvb
, DVB_S2_BB_HEADER_LEN
- 1, offset
, input8
))
720 static int dissect_dvb_s2_bb(tvbuff_t
*tvb
, int cur_off
, proto_tree
*tree
, packet_info
*pinfo
)
723 proto_tree
*dvb_s2_bb_tree
, *dvb_s2_bb_matype1_tree
;
726 guint16 input16
, bb_data_len
= 0;
728 int sub_dissected
= 0, flag_is_ms
= 0, new_off
= 0;
730 col_append_str(pinfo
->cinfo
, COL_PROTOCOL
, "BB ");
731 col_append_str(pinfo
->cinfo
, COL_INFO
, "Baseband ");
733 /* create display subtree for the protocol */
734 ti
= proto_tree_add_item(tree
, proto_dvb_s2_bb
, tvb
, cur_off
, DVB_S2_BB_HEADER_LEN
, ENC_NA
);
735 dvb_s2_bb_tree
= proto_item_add_subtree(ti
, ett_dvb_s2_bb
);
737 input8
= tvb_get_guint8(tvb
, cur_off
+ DVB_S2_BB_OFFS_MATYPE1
);
740 if (BIT_IS_CLEAR(input8
, DVB_S2_BB_MIS_POS
))
743 tf
= proto_tree_add_item(dvb_s2_bb_tree
, hf_dvb_s2_bb_matype1
, tvb
, cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, input8
);
744 dvb_s2_bb_matype1_tree
= proto_item_add_subtree(tf
, ett_dvb_s2_bb_matype1
);
745 proto_tree_add_item(dvb_s2_bb_matype1_tree
, hf_dvb_s2_bb_matype1_gs
, tvb
,
746 cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, ENC_BIG_ENDIAN
);
747 proto_tree_add_item(dvb_s2_bb_matype1_tree
, hf_dvb_s2_bb_matype1_mis
, tvb
,
748 cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, ENC_BIG_ENDIAN
);
749 proto_tree_add_item(dvb_s2_bb_matype1_tree
, hf_dvb_s2_bb_matype1_acm
, tvb
,
750 cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, ENC_BIG_ENDIAN
);
751 proto_tree_add_item(dvb_s2_bb_matype1_tree
, hf_dvb_s2_bb_matype1_issyi
, tvb
,
752 cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, ENC_BIG_ENDIAN
);
753 proto_tree_add_item(dvb_s2_bb_matype1_tree
, hf_dvb_s2_bb_matype1_npd
, tvb
,
754 cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, ENC_BIG_ENDIAN
);
755 proto_tree_add_item(dvb_s2_bb_matype1_tree
, hf_dvb_s2_bb_matype1_ro
, tvb
,
756 cur_off
+ DVB_S2_BB_OFFS_MATYPE1
, 1, ENC_BIG_ENDIAN
);
758 input8
= tvb_get_guint8(tvb
, cur_off
+ DVB_S2_BB_OFFS_MATYPE2
);
761 proto_tree_add_uint_format_value(dvb_s2_bb_tree
, hf_dvb_s2_bb_matype2
, tvb
,
762 cur_off
+ DVB_S2_BB_OFFS_MATYPE2
, 1, input8
, "Input Stream Identifier (ISI): %d",
765 proto_tree_add_uint_format_value(dvb_s2_bb_tree
, hf_dvb_s2_bb_matype2
, tvb
,
766 cur_off
+ DVB_S2_BB_OFFS_MATYPE2
, 1, input8
, "reserved");
769 input16
= tvb_get_ntohs(tvb
, cur_off
+ DVB_S2_BB_OFFS_UPL
);
772 proto_tree_add_uint_format(dvb_s2_bb_tree
, hf_dvb_s2_bb_upl
, tvb
,
773 cur_off
+ DVB_S2_BB_OFFS_UPL
, 2, input16
, "User Packet Length: %d bits (%d bytes)",
774 (guint16
) input16
, (guint16
) input16
/ 8);
776 bb_data_len
= input16
= tvb_get_ntohs(tvb
, cur_off
+ DVB_S2_BB_OFFS_DFL
);
780 proto_tree_add_uint_format_value(dvb_s2_bb_tree
, hf_dvb_s2_bb_dfl
, tvb
,
781 cur_off
+ DVB_S2_BB_OFFS_DFL
, 2, input16
, "%d bits (%d bytes)", input16
, input16
/ 8);
784 proto_tree_add_item(dvb_s2_bb_tree
, hf_dvb_s2_bb_sync
, tvb
, cur_off
+ DVB_S2_BB_OFFS_SYNC
, 1, ENC_BIG_ENDIAN
);
787 proto_tree_add_item(dvb_s2_bb_tree
, hf_dvb_s2_bb_syncd
, tvb
, cur_off
+ DVB_S2_BB_OFFS_SYNCD
, 2, ENC_BIG_ENDIAN
);
789 input8
= tvb_get_guint8(tvb
, cur_off
+ DVB_S2_BB_OFFS_CRC
);
791 if (check_crc8(tvb
, DVB_S2_BB_HEADER_LEN
- 1, cur_off
, input8
)) {
792 proto_tree_add_uint_format(dvb_s2_bb_tree
, hf_dvb_s2_bb_crc
, tvb
,
793 cur_off
+ DVB_S2_BB_OFFS_CRC
, 1, 1, "Checksum: correct (0x%2.2x)", input8
);
795 proto_tree_add_uint_format(dvb_s2_bb_tree
, hf_dvb_s2_bb_crc
, tvb
,
796 cur_off
+ DVB_S2_BB_OFFS_CRC
, 1, -1, "Checksum: incorrect! (0x%2.2x)", input8
);
799 while (bb_data_len
) {
800 /* start DVB-GSE dissector */
801 sub_dissected
= dissect_dvb_s2_gse(tvb
, cur_off
+ new_off
, tree
, pinfo
);
802 new_off
+= sub_dissected
;
804 if ((sub_dissected
<= bb_data_len
) && (sub_dissected
>= DVB_S2_GSE_MINSIZE
)) {
805 bb_data_len
-= sub_dissected
;
806 if (bb_data_len
< DVB_S2_GSE_MINSIZE
)
815 static int dissect_dvb_s2_modeadapt(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
817 int cur_off
= 0, dvb_s2_modeadapt_len
= -1;
820 proto_tree
*dvb_s2_modeadapt_tree
;
821 proto_tree
*dvb_s2_modeadapt_acm_tree
;
825 /* Check that there's enough data */
826 if (tvb_length(tvb
) < 1)
829 /* Check if first byte is valid for this dissector */
830 byte
= tvb_get_guint8(tvb
, DVB_S2_MODEADAPT_OFFS_SYNCBYTE
);
832 if (byte
!= DVB_S2_MODEADAPT_SYNCBYTE
)
835 /* Check if BB-Header CRC is valid and determine input or output */
837 if (test_dvb_s2_crc(tvb
, DVB_S2_MODEADAPT_INSIZE
)) {
838 dvb_s2_modeadapt_len
= 2;
839 } else if (test_dvb_s2_crc(tvb
, DVB_S2_MODEADAPT_OUTSIZE
)) {
840 dvb_s2_modeadapt_len
= 4;
845 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DVB-S2 ");
846 col_set_str(pinfo
->cinfo
, COL_INFO
, "DVB-S2 ");
848 /* create display subtree for the protocol */
849 ti
= proto_tree_add_item(tree
, proto_dvb_s2_modeadapt
, tvb
, 0, dvb_s2_modeadapt_len
, ENC_NA
);
850 dvb_s2_modeadapt_tree
= proto_item_add_subtree(ti
, ett_dvb_s2_modeadapt
);
852 proto_tree_add_item(dvb_s2_modeadapt_tree
, hf_dvb_s2_modeadapt_sync
, tvb
, DVB_S2_MODEADAPT_OFFS_SYNCBYTE
, 1, ENC_BIG_ENDIAN
);
855 tf
= proto_tree_add_item(dvb_s2_modeadapt_tree
, hf_dvb_s2_modeadapt_acm
, tvb
,
856 DVB_S2_MODEADAPT_OFFS_ACMBYTE
, 1, ENC_BIG_ENDIAN
);
858 dvb_s2_modeadapt_acm_tree
= proto_item_add_subtree(tf
, ett_dvb_s2_modeadapt_acm
);
860 proto_tree_add_item(dvb_s2_modeadapt_acm_tree
, hf_dvb_s2_modeadapt_acm_fecframe
, tvb
,
861 DVB_S2_MODEADAPT_OFFS_ACMBYTE
, 1, ENC_BIG_ENDIAN
);
862 proto_tree_add_item(dvb_s2_modeadapt_acm_tree
, hf_dvb_s2_modeadapt_acm_pilot
, tvb
,
863 DVB_S2_MODEADAPT_OFFS_ACMBYTE
, 1, ENC_BIG_ENDIAN
);
864 proto_tree_add_item(dvb_s2_modeadapt_acm_tree
, hf_dvb_s2_modeadapt_acm_modcod
, tvb
,
865 DVB_S2_MODEADAPT_OFFS_ACMBYTE
, 1, ENC_BIG_ENDIAN
);
867 if (dvb_s2_modeadapt_len
> 2) {
869 proto_tree_add_item(dvb_s2_modeadapt_tree
, hf_dvb_s2_modeadapt_cni
, tvb
, DVB_S2_MODEADAPT_OFFS_CNI
, 1, ENC_BIG_ENDIAN
);
872 proto_tree_add_item(dvb_s2_modeadapt_tree
, hf_dvb_s2_modeadapt_frameno
, tvb
, DVB_S2_MODEADAPT_OFFS_FNO
, 1, ENC_BIG_ENDIAN
);
875 /* start DVB-BB dissector */
876 cur_off
= dissect_dvb_s2_bb(tvb
, cur_off
, tree
, pinfo
);
883 /* Register the protocol with Wireshark */
884 void proto_register_dvb_s2_modeadapt(void)
886 module_t
*dvb_s2_modeadapt_module
;
888 static hf_register_info hf_modeadapt
[] = {
889 {&hf_dvb_s2_modeadapt_sync
, {
890 "Sync Byte", "dvb-s2_modeadapt.sync",
891 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
892 "Das Sync Byte", HFILL
}
894 {&hf_dvb_s2_modeadapt_acm
, {
895 "ACM command", "dvb-s2_modeadapt.acmcmd",
896 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
899 {&hf_dvb_s2_modeadapt_acm_fecframe
, {
900 "FEC frame size", "dvb-s2_modeadapt.acmcmd.fecframe",
901 FT_BOOLEAN
, 8, TFS(&tfs_modeadapt_fecframe
), DVB_S2_MODEADAPT_FECFRAME_MASK
,
904 {&hf_dvb_s2_modeadapt_acm_pilot
, {
905 "Pilots configuration", "dvb-s2_modeadapt.acmcmd.pilots",
906 FT_BOOLEAN
, 8, TFS(&tfs_modeadapt_pilots
), DVB_S2_MODEADAPT_PILOTS_MASK
,
909 {&hf_dvb_s2_modeadapt_acm_modcod
, {
910 "Modcod indicator", "dvb-s2_modeadapt.acmcmd.modcod",
911 FT_UINT8
, BASE_DEC
|BASE_EXT_STRING
, &modeadapt_modcods_ext
, DVB_S2_MODEADAPT_MODCODS_MASK
,
914 {&hf_dvb_s2_modeadapt_cni
, {
915 "Carrier to Noise [dB]", "dvb-s2_modeadapt.cni",
916 FT_UINT8
, BASE_DEC
|BASE_EXT_STRING
, &modeadapt_esno_ext
, 0x0,
919 {&hf_dvb_s2_modeadapt_frameno
, {
920 "Frame number", "dvb-s2_modeadapt.frameno",
921 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
926 /* Setup protocol subtree array */
927 static gint
*ett_modeadapt
[] = {
928 &ett_dvb_s2_modeadapt
,
929 &ett_dvb_s2_modeadapt_acm
932 static hf_register_info hf_bb
[] = {
933 {&hf_dvb_s2_bb_matype1
, {
934 "MATYPE1", "dvb-s2_bb.matype1",
935 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
936 "MATYPE1 Header Field", HFILL
}
938 {&hf_dvb_s2_bb_matype1_gs
, {
939 "Stream Input", "dvb-s2_bb.matype1.gs",
940 FT_UINT8
, BASE_DEC
, VALS(bb_gs
), DVB_S2_BB_GS_MASK
,
941 "Transport Stream Input or Generic Stream Input", HFILL
}
943 {&hf_dvb_s2_bb_matype1_mis
, {
944 "Input Stream", "dvb-s2_bb.matype1.mis",
945 FT_BOOLEAN
, 8, TFS(&tfs_bb_mis
), DVB_S2_BB_MIS_MASK
,
946 "Single Input Stream or Multiple Input Stream", HFILL
}
948 {&hf_dvb_s2_bb_matype1_acm
, {
949 "Coding and Modulation", "dvb-s2_bb.matype1.acm",
950 FT_BOOLEAN
, 8, TFS(&tfs_bb_acm
), DVB_S2_BB_ACM_MASK
,
951 "Constant Coding and Modulation or Adaptive Coding and Modulation", HFILL
}
953 {&hf_dvb_s2_bb_matype1_issyi
, {
954 "ISSYI", "dvb-s2_bb.matype1.issyi",
955 FT_BOOLEAN
, 8, TFS(&tfs_bb_issyi
), DVB_S2_BB_ISSYI_MASK
,
956 "Input Stream Synchronization Indicator", HFILL
}
958 {&hf_dvb_s2_bb_matype1_npd
, {
959 "NPD", "dvb-s2_bb.matype1.npd",
960 FT_BOOLEAN
, 8, TFS(&tfs_bb_npd
), DVB_S2_BB_NPD_MASK
,
961 "Null-packet deletion enabled", HFILL
}
963 {&hf_dvb_s2_bb_matype1_ro
, {
964 "RO", "dvb-s2_bb.matype1.ro",
965 FT_UINT8
, BASE_DEC
, VALS(bb_ro
), DVB_S2_BB_RO_MASK
,
966 "Transmission Roll-off factor", HFILL
}
968 {&hf_dvb_s2_bb_matype2
, {
969 "MATYPE2", "dvb-s2_bb.matype2",
970 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
971 "MATYPE2 Header Field", HFILL
}
973 {&hf_dvb_s2_bb_upl
, {
974 "UPL", "dvb-s2_bb.upl",
975 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
976 "User Packet Length", HFILL
}
978 {&hf_dvb_s2_bb_dfl
, {
979 "DFL", "dvb-s2_bb.dfl",
980 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
981 "Data Field Length", HFILL
}
983 {&hf_dvb_s2_bb_sync
, {
984 "SYNC", "dvb-s2_bb.sync",
985 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
986 "Copy of the User Packet Sync-byte", HFILL
}
988 {&hf_dvb_s2_bb_syncd
, {
989 "SYNCD", "dvb-s2_bb.syncd",
990 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
991 "Distance to first user packet", HFILL
}
993 {&hf_dvb_s2_bb_crc
, {
994 "CRC", "dvb-s2_bb.crc",
995 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1000 static gint
*ett_bb
[] = {
1002 &ett_dvb_s2_bb_matype1
1005 /* DVB-S2 GSE Frame */
1006 static hf_register_info hf_gse
[] = {
1007 {&hf_dvb_s2_gse_hdr
, {
1008 "GSE header", "dvb-s2_gse.hdr",
1009 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1010 "GSE Header (start/stop/length)", HFILL
}
1012 {&hf_dvb_s2_gse_hdr_start
, {
1013 "Start", "dvb-s2_gse.hdr.start",
1014 FT_BOOLEAN
, 16, TFS(&tfs_gse_ss
), DVB_S2_GSE_HDR_START_MASK
,
1015 "Start Indicator", HFILL
}
1017 {&hf_dvb_s2_gse_hdr_stop
, {
1018 "Stop", "dvb-s2_gse.hdr.stop",
1019 FT_BOOLEAN
, 16, TFS(&tfs_gse_ss
), DVB_S2_GSE_HDR_STOP_MASK
,
1020 "Stop Indicator", HFILL
}
1022 {&hf_dvb_s2_gse_hdr_labeltype
, {
1023 "Label Type", "dvb-s2_gse.hdr.labeltype",
1024 FT_UINT16
, BASE_HEX
, VALS(gse_labeltype
), DVB_S2_GSE_HDR_LABELTYPE_MASK
,
1025 "Label Type Indicator", HFILL
}
1027 {&hf_dvb_s2_gse_hdr_length
, {
1028 "Length", "dvb-s2_gse.hdr.length",
1029 FT_UINT16
, BASE_DEC
, NULL
, DVB_S2_GSE_HDR_LENGTH_MASK
,
1030 "GSE Length", HFILL
}
1032 {&hf_dvb_s2_gse_proto
, {
1033 "Protocol", "dvb-s2_gse.proto",
1034 FT_UINT16
, BASE_HEX
| BASE_RANGE_STRING
, RVALS(gse_proto_str
), 0x0,
1035 "Protocol Type", HFILL
}
1037 {&hf_dvb_s2_gse_label6
, {
1038 "Label", "dvb-s2_gse.label",
1039 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
1040 "Label Field", HFILL
}
1042 {&hf_dvb_s2_gse_label3
, {
1043 "Label", "dvb-s2_gse.label",
1044 FT_UINT24
, BASE_HEX
, NULL
, 0x0,
1045 "Label Field", HFILL
}
1047 {&hf_dvb_s2_gse_fragid
, {
1048 "Frag ID", "dvb-s2_gse.fragid",
1049 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1050 "Fragment ID", HFILL
}
1052 {&hf_dvb_s2_gse_totlength
, {
1053 "Total Length", "dvb-s2_gse.totlength",
1054 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1055 "GSE Total Frame Length", HFILL
}
1057 {&hf_dvb_s2_gse_exthdr
, {
1058 "Extension Header", "dvb-s2_gse.exthdr",
1059 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1060 "optional Extension Header", HFILL
}
1062 {&hf_dvb_s2_gse_data
, {
1063 "PDU Data", "dvb-s2_gse.data",
1064 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1065 "GSE Frame User Data", HFILL
}
1067 {&hf_dvb_s2_gse_crc32
, {
1068 "CRC", "dvb-s2_gse.crc",
1069 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
1074 static gint
*ett_gse
[] = {
1079 proto_dvb_s2_modeadapt
= proto_register_protocol("DVB-S2 Modeadaption Header", "DVB-S2", "dvb-s2_modeadapt");
1081 proto_dvb_s2_bb
= proto_register_protocol("DVB-S2 Baseband Frame", "DVB-S2-BB", "dvb-s2_bb");
1083 proto_dvb_s2_gse
= proto_register_protocol("DVB-S2 GSE Packet", "DVB-S2-GSE", "dvb-s2_gse");
1085 proto_register_field_array(proto_dvb_s2_modeadapt
, hf_modeadapt
, array_length(hf_modeadapt
));
1086 proto_register_subtree_array(ett_modeadapt
, array_length(ett_modeadapt
));
1088 proto_register_field_array(proto_dvb_s2_bb
, hf_bb
, array_length(hf_bb
));
1089 proto_register_subtree_array(ett_bb
, array_length(ett_bb
));
1091 proto_register_field_array(proto_dvb_s2_gse
, hf_gse
, array_length(hf_gse
));
1092 proto_register_subtree_array(ett_gse
, array_length(ett_gse
));
1094 dvb_s2_modeadapt_module
= prefs_register_protocol(proto_dvb_s2_modeadapt
, proto_reg_handoff_dvb_s2_modeadapt
);
1096 prefs_register_bool_preference(dvb_s2_modeadapt_module
, "enable", "Enable dissector",
1097 "Enable DVB-S2 dissector", &dvb_s2_enable
);
1099 prefs_register_bool_preference(dvb_s2_modeadapt_module
, "full_decode",
1100 "Enable dissection of GSE data",
1101 "Check this to enable full protocol dissection of data above GSE Layer",
1102 &dvb_s2_full_dissection
);
1105 void proto_reg_handoff_dvb_s2_modeadapt(void)
1107 static gboolean prefs_initialized
= FALSE
;
1109 if (!prefs_initialized
) {
1110 heur_dissector_add("udp", dissect_dvb_s2_modeadapt
, proto_dvb_s2_modeadapt
);
1111 ip_handle
= find_dissector("ip");
1112 ipv6_handle
= find_dissector("ipv6");
1113 prefs_initialized
= TRUE
;
1116 proto_set_decoding(proto_dvb_s2_modeadapt
, dvb_s2_enable
);
1120 * Editor modelines - http://www.wireshark.org/tools/modelines.html
1125 * indent-tabs-mode: nil
1128 * vi: set shiftwidth=4 tabstop=8 expandtab:
1129 * :indentSize=4:tabSize=8:noTabs=true: