2 * Routines for fmp dissection
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <epan/packet.h>
15 #include "packet-rpc.h"
16 #include "packet-fmp.h"
18 void proto_register_fmp_notify(void);
19 void proto_reg_handoff_fmp_notify(void);
21 #define FMP_NOTIFY_PROG 1001912
22 #define FMP_NOTIFY_VERSION_2 2
25 * FMP/NOTIFY Procedures
27 #define FMP_NOTIFY_DownGrade 1
28 #define FMP_NOTIFY_RevokeList 2
29 #define FMP_NOTIFY_RevokeAll 3
30 #define FMP_NOTIFY_FileSetEof 4
31 #define FMP_NOTIFY_RequestDone 5
32 #define FMP_NOTIFY_volFreeze 6
33 #define FMP_NOTIFY_revokeHandleList 7
36 FMP_LIST_USER_QUOTA_EXCEEDED
= 0,
37 FMP_LIST_GROUP_QUOTA_EXCEEDED
= 1,
38 FMP_LIST_SERVER_RESOURCE_LOW
= 2
39 } revokeHandleListReason
;
41 static int proto_fmp_notify
;
42 static int hf_fmp_handleListLen
;
43 static int hf_fmp_notify_procedure
;
44 static int hf_fmp_fsID
;
45 /* static int hf_fmp_fsBlkSz; */
46 static int hf_fmp_sessionHandle
;
47 static int hf_fmp_fmpFHandle
;
48 static int hf_fmp_msgNum
;
49 static int hf_fmp_fileSize
;
50 static int hf_fmp_cookie
;
51 static int hf_fmp_firstLogBlk
;
52 static int hf_fmp_numBlksReq
;
53 static int hf_fmp_status
;
54 static int hf_fmp_extentList_len
;
55 static int hf_fmp_numBlks
;
56 static int hf_fmp_volID
;
57 static int hf_fmp_startOffset
;
58 static int hf_fmp_extent_state
;
59 static int hf_fmp_revokeHandleListReason
;
61 static int ett_fmp_notify
;
62 static int ett_fmp_notify_hlist
;
63 static int ett_fmp_extList
;
64 static int ett_fmp_ext
;
67 static int dissect_fmp_notify_extentList(tvbuff_t
*, int, packet_info
*, proto_tree
*);
70 dissect_fmp_notify_status(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
, int *rval
)
74 status
= (fmpStat
)tvb_get_ntohl(tvb
, offset
);
98 case FMP_WRONG_MSG_NUM
:
101 case FMP_SESSION_LOST
:
104 case FMP_HOT_SESSION
:
108 case FMP_COLD_SESSION
:
111 case FMP_CLIENT_TERMINATED
:
114 case FMP_WRITER_LOST_BLK
:
117 case FMP_REQUEST_QUEUED
:
123 case FMP_REQUEST_CANCELLED
:
127 case FMP_WRITER_ZEROED_BLK
:
130 case FMP_NOTIFY_ERROR
:
133 case FMP_WRONG_HANDLE
:
136 case FMP_DUPLICATE_OPEN
:
139 case FMP_PLUGIN_NOFUNC
:
147 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_status
, offset
);
153 dissect_revokeHandleListReason(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
155 proto_tree_add_item(tree
, hf_fmp_revokeHandleListReason
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
161 dissect_handleList(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
168 proto_tree
*handleListTree
;
170 numHandles
= tvb_get_ntohl(tvb
, offset
);
173 for (i
= 0; i
< numHandles
; i
++) {
174 listLength
+= (4 + tvb_get_ntohl(tvb
, offset
+ listLength
));
177 handleListTree
= proto_tree_add_subtree(tree
, tvb
, offset
, listLength
,
178 ett_fmp_notify_hlist
, NULL
, "Handle List");
180 offset
= dissect_rpc_uint32(tvb
, handleListTree
,
181 hf_fmp_handleListLen
, offset
);
183 for (i
= 0; i
< numHandles
; i
++) {
184 offset
= dissect_rpc_data(tvb
, handleListTree
,
185 hf_fmp_fmpFHandle
, offset
);/* changed */
192 dissect_FMP_NOTIFY_DownGrade_request(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
196 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_sessionHandle
,
198 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_fmpFHandle
, offset
);
199 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_msgNum
, offset
);
200 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_firstLogBlk
,
202 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_numBlksReq
, offset
);
207 dissect_FMP_NOTIFY_DownGrade_reply(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
211 return dissect_fmp_notify_status(tvb
, 0,tree
, &rval
);
215 dissect_FMP_NOTIFY_RevokeList_request(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
219 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_sessionHandle
,
221 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_fmpFHandle
, offset
);
222 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_msgNum
, offset
);
223 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_firstLogBlk
,
225 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_numBlksReq
, offset
);
230 dissect_FMP_NOTIFY_RevokeList_reply(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
234 return dissect_fmp_notify_status(tvb
, 0, tree
, &rval
);
238 dissect_FMP_NOTIFY_RevokeAll_request(tvbuff_t
*tvb
,
239 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
242 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_sessionHandle
,
244 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_fmpFHandle
, offset
);
245 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_msgNum
, offset
);
250 dissect_FMP_NOTIFY_RevokeAll_reply(tvbuff_t
*tvb
,
251 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
255 return dissect_fmp_notify_status(tvb
, 0, tree
, &rval
);
259 dissect_FMP_NOTIFY_FileSetEof_request(tvbuff_t
*tvb
,
260 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
263 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_sessionHandle
,
265 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_fmpFHandle
, offset
);
266 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_msgNum
, offset
);
267 offset
= dissect_rpc_uint64(tvb
, tree
, hf_fmp_fileSize
, offset
);
272 dissect_FMP_NOTIFY_FileSetEof_reply(tvbuff_t
*tvb
,
273 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
277 return dissect_fmp_notify_status(tvb
, 0, tree
, &rval
);
281 dissect_FMP_NOTIFY_RequestDone_request(tvbuff_t
*tvb
,
282 packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
287 offset
= dissect_fmp_notify_status(tvb
, offset
,tree
, &rval
);
289 offset
= dissect_rpc_data(tvb
, tree
,
290 hf_fmp_sessionHandle
, offset
);
291 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_fmpFHandle
,
293 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_msgNum
,
295 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_cookie
,
297 offset
= dissect_fmp_notify_extentList(tvb
, offset
, pinfo
, tree
);
303 dissect_FMP_NOTIFY_RequestDone_reply(tvbuff_t
*tvb
,
304 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
308 return dissect_fmp_notify_status(tvb
, 0, tree
, &rval
);
312 dissect_FMP_NOTIFY_volFreeze_request(tvbuff_t
*tvb
,
313 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
317 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_sessionHandle
,
319 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_fsID
, offset
);
324 dissect_FMP_NOTIFY_volFreeze_reply(tvbuff_t
*tvb
,
325 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
329 return dissect_fmp_notify_status(tvb
, 0, tree
, &rval
);
333 dissect_FMP_NOTIFY_revokeHandleList_request(tvbuff_t
*tvb
,
334 packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
338 offset
= dissect_rpc_data(tvb
, tree
, hf_fmp_sessionHandle
,
340 offset
= dissect_revokeHandleListReason(tvb
, offset
, tree
);
341 offset
= dissect_handleList(tvb
, offset
, pinfo
, tree
);
346 dissect_FMP_NOTIFY_revokeHandleList_reply(tvbuff_t
*tvb
,
347 packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
351 return dissect_fmp_notify_status(tvb
, 0, tree
, &rval
);
355 * proc number, "proc name", dissect_request, dissect_reply
357 static const vsff fmp_notify2_proc
[] = {
362 { FMP_NOTIFY_DownGrade
, "DownGrade",
363 dissect_FMP_NOTIFY_DownGrade_request
,
364 dissect_FMP_NOTIFY_DownGrade_reply
},
366 { FMP_NOTIFY_RevokeList
, "RevokeList",
367 dissect_FMP_NOTIFY_RevokeList_request
,
368 dissect_FMP_NOTIFY_RevokeList_reply
},
370 { FMP_NOTIFY_RevokeAll
, "RevokeAll",
371 dissect_FMP_NOTIFY_RevokeAll_request
,
372 dissect_FMP_NOTIFY_RevokeAll_reply
},
374 { FMP_NOTIFY_FileSetEof
, "FileSetEof",
375 dissect_FMP_NOTIFY_FileSetEof_request
,
376 dissect_FMP_NOTIFY_FileSetEof_reply
},
378 { FMP_NOTIFY_RequestDone
, "RequestDone",
379 dissect_FMP_NOTIFY_RequestDone_request
,
380 dissect_FMP_NOTIFY_RequestDone_reply
},
382 { FMP_NOTIFY_volFreeze
, "volFreeze",
383 dissect_FMP_NOTIFY_volFreeze_request
,
384 dissect_FMP_NOTIFY_volFreeze_reply
},
386 { FMP_NOTIFY_revokeHandleList
, "revokeHandleList",
387 dissect_FMP_NOTIFY_revokeHandleList_request
,
388 dissect_FMP_NOTIFY_revokeHandleList_reply
},
390 { 0, NULL
, NULL
, NULL
}
393 static const rpc_prog_vers_info fmp_notify_vers_info
[] = {
394 { FMP_NOTIFY_VERSION_2
, fmp_notify2_proc
, &hf_fmp_notify_procedure
}
397 static const value_string fmp_notify_proc_vals
[] = {
403 { 5, "RequestDone" },
405 { 7, "RevokeHandleList" },
409 static const value_string fmp_status_vals
[] = {
417 {500, "WRONG_MSG_NUM"},
418 {501, "SESSION_LOST"},
419 {502, "HOT_SESSION"},
420 {503, "COLD_SESSION"},
421 {504, "CLIENT_TERMINATED"},
422 {505, "WRITER_LOST_BLK"},
423 {506, "FMP_REQUEST_QUEUED"},
424 {507, "FMP_FALL_BACK"},
425 {508, "REQUEST_CANCELLED"},
426 {509, "WRITER_ZEROED_BLK"},
427 {510, "NOTIFY_ERROR"},
428 {511, "FMP_WRONG_HANDLE"},
429 {512, "DUPLICATE_OPEN"},
430 {600, "PLUGIN_NOFUNC"},
435 static const value_string fmp_revokeHandleListReason_vals
[] = {
436 {FMP_LIST_USER_QUOTA_EXCEEDED
, "LIST_USER_QUOTA_EXCEEDED"},
437 {FMP_LIST_GROUP_QUOTA_EXCEEDED
, "LIST_GROUP_QUOTA_EXCEEDED"},
438 {FMP_LIST_SERVER_RESOURCE_LOW
, "LIST_SERVER_RESOURCE_LOW"},
443 dissect_fmp_notify_extentState(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
445 offset
= dissect_rpc_uint32(tvb
, tree
, hf_fmp_extent_state
,
452 dissect_fmp_notify_extent(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
453 proto_tree
*tree
, uint32_t ext_num
)
457 extTree
= proto_tree_add_subtree_format(tree
, tvb
, offset
, 20 ,
458 ett_fmp_ext
, NULL
, "Extent (%u)", (uint32_t) ext_num
);
460 offset
= dissect_rpc_uint32(tvb
, extTree
, hf_fmp_firstLogBlk
,
462 offset
= dissect_rpc_uint32(tvb
, extTree
, hf_fmp_numBlks
,
464 offset
= dissect_rpc_uint32(tvb
, extTree
, hf_fmp_volID
, offset
);
465 offset
= dissect_rpc_uint32(tvb
, extTree
, hf_fmp_startOffset
,
467 offset
= dissect_fmp_notify_extentState(tvb
, offset
, extTree
);
474 dissect_fmp_notify_extentList(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
,
478 uint32_t totalLength
;
479 proto_tree
*extListTree
;
482 numExtents
= tvb_get_ntohl(tvb
, offset
);
483 totalLength
= 4 + (20 * numExtents
);
485 extListTree
= proto_tree_add_subtree(tree
, tvb
, offset
, totalLength
,
486 ett_fmp_extList
, NULL
, "Extent List");
488 offset
= dissect_rpc_uint32(tvb
, extListTree
,
489 hf_fmp_extentList_len
, offset
);
491 for (i
= 0; i
< numExtents
; i
++) {
492 offset
= dissect_fmp_notify_extent(tvb
, offset
, pinfo
, extListTree
, i
+1);
499 proto_register_fmp_notify(void)
501 static hf_register_info hf
[] = {
502 { &hf_fmp_notify_procedure
, {
503 "Procedure", "fmp_notify.notify_procedure", FT_UINT32
, BASE_DEC
,
504 VALS(fmp_notify_proc_vals
) , 0, NULL
, HFILL
}}, /* New addition */
507 "Status", "fmp_notify.status", FT_UINT32
, BASE_DEC
,
508 VALS(fmp_status_vals
), 0, "Reply Status", HFILL
}},
510 { &hf_fmp_extentList_len
, {
511 "Extent List length", "fmp_notify.extentListLength",
512 FT_UINT32
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
515 "Number Blocks", "fmp_notify.numBlks", FT_UINT32
,
516 BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
519 "Volume ID", "fmp_notify.volID", FT_UINT32
,
520 BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
522 { &hf_fmp_startOffset
, {
523 "Start Offset", "fmp_notify.startOffset", FT_UINT32
,
524 BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
526 { &hf_fmp_extent_state
, {
527 "Extent State", "fmp_notify.extentState", FT_UINT32
,
528 BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
530 { &hf_fmp_handleListLen
, {
531 "Number of File Handles", "fmp_notify.handleListLength",
532 FT_UINT32
, BASE_DEC
, NULL
, 0,
535 { &hf_fmp_sessionHandle
, {
536 "Session Handle", "fmp_notify.sessHandle", FT_BYTES
, BASE_NONE
,
537 NULL
, 0, NULL
, HFILL
}},
541 "File System ID", "fmp_notify.fsID", FT_UINT32
, BASE_HEX
,
542 NULL
, 0, NULL
, HFILL
}},
546 "FS Block Size", "fmp_notify.fsBlkSz", FT_UINT32
, BASE_DEC
,
547 NULL
, 0, NULL
, HFILL
}},
550 { &hf_fmp_numBlksReq
, {
551 "Number Blocks Requested", "fmp_notify.numBlksReq", FT_UINT32
,
552 BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
556 "Message Number", "fmp_notify.msgNum", FT_UINT32
, BASE_DEC
,
557 NULL
, 0, NULL
, HFILL
}},
560 "Cookie", "fmp_notify.cookie", FT_UINT32
, BASE_HEX
,
561 NULL
, 0, "Cookie for FMP_REQUEST_QUEUED Resp", HFILL
}},
564 { &hf_fmp_firstLogBlk
, {
565 "First Logical Block", "fmp_notify.firstLogBlk", FT_UINT32
,
566 BASE_DEC
, NULL
, 0, "First Logical File Block", HFILL
}},
569 { &hf_fmp_fileSize
, {
570 "File Size", "fmp_notify.fileSize", FT_UINT64
, BASE_DEC
,
571 NULL
, 0, NULL
, HFILL
}},
573 { &hf_fmp_fmpFHandle
, {
574 "FMP File Handle", "fmp_notify.fmpFHandle",
575 FT_BYTES
, BASE_NONE
, NULL
, 0, NULL
,
578 { &hf_fmp_revokeHandleListReason
,
579 { "Reason", "fmp.revokeHandleListReason",
580 FT_UINT32
, BASE_DEC
, VALS(fmp_revokeHandleListReason_vals
), 0,
586 static int *ett
[] = {
588 &ett_fmp_notify_hlist
,
594 proto_register_protocol("File Mapping Protocol Notify",
595 "FMP/NOTIFY", "fmp_notify");
596 proto_register_field_array(proto_fmp_notify
, hf
, array_length(hf
));
597 proto_register_subtree_array(ett
, array_length(ett
));
602 proto_reg_handoff_fmp_notify(void)
604 /* Register the protocol as RPC */
605 rpc_init_prog(proto_fmp_notify
, FMP_NOTIFY_PROG
, ett_fmp_notify
,
606 G_N_ELEMENTS(fmp_notify_vers_info
), fmp_notify_vers_info
);
610 * Editor modelines - https://www.wireshark.org/tools/modelines.html
615 * indent-tabs-mode: t
618 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
619 * :indentSize=8:tabSize=8:noTabs=false: