2 * Routines for fmp dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 #include <sys/types.h>
37 #include <epan/strutil.h>
39 #include "packet-rpc.h"
40 #include "packet-fmp.h"
42 #define FMP_NOTIFY_PROG 1001912
43 #define FMP_NOTIFY_VERSION_2 2
46 * FMP/NOTIFY Procedures
48 #define FMP_NOTIFY_DownGrade 1
49 #define FMP_NOTIFY_RevokeList 2
50 #define FMP_NOTIFY_RevokeAll 3
51 #define FMP_NOTIFY_FileSetEof 4
52 #define FMP_NOTIFY_RequestDone 5
53 #define FMP_NOTIFY_volFreeze 6
54 #define FMP_NOTIFY_revokeHandleList 7
57 FMP_LIST_USER_QUOTA_EXCEEDED = 0,
58 FMP_LIST_GROUP_QUOTA_EXCEEDED = 1,
59 FMP_LIST_SERVER_RESOURCE_LOW = 2
60 } revokeHandleListReason;
62 static int proto_fmp_notify = -1;
63 static int hf_fmp_handleListLen = -1;
64 static int hf_fmp_notify_procedure = -1;
65 static int hf_fmp_fsID = -1;
66 static int hf_fmp_fsBlkSz = -1;
67 static int hf_fmp_sessionHandle = -1;
68 static int hf_fmp_fmpFHandle = -1;
69 static int hf_fmp_msgNum = -1;
70 static int hf_fmp_fileSize = -1;
71 static int hf_fmp_cookie = -1;
72 static int hf_fmp_firstLogBlk = -1;
73 static int hf_fmp_numBlksReq = -1;
74 static int hf_fmp_status = -1;
76 static int ett_fmp_notify = -1;
77 static int ett_fmp_notify_hlist = -1;
79 static gint ett_fmp_extList = -1;
80 static int hf_fmp_extentList_len = -1;
81 static gint ett_fmp_ext = -1;
82 static int hf_fmp_numBlks = -1;
83 static int hf_fmp_volID = -1;
84 static int hf_fmp_startOffset = -1;
85 static int hf_fmp_extent_state = -1;
88 int dissect_fmp_notify_extentList(tvbuff_t *, int, packet_info *, proto_tree *);
91 dissect_fmp_notify_status(tvbuff_t *tvb, int offset, proto_tree *tree, int *rval)
99 status = tvb_get_ntohl(tvb, offset);
123 case FMP_WRONG_MSG_NUM:
126 case FMP_SESSION_LOST:
129 case FMP_HOT_SESSION:
133 case FMP_COLD_SESSION:
136 case FMP_CLIENT_TERMINATED:
139 case FMP_WRITER_LOST_BLK:
142 case FMP_REQUEST_QUEUED:
148 case FMP_REQUEST_CANCELLED:
152 case FMP_WRITER_ZEROED_BLK:
155 case FMP_NOTIFY_ERROR:
158 case FMP_WRONG_HANDLE:
161 case FMP_DUPLICATE_OPEN:
164 case FMP_PLUGIN_NOFUNC:
172 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_status , offset);
178 dissect_revokeHandleListReason(tvbuff_t *tvb, int offset, proto_tree *tree)
180 revokeHandleListReason reason;
186 reason = tvb_get_ntohl(tvb, offset);
189 case FMP_LIST_USER_QUOTA_EXCEEDED:
190 proto_tree_add_text(tree, tvb, offset, 4, "Reason: %s",
191 "LIST_USER_QUOTA_EXCEEDED");
194 case FMP_LIST_GROUP_QUOTA_EXCEEDED:
195 proto_tree_add_text(tree, tvb, offset, 4, "Reason: %s",
196 "LIST_GROUP_QUOTA_EXCEEDED");
199 case FMP_LIST_SERVER_RESOURCE_LOW:
200 proto_tree_add_text(tree, tvb, offset, 4, "Reason: %s",
201 "LIST_SERVER_RESOURCE_LOW");
205 proto_tree_add_text(tree, tvb, offset, 4, "Reason: %s",
214 dissect_handleList(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
221 proto_item *handleListItem;
222 proto_tree *handleListTree;
228 numHandles = tvb_get_ntohl(tvb, offset);
231 for (i = 0; i < numHandles; i++) {
232 listLength += (4 + tvb_get_ntohl(tvb, offset + listLength));
235 handleListItem = proto_tree_add_text(tree, tvb, offset, listLength,
237 handleListTree = proto_item_add_subtree(handleListItem,
238 ett_fmp_notify_hlist);
240 offset = dissect_rpc_uint32(tvb, handleListTree,
241 hf_fmp_handleListLen, offset);
243 for (i = 0; i <= numHandles; i++) {
244 offset = dissect_rpc_data(tvb, handleListTree,
245 hf_fmp_fmpFHandle, offset);/* changed */
252 dissect_FMP_NOTIFY_DownGrade_request(tvbuff_t *tvb, int offset,
253 packet_info *pinfo _U_, proto_tree *tree)
257 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
259 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle, offset);
260 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum, offset);
261 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_firstLogBlk,
263 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_numBlksReq, offset);
268 dissect_FMP_NOTIFY_DownGrade_reply(tvbuff_t *tvb, int offset,
269 packet_info *pinfo _U_, proto_tree *tree)
273 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
278 dissect_FMP_NOTIFY_RevokeList_request(tvbuff_t *tvb, int offset,
279 packet_info *pinfo _U_, proto_tree *tree)
282 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
284 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle, offset);
285 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum, offset);
286 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_firstLogBlk,
288 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_numBlksReq, offset);
293 dissect_FMP_NOTIFY_RevokeList_reply(tvbuff_t *tvb, int offset,
294 packet_info *pinfo _U_, proto_tree *tree)
298 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
303 dissect_FMP_NOTIFY_RevokeAll_request(tvbuff_t *tvb, int offset,
304 packet_info *pinfo _U_, proto_tree *tree)
306 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
308 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle, offset);
309 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum, offset);
314 dissect_FMP_NOTIFY_RevokeAll_reply(tvbuff_t *tvb, int offset,
315 packet_info *pinfo _U_, proto_tree *tree)
319 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
324 dissect_FMP_NOTIFY_FileSetEof_request(tvbuff_t *tvb, int offset,
325 packet_info *pinfo _U_, proto_tree *tree)
327 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
329 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle, offset);
330 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum, offset);
331 offset = dissect_rpc_uint64(tvb, tree, hf_fmp_fileSize, offset);
336 dissect_FMP_NOTIFY_FileSetEof_reply(tvbuff_t *tvb, int offset,
337 packet_info *pinfo _U_, proto_tree *tree)
341 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
346 dissect_FMP_NOTIFY_RequestDone_request(tvbuff_t *tvb, int offset,
347 packet_info *pinfo, proto_tree *tree)
351 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
353 offset = dissect_rpc_data(tvb, tree,
354 hf_fmp_sessionHandle, offset);
355 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle,
357 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum,
359 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_cookie,
361 offset = dissect_fmp_notify_extentList(tvb, offset, pinfo, tree);
367 dissect_FMP_NOTIFY_RequestDone_reply(tvbuff_t *tvb, int offset,
368 packet_info *pinfo _U_, proto_tree *tree)
372 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
377 dissect_FMP_NOTIFY_volFreeze_request(tvbuff_t *tvb, int offset,
378 packet_info *pinfo _U_, proto_tree *tree)
380 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
382 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_fsID, offset);
387 dissect_FMP_NOTIFY_volFreeze_reply(tvbuff_t *tvb, int offset,
388 packet_info *pinfo _U_, proto_tree *tree)
392 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
397 dissect_FMP_NOTIFY_revokeHandleList_request(tvbuff_t *tvb, int offset,
401 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
403 offset = dissect_revokeHandleListReason(tvb, offset, tree);
404 offset = dissect_handleList(tvb, offset, pinfo, tree);
409 dissect_FMP_NOTIFY_revokeHandleList_reply(tvbuff_t *tvb, int offset,
410 packet_info *pinfo _U_, proto_tree *tree)
414 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
419 * proc number, "proc name", dissect_request, dissect_reply
420 * NULL as function pointer means: type of arguments is "void".
422 static const vsff fmp_notify2_proc[] = {
424 { FMP_NOTIFY_DownGrade, "DownGrade",
425 dissect_FMP_NOTIFY_DownGrade_request,
426 dissect_FMP_NOTIFY_DownGrade_reply },
428 { FMP_NOTIFY_RevokeList, "RevokeList",
429 dissect_FMP_NOTIFY_RevokeList_request,
430 dissect_FMP_NOTIFY_RevokeList_reply },
432 { FMP_NOTIFY_RevokeAll, "RevokeAll",
433 dissect_FMP_NOTIFY_RevokeAll_request,
434 dissect_FMP_NOTIFY_RevokeAll_reply },
436 { FMP_NOTIFY_FileSetEof, "FileSetEof",
437 dissect_FMP_NOTIFY_FileSetEof_request,
438 dissect_FMP_NOTIFY_FileSetEof_reply },
440 { FMP_NOTIFY_RequestDone, "RequestDone",
441 dissect_FMP_NOTIFY_RequestDone_request,
442 dissect_FMP_NOTIFY_RequestDone_reply },
444 { FMP_NOTIFY_volFreeze, "volFreeze",
445 dissect_FMP_NOTIFY_volFreeze_request,
446 dissect_FMP_NOTIFY_volFreeze_reply },
448 { FMP_NOTIFY_revokeHandleList, "revokeHandleList",
449 dissect_FMP_NOTIFY_revokeHandleList_request,
450 dissect_FMP_NOTIFY_revokeHandleList_reply },
452 { 0, NULL, NULL, NULL }
455 static const value_string fmp_notify_proc_vals[] = {
460 { 5, "RequestDone" },
462 { 7, "RevokeHandleList" },
468 static const value_string fmp_status_vals[] = {
476 {500,"WRONG_MSG_NUM"},
477 {501,"SESSION_LOST"},
479 {503,"COLD_SESSION"},
480 {504,"CLIENT_TERMINATED"},
481 {505,"WRITER_LOST_BLK"},
482 {506,"FMP_REQUEST_QUEUED"},
483 {507,"FMP_FALL_BACK"},
484 {508,"REQUEST_CANCELLED"},
485 {509,"WRITER_ZEROED_BLK"},
486 {510,"NOTIFY_ERROR"},
487 {511,"FMP_WRONG_HANDLE"},
488 {512,"DUPLICATE_OPEN"},
489 {600,"PLUGIN_NOFUNC"},
496 proto_register_fmp_notify(void)
498 static hf_register_info hf[] = {
499 { &hf_fmp_notify_procedure, {
500 "Procedure", "fmp_notify.fmp_notify_procedure", FT_UINT32, BASE_DEC,
501 VALS(fmp_notify_proc_vals) , 0, NULL, HFILL }}, /* New addition */
504 "Status", "fmp_notify.status", FT_UINT32, BASE_DEC,
505 VALS(fmp_status_vals), 0, "Reply Status", HFILL }},
508 { &hf_fmp_handleListLen, {
509 "Number File Handles", "fmp_notify.handleListLength",
510 FT_UINT32, BASE_DEC, NULL, 0,
511 "Number of File Handles", HFILL }},
514 { &hf_fmp_sessionHandle, {
515 "Session Handle", "fmp_notify.sessHandle", FT_BYTES, BASE_NONE,
516 NULL, 0, "FMP Session Handle", HFILL }},
520 "File System ID", "fmp_notify.fsID", FT_UINT32, BASE_HEX,
521 NULL, 0, NULL, HFILL }},
524 "FS Block Size", "fmp_notify.fsBlkSz", FT_UINT32, BASE_DEC,
525 NULL, 0, "File System Block Size", HFILL }},
528 { &hf_fmp_numBlksReq, {
529 "Number Blocks Requested", "fmp_notify.numBlksReq", FT_UINT32,
530 BASE_DEC, NULL, 0, NULL, HFILL }},
534 "Message Number", "fmp_notify.msgNum", FT_UINT32, BASE_DEC,
535 NULL, 0, "FMP Message Number", HFILL }},
538 "Cookie", "fmp_notify.cookie", FT_UINT32, BASE_HEX,
539 NULL, 0, "Cookie for FMP_REQUEST_QUEUED Resp", HFILL }},
542 { &hf_fmp_firstLogBlk, {
543 "First Logical Block", "fmp_notify.firstLogBlk", FT_UINT32,
544 BASE_DEC, NULL, 0, "First Logical File Block", HFILL }},
547 { &hf_fmp_fileSize, {
548 "File Size", "fmp_notify.fileSize", FT_UINT64, BASE_DEC,
549 NULL, 0, NULL, HFILL }},
551 { &hf_fmp_fmpFHandle, {
552 "FMP File Handle", "fmp_notify.fmpFHandle",
553 FT_BYTES, BASE_NONE, NULL, 0, NULL,
560 static gint *ett[] = {
562 &ett_fmp_notify_hlist,
566 proto_register_protocol("File Mapping Protocol Nofity",
567 "FMP/NOTIFY", "fmp_notify");
568 proto_register_field_array(proto_fmp_notify, hf, array_length(hf));
569 proto_register_subtree_array(ett, array_length(ett));
574 proto_reg_handoff_fmp_notify(void)
576 /* Register the protocol as RPC */
577 rpc_init_prog(proto_fmp_notify, FMP_NOTIFY_PROG, ett_fmp_notify);
579 /* Register the procedure tables */
580 rpc_init_proc_table(FMP_NOTIFY_PROG, FMP_NOTIFY_VERSION_2,
581 fmp_notify2_proc,hf_fmp_notify_procedure);
586 dissect_fmp_notify_extentState(tvbuff_t *tvb, int offset, proto_tree *tree)
594 state = tvb_get_ntohl(tvb, offset);
595 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_extent_state,
602 dissect_fmp_notify_extent(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
603 proto_tree *tree, guint32 ext_num)
612 extItem = proto_tree_add_text(tree, tvb, offset, 20 ,
613 "Extent (%u)", (guint32) ext_num);
616 extTree = proto_item_add_subtree(extItem, ett_fmp_ext);
618 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_firstLogBlk,
620 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_numBlks,
622 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_volID, offset);
623 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_startOffset,
625 offset = dissect_fmp_notify_extentState(tvb, offset, extTree);
632 dissect_fmp_notify_extentList(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
637 proto_item *extListItem;
638 proto_tree *extListTree;
645 numExtents = tvb_get_ntohl(tvb, offset);
646 totalLength = 4 + (20 * numExtents);
648 extListItem = proto_tree_add_text(tree, tvb, offset, totalLength,
650 extListTree = proto_item_add_subtree(extListItem, ett_fmp_extList);
652 offset = dissect_rpc_uint32(tvb, extListTree,
653 hf_fmp_extentList_len, offset);
655 for (i = 1; i <= numExtents; i++) {
656 offset = dissect_fmp_notify_extent(tvb, offset, pinfo, extListTree, i);