Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-fmp_notify.c
blob973718bbb5d9e399470fc84b239aea7896f67ab0
1 /* packet-fmp_notify.c
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
9 */
11 #include "config.h"
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
35 typedef enum {
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 *);
69 static int
70 dissect_fmp_notify_status(tvbuff_t *tvb, int offset, proto_tree *tree, int *rval)
72 fmpStat status;
74 status = (fmpStat)tvb_get_ntohl(tvb, offset);
76 switch (status) {
77 case FMP_OK:
78 *rval = 0;
79 break;
80 case FMP_IOERROR:
81 *rval = 1;
82 break;
83 case FMP_NOMEM:
84 *rval = 1;
85 break;
86 case FMP_NOACCESS:
87 *rval = 1;
88 break;
89 case FMP_INVALIDARG:
90 *rval = 1;
91 break;
92 case FMP_FSFULL:
93 *rval = 0;
94 break;
95 case FMP_QUEUE_FULL:
96 *rval = 1;
97 break;
98 case FMP_WRONG_MSG_NUM:
99 *rval = 1;
100 break;
101 case FMP_SESSION_LOST:
102 *rval = 1;
103 break;
104 case FMP_HOT_SESSION:
105 *rval = 0;
106 break;
108 case FMP_COLD_SESSION:
109 *rval = 0;
110 break;
111 case FMP_CLIENT_TERMINATED:
112 *rval = 0;
113 break;
114 case FMP_WRITER_LOST_BLK:
115 *rval = 1;
116 break;
117 case FMP_REQUEST_QUEUED:
118 *rval = 0;
119 break;
120 case FMP_FALL_BACK:
121 *rval = 0;
122 break;
123 case FMP_REQUEST_CANCELLED:
124 *rval = 1;
125 break;
127 case FMP_WRITER_ZEROED_BLK:
128 *rval = 0;
129 break;
130 case FMP_NOTIFY_ERROR:
131 *rval = 1;
132 break;
133 case FMP_WRONG_HANDLE:
134 *rval = 0;
135 break;
136 case FMP_DUPLICATE_OPEN:
137 *rval = 1;
138 break;
139 case FMP_PLUGIN_NOFUNC:
140 *rval = 1;
141 break;
142 default:
143 *rval = 1;
144 break;
147 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_status , offset);
148 return offset;
152 static int
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);
156 offset += 4;
157 return offset;
160 static int
161 dissect_handleList(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
162 proto_tree *tree)
165 int numHandles;
166 int listLength;
167 int i;
168 proto_tree *handleListTree;
170 numHandles = tvb_get_ntohl(tvb, offset);
171 listLength = 4;
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 */
188 return offset;
191 static int
192 dissect_FMP_NOTIFY_DownGrade_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
194 int offset = 0;
196 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
197 offset);
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,
201 offset);
202 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_numBlksReq, offset);
203 return offset;
206 static int
207 dissect_FMP_NOTIFY_DownGrade_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
209 int rval;
211 return dissect_fmp_notify_status(tvb, 0,tree, &rval);
214 static int
215 dissect_FMP_NOTIFY_RevokeList_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
217 int offset = 0;
219 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
220 offset);
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,
224 offset);
225 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_numBlksReq, offset);
226 return offset;
229 static int
230 dissect_FMP_NOTIFY_RevokeList_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
232 int rval;
234 return dissect_fmp_notify_status(tvb, 0, tree, &rval);
237 static int
238 dissect_FMP_NOTIFY_RevokeAll_request(tvbuff_t *tvb,
239 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
241 int offset = 0;
242 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
243 offset);
244 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle, offset);
245 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum, offset);
246 return offset;
249 static int
250 dissect_FMP_NOTIFY_RevokeAll_reply(tvbuff_t *tvb,
251 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
253 int rval;
255 return dissect_fmp_notify_status(tvb, 0, tree, &rval);
258 static int
259 dissect_FMP_NOTIFY_FileSetEof_request(tvbuff_t *tvb,
260 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
262 int offset = 0;
263 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
264 offset);
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);
268 return offset;
271 static int
272 dissect_FMP_NOTIFY_FileSetEof_reply(tvbuff_t *tvb,
273 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
275 int rval;
277 return dissect_fmp_notify_status(tvb, 0, tree, &rval);
280 static int
281 dissect_FMP_NOTIFY_RequestDone_request(tvbuff_t *tvb,
282 packet_info *pinfo, proto_tree *tree, void* data _U_)
284 int rval;
285 int offset = 0;
287 offset = dissect_fmp_notify_status(tvb, offset,tree, &rval);
288 if (rval == 0) {
289 offset = dissect_rpc_data(tvb, tree,
290 hf_fmp_sessionHandle, offset);
291 offset = dissect_rpc_data(tvb, tree, hf_fmp_fmpFHandle,
292 offset);
293 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_msgNum,
294 offset);
295 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_cookie,
296 offset);
297 offset = dissect_fmp_notify_extentList(tvb, offset, pinfo, tree);
299 return offset;
302 static int
303 dissect_FMP_NOTIFY_RequestDone_reply(tvbuff_t *tvb,
304 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
306 int rval;
308 return dissect_fmp_notify_status(tvb, 0, tree, &rval);
311 static int
312 dissect_FMP_NOTIFY_volFreeze_request(tvbuff_t *tvb,
313 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
315 int offset = 0;
317 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
318 offset);
319 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_fsID, offset);
320 return offset;
323 static int
324 dissect_FMP_NOTIFY_volFreeze_reply(tvbuff_t *tvb,
325 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
327 int rval;
329 return dissect_fmp_notify_status(tvb, 0, tree, &rval);
332 static int
333 dissect_FMP_NOTIFY_revokeHandleList_request(tvbuff_t *tvb,
334 packet_info *pinfo, proto_tree *tree, void* data _U_)
336 int offset = 0;
338 offset = dissect_rpc_data(tvb, tree, hf_fmp_sessionHandle,
339 offset);
340 offset = dissect_revokeHandleListReason(tvb, offset, tree);
341 offset = dissect_handleList(tvb, offset, pinfo, tree);
342 return offset;
345 static int
346 dissect_FMP_NOTIFY_revokeHandleList_reply(tvbuff_t *tvb,
347 packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
349 int rval;
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[] = {
358 { 0, "NULL",
359 dissect_rpc_void,
360 dissect_rpc_void, },
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[] = {
398 { 0, "NULL" },
399 { 1, "DownGrade" },
400 { 2, "RevokeList" },
401 { 3, "RevokeAll" },
402 { 4, "FileSetEof" },
403 { 5, "RequestDone" },
404 { 6, "VolFreeze" },
405 { 7, "RevokeHandleList" },
406 { 0,NULL}
409 static const value_string fmp_status_vals[] = {
410 { 0, "OK"},
411 { 5, "IOERROR"},
412 { 12, "NOMEM"},
413 { 13, "NOACCESS"},
414 { 22, "INVALIDARG"},
415 { 28, "FSFULL"},
416 { 79, "QUEUE_FULL"},
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"},
431 {0,NULL}
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"},
439 {0,NULL}
442 static int
443 dissect_fmp_notify_extentState(tvbuff_t *tvb, int offset, proto_tree *tree)
445 offset = dissect_rpc_uint32(tvb, tree, hf_fmp_extent_state,
446 offset);
448 return offset;
451 static int
452 dissect_fmp_notify_extent(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
453 proto_tree *tree, uint32_t ext_num)
455 proto_tree *extTree;
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,
461 offset);
462 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_numBlks,
463 offset);
464 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_volID, offset);
465 offset = dissect_rpc_uint32(tvb, extTree, hf_fmp_startOffset,
466 offset);
467 offset = dissect_fmp_notify_extentState(tvb, offset, extTree);
469 return offset;
473 static int
474 dissect_fmp_notify_extentList(tvbuff_t *tvb, int offset, packet_info *pinfo,
475 proto_tree *tree)
477 uint32_t numExtents;
478 uint32_t totalLength;
479 proto_tree *extListTree;
480 uint32_t i;
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);
495 return offset;
498 void
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 */
506 { &hf_fmp_status, {
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 }},
514 { &hf_fmp_numBlks, {
515 "Number Blocks", "fmp_notify.numBlks", FT_UINT32,
516 BASE_DEC, NULL, 0, NULL, HFILL }},
518 { &hf_fmp_volID, {
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,
533 NULL, HFILL }},
535 { &hf_fmp_sessionHandle, {
536 "Session Handle", "fmp_notify.sessHandle", FT_BYTES, BASE_NONE,
537 NULL, 0, NULL, HFILL }},
540 { &hf_fmp_fsID, {
541 "File System ID", "fmp_notify.fsID", FT_UINT32, BASE_HEX,
542 NULL, 0, NULL, HFILL }},
544 #if 0
545 { &hf_fmp_fsBlkSz, {
546 "FS Block Size", "fmp_notify.fsBlkSz", FT_UINT32, BASE_DEC,
547 NULL, 0, NULL, HFILL }},
548 #endif
550 { &hf_fmp_numBlksReq, {
551 "Number Blocks Requested", "fmp_notify.numBlksReq", FT_UINT32,
552 BASE_DEC, NULL, 0, NULL, HFILL }},
555 { &hf_fmp_msgNum, {
556 "Message Number", "fmp_notify.msgNum", FT_UINT32, BASE_DEC,
557 NULL, 0, NULL, HFILL }},
559 { &hf_fmp_cookie, {
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,
576 HFILL }},
578 { &hf_fmp_revokeHandleListReason,
579 { "Reason", "fmp.revokeHandleListReason",
580 FT_UINT32, BASE_DEC, VALS(fmp_revokeHandleListReason_vals), 0,
581 NULL, HFILL }},
586 static int *ett[] = {
587 &ett_fmp_notify,
588 &ett_fmp_notify_hlist,
589 &ett_fmp_extList,
590 &ett_fmp_ext
593 proto_fmp_notify =
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));
601 void
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
612 * Local variables:
613 * c-basic-offset: 8
614 * tab-width: 8
615 * indent-tabs-mode: t
616 * End:
618 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
619 * :indentSize=8:tabSize=8:noTabs=false: