2 * HDFS Protocol and dissectors
4 * Copyright (c) 2011 by Isilon Systems.
6 * Author: Allison Obourn <aobourn@isilon.com>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1999 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include <epan/packet.h>
35 #include <epan/dissectors/packet-tcp.h>
36 #include <epan/prefs.h>
39 #define NAMENODE_PORT 8020
42 #define REQUEST_STR "hrpc"
44 #define SEND_DEC 1936027236
45 #define SEND_OFFSET 13
46 #define HEAR_DEC 1214603634
48 #define TBEA_DEC 1952605537
53 #define FIRST_READ_FRAGMENT_LEN 15
54 #define SECOND_READ_FRAGMENT_LEN 29
58 static const int START
= 0;
59 static const int AUTHENTICATION
= 1;
60 static const int DATA
= 2;
63 static guint tcp_port
= 0;
65 static int proto_hdfs
= -1;
66 static int hf_hdfs_pdu_type
= -1;
67 static int hf_hdfs_flags
= -1;
68 static int hf_hdfs_sequenceno
= -1;
69 static int hf_hdfs_packetno
= -1;
70 static int hf_hdfs_authlen
= -1;
71 static int hf_hdfs_success
= -1;
72 static int hf_hdfs_auth
= -1;
73 static int hf_hdfs_len
= -1;
74 static int hf_hdfs_strcall
= -1;
75 static int hf_hdfs_params
= -1;
76 static int hf_hdfs_paramtype
= -1;
77 static int hf_hdfs_paramval
= -1;
78 static int hf_hdfs_paramvalnum
= -1;
79 /* static int hf_hdfs_rest = -1; */
80 static int hf_hdfs_fileperm
= -1;
81 static int hf_hdfs_blockloc
= -1;
82 static int hf_hdfs_endblockloc
= -1;
83 static int hf_hdfs_blockgen
= -1;
84 static int hf_hdfs_prover
= -1;
85 static int hf_hdfs_objname
= -1;
86 static int hf_hdfs_filename
= -1;
87 static int hf_hdfs_blockcount
= -1;
88 static int hf_hdfs_ownername
= -1;
89 static int hf_hdfs_groupname
= -1;
90 static int hf_hdfs_namelenone
= -1;
91 static int hf_hdfs_namelentwo
= -1;
92 static int hf_hdfs_accesstime
= -1;
93 static int hf_hdfs_modtime
= -1;
94 static int hf_hdfs_blockrep
= -1;
95 static int hf_hdfs_isdir
= -1;
96 static int hf_hdfs_blocksize
= -1;
97 static int hf_hdfs_filelen
= -1;
98 static int hf_hdfs_construct
= -1;
99 static int hf_hdfs_hostname
= -1;
100 static int hf_hdfs_rackloc
= -1;
101 static int hf_hdfs_adminstate
= -1;
102 static int hf_hdfs_activecon
= -1;
103 static int hf_hdfs_lastupdate
= -1;
104 static int hf_hdfs_remaining
= -1;
105 static int hf_hdfs_dfsused
= -1;
106 static int hf_hdfs_capacity
= -1;
107 static int hf_hdfs_ipcport
= -1;
108 static int hf_hdfs_infoport
= -1;
109 static int hf_hdfs_storageid
= -1;
110 static int hf_hdfs_datanodeid
= -1;
111 static int hf_hdfs_locations
= -1;
112 static int hf_hdfs_offset
= -1;
113 static int hf_hdfs_corrupt
= -1;
114 static int hf_hdfs_identifier
= -1;
115 static int hf_hdfs_password
= -1;
116 static int hf_hdfs_kind
= -1;
117 static int hf_hdfs_service
= -1;
119 static gint ett_hdfs
= -1;
121 static dissector_handle_t hdfs_handle
;
123 void proto_reg_handoff_hdfs(void);
125 /* Parses the parameters of a function.
126 Parses the type length which is always in 2 bytes.
127 Next the type which is the previously found length.
128 If this type is variable length it then reads the length of the data
129 from 2 bytes and then the data.
130 Otherwise reads just the data. */
132 dissect_params (tvbuff_t
*tvb
, proto_tree
*hdfs_tree
, guint offset
, int params
) {
136 const guint8
* type_name
;
137 for (i
= 0; i
< params
; i
++) {
139 /* get length that we just dissected */
140 length
= tvb_get_ntohs(tvb
, offset
);
142 /* 2 bytes = parameter type length */
143 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
146 /* length bytes = parameter type */
147 proto_tree_add_item(hdfs_tree
, hf_hdfs_paramtype
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
150 if (offset
>= length
&& (!tvb_memeql(tvb
, offset
- length
, "long", length
) || !tvb_memeql(tvb
, offset
- length
, "int", length
) ||
151 !tvb_memeql(tvb
, offset
- length
, "short", length
) || !tvb_memeql(tvb
, offset
- length
, "char", length
) ||
152 !tvb_memeql(tvb
, offset
- length
, "byte", length
) || !tvb_memeql(tvb
, offset
- length
, "float", length
)
153 || !tvb_memeql(tvb
, offset
- length
, "double", length
) || !tvb_memeql(tvb
, offset
- length
, "boolean", length
))) {
155 if (!tvb_memeql(tvb
, offset
- length
, "boolean", length
)) {
157 } else if (!tvb_memeql(tvb
, offset
- length
, "short", length
)) {
160 length
= sizeof(type_name
);
163 proto_tree_add_item(hdfs_tree
, hf_hdfs_paramvalnum
, tvb
, offset
, length
, ENC_BIG_ENDIAN
);
168 length
= tvb_get_ntohs(tvb
, offset
);
170 /* 2 bytes = parameter value length */
171 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
174 proto_tree_add_item(hdfs_tree
, hf_hdfs_paramval
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
177 if (!tvb_memeql(tvb
, offset
- length
, "org.apache.hadoop.fs.permission.FsPermission", length
)) {
178 proto_tree_add_item(hdfs_tree
, hf_hdfs_fileperm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
186 /* Dissects a data packet of the form:
187 method name length : 2B
188 method name : above value
189 number of parameters : 4B
190 -- list of parameters the length of above --
191 parameter type length : 2B
192 parameter type : above value
193 -- if the type is variable size --
194 parameter value length : 2B
195 parameter value : above value
197 parameter value : length of the type */
199 dissect_data (tvbuff_t
*tvb
, proto_tree
*hdfs_tree
, guint offset
) {
204 length
= tvb_get_ntohs(tvb
, offset
);
206 /* method name length = 2 B */
207 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
210 /* length bytes = method name */
211 proto_tree_add_item(hdfs_tree
, hf_hdfs_strcall
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
214 /* we only want to parse the packet if it is not a heartbeat (random looking numbers are the decimal
215 representation of sendHeartbeat */
216 if (!(tvb_get_ntohl(tvb
, offset
- SEND_OFFSET
) == SEND_DEC
&& tvb_get_ntohl(tvb
, offset
- HEAR_OFFSET
) == HEAR_DEC
&&
217 tvb_get_ntohl(tvb
, offset
- TBEA_OFFSET
) == TBEA_DEC
&& tvb_get_guint8(tvb
, offset
- T_OFFSET
) == T_DEC
)) {
219 /* get number of params */
220 params
= tvb_get_ntohl(tvb
, offset
);
222 /* 4 bytes = # of parameters */
223 proto_tree_add_item(hdfs_tree
, hf_hdfs_params
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
226 /* go through all params and dissect their type length, type, value length and value */
227 dissect_params (tvb
, hdfs_tree
, offset
, params
);
232 response to a get protocol version message
233 contains a type length, type name and the value
236 dissect_resp_long (tvbuff_t
*tvb
, proto_tree
*hdfs_tree
, int offset
) {
237 /* get length that we just dissected */
238 int length
= tvb_get_ntohs(tvb
, offset
);
240 /* 2 bytes = parameter type length */
241 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
244 /* length bytes = parameter type */
245 proto_tree_add_item(hdfs_tree
, hf_hdfs_paramtype
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
249 proto_tree_add_item(hdfs_tree
, hf_hdfs_prover
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
256 Response to a file status message
259 dissect_resp_filestatus (tvbuff_t
*tvb
, proto_tree
*hdfs_tree
, int offset
) {
264 proto_tree_add_item(hdfs_tree
, hf_hdfs_fileperm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
268 length
= tvb_get_ntohs(tvb
, offset
);
270 /* 2 bytes = file name length */
271 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
275 proto_tree_add_item(hdfs_tree
, hf_hdfs_filename
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
279 /* 8 file size / end location */
280 proto_tree_add_item(hdfs_tree
, hf_hdfs_endblockloc
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
284 proto_tree_add_item(hdfs_tree
, hf_hdfs_isdir
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
287 /* block replication factor */
288 proto_tree_add_item(hdfs_tree
, hf_hdfs_blockrep
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
292 proto_tree_add_item(hdfs_tree
, hf_hdfs_blocksize
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
296 proto_tree_add_item(hdfs_tree
, hf_hdfs_modtime
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
300 proto_tree_add_item(hdfs_tree
, hf_hdfs_accesstime
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
303 /* 2 of file permissions */
304 proto_tree_add_item(hdfs_tree
, hf_hdfs_fileperm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
309 length
= tvb_get_guint8 (tvb
, offset
);
311 /* owner name length */
312 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
316 proto_tree_add_item(hdfs_tree
, hf_hdfs_ownername
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
320 length
= tvb_get_guint8 (tvb
, offset
);
322 /* group name length */
323 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
327 proto_tree_add_item(hdfs_tree
, hf_hdfs_groupname
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
335 Response to the get block info message
336 parses the sent back information about each blcok
339 dissect_block_info (tvbuff_t
*tvb
, proto_tree
*hdfs_tree
, int offset
) {
343 length
= tvb_get_guint8(tvb
, offset
);
345 /* identifier length */
346 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
350 proto_tree_add_item(hdfs_tree
, hf_hdfs_identifier
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
353 length
= tvb_get_guint8(tvb
, offset
);
355 /* password length */
356 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
360 proto_tree_add_item(hdfs_tree
, hf_hdfs_password
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
363 length
= tvb_get_guint8(tvb
, offset
);
366 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
370 proto_tree_add_item(hdfs_tree
, hf_hdfs_kind
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
373 length
= tvb_get_guint8(tvb
, offset
);
376 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
380 proto_tree_add_item(hdfs_tree
, hf_hdfs_service
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
384 proto_tree_add_item(hdfs_tree
, hf_hdfs_corrupt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
388 proto_tree_add_item(hdfs_tree
, hf_hdfs_offset
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
392 /* block info section */
395 proto_tree_add_item(hdfs_tree
, hf_hdfs_blockloc
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
399 proto_tree_add_item(hdfs_tree
, hf_hdfs_blocksize
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
403 proto_tree_add_item(hdfs_tree
, hf_hdfs_blockgen
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
407 proto_tree_add_item(hdfs_tree
, hf_hdfs_locations
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
411 /* address section */
414 length
= tvb_get_ntohs(tvb
, offset
);
417 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
421 proto_tree_add_item(hdfs_tree
, hf_hdfs_datanodeid
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
424 length
= tvb_get_ntohs(tvb
, offset
);
427 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
431 proto_tree_add_item(hdfs_tree
, hf_hdfs_storageid
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
435 proto_tree_add_item(hdfs_tree
, hf_hdfs_infoport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
439 /* default name node port */
440 proto_tree_add_item(hdfs_tree
, hf_hdfs_ipcport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
444 proto_tree_add_item(hdfs_tree
, hf_hdfs_capacity
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
448 proto_tree_add_item(hdfs_tree
, hf_hdfs_dfsused
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
452 proto_tree_add_item(hdfs_tree
, hf_hdfs_remaining
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
456 proto_tree_add_item(hdfs_tree
, hf_hdfs_lastupdate
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
459 /* num active connections */
460 proto_tree_add_item(hdfs_tree
, hf_hdfs_activecon
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
464 length
= tvb_get_guint8(tvb
, offset
);
466 /* location rack length */
467 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
471 proto_tree_add_item(hdfs_tree
, hf_hdfs_rackloc
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
474 length
= tvb_get_guint8(tvb
, offset
);
476 /* hostname length */
477 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
481 proto_tree_add_item(hdfs_tree
, hf_hdfs_hostname
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
484 length
= tvb_get_guint8(tvb
, offset
);
486 /* admin state length */
487 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelenone
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
491 proto_tree_add_item(hdfs_tree
, hf_hdfs_adminstate
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
501 dissects the response from get block info.
504 dissect_resp_locatedblocks (tvbuff_t
*tvb
, proto_tree
*hdfs_tree
, int offset
) {
507 /* file length = 8 */
508 proto_tree_add_item(hdfs_tree
, hf_hdfs_filelen
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
511 /* under construction = 1 */
512 proto_tree_add_item(hdfs_tree
, hf_hdfs_construct
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
515 /* number of blocks */
516 proto_tree_add_item(hdfs_tree
, hf_hdfs_blockcount
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
519 /* dissect info for each block */
520 while (tvb_reported_length(tvb
) - offset
> 0) {
521 offset
= dissect_block_info (tvb
, hdfs_tree
, offset
);
528 dissect_hdfs_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
535 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "HDFS");
536 /* Clear out stuff in the info column */
537 col_clear(pinfo
->cinfo
,COL_INFO
);
541 proto_item
*ti
= NULL
;
542 proto_tree
*hdfs_tree
= NULL
;
544 ti
= proto_tree_add_item(tree
, proto_hdfs
, tvb
, 0, -1, ENC_NA
);
545 hdfs_tree
= proto_item_add_subtree(ti
, ett_hdfs
);
548 if (pinfo
->srcport
== tcp_port
) {
549 /* 4 bytes = sequence number */
550 proto_tree_add_item(hdfs_tree
, hf_hdfs_packetno
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
553 /* 4 bytes = status -> 0000 = success, 0001 = error, ffff = fatal */
554 success
= tvb_get_ntohl(tvb
, offset
);
555 proto_tree_add_item(hdfs_tree
, hf_hdfs_success
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
562 if (!tvb_memeql(tvb
, offset
+ 2, "long", 4)) {
563 dissect_resp_long (tvb
, hdfs_tree
, offset
);
567 /* name length = 2 B */
568 length
= tvb_get_ntohs(tvb
, offset
);
569 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
572 /* length bytes = method name */
573 proto_tree_add_item(hdfs_tree
, hf_hdfs_objname
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
576 /* get length that we just dissected */
577 length
= tvb_get_ntohs(tvb
, offset
);
579 /* 2 bytes = objects length */
580 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
583 /* length bytes = object name */
584 proto_tree_add_item(hdfs_tree
, hf_hdfs_objname
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
587 /* responses about block location info */
588 if (!tvb_memeql(tvb
, offset
- length
, "org.apache.hadoop.hdfs.protocol.LocatedBlocks", length
)) {
589 dissect_resp_locatedblocks (tvb
, hdfs_tree
, offset
);
591 /* responses about file statuses */
592 } else if (!tvb_memeql(tvb
, offset
- length
, "org.apache.hadoop.hdfs.protocol.HdfsFileStatus", length
)) {
593 dissect_resp_filestatus (tvb
, hdfs_tree
, offset
);
597 length
= tvb_get_ntohs(tvb
, offset
);
599 /* 2 bytes = parameter value length */
600 proto_tree_add_item(hdfs_tree
, hf_hdfs_namelentwo
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
603 /* the value of the parameter */
604 proto_tree_add_item(hdfs_tree
, hf_hdfs_paramval
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
605 /*offset += length;*/
609 /* Request to namenode */
612 /* check the packet length */
613 guint auth
= tvb_get_ntohl(tvb
, offset
);
615 /* first setup packet starts with "hrpc" */
616 if (!tvb_memeql(tvb
, offset
, REQUEST_STR
, sizeof(REQUEST_STR
) - 1)) {
618 proto_tree_add_item(hdfs_tree
, hf_hdfs_sequenceno
, tvb
, offset
, sizeof(REQUEST_STR
) - 1, ENC_ASCII
|ENC_NA
);
619 offset
+= (int)sizeof(REQUEST_STR
) - 1;
621 proto_tree_add_item(hdfs_tree
, hf_hdfs_pdu_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
624 proto_tree_add_item(hdfs_tree
, hf_hdfs_flags
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
628 /* second authentication packet */
629 if (auth
+ 4 != tvb_reported_length(tvb
)) {
631 /* authentication length (read out of first 4 bytes) */
632 length
= tvb_get_ntohl(tvb
, offset
);
633 proto_tree_add_item(hdfs_tree
, hf_hdfs_authlen
, tvb
, offset
, 4, ENC_ASCII
|ENC_NA
);
636 /* authentication (length the number we just got) */
637 proto_tree_add_item(hdfs_tree
, hf_hdfs_auth
, tvb
, offset
, length
, ENC_ASCII
|ENC_NA
);
643 /* 4 bytes = length */
644 proto_tree_add_item(hdfs_tree
, hf_hdfs_len
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
647 /* 4 bytes = sequence number */
648 proto_tree_add_item(hdfs_tree
, hf_hdfs_packetno
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
651 /* dissect packet data */
652 dissect_data (tvb
, hdfs_tree
, offset
);
656 return tvb_length(tvb
);
659 /* determine PDU length of protocol */
660 static guint
get_hdfs_message_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset _U_
)
662 int len
= tvb_reported_length(tvb
);
664 if (tvb_reported_length(tvb
) == 1448 || tvb_reported_length(tvb
) == 1321) {
665 len
= 150 * tvb_get_ntohs(tvb
, 113) + 115 ;
673 dissect_hdfs(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
675 int frame_header_len
= 0;
676 gboolean need_reassemble
= FALSE
;
678 frame_header_len
= tvb_reported_length(tvb
);
680 if (frame_header_len
== 1448 || frame_header_len
== 1321) {
681 need_reassemble
= TRUE
;
684 tcp_dissect_pdus(tvb
, pinfo
, tree
, need_reassemble
, frame_header_len
, get_hdfs_message_len
, dissect_hdfs_message
, data
);
685 return tvb_length(tvb
);
688 /* registers the protcol with the given names */
690 proto_register_hdfs(void)
693 static hf_register_info hf
[] = {
695 /* list of all options for dissecting the protocol */
697 /*************************************************
699 **************************************************/
700 { &hf_hdfs_sequenceno
,
701 { "HDFS protocol type", "hdfs.type",
702 FT_STRING
, BASE_NONE
,
707 { "HDFS protocol version", "hdfs.version",
713 { "HDFS authentication type", "hdfs.auth_type",
718 /***********************************************
719 Authentication packet
720 ***********************************************/
722 { "HDFS authentication length", "hdfs.authlen",
723 FT_STRING
, BASE_NONE
,
728 { "HDFS authorization bits", "hdfs.auth",
729 FT_STRING
, BASE_NONE
,
733 /**********************************************
735 **********************************************/
737 { "HDFS packet number", "hdfs.seqno",
743 { "HDFS success", "hdfs.success",
749 { "HDFS method name", "hdfs.strcall",
750 FT_STRING
, BASE_NONE
,
756 { "HDFS value", "hdfs.rest",
757 FT_STRING
, BASE_NONE
,
763 { "HDFS block location", "hdfs.blockloc",
768 { &hf_hdfs_blocksize
,
769 { "HDFS block size", "hdfs.blocksize",
774 { &hf_hdfs_endblockloc
,
775 { "HDFS file size", "hdfs.endblockloc",
781 { "HDFS block gen", "hdfs.blockgen",
787 { "HDFS protocol version", "hdfs.prover",
793 { "HDFS object name", "hdfs.objname",
794 FT_STRING
, BASE_NONE
,
799 { "HDFS file name", "hdfs.filename",
800 FT_STRING
, BASE_NONE
,
804 { &hf_hdfs_blockcount
,
805 { "HDFS block count", "hdfs.blockcount",
810 { &hf_hdfs_ownername
,
811 { "HDFS owner name", "hdfs.ownername",
812 FT_STRING
, BASE_NONE
,
816 { &hf_hdfs_groupname
,
817 { "HDFS group name", "hdfs.groupname",
818 FT_STRING
, BASE_NONE
,
822 { &hf_hdfs_accesstime
,
823 { "HDFS access time", "hdfs.accesstime",
829 { "HDFS modified time", "hdfs.modtime",
835 { "HDFS block replication factor", "hdfs.blockrep",
841 { "HDFS is directory", "hdfs.isdir",
847 { "HDFS file length", "hdfs.filelen",
852 { &hf_hdfs_construct
,
853 { "HDFS under construction", "hdfs.construct",
859 { "HDFS rack location", "hdfs.rackloc",
860 FT_STRING
, BASE_NONE
,
864 { &hf_hdfs_adminstate
,
865 { "HDFS admin state", "hdfs.adminstate",
866 FT_STRING
, BASE_NONE
,
871 { "HDFS hostname", "hdfs.hostname",
872 FT_STRING
, BASE_NONE
,
878 { &hf_hdfs_namelenone
,
879 { "HDFS name length", "hdfs.namelenone",
884 { &hf_hdfs_namelentwo
,
885 { "HDFS name length", "hdfs.namelentwo",
892 /***************************************
894 ***************************************/
895 { &hf_hdfs_activecon
,
896 { "HDFS active connections", "hdfs.activecon",
901 { &hf_hdfs_lastupdate
,
902 { "HDFS lastupdate", "hdfs.lastupdate",
907 { &hf_hdfs_remaining
,
908 { "HDFS remaining", "hdfs.remaining",
914 { "HDFS dfs used", "hdfs.dfsused",
920 { "HDFS capacity", "hdfs.capacity",
926 { "HDFS ipcport", "hdfs.ipcport",
932 { "HDFS info port", "hdfs.infoport",
937 { &hf_hdfs_storageid
,
938 { "HDFS storage id", "hdfs.storageid",
939 FT_STRING
, BASE_NONE
,
943 { &hf_hdfs_datanodeid
,
944 { "HDFS datanodeid", "hdfs.datanodeid",
945 FT_STRING
, BASE_NONE
,
949 { &hf_hdfs_locations
,
950 { "HDFS locations", "hdfs.locations",
956 { &hf_hdfs_identifier
,
957 { "HDFS locations", "hdfs.identifier",
958 FT_STRING
, BASE_NONE
,
963 { "HDFS password", "hdfs.password",
964 FT_STRING
, BASE_NONE
,
969 { "HDFS kind", "hdfs.kind",
970 FT_STRING
, BASE_NONE
,
975 { "HDFS locations", "hdfs.service",
976 FT_STRING
, BASE_NONE
,
981 { "HDFS corrupt", "hdfs.corrupt",
987 { "HDFS offset", "hdfs.offset",
994 /***********************************************
996 ***********************************************/
998 { "HDFS length", "hdfs.len",
1003 /* packet number, same as in response
1004 method name length, same as in response
1005 string call, same as in response */
1007 { "HDFS number of parameters", "hdfs.params",
1008 FT_UINT32
, BASE_DEC
,
1012 { &hf_hdfs_paramtype
,
1013 { "HDFS parameter type", "hdfs.paramtype",
1014 FT_STRING
, BASE_NONE
,
1018 { &hf_hdfs_paramval
,
1019 { "HDFS parameter value", "hdfs.paramval",
1020 FT_STRING
, BASE_NONE
,
1024 /* param value that is displayed as a number not a string */
1025 { &hf_hdfs_paramvalnum
,
1026 { "HDFS parameter value", "hdfs.paramvalnum",
1031 { &hf_hdfs_fileperm
,
1032 { "HDFS File permission", "hdfs.fileperm",
1040 /* Setup protocol subtree array */
1041 static gint
*ett
[] = {
1045 module_t
*hdfs_module
;
1047 proto_hdfs
= proto_register_protocol (
1048 "HDFS Protocol", /* name */
1049 "HDFS", /* short name */
1053 proto_register_field_array(proto_hdfs
, hf
, array_length(hf
));
1054 proto_register_subtree_array(ett
, array_length(ett
));
1056 hdfs_module
= prefs_register_protocol(proto_hdfs
, proto_reg_handoff_hdfs
);
1058 prefs_register_uint_preference(hdfs_module
,
1060 "TCP port for HDFS",
1061 "Set the TCP port for HDFS",
1065 hdfs_handle
= new_register_dissector("hdfs", dissect_hdfs
, proto_hdfs
);
1068 /* registers handoff */
1070 proto_reg_handoff_hdfs(void)
1072 static gboolean initialized
= FALSE
;
1073 static guint saved_tcp_port
;
1076 dissector_add_handle("tcp.port", hdfs_handle
); /* for "decode as" */
1078 } else if (saved_tcp_port
!= 0) {
1079 dissector_delete_uint("tcp.port", saved_tcp_port
, hdfs_handle
);
1082 if (tcp_port
!= 0) {
1083 dissector_add_uint("tcp.port", tcp_port
, hdfs_handle
);
1086 saved_tcp_port
= tcp_port
;
1094 * indent-tabs-mode: nil
1097 * ex: set shiftwidth=4 tabstop=8 expandtab:
1098 * :indentSize=4:tabSize=8:noTabs=true: