2 * Routines for AVB-TP (Audio Video Bridging - Transport Protocol) dissection
3 * Copyright 2010, Torrey Atcitty <tatcitty@harman.com>
4 * Dave Olsen <dave.olsen@harman.com>
5 * Levi Pearson <levi.pearson@harman.com>
7 * Copyright 2011, Thomas Bottom <tom.bottom@labxtechnologies.com>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 * The 1722 Protocol specification can be found at the following:
30 * http://grouper.ieee.org/groups/1722/
36 #include <epan/packet.h>
37 #include <epan/etypes.h>
40 #define IEEE_1722_CD_OFFSET 0
41 #define IEEE_1722_VERSION_OFFSET 1
42 #define IEEE_1722_SEQ_NUM_OFFSET 2
43 #define IEEE_1722_TU_FIELD_OFFSET 3
44 #define IEEE_1722_STREAM_ID_OFFSET 4
45 #define IEEE_1722_TIMESTAMP_OFFSET 12
46 #define IEEE_1722_GW_INFO_OFFSET 16
47 #define IEEE_1722_PKT_DATA_LENGTH_OFFSET 20
48 #define IEEE_1722_TAG_OFFSET 22
49 #define IEEE_1722_TCODE_OFFSET 23
50 #define IEEE_1722_SID_OFFSET 24
51 #define IEEE_1722_DBS_OFFSET 25
52 #define IEEE_1722_FN_OFFSET 26
53 #define IEEE_1722_DBC_OFFSET 27
54 #define IEEE_1722_FMT_OFFSET 28
55 #define IEEE_1722_FDF_OFFSET 29
56 #define IEEE_1722_SYT_OFFSET 30
57 #define IEEE_1722_DATA_OFFSET 32
59 #define IEEE_1722_CIP_HEADER_SIZE 8
62 #define IEEE_1722_CD_MASK 0x80
63 #define IEEE_1722_SUBTYPE_MASK 0x7f
64 #define IEEE_1722_SV_MASK 0x80
65 #define IEEE_1722_VER_MASK 0x70
66 #define IEEE_1722_MR_MASK 0x08
67 #define IEEE_1722_GV_MASK 0x02
68 #define IEEE_1722_TV_MASK 0x01
69 #define IEEE_1722_TU_MASK 0x01
70 #define IEEE_1722_TAG_MASK 0xc0
71 #define IEEE_1722_CHANNEL_MASK 0x3f
72 #define IEEE_1722_TCODE_MASK 0xf0
73 #define IEEE_1722_SY_MASK 0x0f
74 #define IEEE_1722_SID_MASK 0x3f
75 #define IEEE_1722_FN_MASK 0xc0
76 #define IEEE_1722_QPC_MASK 0x38
77 #define IEEE_1722_SPH_MASK 0x04
78 #define IEEE_1722_FMT_MASK 0x3f
80 /**********************************************************/
81 /* Initialize the protocol and registered fields */
82 /**********************************************************/
83 static int proto_1722
= -1;
84 static int hf_1722_cdfield
= -1;
85 static int hf_1722_subtype
= -1;
86 static int hf_1722_svfield
= -1;
87 static int hf_1722_verfield
= -1;
88 static int hf_1722_mrfield
= -1;
89 static int hf_1722_gvfield
= -1;
90 static int hf_1722_tvfield
= -1;
91 static int hf_1722_seqnum
= -1;
92 static int hf_1722_tufield
= -1;
93 static int hf_1722_stream_id
= -1;
94 static int hf_1722_avbtp_timestamp
= -1;
95 static int hf_1722_gateway_info
= -1;
96 static int hf_1722_packet_data_length
= -1;
97 static int hf_1722_tag
= -1;
98 static int hf_1722_channel
= -1;
99 static int hf_1722_tcode
= -1;
100 static int hf_1722_sy
= -1;
101 static int hf_1722_sid
= -1;
102 static int hf_1722_dbs
= -1;
103 static int hf_1722_fn
= -1;
104 static int hf_1722_qpc
= -1;
105 static int hf_1722_sph
= -1;
106 static int hf_1722_dbc
= -1;
107 static int hf_1722_fmt
= -1;
108 static int hf_1722_fdf
= -1;
109 static int hf_1722_syt
= -1;
110 static int hf_1722_data
= -1;
111 static int hf_1722_label
= -1;
112 static int hf_1722_sample
= -1;
114 /* Initialize the subtree pointers */
115 static int ett_1722
= -1;
116 static int ett_1722_audio
= -1;
117 static int ett_1722_sample
= -1;
119 static dissector_table_t avb_dissector_table
;
122 dissect_1722(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
125 proto_tree
*ieee1722_tree
= NULL
;
126 proto_tree
*audio_tree
;
127 proto_tree
*sample_tree
;
134 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "IEEE1722");
136 col_set_str(pinfo
->cinfo
, COL_INFO
, "AVB Transportation Protocol");
139 ti
= proto_tree_add_item(tree
, proto_1722
, tvb
, 0, -1, ENC_NA
);
141 ieee1722_tree
= proto_item_add_subtree(ti
, ett_1722
);
143 /* Add the CD and Subtype fields
145 * Subtype field is 7 bits
147 proto_tree_add_item(ieee1722_tree
, hf_1722_cdfield
, tvb
, IEEE_1722_CD_OFFSET
, 1, ENC_BIG_ENDIAN
);
148 proto_tree_add_item(ieee1722_tree
, hf_1722_subtype
, tvb
, IEEE_1722_CD_OFFSET
, 1, ENC_BIG_ENDIAN
);
150 proto_tree_add_item(ieee1722_tree
, hf_1722_svfield
, tvb
, IEEE_1722_VERSION_OFFSET
, 1, ENC_BIG_ENDIAN
);
151 proto_tree_add_item(ieee1722_tree
, hf_1722_verfield
, tvb
, IEEE_1722_VERSION_OFFSET
, 1, ENC_BIG_ENDIAN
);
155 /* Version field ends the common AVTPDU. Now parse the specfic packet type */
156 subtype
= tvb_get_guint8(tvb
, IEEE_1722_CD_OFFSET
);
159 /* call any registered subtype dissectors which use only the common AVTPDU (e.g. 1722.1 and MAAP) */
160 if (dissector_try_uint(avb_dissector_table
, subtype
, tvb
, pinfo
, tree
)) return;
163 proto_tree_add_item(ieee1722_tree
, hf_1722_mrfield
, tvb
, IEEE_1722_VERSION_OFFSET
, 1, ENC_BIG_ENDIAN
);
164 proto_tree_add_item(ieee1722_tree
, hf_1722_gvfield
, tvb
, IEEE_1722_VERSION_OFFSET
, 1, ENC_BIG_ENDIAN
);
165 proto_tree_add_item(ieee1722_tree
, hf_1722_tvfield
, tvb
, IEEE_1722_VERSION_OFFSET
, 1, ENC_BIG_ENDIAN
);
167 /* Add the rest of the packet fields */
168 proto_tree_add_item(ieee1722_tree
, hf_1722_seqnum
, tvb
,
169 IEEE_1722_SEQ_NUM_OFFSET
, 1, ENC_BIG_ENDIAN
);
171 proto_tree_add_item(ieee1722_tree
, hf_1722_tufield
, tvb
,
172 IEEE_1722_TU_FIELD_OFFSET
, 1, ENC_BIG_ENDIAN
);
174 proto_tree_add_item(ieee1722_tree
, hf_1722_stream_id
, tvb
,
175 IEEE_1722_STREAM_ID_OFFSET
, 8, ENC_BIG_ENDIAN
);
177 proto_tree_add_item(ieee1722_tree
, hf_1722_avbtp_timestamp
, tvb
,
178 IEEE_1722_TIMESTAMP_OFFSET
, 4, ENC_BIG_ENDIAN
);
180 proto_tree_add_item(ieee1722_tree
, hf_1722_gateway_info
, tvb
,
181 IEEE_1722_GW_INFO_OFFSET
, 4, ENC_BIG_ENDIAN
);
183 proto_tree_add_item(ieee1722_tree
, hf_1722_packet_data_length
, tvb
,
184 IEEE_1722_PKT_DATA_LENGTH_OFFSET
, 2, ENC_BIG_ENDIAN
);
186 proto_tree_add_item(ieee1722_tree
, hf_1722_tag
, tvb
,
187 IEEE_1722_TAG_OFFSET
, 1, ENC_BIG_ENDIAN
);
188 proto_tree_add_item(ieee1722_tree
, hf_1722_channel
, tvb
,
189 IEEE_1722_TAG_OFFSET
, 1, ENC_BIG_ENDIAN
);
191 proto_tree_add_item(ieee1722_tree
, hf_1722_tcode
, tvb
,
192 IEEE_1722_TCODE_OFFSET
, 1, ENC_BIG_ENDIAN
);
193 proto_tree_add_item(ieee1722_tree
, hf_1722_sy
, tvb
,
194 IEEE_1722_TCODE_OFFSET
, 1, ENC_BIG_ENDIAN
);
196 proto_tree_add_item(ieee1722_tree
, hf_1722_sid
, tvb
,
197 IEEE_1722_SID_OFFSET
, 1, ENC_BIG_ENDIAN
);
199 proto_tree_add_item(ieee1722_tree
, hf_1722_dbs
, tvb
,
200 IEEE_1722_DBS_OFFSET
, 1, ENC_BIG_ENDIAN
);
202 proto_tree_add_item(ieee1722_tree
, hf_1722_fn
, tvb
,
203 IEEE_1722_FN_OFFSET
, 1, ENC_BIG_ENDIAN
);
204 proto_tree_add_item(ieee1722_tree
, hf_1722_qpc
, tvb
,
205 IEEE_1722_FN_OFFSET
, 1, ENC_BIG_ENDIAN
);
206 proto_tree_add_item(ieee1722_tree
, hf_1722_sph
, tvb
,
207 IEEE_1722_FN_OFFSET
, 1, ENC_BIG_ENDIAN
);
209 proto_tree_add_item(ieee1722_tree
, hf_1722_dbc
, tvb
,
210 IEEE_1722_DBC_OFFSET
, 1, ENC_BIG_ENDIAN
);
212 proto_tree_add_item(ieee1722_tree
, hf_1722_fmt
, tvb
,
213 IEEE_1722_FMT_OFFSET
, 1, ENC_BIG_ENDIAN
);
215 proto_tree_add_item(ieee1722_tree
, hf_1722_fdf
, tvb
,
216 IEEE_1722_FDF_OFFSET
, 1, ENC_BIG_ENDIAN
);
218 proto_tree_add_item(ieee1722_tree
, hf_1722_syt
, tvb
,
219 IEEE_1722_SYT_OFFSET
, 2, ENC_BIG_ENDIAN
);
221 /* Calculate the remaining size by subtracting the CIP header size
222 from the value in the packet data length field */
223 datalen
= tvb_get_ntohs(tvb
, IEEE_1722_PKT_DATA_LENGTH_OFFSET
);
224 datalen
-= IEEE_1722_CIP_HEADER_SIZE
;
226 /* Make the Audio sample tree. */
227 ti
= proto_tree_add_item(ieee1722_tree
, hf_1722_data
, tvb
,
228 IEEE_1722_DATA_OFFSET
, datalen
, ENC_NA
);
230 audio_tree
= proto_item_add_subtree(ti
, ett_1722_audio
);
232 /* Need to get the offset of where the audio data starts */
233 offset
= IEEE_1722_DATA_OFFSET
;
234 dbs
= tvb_get_guint8(tvb
, IEEE_1722_DBS_OFFSET
);
236 /* If the DBS is ever 0 for whatever reason, then just add the rest of packet as unknown */
238 proto_tree_add_text(ieee1722_tree
, tvb
, IEEE_1722_DATA_OFFSET
, datalen
, "Incorrect DBS");
241 /* Loop through all samples and add them to the audio tree. */
242 for (j
= 0; j
< (datalen
/ (dbs
*4)); j
++) {
243 ti
= proto_tree_add_text(audio_tree
, tvb
, offset
, 1, "Sample %d", j
+1);
244 sample_tree
= proto_item_add_subtree(ti
, ett_1722_sample
);
245 for (i
= 0; i
< dbs
; i
++) {
246 proto_tree_add_item(sample_tree
, hf_1722_label
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
249 proto_tree_add_item(sample_tree
, hf_1722_sample
, tvb
, offset
, 3, ENC_NA
);
257 /* Register the protocol with Wireshark */
258 void proto_register_1722(void)
260 static hf_register_info hf
[] = {
262 { "Control/Data Indicator", "ieee1722.cdfield",
263 FT_BOOLEAN
, 8, NULL
, IEEE_1722_CD_MASK
, NULL
, HFILL
}
266 { "AVBTP Subtype", "ieee1722.subtype",
267 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_SUBTYPE_MASK
, NULL
, HFILL
}
270 { "AVBTP Stream ID Valid", "ieee1722.svfield",
271 FT_BOOLEAN
, 8, NULL
, IEEE_1722_SV_MASK
, NULL
, HFILL
}
274 { "AVBTP Version", "ieee1722.verfield",
275 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_VER_MASK
, NULL
, HFILL
}
278 { "AVBTP Media Reset", "ieee1722.mrfield",
279 FT_UINT8
, BASE_DEC
, NULL
, IEEE_1722_MR_MASK
, NULL
, HFILL
}
282 { "AVBTP Gateway Info Valid", "ieee1722.gvfield",
283 FT_BOOLEAN
, 8, NULL
, IEEE_1722_GV_MASK
, NULL
, HFILL
}
286 { "Source Timestamp Valid", "ieee1722.tvfield",
287 FT_BOOLEAN
, 8, NULL
, IEEE_1722_TV_MASK
, NULL
, HFILL
}
290 { "Sequence Number", "ieee1722.seqnum",
291 FT_UINT8
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
294 { "AVBTP Timestamp Uncertain", "ieee1722.tufield",
295 FT_BOOLEAN
, 8, NULL
, IEEE_1722_TU_MASK
, NULL
, HFILL
}
297 { &hf_1722_stream_id
,
298 { "Stream ID", "ieee1722.stream_id",
299 FT_UINT64
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
301 { &hf_1722_avbtp_timestamp
,
302 { "AVBTP Timestamp", "ieee1722.avbtp_timestamp",
303 FT_UINT32
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
305 { &hf_1722_gateway_info
,
306 { "Gateway Info", "ieee1722.gateway_info",
307 FT_UINT32
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
309 { &hf_1722_packet_data_length
,
310 { "1394 Packet Data Length", "ieee1722.packet_data_len",
311 FT_UINT16
, BASE_DEC
, NULL
, 0x00, NULL
, HFILL
}
314 { "1394 Packet Format Tag", "ieee1722.tag",
315 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_TAG_MASK
, NULL
, HFILL
}
318 { "1394 Packet Channel", "ieee1722.channel",
319 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_CHANNEL_MASK
, NULL
, HFILL
}
322 { "1394 Packet Tcode", "ieee1722.tcode",
323 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_TCODE_MASK
, NULL
, HFILL
}
326 { "1394 App-specific Control", "ieee1722.sy",
327 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_SY_MASK
, NULL
, HFILL
}
330 { "Source ID", "ieee1722.sid",
331 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_SID_MASK
, NULL
, HFILL
}
334 { "Data Block Size", "ieee1722.dbs",
335 FT_UINT8
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
338 { "Fraction Number", "ieee1722.fn",
339 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_FN_MASK
, NULL
, HFILL
}
342 { "Quadlet Padding Count", "ieee1722.qpc",
343 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_QPC_MASK
, NULL
, HFILL
}
346 { "Source Packet Header", "ieee1722.sph",
347 FT_BOOLEAN
, 8, NULL
, IEEE_1722_SPH_MASK
, NULL
, HFILL
}
350 { "Data Block Continuity", "ieee1722.dbc",
351 FT_UINT8
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
354 { "Format ID", "ieee1722.fmt",
355 FT_UINT8
, BASE_HEX
, NULL
, IEEE_1722_FMT_MASK
, NULL
, HFILL
}
358 { "Format Dependent Field", "ieee1722.fdf",
359 FT_UINT8
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
362 { "SYT", "ieee1722.syt",
363 FT_UINT16
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
366 { "Audio Data", "ieee1722.data",
367 FT_BYTES
, BASE_NONE
, NULL
, 0x00, NULL
, HFILL
}
370 { "Label", "ieee1722.data.sample.label",
371 FT_UINT8
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
374 { "Sample", "ieee1722.data.sample.sampledata",
375 FT_BYTES
, BASE_NONE
, NULL
, 0x00, NULL
, HFILL
}
379 static gint
*ett
[] = {
385 /* Register the protocol name and description */
386 proto_1722
= proto_register_protocol("IEEE 1722 Protocol", "IEEE1722", "ieee1722");
388 /* Required function calls to register the header fields and subtrees used */
389 proto_register_field_array(proto_1722
, hf
, array_length(hf
));
390 proto_register_subtree_array(ett
, array_length(ett
));
392 /* Sub-dissector for 1772.1 */
393 avb_dissector_table
= register_dissector_table("ieee1722.subtype",
394 "IEEE1722 AVBTP Subtype", FT_UINT8
, BASE_HEX
);
397 void proto_reg_handoff_1722(void)
399 dissector_handle_t avbtp_handle
;
401 avbtp_handle
= create_dissector_handle(dissect_1722
, proto_1722
);
402 dissector_add_uint("ethertype", ETHERTYPE_AVBTP
, avbtp_handle
);