Rewrote to use g_strlcat and g_strlcpy.
[metze/wireshark/wip.git] / epan / dissectors / packet-ncp2222.inc
1 #define FAKE_TREE_IS_VISIBLE    1
2 /* fake that the tree is visible so that proto.c will not try to
3  "fake" generation of finfo values/nodes.
4   Thus this means netware dissector is slower than it has to, but it wont crash.
5   once the dissector is refactored to avoid calling fvalue_ functions directly this faking of whether the tree is visible or not can be removed.
6 */
7
8
9 /* packet-ncp2222.inc
10  *
11  * Routines for NetWare Core Protocol. This C code gets #include'd
12  * into packet-ncp2222.c, which is generated from ncp2222.py. It's
13  * #include'd instead of being in a separate compilation unit so
14  * that all the data tables in packet-ncp2222.c can remain static.
15  *
16  * Gilbert Ramirez <gram@alumni.rice.edu>
17  * Modified to decode NDS packets by Greg Morris <gmorris@novell.com>
18  *
19  * Portions Copyright (c) Gilbert Ramirez 2000-2002
20  * Portions Copyright (c) Novell, Inc. 2000-2003
21  *
22  * $Id$
23  *
24  * Wireshark - Network traffic analyzer
25  * By Gerald Combs <gerald@wireshark.org>
26  * Copyright 2000 Gerald Combs
27  *
28  * This program is free software; you can redistribute it and/or
29  * modify it under the terms of the GNU General Public License
30  * as published by the Free Software Foundation; either version 2
31  * of the License, or (at your option) any later version.
32  *
33  * This program is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36  * GNU General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License
39  * along with this program; if not, write to the Free Software
40  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
41  */
42
43 #define NCP_PACKET_INIT_COUNT   200
44 #define PROTO_LENGTH_UNTIL_END -1
45
46 gboolean        nds_defragment = TRUE;
47 gboolean        nds_echo_eid = TRUE;
48 gboolean        ncp_echo_err = TRUE;
49 gboolean        ncp_echo_conn = FALSE;
50 gboolean        ncp_echo_server = TRUE;
51 gboolean        ncp_echo_file = FALSE;
52 gboolean        ncp_newstyle = TRUE;
53
54 extern dissector_handle_t nds_data_handle;
55 typedef struct {
56         guint32         nds_frag_verb;
57         guint32         nds_frag_version;
58         guint32         nds_frag_flags;
59         guint32         nds_frag_prot_flags;
60         guint32         nds_length;
61         guint32         nds_frag;
62         gboolean        nds_fragmented;
63 } frag_info;
64
65 frag_info           frags[100];
66 char    mv_resolve_name_string[128];
67
68 const fragment_items nds_frag_items = {
69         &ett_nds_segment,
70         &ett_nds_segments,
71         &hf_nds_segments,
72         &hf_nds_segment,
73         &hf_nds_segment_overlap,
74         &hf_nds_segment_overlap_conflict,
75         &hf_nds_segment_multiple_tails,
76         &hf_nds_segment_too_long_segment,
77         &hf_nds_segment_error,
78         NULL,
79         "segments"
80 };
81
82 #define NDS_TAG_NO_SUCH_ENTRY               0x00000000
83 #define NDS_TAG_LOCAL_ENTRY                     0x00000001
84 #define NDS_TAG_REMOTE_ENTRY                0x00000002
85 #define NDS_TAG_ALIAS_ENTRY                     0x00000003
86 #define NDS_TAG_REFERRAL_INFORMATION    0x00000004
87 #define NDS_TAG_ENTRY_AND_REFERRALS         0x00000006
88
89 /* Search objects */
90 #define NDS_SEARCH_ENTRY                                    0
91 #define NDS_SEARCH_SUBORDINATES                 1
92 #define NDS_SEARCH_SUBTREE                                  2
93 #define NDS_SEARCH_PARTITION                        3
94
95 /* Search Referal Types */
96 #define NDS_ALIAS_REFERRAL                                  0
97 #define NDS_PARTITION_REFERRAL                      1
98
99 /* Search Filter Types */
100 #define NDS_SEARCH_ITEM                                         0
101 #define NDS_SEARCH_OR                                           1
102 #define NDS_SEARCH_AND                                          2
103 #define NDS_SEARCH_NOT                                          3
104
105 /* Search Operators */
106 #define NDS_SEARCH_EQUAL                                        7
107 #define NDS_SEARCH_GREATER_OR_EQUAL                 8
108 #define NDS_SEARCH_LESS_OR_EQUAL                        9
109 #define NDS_SEARCH_APPROX                                       10
110 #define NDS_SEARCH_PRESENT                                      15
111 #define NDS_SEARCH_RDN                                          16
112 #define NDS_SEARCH_BASE_CLASS                           17
113 #define NDS_SEARCH_MODIFICATION_GE                  18  /* Deprecated, use DS_SEARCH_ENTRY_MTS_GE */
114 #define NDS_SEARCH_VALUE_TIME_GE                        19      /* Deprecated, use DS_SEARCH_VALUE_MTS_GE */
115 #define NDS_SEARCH_REFERENCES                           20
116 #define NDS_SEARCH_DN_IN_VALUE                          21
117 #define NDS_SEARCH_SCHEMA_IN_VALUE                  22
118 #define NDS_SEARCH_ENTRY_FLAGS                          23
119 #define NDS_SEARCH_ENTRY_HAS_FLAG                       24
120 #define NDS_SEARCH_VALUE_FLAGS                          25
121 #define NDS_SEARCH_VALUE_HAS_FLAG                       26
122 #define NDS_SEARCH_ATTR_FLAGS                           27
123 #define NDS_SEARCH_ATTR_HAS_FLAG                        28
124 #define NDS_SEARCH_EID                                          29
125
126 #define NDS_SEARCH_ENTRY_MTS_GE                     18
127 #define NDS_SEARCH_ENTRY_MTS_G                          30
128 #define NDS_SEARCH_ENTRY_MTS_LE                     31
129 #define NDS_SEARCH_ENTRY_MTS_L                          32
130 #define NDS_SEARCH_ENTRY_MTS_EQ                     33
131 #define NDS_SEARCH_ENTRY_MTS_EQ_APPROX      34
132 #define NDS_SEARCH_VALUE_MTS_GE                     19
133 #define NDS_SEARCH_VALUE_MTS_G                          35
134 #define NDS_SEARCH_VALUE_MTS_LE                     36
135 #define NDS_SEARCH_VALUE_MTS_L                          37
136 #define NDS_SEARCH_VALUE_MTS_EQ                     38
137 #define NDS_SEARCH_VALUE_MTS_EQ_APPROX      39
138
139 #define NDS_SEARCH_ENTRY_CTS_GE                     40
140 #define NDS_SEARCH_ENTRY_CTS_G                          41
141 #define NDS_SEARCH_ENTRY_CTS_LE                     42
142 #define NDS_SEARCH_ENTRY_CTS_L                          43
143 #define NDS_SEARCH_ENTRY_CTS_EQ                     44
144 #define NDS_SEARCH_ENTRY_CTS_EQ_APPROX      45
145 #define NDS_SEARCH_VALUE_CTS_GE                     46
146 #define NDS_SEARCH_VALUE_CTS_G                          47
147 #define NDS_SEARCH_VALUE_CTS_LE                     48
148 #define NDS_SEARCH_VALUE_CTS_L                          49
149 #define NDS_SEARCH_VALUE_CTS_EQ                     50
150 #define NDS_SEARCH_VALUE_CTS_EQ_APPROX      51
151 #define NDS_SEARCH_EXTENSIBLE               52
152 #define NDS_SEARCH_ENTRY_SUBCOUNT_GE        53
153 #define NDS_SEARCH_ENTRY_SUBCOUNT_G         54
154 #define NDS_SEARCH_ENTRY_SUBCOUNT_LE        55
155 #define NDS_SEARCH_ENTRY_SUBCOUNT_L         56
156 #define NDS_SEARCH_ENTRY_SUBCOUNT_EQ        57
157
158 #define DCS_OPS                                         0x10000000L
159 #define DCS_MOD_GE_WITH_ATTR            DCS_OPS + NDS_SEARCH_MODIFICATION_GE
160 #define DCS_VALUE_GE_WITH_ATTR      DCS_OPS + NDS_SEARCH_VALUE_TIME_GE
161 #define DCS_MASK                                        ~DCS_OPS
162
163 /* Iterator verbs */
164 #define IT_CLEAR                                1
165 #define IT_COPY                             2
166 #define IT_COUNT                                3
167 #define IT_CREATE                           4
168 #define IT_CURRENT                          5
169 #define IT_DESTROY                          6
170 #define IT_DONE                             7
171 #define IT_FIRST                                8
172 #define IT_GETPOSITION              9
173 #define IT_LAST                             10
174 #define IT_NEXT                             11
175 #define IT_PREV                             12
176 #define IT_POSITION                         13
177 #define IT_POSITION_IT              14
178 #define IT_SETINDEX                         15
179 #define IT_SETFILTER                    16
180 #define IT_SKIP                             17
181 #define IT_TYPEDOWN                         18
182 #define IT_ATFIRST                          19
183 #define IT_ATEOF                                20
184 #define IT_GETINDEX                         21
185 #define IT_ISPOSITIONABLE           22
186 #define IT_ATBOF                                23
187 #define IT_ATLAST                               24
188
189 /* Iteration information flags */
190 #define DSI_OUTPUT_FIELDS                               0x00000001L
191 #define DSI_ENTRY_ID                                            0x00000002L
192 #define DSI_ENTRY_FLAGS                                 0x00000004L
193 #define DSI_SUBORDINATE_COUNT                   0x00000008L
194 #define DSI_MODIFICATION_TIME                   0x00000010L
195 #define DSI_MODIFICATION_TIMESTAMP      0x00000020L
196 #define DSI_CREATION_TIMESTAMP          0x00000040L
197 #define DSI_PARTITION_ROOT_ID                   0x00000080L
198 #define DSI_PARENT_ID                                   0x00000100L
199 #define DSI_REVISION_COUNT                              0x00000200L
200 #define DSI_REPLICA_TYPE                                0x00000400L
201 #define DSI_BASE_CLASS                                  0x00000800L
202 #define DSI_ENTRY_RDN                                   0x00001000L
203 #define DSI_ENTRY_DN                                            0x00002000L
204 #define DSI_PARTITION_ROOT_DN                   0x00004000L
205 #define DSI_PARENT_DN                                   0x00008000L
206 #define DSI_PURGE_TIME                                  0x00010000L
207 #define DSI_DEREFERENCED_BASE_CLASS 0x00020000L
208 #define DSI_REPLICA_NUMBER                              0x00040000L
209 #define DSI_REPLICA_STATE                               0x00080000L
210 #define DSI_FEDERATION_BOUNDARY         0x00100000L
211 #define DSI_SCHEMA_BOUNDARY                     0x00200000L
212 #define DSI_FEDERATION_BOUNDARY_ID      0x00400000L
213 #define DSI_SCHEMA_BOUNDARY_ID          0x00800000L
214 #define DSI_CUR_SUBCOUNT                                0x01000000L
215 #define DSI_LOCAL_ENTRY_FLAGS                   0x02000000L
216
217 static const value_string zensearchenum[] = {
218     { 0, "[Root]" },
219     { 1, "Object Container" },
220     { 2, "Associated Container" },
221     { 3, "Selected Container" },
222     {0, NULL }
223 };
224
225 static const value_string itersearchenum[] = {
226     { NDS_SEARCH_ITEM, "Search Item" },
227     { NDS_SEARCH_OR, "OR" },
228     { NDS_SEARCH_AND, "AND" },
229     { NDS_SEARCH_NOT, "NOT" },
230     { NDS_SEARCH_EQUAL, "Equals" },
231     { NDS_SEARCH_GREATER_OR_EQUAL, "Greater or Equals" },
232     { NDS_SEARCH_LESS_OR_EQUAL, "Less or Equals" },
233     { NDS_SEARCH_APPROX, "Approximately" },
234     { NDS_SEARCH_PRESENT, "Present" },
235     { NDS_SEARCH_RDN, "Relative Distinguished Name" },
236     { NDS_SEARCH_BASE_CLASS, "Base Class" },
237     { NDS_SEARCH_MODIFICATION_GE, "Modification Greater or Equal" },
238     { NDS_SEARCH_VALUE_TIME_GE, "Time Value Greater or Equal" },
239     { NDS_SEARCH_REFERENCES, "References" },
240     { NDS_SEARCH_DN_IN_VALUE, "Designated Name in Value" },
241     { NDS_SEARCH_SCHEMA_IN_VALUE, "Schema in Value" },
242     { NDS_SEARCH_ENTRY_FLAGS, "Entry Flags" },
243     { NDS_SEARCH_ENTRY_HAS_FLAG, "Entry has Flags" },
244     { NDS_SEARCH_VALUE_FLAGS, "Value Flags" },
245     { NDS_SEARCH_VALUE_HAS_FLAG, "Value has Flags" },
246     { NDS_SEARCH_ATTR_FLAGS, "Attribute Flags" },
247     { NDS_SEARCH_ATTR_HAS_FLAG, "Attribute has Flags" },
248     { NDS_SEARCH_EID, "Entry ID" },
249     { NDS_SEARCH_ENTRY_MTS_GE, "Entry Modification Timestamp Greater or Equal" },
250     { NDS_SEARCH_ENTRY_MTS_G, "Entry Modification Timestamp Greater" },
251     { NDS_SEARCH_ENTRY_MTS_LE, "Entry Modification Timestamp Less or Equals" },
252     { NDS_SEARCH_ENTRY_MTS_L, "Entry Modification Timestamp Less" },
253     { NDS_SEARCH_ENTRY_MTS_EQ, "Entry Modification Timestamp Equals" },
254     { NDS_SEARCH_ENTRY_MTS_EQ_APPROX, "Entry Modification Timestamp Equals Approximately" },
255     { NDS_SEARCH_VALUE_MTS_GE, "Value Modification Timestamp Greater or Equal" },
256     { NDS_SEARCH_VALUE_MTS_G, "Value Modification Timestamp Greater" },
257     { NDS_SEARCH_VALUE_MTS_LE, "Value Modification Timestamp Less or Equals" },
258     { NDS_SEARCH_VALUE_MTS_L, "Value Modification Timestamp Less" },
259     { NDS_SEARCH_VALUE_MTS_EQ, "Value Modification Timestamp Equals" },
260     { NDS_SEARCH_VALUE_MTS_EQ_APPROX, "Value Modification Timestamp Equals Approximately" },
261     { NDS_SEARCH_ENTRY_CTS_GE, "Entry Creation Timestamp Greater or Equals" },
262     { NDS_SEARCH_ENTRY_CTS_G, "Entry Creation Timestamp Greater" },
263     { NDS_SEARCH_ENTRY_CTS_LE, "Entry Creation Timestamp Less or Equals" },
264     { NDS_SEARCH_ENTRY_CTS_L, "Entry Creation Timestamp Less" },
265     { NDS_SEARCH_ENTRY_CTS_EQ, "Entry Creation Timestamp Equals" },
266     { NDS_SEARCH_ENTRY_CTS_EQ_APPROX, "Entry Creation Timestamp Equals Approximately" },
267     { NDS_SEARCH_VALUE_CTS_GE, "Value Creation Timestamp Greater or Equals" },
268     { NDS_SEARCH_VALUE_CTS_G, "Value Creation Timestamp Greater" },
269     { NDS_SEARCH_VALUE_CTS_LE, "Value Creation Timestamp Less or Equals" },
270     { NDS_SEARCH_VALUE_CTS_L, "Value Creation Timestamp Less" },
271     { NDS_SEARCH_VALUE_CTS_EQ, "Value Creation Timestamp Equals" },
272     { NDS_SEARCH_VALUE_CTS_EQ_APPROX, "Value Creation Timestamp Equals Approximately" },
273     { NDS_SEARCH_EXTENSIBLE, "Extensible" },
274     { NDS_SEARCH_ENTRY_SUBCOUNT_GE, "Entry SubCount Greater or Equals" },
275     { NDS_SEARCH_ENTRY_SUBCOUNT_G, "Entry SubCount Greater" },
276     { NDS_SEARCH_ENTRY_SUBCOUNT_LE, "Entry SubCount Less or Equals" },
277     { NDS_SEARCH_ENTRY_SUBCOUNT_L, "Entry SubCount Less" },
278     { NDS_SEARCH_ENTRY_SUBCOUNT_EQ, "Entry SubCount Equals" },
279     {0, NULL }
280 };
281
282 static const value_string iterator_subverbs[] = {
283         { IT_CLEAR, "Clear" },
284         { IT_COPY, "Copy" },
285         { IT_COUNT, "Count" },
286         { IT_CREATE, "Create" },
287         { IT_CURRENT, "Current" },
288         { IT_DESTROY, "Destroy" },
289         { IT_DONE, "Done" },
290         { IT_FIRST, "First" },
291         { IT_GETPOSITION, "Get Position" },
292         { IT_LAST, "Last" },
293         { IT_NEXT, "Next" },
294         { IT_PREV, "Previous" },
295         { IT_POSITION, "Position" },
296         { IT_POSITION_IT, "Position Iterator" },
297         { IT_SETINDEX, "Set Index" },
298         { IT_SETFILTER, "Set Filter" },
299         { IT_SKIP, "Skip" },
300         { IT_TYPEDOWN, "Type Down" },
301         { IT_ATFIRST, "At First" },
302         { IT_ATEOF, "At End of File" },
303         { IT_GETINDEX, "Get Index" },
304         { IT_ISPOSITIONABLE, "Is Positionable" },
305         { IT_ATBOF, "At Beginning of File" },
306         { IT_ATLAST, "At Last" },
307         { 0,    NULL }
308 };
309
310
311 static const value_string nds_tuned_tags[] = {
312     { 0, "RDN Hint" },
313     { 1, "RDN History" },
314     {0, NULL }
315 };
316
317 static const value_string nds_scope_vals[] = {
318     { 0, "Search Scope: 0x0000 - Examine base object only" },
319     { 1, "Search Scope: 0x0001 - Search the immediate subordinates of the base object" },
320     { 2, "Search Scope: 0x0002 - Search the base object and all of its subordinates" },
321     { 3, "Search Scope: 0x0003 - Search the base objects and all objects in its partition (NDS version 8 or higher)" },
322     {0, NULL }
323 };
324
325 static const value_string nds_tuned_item_tags[] = {
326     { 0, "Single Item" },
327     { 1, "Multiple Items" },
328     {0, NULL }
329 };
330
331 static const value_string nds_tags[] = {
332         { NDS_TAG_NO_SUCH_ENTRY,        "No Such Entry" },
333         { NDS_TAG_LOCAL_ENTRY,          "Local Entry" },
334         { NDS_TAG_REMOTE_ENTRY,         "Remote Entry" },
335         { NDS_TAG_ALIAS_ENTRY,          "Alias Entry" },
336         { NDS_TAG_REFERRAL_INFORMATION, "Referral Information" },
337         { NDS_TAG_ENTRY_AND_REFERRALS,  "Entry and Referrals" },
338         { 0,    NULL }
339 };
340
341 static const value_string nds_info_type[] = {
342         { 0x00000000, "Attribute Names Only / " },
343         { 0x00000001, "Attribute Name & Value / " },
344         { 0x00000002, "Effective Privileges / " },
345         { 0x00000003, "Value Information / " },
346         { 0x00000004, "Abbreviated Value / " },
347         { 0,    NULL }
348 };
349
350 static const value_string nds_kind_of_changes[] = {
351         { 0x00000000, "Add Attribute" },
352         { 0x00000001, "Remove Attribute" },
353         { 0x00000002, "Add Value" },
354         { 0x00000003, "Remove Value" },
355         { 0x00000004, "Add Additional Value" },
356         { 0x00000005, "Overwrite Value" },
357         { 0x00000006, "Clear Attribute" },
358         { 0x00000007, "Clear Value" },
359         { 0,    NULL }
360 };
361
362 static const value_string es_type[] = {
363         { 0x00000000, "No type is specified" },
364         { 0x00000001, "Unicode string" },
365         { 0x00000002, "Partial name" },
366         { 0x00000003, "Referrals" },
367         { 0x00000004, "Tuned name" },
368         { 0x00000005, "GUID attribute" },
369         { 0x00000006, "Local entry ID" },
370         { 0x00000007, "Number of defined entry specifiers" },
371         { 0,    NULL }
372 };
373
374 static const value_string ncp_rights_vals[] = {
375   { 0x00, "No Rights"},
376   { 0x01, "Read"},
377   { 0x02, "Write"},
378   { 0x03, "Read, Write"},
379   { 0x04, "Deny Read"},
380   { 0x05, "Read, Deny Read"},
381   { 0x06, "Write, Deny Read"},
382   { 0x07, "Read, Write, Deny Read"},
383   { 0x08, "Deny Write"},
384   { 0x09, "Read, Deny Write"},
385   { 0x0a, "Write, Deny Write"},
386   { 0x0b, "Read, Write, Deny Write"},
387   { 0x0c, "Deny Read, Deny Write"},
388   { 0x0d, "Read, Deny Read, Deny Write"},
389   { 0x0e, "Write, Deny Read, Deny Write"},
390   { 0x0f, "Read, Write, Deny Read, Deny Write"},
391   { 0x10, "Compatibility"},
392   { 0x11, "Read, Compatibility"},
393   { 0x12, "Write, Compatibility"},
394   { 0x13, "Read, Write, Compatibility"},
395   { 0x14, "Deny Read, Compatibility"},
396   { 0x15, "Read, Deny Read, Compatibility"},
397   { 0x16, "Write, Deny Read, Compatibility"},
398   { 0x17, "Read, Write, Deny Read, Compatibility"},
399   { 0x18, "Deny Write, Compatibility"},
400   { 0x19, "Read, Deny Write, Compatibility"},
401   { 0x1a, "Write, Deny Write, Compatibility"},
402   { 0x1b, "Read, Write, Deny Write, Compatibility"},
403   { 0x1c, "Deny Read, Deny Write, Compatibility"},
404   { 0x1d, "Read, Deny Read, Deny Write, Compatibility"},
405   { 0x1e, "Write, Deny Read, Deny Write, Compatibility"},
406   { 0x1f, "Read, Write, Deny Read, Deny Write, Compatibility"},
407   { 0x40, "File Write Through"},
408   { 0x41, "Read, File Write Through"},
409   { 0x42, "Write, File Write Through"},
410   { 0x43, "Read, Write, File Write Through"},
411   { 0x44, "Deny Read, File Write Through"},
412   { 0x45, "Read, Deny Read, File Write Through"},
413   { 0x46, "Write, Deny Read, File Write Through"},
414   { 0x47, "Read, Write, Deny Read, File Write Through"},
415   { 0x48, "Deny Write, File Write Through"},
416   { 0x49, "Read, Deny Write, File Write Through"},
417   { 0x4a, "Write, Deny Write, File Write Through"},
418   { 0x4b, "Read, Write, Deny Write, File Write Through"},
419   { 0x4c, "Deny Read, Deny Write, File Write Through"},
420   { 0x4d, "Read, Deny Read, Deny Write, File Write Through"},
421   { 0x4e, "Write, Deny Read, Deny Write, File Write Through"},
422   { 0x4f, "Read, Write, Deny Read, Deny Write, File Write Through"},
423   { 0x50, "Compatibility, File Write Through"},
424   { 0x51, "Read, Compatibility, File Write Through"},
425   { 0x52, "Write, Compatibility, File Write Through"},
426   { 0x53, "Read, Write, Compatibility, File Write Through"},
427   { 0x54, "Deny Read, Compatibility, File Write Through"},
428   { 0x55, "Read, Deny Read, Compatibility, File Write Through"},
429   { 0x56, "Write, Deny Read, Compatibility, File Write Through"},
430   { 0x57, "Read, Write, Deny Read, Compatibility, File Write Through"},
431   { 0x58, "Deny Write, Compatibility, File Write Through"},
432   { 0x59, "Read, Deny Write, Compatibility, File Write Through"},
433   { 0x5a, "Write, Deny Write, Compatibility, File Write Through"},
434   { 0x5b, "Read, Write, Deny Write, Compatibility, File Write Through"},
435   { 0x5c, "Deny Read, Deny Write, Compatibility, File Write Through"},
436   { 0x5d, "Read, Deny Read, Deny Write, Compatibility, File Write Through"},
437   { 0x5e, "Write, Deny Read, Deny Write, Compatibility, File Write Through"},
438   { 0x5f, "Read, Write, Deny Read, Deny Write, Compatibility, File Write Through"},
439   { 0,    NULL }
440 };
441
442 static const value_string open_create_mode_vals[] = {
443     { 0x01, "Open"},
444     { 0x02, "Replace"},
445     { 0x03, "Open, Replace"},
446     { 0x08, "Create"},
447     { 0x09, "Open, Create"},
448     { 0x0a, "Replace, Create"},
449     { 0x0b, "Open, Replace, Create"},
450     { 0x20, "64-bit"},
451     { 0x21, "Open, 64-bit"},
452     { 0x22, "Replace, 64-bit"},
453     { 0x23, "Open, Replace, 64-bit"},
454     { 0x28, "Create, 64-bit"},
455     { 0x29, "Open, Create, 64-bit"},
456     { 0x2a, "Replace, Create, 64-bit"},
457     { 0x2b, "Open, Replace, Create, 64-bit"},
458     { 0x40, "Read Only"},
459     { 0x41, "Open, Read Only"},
460     { 0x42, "Replace, Read Only"},
461     { 0x43, "Open, Replace, Read Only"},
462     { 0x48, "Create, Read Only"},
463     { 0x49, "Open, Create, Read Only"},
464     { 0x4a, "Replace, Create, Read Only"},
465     { 0x4b, "Open, Replace, Create, Read Only"},
466     { 0x60, "64-bit, Read Only"},
467     { 0x61, "Open, 64-bit, Read Only"},
468     { 0x62, "Replace, 64-bit, Read Only"},
469     { 0x63, "Open, Replace, 64-bit, Read Only"},
470     { 0x68, "Create, 64-bit, Read Only"},
471     { 0x69, "Open, Create, 64-bit, Read Only"},
472     { 0x6a, "Replace, Create, 64-bit, Read Only"},
473     { 0x6b, "Open, Replace, Create, 64-bit, Read Only"},
474     { 0x80, "Op-Lock"},
475     { 0x81, "Open, Op-Lock"},
476     { 0x82, "Replace, Op-Lock"},
477     { 0x83, "Open, Replace, Op-Lock"},
478     { 0x88, "Create, Op-Lock"},
479     { 0x89, "Open, Create, Op-Lock"},
480     { 0x8a, "Replace, Create, Op-Lock"},
481     { 0x8b, "Open, Replace, Create, Op-Lock"},
482     { 0xa0, "64-bit, Op-Lock"},
483     { 0xa1, "Open, 64-bit, Op-Lock"},
484     { 0xa2, "Replace, 64-bit, Op-Lock"},
485     { 0xa3, "Open, Replace, 64-bit, Op-Lock"},
486     { 0xa8, "Create, 64-bit, Op-Lock"},
487     { 0xa9, "Open, Create, 64-bit, Op-Lock"},
488     { 0xaa, "Replace, Create, 64-bit, Op-Lock"},
489     { 0xab, "Open, Replace, Create, 64-bit, Op-Lock"},
490     { 0xc0, "Read Only, Op-Lock"},
491     { 0xc1, "Open, Read Only, Op-Lock"},
492     { 0xc2, "Replace, Read Only, Op-Lock"},
493     { 0xc3, "Open, Replace, Read Only, Op-Lock"},
494     { 0xc8, "Create, Read Only, Op-Lock"},
495     { 0xc9, "Open, Create, Read Only, Op-Lock"},
496     { 0xca, "Replace, Create, Read Only, Op-Lock"},
497     { 0xcb, "Open, Replace, Create, Read Only, Op-Lock"},
498     { 0xe0, "64-bit, Read Only, Op-Lock"},
499     { 0xe1, "Open, 64-bit, Read Only, Op-Lock"},
500     { 0xe2, "Replace, 64-bit, Read Only, Op-Lock"},
501     { 0xe3, "Open, Replace, 64-bit, Read Only, Op-Lock"},
502     { 0xe8, "Create, 64-bit, Read Only, Op-Lock"},
503     { 0xe9, "Open, Create, 64-bit, Read Only, Op-Lock"},
504     { 0xea, "Replace, Create, 64-bit, Read Only, Op-Lock"},
505     { 0xeb, "Open, Replace, Create, 64-bit, Read Only, Op-Lock"},
506     { 0,    NULL }
507 };
508
509 static const value_string open_create_action_vals[] = {
510     { 0x01, "Opened"},
511     { 0x02, "Created"},
512     { 0x03, "Opened, Created"},
513     { 0x04, "Replaced"},
514     { 0x05, "Opened, Replaced"},
515     { 0x06, "Created, Replaced"},
516     { 0x07, "Opened, Created, Replaced"},
517     { 0x08, "Compressed"},
518     { 0x09, "Opened, Compressed"},
519     { 0x0a, "Created, Compressed"},
520     { 0x0b, "Opened, Created, Compressed"},
521     { 0x0c, "Replaced, Compressed"},
522     { 0x0d, "Opened, Replaced, Compressed"},
523     { 0x0e, "Created, Replaced, Compressed"},
524     { 0x0f, "Opened, Created, Replaced, Compressed"},
525     { 0x80, "Read Only"},
526     { 0x81, "Opened, Read Only"},
527     { 0x82, "Created, Read Only"},
528     { 0x83, "Opened, Created, Read Only"},
529     { 0x84, "Replaced, Read Only"},
530     { 0x85, "Opened, Replaced, Read Only"},
531     { 0x86, "Created, Replaced, Read Only"},
532     { 0x87, "Opened, Created, Replaced, Read Only"},
533     { 0x88, "Compressed, Read Only"},
534     { 0x89, "Opened, Compressed, Read Only"},
535     { 0x8a, "Created, Compressed, Read Only"},
536     { 0x8b, "Opened, Created, Compressed, Read Only"},
537     { 0x8c, "Replaced, Compressed, Read Only"},
538     { 0x8d, "Opened, Replaced, Compressed, Read Only"},
539     { 0x8e, "Created, Replaced, Compressed, Read Only"},
540     { 0x8f, "Opened, Created, Replaced, Compressed, Read Only"},
541     { 0,    NULL }
542 };
543
544 static const value_string access_rights_vals[] = {
545     { 0x0000, "No Rights"},
546         { 0x0001, "Read"},
547     { 0x0002, "Write"},
548     { 0x0003, "Read, Write"},
549     { 0x0004, "Open"},
550         { 0x0005, "Read, Open"},
551     { 0x0006, "Write, Open"},
552     { 0x0007, "Read, Write, Open"},
553     { 0x0008, "Create"},
554         { 0x0009, "Read, Create"},
555     { 0x000a, "Write, Create"},
556     { 0x000b, "Read, Write, Create"},
557     { 0x000c, "Open, Create"},
558         { 0x000d, "Read, Open, Create"},
559     { 0x000e, "Write, Open, Create"},
560     { 0x000f, "Read, Write, Open, Create"},
561     { 0x0010, "Delete"},
562         { 0x0011, "Read, Delete"},
563     { 0x0012, "Write, Delete"},
564     { 0x0013, "Read, Write, Delete"},
565     { 0x0014, "Open, Delete"},
566         { 0x0015, "Read, Open, Delete"},
567     { 0x0016, "Write, Open, Delete"},
568     { 0x0017, "Read, Write, Open, Delete"},
569     { 0x0018, "Create, Delete"},
570         { 0x0019, "Read, Create, Delete"},
571     { 0x001a, "Write, Create, Delete"},
572     { 0x001b, "Read, Write, Create, Delete"},
573     { 0x001c, "Open, Create, Delete"},
574         { 0x001d, "Read, Open, Create, Delete"},
575     { 0x001e, "Write, Open, Create, Delete"},
576     { 0x001f, "Read, Write, Open, Create, Delete"},
577     { 0x0020, "Parental"},
578         { 0x0021, "Read, Parental"},
579     { 0x0022, "Write, Parental"},
580     { 0x0023, "Read, Write, Parental"},
581     { 0x0024, "Open, Parental"},
582         { 0x0025, "Read, Open, Parental"},
583     { 0x0026, "Write, Open, Parental"},
584     { 0x0027, "Read, Write, Open, Parental"},
585     { 0x0028, "Create, Parental"},
586         { 0x0029, "Read, Create, Parental"},
587     { 0x002a, "Write, Create, Parental"},
588     { 0x002b, "Read, Write, Create, Parental"},
589     { 0x002c, "Open, Create, Parental"},
590         { 0x002d, "Read, Open, Create, Parental"},
591     { 0x002e, "Write, Open, Create, Parental"},
592     { 0x002f, "Read, Write, Open, Create, Parental"},
593     { 0x0030, "Delete, Parental"},
594         { 0x0031, "Read, Delete, Parental"},
595     { 0x0032, "Write, Delete, Parental"},
596     { 0x0033, "Read, Write, Delete, Parental"},
597     { 0x0034, "Open, Delete, Parental"},
598         { 0x0035, "Read, Open, Delete, Parental"},
599     { 0x0036, "Write, Open, Delete, Parental"},
600     { 0x0037, "Read, Write, Open, Delete, Parental"},
601     { 0x0038, "Create, Delete, Parental"},
602         { 0x0039, "Read, Create, Delete, Parental"},
603     { 0x003a, "Write, Create, Delete, Parental"},
604     { 0x003b, "Read, Write, Create, Delete, Parental"},
605     { 0x003c, "Open, Create, Delete, Parental"},
606         { 0x003d, "Read, Open, Create, Delete, Parental"},
607     { 0x003e, "Write, Open, Create, Delete, Parental"},
608     { 0x003f, "Read, Write, Open, Create, Delete, Parental"},
609     { 0x0040, "Search"},
610         { 0x0041, "Read, Search"},
611     { 0x0042, "Write, Search"},
612     { 0x0043, "Read, Write, Search"},
613     { 0x0044, "Open, Search"},
614         { 0x0045, "Read, Open, Search"},
615     { 0x0046, "Write, Open, Search"},
616     { 0x0047, "Read, Write, Open, Search"},
617     { 0x0048, "Create, Search"},
618         { 0x0049, "Read, Create, Search"},
619     { 0x004a, "Write, Create, Search"},
620     { 0x004b, "Read, Write, Create, Search"},
621     { 0x004c, "Open, Create, Search"},
622         { 0x004d, "Read, Open, Create, Search"},
623     { 0x004e, "Write, Open, Create, Search"},
624     { 0x004f, "Read, Write, Open, Create, Search"},
625     { 0x0050, "Delete, Search"},
626         { 0x0051, "Read, Delete, Search"},
627     { 0x0052, "Write, Delete, Search"},
628     { 0x0053, "Read, Write, Delete, Search"},
629     { 0x0054, "Open, Delete, Search"},
630         { 0x0055, "Read, Open, Delete, Search"},
631     { 0x0056, "Write, Open, Delete, Search"},
632     { 0x0057, "Read, Write, Open, Delete, Search"},
633     { 0x0058, "Create, Delete, Search"},
634         { 0x0059, "Read, Create, Delete, Search"},
635     { 0x005a, "Write, Create, Delete, Search"},
636     { 0x005b, "Read, Write, Create, Delete, Search"},
637     { 0x005c, "Open, Create, Delete, Search"},
638         { 0x005d, "Read, Open, Create, Delete, Search"},
639     { 0x005e, "Write, Open, Create, Delete, Search"},
640     { 0x005f, "Read, Write, Open, Create, Delete, Search"},
641     { 0x0060, "Parental, Search"},
642         { 0x0061, "Read, Parental, Search"},
643     { 0x0062, "Write, Parental, Search"},
644     { 0x0063, "Read, Write, Parental, Search"},
645     { 0x0064, "Open, Parental, Search"},
646         { 0x0065, "Read, Open, Parental, Search"},
647     { 0x0066, "Write, Open, Parental, Search"},
648     { 0x0067, "Read, Write, Open, Parental, Search"},
649     { 0x0068, "Create, Parental, Search"},
650         { 0x0069, "Read, Create, Parental, Search"},
651     { 0x006a, "Write, Create, Parental, Search"},
652     { 0x006b, "Read, Write, Create, Parental, Search"},
653     { 0x006c, "Open, Create, Parental, Search"},
654         { 0x006d, "Read, Open, Create, Parental, Search"},
655     { 0x006e, "Write, Open, Create, Parental, Search"},
656     { 0x006f, "Read, Write, Open, Create, Parental, Search"},
657     { 0x0070, "Delete, Parental, Search"},
658         { 0x0071, "Read, Delete, Parental, Search"},
659     { 0x0072, "Write, Delete, Parental, Search"},
660     { 0x0073, "Read, Write, Delete, Parental, Search"},
661     { 0x0074, "Open, Delete, Parental, Search"},
662         { 0x0075, "Read, Open, Delete, Parental, Search"},
663     { 0x0076, "Write, Open, Delete, Parental, Search"},
664     { 0x0077, "Read, Write, Open, Delete, Parental, Search"},
665     { 0x0078, "Create, Delete, Parental, Search"},
666         { 0x0079, "Read, Create, Delete, Parental, Search"},
667     { 0x007a, "Write, Create, Delete, Parental, Search"},
668     { 0x007b, "Read, Write, Create, Delete, Parental, Search"},
669     { 0x007c, "Open, Create, Delete, Parental, Search"},
670         { 0x007d, "Read, Open, Create, Delete, Parental, Search"},
671     { 0x007e, "Write, Open, Create, Delete, Parental, Search"},
672     { 0x007f, "Read, Write, Open, Create, Delete, Parental, Search"},
673     { 0x0080, "Modify"},
674         { 0x0081, "Read, Modify"},
675     { 0x0082, "Write, Modify"},
676     { 0x0083, "Read, Write, Modify"},
677     { 0x0084, "Open, Modify"},
678         { 0x0085, "Read, Open, Modify"},
679     { 0x0086, "Write, Open, Modify"},
680     { 0x0087, "Read, Write, Open, Modify"},
681     { 0x0088, "Create, Modify"},
682         { 0x0089, "Read, Create, Modify"},
683     { 0x008a, "Write, Create, Modify"},
684     { 0x008b, "Read, Write, Create, Modify"},
685     { 0x008c, "Open, Create, Modify"},
686         { 0x008d, "Read, Open, Create, Modify"},
687     { 0x008e, "Write, Open, Create, Modify"},
688     { 0x008f, "Read, Write, Open, Create, Modify"},
689     { 0x0090, "Delete, Modify"},
690         { 0x0091, "Read, Delete, Modify"},
691     { 0x0092, "Write, Delete, Modify"},
692     { 0x0093, "Read, Write, Delete, Modify"},
693     { 0x0094, "Open, Delete, Modify"},
694         { 0x0095, "Read, Open, Delete, Modify"},
695     { 0x0096, "Write, Open, Delete, Modify"},
696     { 0x0097, "Read, Write, Open, Delete, Modify"},
697     { 0x0098, "Create, Delete, Modify"},
698         { 0x0099, "Read, Create, Delete, Modify"},
699     { 0x009a, "Write, Create, Delete, Modify"},
700     { 0x009b, "Read, Write, Create, Delete, Modify"},
701     { 0x009c, "Open, Create, Delete, Modify"},
702         { 0x009d, "Read, Open, Create, Delete, Modify"},
703     { 0x009e, "Write, Open, Create, Delete, Modify"},
704     { 0x009f, "Read, Write, Open, Create, Delete, Modify"},
705     { 0x00a0, "Parental, Modify"},
706         { 0x00a1, "Read, Parental, Modify"},
707     { 0x00a2, "Write, Parental, Modify"},
708     { 0x00a3, "Read, Write, Parental, Modify"},
709     { 0x00a4, "Open, Parental, Modify"},
710         { 0x00a5, "Read, Open, Parental, Modify"},
711     { 0x00a6, "Write, Open, Parental, Modify"},
712     { 0x00a7, "Read, Write, Open, Parental, Modify"},
713     { 0x00a8, "Create, Parental, Modify"},
714         { 0x00a9, "Read, Create, Parental, Modify"},
715     { 0x00aa, "Write, Create, Parental, Modify"},
716     { 0x00ab, "Read, Write, Create, Parental, Modify"},
717     { 0x00ac, "Open, Create, Parental, Modify"},
718         { 0x00ad, "Read, Open, Create, Parental, Modify"},
719     { 0x00ae, "Write, Open, Create, Parental, Modify"},
720     { 0x00af, "Read, Write, Open, Create, Parental, Modify"},
721     { 0x00b0, "Delete, Parental, Modify"},
722         { 0x00b1, "Read, Delete, Parental, Modify"},
723     { 0x00b2, "Write, Delete, Parental, Modify"},
724     { 0x00b3, "Read, Write, Delete, Parental, Modify"},
725     { 0x00b4, "Open, Delete, Parental, Modify"},
726         { 0x00b5, "Read, Open, Delete, Parental, Modify"},
727     { 0x00b6, "Write, Open, Delete, Parental, Modify"},
728     { 0x00b7, "Read, Write, Open, Delete, Parental, Modify"},
729     { 0x00b8, "Create, Delete, Parental, Modify"},
730         { 0x00b9, "Read, Create, Delete, Parental, Modify"},
731     { 0x00ba, "Write, Create, Delete, Parental, Modify"},
732     { 0x00bb, "Read, Write, Create, Delete, Parental, Modify"},
733     { 0x00bc, "Open, Create, Delete, Parental, Modify"},
734         { 0x00bd, "Read, Open, Create, Delete, Parental, Modify"},
735     { 0x00be, "Write, Open, Create, Delete, Parental, Modify"},
736     { 0x00bf, "Read, Write, Open, Create, Delete, Parental, Modify"},
737     { 0x00c0, "Search, Modify"},
738         { 0x00c1, "Read, Search, Modify"},
739     { 0x00c2, "Write, Search, Modify"},
740     { 0x00c3, "Read, Write, Search, Modify"},
741     { 0x00c4, "Open, Search, Modify"},
742         { 0x00c5, "Read, Open, Search, Modify"},
743     { 0x00c6, "Write, Open, Search, Modify"},
744     { 0x00c7, "Read, Write, Open, Search, Modify"},
745     { 0x00c8, "Create, Search, Modify"},
746         { 0x00c9, "Read, Create, Search, Modify"},
747     { 0x00ca, "Write, Create, Search, Modify"},
748     { 0x00cb, "Read, Write, Create, Search, Modify"},
749     { 0x00cc, "Open, Create, Search, Modify"},
750         { 0x00cd, "Read, Open, Create, Search, Modify"},
751     { 0x00ce, "Write, Open, Create, Search, Modify"},
752     { 0x00cf, "Read, Write, Open, Create, Search, Modify"},
753     { 0x00d0, "Delete, Search, Modify"},
754         { 0x00d1, "Read, Delete, Search, Modify"},
755     { 0x00d2, "Write, Delete, Search, Modify"},
756     { 0x00d3, "Read, Write, Delete, Search, Modify"},
757     { 0x00d4, "Open, Delete, Search, Modify"},
758         { 0x00d5, "Read, Open, Delete, Search, Modify"},
759     { 0x00d6, "Write, Open, Delete, Search, Modify"},
760     { 0x00d7, "Read, Write, Open, Delete, Search, Modify"},
761     { 0x00d8, "Create, Delete, Search, Modify"},
762         { 0x00d9, "Read, Create, Delete, Search, Modify"},
763     { 0x00da, "Write, Create, Delete, Search, Modify"},
764     { 0x00db, "Read, Write, Create, Delete, Search, Modify"},
765     { 0x00dc, "Open, Create, Delete, Search, Modify"},
766         { 0x00dd, "Read, Open, Create, Delete, Search, Modify"},
767     { 0x00de, "Write, Open, Create, Delete, Search, Modify"},
768     { 0x00df, "Read, Write, Open, Create, Delete, Search, Modify"},
769     { 0x00e0, "Parental, Search, Modify"},
770         { 0x00e1, "Read, Parental, Search, Modify"},
771     { 0x00e2, "Write, Parental, Search, Modify"},
772     { 0x00e3, "Read, Write, Parental, Search, Modify"},
773     { 0x00e4, "Open, Parental, Search, Modify"},
774         { 0x00e5, "Read, Open, Parental, Search, Modify"},
775     { 0x00e6, "Write, Open, Parental, Search, Modify"},
776     { 0x00e7, "Read, Write, Open, Parental, Search, Modify"},
777     { 0x00e8, "Create, Parental, Search, Modify"},
778         { 0x00e9, "Read, Create, Parental, Search, Modify"},
779     { 0x00ea, "Write, Create, Parental, Search, Modify"},
780     { 0x00eb, "Read, Write, Create, Parental, Search, Modify"},
781     { 0x00ec, "Open, Create, Parental, Search, Modify"},
782         { 0x00ed, "Read, Open, Create, Parental, Search, Modify"},
783     { 0x00ee, "Write, Open, Create, Parental, Search, Modify"},
784     { 0x00ef, "Read, Write, Open, Create, Parental, Search, Modify"},
785     { 0x00f0, "Delete, Parental, Search, Modify"},
786         { 0x00f1, "Read, Delete, Parental, Search, Modify"},
787     { 0x00f2, "Write, Delete, Parental, Search, Modify"},
788     { 0x00f3, "Read, Write, Delete, Parental, Search, Modify"},
789     { 0x00f4, "Open, Delete, Parental, Search, Modify"},
790         { 0x00f5, "Read, Open, Delete, Parental, Search, Modify"},
791     { 0x00f6, "Write, Open, Delete, Parental, Search, Modify"},
792     { 0x00f7, "Read, Write, Open, Delete, Parental, Search, Modify"},
793     { 0x00f8, "Create, Delete, Parental, Search, Modify"},
794         { 0x00f9, "Read, Create, Delete, Parental, Search, Modify"},
795     { 0x00fa, "Write, Create, Delete, Parental, Search, Modify"},
796     { 0x00fb, "Read, Write, Create, Delete, Parental, Search, Modify"},
797     { 0x00fc, "Open, Create, Delete, Parental, Search, Modify"},
798         { 0x00fd, "Read, Open, Create, Delete, Parental, Search, Modify"},
799     { 0x00fe, "Write, Open, Create, Delete, Parental, Search, Modify"},
800     { 0x00ff, "Read, Write, Open, Create, Delete, Parental, Search, Modify"},
801     { 0x0100, "Supervisor"},
802         { 0x0101, "Read, Supervisor"},
803     { 0x0102, "Write, Supervisor"},
804     { 0x0103, "Read, Write, Supervisor"},
805     { 0x0104, "Open, Supervisor"},
806         { 0x0105, "Read, Open, Supervisor"},
807     { 0x0106, "Write, Open, Supervisor"},
808     { 0x0107, "Read, Write, Open, Supervisor"},
809     { 0x0108, "Create, Supervisor"},
810         { 0x0109, "Read, Create, Supervisor"},
811     { 0x010a, "Write, Create, Supervisor"},
812     { 0x010b, "Read, Write, Create, Supervisor"},
813     { 0x010c, "Open, Create, Supervisor"},
814         { 0x010d, "Read, Open, Create, Supervisor"},
815     { 0x010e, "Write, Open, Create, Supervisor"},
816     { 0x010f, "Read, Write, Open, Create, Supervisor"},
817     { 0x0110, "Delete, Supervisor"},
818         { 0x0111, "Read, Delete, Supervisor"},
819     { 0x0112, "Write, Delete, Supervisor"},
820     { 0x0113, "Read, Write, Delete, Supervisor"},
821     { 0x0114, "Open, Delete, Supervisor"},
822         { 0x0115, "Read, Open, Delete, Supervisor"},
823     { 0x0116, "Write, Open, Delete, Supervisor"},
824     { 0x0117, "Read, Write, Open, Delete, Supervisor"},
825     { 0x0118, "Create, Delete, Supervisor"},
826         { 0x0119, "Read, Create, Delete, Supervisor"},
827     { 0x011a, "Write, Create, Delete, Supervisor"},
828     { 0x011b, "Read, Write, Create, Delete, Supervisor"},
829     { 0x011c, "Open, Create, Delete, Supervisor"},
830         { 0x011d, "Read, Open, Create, Delete, Supervisor"},
831     { 0x011e, "Write, Open, Create, Delete, Supervisor"},
832     { 0x011f, "Read, Write, Open, Create, Delete, Supervisor"},
833     { 0x0120, "Parental, Supervisor"},
834         { 0x0121, "Read, Parental, Supervisor"},
835     { 0x0122, "Write, Parental, Supervisor"},
836     { 0x0123, "Read, Write, Parental, Supervisor"},
837     { 0x0124, "Open, Parental, Supervisor"},
838         { 0x0125, "Read, Open, Parental, Supervisor"},
839     { 0x0126, "Write, Open, Parental, Supervisor"},
840     { 0x0127, "Read, Write, Open, Parental, Supervisor"},
841     { 0x0128, "Create, Parental, Supervisor"},
842         { 0x0129, "Read, Create, Parental, Supervisor"},
843     { 0x012a, "Write, Create, Parental, Supervisor"},
844     { 0x012b, "Read, Write, Create, Parental, Supervisor"},
845     { 0x012c, "Open, Create, Parental, Supervisor"},
846         { 0x012d, "Read, Open, Create, Parental, Supervisor"},
847     { 0x012e, "Write, Open, Create, Parental, Supervisor"},
848     { 0x012f, "Read, Write, Open, Create, Parental, Supervisor"},
849     { 0x0130, "Delete, Parental, Supervisor"},
850         { 0x0131, "Read, Delete, Parental, Supervisor"},
851     { 0x0132, "Write, Delete, Parental, Supervisor"},
852     { 0x0133, "Read, Write, Delete, Parental, Supervisor"},
853     { 0x0134, "Open, Delete, Parental, Supervisor"},
854         { 0x0135, "Read, Open, Delete, Parental, Supervisor"},
855     { 0x0136, "Write, Open, Delete, Parental, Supervisor"},
856     { 0x0137, "Read, Write, Open, Delete, Parental, Supervisor"},
857     { 0x0138, "Create, Delete, Parental, Supervisor"},
858         { 0x0139, "Read, Create, Delete, Parental, Supervisor"},
859     { 0x013a, "Write, Create, Delete, Parental, Supervisor"},
860     { 0x013b, "Read, Write, Create, Delete, Parental, Supervisor"},
861     { 0x013c, "Open, Create, Delete, Parental, Supervisor"},
862         { 0x013d, "Read, Open, Create, Delete, Parental, Supervisor"},
863     { 0x013e, "Write, Open, Create, Delete, Parental, Supervisor"},
864     { 0x013f, "Read, Write, Open, Create, Delete, Parental, Supervisor"},
865     { 0x0140, "Search, Supervisor"},
866         { 0x0141, "Read, Search, Supervisor"},
867     { 0x0142, "Write, Search, Supervisor"},
868     { 0x0143, "Read, Write, Search, Supervisor"},
869     { 0x0144, "Open, Search, Supervisor"},
870         { 0x0145, "Read, Open, Search, Supervisor"},
871     { 0x0146, "Write, Open, Search, Supervisor"},
872     { 0x0147, "Read, Write, Open, Search, Supervisor"},
873     { 0x0148, "Create, Search, Supervisor"},
874         { 0x0149, "Read, Create, Search, Supervisor"},
875     { 0x014a, "Write, Create, Search, Supervisor"},
876     { 0x014b, "Read, Write, Create, Search, Supervisor"},
877     { 0x014c, "Open, Create, Search, Supervisor"},
878         { 0x014d, "Read, Open, Create, Search, Supervisor"},
879     { 0x014e, "Write, Open, Create, Search, Supervisor"},
880     { 0x014f, "Read, Write, Open, Create, Search, Supervisor"},
881     { 0x0150, "Delete, Search, Supervisor"},
882         { 0x0151, "Read, Delete, Search, Supervisor"},
883     { 0x0152, "Write, Delete, Search, Supervisor"},
884     { 0x0153, "Read, Write, Delete, Search, Supervisor"},
885     { 0x0154, "Open, Delete, Search, Supervisor"},
886         { 0x0155, "Read, Open, Delete, Search, Supervisor"},
887     { 0x0156, "Write, Open, Delete, Search, Supervisor"},
888     { 0x0157, "Read, Write, Open, Delete, Search, Supervisor"},
889     { 0x0158, "Create, Delete, Search, Supervisor"},
890         { 0x0159, "Read, Create, Delete, Search, Supervisor"},
891     { 0x015a, "Write, Create, Delete, Search, Supervisor"},
892     { 0x015b, "Read, Write, Create, Delete, Search, Supervisor"},
893     { 0x015c, "Open, Create, Delete, Search, Supervisor"},
894         { 0x015d, "Read, Open, Create, Delete, Search, Supervisor"},
895     { 0x015e, "Write, Open, Create, Delete, Search, Supervisor"},
896     { 0x015f, "Read, Write, Open, Create, Delete, Search, Supervisor"},
897     { 0x0160, "Parental, Search, Supervisor"},
898         { 0x0161, "Read, Parental, Search, Supervisor"},
899     { 0x0162, "Write, Parental, Search, Supervisor"},
900     { 0x0163, "Read, Write, Parental, Search, Supervisor"},
901     { 0x0164, "Open, Parental, Search, Supervisor"},
902         { 0x0165, "Read, Open, Parental, Search, Supervisor"},
903     { 0x0166, "Write, Open, Parental, Search, Supervisor"},
904     { 0x0167, "Read, Write, Open, Parental, Search, Supervisor"},
905     { 0x0168, "Create, Parental, Search, Supervisor"},
906         { 0x0169, "Read, Create, Parental, Search, Supervisor"},
907     { 0x016a, "Write, Create, Parental, Search, Supervisor"},
908     { 0x016b, "Read, Write, Create, Parental, Search, Supervisor"},
909     { 0x016c, "Open, Create, Parental, Search, Supervisor"},
910         { 0x016d, "Read, Open, Create, Parental, Search, Supervisor"},
911     { 0x016e, "Write, Open, Create, Parental, Search, Supervisor"},
912     { 0x016f, "Read, Write, Open, Create, Parental, Search, Supervisor"},
913     { 0x0170, "Delete, Parental, Search, Supervisor"},
914         { 0x0171, "Read, Delete, Parental, Search, Supervisor"},
915     { 0x0172, "Write, Delete, Parental, Search, Supervisor"},
916     { 0x0173, "Read, Write, Delete, Parental, Search, Supervisor"},
917     { 0x0174, "Open, Delete, Parental, Search, Supervisor"},
918         { 0x0175, "Read, Open, Delete, Parental, Search, Supervisor"},
919     { 0x0176, "Write, Open, Delete, Parental, Search, Supervisor"},
920     { 0x0177, "Read, Write, Open, Delete, Parental, Search, Supervisor"},
921     { 0x0178, "Create, Delete, Parental, Search, Supervisor"},
922         { 0x0179, "Read, Create, Delete, Parental, Search, Supervisor"},
923     { 0x017a, "Write, Create, Delete, Parental, Search, Supervisor"},
924     { 0x017b, "Read, Write, Create, Delete, Parental, Search, Supervisor"},
925     { 0x017c, "Open, Create, Delete, Parental, Search, Supervisor"},
926         { 0x017d, "Read, Open, Create, Delete, Parental, Search, Supervisor"},
927     { 0x017e, "Write, Open, Create, Delete, Parental, Search, Supervisor"},
928     { 0x017f, "Read, Write, Open, Create, Delete, Parental, Search, Supervisor"},
929     { 0x0180, "Modify, Supervisor"},
930         { 0x0181, "Read, Modify, Supervisor"},
931     { 0x0182, "Write, Modify, Supervisor"},
932     { 0x0183, "Read, Write, Modify, Supervisor"},
933     { 0x0184, "Open, Modify, Supervisor"},
934         { 0x0185, "Read, Open, Modify, Supervisor"},
935     { 0x0186, "Write, Open, Modify, Supervisor"},
936     { 0x0187, "Read, Write, Open, Modify, Supervisor"},
937     { 0x0188, "Create, Modify, Supervisor"},
938         { 0x0189, "Read, Create, Modify, Supervisor"},
939     { 0x018a, "Write, Create, Modify, Supervisor"},
940     { 0x018b, "Read, Write, Create, Modify, Supervisor"},
941     { 0x018c, "Open, Create, Modify, Supervisor"},
942         { 0x018d, "Read, Open, Create, Modify, Supervisor"},
943     { 0x018e, "Write, Open, Create, Modify, Supervisor"},
944     { 0x018f, "Read, Write, Open, Create, Modify, Supervisor"},
945     { 0x0190, "Delete, Modify, Supervisor"},
946         { 0x0191, "Read, Delete, Modify, Supervisor"},
947     { 0x0192, "Write, Delete, Modify, Supervisor"},
948     { 0x0193, "Read, Write, Delete, Modify, Supervisor"},
949     { 0x0194, "Open, Delete, Modify, Supervisor"},
950         { 0x0195, "Read, Open, Delete, Modify, Supervisor"},
951     { 0x0196, "Write, Open, Delete, Modify, Supervisor"},
952     { 0x0197, "Read, Write, Open, Delete, Modify, Supervisor"},
953     { 0x0198, "Create, Delete, Modify, Supervisor"},
954         { 0x0199, "Read, Create, Delete, Modify, Supervisor"},
955     { 0x019a, "Write, Create, Delete, Modify, Supervisor"},
956     { 0x019b, "Read, Write, Create, Delete, Modify, Supervisor"},
957     { 0x019c, "Open, Create, Delete, Modify, Supervisor"},
958         { 0x019d, "Read, Open, Create, Delete, Modify, Supervisor"},
959     { 0x019e, "Write, Open, Create, Delete, Modify, Supervisor"},
960     { 0x019f, "Read, Write, Open, Create, Delete, Modify, Supervisor"},
961     { 0x01a0, "Parental, Modify, Supervisor"},
962         { 0x01a1, "Read, Parental, Modify, Supervisor"},
963     { 0x01a2, "Write, Parental, Modify, Supervisor"},
964     { 0x01a3, "Read, Write, Parental, Modify, Supervisor"},
965     { 0x01a4, "Open, Parental, Modify, Supervisor"},
966         { 0x01a5, "Read, Open, Parental, Modify, Supervisor"},
967     { 0x01a6, "Write, Open, Parental, Modify, Supervisor"},
968     { 0x01a7, "Read, Write, Open, Parental, Modify, Supervisor"},
969     { 0x01a8, "Create, Parental, Modify, Supervisor"},
970         { 0x01a9, "Read, Create, Parental, Modify, Supervisor"},
971     { 0x01aa, "Write, Create, Parental, Modify, Supervisor"},
972     { 0x01ab, "Read, Write, Create, Parental, Modify, Supervisor"},
973     { 0x01ac, "Open, Create, Parental, Modify, Supervisor"},
974         { 0x01ad, "Read, Open, Create, Parental, Modify, Supervisor"},
975     { 0x01ae, "Write, Open, Create, Parental, Modify, Supervisor"},
976     { 0x01af, "Read, Write, Open, Create, Parental, Modify, Supervisor"},
977     { 0x01b0, "Delete, Parental, Modify, Supervisor"},
978         { 0x01b1, "Read, Delete, Parental, Modify, Supervisor"},
979     { 0x01b2, "Write, Delete, Parental, Modify, Supervisor"},
980     { 0x01b3, "Read, Write, Delete, Parental, Modify, Supervisor"},
981     { 0x01b4, "Open, Delete, Parental, Modify, Supervisor"},
982         { 0x01b5, "Read, Open, Delete, Parental, Modify, Supervisor"},
983     { 0x01b6, "Write, Open, Delete, Parental, Modify, Supervisor"},
984     { 0x01b7, "Read, Write, Open, Delete, Parental, Modify, Supervisor"},
985     { 0x01b8, "Create, Delete, Parental, Modify, Supervisor"},
986         { 0x01b9, "Read, Create, Delete, Parental, Modify, Supervisor"},
987     { 0x01ba, "Write, Create, Delete, Parental, Modify, Supervisor"},
988     { 0x01bb, "Read, Write, Create, Delete, Parental, Modify, Supervisor"},
989     { 0x01bc, "Open, Create, Delete, Parental, Modify, Supervisor"},
990         { 0x01bd, "Read, Open, Create, Delete, Parental, Modify, Supervisor"},
991     { 0x01be, "Write, Open, Create, Delete, Parental, Modify, Supervisor"},
992     { 0x01bf, "Read, Write, Open, Create, Delete, Parental, Modify, Supervisor"},
993     { 0x01c0, "Search, Modify, Supervisor"},
994         { 0x01c1, "Read, Search, Modify, Supervisor"},
995     { 0x01c2, "Write, Search, Modify, Supervisor"},
996     { 0x01c3, "Read, Write, Search, Modify, Supervisor"},
997     { 0x01c4, "Open, Search, Modify, Supervisor"},
998         { 0x01c5, "Read, Open, Search, Modify, Supervisor"},
999     { 0x01c6, "Write, Open, Search, Modify, Supervisor"},
1000     { 0x01c7, "Read, Write, Open, Search, Modify, Supervisor"},
1001     { 0x01c8, "Create, Search, Modify, Supervisor"},
1002         { 0x01c9, "Read, Create, Search, Modify, Supervisor"},
1003     { 0x01ca, "Write, Create, Search, Modify, Supervisor"},
1004     { 0x01cb, "Read, Write, Create, Search, Modify, Supervisor"},
1005     { 0x01cc, "Open, Create, Search, Modify, Supervisor"},
1006         { 0x01cd, "Read, Open, Create, Search, Modify, Supervisor"},
1007     { 0x01ce, "Write, Open, Create, Search, Modify, Supervisor"},
1008     { 0x01cf, "Read, Write, Open, Create, Search, Modify, Supervisor"},
1009     { 0x01d0, "Delete, Search, Modify, Supervisor"},
1010         { 0x01d1, "Read, Delete, Search, Modify, Supervisor"},
1011     { 0x01d2, "Write, Delete, Search, Modify, Supervisor"},
1012     { 0x01d3, "Read, Write, Delete, Search, Modify, Supervisor"},
1013     { 0x01d4, "Open, Delete, Search, Modify, Supervisor"},
1014         { 0x01d5, "Read, Open, Delete, Search, Modify, Supervisor"},
1015     { 0x01d6, "Write, Open, Delete, Search, Modify, Supervisor"},
1016     { 0x01d7, "Read, Write, Open, Delete, Search, Modify, Supervisor"},
1017     { 0x01d8, "Create, Delete, Search, Modify, Supervisor"},
1018         { 0x01d9, "Read, Create, Delete, Search, Modify, Supervisor"},
1019     { 0x01da, "Write, Create, Delete, Search, Modify, Supervisor"},
1020     { 0x01db, "Read, Write, Create, Delete, Search, Modify, Supervisor"},
1021     { 0x01dc, "Open, Create, Delete, Search, Modify, Supervisor"},
1022         { 0x01dd, "Read, Open, Create, Delete, Search, Modify, Supervisor"},
1023     { 0x01de, "Write, Open, Create, Delete, Search, Modify, Supervisor"},
1024     { 0x01df, "Read, Write, Open, Create, Delete, Search, Modify, Supervisor"},
1025     { 0x01e0, "Parental, Search, Modify, Supervisor"},
1026         { 0x01e1, "Read, Parental, Search, Modify, Supervisor"},
1027     { 0x01e2, "Write, Parental, Search, Modify, Supervisor"},
1028     { 0x01e3, "Read, Write, Parental, Search, Modify, Supervisor"},
1029     { 0x01e4, "Open, Parental, Search, Modify, Supervisor"},
1030         { 0x01e5, "Read, Open, Parental, Search, Modify, Supervisor"},
1031     { 0x01e6, "Write, Open, Parental, Search, Modify, Supervisor"},
1032     { 0x01e7, "Read, Write, Open, Parental, Search, Modify, Supervisor"},
1033     { 0x01e8, "Create, Parental, Search, Modify, Supervisor"},
1034         { 0x01e9, "Read, Create, Parental, Search, Modify, Supervisor"},
1035     { 0x01ea, "Write, Create, Parental, Search, Modify, Supervisor"},
1036     { 0x01eb, "Read, Write, Create, Parental, Search, Modify, Supervisor"},
1037     { 0x01ec, "Open, Create, Parental, Search, Modify, Supervisor"},
1038         { 0x01ed, "Read, Open, Create, Parental, Search, Modify, Supervisor"},
1039     { 0x01ee, "Write, Open, Create, Parental, Search, Modify, Supervisor"},
1040     { 0x01ef, "Read, Write, Open, Create, Parental, Search, Modify, Supervisor"},
1041     { 0x01f0, "Delete, Parental, Search, Modify, Supervisor"},
1042         { 0x01f1, "Read, Delete, Parental, Search, Modify, Supervisor"},
1043     { 0x01f2, "Write, Delete, Parental, Search, Modify, Supervisor"},
1044     { 0x01f3, "Read, Write, Delete, Parental, Search, Modify, Supervisor"},
1045     { 0x01f4, "Open, Delete, Parental, Search, Modify, Supervisor"},
1046         { 0x01f5, "Read, Open, Delete, Parental, Search, Modify, Supervisor"},
1047     { 0x01f6, "Write, Open, Delete, Parental, Search, Modify, Supervisor"},
1048     { 0x01f7, "Read, Write, Open, Delete, Parental, Search, Modify, Supervisor"},
1049     { 0x01f8, "Create, Delete, Parental, Search, Modify, Supervisor"},
1050         { 0x01f9, "Read, Create, Delete, Parental, Search, Modify, Supervisor"},
1051     { 0x01fa, "Write, Create, Delete, Parental, Search, Modify, Supervisor"},
1052     { 0x01fb, "Read, Write, Create, Delete, Parental, Search, Modify, Supervisor"},
1053     { 0x01fc, "Open, Create, Delete, Parental, Search, Modify, Supervisor"},
1054         { 0x01fd, "Read, Open, Create, Delete, Parental, Search, Modify, Supervisor"},
1055     { 0x01fe, "Write, Open, Create, Delete, Parental, Search, Modify, Supervisor"},
1056     { 0x01ff, "Read, Write, Open, Create, Delete, Parental, Search, Modify, Supervisor"},
1057     { 0,    NULL }
1058 };
1059
1060
1061 static const value_string nds_reply_errors[] = {
1062         { 0xffffffff, "(-1) Insufficient Space" },
1063         { 0xffffff89, "(-119) Buffer too Small" },
1064         { 0xffffff88, "(-120) RR Volume Flag Not Set" },
1065         { 0xffffff87, "(-121) No Items Found" },
1066         { 0xffffff86, "(-122) Connection Already Temporary" },
1067         { 0xffffff85, "(-123) Connection Already Logged In" },
1068         { 0xffffff84, "(-124) Connection Not Authenticated" },
1069         { 0xffffff83, "(-125) Connection Not Logged In" },
1070         { 0xffffff82, "(-126) NCP Boundary Check Failed" },
1071         { 0xffffff81, "(-127) Lock Waiting" },
1072         { 0xffffff80, "(-128) Lock Fail" },
1073         { 0xffffff7f, "(-129) Out of Handles" },
1074         { 0xffffff7e, "(-130) No Open Privilege" },
1075         { 0xffffff7d, "(-131) Hard IO Error" },
1076         { 0xffffff7c, "(-132) No Create Privilege" },
1077         { 0xffffff7b, "(-133) No Create Delete Privilege" },
1078         { 0xffffff7a, "(-134) Create Duplicate When Read Only" },
1079         { 0xffffff79, "(-135) Create File with Invalid Name" },
1080         { 0xffffff78, "(-136) Invalid File Handle" },
1081         { 0xffffff77, "(-137) No Search Privilege"   },
1082         { 0xffffff76, "(-138) No Delete Privilege" },
1083         { 0xffffff75, "(-139) No Rename Privilege" },
1084         { 0xffffff74, "(-140) No Set Privilege" },
1085         { 0xffffff73, "(-141) Some File in Use" },
1086         { 0xffffff72, "(-142) All File in Use" },
1087         { 0xffffff71, "(-143) Some Read Only" },
1088         { 0xffffff70, "(-144) All Read Only" },
1089         { 0xffffff6f, "(-145) Some names Exist" },
1090         { 0xffffff6e, "(-146) All Names Exist" },
1091         { 0xffffff6d, "(-147) No Read Privilege" },
1092         { 0xffffff6c, "(-148) No Write Privilege" },
1093         { 0xffffff6b, "(-149) File Detached" },
1094         { 0xffffff6a, "(-150) No Alloc Space/Target Not a Subdirectory/Insuffficient Memory" },
1095         { 0xffffff69, "(-151) No Spool Space" },
1096         { 0xffffff68, "(-152) Invalid Volume" },
1097         { 0xffffff67, "(-153) Directory Full" },
1098         { 0xffffff66, "(-154) Rename Across Volume" },
1099         { 0xffffff65, "(-155) Bad Directory Handle" },
1100         { 0xffffff64, "(-156) Invalid Path/No Such Extension" },
1101         { 0xffffff63, "(-157) No Directory Handles" },
1102         { 0xffffff62, "(-158) Bad File Name" },
1103         { 0xffffff61, "(-159) Directory Active" },
1104         { 0xffffff60, "(-160) Directory Not Empty" },
1105         { 0xffffff5f, "(-161) Directory IO Error" },
1106         { 0xffffff5e, "(-162) IO Locked" },
1107         { 0xffffff5d, "(-163) Transaction Restarted" },
1108         { 0xffffff5c, "(-164) Rename Directory Invalid" },
1109         { 0xffffff5b, "(-165) Invalid Open/Create Mode" },
1110         { 0xffffff5a, "(-166) Already in Use" },
1111         { 0xffffff59, "(-167) Invalid Resource Tag" },
1112         { 0xffffff58, "(-168) Access Denied" },
1113         { 0xffffff44, "(-188) Login Signing Required" },
1114         { 0xffffff43, "(-189) Login Encryption Required" },
1115         { 0xffffff42, "(-190) Invalid Data Stream" },
1116         { 0xffffff41, "(-191) Invalid Name Space" },
1117         { 0xffffff40, "(-192) No Accounting Privileges" },
1118         { 0xffffff3f, "(-193) No Account Balance" },
1119         { 0xffffff3e, "(-194) Credit Limit Exceeded" },
1120         { 0xffffff3d, "(-195) Too Many Holds" },
1121         { 0xffffff3c, "(-196) Accounting Disabled" },
1122         { 0xffffff3b, "(-197) Intruder Login Lockout" },
1123         { 0xffffff3a, "(-198) No Console Rights" },
1124         { 0xffffff30, "(-208) Queue IO Failure" },
1125         { 0xffffff2f, "(-209) No Queue" },
1126         { 0xffffff2e, "(-210) No Queue Server" },
1127         { 0xffffff2d, "(-211) No Queue Rights" },
1128         { 0xffffff2c, "(-212) Queue Full" },
1129         { 0xffffff2b, "(-213) No Queue Job" },
1130         { 0xffffff2a, "(-214) No Queue Job Rights/Unencrypted Not Allowed" },
1131         { 0xffffff29, "(-215) Queue In Service/Duplicate Password" },
1132         { 0xffffff28, "(-216) Queue Not Active/Password Too Short" },
1133         { 0xffffff27, "(-217) Queue Station Not Server/Maximum Logins Exceeded" },
1134         { 0xffffff26, "(-218) Queue Halted/Bad Login Time" },
1135         { 0xffffff25, "(-219) Queue Maximum Servers/Node Address Violation" },
1136         { 0xffffff24, "(-220) Login Account Expired" },
1137         { 0xffffff22, "(-222) Bad Password" },
1138         { 0xffffff21, "(-223) Password Expired" },
1139         { 0xffffff20, "(-224) No Login Connection Available" },
1140         { 0xffffff18, "(-232) Write to Group Property" },
1141         { 0xffffff17, "(-233) Member Already Exists" },
1142         { 0xffffff16, "(-234) No Such Member" },
1143         { 0xffffff15, "(-235) Property Not Group" },
1144         { 0xffffff14, "(-236) No Such Value Set" },
1145         { 0xffffff13, "(-237) Property Already Exists" },
1146         { 0xffffff12, "(-238) Object Already Exists" },
1147         { 0xffffff11, "(-239) Illegal Name" },
1148         { 0xffffff10, "(-240) Illegal Wildcard" },
1149         { 0xffffff0f, "(-241) Bindery Security" },
1150         { 0xffffff0e, "(-242) No Object Read Rights" },
1151         { 0xffffff0d, "(-243) No Object Rename Rights" },
1152         { 0xffffff0c, "(-244) No Object Delete Rights" },
1153         { 0xffffff0b, "(-245) No Object Create Rights" },
1154         { 0xffffff0a, "(-246) No Property Delete Rights" },
1155         { 0xffffff09, "(-247) No Property Create Rigths" },
1156         { 0xffffff08, "(-248) No Property Write Rights" },
1157         { 0xffffff07, "(-249) No Propery Read Rights" },
1158         { 0xffffff06, "(-250) Temp Remap" },
1159         { 0xffffff05, "(-251) Unknown Request/No Such Property" },
1160         { 0xffffff04, "(-252) Message Queue Full/Target Already Has Message/No Such Object" },
1161         { 0xffffff03, "(-253) Bad Station Number" },
1162         { 0xffffff02, "(-254) Bindery Locked/Directory Locked/Spool Delete/Trustee not Found/Timeout" },
1163         { 0xffffff01, "(-255) Hard Failure" },
1164         { 0xfffffed3, "(-301) Not Enough Memory" },
1165         { 0xfffffed2, "(-302) Bad Key" },
1166         { 0xfffffed1, "(-303) Bad Context" },
1167         { 0xfffffed0, "(-304) Buffer Full" },
1168         { 0xfffffecf, "(-305) List Empty" },
1169         { 0xfffffece, "(-306) Bad Syntax"   },
1170         { 0xfffffecd, "(-307) Buffer Empty" },
1171         { 0xfffffecc, "(-308) Bad Verb" },
1172         { 0xfffffecb, "(-309) Expected Identifier" },
1173         { 0xfffffeca, "(-310) Expected Equals" },
1174         { 0xfffffec9, "(-311) Attribute Type Expected" },
1175         { 0xfffffec8, "(-312) Attribute Type Not Expected" },
1176         { 0xfffffec7, "(-313) Filter Tree Empty" },
1177         { 0xfffffec6, "(-314) Invalid Object Name" },
1178         { 0xfffffec5, "(-315) Expected RDN Delimiter" },
1179         { 0xfffffec4, "(-316) Too Many Tokens" },
1180         { 0xfffffec3, "(-317) Inconsistent MultiAVA" },
1181         { 0xfffffec2, "(-318) Country Name Too Long" },
1182         { 0xfffffec1, "(-319) Internal Error" },
1183         { 0xfffffec0, "(-320) Can't Add Root" },
1184         { 0xfffffebf, "(-321) Unable to Attach" },
1185         { 0xfffffebe, "(-322) Invalid Iteration Handle" },
1186         { 0xfffffebd, "(-323) Buffer Zero Length" },
1187         { 0xfffffebc, "(-324) Invalid Replica Type" },
1188         { 0xfffffebb, "(-325) Invalid Attribute Syntax" },
1189         { 0xfffffeba, "(-326) Invalid Filter Syntax" },
1190         { 0xfffffeb8, "(-328) Unicode Error during Context Creation" },
1191         { 0xfffffeb7, "(-329) Invalid Union Tag" },
1192         { 0xfffffeb6, "(-330) Invalid Server Response" },
1193         { 0xfffffeb5, "(-331) Null Pointer" },
1194         { 0xfffffeb4, "(-332) No Server Found" },
1195         { 0xfffffeb3, "(-333) No Connection" },
1196         { 0xfffffeb2, "(-334) RDN Too Long" },
1197         { 0xfffffeb1, "(-335) Duplicate Type" },
1198         { 0xfffffeb0, "(-336) Data Store Failure" },
1199         { 0xfffffeaf, "(-337) Not Logged In" },
1200         { 0xfffffeae, "(-338) Invalid Password Characters" },
1201         { 0xfffffead, "(-339) Failed Server Authentication" },
1202         { 0xfffffeac, "(-340) Transport Failed" },
1203         { 0xfffffeab, "(-341) No Such Syntax" },
1204         { 0xfffffeaa, "(-342) Invalid DS Name" },
1205         { 0xfffffea9, "(-343) Attribute Name Too Long" },
1206         { 0xfffffea8, "(-344) Invalid TDS" },
1207         { 0xfffffea7, "(-345) Invalid DS Version" },
1208         { 0xfffffea6, "(-346) Unicode Translation" },
1209         { 0xfffffea5, "(-347) Schema Name Too Long" },
1210         { 0xfffffea4, "(-348) Unicode File Not Found" },
1211         { 0xfffffea3, "(-349) Unicode Already Loaded" },
1212         { 0xfffffea2, "(-350) Not Context Owner" },
1213         { 0xfffffea1, "(-351) Attempt to Authenticate" },
1214         { 0xfffffea0, "(-352) No Writable Replicas" },
1215         { 0xfffffe9f, "(-353) DN Too Long" },
1216         { 0xfffffe9e, "(-354) Rename Not Allowed" },
1217         { 0xfffffe9d, "(-355) Not NDS for NT" },
1218         { 0xfffffe9c, "(-356) NDS for NT - No Domain" },
1219         { 0xfffffe9b, "(-357) NDS for NT - Sync Disabled" },
1220         { 0xfffffe9a, "(-358) Iterator Invalid Handle" },
1221         { 0xfffffe99, "(-359) Iterator Invalid Position" },
1222         { 0xfffffe98, "(-360) Iterator Invalid Search Data" },
1223         { 0xfffffe97, "(-361) Iterator Invalid Scope" },
1224         { 0xfffffda7, "(-601) No Such Entry" },
1225         { 0xfffffda6, "(-602) No Such Value" },
1226         { 0xfffffda5, "(-603) No Such Attribute" },
1227         { 0xfffffda4, "(-604) No Such Class" },
1228         { 0xfffffda3, "(-605) No Such Partition" },
1229         { 0xfffffda2, "(-606) Entry Already Exists" },
1230         { 0xfffffda1, "(-607) Not Effective Class" },
1231         { 0xfffffda0, "(-608) Illegal Attribute" },
1232         { 0xfffffd9f, "(-609) Missing Mandatory" },
1233         { 0xfffffd9e, "(-610) Illegal DS Name" },
1234         { 0xfffffd9d, "(-611) Illegal Containment" },
1235         { 0xfffffd9c, "(-612) Can't Have Multiple Values" },
1236         { 0xfffffd9b, "(-613) Syntax Violation" },
1237         { 0xfffffd9a, "(-614) Duplicate Value" },
1238         { 0xfffffd99, "(-615) Attribute Already Exists" },
1239         { 0xfffffd98, "(-616) Maximum Entries Exist" },
1240         { 0xfffffd97, "(-617) Database Format" },
1241         { 0xfffffd96, "(-618) Inconsistent Database" },
1242         { 0xfffffd95, "(-619) Invalid Comparison" },
1243         { 0xfffffd94, "(-620) Comparison Failed" },
1244         { 0xfffffd93, "(-621) Transaction Tracking Disabled" },
1245         { 0xfffffd92, "(-622) Invalid Transport" },
1246         { 0xfffffd91, "(-623) Syntax Invalid in Name" },
1247         { 0xfffffd90, "(-624) Replica Already Exists" },
1248         { 0xfffffd8f, "(-625) Transport Failure" },
1249         { 0xfffffd8e, "(-626) All Referrals Failed" },
1250         { 0xfffffd8d, "(-627) Can't Remove Naming Value" },
1251         { 0xfffffd8c, "(-628) Object Class Violation" },
1252         { 0xfffffd8b, "(-629) Entry is Not Leaf" },
1253         { 0xfffffd8a, "(-630) Different Tree" },
1254         { 0xfffffd89, "(-631) Illegal Replica Type" },
1255         { 0xfffffd88, "(-632) System Failure" },
1256         { 0xfffffd87, "(-633) Invalid Entry for Root" },
1257         { 0xfffffd86, "(-634) No Referrals" },
1258         { 0xfffffd85, "(-635) Remote Failure" },
1259         { 0xfffffd84, "(-636) Unreachable Server" },
1260         { 0xfffffd83, "(-637) Previous Move in Progress" },
1261         { 0xfffffd82, "(-638) No Character Mapping" },
1262         { 0xfffffd81, "(-639) Incomplete Authentication" },
1263         { 0xfffffd80, "(-640) Invalid Certificate" },
1264         { 0xfffffd7f, "(-641) Invalid Request" },
1265         { 0xfffffd7e, "(-642) Invalid Iteration" },
1266         { 0xfffffd7d, "(-643) Schema is Non-removable" },
1267         { 0xfffffd7c, "(-644) Schema is in Use" },
1268         { 0xfffffd7b, "(-645) Class Already Exists" },
1269         { 0xfffffd7a, "(-646) Bad Naming Attributes" },
1270         { 0xfffffd79, "(-647) Not Root Partition" },
1271         { 0xfffffd78, "(-648) Insufficient Stack" },
1272         { 0xfffffd77, "(-649) Insufficient Buffer" },
1273         { 0xfffffd76, "(-650) Ambiguous Containment" },
1274         { 0xfffffd75, "(-651) Ambiguous Naming" },
1275         { 0xfffffd74, "(-652) Duplicate Mandatory" },
1276         { 0xfffffd73, "(-653) Duplicate Optional" },
1277         { 0xfffffd72, "(-654) Partition Busy" },
1278         { 0xfffffd71, "(-655) Multiple Replicas" },
1279         { 0xfffffd70, "(-656) Crucial Replica" },
1280         { 0xfffffd6f, "(-657) Schema Sync in Progress" },
1281         { 0xfffffd6e, "(-658) Skulk in Progress" },
1282         { 0xfffffd6d, "(-659) Time Not Synchronized" },
1283         { 0xfffffd6c, "(-660) Record in Use" },
1284         { 0xfffffd6b, "(-661) DS Volume Not Mounted" },
1285         { 0xfffffd6a, "(-662) DS Volume IO Failure" },
1286         { 0xfffffd69, "(-663) DS Locked" },
1287         { 0xfffffd68, "(-664) Old Epoch" },
1288         { 0xfffffd67, "(-665) New Epoch" },
1289         { 0xfffffd66, "(-666) Incompatible DS Version" },
1290         { 0xfffffd65, "(-667) Partition Root" },
1291         { 0xfffffd64, "(-668) Entry Not Container" },
1292         { 0xfffffd63, "(-669) Failed Authentication" },
1293         { 0xfffffd62, "(-670) Invalid Context" },
1294         { 0xfffffd61, "(-671) No Such Parent" },
1295         { 0xfffffd60, "(-672) No Access" },
1296         { 0xfffffd5f, "(-673) Replica Not On" },
1297         { 0xfffffd5e, "(-674) Invalid Name Service" },
1298         { 0xfffffd5d, "(-675) Invalid Task" },
1299         { 0xfffffd5c, "(-676) Invalide Connection Handle" },
1300         { 0xfffffd5b, "(-677) Invalid Identity" },
1301         { 0xfffffd5a, "(-678) Duplicate ACL" },
1302         { 0xfffffd59, "(-679) Partition Already Exists" },
1303         { 0xfffffd58, "(-680) Transport Modified" },
1304         { 0xfffffd57, "(-681) Alias of an Alias" },
1305         { 0xfffffd56, "(-682) Auditing Failed" },
1306         { 0xfffffd55, "(-683) Invalid API Version" },
1307         { 0xfffffd54, "(-684) Secure NCP Violation" },
1308         { 0xfffffd53, "(-685) Move in Progress" },
1309         { 0xfffffd52, "(-686) Not a Leaf Partition" },
1310         { 0xfffffd51, "(-687) Cannot Abort" },
1311         { 0xfffffd50, "(-688) Cache Overflow" },
1312         { 0xfffffd4f, "(-689) Invalid Subordinate Count" },
1313         { 0xfffffd4e, "(-690) Invalid RDN" },
1314         { 0xfffffd4d, "(-691) Modification Time Not Current" },
1315         { 0xfffffd4c, "(-692) Incorrect Base Class" },
1316         { 0xfffffd4b, "(-693) Missing Reference" },
1317         { 0xfffffd4a, "(-694) Lost Entry" },
1318         { 0xfffffd49, "(-695) Agent Already Registered" },
1319         { 0xfffffd48, "(-696) DS Loader Busy" },
1320         { 0xfffffd47, "(-697) DS Cannot Reload" },
1321         { 0xfffffd46, "(-698) Replica in Skulk" },
1322         { 0xfffffd45, "(-699) Fatal" },
1323         { 0xfffffd44, "(-700) Obsolete API" },
1324         { 0xfffffd43, "(-701) Synchronization Disabled" },
1325         { 0xfffffd42, "(-702) Invalid Parameter" },
1326         { 0xfffffd41, "(-703) Duplicate Template" },
1327         { 0xfffffd40, "(-704) No Master Replica" },
1328         { 0xfffffd3f, "(-705) Duplicate Containment" },
1329         { 0xfffffd3e, "(-706) Not a Sibling" },
1330         { 0xfffffd3d, "(-707) Invalid Signature" },
1331         { 0xfffffd3c, "(-708) Invalid Response" },
1332         { 0xfffffd3b, "(-709) Insufficient Sockets" },
1333         { 0xfffffd3a, "(-710) Database Read Fail" },
1334         { 0xfffffd39, "(-711) Invalid Code Page" },
1335         { 0xfffffd38, "(-712) Invalid Escape Character" },
1336         { 0xfffffd37, "(-713) Invalide Delimiters" },
1337         { 0xfffffd36, "(-714) Not Implemented" },
1338         { 0xfffffd35, "(-715) Checksum Failure" },
1339         { 0xfffffd34, "(-716) Checksumming Not Supported" },
1340         { 0xfffffd33, "(-717) CRC Failure" },
1341         { 0xfffffd32, "(-718) Invalid Entry Handle" },
1342         { 0xfffffd31, "(-719) Invalid Value Handle" },
1343         { 0xfffffd30, "(-720) Connection Denied" },
1344         { 0xfffffd2f, "(-721) No Such Federation Link" },
1345         { 0xfffffd2e, "(-722) Operetational Schema Mismatch" },
1346         { 0xfffffd2d, "(-723) Stream Not Found" },
1347         { 0xfffffd2c, "(-724) DClient Unavailable" },
1348         { 0xfffffd2b, "(-725) MASV No Access" },
1349         { 0xfffffd2a, "(-726) MASV Invalid Request" },
1350         { 0xfffffd29, "(-727) MASV Failure" },
1351         { 0xfffffd28, "(-728) MASV Already Exists" },
1352         { 0xfffffd27, "(-729) MASV Not Found" },
1353         { 0xfffffd26, "(-730) MASV Bad Range" },
1354         { 0xfffffd25, "(-731) Value Data" },
1355         { 0xfffffd24, "(-732) Database Locked" },
1356         { 0xfffffd21, "(-735) Nothing to Abort" },
1357         { 0xfffffd20, "(-736) End of Stream" },
1358         { 0xfffffd1f, "(-737) No Such Template" },
1359         { 0xfffffd1e, "(-738) SAS Locked" },
1360         { 0xfffffd1d, "(-739) Invalid SAS Version" },
1361         { 0xfffffd1c, "(-740) SAS Already Registered" },
1362         { 0xfffffd1b, "(-741) Name Type Not Supported" },
1363         { 0xfffffd1a, "(-742) Wrong DS Version" },
1364         { 0xfffffd19, "(-743) Invalid Control Function" },
1365         { 0xfffffd18, "(-744) Invalid Control State" },
1366         { 0xfffffd17, "(-745) Cache in Use" },
1367         { 0xfffffd16, "(-746) Zero Creation Time" },
1368         { 0xfffffd15, "(-747) Would Block" },
1369         { 0xfffffd14, "(-748) Connection Timeout" },
1370         { 0xfffffd13, "(-749) Too Many Referrals" },
1371         { 0xfffffd12, "(-750) Operation Cancelled" },
1372         { 0xfffffd11, "(-751) Unknown Target" },
1373         { 0xfffffd10, "(-752) GUID Failure" },
1374         { 0xfffffd0f, "(-753) Incompatible OS" },
1375         { 0xfffffd0e, "(-754) Callback Cancel" },
1376         { 0xfffffd0d, "(-755) Invalid Synchronization Data" },
1377         { 0xfffffd0c, "(-756) Stream Exists" },
1378         { 0xfffffd0b, "(-757) Auxiliary Has Containment" },
1379         { 0xfffffd0a, "(-758) Auxiliary Not Container" },
1380         { 0xfffffd09, "(-759) Auxiliary Not Effective" },
1381         { 0xfffffd08, "(-760) Auxiliary On Alias" },
1382         { 0xfffffd07, "(-761) Have Seen State" },
1383         { 0xfffffd06, "(-762) Verb Locked" },
1384         { 0xfffffd05, "(-763) Verb Exceeds Table Length" },
1385         { 0xfffffd04, "(-764) BOF Hit" },
1386         { 0xfffffd03, "(-765) EOF Hit" },
1387         { 0xfffffd02, "(-766) Incompatible Replica Version" },
1388         { 0xfffffd01, "(-767) Query Timeout" },
1389         { 0xfffffd00, "(-768) Query Maximum Count" },
1390         { 0xfffffcff, "(-769) Duplicate Naming" },
1391         { 0xfffffcfe, "(-770) No Transaction Active" },
1392         { 0xfffffcfd, "(-771) Transaction Active" },
1393         { 0xfffffcfc, "(-772) Illegal Transaction Operation" },
1394         { 0xfffffcfb, "(-773) Iterator Syntax" },
1395         { 0xfffffcfa, "(-774) Repairing DIB" },
1396         { 0xfffffcf9, "(-775) Invalid OID Format" },
1397         { 0xfffffcf8, "(-776) Attempted to perform an NDS operation, and the DS agent on this server is closing" },
1398         { 0xfffffcf7, "(-777) Attempted to modify an object's attribute that is not stored on the sparse replica" },
1399         { 0xfffffcf6, "(-778) VpVector and VpvUser which must be correlated, are out of sync" },
1400         { 0xfffffcf5, "(-779) Error Cannot Go Remote" },
1401         { 0xfffffcf4, "(-780) Request not Supported" },
1402         { 0xfffffcf3, "(-781) Entry Not Local" },
1403         { 0xfffffcf2, "(-782) Root Unreachable" },
1404         { 0xfffffcf1, "(-783) VRDIM Not Initialized" },
1405         { 0xfffffcf0, "(-784) Wait Timeout" },
1406         { 0xfffffcef, "(-785) DIB Error" },
1407         { 0xfffffcee, "(-786) DIB IO Failure" },
1408         { 0xfffffced, "(-787) Illegal Schema Attribute" },
1409         { 0xfffffcec, "(-788) Error Schema Partition" },
1410         { 0xfffffceb, "(-789) Invalid Template" },
1411         { 0xfffffcea, "(-790) Error Opening File" },
1412         { 0xfffffce9, "(-791) Error Direct Opening File" },
1413         { 0xfffffce8, "(-792) Error Creating File" },
1414         { 0xfffffce7, "(-793) Error Direct Creating File" },
1415         { 0xfffffce6, "(-794) Error Reading File" },
1416         { 0xfffffce5, "(-795) Error Direct Reading File" },
1417         { 0xfffffce4, "(-796) Error Writing File" },
1418         { 0xfffffce3, "(-797) Error Direct Writing File" },
1419         { 0xfffffce2, "(-798) Error Positioning in File" },
1420         { 0xfffffce1, "(-799) Error Getting File Size" },
1421         { 0xffffe88f, "(-6001) Error Truncating File" },
1422         { 0xffffe88e, "(-6002) Error Parsing File Name" },
1423         { 0xffffe88d, "(-6003) Error Closing File" },
1424         { 0xffffe88c, "(-6004) Error Getting File Info" },
1425         { 0xffffe88b, "(-6005) Error Expanding File" },
1426         { 0xffffe88a, "(-6006) Error Getting Free Blocks" },
1427         { 0xffffe889, "(-6007) Error Checking File Existence" },
1428         { 0xffffe888, "(-6008) Error Deleting File" },
1429         { 0xffffe887, "(-6009) Error Renaming File" },
1430         { 0xffffe886, "(-6010) Error Initializing IO System" },
1431         { 0xffffe885, "(-6011) Error Flushing File" },
1432         { 0xffffe884, "(-6012) Error Setting Up for Read" },
1433         { 0xffffe883, "(-6013) Error Setting up for Write" },
1434         { 0xffffe882, "(-6014) Error Old View" },
1435         { 0xffffe881, "(-6015) Server in Skulk" },
1436         { 0xffffe880, "(-6016) Error Returning Partial Results" },
1437         { 0xffffe87f, "(-6017) No Such Schema" },
1438         { 0xffffe87e, "(-6018) Serial Number Mismatch" },
1439         { 0xffffe87d, "(-6019) Bad Referal Database Serial Number" },
1440         { 0xffffe87c, "(-6020) Bad Referal Serial Number" },
1441         { 0xffffe87b, "(-6021) Invalid File Sequence" },
1442         { 0xffffe87a, "(-6022) Error Referal Trans Gap" },
1443         { 0xffffe879, "(-6023) Bad Referal File Number" },
1444         { 0xffffe878, "(-6024) Referal File Not Found" },
1445         { 0xffffe877, "(-6025) Error Backup Active" },
1446         { 0xffffe876, "(-6026) Referal Device Full" },
1447         { 0xffffe875, "(-6027) Unsupported Version" },
1448         { 0xffffe874, "(-6028) Error Must Wait Checkpoint" },
1449         { 0xffffe873, "(-6029) Attribute Maintenance in Progress" },
1450         { 0xffffe872, "(-6030) Error Abort Transaction" },
1451         { 0xffff0000, "Ok" },
1452         { 0x0000, "Ok" },
1453         { 0,    NULL }
1454 };
1455
1456 #define NDS_PTYPE_IPX           0x00000000
1457 #define NDS_PTYPE_IP            0x00000001
1458 #define NDS_PTYPE_SDLC          0x00000002
1459 #define NDS_PTYPE_TR_ON_ETH     0x00000003
1460 #define NDS_PTYPE_OSI           0x00000004
1461 #define NDS_PTYPE_APPLETALK     0x00000005
1462 #define NDS_PTYPE_NETBEUI       0x00000006
1463 #define NDS_PTYPE_SOCKETADDRESS 0x00000007
1464 #define NDS_PTYPE_UDP           0x00000008
1465 #define NDS_PTYPE_TCP           0x00000009
1466 #define NDS_PTYPE_UDPv6         0x0000000a
1467 #define NDS_PTYPE_TCPv6         0x0000000b
1468 #define NDS_PTYPE_INTERNAL      0x0000000c
1469 #define NDS_PTYPE_URL           0x0000000d
1470 #define NDS_PTYPE_DNS       0x0000000e
1471
1472 static const value_string nds_protocol_type[] = {
1473         { NDS_PTYPE_IPX,           "(IPX Protocol)" },
1474         { NDS_PTYPE_IP,            "(IP Protocol)" },
1475         { NDS_PTYPE_SDLC,          "(SDLC Protocol)" },
1476         { NDS_PTYPE_TR_ON_ETH,     "(TokenRing on Ethernet Protocol)" },
1477         { NDS_PTYPE_OSI,           "(OSI Protocol)" },
1478         { NDS_PTYPE_APPLETALK,     "(AppleTalk Protocol)" },
1479         { NDS_PTYPE_NETBEUI,       "(NetBEUI Protocol)" },
1480         { NDS_PTYPE_SOCKETADDRESS, "(Socket Address Protocol)" },
1481         { NDS_PTYPE_UDP,           "(UDP Protocol)" },
1482         { NDS_PTYPE_TCP,           "(TCP Protocol)" },
1483         { NDS_PTYPE_UDPv6,         "(UDP v6 Protocol)" },
1484         { NDS_PTYPE_TCPv6,         "(TCP v6 Protocol)" },
1485         { NDS_PTYPE_INTERNAL,      "(Internal Protocol)" },
1486         { NDS_PTYPE_URL,           "(URL Protocol)" },
1487         { NDS_PTYPE_DNS,           "(DNS Protocol)" },
1488         { 0,    NULL }
1489 };
1490
1491
1492 static const value_string nds_syntax[] = {
1493         { 0x00000000, "Unknown Syntax" },
1494         { 0x00000001, "Distinguished Name" },
1495         { 0x00000002, "Case Sensitive Unicode String" },
1496         { 0x00000003, "Non Case Sensitive Unicode String" },
1497         { 0x00000004, "Printable String" },
1498         { 0x00000005, "Numeric String" },
1499         { 0x00000006, "Case Insensitive List" },
1500         { 0x00000007, "Boolean" },
1501         { 0x00000008, "Signed Integer" },
1502         { 0x00000009, "Binary String" },
1503         { 0x0000000a, "Telephone Number" },
1504         { 0x0000000b, "Fax Number" },
1505         { 0x0000000c, "Network Address" },
1506         { 0x0000000d, "Binary String List" },
1507         { 0x0000000e, "Email Address" },
1508         { 0x0000000f, "File System Path" },
1509         { 0x00000010, "Replica Pointer" },
1510         { 0x00000011, "Object ACL" },
1511         { 0x00000012, "Postal Address" },
1512         { 0x00000013, "Time Stamp" },
1513         { 0x00000014, "Class Name" },
1514         { 0x00000015, "Stream" },
1515         { 0x00000016, "Counter" },
1516         { 0x00000017, "Back Link" },
1517         { 0x00000018, "Time" },
1518         { 0x00000019, "Typed Name" },
1519         { 0x0000001a, "Hold" },
1520         { 0x0000001b, "Interval" },
1521         { 0,    NULL }
1522 };
1523
1524 static const value_string name_space_type[] = {
1525         { 0x00000000, "DOS Name Space" },
1526         { 0x00000001, "MAC Name Space" },
1527         { 0x00000002, "NFS Name Space" },
1528         { 0x00000003, "FTAM Name Space" },
1529         { 0x00000004, "OS/2, Long Name Space" },
1530         { 0,    NULL }
1531 };
1532
1533
1534 static const value_string nds_replica_state[] = {
1535         { 0x0000, "On" },
1536         { 0x0001, "New" },
1537         { 0x0002, "Dying" },
1538         { 0x0003, "Locked" },
1539         { 0x0004, "Create Master State 0" },
1540         { 0x0005, "Create Master State 1" },
1541         { 0x0006, "Transition On" },
1542         { 0x0007, "Dead Replica" },
1543         { 0x0008, "Begin Add" },
1544         { 0x000b, "Master Start" },
1545         { 0x000c, "Master Done" },
1546         { 0x0017, "Federated" },
1547         { 0x0030, "Split State 0" },
1548         { 0x0031, "Split State 1" },
1549         { 0x0040, "Join State 0" },
1550         { 0x0041, "Join State 1" },
1551         { 0x0042, "Join State 2" },
1552         { 0x0050, "Move Subtree State 0" },
1553         { 0x0051, "Move Subtree State 1" },
1554         { 0,    NULL }
1555 };
1556
1557 static const value_string nds_replica_type[] = {
1558         { 0x0000, "Master" },
1559         { 0x0001, "Secondary" },
1560         { 0x0002, "Read Only" },
1561         { 0x0003, "Sub Ref" },
1562         { 0,    NULL }
1563 };
1564
1565 static const value_string class_def_type[] = {
1566         { 0x0000, "Return Class Name" },
1567         { 0x0001, "Return Class Name, Flag, and Definition" },
1568         { 0x0002, "Return Class Name, Flag, Definition, and Super Class" },
1569         { 0x0003, "Return Class Name, Flag, and ASN.1 identifier" },
1570         { 0x0004, "Return Class Name, Flag, Definition, Super Class, and ACL" },
1571         { 0x0005, "Return Class Name, Flag, Creation Timestamp, Modification Timestamp, Definition, and ACL" },
1572         { 0,    NULL }
1573 };
1574
1575 static const value_string nds_search_scope[] = {
1576         { 0x0000, "Examine the base object only" },
1577         { 0x0001, "Search the immediate subordinates of the base object" },
1578         { 0x0002, "Search the base object and all its subordinates" },
1579         { 0x0003, "Search the base objects and all objects in its partition (Implemented in NDS 8)" },
1580         { 0,    NULL }
1581 };
1582
1583 static const value_string nds_verb2b_flag_vals[] = {
1584         { 0, "Request Flags (0x0000) - Retain old object name" },
1585         { 1, "Request Flags (0x0001) - Delete old object name" },
1586         { 0,  NULL }
1587 };
1588
1589 static void
1590 process_ptvc_record(ptvcursor_t *ptvc, const ptvc_record *rec,
1591                 int *req_cond_results, gboolean really_decode,
1592                 const ncp_record *ncp_rec);
1593
1594 /* NCP packets come in request/reply pairs. The request packets tell the type
1595  * of NCP request and give a sequence ID. The response, unfortunately, only
1596  * identifies itself via the sequence ID; you have to know what type of NCP
1597  * request the request packet contained in order to successfully parse the NCP
1598  * response. A global method for doing this does not exist in wireshark yet
1599  * (NFS also requires it), so for now the NCP section will keep its own hash
1600  * table keeping track of NCP packet types.
1601  *
1602  * We construct a conversation specified by the client and server
1603  * addresses and the connection number; the key representing the unique
1604  * NCP request then is composed of the pointer to the conversation
1605  * structure, cast to a "guint" (which may throw away the upper 32
1606  * bits of the pointer on a P64 platform, but the low-order 32 bits
1607  * are more likely to differ between conversations than the upper 32 bits),
1608  * and the sequence number.
1609  *
1610  * The value stored in the hash table is the ncp_req_hash_value pointer. This
1611  * struct tells us the NCP type and gives the ncp2222_record pointer, if
1612  * ncp_type == 0x2222.
1613  */
1614 typedef struct {
1615         conversation_t  *conversation;
1616         guint8          nw_sequence;
1617 } ncp_req_hash_key;
1618
1619
1620 typedef struct {
1621         guint32         nw_eid;
1622 } ncp_req_eid_hash_key;
1623
1624 typedef struct {
1625         ncp_req_eid_hash_key    *nds_eid;
1626         char                        object_name[256];
1627         char                    *object_class;
1628 } ncp_req_eid_hash_value;
1629
1630 static GHashTable *ncp_req_hash = NULL;
1631 static GHashTable *ncp_req_eid_hash = NULL;
1632 static GMemChunk *ncp_req_eid_hash_keys = NULL;
1633 static GMemChunk *ncp_req_eid_hash_values = NULL;
1634 static GMemChunk *ncp_req_hash_keys = NULL;
1635 static GMemChunk *ncp_req_hash_values = NULL;
1636
1637 /* Hash Functions */
1638 static gint
1639 ncp_equal(gconstpointer v, gconstpointer v2)
1640 {
1641         const ncp_req_hash_key  *val1 = (const ncp_req_hash_key*)v;
1642         const ncp_req_hash_key  *val2 = (const ncp_req_hash_key*)v2;
1643
1644         if (val1->conversation == val2->conversation &&
1645             val1->nw_sequence  == val2->nw_sequence ) {
1646                 return 1;
1647         }
1648         return 0;
1649 }
1650
1651 static gint
1652 ncp_eid_equal(gconstpointer v, gconstpointer v2)
1653 {
1654         const ncp_req_eid_hash_key      *val1 = (const ncp_req_eid_hash_key*)v;
1655         const ncp_req_eid_hash_key      *val2 = (const ncp_req_eid_hash_key*)v2;
1656
1657         if (val1->nw_eid == val2->nw_eid ) {
1658                 return 1;
1659         }
1660         return 0;
1661 }
1662
1663 static guint
1664 ncp_hash(gconstpointer v)
1665 {
1666         const ncp_req_hash_key  *ncp_key = (const ncp_req_hash_key*)v;
1667         return GPOINTER_TO_UINT(ncp_key->conversation) + ncp_key->nw_sequence;
1668 }
1669
1670 static guint
1671 ncp_eid_hash(gconstpointer v)
1672 {
1673         const ncp_req_eid_hash_key      *ncp_eid_key = (const ncp_req_eid_hash_key*)v;
1674         return GPOINTER_TO_UINT(ncp_eid_key->nw_eid);
1675 }
1676
1677 /* Frees memory used by the ncp_req_hash_value's */
1678 static void
1679 ncp_req_hash_cleanup(gpointer key _U_, gpointer value, gpointer user_data _U_)
1680 {
1681         ncp_req_hash_value      *request_value = (ncp_req_hash_value*) value;
1682
1683         if (request_value->req_cond_results) {
1684                 g_free(request_value->req_cond_results);
1685         }
1686 }
1687
1688 /* Frees memory used by the ncp_req_hash_value's */
1689 static void
1690 ncp_req_eid_hash_cleanup(gpointer key _U_, gpointer value, gpointer user_data _U_)
1691 {
1692         ncp_req_eid_hash_value  *request_eid_value = (ncp_req_eid_hash_value*) value;
1693
1694         if (request_eid_value->object_class) {
1695                 g_free(request_eid_value->object_name);
1696         }
1697 }
1698
1699 /* Initializes the hash table and the mem_chunk area each time a new
1700  * file is loaded or re-loaded in wireshark */
1701 static void
1702 ncp_init_protocol(void)
1703 {
1704     int i;
1705
1706         /* fragment */
1707         fragment_table_init(&nds_fragment_table);
1708         reassembled_table_init(&nds_reassembled_table);
1709
1710     for (i = 0; i < 99; i++) {
1711         frags[i].nds_frag = 0xfffffff0;
1712     }
1713
1714         if (ncp_req_hash) {
1715                 g_hash_table_foreach(ncp_req_hash, ncp_req_hash_cleanup, NULL);
1716                 g_hash_table_destroy(ncp_req_hash);
1717         }
1718         if (ncp_req_eid_hash) {
1719                 g_hash_table_foreach(ncp_req_eid_hash, ncp_req_eid_hash_cleanup, NULL);
1720                 g_hash_table_destroy(ncp_req_eid_hash);
1721         }
1722         if (ncp_req_hash_keys)
1723                 g_mem_chunk_destroy(ncp_req_hash_keys);
1724         if (ncp_req_hash_values)
1725                 g_mem_chunk_destroy(ncp_req_hash_values);
1726         if (ncp_req_eid_hash_keys)
1727                 g_mem_chunk_destroy(ncp_req_eid_hash_keys);
1728         if (ncp_req_eid_hash_values)
1729                 g_mem_chunk_destroy(ncp_req_eid_hash_values);
1730
1731         ncp_req_hash = g_hash_table_new(ncp_hash, ncp_equal);
1732         ncp_req_eid_hash = g_hash_table_new(ncp_eid_hash, ncp_eid_equal);
1733         ncp_req_hash_keys = g_mem_chunk_new("ncp_req_hash_keys",
1734                         sizeof(ncp_req_hash_key),
1735                         NCP_PACKET_INIT_COUNT * sizeof(ncp_req_hash_key),
1736                         G_ALLOC_ONLY);
1737         ncp_req_hash_values = g_mem_chunk_new("ncp_req_hash_values",
1738                         sizeof(ncp_req_hash_value),
1739                         NCP_PACKET_INIT_COUNT * sizeof(ncp_req_hash_value),
1740                         G_ALLOC_ONLY);
1741         ncp_req_eid_hash_keys = g_mem_chunk_new("ncp_req_eid_hash_keys",
1742                         sizeof(ncp_req_eid_hash_key),
1743                         NCP_PACKET_INIT_COUNT * sizeof(ncp_req_eid_hash_key),
1744                         G_ALLOC_ONLY);
1745         ncp_req_eid_hash_values = g_mem_chunk_new("ncp_req_eid_hash_values",
1746                         sizeof(ncp_req_eid_hash_value),
1747                         NCP_PACKET_INIT_COUNT * sizeof(ncp_req_eid_hash_value),
1748                         G_ALLOC_ONLY);
1749 }
1750
1751 /* After the sequential run, we don't need the ncp_request hash and keys
1752  * anymore; the lookups have already been done and the vital info
1753  * saved in the reply-packets' private_data in the frame_data struct. */
1754 static void
1755 ncp_postseq_cleanup(void)
1756 {
1757         if (ncp_req_hash) {
1758                 /* Destroy the hash, but don't clean up request_condition data. */
1759                 /*g_hash_table_destroy(ncp_req_hash);
1760                 ncp_req_hash = NULL;*/
1761         }
1762         if (ncp_req_hash_keys) {
1763                 /*g_mem_chunk_destroy(ncp_req_hash_keys);
1764                 ncp_req_hash_keys = NULL;*/
1765         }
1766         /* Don't free the ncp_req_hash_values or EID_hash_table, as they're
1767          * needed during random-access processing of the proto_tree.*/
1768 }
1769
1770 static ncp_req_hash_value*
1771 ncp_hash_insert(conversation_t *conversation, guint8 nw_sequence,
1772                 const ncp_record *ncp_rec)
1773 {
1774         ncp_req_hash_key                *request_key;
1775         ncp_req_hash_value              *request_value;
1776
1777         /* Now remember the request, so we can find it if we later
1778            a reply to it. */
1779         request_key = g_mem_chunk_alloc(ncp_req_hash_keys);
1780         request_key->conversation = conversation;
1781         request_key->nw_sequence = nw_sequence;
1782
1783         request_value = g_mem_chunk_alloc(ncp_req_hash_values);
1784         request_value->ncp_rec = ncp_rec;
1785         request_value->req_cond_results = NULL;
1786         request_value->req_nds_flags = 0;
1787         request_value->nds_request_verb = 0;
1788         request_value->nds_version = 0;
1789         g_strlcpy(request_value->object_name, " ", 256);
1790         request_value->nds_frag = TRUE;
1791
1792         g_hash_table_insert(ncp_req_hash, request_key, request_value);
1793
1794         return request_value;
1795 }
1796
1797 static ncp_req_eid_hash_value*
1798 ncp_eid_hash_insert(guint32 nw_eid)
1799 {
1800         ncp_req_eid_hash_key            *request_eid_key;
1801         ncp_req_eid_hash_value          *request_eid_value;
1802
1803         /* Now remember the request, so we can find it if we later
1804            a reply to it. */
1805         request_eid_key = g_mem_chunk_alloc(ncp_req_eid_hash_keys);
1806         request_eid_key->nw_eid = nw_eid;
1807
1808         request_eid_value = g_mem_chunk_alloc(ncp_req_eid_hash_values);
1809         g_strlcpy(request_eid_value->object_name, " ", 256);
1810         request_eid_value->object_class = NULL;
1811
1812         g_hash_table_insert(ncp_req_eid_hash, request_eid_key, request_eid_value);
1813
1814         return request_eid_value;
1815 }
1816
1817 /* Returns the ncp_rec*, or NULL if not found. */
1818 static ncp_req_hash_value*
1819 ncp_hash_lookup(conversation_t *conversation, guint8 nw_sequence)
1820 {
1821         ncp_req_hash_key                request_key;
1822
1823         request_key.conversation = conversation;
1824         request_key.nw_sequence = nw_sequence;
1825
1826         return g_hash_table_lookup(ncp_req_hash, &request_key);
1827 }
1828
1829 /* Returns the value_rec* for needed EID, or NULL if not found. */
1830 static ncp_req_eid_hash_value*
1831 ncp_eid_hash_lookup(conversation_t *conversation _U_, guint32 nw_eid)
1832 {
1833         ncp_req_eid_hash_key            request_eid_key;
1834
1835         request_eid_key.nw_eid = nw_eid;
1836
1837         return g_hash_table_lookup(ncp_req_eid_hash, &request_eid_key);
1838 }
1839
1840 /* Does NCP func require a subfunction code? */
1841 static gboolean
1842 ncp_requires_subfunc(guint8 func)
1843 {
1844         const guint8 *ncp_func_requirement = ncp_func_requires_subfunc;
1845
1846         while (*ncp_func_requirement != 0) {
1847                 if (*ncp_func_requirement == func) {
1848                         return TRUE;
1849                 }
1850                 ncp_func_requirement++;
1851         }
1852         return FALSE;
1853 }
1854
1855 /* Does the NCP func have a length parameter? */
1856 static gboolean
1857 ncp_has_length_parameter(guint8 func)
1858 {
1859         const guint8 *ncp_func_requirement = ncp_func_has_no_length_parameter;
1860
1861         while (*ncp_func_requirement != 0) {
1862                 if (*ncp_func_requirement == func) {
1863                         return FALSE;
1864                 }
1865                 ncp_func_requirement++;
1866         }
1867         return TRUE;
1868 }
1869
1870
1871 /* Return a ncp_record* based on func and possibly subfunc */
1872 static const ncp_record *
1873 ncp_record_find(guint8 func, guint8 subfunc)
1874 {
1875         const ncp_record *ncp_rec = ncp_packets;
1876
1877         while(ncp_rec->func != 0 || ncp_rec->subfunc != 0 ||
1878                 ncp_rec->name != NULL ) {
1879                 if (ncp_rec->func == func) {
1880                         if (ncp_rec->has_subfunc) {
1881                                 if (ncp_rec->subfunc == subfunc) {
1882                                         return ncp_rec;
1883                                 }
1884                         }
1885                         else {
1886                                 return ncp_rec;
1887                         }
1888                 }
1889                 ncp_rec++;
1890         }
1891         return NULL;
1892 }
1893
1894
1895 /* Given a proto_item*, assume it contains an integer value
1896  * and return a guint from it. */
1897 static guint
1898 get_finfo_value_integer(field_info *finfo)
1899 {
1900         /* XXX the fvalue functions are no longer safe to call directly
1901            since we sometimes fake the entries to speed things up.
1902            this dissector should not call fvalue_ functions directly.
1903         */
1904         if(!finfo->value.ftype->get_value_uinteger){
1905                 return 0;
1906         }
1907         return fvalue_get_uinteger(&finfo->value);
1908 }
1909 static guint
1910 get_item_value(proto_item *item)
1911 {
1912         return get_finfo_value_integer(PITEM_FINFO(item));
1913 }
1914
1915
1916 static guint
1917 get_finfo_length(field_info *finfo)
1918 {
1919         return fvalue_length(&finfo->value);
1920 }
1921
1922
1923 static char *
1924 get_finfo_value_string(field_info *finfo)
1925 {
1926         return fvalue_get(&finfo->value);
1927 }
1928 #if 0
1929 static char *
1930 get_item_string(proto_item *item)
1931 {
1932         return get_finfo_value_string(PITEM_FINFO(item));
1933 }
1934 #endif
1935
1936 static const char *
1937 get_item_name(proto_item *item)
1938 {
1939         return PITEM_FINFO(item)->hfinfo->name;
1940 }
1941
1942
1943 typedef proto_item* (*padd_func_t)(ptvcursor_t*, const ptvc_record*);
1944
1945 /*
1946  * XXX - are these just DOS-format dates and times?
1947  *
1948  * Should we put code to understand various date and time formats (UNIX,
1949  * DOS, SMB weird mutant UNIX, NT, Mac, etc. into libwireshark, and have
1950  * the "display" member of an HF_ABSOLUTE_TIME field specify whether
1951  * it's DOS date/DOS time, DOS time/DOS date, NT time, UNIX time_t,
1952  * UNIX "struct timeval", NFSv3/NFSv4 seconds/nanoseconds, Mac, etc.?
1953  *
1954  * What about hijacking the "bitmask" field to specify the precision of
1955  * the time stamp, or putting a combination of precision and format
1956  * into the "display" member?
1957  *
1958  * What about relative times?  Should they have units (seconds, milliseconds,
1959  * microseconds, nanoseconds, etc.), precision, and format in there?
1960  */
1961 typedef struct {
1962         guint   year;
1963         guint   month;
1964         guint   day;
1965 } nw_date_t;
1966
1967 typedef struct {
1968         guint   hour;
1969         guint   minute;
1970         guint   second;
1971 } nw_time_t;
1972
1973 typedef struct {
1974         char   buffer[1024];
1975 } nw_uni_t;
1976
1977 #define VTYPE_NONE              0       /* no value */
1978 #define VTYPE_UINT8             1
1979 #define VTYPE_UINT16            2
1980 #define VTYPE_UINT32            3
1981 #define VTYPE_STRING            4
1982 #define VTYPE_BITFIELD          5
1983 #define VTYPE_MULTIVALUE_UINT32 6
1984 #define VTYPE_BYTES             7
1985 #define VTYPE_BOOLEAN           8
1986 #define VTYPE_ITEM          9
1987
1988 #define MVTYPE_ATTR_REQUEST             1
1989 #define MVTYPE_ATTR_REPLY               2
1990 #define MVTYPE_ATTR_REQUEST2            3
1991 #define MVTYPE_READ_CLASS_REQ           4
1992 #define MVTYPE_READ_REPLICAS            5
1993 #define MVTYPE_MODIFY_ATTR_REQUEST      6
1994 #define MVTYPE_ADDR_REFERRAL_REQUEST    7
1995 #define MVTYPE_ADDR_REFERRAL_REPLY      8
1996 #define MVTYPE_LOC_ADDR_REFERRAL_REPLY  9
1997 #define MVTYPE_PROC_ENTRY_SPECIFIERS    10
1998 #define MVTYPE_PRINT_TIMESTAMP          11
1999 #define MVTYPE_LIST_PARTITIONS          12
2000 #define MVTYPE_CLASS_NAMES              13
2001 #define MVTYPE_MODIFY_CLASS             14
2002 #define MVTYPE_ADD_ATTR_REQUEST         15
2003 #define MVTYPE_PROCESS_TAGS         16
2004 #define MVTYPE_PROCESS_ITERATOR     17
2005
2006 typedef struct {
2007         guint8          vtype;
2008         guint32         vvalue;
2009         char*           vstring;
2010         const char*     vdesc;
2011         guint32         vlength;
2012         guint32         voffset;
2013         guint32         hfname;
2014         const char*     bit1;
2015         guint32         bit1hfname;
2016         const char*     bit2;
2017         guint32         bit2hfname;
2018         const char*     bit3;
2019         guint32         bit3hfname;
2020         const char*     bit4;
2021         guint32         bit4hfname;
2022         const char*     bit5;
2023         guint32         bit5hfname;
2024         const char*     bit6;
2025         guint32         bit6hfname;
2026         const char*     bit7;
2027         guint32         bit7hfname;
2028         const char*     bit8;
2029         guint32         bit8hfname;
2030         const char*     bit9;
2031         guint32         bit9hfname;
2032         const char*     bit10;
2033         guint32         bit10hfname;
2034         const char*     bit11;
2035         guint32         bit11hfname;
2036         const char*     bit12;
2037         guint32         bit12hfname;
2038         const char*     bit13;
2039         guint32         bit13hfname;
2040         const char*     bit14;
2041         guint32         bit14hfname;
2042         const char*     bit15;
2043         guint32         bit15hfname;
2044         const char*     bit16;
2045         guint32         bit16hfname;
2046         guint8          mvtype;
2047         guint32         vflags;
2048         guint32         nds_version;
2049 } nds_val;
2050
2051
2052 /* Given an integer, fill in a nw_date_t struct. */
2053 static void
2054 uint_to_nwdate(guint data, nw_date_t *nwdate)
2055 {
2056         nwdate->day   =  data & 0x001f;
2057         nwdate->month = (data & 0x01e0) >> 5;
2058         nwdate->year  = ((data & 0xfe00) >> 9) + 1980;
2059 }
2060
2061 /* Given an integer, fill in a nw_time_t struct. */
2062 static void
2063 uint_to_nwtime(guint data, nw_time_t *nwtime)
2064 {
2065         /* 2-second resolution */
2066         nwtime->second = (data & 0x001f) * 2;
2067         nwtime->minute = ((data & 0x07e0) >> 5);
2068         nwtime->hour   = ((data & 0xf800) >> 11);
2069 }
2070
2071 static proto_item*
2072 padd_normal(ptvcursor_t *ptvc, const ptvc_record *rec)
2073 {
2074         return
2075         ptvcursor_add(ptvc, *rec->hf_ptr,
2076                 rec->length, rec->endianness);
2077 }
2078
2079 static proto_item*
2080 padd_date(ptvcursor_t *ptvc, const ptvc_record *rec)
2081 {
2082         proto_item      *item;
2083         nw_date_t       nw_date;
2084         gint            offset;
2085
2086         offset = ptvcursor_current_offset(ptvc);
2087
2088         item = ptvcursor_add(ptvc, *rec->hf_ptr,
2089                 rec->length, rec->endianness);
2090
2091         if (item) {
2092                 uint_to_nwdate(get_item_value(item), &nw_date);
2093
2094                 proto_item_set_text(item, "%s", get_item_name(item));
2095                 proto_item_append_text(item, ": %04u/%02u/%02u",
2096                                 nw_date.year, nw_date.month, nw_date.day);
2097         }
2098         return item;
2099 }
2100
2101 static proto_item*
2102 padd_time(ptvcursor_t *ptvc, const ptvc_record *rec)
2103 {
2104         proto_item      *item;
2105         nw_time_t       nw_time;
2106         gint            offset;
2107
2108         offset = ptvcursor_current_offset(ptvc);
2109
2110         item = ptvcursor_add(ptvc, *rec->hf_ptr,
2111                 rec->length, rec->endianness);
2112
2113         if (item) {
2114                 uint_to_nwtime(get_item_value(item), &nw_time);
2115
2116                 proto_item_set_text(item, "%s", get_item_name(item));
2117                 proto_item_append_text(item, ": %02u:%02u:%02u",
2118                                 nw_time.hour, nw_time.minute, nw_time.second);
2119         }
2120         return item;
2121 }
2122
2123
2124 /* Convert a string from little-endian unicode to ascii.  At the moment we
2125    fake it by taking every odd byte.  )-:  The caller must free the
2126    result returned. */
2127 static proto_item*
2128 padd_uni(ptvcursor_t *ptvc, const ptvc_record *rec)
2129 {
2130         proto_item      *item;
2131         nw_uni_t        nw_uni;
2132         guint            offset;
2133
2134         nw_uni.buffer[0] = '\0';
2135         offset = ptvcursor_current_offset(ptvc);
2136
2137         item = ptvcursor_add(ptvc, *rec->hf_ptr,
2138                 rec->length, rec->endianness);
2139
2140         if (item) {
2141                 proto_item_set_text(item, "%s", get_item_name(item));
2142                 proto_item_append_text(item, " %s",
2143                                 nw_uni.buffer);
2144         }
2145
2146         return item;
2147 }
2148
2149 /* Add a value for a ptvc_record, and process the sub-ptvc_record
2150  * that it points to. */
2151 static void
2152 process_bitfield_sub_ptvc_record(ptvcursor_t *ptvc, const ptvc_record *rec,
2153                 gboolean really_decode)
2154 {
2155         proto_item              *item;
2156         proto_tree              *sub_tree;
2157         const ptvc_record       *sub_rec;
2158         int                     current_offset;
2159         gint                    ett;
2160         ptvcursor_t             *sub_ptvc;
2161
2162         if (really_decode) {
2163                 /* Save the current offset */
2164                 current_offset = ptvcursor_current_offset(ptvc);
2165
2166                 /* Add the item */
2167                 item = ptvcursor_add(ptvc, *rec->hf_ptr, rec->length,
2168                                 rec->endianness);
2169
2170                 ett = *rec->sub_ptvc_rec->ett;
2171
2172                 /* Make a new protocol sub-tree */
2173                 sub_tree = proto_item_add_subtree(item, ett);
2174
2175                 /* Make a new ptvcursor */
2176                 sub_ptvc = ptvcursor_new(sub_tree, ptvcursor_tvbuff(ptvc),
2177                                 current_offset);
2178
2179                 /* Use it */
2180                 sub_rec = rec->sub_ptvc_rec->ptvc_rec;
2181                 while(sub_rec->hf_ptr != NULL) {
2182                         DISSECTOR_ASSERT(!sub_rec->sub_ptvc_rec);
2183                         ptvcursor_add_no_advance(sub_ptvc, *sub_rec->hf_ptr,
2184                                         sub_rec->length, sub_rec->endianness);
2185                         sub_rec++;
2186                 }
2187
2188                 /* Free it. */
2189                 ptvcursor_free(sub_ptvc);
2190         }
2191         else {
2192                 DISSECTOR_ASSERT(rec->length > 0 &&
2193                    proto_registrar_get_nth(*rec->hf_ptr)->type != FT_UINT_STRING);
2194                 ptvcursor_advance(ptvc, rec->length);
2195         }
2196 }
2197
2198 /* Process a sub-ptvc_record that points to a "struct" ptvc_record. */
2199 static void
2200 process_struct_sub_ptvc_record(ptvcursor_t *ptvc, const ptvc_record *rec,
2201                 int *req_cond_results, gboolean really_decode,
2202                 const ncp_record *ncp_rec)
2203 {
2204         const ptvc_record       *sub_rec;
2205         gint                    ett;
2206         proto_tree              *old_tree=NULL, *new_tree;
2207         proto_item              *item=NULL;
2208         gint                    offset=0;
2209
2210         /* Create a sub-proto_tree? */
2211         if (rec->sub_ptvc_rec->descr) {
2212                 ett = *rec->sub_ptvc_rec->ett;
2213                 old_tree = ptvcursor_tree(ptvc);
2214                 offset = ptvcursor_current_offset(ptvc);
2215                 item = proto_tree_add_text(old_tree, ptvcursor_tvbuff(ptvc),
2216                                 offset, PROTO_LENGTH_UNTIL_END,
2217                                 rec->sub_ptvc_rec->descr);
2218                 new_tree = proto_item_add_subtree(item, ett);
2219                 ptvcursor_set_tree(ptvc, new_tree);
2220         }
2221
2222         /* Get the ptvc_record for the struct and call our caller
2223          * to process it. */
2224         sub_rec = rec->sub_ptvc_rec->ptvc_rec;
2225         process_ptvc_record(ptvc, sub_rec, req_cond_results, really_decode, ncp_rec);
2226
2227         /* Re-set the tree */
2228         if (rec->sub_ptvc_rec->descr) {
2229                 if (ptvcursor_current_offset(ptvc) <= offset)
2230                         THROW(ReportedBoundsError);
2231
2232                 proto_item_set_len(item, ptvcursor_current_offset(ptvc) - offset);
2233                 ptvcursor_set_tree(ptvc, old_tree);
2234         }
2235 }
2236
2237 /* Run through the table of ptvc_record's and add info to the tree. This
2238  * is the work-horse of process_ptvc_record(). */
2239 static void
2240 _process_ptvc_record(ptvcursor_t *ptvc, const ptvc_record *rec,
2241                 int *req_cond_results, gboolean really_decode,
2242                 const ncp_record *ncp_rec)
2243 {
2244         proto_item      *item;
2245         guint           i, repeat_count;
2246         padd_func_t     func = NULL;
2247
2248         if (rec->sub_ptvc_rec) {
2249                 /* Repeat this? */
2250                 if (rec->repeat_index == NO_REPEAT) {
2251                         if (rec->hf_ptr == PTVC_STRUCT) {
2252                                 process_struct_sub_ptvc_record(ptvc, rec,
2253                                                 req_cond_results, really_decode,
2254                                                 ncp_rec);
2255                         }
2256                         else {
2257                                 process_bitfield_sub_ptvc_record(ptvc, rec,
2258                                                 really_decode);
2259                         }
2260                 }
2261                 else {
2262                         repeat_count = repeat_vars[rec->repeat_index];
2263                         for (i = 0; i < repeat_count; i++ ) {
2264                                 if (rec->hf_ptr == PTVC_STRUCT) {
2265                                         process_struct_sub_ptvc_record(ptvc, rec,
2266                                                 req_cond_results, really_decode,
2267                                                 ncp_rec);
2268                                 }
2269                                 else {
2270                                         process_bitfield_sub_ptvc_record(ptvc, rec,
2271                                                         really_decode);
2272                                 }
2273                         }
2274                 }
2275         }
2276         else {
2277                 /* If we can't repeat this field, we might use it
2278                  * to set a 'var'. */
2279                 if (rec->repeat_index == NO_REPEAT) {
2280                         if (really_decode) {
2281                                 /* Handle any special formatting. */
2282                                 switch(rec->special_fmt) {
2283                                         case NCP_FMT_NONE:
2284                                                 func = padd_normal;
2285                                                 break;
2286                                         case NCP_FMT_NW_DATE:
2287                                                 func = padd_date;
2288                                                 break;
2289                                         case NCP_FMT_NW_TIME:
2290                                                 func = padd_time;
2291                                                 break;
2292                                         case NCP_FMT_UNICODE:
2293                                                 func = padd_uni;
2294                                                 break;
2295                                         default:
2296                                                 DISSECTOR_ASSERT_NOT_REACHED();
2297                                 }
2298                                 item = func(ptvc, rec);
2299
2300                                 /* Set the value as a 'var' ? */
2301                                 if (rec->var_index != NO_VAR) {
2302                                         repeat_vars[rec->var_index] = get_item_value(item);
2303                                 }
2304                         }
2305                         else {
2306                                 /* If we don't decode the field, we
2307                                  * better not use the value to set a var.
2308                                  * Actually, we could, as long as we don't
2309                                  * *use* that var; for now keep this assert in
2310                                  * place. */
2311                                 DISSECTOR_ASSERT(rec->var_index == NO_VAR);
2312
2313                                 /* This had better not be variable-length,
2314                                  * either. */
2315                                 DISSECTOR_ASSERT(rec->length > 0 &&
2316                                    proto_registrar_get_nth(*rec->hf_ptr)->type != FT_UINT_STRING);
2317                                 ptvcursor_advance(ptvc, rec->length);
2318                         }
2319                 }
2320                 else {
2321                         /* We do repeat this field. */
2322                         repeat_count = repeat_vars[rec->repeat_index];
2323                         if (really_decode) {
2324                                 /* Handle any special formatting. */
2325                                 switch(rec->special_fmt) {
2326                                         case NCP_FMT_NONE:
2327                                                 func = padd_normal;
2328                                                 break;
2329                                         case NCP_FMT_NW_DATE:
2330                                                 func = padd_date;
2331                                                 break;
2332                                         case NCP_FMT_NW_TIME:
2333                                                 func = padd_time;
2334                                                 break;
2335                                         case NCP_FMT_UNICODE:
2336                                                 func = padd_uni;
2337                                                 break;
2338                                         default:
2339                                                 DISSECTOR_ASSERT_NOT_REACHED();
2340                                 }
2341                                 for (i = 0; i < repeat_count; i++ ) {
2342                                         func(ptvc, rec);
2343                                 }
2344                         }
2345                         else {
2346                                 for (i = 0; i < repeat_count; i++ ) {
2347                                         DISSECTOR_ASSERT(rec->length > 0 &&
2348                                            proto_registrar_get_nth(*rec->hf_ptr)->type != FT_UINT_STRING);
2349                                         ptvcursor_advance(ptvc, rec->length);
2350                                 }
2351                         }
2352                 }
2353         }
2354 }
2355
2356 /* Run through the table of ptvc_record's and add info to the tree.
2357  * Honor a request condition result. */
2358 static void
2359 process_ptvc_record(ptvcursor_t *ptvc, const ptvc_record *rec,
2360                 int *req_cond_results, gboolean really_decode,
2361                 const ncp_record *ncp_rec)
2362 {
2363         gboolean decode;
2364
2365         while(rec->hf_ptr != NULL) {
2366                 decode = really_decode;
2367                 /* If we're supposed to decode, check the request condition
2368                  * results to see if we should override this and *not* decode. */
2369                 if (decode && req_cond_results) {
2370                         if (rec->req_cond_index != NO_REQ_COND) {
2371                                 if (req_cond_results[rec->req_cond_index] == FALSE) {
2372                                         decode = FALSE;
2373                                 }
2374                         }
2375                 }
2376                 if (decode || ncp_rec->req_cond_size_type == REQ_COND_SIZE_CONSTANT) {
2377                         _process_ptvc_record(ptvc, rec, req_cond_results, decode, ncp_rec);
2378                 }
2379                 rec++;
2380         }
2381 }
2382
2383
2384
2385 /* Clear the repeat_vars array. */
2386 static void
2387 clear_repeat_vars(void)
2388 {
2389         guint i;
2390
2391         for (i = 0 ; i < NUM_REPEAT_VARS; i++ ) {
2392                 repeat_vars[i] = 0;
2393         }
2394 }
2395
2396
2397 /* Given an error_equivalency table and a completion code, return
2398  * the string representing the error. */
2399 static const char*
2400 ncp_error_string(const error_equivalency *errors, guint8 completion_code)
2401 {
2402
2403         while (errors->ncp_error_index != -1) {
2404                 if (errors->error_in_packet == completion_code) {
2405                         return ncp_errors[errors->ncp_error_index];
2406                 }
2407                 errors++;
2408         }
2409
2410         return "Unknown Error Code";
2411 }
2412
2413 static const ncp_record ncp1111_request =
2414         { 0x1, 0x00, NO_SUBFUNC, "Create Connection Service", NCP_GROUP_CONNECTION,
2415                 NULL, NULL, ncp_0x2_errors, NULL, NO_REQ_COND_SIZE, NULL };
2416
2417 static const ncp_record ncp5555_request =
2418         { 0x5, 0x00, NO_SUBFUNC, "Destroy Connection Service", NCP_GROUP_CONNECTION,
2419                 NULL, NULL, ncp_0x2_errors, NULL, NO_REQ_COND_SIZE, NULL };
2420
2421 static const ncp_record ncpbbbb_request =
2422         { 0xb, 0x00, NO_SUBFUNC, "Server Broadcast Message", NCP_GROUP_CONNECTION,
2423                 NULL, NULL, ncp_0x2_errors, NULL, NO_REQ_COND_SIZE, NULL };
2424
2425 static const ncp_record ncplip_echo =
2426         { 0x1f, 0x00, NO_SUBFUNC, "LIP Echo Packet", NCP_GROUP_CONNECTION,
2427                 NULL, NULL, ncp_0x2_errors, NULL, NO_REQ_COND_SIZE, NULL };
2428
2429 /* Wrapper around proto_tree_free() */
2430 static void free_proto_tree(void *tree)
2431 {
2432         if (tree) {
2433                 proto_tree_free((proto_tree*) tree);
2434         }
2435 }
2436
2437 static guint32
2438 align_4(tvbuff_t *tvb, guint32 aoffset)
2439 {
2440        if(tvb_length_remaining(tvb, aoffset) > 4 )
2441        {
2442                 return (aoffset%4);
2443        }
2444        return 0;
2445 }
2446
2447 static void
2448 get_string(tvbuff_t* tvb, guint offset, guint str_length, char *dest_buf)
2449 {
2450         gint i;
2451         guint16 c_char;
2452         gint length_remaining = 0;
2453
2454         length_remaining = tvb_length_remaining(tvb, offset);
2455         if((gint)str_length > length_remaining)
2456         {
2457                 THROW(ReportedBoundsError);
2458         }
2459         dest_buf[0] = '\0';
2460         if(str_length == 0)
2461         {
2462                 return;
2463         }
2464         for ( i = 0; i < (gint)str_length; i++ )
2465         {
2466                 c_char = tvb_get_guint8(tvb, offset );
2467                 if (c_char<0x20 || c_char>0x7e)
2468                 {
2469                         if (c_char != 0x00)
2470                         {
2471                                 c_char = '.';
2472                                 dest_buf[i] = c_char & 0xff;
2473                         }
2474                         else
2475                         {
2476                                 i--;
2477                                 str_length--;
2478                         }
2479                 }
2480                 else
2481                 {
2482                         dest_buf[i] = c_char & 0xff;
2483                 }
2484                 offset++;
2485                 length_remaining--;
2486
2487                 if(length_remaining==1)
2488                 {
2489                         dest_buf[i+1] = '\0';
2490                         return;
2491                 }
2492                 if (i >= 1023) { /* Don't process beyond the size of our varible */
2493                     break;       /* If string is too long just return the first 1K. */
2494                 }
2495         }
2496         if (i < 0) {
2497                 i = 0;
2498         }
2499         dest_buf[i] = '\0';
2500         return;
2501 }
2502
2503 static void
2504 uni_to_string(char * data, guint32 str_length, char *dest_buf)
2505 {
2506         gint i;
2507         guint16 c_char;
2508         gint length_remaining = 0;
2509
2510         length_remaining = str_length;
2511         dest_buf[0] = '\0';
2512         if(str_length == 0)
2513         {
2514                 return;
2515         }
2516         for ( i = 0; i < (gint) str_length; i++ )
2517         {
2518                 c_char = data[i];
2519                 if (c_char<0x20 || c_char>0x7e)
2520                 {
2521                         if (c_char != 0x00)
2522                         {
2523                                 c_char = '.';
2524                                 dest_buf[i] = c_char & 0xff;
2525                         }
2526                         else
2527                         {
2528                                 i--;
2529                                 str_length--;
2530                         }
2531                 }
2532                 else
2533                 {
2534                         dest_buf[i] = c_char & 0xff;
2535                 }
2536                 length_remaining--;
2537
2538                 if(length_remaining==0)
2539                 {
2540                         dest_buf[i+1] = '\0';
2541                         return;
2542                 }
2543         }
2544         if (i < 0) {
2545                 i = 0;
2546         }
2547         dest_buf[i] = '\0';
2548         return;
2549 }
2550
2551 /*************************************
2552 * Return based on % format in request
2553 * %d = integer in decimal format = 0
2554 * %x = integer in hex format = 1
2555 * %s = string = 2
2556 **************************************/
2557 static int
2558 get_info_type(const gchar* check_string)
2559 {
2560         guint length;
2561         guint i;
2562         char char_val;
2563
2564         length =  strlen(check_string);
2565
2566         for (i = 0 ; i < length-1 ; i++ ) {
2567                 char_val = check_string[i+1];
2568                 if (check_string[i] == 0x25 && check_string[i+1] == 0x64) {   /* %d Digits*/
2569                         return 0;
2570                 }
2571                 if ( check_string[i] == 0x78 && check_string[i+1] == 0x25 && check_string[i+2] == 0x73) {  /* x%s Bytes*/
2572                         return 1;
2573                 }
2574         }
2575         return 2; /* Normal String */
2576 }
2577
2578 static void
2579 process_bitfield(proto_tree *ncp_tree, tvbuff_t *tvb, nds_val *values)
2580 {
2581         gchar                   flags_str[512];
2582         const gchar             *sep;
2583         proto_item              *tinew;
2584         proto_tree              *flags_tree;
2585         guint32                 i;
2586         guint32                 bvalue = 0;
2587
2588         bvalue = 0x00000001;
2589         flags_str[0]='\0';
2590         sep="";
2591         for (i = 0 ; i < (values->vlength*8); i++ ) {
2592                 if (values->vvalue & bvalue)
2593                 {
2594                         g_strlcat(flags_str, sep, 512);
2595                         switch(bvalue){
2596                                 case 0x00000001:
2597                                         g_strlcat(flags_str, values->bit1, 512);
2598                                         break;
2599                                 case 0x00000002:
2600                                         g_strlcat(flags_str, values->bit2, 512);
2601                                         break;
2602                                 case 0x00000004:
2603                                         g_strlcat(flags_str, values->bit3, 512);
2604                                         break;
2605                                 case 0x00000008:
2606                                         g_strlcat(flags_str, values->bit4, 512);
2607                                         break;
2608                                 case 0x00000010:
2609                                         g_strlcat(flags_str, values->bit5, 512);
2610                                         break;
2611                                 case 0x00000020:
2612                                         g_strlcat(flags_str, values->bit6, 512);
2613                                         break;
2614                                 case 0x00000040:
2615                                         g_strlcat(flags_str, values->bit7, 512);
2616                                         break;
2617                                 case 0x00000080:
2618                                         g_strlcat(flags_str, values->bit8, 512);
2619                                         break;
2620                                 case 0x00000100:
2621                                         g_strlcat(flags_str, values->bit9, 512);
2622                                         break;
2623                                 case 0x00000200:
2624                                         g_strlcat(flags_str, values->bit10, 512);
2625                                         break;
2626                                 case 0x00000400:
2627                                         g_strlcat(flags_str, values->bit11, 512);
2628                                         break;
2629                                 case 0x00000800:
2630                                         g_strlcat(flags_str, values->bit12, 512);
2631                                         break;
2632                                 case 0x00001000:
2633                                         g_strlcat(flags_str, values->bit13, 512);
2634                                         break;
2635                                 case 0x00002000:
2636                                         g_strlcat(flags_str, values->bit14, 512);
2637                                         break;
2638                                 case 0x00004000:
2639                                         g_strlcat(flags_str, values->bit15, 512);
2640                                         break;
2641                                 case 0x00008000:
2642                                         g_strlcat(flags_str, values->bit16, 512);
2643                                         break;
2644                                 default:
2645                                         break;
2646                         }
2647                         sep = ", ";
2648                 }
2649                 bvalue = bvalue*2;
2650         }
2651         if(values->vlength==4)
2652         {
2653                 tinew = proto_tree_add_uint_format(ncp_tree, values->hfname,
2654                         tvb, values->voffset, values->vlength, values->vvalue, "%s 0x%08x",
2655                         values->vdesc, values->vvalue);
2656         }
2657         else
2658         {
2659                 tinew = proto_tree_add_uint_format(ncp_tree, values->hfname,
2660                         tvb, values->voffset, values->vlength, values->vvalue, "%s 0x%04x",
2661                         values->vdesc, values->vvalue);
2662         }
2663         if (flags_str[0] != '\0')
2664                 proto_item_append_text(tinew, " - (%s)", flags_str);
2665
2666         flags_tree = proto_item_add_subtree(tinew, ett_nds);
2667
2668         bvalue = 0x00000001;
2669
2670         for (i = 0 ; i < (values->vlength*8); i++ ) {
2671                 if (values->vvalue & bvalue)
2672                 {
2673                         switch(bvalue)
2674                         {
2675                                 case 0x00000001:
2676                                         proto_tree_add_item(flags_tree, values->bit1hfname, tvb, values->voffset, values->vlength, TRUE);
2677                                         break;
2678                                 case 0x00000002:
2679                                             proto_tree_add_item(flags_tree, values->bit2hfname, tvb, values->voffset, values->vlength, TRUE);
2680                                         break;
2681                                 case 0x00000004:
2682                                             proto_tree_add_item(flags_tree, values->bit3hfname, tvb, values->voffset, values->vlength, TRUE);
2683                                         break;
2684                                 case 0x00000008:
2685                                         proto_tree_add_item(flags_tree, values->bit4hfname, tvb, values->voffset, values->vlength, TRUE);
2686                                         break;
2687                                 case 0x00000010:
2688                                         proto_tree_add_item(flags_tree, values->bit5hfname, tvb, values->voffset, values->vlength, TRUE);
2689                                         break;
2690                                 case 0x00000020:
2691                                         proto_tree_add_item(flags_tree, values->bit6hfname, tvb, values->voffset, values->vlength, TRUE);
2692                                         break;
2693                                 case 0x00000040:
2694                                         proto_tree_add_item(flags_tree, values->bit7hfname, tvb, values->voffset, values->vlength, TRUE);
2695                                         break;
2696                                 case 0x00000080:
2697                                         proto_tree_add_item(flags_tree, values->bit8hfname, tvb, values->voffset, values->vlength, TRUE);
2698                                         break;
2699                                 case 0x00000100:
2700                                         proto_tree_add_item(flags_tree, values->bit9hfname, tvb, values->voffset, values->vlength, TRUE);
2701                                         break;
2702                                 case 0x00000200:
2703                                         proto_tree_add_item(flags_tree, values->bit10hfname, tvb, values->voffset, values->vlength, TRUE);
2704                                         break;
2705                                 case 0x00000400:
2706                                         proto_tree_add_item(flags_tree, values->bit11hfname, tvb, values->voffset, values->vlength, TRUE);
2707                                         break;
2708                                 case 0x00000800:
2709                                         proto_tree_add_item(flags_tree, values->bit12hfname, tvb, values->voffset, values->vlength, TRUE);
2710                                         break;
2711                                 case 0x00001000:
2712                                         proto_tree_add_item(flags_tree, values->bit13hfname, tvb, values->voffset, values->vlength, TRUE);
2713                                         break;
2714                                 case 0x00002000:
2715                                         proto_tree_add_item(flags_tree, values->bit14hfname, tvb, values->voffset, values->vlength, TRUE);
2716                                         break;
2717                                 case 0x00004000:
2718                                         proto_tree_add_item(flags_tree, values->bit15hfname, tvb, values->voffset, values->vlength, TRUE);
2719                                         break;
2720                                 case 0x00008000:
2721                                         proto_tree_add_item(flags_tree, values->bit16hfname, tvb, values->voffset, values->vlength, TRUE);
2722                                         break;
2723                                 default:
2724                                         break;
2725                         }
2726                 }
2727                 bvalue = bvalue*2;
2728         }
2729 }
2730
2731 /* NCP data from python code can't be accessed directly. Parse the ncp tree and find the items
2732  * and their associated values. Store results in passed buffer.
2733  */
2734 static void
2735 build_expert_data(proto_tree *ncp_tree, char *hf_name, char *buffer, int repeat_lookup, gboolean search_structs)
2736 {
2737         proto_tree              *tree_pointer;
2738         proto_tree              *tree_loc;
2739         proto_tree              *struct_tree_pointer = NULL;
2740     char            temp_buffer[256]="\0";
2741     gboolean        in_struct=FALSE;
2742
2743     tree_loc = ncp_tree->first_child;
2744         for (tree_pointer=tree_loc; tree_pointer!=NULL; tree_pointer=tree_pointer->next)
2745         {
2746         /* We currently only go one structure deep in our search for values */
2747         if (tree_pointer->first_child && !in_struct && search_structs) {
2748             struct_tree_pointer = tree_pointer;
2749             tree_pointer = tree_pointer->first_child;
2750             in_struct=TRUE;
2751         }
2752                 if (strcmp(tree_pointer->finfo->hfinfo->abbrev, hf_name)==0)
2753                 {
2754                         switch (tree_pointer->finfo->hfinfo->type)
2755                         {
2756             case 3:                             /* uint8 */
2757             case 4:                             /* uint16 */
2758                 g_snprintf(buffer, get_finfo_length(tree_pointer->finfo)*4, "%d", get_finfo_value_integer(tree_pointer->finfo));
2759                                 break;
2760
2761             case 6:             /* uint32 */
2762                 g_snprintf(buffer, get_finfo_length(tree_pointer->finfo)*4, "%08x", get_finfo_value_integer(tree_pointer->finfo));
2763                                 break;
2764             case 17:
2765             case 18:
2766             case 19:
2767                         case 20:                        /* string */
2768                         uni_to_string(get_finfo_value_string(tree_pointer->finfo), get_finfo_length(tree_pointer->finfo), buffer);
2769                 if (repeat_lookup > 0) {
2770                     if (strlen(temp_buffer) + strlen(buffer) < 250) {
2771                         g_strlcat(temp_buffer, buffer, 256);
2772                         repeat_lookup--;
2773                         if (repeat_lookup == 0) {
2774                             g_strlcpy(buffer, temp_buffer, 256);
2775                             break;
2776                         }
2777                         else
2778                         {
2779                             g_strlcat(temp_buffer, "/", 256);
2780                             break;
2781                         }
2782                     }
2783                     else
2784                     {
2785                         return;
2786                     }
2787                 }
2788                 else
2789                 {
2790                     break;
2791                 }
2792             case 21:
2793             case 22:             /* Bytes */
2794                 g_snprintf(buffer, (get_finfo_length(tree_pointer->finfo))*4, "%s", bytes_to_str(get_finfo_value_string(tree_pointer->finfo), get_finfo_length(tree_pointer->finfo)));
2795                 break;
2796                         default:                        /* Dont currently handle. Only need string, integers, and bytes */
2797                                 buffer = "Unsupported Expert Type\0";
2798                                 return;
2799                         }
2800             if (repeat_lookup ==0) {
2801                 break;
2802             }
2803                 }
2804         if (tree_pointer->next==NULL && in_struct && search_structs) {
2805                 tree_pointer = struct_tree_pointer;
2806                 in_struct=FALSE;
2807         }
2808         }
2809     if (strlen(buffer)==0) {
2810         buffer = "No Value\0";
2811     }
2812     return;
2813 }
2814
2815 /* Some NCP data may be desirable to echo to the expert table.
2816  * But to extract we must have visability to the tree
2817  * This means that to extract the data we can only perform
2818  * this code path on the first dissection or a redissect.
2819  *
2820  * Should the dissector store this info in memory so that
2821  * the data can be reported wihout a complete redissection?
2822  */
2823 static void
2824 trap_for_expert_event(proto_tree *ncp_tree, packet_info *pinfo, const ncp_record *ncp_rec, int request_reply)
2825 {
2826     if (ncp_rec == NULL)
2827         return;
2828     /* Request == 0, Reply == 1 */
2829     if (request_reply==0) {
2830         if (ncp_echo_file) {
2831             /* The following allows for Update file handle rights echoed to expert tap. */
2832             if (ncp_rec->func == 66) {
2833                 char p_filehandle[15]="\0";
2834
2835                 build_expert_data(ncp_tree, "ncp.file_handle", p_filehandle, 0, FALSE);
2836
2837                 expert_add_info_format(pinfo, NULL, PI_REQUEST_CODE, PI_CHAT, "Close file handle %s", p_filehandle);
2838             }
2839             /* The following allows for oplock level 1 file opens echoed to expert tap. */
2840             if ((ncp_rec->func == 89 || ncp_rec->func == 87) && (ncp_rec->subfunc == 1 || ncp_rec->subfunc == 30 || ncp_rec->subfunc == 32 || ncp_rec->subfunc == 33)) {
2841                 char oaction[2]="\0";
2842                 char p_filename[256]="\0";
2843                 char p_rights[2]="\0";
2844                 char p_path_count[2]="\0";
2845
2846                 build_expert_data(ncp_tree, "ncp.open_create_mode", oaction, 0, FALSE);
2847                 build_expert_data(ncp_tree, "ncp.desired_access_rights", p_rights, 0, FALSE);
2848                 build_expert_data(ncp_tree, "ncp.path_count", p_path_count, 0, FALSE);
2849
2850                 if (ncp_rec->func == 87) {
2851                     build_expert_data(ncp_tree, "ncp.path", p_filename, atoi(p_path_count), FALSE);
2852                 }
2853                 else
2854                 {
2855                     build_expert_data(ncp_tree, "ncp.path16", p_filename, atoi(p_path_count), FALSE);
2856                 }
2857
2858                 expert_add_info_format(pinfo, NULL, PI_REQUEST_CODE, PI_CHAT, "%s: %s, Rights:(%s)", match_strval((atoi(oaction) & 0xeb), open_create_mode_vals), p_filename, match_strval((atoi(p_rights) & 0x5f), ncp_rights_vals));
2859             }
2860             /* The following allows for oplock ack's and level 2 request echoed to expert tap. */
2861             if (ncp_rec->func == 87 && ncp_rec->subfunc == 34) {
2862                 char cc_function[2]="\0";
2863                 char p_filehandle[15]="\0";
2864
2865                 build_expert_data(ncp_tree, "ncp.cc_file_handle", p_filehandle, 0, FALSE);
2866                 build_expert_data(ncp_tree, "ncp.cc_function", cc_function, 0, FALSE);
2867
2868                 expert_add_info_format(pinfo, NULL, PI_REQUEST_CODE, PI_CHAT, "Op-lock on handle %s - %s", p_filehandle, match_strval(atoi(cc_function), ncp_cc_function_vals));
2869             }
2870             /* The following allows for Update file handle rights echoed to expert tap. */
2871             if (ncp_rec->func == 87 && ncp_rec->subfunc == 44) {
2872                 char p_rights[20]="\0";
2873                 char n_rights[20]="\0";
2874                 char p_filehandle[15]="\0";
2875
2876                 build_expert_data(ncp_tree, "ncp.file_handle", p_filehandle, 0, FALSE);
2877                 build_expert_data(ncp_tree, "ncp.access_rights_mask_word", p_rights, 0, FALSE);
2878                 build_expert_data(ncp_tree, "ncp.new_access_rights_mask", n_rights, 0, FALSE);
2879                 expert_add_info_format(pinfo, NULL, PI_REQUEST_CODE, PI_CHAT, "Change handle %s rights from:(%s) to:(%s)", p_filehandle, match_strval((atoi(p_rights) & 0x1ff), access_rights_vals), match_strval((atoi(n_rights) & 0x1ff), access_rights_vals));
2880             }
2881         }
2882     }
2883     else
2884     {
2885
2886         if (ncp_echo_file) { /* Echo File System Data */
2887             /* The following allows for oplock level 1 file opens echoed to expert tap. */
2888             if ((ncp_rec->func == 89 || ncp_rec->func == 87) && (ncp_rec->subfunc == 32 || ncp_rec->subfunc == 1)) {
2889                 char oaction[2]="\0";
2890                 char oplockflg[2]="\0";
2891                 char p_filehandle[15]="\0";
2892
2893                 build_expert_data(ncp_tree, "ncp.open_create_action", oaction, 0, FALSE);
2894                 build_expert_data(ncp_tree, "ncp.file_handle", p_filehandle, 0, FALSE);
2895
2896                 if (ncp_rec->subfunc == 1) {
2897                     expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "%s - File handle %s", match_strval((atoi(oaction) & 0x8f), open_create_action_vals), p_filehandle);
2898                 }
2899                 else
2900                 {
2901                     build_expert_data(ncp_tree, "ncp.o_c_ret_flags", oplockflg, 0, FALSE);
2902                     expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "%s - File handle %s, %s", match_strval((atoi(oaction) & 0x8f), open_create_action_vals), p_filehandle, match_strval(atoi(oplockflg), ncp_o_c_ret_flags_vals));
2903                 }
2904             }
2905             /* The following allows for Update file handle rights echoed to expert tap. */
2906             if (ncp_rec->func == 87 && ncp_rec->subfunc == 44) {
2907                 char p_rights[20]="\0";
2908                 char p_filehandle[15]="\0";
2909
2910                 build_expert_data(ncp_tree, "ncp.file_handle", p_filehandle, 0, FALSE);
2911                 build_expert_data(ncp_tree, "ncp.effective_rights", p_rights, 0, FALSE);
2912                 expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Handle %s effective rights:(%s)", p_filehandle, match_strval((atoi(p_rights) & 0x1ff), access_rights_vals));
2913             }
2914         }
2915         /* The following allows for specific NCP server info to be echoed to the expert tap. */
2916         if (ncp_rec->func == 23 && ncp_rec->subfunc == 17 && ncp_echo_server) {
2917             char fsname[50]="\0";
2918             char p_maj_ver[3]="\0";
2919             char p_min_ver[3]="\0";
2920             char p_rev[3]="\0";
2921             char p_lang[3]="\0";
2922
2923             /* Get Server name and version info */
2924             build_expert_data(ncp_tree, "ncp.server_name", fsname, 0, FALSE);
2925             build_expert_data(ncp_tree, "ncp.product_major_version", p_maj_ver, 0, FALSE);
2926             build_expert_data(ncp_tree, "ncp.product_minor_version", p_min_ver, 0, FALSE);
2927             build_expert_data(ncp_tree, "ncp.product_revision_version", p_rev, 0, FALSE);
2928             build_expert_data(ncp_tree, "ncp.os_language_id", p_lang, 0, FALSE);
2929             expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Server %s, version %s.%s, support pack %s, language %s", fsname,
2930                                    p_maj_ver, p_min_ver, p_rev, p_lang);
2931         }
2932     }
2933 }
2934
2935
2936 static void
2937 print_nds_values(proto_tree *vtree, tvbuff_t *tvb, guint32 syntax_type, nds_val *vvalues)
2938 {
2939         guint32         value1 = 0;
2940         guint32         value2 = 0;
2941         guint32         value3 = 0;
2942         guint32         value4 = 0;
2943         guint32         value5 = 0;
2944         guint32         voffset = 0, oldvoffset;
2945         guint32         icounter;
2946         guint32         number_of_values = 0;
2947         guint32         number_of_items = 0;
2948         guint32         r;
2949         proto_item      *vitem;
2950         proto_tree      *nvtree;
2951         proto_item      *aditem;
2952         proto_tree      *adtree;
2953         const char      *valuestr = NULL;
2954         guint16         rtype = 0;
2955         guint16         rstate = 0;
2956         guint16         rnum = 0;
2957         guint16         revent = 0;
2958             gint                    length_remaining;
2959         nstime_t        ns;
2960         gboolean        entry_rights = FALSE;
2961         nds_val         temp_values;
2962
2963         voffset = vvalues->voffset;
2964         if(tvb_get_guint8(tvb, voffset) == 0x00)
2965         {
2966                 voffset = voffset+2;
2967         }
2968
2969         number_of_values = tvb_get_letohl(tvb, voffset);
2970
2971         vitem = proto_tree_add_uint_format(vtree, hf_nds_uint32value, tvb, voffset,
2972                 4, number_of_values, "Number of Values: %u", number_of_values);
2973
2974         nvtree = proto_item_add_subtree(vitem, ett_nds);
2975
2976         oldvoffset = voffset;
2977         voffset = voffset + 4;
2978
2979         for (icounter = 1 ; icounter <= number_of_values; icounter++ )
2980         {
2981                 if (oldvoffset >= voffset) {
2982                         proto_tree_add_text(nvtree, tvb, 0, 0, "[ Invalid offset: %u ]", voffset);
2983                         THROW(ReportedBoundsError);
2984                 }
2985                 oldvoffset = voffset;
2986                 switch(syntax_type)
2987                 {
2988                        case 0x00000006:        /* Case Insensitive List */
2989                        case 0x00000012:        /* Postal Address */
2990                                voffset += align_4(tvb, voffset);
2991                                voffset = voffset+4;
2992                                number_of_items = tvb_get_letohl(tvb, voffset);
2993                                voffset = voffset+4;
2994                                for (r=1; r<=number_of_items; r++)
2995                                {
2996                                        value1 = tvb_get_letohl(tvb, voffset);
2997                                        voffset = voffset + 4;
2998                                        get_string(tvb, voffset, value1, vvalues->vstring);
2999                                        proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3000                                            value1, vvalues->vstring);
3001                                        voffset = voffset + value1;
3002                                        voffset += align_4(tvb, voffset);
3003                                }
3004                                break;
3005                         case 0x00000007:        /* Boolean */
3006                                voffset+=4;                            /* this is always just a parameter count of 1, so ignore */
3007                                value1 = tvb_get_guint8(tvb, voffset); /* Boolean value */
3008                                if (value1==0)
3009                                {
3010                                        vvalues->vstring = "False";
3011                                }
3012                                else
3013                                {
3014                                        vvalues->vstring = "True";
3015                                }
3016                                tvb_ensure_bytes_exist(tvb, voffset, 1);
3017                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3018                                            1, vvalues->vstring);
3019                                voffset=voffset+1;
3020                                voffset += align_4(tvb, voffset);
3021                                break;
3022                        case 0x00000009:        /* Binary String */
3023                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3024                                length_remaining = tvb_length_remaining(tvb, voffset);
3025                                if(length_remaining == -1 || value1 > (guint32) length_remaining)
3026                                {
3027                                         break;
3028                                }
3029                                voffset += 4;
3030                                tvb_ensure_bytes_exist(tvb, voffset, value1);
3031                                proto_tree_add_bytes(nvtree, hf_value_bytes, tvb, voffset, value1, tvb_get_ptr(tvb, voffset, value1));
3032                                voffset += value1;
3033                                voffset += (value1%2);
3034                                break;
3035                        case 0x0000000d:        /* Binary String List */
3036                            value1 = tvb_get_letohl(tvb, voffset); /* Overall length of field list */
3037                            length_remaining = tvb_length_remaining(tvb, voffset);
3038                            if(length_remaining == -1 || value1 > (guint32) length_remaining)
3039                            {
3040                                     break;
3041                            }
3042                            voffset += 4;
3043                            tvb_ensure_bytes_exist(tvb, voffset, value1);
3044                            number_of_items = tvb_get_letohl(tvb, voffset);
3045                            voffset = voffset+4;
3046                            for (r=1; r<=number_of_items; r++)
3047                            {
3048                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3049                                length_remaining = tvb_length_remaining(tvb, voffset);
3050                                if(length_remaining == -1 || value1 > (guint32) length_remaining)
3051                                {
3052                                         break;
3053                                }
3054                                voffset += 4;
3055                                tvb_ensure_bytes_exist(tvb, voffset, value1);
3056                                proto_tree_add_bytes(nvtree, hf_value_bytes, tvb, voffset, value1, tvb_get_ptr(tvb, voffset, value1));
3057                                voffset += value1;
3058                                voffset += (value1%2);
3059                            }
3060                            break;
3061                        case 0x00000015:        /* Stream */
3062                            value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3063                            length_remaining = tvb_length_remaining(tvb, voffset);
3064                            if(length_remaining == -1 || value1 > (guint32) length_remaining)
3065                            {
3066                                     break;
3067                            }
3068                            proto_tree_add_text(nvtree, tvb, voffset, 4, "No value, Open stream file for data.");
3069                            voffset += 4;
3070                            voffset += value1;
3071                            voffset += (value1%2);
3072                            break;
3073                        case 0x00000008:        /* Signed Integer */
3074                        case 0x00000016:        /* Counter */
3075                        case 0x0000001b:        /* Interval */
3076                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3077                                voffset = voffset+4;
3078                                value2 = tvb_get_letohl(tvb, voffset); /* Value */
3079                                tvb_ensure_bytes_exist(tvb, voffset, value1);
3080                                if (strcmp(vvalues->vstring, "zendmSearchType")==0) {
3081                                    proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3082                                             value1, value2, "Value (%d) = %s", value2, match_strval(value2, zensearchenum));
3083                                }
3084                                else
3085                                {
3086                                    proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3087                                             value1, value2, "Value %d", value2);
3088                                }
3089                                voffset = voffset+4;
3090                                break;
3091                        case 0x0000000b:        /* Fax Number */
3092                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3093                                voffset = voffset+4;
3094                                get_string(tvb, voffset, value1, vvalues->vstring);
3095                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3096                                         value1, vvalues->vstring);
3097                                voffset = voffset + value1;
3098                                voffset += align_4(tvb, voffset);
3099                                break;
3100                        case 0x0000000c:        /* Network Address */
3101                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3102                                voffset = voffset + 4;
3103                                value2 = tvb_get_letohl(tvb, voffset); /* type of Protocol */
3104                                valuestr = match_strval(value2, nds_protocol_type);
3105                                if (valuestr == NULL)
3106                                {
3107                                                valuestr="(Undefined Protocol)";
3108                                }
3109                                tvb_ensure_bytes_exist(tvb, voffset, value1);
3110                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3111                                    value1, value2, valuestr, value2);
3112                                voffset = voffset+4;
3113                                value3 = tvb_get_letohl(tvb, voffset); /* length of address */
3114                                voffset = voffset+4;
3115                                switch (value2)
3116                                {
3117                                         case NDS_PTYPE_IPX:
3118                                                 proto_tree_add_item(nvtree, hf_nds_net, tvb, voffset, 4, FALSE);
3119                                                         proto_tree_add_item(nvtree, hf_nds_node, tvb, voffset+4, 6, FALSE);
3120                                                         proto_tree_add_item(nvtree, hf_nds_socket, tvb, voffset+10, 2, FALSE);
3121                                                 break;
3122                                         case NDS_PTYPE_IP:
3123                                             if (value3 > 4) {
3124                                                 proto_tree_add_item(nvtree, hf_nds_port, tvb, voffset, 2, FALSE);
3125                                                 voffset += 2;
3126                                             }
3127                                                 proto_tree_add_item(nvtree, hf_add_ref_ip, tvb, voffset, 4, FALSE);
3128                                             break;
3129                                         case NDS_PTYPE_UDP:
3130                                             if (value3 > 4) {
3131                                                 proto_tree_add_item(nvtree, hf_nds_port, tvb, voffset, 2, FALSE);
3132                                                 voffset += 2;
3133                                             }
3134                                                 proto_tree_add_item(nvtree, hf_add_ref_udp, tvb, voffset, 4, FALSE);
3135                                             break;
3136                                         case NDS_PTYPE_TCP:
3137                                                 proto_tree_add_item(nvtree, hf_nds_port, tvb, voffset, 2, FALSE);
3138                                                 proto_tree_add_item(nvtree, hf_add_ref_tcp, tvb, voffset+2, 4, FALSE);
3139                                                 break;
3140                                         case NDS_PTYPE_URL:
3141                                         case NDS_PTYPE_DNS:
3142                                                 get_string(tvb, voffset, value3, vvalues->vstring);
3143                                                 proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3144                                                         value3, vvalues->vstring);
3145                                                 break;
3146                                         default:
3147                                                 break;
3148                                }
3149                                voffset = voffset + value3;
3150                                voffset += align_4(tvb, voffset);
3151                                break;
3152                        case 0x0000000f:        /* File System Path */
3153                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3154                                voffset = voffset + 4;
3155                                value2 = tvb_get_letohl(tvb, voffset); /* Name Space */
3156                                valuestr = match_strval(value2, name_space_type);
3157                                if (valuestr == NULL)
3158                                {
3159                                         valuestr = "Unknown Name Space";
3160                                }
3161                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3162                                         4, valuestr);
3163                                voffset = voffset+4;
3164                                value3 = tvb_get_letohl(tvb, voffset); /* Length of Volume name */
3165                                voffset = voffset+4;
3166                                get_string(tvb, voffset, value3, vvalues->vstring);
3167                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3168                                         value3, vvalues->vstring);
3169                                voffset = voffset+value3;
3170                                voffset += align_4(tvb, voffset);
3171                                value4 = tvb_get_letohl(tvb, voffset); /* Length of Path name */
3172                                voffset = voffset+4;
3173                                get_string(tvb, voffset, value4, vvalues->vstring);
3174                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3175                                         value4, vvalues->vstring);
3176                                voffset = voffset+value4;
3177                                voffset += align_4(tvb, voffset);
3178                                break;
3179                        case 0x00000010:        /* Replica Pointer */
3180                                value1 = tvb_get_letohl(tvb, voffset); /* length of field */
3181                                voffset = voffset + 4;
3182                                value2 = tvb_get_letohl(tvb, voffset); /* Length of Server name */
3183                                voffset = voffset+4;
3184                                get_string(tvb, voffset, value2, vvalues->vstring);
3185                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3186                                         value2, vvalues->vstring);
3187                                voffset = voffset+value2;
3188                                voffset += align_4(tvb, voffset);
3189                                rtype = tvb_get_letohs(tvb, voffset); /* replica type */
3190                                valuestr = match_strval(rtype, nds_replica_type);
3191                                if (valuestr == NULL)
3192                                {
3193                                         valuestr="(Unknown Replica Type)";
3194                                }
3195                                proto_tree_add_string(nvtree, hf_replica_type, tvb, voffset,
3196                                         2, valuestr);
3197                                voffset = voffset+2;
3198                                rstate = tvb_get_letohs(tvb, voffset); /* replica state */
3199                                valuestr = match_strval(rstate, nds_replica_state);
3200                                if (valuestr == NULL)
3201                                {
3202                                         valuestr="(Unknown Replica State)";
3203                                }
3204                                proto_tree_add_string(nvtree, hf_replica_state, tvb, voffset,
3205                                         2, valuestr);
3206                                voffset = voffset+2;
3207                                value3 = tvb_get_letohl(tvb, voffset); /* Replica number */
3208                                proto_tree_add_uint_format(nvtree, hf_replica_number, tvb, voffset,
3209                                         4, value3, "Replica Number %d", value3);
3210                                voffset = voffset+4;
3211                                number_of_items = tvb_get_letohl(tvb, voffset);  /* Number of Addresses */
3212                                aditem = proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3213                                         4, number_of_items, "Number of Addresses: %u", number_of_items);
3214
3215                                adtree = proto_item_add_subtree(aditem, ett_nds);
3216                                voffset = voffset+4;
3217                                for (r=1; r <= number_of_items; r++)
3218                                {
3219                                         voffset += align_4(tvb, voffset);
3220                                         value4 = tvb_get_letohl(tvb, voffset); /* type of Protocol */
3221                                         valuestr = match_strval(value4, nds_protocol_type);
3222                                         if (valuestr == NULL)
3223                                         {
3224                                                valuestr="(Undefined Protocol)";
3225                                         }
3226                                         proto_tree_add_uint_format(adtree, hf_nds_uint32value, tvb, voffset,
3227                                                 4, value4, valuestr, value4);
3228                                         voffset = voffset+4;
3229                                         value5 = tvb_get_letohl(tvb, voffset); /* length of address */
3230                                         voffset = voffset+4;
3231                                         switch (value4)
3232                                         {
3233                                                 case NDS_PTYPE_IPX:
3234                                                         proto_tree_add_item(adtree, hf_nds_net, tvb, voffset, 4, FALSE);
3235                                                         proto_tree_add_item(adtree, hf_nds_node, tvb, voffset+4, 6, FALSE);
3236                                                         proto_tree_add_item(adtree, hf_nds_socket, tvb, voffset+10, 2, FALSE);
3237                                                         break;
3238                                                 case NDS_PTYPE_IP:
3239                                                         proto_tree_add_item(adtree, hf_nds_port, tvb, voffset, 2, FALSE);
3240                                                         proto_tree_add_item(adtree, hf_add_ref_ip, tvb, voffset+2, 4, FALSE);
3241                                                         break;
3242                                                 case NDS_PTYPE_UDP:
3243                                                         proto_tree_add_item(adtree, hf_nds_port, tvb, voffset, 2, FALSE);
3244                                                         proto_tree_add_item(adtree, hf_add_ref_udp, tvb, voffset+2, 4, FALSE);
3245                                                         break;
3246                                                 case NDS_PTYPE_TCP:
3247                                                         proto_tree_add_item(adtree, hf_nds_port, tvb, voffset, 2, FALSE);
3248                                                         proto_tree_add_item(adtree, hf_add_ref_tcp, tvb, voffset+2, 4, FALSE);
3249                                                         break;
3250                                                 case NDS_PTYPE_URL:
3251                                                 case NDS_PTYPE_DNS:
3252                                                         get_string(tvb, voffset, value5, vvalues->vstring);
3253                                                         proto_tree_add_string(adtree, hf_value_string, tvb, voffset,
3254                                                                 value5, vvalues->vstring);
3255                                                         break;
3256                                                 default:
3257                                                         break;
3258                                         }
3259                                         voffset = voffset + value5;
3260                                }
3261                                voffset += align_4(tvb, voffset);
3262                                break;
3263                        case 0x00000011:        /* Object ACL */
3264                                value1 = tvb_get_letohl(tvb, voffset); /* Length of Field */
3265                                voffset = voffset + 4;
3266                                value2 = tvb_get_letohl(tvb, voffset);
3267                                voffset = voffset + 4;
3268                                get_string(tvb, voffset, value2, vvalues->vstring); /* Unicode String */
3269                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3270                                    value2, vvalues->vstring);
3271                                if (strcmp(vvalues->vstring, "[Entry Rights]")) {
3272                                    entry_rights=TRUE;
3273                                }
3274                                else
3275                                {
3276                                    entry_rights=FALSE;
3277                                }
3278                                voffset = voffset + value2;
3279                                voffset += align_4(tvb, voffset);
3280                                value3 = tvb_get_letohl(tvb, voffset);
3281                                voffset = voffset + 4;
3282                                get_string(tvb, voffset, value3, vvalues->vstring); /* Unicode Subject Name */
3283                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3284                                    value3, vvalues->vstring);
3285                                voffset = voffset + value3;
3286                                voffset += align_4(tvb, voffset);
3287                                temp_values.vvalue = tvb_get_letohl(tvb, voffset); /* Entry or Attribute Privileges */
3288                                temp_values.vlength = 2;
3289                                temp_values.hfname = hf_nds_vflags;
3290                                temp_values.voffset = voffset;
3291                                temp_values.vdesc = "Privileges";
3292                                if (entry_rights) {
3293                                    /* if Entries then use these bits */
3294                                    temp_values.bit1 = "Compare Attributes";
3295                                    temp_values.bit1hfname = hf_nds_compare_attributes;
3296                                    temp_values.bit2 = "Read Attribute";
3297                                    temp_values.bit2hfname = hf_nds_read_attribute;
3298                                    temp_values.bit3 = "Write, Add, Delete Attribute";
3299                                    temp_values.bit3hfname = hf_nds_write_add_delete_attribute;
3300                                    temp_values.bit4 = "Add/Delete Self";
3301                                    temp_values.bit4hfname = hf_nds_add_delete_self;
3302                                    temp_values.bit5 = "Attribute Privilege Not Defined";
3303                                    temp_values.bit5hfname = hf_nds_privilege_not_defined;
3304                                    temp_values.bit6 = "Supervisor";
3305                                    temp_values.bit6hfname = hf_nds_supervisor;
3306                                    temp_values.bit7 = "Inheritance Control";
3307                                    temp_values.bit7hfname = hf_nds_inheritance_control;
3308                                    temp_values.bit8 = "Not Defined";
3309                                    temp_values.bit8hfname = hf_bit8vflags;
3310                                    temp_values.bit9 = "Not Defined";
3311                                    temp_values.bit9hfname = hf_bit9vflags;
3312                                    temp_values.bit10 = "Not Defined";
3313                                    temp_values.bit10hfname = hf_bit10vflags;
3314                                    temp_values.bit11 = "Not Defined";
3315                                    temp_values.bit11hfname = hf_bit11vflags;
3316                                    temp_values.bit12 = "Not Defined";
3317                                    temp_values.bit12hfname = hf_bit12vflags;
3318                                    temp_values.bit13 = "Not Defined";
3319                                    temp_values.bit13hfname = hf_bit13vflags;
3320                                    temp_values.bit14 = "Not Defined";
3321                                    temp_values.bit14hfname = hf_bit14vflags;
3322                                    temp_values.bit15 = "Not Defined";
3323                                    temp_values.bit15hfname = hf_bit15vflags;
3324                                    temp_values.bit16 = "Not Defined";
3325                                    temp_values.bit16hfname = hf_bit16vflags;
3326                                }
3327                                else
3328                                {
3329                                    /* if attribute rights then do these bits */
3330                                    temp_values.bit1 = "Browse";
3331                                    temp_values.bit1hfname = hf_nds_browse_entry;
3332                                    temp_values.bit2 = "Add";
3333                                    temp_values.bit2hfname = hf_nds_add_entry;
3334                                    temp_values.bit3 = "Delete";
3335                                    temp_values.bit3hfname = hf_nds_delete_entry;
3336                                    temp_values.bit4 = "Rename";
3337                                    temp_values.bit4hfname = hf_nds_rename_entry;
3338                                    temp_values.bit5 = "Supervisor";
3339                                    temp_values.bit5hfname = hf_nds_supervisor_entry;
3340                                    temp_values.bit6 = "Entry Privilege Not Defined";
3341                                    temp_values.bit6hfname = hf_nds_entry_privilege_not_defined;
3342                                    temp_values.bit7 = "Inheritance Control";
3343                                    temp_values.bit7hfname = hf_nds_inheritance_control;
3344                                    temp_values.bit8 = "Not Defined";
3345                                    temp_values.bit8hfname = hf_bit8vflags;
3346                                    temp_values.bit9 = "Not Defined";
3347                                    temp_values.bit9hfname = hf_bit9vflags;
3348                                    temp_values.bit10 = "Not Defined";
3349                                    temp_values.bit10hfname = hf_bit10vflags;
3350                                    temp_values.bit11 = "Not Defined";
3351                                    temp_values.bit11hfname = hf_bit11vflags;
3352                                    temp_values.bit12 = "Not Defined";
3353                                    temp_values.bit12hfname = hf_bit12vflags;
3354                                    temp_values.bit13 = "Not Defined";
3355                                    temp_values.bit13hfname = hf_bit13vflags;
3356                                    temp_values.bit14 = "Not Defined";
3357                                    temp_values.bit14hfname = hf_bit14vflags;
3358                                    temp_values.bit15 = "Not Defined";
3359                                    temp_values.bit15hfname = hf_bit15vflags;
3360                                    temp_values.bit16 = "Not Defined";
3361                                    temp_values.bit16hfname = hf_bit16vflags;
3362                                }
3363                                process_bitfield(nvtree, tvb, &temp_values);
3364                                voffset = voffset+4;
3365                                voffset += align_4(tvb, voffset);
3366                                break;
3367                        case 0x00000013:        /* Time Stamp */
3368                                value1 = tvb_get_letohl(tvb, voffset);         /* Seconds */
3369                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3370                                         4, value1, "Length of Record: %d", value1);
3371                                voffset = voffset+4;
3372                                ns.secs = tvb_get_letohl(tvb, voffset);
3373                                ns.nsecs = 0;
3374                                proto_tree_add_time_format(nvtree, hf_nds_ds_time, tvb, voffset, 4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
3375                                voffset = voffset + 4;
3376                                rnum = tvb_get_letohs(tvb, voffset); /* replica number */
3377                                proto_tree_add_uint_format(nvtree, hf_nds_rnum, tvb, voffset,
3378                                         2, rnum, "Replica Number: %d", rnum);
3379                                voffset = voffset+2;
3380                                revent = tvb_get_letohs(tvb, voffset); /* Event */
3381                                proto_tree_add_uint_format(nvtree, hf_nds_revent, tvb, voffset,
3382                                         2, revent, "Event: %d", revent);
3383                                voffset = voffset+2;
3384                                voffset += align_4(tvb, voffset);
3385                                break;
3386                        case 0x00000017:        /* Back Link */
3387                                value1 = tvb_get_letohl(tvb, voffset);         /* Length */
3388                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3389                                         4, value1, "Length of Record %08x", value1);
3390                                voffset = voffset+4;
3391                                value2 = tvb_get_letohl(tvb, voffset);         /* Remote ID */
3392                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3393                                         4, value2, "Remote ID %08x", value2);
3394                                voffset = voffset+4;
3395                                value3 = tvb_get_letohl(tvb, voffset);         /* Length of string */
3396                                voffset = voffset+4;
3397                                get_string(tvb, voffset, value3, vvalues->vstring);
3398                                proto_tree_add_string_format(nvtree, hf_value_string, tvb, voffset,
3399                                         value3, vvalues->vstring,
3400                                         "Server Distinguished Name - %s", vvalues->vstring);
3401                                voffset = voffset+value3;
3402                                voffset += align_4(tvb, voffset);
3403                                break;
3404                        case 0x00000018:        /* Time */
3405                                voffset += 4; /* This is the length of the time data no need to decode, always 4 bytes */
3406                                ns.secs = tvb_get_letohl(tvb, voffset);
3407                                ns.nsecs = 0;
3408                                proto_tree_add_time_format(nvtree, hf_nds_ds_time, tvb, voffset, 4, &ns, "Time: %s", abs_time_to_str(&ns));
3409                                voffset = voffset + 4;
3410                                break;
3411                        case 0x00000019:        /* Typed Name */
3412                                value1 = tvb_get_letohl(tvb, voffset);         /* Length */
3413                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3414                                         4, value1, "Length of Record %08x", value1);
3415                                voffset = voffset+4;
3416                                value2 = tvb_get_letohl(tvb, voffset);         /* Level */
3417                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3418                                         4, value2, "Level %d", value2);
3419                                voffset = voffset+4;
3420                                value3 = tvb_get_letohl(tvb, voffset);         /* Interval */
3421                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3422                                         4, value3, "Interval %d", value3);
3423                                voffset = voffset+4;
3424                                value4 = tvb_get_letohl(tvb, voffset);         /* Distinguished Name */
3425                                voffset = voffset+4;
3426                                get_string(tvb, voffset, value4, vvalues->vstring);
3427                                proto_tree_add_string_format(nvtree, hf_value_string, tvb, voffset,
3428                                         value4, vvalues->vstring,
3429                                         "Distinguished Name - %s", vvalues->vstring);
3430                                voffset = voffset+value4;
3431                                voffset += align_4(tvb, voffset);
3432                                break;
3433                        case 0x0000001a:        /* Hold */
3434                                value1 = tvb_get_letohl(tvb, voffset);         /* Length */
3435                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3436                                         4, value1, "Length of Record %08x", value1);
3437                                voffset = voffset+4;
3438                                value2 = tvb_get_letohl(tvb, voffset);         /* Amount */
3439                                proto_tree_add_uint_format(nvtree, hf_nds_uint32value, tvb, voffset,
3440                                         4, value2, "Amount %d", value2);
3441                                voffset = voffset+4;
3442                                value3 = tvb_get_letohl(tvb, voffset);         /* Subject */
3443                                voffset = voffset+4;
3444                                get_string(tvb, voffset, value3, vvalues->vstring);
3445                                proto_tree_add_string_format(nvtree, hf_value_string, tvb, voffset,
3446                                         value3, vvalues->vstring,
3447                                         "Subject - %s", vvalues->vstring);
3448                                voffset = voffset+value3;
3449                                voffset += align_4(tvb, voffset);
3450                                break;
3451                        case 0x00000001:        /* Distinguished Name */
3452                        case 0x00000002:        /* Case Sensitive Unicode String */
3453                        case 0x00000003:        /* Non Case Sensitive Unicode String */
3454                        case 0x00000004:        /* Printable String */
3455                        case 0x00000005:        /* Numeric String */
3456                        case 0x0000000a:        /* Telephone Number */
3457                        case 0x0000000e:        /* Email Address */
3458                        case 0x00000014:        /* Class Name */
3459                        default:
3460                                value1 = tvb_get_letohl(tvb, voffset);
3461                                voffset = voffset + 4;
3462                                if (strcmp(vvalues->vstring, "zendmSearchOrder")==0) {
3463                                    get_string(tvb, voffset, value1, vvalues->vstring);
3464                                    if (strcmp(vvalues->vstring, "0")==0) {
3465                                        vvalues->vstring = "Value (0) = Object";
3466                                    }
3467                                    if (strcmp(vvalues->vstring, "1")==0) {
3468                                        vvalues->vstring = "Value (1) = Group";
3469                                    }
3470                                    if (strcmp(vvalues->vstring, "2")==0) {
3471                                        vvalues->vstring = "Value (2) = Container";
3472                                    }
3473                                    if (strcmp(vvalues->vstring, "01")==0) {
3474                                        vvalues->vstring = "Value (01) = Object, Group";
3475                                    }
3476                                    if (strcmp(vvalues->vstring, "02")==0) {
3477                                        vvalues->vstring = "Value (02) = Object, Container";
3478                                    }
3479                                    if (strcmp(vvalues->vstring, "10")==0) {
3480                                        vvalues->vstring = "Value (10) = Group, Object";
3481                                    }
3482                                    if (strcmp(vvalues->vstring, "12")==0) {
3483                                        vvalues->vstring = "Value (12) = Group, Container";
3484                                    }
3485                                    if (strcmp(vvalues->vstring, "20")==0) {
3486                                        vvalues->vstring = "Value (20) = Container, Object";
3487                                    }
3488                                    if (strcmp(vvalues->vstring, "21")==0) {
3489                                        vvalues->vstring = "Value (21) = Container, Group";
3490                                    }
3491                                    if (strcmp(vvalues->vstring, "012")==0) {
3492                                        vvalues->vstring = "Value (012) = Object, Group, Container";
3493                                    }
3494                                    if (strcmp(vvalues->vstring, "021")==0) {
3495                                        vvalues->vstring = "Value (021) = Object, Container, Group";
3496                                    }
3497                                    if (strcmp(vvalues->vstring, "102")==0) {
3498                                        vvalues->vstring = "Value (102) = Group, Object, Container";
3499                                    }
3500                                    if (strcmp(vvalues->vstring, "120")==0) {
3501                                        vvalues->vstring = "Value (120) = Group, Container, Object";
3502                                    }
3503                                    if (strcmp(vvalues->vstring, "201")==0) {
3504                                        vvalues->vstring = "Value (201) = Container, Object, Group";
3505                                    }
3506                                    if (strcmp(vvalues->vstring, "210")==0) {
3507                                        vvalues->vstring = "Value (210) = Container, Group, Object";
3508                                    }
3509                                }
3510                                else
3511                                {
3512                                    get_string(tvb, voffset, value1, vvalues->vstring);
3513                                }
3514                                proto_tree_add_string(nvtree, hf_value_string, tvb, voffset,
3515                                    value1, vvalues->vstring);
3516                                voffset = voffset + value1;
3517                                voffset += align_4(tvb, voffset);
3518                                break;
3519                 }
3520                 voffset += align_4(tvb, voffset);
3521         }
3522         vvalues->voffset=voffset;
3523 return;
3524 }
3525
3526 static guint32
3527 print_es_type(proto_tree *estree, tvbuff_t *tvb, nds_val *values, guint32 vtype, guint32 ioffset)
3528 {
3529         guint32         value1;
3530         guint32         value2;
3531         guint32         value3;
3532         guint32         value4;
3533         guint32         value5;
3534         guint32         number_of_referrals;
3535         guint32         r;
3536         guint32         i;
3537         guint16         replica_num;
3538         guint16         event_num;
3539         nw_uni_t        mval_buf;
3540         proto_tree      *nestree;
3541             proto_item      *nesitem;
3542         proto_tree      *sub1tree;
3543             proto_item      *sub1item;
3544         proto_tree      *sub2tree;
3545             proto_item      *sub2item;
3546         const char      *vstring="";
3547         nstime_t        ns;
3548
3549         mval_buf.buffer[0] = '\0';
3550
3551         switch (vtype)
3552         {
3553                 case 0: /* No Specifier Type */
3554                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3555                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3556                                 4, value1);
3557                         ioffset = ioffset + 4;
3558                         break;
3559                 case 1: /* Unicode String */
3560                         value1 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3561                         ioffset = ioffset + 4;
3562                         get_string(tvb, ioffset, value1, mval_buf.buffer);
3563                         values->vstring = mval_buf.buffer;
3564                         proto_tree_add_string_format(estree, hf_mv_string, tvb, ioffset,
3565                                 value1, values->vstring, "Delimeter ->%s", values->vstring);
3566                         ioffset=ioffset + value1;
3567                         ioffset += align_4(tvb, ioffset);
3568                         value2 = tvb_get_letohl(tvb, ioffset);
3569                         ioffset = ioffset + 4;
3570                         get_string(tvb, ioffset, value2, mval_buf.buffer);
3571                         values->vstring = mval_buf.buffer;
3572                         proto_tree_add_string(estree, hf_mv_string, tvb, ioffset,
3573                                 value2, values->vstring);
3574                         values->voffset=ioffset + value2;
3575                         ioffset = values->voffset;
3576                         ioffset += align_4(tvb, ioffset);
3577                         break;
3578                 case 2: /* Based */
3579                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3580                         vstring = match_strval(value1, es_type);
3581                         if (vstring == NULL)
3582                         {
3583                                 vstring = "No ES Type Found";
3584                         }
3585                         nesitem = proto_tree_add_string_format(estree, hf_es_type, tvb, ioffset,
3586                                 4, vstring, "Base Context Type - %s", vstring);
3587                         nestree = proto_item_add_subtree(nesitem, ett_nds);
3588                         ioffset = ioffset + 4;
3589                         switch (value1)
3590                         {
3591                                 case 0: /* No Specifier Type */
3592                                         value2 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3593                                         proto_tree_add_item(nestree, hf_es_value, tvb, ioffset,
3594                                                 4, value2);
3595                                         ioffset = ioffset + 4;
3596                                         break;
3597                                 case 1: /* Unicode String */
3598                                         value2 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3599                                         ioffset = ioffset + 4;
3600                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
3601                                         values->vstring = mval_buf.buffer;
3602                                         proto_tree_add_string_format(nestree, hf_mv_string, tvb, ioffset,
3603                                                 value2, values->vstring, "Delimeter ->%s", values->vstring);
3604                                         ioffset=ioffset + value2;
3605                                         ioffset += align_4(tvb, ioffset);
3606                                         value3 = tvb_get_letohl(tvb, ioffset);
3607                                         ioffset = ioffset + 4;
3608                                         get_string(tvb, ioffset, value3, mval_buf.buffer);
3609                                         values->vstring = mval_buf.buffer;
3610                                         proto_tree_add_string(nestree, hf_mv_string, tvb, ioffset,
3611                                                 value3, values->vstring);
3612                                         values->voffset=ioffset + value3;
3613                                         ioffset = values->voffset;
3614                                         ioffset += align_4(tvb, ioffset);
3615                                         break;
3616                                 case 2: /* Based */
3617                                         break;
3618                                 case 3: /* Hinted */
3619                                         break;
3620                                 case 4: /* Tuned */
3621                                         value2 = tvb_get_letohl(tvb, ioffset);   /* Count */
3622                                         proto_tree_add_item(nestree, hf_es_rdn_count, tvb, ioffset,
3623                                                 4, value2);
3624                                         ioffset = ioffset + 4;
3625                                         for (r = 1 ; r <= value2; r++ )
3626                                         {
3627                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
3628                                                 ns.nsecs = 0;
3629                                                 proto_tree_add_time_format(nestree, hf_es_seconds, tvb, ioffset,
3630                                                         4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
3631                                                 ioffset = ioffset + 4;
3632                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
3633                                                 proto_tree_add_item(nestree, hf_nds_replica_num, tvb, ioffset,
3634                                                         2, replica_num);
3635                                                 ioffset = ioffset + 2;
3636                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
3637                                                 proto_tree_add_item(nestree, hf_nds_event_num, tvb, ioffset,
3638                                                         2, event_num);
3639                                                 ioffset = ioffset + 2;
3640                                         }
3641                                         value4 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3642                                         ioffset = ioffset + 4;
3643                                         get_string(tvb, ioffset, value4, mval_buf.buffer);
3644                                         values->vstring = mval_buf.buffer;
3645                                         proto_tree_add_string(nestree, hf_mv_string, tvb, ioffset,
3646                                                 value4, values->vstring);
3647                                         ioffset=ioffset + value4;
3648                                         ioffset += align_4(tvb, ioffset);
3649                                         value5 = tvb_get_letohl(tvb, ioffset);   /* RDN */
3650                                         ioffset = ioffset + 4;
3651                                         get_string(tvb, ioffset, value5, mval_buf.buffer);
3652                                         values->vstring = mval_buf.buffer;
3653                                         proto_tree_add_string(nestree, hf_rdn_string, tvb, ioffset,
3654                                                 value5, values->vstring);
3655                                         ioffset=ioffset + value5;
3656                                         ioffset += align_4(tvb, ioffset);
3657                                         break;
3658                                 case 5: /* GUID */
3659                                 case 6: /* ID32 */
3660                                 case 7: /* Count */
3661                                 default:
3662                                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3663                                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3664                                                 4, value1);
3665                                         ioffset = ioffset + 4;
3666                                         break;
3667                          }
3668                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3669                         vstring = match_strval(value1, es_type);
3670                         if (vstring == NULL)
3671                         {
3672                                 vstring = "No ES Type Found";
3673                         }
3674                         nesitem = proto_tree_add_string_format(estree, hf_es_type, tvb, ioffset,
3675                                 4, vstring, "Object Name Type - %s", vstring);
3676                         nestree = proto_item_add_subtree(nesitem, ett_nds);
3677                         ioffset = ioffset + 4;
3678                         switch (value1)
3679                         {
3680                                 case 0: /* No Specifier Type */
3681                                         value2 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3682                                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3683                                                 4, value2);
3684                                         ioffset = ioffset + 4;
3685                                         break;
3686                                 case 1: /* Unicode String */
3687                                         value2 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3688                                         ioffset = ioffset + 4;
3689                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
3690                                         values->vstring = mval_buf.buffer;
3691                                         proto_tree_add_string_format(estree, hf_mv_string, tvb, ioffset,
3692                                                 value2, values->vstring, "Delimeter ->%s", values->vstring);
3693                                         ioffset=ioffset + value2;
3694                                         ioffset += align_4(tvb, ioffset);
3695                                         value3 = tvb_get_letohl(tvb, ioffset);
3696                                         ioffset = ioffset + 4;
3697                                         get_string(tvb, ioffset, value3, mval_buf.buffer);
3698                                         values->vstring = mval_buf.buffer;
3699                                         proto_tree_add_string(estree, hf_mv_string, tvb, ioffset,
3700                                                 value3, values->vstring);
3701                                         values->voffset=ioffset + value3;
3702                                         ioffset = values->voffset;
3703                                         ioffset += align_4(tvb, ioffset);
3704                                         break;
3705                                 case 2: /* Based */
3706                                         break;
3707                                 case 3: /* Hinted */
3708                                         break;
3709                                 case 4: /* Tuned */
3710                                         value2 = tvb_get_letohl(tvb, ioffset);   /* Count */
3711                                         proto_tree_add_item(estree, hf_es_rdn_count, tvb, ioffset,
3712                                                 4, value2);
3713                                         ioffset = ioffset + 4;
3714                                         for (r = 1 ; r <= value2; r++ )
3715                                         {
3716                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
3717                                                 ns.nsecs = 0;
3718                                                 proto_tree_add_time_format(estree, hf_es_seconds, tvb, ioffset,
3719                                                         4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
3720                                                 ioffset = ioffset + 4;
3721                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
3722                                                 proto_tree_add_item(estree, hf_nds_replica_num, tvb, ioffset,
3723                                                         2, replica_num);
3724                                                 ioffset = ioffset + 2;
3725                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
3726                                                 proto_tree_add_item(estree, hf_nds_event_num, tvb, ioffset,
3727                                                         2, event_num);
3728                                                 ioffset = ioffset + 2;
3729                                         }
3730                                         value4 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3731                                         ioffset = ioffset + 4;
3732                                         get_string(tvb, ioffset, value4, mval_buf.buffer);
3733                                         values->vstring = mval_buf.buffer;
3734                                         proto_tree_add_string(estree, hf_mv_string, tvb, ioffset,
3735                                                 value4, values->vstring);
3736                                         ioffset=ioffset + value4;
3737                                         ioffset += align_4(tvb, ioffset);
3738                                         value5 = tvb_get_letohl(tvb, ioffset);   /* RDN */
3739                                         ioffset = ioffset + 4;
3740                                         get_string(tvb, ioffset, value5, mval_buf.buffer);
3741                                         values->vstring = mval_buf.buffer;
3742                                         proto_tree_add_string(estree, hf_rdn_string, tvb, ioffset,
3743                                                 value5, values->vstring);
3744                                         ioffset=ioffset + value5;
3745                                         ioffset += align_4(tvb, ioffset);
3746                                         break;
3747                                 case 5: /* GUID */
3748                                 case 6: /* ID32 */
3749                                 case 7: /* Count */
3750                                 default:
3751                                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3752                                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3753                                                 4, value1);
3754                                         ioffset = ioffset + 4;
3755                                         break;
3756                          }
3757                         break;
3758                 case 3: /* Hinted */
3759                         number_of_referrals = tvb_get_letohl(tvb, ioffset);
3760
3761                         for (r = 1 ; r <= number_of_referrals; r++ )
3762                         {
3763                                 sub1item = proto_tree_add_uint_format(estree, hf_referral_record, tvb, 6, 0,
3764                                 r, "NDS Referral Record #%u", r);
3765                                 sub1tree = proto_item_add_subtree(sub1item, ett_nds);
3766
3767                                 value1 = tvb_get_letohl(tvb, ioffset);
3768
3769                                 proto_tree_add_uint_format(sub1tree, hf_referral_addcount, tvb, ioffset, 4,
3770                                         value1, "Number of Addresses in Referral - %d", value1);
3771
3772                                 ioffset = ioffset + 4;
3773                                 for (i = 1 ; i <= value1; i++ )
3774                                 {
3775                                         value2 = tvb_get_letohl(tvb, ioffset);
3776                                         values->vstring =(char *)match_strval(value2, nds_protocol_type);
3777                                         if (values->vstring == NULL)
3778                                         {
3779                                                values->vstring="(Undefined Protocol)";
3780                                         }
3781                                         proto_tree_add_uint_format(sub1tree, hf_nds_uint32value, tvb, ioffset,
3782                                         4, value2, vstring, value2);
3783                                         ioffset = ioffset+4;
3784                                         value3 = tvb_get_letohl(tvb, ioffset);
3785                                         ioffset = ioffset+4;
3786                                         switch (value2)
3787                                         {
3788                                                 case NDS_PTYPE_IPX:
3789                                                         proto_tree_add_item(sub1tree, hf_nds_net, tvb, ioffset, 4, FALSE);
3790                                                         proto_tree_add_item(sub1tree, hf_nds_node, tvb, ioffset+4, 6, FALSE);
3791                                                         proto_tree_add_item(sub1tree, hf_nds_socket, tvb, ioffset+10, 2, FALSE);
3792                                                         break;
3793                                                 case NDS_PTYPE_IP:
3794                                                         proto_tree_add_item(sub1tree, hf_nds_port, tvb, ioffset, 2, FALSE);
3795                                                         proto_tree_add_item(sub1tree, hf_add_ref_ip, tvb, ioffset+2, 4, FALSE);
3796                                                         break;
3797                                                 case NDS_PTYPE_UDP:
3798                                                         proto_tree_add_item(sub1tree, hf_nds_port, tvb, ioffset, 2, FALSE);
3799                                                         proto_tree_add_item(sub1tree, hf_add_ref_udp, tvb, ioffset+2, 4, FALSE);
3800                                                         break;
3801                                                 case NDS_PTYPE_TCP:
3802                                                         proto_tree_add_item(sub1tree, hf_nds_port, tvb, ioffset, 2, FALSE);
3803                                                         proto_tree_add_item(sub1tree, hf_add_ref_tcp, tvb, ioffset+2, 4, FALSE);
3804                                                         break;
3805                                                 case NDS_PTYPE_URL:
3806                                                 case NDS_PTYPE_DNS:
3807                                                         get_string(tvb, ioffset, value3, values->vstring);
3808                                                         proto_tree_add_string(sub1tree, hf_value_string, tvb, ioffset,
3809                                                                 value3, values->vstring);
3810                                                         break;
3811                                                 default:
3812                                                         break;
3813                                         }
3814                                         ioffset = ioffset + value3;
3815                                         ioffset += align_4(tvb, ioffset);
3816                                 }
3817
3818                         }
3819                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3820                         vstring = match_strval(value1, es_type);
3821                         if (vstring == NULL)
3822                         {
3823                                 vstring = "No ES Type Found";
3824                         }
3825                         nesitem = proto_tree_add_string_format(estree, hf_es_type, tvb, ioffset,
3826                                 4, vstring, "Object Name Type - %s", vstring);
3827                         nestree = proto_item_add_subtree(nesitem, ett_nds);
3828                         ioffset = ioffset + 4;
3829                         switch (value1)
3830                         {
3831                                 case 0: /* No Specifier Type */
3832                                         value2 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3833                                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3834                                                 4, value2);
3835                                         ioffset = ioffset + 4;
3836                                         break;
3837                                 case 1: /* Unicode String */
3838                                         value2 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3839                                         ioffset = ioffset + 4;
3840                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
3841                                         values->vstring = mval_buf.buffer;
3842                                         proto_tree_add_string_format(estree, hf_mv_string, tvb, ioffset,
3843                                                 value2, values->vstring, "Delimeter ->%s", values->vstring);
3844                                         ioffset=ioffset + value2;
3845                                         ioffset += align_4(tvb, ioffset);
3846                                         value3 = tvb_get_letohl(tvb, ioffset);
3847                                         ioffset = ioffset + 4;
3848                                         get_string(tvb, ioffset, value3, mval_buf.buffer);
3849                                         values->vstring = mval_buf.buffer;
3850                                         proto_tree_add_string(estree, hf_mv_string, tvb, ioffset,
3851                                                 value3, values->vstring);
3852                                         values->voffset=ioffset + value3;
3853                                         ioffset = values->voffset;
3854                                         ioffset += align_4(tvb, ioffset);
3855                                         break;
3856                                 case 2: /* Based */
3857                                         break;
3858                                 case 3: /* Hinted */
3859                                         break;
3860                                 case 4: /* Tuned */
3861                                         value2 = tvb_get_letohl(tvb, ioffset);   /* Count */
3862                                         proto_tree_add_item(estree, hf_es_rdn_count, tvb, ioffset,
3863                                                 4, value2);
3864                                         ioffset = ioffset + 4;
3865                                         for (r = 1 ; r <= value2; r++ )
3866                                         {
3867                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
3868                                                 ns.nsecs = 0;
3869                                                 proto_tree_add_time_format(estree, hf_es_seconds, tvb, ioffset,
3870                                                         4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
3871                                                 ioffset = ioffset + 4;
3872                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
3873                                                 proto_tree_add_item(estree, hf_nds_replica_num, tvb, ioffset,
3874                                                         2, replica_num);
3875                                                 ioffset = ioffset + 2;
3876                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
3877                                                 proto_tree_add_item(estree, hf_nds_event_num, tvb, ioffset,
3878                                                         2, event_num);
3879                                                 ioffset = ioffset + 2;
3880                                         }
3881                                         value4 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3882                                         ioffset = ioffset + 4;
3883                                         get_string(tvb, ioffset, value4, mval_buf.buffer);
3884                                         values->vstring = mval_buf.buffer;
3885                                         proto_tree_add_string(estree, hf_mv_string, tvb, ioffset,
3886                                                 value4, values->vstring);
3887                                         ioffset=ioffset + value4;
3888                                         ioffset += align_4(tvb, ioffset);
3889                                         value5 = tvb_get_letohl(tvb, ioffset);   /* RDN */
3890                                         ioffset = ioffset + 4;
3891                                         get_string(tvb, ioffset, value5, mval_buf.buffer);
3892                                         values->vstring = mval_buf.buffer;
3893                                         proto_tree_add_string(estree, hf_rdn_string, tvb, ioffset,
3894                                                 value5, values->vstring);
3895                                         ioffset=ioffset + value5;
3896                                         ioffset += align_4(tvb, ioffset);
3897                                         break;
3898                                 case 5: /* GUID */
3899                                 case 6: /* ID32 */
3900                                 case 7: /* Count */
3901                                 default:
3902                                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3903                                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3904                                                 4, value1);
3905                                         ioffset = ioffset + 4;
3906                                         break;
3907                          }
3908                         break;
3909                 case 4: /* Tuned */
3910                         value1 = tvb_get_letohl(tvb, ioffset);
3911                         sub1item = proto_tree_add_uint_format(estree, hf_es_rdn_count, tvb, ioffset,
3912                                 4, value1, "Number of RDN Items %d", value1);
3913                         sub1tree = proto_item_add_subtree(sub1item, ett_nds);
3914                         ioffset = ioffset + 4;
3915                         for (r = 1 ; r <= value1; r++ )
3916                         {
3917                                 sub2item = proto_tree_add_text(sub1tree, tvb, ioffset, 0, "Item %d", r);
3918                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
3919
3920                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
3921                                 ns.nsecs = 0;
3922                                 proto_tree_add_time_format(sub2tree, hf_es_seconds, tvb, ioffset,
3923                                         4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
3924                                 ioffset = ioffset + 4;
3925                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
3926                                 proto_tree_add_item(sub2tree, hf_nds_replica_num, tvb, ioffset,
3927                                         2, replica_num);
3928                                 ioffset = ioffset + 2;
3929                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
3930                                 proto_tree_add_item(sub2tree, hf_nds_event_num, tvb, ioffset,
3931                                         2, event_num);
3932                                 ioffset = ioffset + 2;
3933                         }
3934                         value3 = tvb_get_letohl(tvb, ioffset);   /* Delimeter Set */
3935                         ioffset = ioffset + 4;
3936                         get_string(tvb, ioffset, value3, mval_buf.buffer);
3937                         values->vstring = mval_buf.buffer;
3938                         proto_tree_add_string(sub1tree, hf_mv_string, tvb, ioffset,
3939                                 value3, values->vstring);
3940                         ioffset=ioffset + value3;
3941                         ioffset += align_4(tvb, ioffset);
3942                         value4 = tvb_get_letohl(tvb, ioffset);   /* RDN */
3943                         ioffset = ioffset + 4;
3944                         get_string(tvb, ioffset, value4, mval_buf.buffer);
3945                         values->vstring = mval_buf.buffer;
3946                         proto_tree_add_string(sub1tree, hf_rdn_string, tvb, ioffset,
3947                                 value4, values->vstring);
3948                         ioffset=ioffset + value4;
3949                         ioffset += align_4(tvb, ioffset);
3950                         break;
3951                 case 5: /* GUID */
3952                 case 6: /* ID32 */
3953                 case 7: /* Count */
3954                 default:
3955                         value1 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
3956                         proto_tree_add_item(estree, hf_es_value, tvb, ioffset,
3957                                 4, value1);
3958                         ioffset = ioffset + 4;
3959                         break;
3960          }
3961         return ioffset;
3962 }
3963
3964
3965 static void process_set_filter(proto_tree* , tvbuff_t*, packet_info*, nds_val*);
3966
3967 static void
3968 process_search_expression(proto_tree *it_tree, tvbuff_t *tvb, nds_val *values)
3969 {
3970     guint32     search_tag, ioffset;
3971     char        *search_string;
3972
3973     ioffset = values->voffset;
3974     search_tag = tvb_get_letohl(tvb, ioffset); /* Get next search operation tag */
3975     search_string = (char *)match_strval(search_tag, itersearchenum);
3976     if(search_string == NULL)
3977     {
3978         search_string = "(No Search Operation Type Found!)";
3979     }
3980     proto_tree_add_uint_format(it_tree, hf_iter_search, tvb, ioffset, 4,
3981         search_tag, "Search Operation Type: %d, (0x%04x), %s",
3982         search_tag, search_tag, search_string);
3983     ioffset += 4;
3984     switch (search_tag)
3985     {
3986     case NDS_SEARCH_EQUAL:
3987     case NDS_SEARCH_GREATER_OR_EQUAL:
3988     case NDS_SEARCH_LESS_OR_EQUAL:
3989     case NDS_SEARCH_APPROX:
3990     case NDS_SEARCH_ATTR_FLAGS:
3991     case NDS_SEARCH_ATTR_HAS_FLAG:
3992         /* start of DCWPutAttribute */
3993         values->vvalue = tvb_get_letohl(tvb, ioffset);
3994         ioffset = ioffset + 4;
3995         get_string(tvb, ioffset, values->vvalue, values->vstring);
3996         proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
3997                 values->vvalue, values->vstring);
3998         ioffset += values->vvalue;
3999         /* end of DCWPutAttribute */
4000
4001         ioffset += align_4(tvb, ioffset);
4002
4003         /* start of DCWPutValue */
4004         values->vvalue = tvb_get_letohl(tvb, ioffset);
4005         values->vstring = (char *)match_strval(values->vvalue, nds_syntax);
4006         if (values->vstring == NULL)
4007         {
4008                 values->vstring = "No Syntax Found";
4009         }
4010         proto_tree_add_string(it_tree, hf_nds_syntax, tvb, ioffset,
4011         4, values->vstring);
4012         ioffset = ioffset + 4;
4013         values->vvalue = tvb_get_letohl(tvb, ioffset);
4014         ioffset = ioffset + 4;
4015         get_string(tvb, ioffset, values->vvalue, values->vstring);
4016         proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4017                 values->vvalue, values->vstring);
4018         ioffset += values->vvalue;
4019         /* end of DCWPutValue */
4020
4021         break;
4022     case NDS_SEARCH_PRESENT:
4023             /* start of DCWPutAttribute */
4024             values->vvalue = tvb_get_letohl(tvb, ioffset);
4025             ioffset = ioffset + 4;
4026             get_string(tvb, ioffset, values->vvalue, values->vstring);
4027             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4028                     values->vvalue, values->vstring);
4029             ioffset = ioffset + values->vvalue;
4030             /* end of DCWPutAttribute */
4031             break;
4032
4033     case NDS_SEARCH_RDN:
4034             /* print the relative distinguished name. This includes context info... */
4035             /*if (err = DCWPutRDN(context, cur, limit, item->data))
4036                 return err;*/
4037
4038             values->vvalue = tvb_get_letohl(tvb, ioffset);
4039             ioffset = ioffset + 4;
4040             get_string(tvb, ioffset, values->vvalue, values->vstring);
4041             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4042                     values->vvalue, values->vstring);
4043             ioffset += values->vvalue;
4044             break;
4045     case NDS_SEARCH_BASE_CLASS:
4046     case NDS_SEARCH_ENTRY_FLAGS:
4047     case NDS_SEARCH_ENTRY_HAS_FLAG:
4048     case NDS_SEARCH_VALUE_FLAGS:
4049     case NDS_SEARCH_VALUE_HAS_FLAG:
4050         /* start of DCWPutValue */
4051         /*values->vvalue = tvb_get_letohl(tvb, ioffset);
4052         values->vstring = (char *)match_strval(values->vvalue, nds_syntax);
4053         if (values->vstring == NULL)
4054         {
4055                 values->vstring = "No Syntax Found";
4056         }
4057         proto_tree_add_string(it_tree, hf_nds_syntax, tvb, ioffset,
4058         4, values->vstring);
4059         ioffset = ioffset + 4;*/
4060         values->vvalue = tvb_get_letohl(tvb, ioffset);
4061         ioffset = ioffset + 4;
4062         get_string(tvb, ioffset, values->vvalue, values->vstring);
4063         proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4064                 values->vvalue, values->vstring);
4065         ioffset += values->vvalue;
4066         /* end of DCWPutValue */
4067         break;
4068     case DCS_VALUE_GE_WITH_ATTR:        /* Deprecated, use DS_SEARCH_VALUE_MTS_GE */
4069     case NDS_SEARCH_VALUE_MTS_GE:
4070     case NDS_SEARCH_VALUE_MTS_G:
4071     case NDS_SEARCH_VALUE_MTS_LE:
4072     case NDS_SEARCH_VALUE_MTS_L:
4073     case NDS_SEARCH_VALUE_MTS_EQ:
4074     case NDS_SEARCH_VALUE_MTS_EQ_APPROX:
4075     case NDS_SEARCH_VALUE_CTS_GE:
4076     case NDS_SEARCH_VALUE_CTS_G:
4077     case NDS_SEARCH_VALUE_CTS_LE:
4078     case NDS_SEARCH_VALUE_CTS_L:
4079     case NDS_SEARCH_VALUE_CTS_EQ:
4080     case NDS_SEARCH_VALUE_CTS_EQ_APPROX:
4081             /* start of DCWPutAttribute */
4082             values->vvalue = tvb_get_letohl(tvb, ioffset);
4083             ioffset = ioffset + 4;
4084             get_string(tvb, ioffset, values->vvalue, values->vstring);
4085             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4086                     values->vvalue, values->vstring);
4087             ioffset += values->vvalue;
4088             /* end of DCWPutAttribute */
4089
4090             ioffset += align_4(tvb, ioffset);
4091
4092             /* start of DCWPutValue */
4093             values->vvalue = tvb_get_letohl(tvb, ioffset);
4094             values->vstring = (char *)match_strval(values->vvalue, nds_syntax);
4095             if (values->vstring == NULL)
4096             {
4097                     values->vstring = "No Syntax Found";
4098             }
4099             proto_tree_add_string(it_tree, hf_nds_syntax, tvb, ioffset,
4100             4, values->vstring);
4101             ioffset = ioffset + 4;
4102             values->vvalue = tvb_get_letohl(tvb, ioffset);
4103             ioffset = ioffset + 4;
4104             get_string(tvb, ioffset, values->vvalue, values->vstring);
4105             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4106                     values->vvalue, values->vstring);
4107             ioffset += values->vvalue;
4108             /* end of DCWPutValue */
4109             break;
4110     case DCS_MOD_GE_WITH_ATTR:        /* Deprecated, use DS_SEARCH_ENTRY_MTS */
4111     case NDS_SEARCH_ENTRY_MTS_GE:
4112     case NDS_SEARCH_ENTRY_MTS_G:
4113     case NDS_SEARCH_ENTRY_MTS_LE:
4114     case NDS_SEARCH_ENTRY_MTS_L:
4115     case NDS_SEARCH_ENTRY_MTS_EQ:
4116     case NDS_SEARCH_ENTRY_MTS_EQ_APPROX:
4117     case NDS_SEARCH_ENTRY_CTS_GE:
4118     case NDS_SEARCH_ENTRY_CTS_G:
4119     case NDS_SEARCH_ENTRY_CTS_LE:
4120     case NDS_SEARCH_ENTRY_CTS_L:
4121     case NDS_SEARCH_ENTRY_CTS_EQ:
4122     case NDS_SEARCH_ENTRY_CTS_EQ_APPROX:
4123             /* start of DCWPutAttribute */
4124             values->vvalue = tvb_get_letohl(tvb, ioffset);
4125             ioffset = ioffset + 4;
4126             get_string(tvb, ioffset, values->vvalue, values->vstring);
4127             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4128                     values->vvalue, values->vstring);
4129             ioffset += values->vvalue;
4130             /* end of DCWPutAttribute */
4131
4132             ioffset += align_4(tvb, ioffset);
4133
4134             /* start of DCWPutValue */
4135             values->vvalue = tvb_get_letohl(tvb, ioffset);
4136             values->vstring = (char *)match_strval(values->vvalue, nds_syntax);
4137             if (values->vstring == NULL)
4138             {
4139                     values->vstring = "No Syntax Found";
4140             }
4141             proto_tree_add_string(it_tree, hf_nds_syntax, tvb, ioffset,
4142             4, values->vstring);
4143             ioffset = ioffset + 4;
4144             values->vvalue = tvb_get_letohl(tvb, ioffset);
4145             ioffset = ioffset + 4;
4146             get_string(tvb, ioffset, values->vvalue, values->vstring);
4147             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4148                     values->vvalue, values->vstring);
4149             ioffset += values->vvalue;
4150             /* end of DCWPutValue */
4151
4152             break;
4153     case NDS_SEARCH_EID:
4154     case NDS_SEARCH_ENTRY_SUBCOUNT_GE:
4155     case NDS_SEARCH_ENTRY_SUBCOUNT_G:
4156     case NDS_SEARCH_ENTRY_SUBCOUNT_LE:
4157     case NDS_SEARCH_ENTRY_SUBCOUNT_L:
4158     case NDS_SEARCH_ENTRY_SUBCOUNT_EQ:
4159             /* start of DCWPutValue */
4160             values->vvalue = tvb_get_letohl(tvb, ioffset);
4161             values->vstring = (char *)match_strval(values->vvalue, nds_syntax);
4162             if (values->vstring == NULL)
4163             {
4164                     values->vstring = "No Syntax Found";
4165             }
4166             proto_tree_add_string(it_tree, hf_nds_syntax, tvb, ioffset,
4167             4, values->vstring);
4168             ioffset = ioffset + 4;
4169             values->vvalue = tvb_get_letohl(tvb, ioffset);
4170             ioffset = ioffset + 4;
4171             get_string(tvb, ioffset, values->vvalue, values->vstring);
4172             proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4173                     values->vvalue, values->vstring);
4174             ioffset += values->vvalue;
4175             /* end of DCWPutValue */
4176
4177             break;
4178
4179     default: /* Unknown Iteration search Item type */
4180         if (tvb_length_remaining(tvb, ioffset) < 4) {
4181             THROW(ReportedBoundsError);
4182         }
4183         break;
4184     }
4185     ioffset += align_4(tvb, ioffset);
4186     values->voffset = ioffset;
4187     return;
4188 }
4189
4190 static void
4191 process_search_subexpression(proto_tree *it_tree, tvbuff_t *tvb, packet_info *pinfo, nds_val *values)
4192 {
4193     proto_tree  *it_subtree, *it_subtree1;
4194     proto_item  *it_subitem, *it_subitem1;
4195     guint32     i, ioffset, number_of_items;
4196
4197     ioffset = values->voffset;
4198     if (values->vvalue != NDS_SEARCH_NOT) {
4199         number_of_items = tvb_get_letohl(tvb, ioffset);
4200         it_subitem = proto_tree_add_item(it_tree, hf_this_count, tvb, ioffset, 4, TRUE);
4201         it_subtree = proto_item_add_subtree(it_subitem, ett_nds);
4202         ioffset += 4;
4203         for (i = 0; i < number_of_items; i++)
4204         {
4205             it_subitem1 = proto_tree_add_text(it_subtree, tvb, ioffset, -1, "Item #: %d", i+1);
4206             it_subtree1 = proto_item_add_subtree(it_subitem1, ett_nds);
4207
4208             values->voffset = ioffset;
4209             process_set_filter(it_subtree1, tvb, pinfo, values);
4210             ioffset = values->voffset;
4211
4212             if (tvb_length_remaining(tvb, ioffset) < 4) {
4213                 THROW(ReportedBoundsError);
4214                 break;
4215             }
4216
4217         }
4218     }
4219     values->voffset = ioffset;
4220     return;
4221 }
4222
4223 static void
4224 process_search_match(proto_tree *it_tree, tvbuff_t *tvb, nds_val *values)
4225 {
4226     guint32     ioffset;
4227
4228     ioffset = values->voffset;
4229
4230     values->vvalue = tvb_get_letohl(tvb, ioffset);
4231     ioffset += 4;
4232     proto_tree_add_item(it_tree, hf_nds_oid, tvb, ioffset, values->vvalue, TRUE);
4233     ioffset += values->vvalue;
4234
4235     ioffset += align_4(tvb, ioffset);
4236
4237     proto_tree_add_item(it_tree, hf_iter_ans, tvb, ioffset, 4, TRUE);
4238     ioffset += 4;
4239
4240     ioffset += align_4(tvb, ioffset);
4241
4242     /* start of DCWPutAttribute */
4243     values->vvalue = tvb_get_letohl(tvb, ioffset);
4244     ioffset = ioffset + 4;
4245     get_string(tvb, ioffset, values->vvalue, values->vstring);
4246     proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4247             values->vvalue, values->vstring);
4248     ioffset = ioffset + values->vvalue;
4249     /* end of DCWPutAttribute */
4250
4251     ioffset += align_4(tvb, ioffset);
4252
4253     /* start of DCWPutValue */
4254     values->vvalue = tvb_get_letohl(tvb, ioffset);
4255     values->vstring = (char *)match_strval(values->vvalue, nds_syntax);
4256     if (values->vstring == NULL)
4257     {
4258             values->vstring = "No Syntax Found";
4259     }
4260     proto_tree_add_string(it_tree, hf_nds_syntax, tvb, ioffset,
4261     4, values->vstring);
4262     ioffset = ioffset + 4;
4263     values->vvalue = tvb_get_letohl(tvb, ioffset);
4264     ioffset = ioffset + 4;
4265     get_string(tvb, ioffset, values->vvalue, values->vstring);
4266     proto_tree_add_string(it_tree, hf_mv_string, tvb, ioffset,
4267             values->vvalue, values->vstring);
4268     ioffset += values->vvalue;
4269     /* end of DCWPutValue */
4270
4271     ioffset += align_4(tvb, ioffset);
4272
4273     values->voffset = ioffset;
4274     return;
4275 }
4276
4277 static void
4278 process_set_filter(proto_tree *it_tree, tvbuff_t *tvb, packet_info *pinfo, nds_val *values)
4279 {
4280     guint32     search_tag, ioffset = values->voffset;
4281     char        *search_string;
4282
4283     search_tag = tvb_get_letohl(tvb, ioffset);
4284     search_string = (char *)match_strval(search_tag, itersearchenum);
4285     if(search_string == NULL)
4286     {
4287         search_string = "(No Search Tag Found)";
4288     }
4289     proto_tree_add_uint_format(it_tree, hf_iter_search, tvb, ioffset, 4,
4290         search_tag, "Type of Search: Tag = %d, (0x%04x), %s",
4291         search_tag, search_tag, search_string);
4292     ioffset += 4;
4293     values->voffset = ioffset;
4294
4295     switch (search_tag)
4296     {
4297     case NDS_SEARCH_ITEM:
4298         /* DCWPutSearchExp */
4299             process_search_expression(it_tree, tvb, values);
4300             break;
4301
4302     case NDS_SEARCH_EXTENSIBLE:
4303             /*err = DCWPutSearchExtMatch(context, syncFormat, cur, limit, sexp->u.extMatch);*/
4304             process_search_match(it_tree, tvb, values);
4305             break;
4306
4307     case NDS_SEARCH_OR:
4308     case NDS_SEARCH_AND:
4309     case NDS_SEARCH_NOT:
4310             /* DCWPutSearchSubExp = process_search_subexpression */
4311             process_search_subexpression(it_tree, tvb, pinfo, values);
4312             break;
4313     default: /* Unknown Iteration search type */
4314             if (tvb_length_remaining(tvb, ioffset) < 4) {
4315                 THROW(ReportedBoundsError);
4316             }
4317             break;
4318     }
4319     ioffset = values->voffset;
4320     return;
4321 }
4322
4323 static void
4324 process_entry_info(proto_tree *it_tree, tvbuff_t *tvb, nds_val *values)
4325 {
4326     guint32     iter_flags, ioffset = values->voffset;
4327     guint16     replica_num, event_num;
4328     char        temp_string[256];
4329     nstime_t    ns;
4330
4331     values->vstring = temp_string;
4332     ioffset += align_4(tvb, ioffset);
4333     iter_flags = tvb_get_letohl(tvb, ioffset);
4334
4335
4336     if (iter_flags & DSI_OUTPUT_FIELDS) { /* Output Flags */
4337         values->vvalue = tvb_get_letohs(tvb, ioffset);
4338         values->vdesc = "Return Information Flags (low) Byte:";
4339         values->vlength = 2;
4340         values->hfname = hf_nds_rflags;
4341         values->voffset = ioffset;
4342         values->bit1 = "Output Flags";
4343         values->bit1hfname = hf_bit1infoflagsl;
4344         values->bit2 = "Entry ID";
4345         values->bit2hfname = hf_bit2infoflagsl;
4346         values->bit3 = "Entry Flags";
4347         values->bit3hfname = hf_bit3infoflagsl;
4348         values->bit4 = "Subordinate Count";
4349         values->bit4hfname = hf_bit4infoflagsl;
4350         values->bit5 = "Modification Time";
4351         values->bit5hfname = hf_bit5infoflagsl;
4352         values->bit6 = "Modification Timestamp";
4353         values->bit6hfname = hf_bit6infoflagsl;
4354         values->bit7 = "Creation Timestamp";
4355         values->bit7hfname = hf_bit7infoflagsl;
4356         values->bit8 = "Partition Root ID";
4357         values->bit8hfname = hf_bit8infoflagsl;
4358         values->bit9 = "Parent ID";
4359         values->bit9hfname = hf_bit9infoflagsl;
4360         values->bit10 = "Revision Count";
4361         values->bit10hfname = hf_bit10infoflagsl;
4362         values->bit11 = "Replica Type";
4363         values->bit11hfname = hf_bit11infoflagsl;
4364         values->bit12 = "Base Class";
4365         values->bit12hfname = hf_bit12infoflagsl;
4366         values->bit13 = "Relative Distinguished Name";
4367         values->bit13hfname = hf_bit13infoflagsl;
4368         values->bit14 = "Distinguished Name";
4369         values->bit14hfname = hf_bit14infoflagsl;
4370         values->bit15 = "Root Distinguished Name";
4371         values->bit15hfname = hf_bit15infoflagsl;
4372         values->bit16 = "Parent Distinguished Name";
4373         values->bit16hfname = hf_bit16infoflagsl;
4374         process_bitfield(it_tree, tvb, values);
4375         ioffset = ioffset+2;
4376
4377         values->vvalue = tvb_get_letohs(tvb, ioffset);
4378         values->vtype = VTYPE_BITFIELD;
4379         values->vdesc = "Return Information Flags (high) Byte:";
4380         values->vlength = 2;
4381         values->hfname= hf_nds_rflags;
4382         values->voffset = ioffset;
4383         values->bit1 = "Purge Time";
4384         values->bit1hfname = hf_bit1infoflagsh;
4385         values->bit2 = "Dereference Base Class";
4386         values->bit2hfname = hf_bit2infoflagsh;
4387         values->bit3 = "Replica Number";
4388         values->bit3hfname = hf_bit3infoflagsh;
4389         values->bit4 = "Replica State";
4390         values->bit4hfname = hf_bit4infoflagsh;
4391         values->bit5 = "Federation Boundary";
4392         values->bit5hfname = hf_bit5infoflagsh;
4393         values->bit6 = "Schema Boundary";
4394         values->bit6hfname = hf_bit6infoflagsh;
4395         values->bit7 = "Federation Boundary ID";
4396         values->bit7hfname = hf_bit7infoflagsh;
4397         values->bit8 = "Schema Boundary ID";
4398         values->bit8hfname = hf_bit8infoflagsh;
4399         values->bit9 = "Current Subcount";
4400         values->bit9hfname = hf_bit9infoflagsh;
4401         values->bit10 = "Local Entry Flags";
4402         values->bit10hfname = hf_bit10infoflagsh;
4403         values->bit11 = "Not Defined";
4404         values->bit11hfname = hf_bit11infoflagsh;
4405         values->bit12 = "Not Defined";
4406         values->bit12hfname = hf_bit12infoflagsh;
4407         values->bit13 = "Not Defined";
4408         values->bit13hfname = hf_bit13infoflagsh;
4409         values->bit14 = "Not Defined";
4410         values->bit14hfname = hf_bit14infoflagsh;
4411         values->bit15 = "Not Defined";
4412         values->bit15hfname = hf_bit15infoflagsh;
4413         values->bit16 = "Not Defined";
4414         values->bit16hfname = hf_bit16infoflagsh;
4415         process_bitfield(it_tree, tvb, values);
4416         ioffset = ioffset+2;
4417     }
4418     if (iter_flags & DSI_ENTRY_ID) { /* Entry ID */
4419         values->vvalue = tvb_get_letohl(tvb, ioffset);
4420         proto_tree_add_uint_format(it_tree, hf_nds_eid, tvb, ioffset,
4421                 4, values->vvalue, "Entry ID 0x%08x", values->vvalue);
4422         ioffset = ioffset + 4;
4423     }
4424     if (iter_flags & DSI_ENTRY_FLAGS) { /* Entry Flags */
4425         values->vvalue = tvb_get_letohl(tvb, ioffset);
4426         values->vtype = VTYPE_BITFIELD;
4427         values->vdesc = "Entry Flags:";
4428         values->vlength = 2;
4429         values->hfname= hf_nds_eflags;
4430         values->voffset = ioffset;
4431         values->bit1 = "Alias Entry";
4432         values->bit1hfname = hf_bit1eflags;
4433         values->bit2 = "Partition Root";
4434         values->bit2hfname = hf_bit2eflags;
4435         values->bit3 = "Container Entry";
4436         values->bit3hfname = hf_bit3eflags;
4437         values->bit4 = "Container Alias";
4438         values->bit4hfname = hf_bit4eflags;
4439         values->bit5 = "Matches List Filter";
4440         values->bit5hfname = hf_bit5eflags;
4441         values->bit6 = "Reference Entry";
4442         values->bit6hfname = hf_bit6eflags;
4443         values->bit7 = "40x Reference Entry";
4444         values->bit7hfname = hf_bit7eflags;
4445         values->bit8 = "Back Linked";
4446         values->bit8hfname = hf_bit8eflags;
4447         values->bit9 = "New Entry";
4448         values->bit9hfname = hf_bit9eflags;
4449         values->bit10 = "Temporary Reference";
4450         values->bit10hfname = hf_bit10eflags;
4451         values->bit11 = "Audited";
4452         values->bit11hfname = hf_bit11eflags;
4453         values->bit12 = "Entry Not Present";
4454         values->bit12hfname = hf_bit12eflags;
4455         values->bit13 = "Entry Verify CTS";
4456         values->bit13hfname = hf_bit13eflags;
4457         values->bit14 = "Entry Damaged";
4458         values->bit14hfname = hf_bit14eflags;
4459         values->bit15 = "Not Defined";
4460         values->bit15hfname = hf_bit15eflags;
4461         values->bit16 = "Not Defined";
4462         values->bit16hfname = hf_bit16eflags;
4463         process_bitfield(it_tree, tvb, values);
4464         ioffset = ioffset+4;
4465     }
4466     if (iter_flags & DSI_SUBORDINATE_COUNT) { /* Subordinate Count */
4467         proto_tree_add_item(it_tree, hf_sub_count, tvb, ioffset, 4, TRUE);
4468         ioffset += 4;
4469     }
4470     if (iter_flags & DSI_MODIFICATION_TIME) { /* Modification Time */
4471         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
4472         ns.nsecs = 0;
4473         proto_tree_add_time_format(it_tree, hf_es_seconds, tvb, ioffset,
4474                 4, &ns, "Modification Time: %s", abs_time_to_str(&ns));
4475         ioffset = ioffset + 4;
4476     }
4477     if (iter_flags & DSI_MODIFICATION_TIMESTAMP) { /* Modification Timestamp */
4478         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
4479         ns.nsecs = 0;
4480         proto_tree_add_time_format(it_tree, hf_es_seconds, tvb, ioffset,
4481                 4, &ns, "Modification Timestamp: %s", abs_time_to_str(&ns));
4482         ioffset = ioffset + 4;
4483         replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
4484         proto_tree_add_item(it_tree, hf_nds_replica_num, tvb, ioffset,
4485                 2, replica_num);
4486         ioffset = ioffset + 2;
4487         event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
4488         proto_tree_add_item(it_tree, hf_nds_event_num, tvb, ioffset,
4489                 2, event_num);
4490         ioffset = ioffset + 2;
4491     }
4492     if (iter_flags & DSI_CREATION_TIMESTAMP) { /* Creation Timestamp */
4493         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
4494         ns.nsecs = 0;
4495         proto_tree_add_time_format(it_tree, hf_es_seconds, tvb, ioffset,
4496                 4, &ns, "Creation Timestamp: %s", abs_time_to_str(&ns));
4497         ioffset = ioffset + 4;
4498         replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
4499         proto_tree_add_item(it_tree, hf_nds_replica_num, tvb, ioffset,
4500                 2, replica_num);
4501         ioffset = ioffset + 2;
4502         event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
4503         proto_tree_add_item(it_tree, hf_nds_event_num, tvb, ioffset,
4504                 2, event_num);
4505         ioffset = ioffset + 2;
4506     }
4507     if (iter_flags & DSI_PARTITION_ROOT_ID) { /* Partition Root ID */
4508         values->vvalue = tvb_get_letohl(tvb, ioffset);
4509         proto_tree_add_uint_format(it_tree, hf_nds_local_partition, tvb, ioffset,
4510                 4, values->vvalue, "Partition Root ID %08x", values->vvalue);
4511         ioffset = ioffset + 4;
4512     }
4513     if (iter_flags & DSI_PARENT_ID) { /* Parent ID */
4514         values->vvalue = tvb_get_letohl(tvb, ioffset);
4515         proto_tree_add_uint_format(it_tree, hf_nds_local_partition, tvb, ioffset,
4516                 4, values->vvalue, "Parent ID %08x", values->vvalue);
4517         ioffset = ioffset + 4;
4518     }
4519     if (iter_flags & DSI_REVISION_COUNT) { /* Revision Count */
4520         values->vvalue = tvb_get_letohl(tvb, ioffset);
4521         proto_tree_add_uint_format(it_tree, hf_nds_local_partition, tvb, ioffset,
4522                 4, values->vvalue, "Revision count %08x", values->vvalue);
4523         ioffset = ioffset + 4;
4524     }
4525     if (iter_flags & DSI_REPLICA_TYPE) { /* Replica Type */
4526         values->vvalue = tvb_get_letohl(tvb, ioffset) & 0x00ff;
4527         values->vstring = (char *)match_strval(values->vvalue, nds_replica_type);
4528         if (values->vstring == NULL)
4529         {
4530                 values->vstring = "No Replica Type Found";
4531         }
4532         proto_tree_add_string(it_tree, hf_replica_type, tvb, ioffset,
4533         4, values->vstring);
4534         values->vvalue = tvb_get_letohl(tvb, ioffset) & 0xff00;
4535         values->vstring = (char *)match_strval(values->vvalue, nds_replica_state);
4536         if (values->vstring == NULL)
4537         {
4538                 values->vstring = "No Replica State Found";
4539         }
4540         proto_tree_add_string(it_tree, hf_replica_state, tvb, ioffset,
4541         4, values->vstring);
4542         ioffset = ioffset + 4;
4543     }
4544     if (iter_flags & DSI_BASE_CLASS) { /* Base Class */
4545         values->vvalue = tvb_get_letohl(tvb, ioffset);         /* Length of string */
4546         ioffset = ioffset+4;
4547         get_string(tvb, ioffset, values->vvalue, values->vstring);
4548         proto_tree_add_string_format(it_tree, hf_value_string, tvb, ioffset,
4549                 values->vvalue, temp_string,
4550                 "Base Class: - %s", temp_string);
4551         ioffset = ioffset+values->vvalue;
4552         ioffset += align_4(tvb, ioffset);
4553     }
4554     if (iter_flags & DSI_ENTRY_RDN) { /* Relative Distiguished Name */
4555         values->vvalue = tvb_get_letohl(tvb, ioffset);         /* Length of string */
4556         ioffset = ioffset+4;
4557         get_string(tvb, ioffset, values->vvalue, values->vstring);
4558         proto_tree_add_string_format(it_tree, hf_value_string, tvb, ioffset,
4559                  values->vvalue, temp_string,
4560                  "Relative Distinguished Name - %s", temp_string);
4561         ioffset = ioffset+values->vvalue;
4562         ioffset += align_4(tvb, ioffset);
4563     }
4564     if (iter_flags & DSI_ENTRY_DN) { /* Distinguished Name */
4565         values->vvalue = tvb_get_letohl(tvb, ioffset);         /* Length of string */
4566         ioffset = ioffset+4;
4567         get_string(tvb, ioffset, values->vvalue, values->vstring);
4568         proto_tree_add_string_format(it_tree, hf_value_string, tvb, ioffset,
4569                  values->vvalue, temp_string,
4570                  "Distinguished Name - %s", temp_string);
4571         ioffset = ioffset+values->vvalue;
4572         ioffset += align_4(tvb, ioffset);
4573     }
4574     if (iter_flags & DSI_PARTITION_ROOT_DN) { /* Root Distinguished Name */
4575         values->vvalue = tvb_get_letohl(tvb, ioffset);         /* Length of string */
4576         ioffset = ioffset+4;
4577         get_string(tvb, ioffset, values->vvalue, values->vstring);
4578         proto_tree_add_string_format(it_tree, hf_value_string, tvb, ioffset,
4579                  values->vvalue, temp_string,
4580                  "Root Distinguished Name - %s", temp_string);
4581         ioffset = ioffset+values->vvalue;
4582         ioffset += align_4(tvb, ioffset);
4583     }
4584     if (iter_flags & DSI_PARENT_DN) { /* Parent Distinguished Name */
4585         values->vvalue = tvb_get_letohl(tvb, ioffset);         /* Length of string */
4586         ioffset = ioffset+4;
4587         get_string(tvb, ioffset, values->vvalue, values->vstring);
4588         proto_tree_add_string_format(it_tree, hf_value_string, tvb, ioffset,
4589                  values->vvalue, temp_string,
4590                  "Parent Distinguished Name - %s", temp_string);
4591         ioffset = ioffset+values->vvalue;
4592         ioffset += align_4(tvb, ioffset);
4593     }
4594     if (iter_flags & DSI_PURGE_TIME) { /* Purge Time */
4595         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
4596         ns.nsecs = 0;
4597         proto_tree_add_time_format(it_tree, hf_nds_purge, tvb, ioffset,
4598                 4, &ns, "Purge Time: %s", abs_time_to_str(&ns));
4599         ioffset = ioffset + 4;
4600     }
4601     if (iter_flags & DSI_DEREFERENCED_BASE_CLASS) { /* Dereference Base Class */
4602         values->vvalue = tvb_get_letohl(tvb, ioffset);
4603         ioffset = ioffset + 4;
4604         get_string(tvb, ioffset, values->vvalue, values->vstring);
4605         proto_tree_add_string(it_tree, hf_deref_base, tvb, ioffset,
4606                 values->vvalue, temp_string);
4607         ioffset = ioffset + values->vvalue;
4608     }
4609     if (iter_flags & DSI_REPLICA_NUMBER) { /* Replica Number */
4610         values->vvalue = tvb_get_letohl(tvb, ioffset); /* Replica number */
4611         proto_tree_add_uint_format(it_tree, hf_replica_number, tvb, ioffset,
4612                  4, values->vvalue, "Replica Number %d", values->vvalue);
4613         ioffset = ioffset+4;
4614     }
4615     if (iter_flags & DSI_REPLICA_STATE) { /* Replica State */
4616         values->vvalue = tvb_get_letohl(tvb, ioffset) & 0xff00;
4617         values->vstring = (char *)match_strval(values->vvalue, nds_replica_state);
4618         if (values->vstring == NULL)
4619         {
4620                 values->vstring = "No Replica State Found";
4621         }
4622         proto_tree_add_string(it_tree, hf_replica_state, tvb, ioffset,
4623         4, values->vstring);
4624         ioffset = ioffset + 2;
4625     }
4626     if (iter_flags & DSI_FEDERATION_BOUNDARY) { /* Federation Boundary */
4627         values->vvalue = tvb_get_letohl(tvb, ioffset);
4628         proto_tree_add_uint_format(it_tree, hf_nds_uint32value, tvb, ioffset,
4629                 4, values->vvalue, "Federation Boundary %d", values->vvalue);
4630         ioffset = ioffset+4;
4631     }
4632     if (iter_flags & DSI_SCHEMA_BOUNDARY) { /* Schema Boundary */
4633         values->vvalue = tvb_get_letohl(tvb, ioffset);
4634         proto_tree_add_uint_format(it_tree, hf_nds_uint32value, tvb, ioffset,
4635                 4, values->vvalue, "Schema Boundary %d", values->vvalue);
4636         ioffset = ioffset+4;
4637     }
4638     if (iter_flags & DSI_FEDERATION_BOUNDARY_ID) { /* Federation Boundary ID */
4639         values->vvalue = tvb_get_letohl(tvb, ioffset);
4640         proto_tree_add_uint_format(it_tree, hf_nds_uint32value, tvb, ioffset,
4641                 4, values->vvalue, "Federation Boundary ID %d", values->vvalue);
4642         ioffset = ioffset+4;
4643     }
4644     if (iter_flags & DSI_SCHEMA_BOUNDARY_ID) { /* Schema Boundary ID*/
4645         values->vvalue = tvb_get_letohl(tvb, ioffset);
4646         proto_tree_add_uint_format(it_tree, hf_nds_uint32value, tvb, ioffset,
4647                 4, values->vvalue, "Schema Boundary ID %d", values->vvalue);
4648         ioffset = ioffset+4;
4649     }
4650     if (iter_flags & DSI_CUR_SUBCOUNT) { /* Current Subcount */
4651         values->vvalue = tvb_get_letohl(tvb, ioffset);
4652         proto_tree_add_uint_format(it_tree, hf_nds_uint32value, tvb, ioffset,
4653                 4, values->vvalue, "Current Subcount %d", values->vvalue);
4654         ioffset = ioffset+4;
4655     }
4656     if (iter_flags & DSI_LOCAL_ENTRY_FLAGS) { /* Local Entry Flags */
4657         values->vvalue = tvb_get_letohl(tvb, ioffset);
4658         values->vtype = VTYPE_BITFIELD;
4659         values->vdesc = "Local Entry Flags:";
4660         values->vlength = 2;
4661         values->hfname= hf_nds_eflags;
4662         values->voffset = ioffset;
4663         values->bit1 = "Alias Entry";
4664         values->bit1hfname = hf_bit1eflags;
4665         values->bit2 = "Partition Root";
4666         values->bit2hfname = hf_bit2eflags;
4667         values->bit3 = "Container Entry";
4668         values->bit3hfname = hf_bit3eflags;
4669         values->bit4 = "Container Alias";
4670         values->bit4hfname = hf_bit4eflags;
4671         values->bit5 = "Matches List Filter";
4672         values->bit5hfname = hf_bit5eflags;
4673         values->bit6 = "Reference Entry";
4674         values->bit6hfname = hf_bit6eflags;
4675         values->bit7 = "40x Reference Entry";
4676         values->bit7hfname = hf_bit7eflags;
4677         values->bit8 = "Back Linked";
4678         values->bit8hfname = hf_bit8eflags;
4679         values->bit9 = "New Entry";
4680         values->bit9hfname = hf_bit9eflags;
4681         values->bit10 = "Temporary Reference";
4682         values->bit10hfname = hf_bit10eflags;
4683         values->bit11 = "Audited";
4684         values->bit11hfname = hf_bit11eflags;
4685         values->bit12 = "Entry Not Present";
4686         values->bit12hfname = hf_bit12eflags;
4687         values->bit13 = "Entry Verify CTS";
4688         values->bit13hfname = hf_bit13eflags;
4689         values->bit14 = "Entry Damaged";
4690         values->bit14hfname = hf_bit14eflags;
4691         values->bit15 = "Not Defined";
4692         values->bit15hfname = hf_bit15eflags;
4693         values->bit16 = "Not Defined";
4694         values->bit16hfname = hf_bit16eflags;
4695         process_bitfield(it_tree, tvb, values);
4696         ioffset = ioffset+4;
4697     }
4698     values->voffset = ioffset;
4699     return;
4700 }
4701
4702 static void
4703 dissect_nds_iterator(proto_tree *it_tree, tvbuff_t *tvb, packet_info *pinfo, guint32 it_verb, guint32 request_flags, guint32 ioffset, gboolean request_reply)
4704 {
4705     guint32     rcode, i, number_of_items, number_to_get;
4706     char        *error_string, *verb_string;
4707     nds_val     values;
4708     proto_tree  *it_subtree, *it_subtree1;
4709     proto_item  *it_subitem, *it_subitem1;
4710
4711     values.vtype = 0;
4712     values.vvalue = 0;
4713     values.vlength = 0;
4714     values.voffset = 0;
4715     values.hfname = 0;
4716     values.vdesc = "\0";
4717     values.vstring = "\0";
4718     values.mvtype = 0;
4719     values.vflags = 0;
4720
4721
4722     while (TRUE) {
4723         verb_string = (char *)match_strval(it_verb, iterator_subverbs);
4724         if(verb_string == NULL)
4725         {
4726             verb_string = "(No Iteration Verb Found)";
4727         }
4728         it_subitem = proto_tree_add_uint_format(it_tree, hf_ncp_nds_iterverb, tvb, ioffset-4, 4,
4729             it_verb, "Iterator Verb: %d, (0x%04x), %s",
4730             it_verb, it_verb, verb_string);
4731
4732         it_subtree = proto_item_add_subtree(it_subitem, ett_nds);
4733
4734         if (request_reply) { /* Request packets */
4735             switch (it_verb) {
4736             case IT_ATFIRST:
4737             case IT_ATEOF:
4738             case IT_ATLAST:
4739             case IT_ATBOF:
4740             case IT_CLEAR:
4741             case IT_COPY:
4742                 break;
4743             case IT_COUNT:
4744                 proto_tree_add_item(it_subtree, hf_timelimit, tvb, ioffset, 4, TRUE);
4745                 ioffset += 4;
4746                 proto_tree_add_item(it_subtree, hf_max_entries, tvb, ioffset, 4, TRUE);
4747                 ioffset += 4;
4748                 proto_tree_add_item(it_subtree, hf_move_position, tvb, ioffset, 4, TRUE);
4749                 ioffset += 4;
4750                 break;
4751             case IT_CREATE:
4752             case IT_CURRENT:
4753             case IT_DESTROY:
4754             case IT_DONE:
4755                 break;
4756             case IT_FIRST:
4757                 proto_tree_add_item(it_subtree, hf_timelimit, tvb, ioffset, 4, TRUE);
4758                 ioffset += 4;
4759                 break;
4760             case IT_GETPOSITION:
4761             case IT_ISPOSITIONABLE:
4762                 break;
4763             case IT_LAST:
4764                 proto_tree_add_item(it_subtree, hf_timelimit, tvb, ioffset, 4, TRUE);
4765                 ioffset += 4;
4766                 break;
4767             case IT_NEXT:
4768             case IT_PREV:
4769                 proto_tree_add_item(it_subtree, hf_timelimit, tvb, ioffset, 4, TRUE);
4770                 ioffset += 4;
4771                 proto_tree_add_item(it_subtree, hf_num_to_get, tvb, ioffset, 4, TRUE);
4772                 ioffset += 4;
4773                 break;
4774             case IT_POSITION:
4775                 proto_tree_add_item(it_subtree, hf_iter_position, tvb, ioffset, 4, TRUE);
4776                 ioffset += 4;
4777                 proto_tree_add_item(it_subtree, hf_timelimit, tvb, ioffset, 4, TRUE);
4778                 ioffset += 4;
4779                 break;
4780             case IT_POSITION_IT:
4781                 proto_tree_add_item(it_subtree, hf_iter_other, tvb, ioffset, 4, TRUE);
4782                 ioffset += 4;
4783                 break;
4784             case IT_SETINDEX:
4785                 proto_tree_add_item(it_subtree, hf_nds_number_of_items, tvb, ioffset, 4, TRUE);
4786                 number_of_items = tvb_get_letohl(tvb, ioffset);
4787                 ioffset += 4;
4788                 for (i=0; i < number_of_items; i++) {
4789                     /* Process the attribute tag */
4790                     values.vvalue = tvb_get_letohl(tvb, ioffset);
4791                     values.vstring = (char *)match_strval(values.vvalue, nds_tags);
4792                     if(values.vstring == NULL)
4793                     {
4794                             values.vstring = "No Tags Set";
4795                     }
4796                     proto_tree_add_string(it_subtree, hf_nds_tag_string, tvb, ioffset, 4, values.vstring);
4797                     ioffset = ioffset + 4;
4798
4799                     /* start of DCWPutAttribute */
4800                     values.vvalue = tvb_get_letohl(tvb, ioffset);
4801                     ioffset = ioffset + 4;
4802                     get_string(tvb, ioffset, values.vvalue, values.vstring);
4803                     proto_tree_add_string(it_subtree, hf_mv_string, tvb, ioffset,
4804                             values.vvalue, values.vstring);
4805                     ioffset = ioffset + values.vvalue;
4806                     /* end of DCWPutAttribute */
4807
4808                     ioffset += align_4(tvb, ioffset);
4809                     if (tvb_length_remaining(tvb, ioffset) < 4) {
4810                         THROW(ReportedBoundsError);
4811                         return;
4812                     }
4813                 }
4814                 break;
4815             case IT_SETFILTER:
4816
4817                 values.voffset = ioffset;
4818
4819                 /* DCWPutSearchExp  = process_set_filter() */
4820                 process_set_filter(it_subtree, tvb, pinfo, &values);
4821
4822                 ioffset = values.voffset;
4823                 ioffset += align_4(tvb, ioffset);
4824                 break;
4825             case IT_SKIP:
4826                 proto_tree_add_item(it_subtree, hf_timelimit, tvb, ioffset, 4, TRUE);
4827                 ioffset += 4;
4828                 proto_tree_add_item(it_subtree, hf_num_to_skip, tvb, ioffset, 4, TRUE);
4829                 ioffset += 4;
4830                 break;
4831             case IT_TYPEDOWN:
4832                 proto_tree_add_item(it_subtree, hf_num_to_get, tvb, ioffset, 4, TRUE);
4833                 number_to_get = tvb_get_letohl(tvb, ioffset);
4834                 ioffset += 4;
4835                 if (number_to_get == 0) {
4836                     values.vvalue = tvb_get_letohl(tvb, ioffset);
4837                     values.vstring = (char *)match_strval(values.vvalue, nds_tags);
4838                     if(values.vstring == NULL)
4839                     {
4840                             values.vstring = "No Tags Set";
4841                     }
4842                     proto_tree_add_string(it_tree, hf_nds_tag_string, tvb, ioffset, 4, values.vstring);
4843                     ioffset = ioffset + 4;
4844
4845                 }
4846                 values.vvalue = tvb_get_letohl(tvb, ioffset);
4847                 ioffset = ioffset + 4;
4848                 get_string(tvb, ioffset, values.vvalue, values.vstring);
4849                 proto_tree_add_string(it_subtree, hf_mv_string, tvb, ioffset,
4850                         values.vvalue, values.vstring);
4851                 ioffset = ioffset + values.vvalue;
4852                 ioffset += align_4(tvb, ioffset);
4853                 break;
4854             default:
4855                 if (tvb_length_remaining(tvb, ioffset) < 4) {
4856                     THROW(ReportedBoundsError);
4857                 }
4858                 return;
4859             }
4860         }
4861         else    /* Reply Packets */
4862         {                                           /* All replies include a completion code first */
4863             rcode = tvb_get_letohl(tvb, ioffset);
4864             error_string = (char *)match_strval(rcode, nds_reply_errors);
4865             if (error_string == NULL) {
4866                 error_string = (char *)"Unknown Interation Verb Completion Code";
4867             }
4868             expert_item = proto_tree_add_uint_format(it_subtree, hf_iter_verb_completion_code, tvb, ioffset,
4869                     4, rcode, "Completion Code: 0x%08x, %s",
4870                     rcode, error_string );
4871
4872             if (rcode != 0 && ncp_echo_err) {
4873                     expert_add_info_format(pinfo, expert_item, PI_RESPONSE_CODE, PI_ERROR, "Iteration Verb Error: 0x%08x %s", rcode, error_string);
4874             }
4875             ioffset += 4;
4876
4877             switch (it_verb) {
4878                         case IT_ATFIRST:
4879                         case IT_ATEOF:
4880                         case IT_ATLAST:
4881                         case IT_ATBOF:
4882                 proto_tree_add_item(it_subtree, hf_iter_ans, tvb, ioffset, 4, TRUE);
4883                 ioffset += 4;
4884                 break;
4885             case IT_CLEAR:
4886                 break;
4887                         case IT_COPY:
4888                 proto_tree_add_item(it_subtree, hf_iter_copy, tvb, ioffset, 4, TRUE);
4889                 ioffset += 4;
4890                 break;
4891                         case IT_COUNT:
4892                 proto_tree_add_item(it_subtree, hf_this_count, tvb, ioffset, 4, TRUE);
4893                 ioffset += 4;
4894                 break;
4895                         case IT_CREATE:
4896                 proto_tree_add_item(it_subtree, hf_nds_iterator, tvb, ioffset, 4, TRUE);
4897                 ioffset += 4;
4898                 break;
4899                         case IT_CURRENT:
4900                         case IT_NEXT:
4901                         case IT_PREV:
4902                         case IT_FIRST:
4903                         case IT_LAST:
4904                 values.vvalue = tvb_get_letohl(tvb, ioffset);
4905                 values.vstring = (char *)match_strval(values.vvalue, nds_info_type);
4906                 if(values.vstring == NULL)
4907                 {
4908                         values.vstring = "No Info Type Set";
4909                 }
4910                 proto_tree_add_string(it_subtree, hf_nds_info_type, tvb, ioffset, 4, values.vstring);
4911                 ioffset = ioffset + 4;
4912                 proto_tree_add_item(it_subtree, hf_data_size, tvb, ioffset, 4, TRUE);
4913                 ioffset += 4;
4914                 number_of_items = tvb_get_letohl(tvb, ioffset);
4915                 proto_tree_add_item(it_subtree, hf_this_count, tvb, ioffset, 4, TRUE);
4916                 ioffset += 4;
4917                                 for (i = 0; i < number_of_items; i++)
4918                                 {
4919                     it_subitem1 = proto_tree_add_text(it_subtree, tvb, ioffset, -1, "Item #: %d", i+1);
4920                     it_subtree1 = proto_item_add_subtree(it_subitem1, ett_nds);
4921
4922                     ioffset += align_4(tvb, ioffset);
4923
4924                     /* Start WGetAndBufferEntryInfo = process_entry_info() */
4925                     values.voffset = ioffset;
4926                     values.vflags = request_flags;
4927                     process_entry_info(it_subtree1, tvb, &values);
4928                     ioffset = values.voffset;
4929                     /* End WGetAndBufferEntryInfo */
4930
4931                     ioffset += align_4(tvb, ioffset);
4932
4933                     /* WGetReadBuffer - This seems to be a count and then size field (2 * guint32) */
4934                     /* For now we will just skip this offset. NEED TO ADD LOGIC TO HANDLE */
4935                     ioffset += 8;
4936
4937                     if (tvb_length_remaining(tvb, ioffset) < 4) {
4938                         break;
4939                     }
4940                 }
4941                 break;
4942             case IT_DESTROY:
4943                         case IT_DONE:
4944                 break;
4945             case IT_GETPOSITION:
4946                 proto_tree_add_item(it_subtree, hf_iter_position, tvb, ioffset, 4, TRUE);
4947                 ioffset += 4;
4948                 break;
4949                         case IT_ISPOSITIONABLE:
4950                 proto_tree_add_item(it_subtree, hf_positionable, tvb, ioffset, 4, TRUE);
4951                 ioffset += 4;
4952                 break;
4953                         case IT_POSITION:
4954                         case IT_POSITION_IT:
4955                         case IT_SETFILTER:
4956             case IT_TYPEDOWN:
4957                 break;
4958                         case IT_SETINDEX:
4959                 proto_tree_add_item(it_subtree, hf_iter_index, tvb, ioffset, 4, TRUE);
4960                 ioffset += 4;
4961                 break;
4962                         case IT_SKIP:
4963                 proto_tree_add_item(it_subtree, hf_num_skipped, tvb, ioffset, 4, TRUE);
4964                 ioffset += 4;
4965                 break;
4966             default:
4967                 if (tvb_length_remaining(tvb, ioffset) < 4) {
4968                     THROW(ReportedBoundsError);
4969                 }
4970                 return;
4971             }
4972         }
4973         it_verb = tvb_get_letohl(tvb, ioffset);
4974         ioffset += 4;
4975         if (it_verb == IT_DONE || tvb_length_remaining(tvb, ioffset) < 4) {
4976             verb_string = (char *)match_strval(it_verb, iterator_subverbs);
4977             if(verb_string == NULL)
4978             {
4979                 verb_string = "Internal error processing NDS iteration verbs";
4980             }
4981             it_subitem = proto_tree_add_uint_format(it_tree, hf_ncp_nds_iterverb, tvb, ioffset-4, 4,
4982                 it_verb, "Iterator Verb: %d, (0x%04x), %s",
4983                 it_verb, it_verb, verb_string);
4984             break;
4985         }
4986     }
4987     return;
4988 }
4989
4990
4991 static void
4992 process_multivalues(proto_tree *ncp_tree, tvbuff_t *tvb, packet_info *pinfo, nds_val *values)
4993 {
4994         guint32         i;
4995         guint32         r;
4996         guint32         ioffset = 0, oldioffset;
4997         guint32         value1 = 0;
4998         guint32         value2 = 0;
4999         guint8          value3 = 0;
5000         guint32         value4 = 0;
5001         gint            value5 = 0;
5002         guint32         value6 = 0;
5003         guint32         value7 = 0;
5004         const char      *valuestr = "";
5005         proto_tree      *ntree;
5006         proto_tree      *atree;
5007             proto_item      *nitem;
5008         proto_item      *aitem;
5009         guint32         number_of_referrals = 0;
5010         nw_uni_t        mval_buf;
5011         proto_tree      *estree;
5012             proto_item      *esitem;
5013         guint16         replica_num = 0;
5014         guint16         event_num = 0;
5015         guint32         bvalue=0;
5016         nds_val         temp_values;
5017         proto_tree      *sub1tree;
5018             proto_item      *sub1item;
5019         proto_tree      *sub2tree;
5020             proto_item      *sub2item;
5021             gint                    length_remaining;
5022         nstime_t        ns;
5023
5024         mval_buf.buffer[0] = '\0';
5025         mv_resolve_name_string[0] = '\0';
5026
5027         /* Is the value passed a string or UINT32? */
5028         if(values->mvtype != MVTYPE_LIST_PARTITIONS && values->mvtype != MVTYPE_PROCESS_TAGS)
5029         {
5030                 nitem = proto_tree_add_uint_format(ncp_tree, values->hfname, tvb, values->voffset+ioffset,
5031                         values->vlength, values->vvalue, values->vdesc, values->vvalue);
5032         }
5033         else
5034         {
5035                 nitem = proto_tree_add_string_format(ncp_tree, values->hfname, tvb, values->voffset+ioffset,
5036                         values->vlength, values->vdesc, "%s", values->vdesc);
5037         }
5038         ioffset = (values->voffset+4);
5039
5040         ntree = proto_item_add_subtree(nitem, ett_nds);
5041
5042         switch (values->mvtype)
5043         {
5044                 case MVTYPE_ATTR_REQUEST:       /* Attribute Request */
5045                         for (i = 1 ; i <= values->vvalue; i++ )
5046                         {
5047                                 ioffset += align_4(tvb, ioffset);
5048                                 value1 = tvb_get_letohl(tvb, ioffset);
5049                                 ioffset = ioffset + 4;
5050                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
5051                                 values->vstring = mval_buf.buffer;
5052                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5053                                         value1, values->vstring);
5054                                 ioffset = ioffset + value1;
5055                         }
5056                         break;
5057
5058                 case MVTYPE_ATTR_REPLY:         /* Attribute Reply */
5059                         switch(values->vflags)
5060                         {
5061                                 case 0:
5062                                         for (i = 1 ; i <= values->vvalue; i++ )
5063                                         {
5064                                                 ioffset += align_4(tvb, ioffset);
5065                                                 value1 = tvb_get_letohl(tvb, ioffset);
5066                                                 ioffset = ioffset + 4;
5067                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
5068                                                 values->vstring = mval_buf.buffer;
5069                                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5070                                                         value1, values->vstring);
5071                                                 ioffset = ioffset + value1;
5072                                         }
5073                                         break;
5074                                 case 1:
5075                                         for (i = 1 ; i <= values->vvalue; i++ )
5076                                         {
5077                                                 value1 = tvb_get_letohl(tvb, ioffset);
5078                                                 values->vstring = (char *)match_strval(value1, nds_syntax);
5079                                                 if (values->vstring == NULL)
5080                                                 {
5081                                                         values->vstring = "No Syntax Found";
5082                                                 }
5083                                                 proto_tree_add_string(ntree, hf_nds_syntax, tvb, ioffset,
5084                                                 4, values->vstring);
5085                                                 ioffset = ioffset + 4;
5086                                                 value2 = tvb_get_letohl(tvb, ioffset);
5087                                                 ioffset = ioffset + 4;
5088                                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
5089                                                 values->vstring = mval_buf.buffer;
5090                                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5091                                                         value2, values->vstring);
5092                                                 ioffset += value2;
5093                                                 ioffset += align_4(tvb, ioffset);
5094                                                 values->voffset = ioffset;
5095
5096                                                 print_nds_values(ntree, tvb, value1, values);
5097                                                 ioffset = values->voffset;
5098                                         }
5099                                         break;
5100                                 case 2:
5101                                         for (i = 1 ; i <= values->vvalue; i++ )
5102                                         {
5103                                                 value1 = tvb_get_letohl(tvb, ioffset);
5104                                                 values->vstring = (char *)match_strval(value1, nds_syntax);
5105                                                 if (values->vstring == NULL)
5106                                                 {
5107                                                         values->vstring = "No Syntax Found";
5108                                                 }
5109                                                 proto_tree_add_string(ntree, hf_nds_syntax, tvb, ioffset,
5110                                                 4, values->vstring);
5111                                                 ioffset = ioffset + 4;
5112                                                 value2 = tvb_get_letohl(tvb, ioffset);
5113                                                 ioffset = ioffset + 4;
5114                                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
5115                                                 values->vstring = mval_buf.buffer;
5116                                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5117                                                         value2, values->vstring);
5118                                                 values->voffset=ioffset + value2;
5119                                                 ioffset += value2;
5120                                                 ioffset += align_4(tvb, ioffset);
5121                                                 value3 = tvb_get_letohl(tvb, ioffset);
5122
5123                                                     proto_tree_add_uint_format(ntree, hf_nds_uint32value, tvb, ioffset, 4,
5124                                                         value3, "Number of Values - %d", value3);
5125
5126                                                 ioffset = ioffset + 4;
5127                                                 for (r = 1 ; r <= value3; r++ )
5128                                                 {
5129                                                         ioffset += 4;   /* Length = 4 */
5130                                                         value4 = tvb_get_letohl(tvb, ioffset);
5131                                                         tvb_ensure_bytes_exist(tvb, ioffset, values->vlength);
5132                                                         proto_tree_add_uint(ntree, hf_nds_privileges, tvb, ioffset,
5133                                                         values->vlength, value4);
5134
5135                                                         ioffset = ioffset+4;
5136                                                 }
5137                                         }
5138                                         break;
5139                                 case 3:
5140                                         for (i = 1 ; i <= values->vvalue; i++ )
5141                                         {
5142                                                 value1 = tvb_get_letohl(tvb, ioffset);
5143                                                 values->vstring = (char *)match_strval(value1, nds_syntax);
5144                                                 if (values->vstring == NULL)
5145                                                 {
5146                                                         values->vstring = "No Syntax Found";
5147                                                 }
5148                                                 proto_tree_add_string(ntree, hf_nds_syntax, tvb, ioffset,
5149                                                 4, values->vstring);
5150                                                 ioffset = ioffset + 4;
5151                                                 value2 = tvb_get_letohl(tvb, ioffset);
5152                                                 ioffset = ioffset + 4;
5153                                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
5154                                                 values->vstring = mval_buf.buffer;
5155                                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5156                                                         value2, values->vstring);
5157                                                 ioffset = ioffset + value2;
5158                                                 ioffset += align_4(tvb, ioffset);
5159                                                 value3 = tvb_get_letohl(tvb, ioffset);
5160
5161                                                 aitem = proto_tree_add_uint_format(ntree, hf_nds_uint32value, tvb, ioffset, 4,
5162                                                         value3, "Number of Values - %d", value3);
5163
5164                                                 atree = proto_item_add_subtree(aitem, ett_nds);
5165
5166                                                 ioffset = ioffset + 4;
5167                                                 for (r = 1 ; r <= value3; r++ )
5168                                                 {
5169                                                         ioffset += align_4(tvb, ioffset);
5170                                                         temp_values.vvalue = tvb_get_letohl(tvb, ioffset);
5171                                                         temp_values.vlength = 2;
5172                                                         temp_values.hfname = hf_nds_vflags;
5173                                                         temp_values.voffset = ioffset;
5174                                                         temp_values.vdesc = "Value Flags";
5175                                                         temp_values.bit1 = "Naming";
5176                                                         temp_values.bit1hfname = hf_bit1vflags;
5177                                                         temp_values.bit2 = "Base Class";
5178                                                         temp_values.bit2hfname = hf_bit2vflags;
5179                                                         temp_values.bit3 = "Present";
5180                                                         temp_values.bit3hfname = hf_bit3vflags;
5181                                                         temp_values.bit4 = "Value Damaged";
5182                                                         temp_values.bit4hfname = hf_bit4vflags;
5183                                                         temp_values.bit5 = "Not Defined";
5184                                                         temp_values.bit5hfname = hf_bit5vflags;
5185                                                         temp_values.bit6 = "Not Defined";
5186                                                         temp_values.bit6hfname = hf_bit6vflags;
5187                                                         temp_values.bit7 = "Not Defined";
5188                                                         temp_values.bit7hfname = hf_bit7vflags;
5189                                                         temp_values.bit8 = "Not Defined";
5190                                                         temp_values.bit8hfname = hf_bit8vflags;
5191                                                         temp_values.bit9 = "Not Defined";
5192                                                         temp_values.bit9hfname = hf_bit9vflags;
5193                                                         temp_values.bit10 = "Not Defined";
5194                                                         temp_values.bit10hfname = hf_bit10vflags;
5195                                                         temp_values.bit11 = "Not Defined";
5196                                                         temp_values.bit11hfname = hf_bit11vflags;
5197                                                         temp_values.bit12 = "Not Defined";
5198                                                         temp_values.bit12hfname = hf_bit12vflags;
5199                                                         temp_values.bit13 = "Not Defined";
5200                                                         temp_values.bit13hfname = hf_bit13vflags;
5201                                                         temp_values.bit14 = "Not Defined";
5202                                                         temp_values.bit14hfname = hf_bit14vflags;
5203                                                         temp_values.bit15 = "Not Defined";
5204                                                         temp_values.bit15hfname = hf_bit15vflags;
5205                                                         temp_values.bit16 = "Not Defined";
5206                                                         temp_values.bit16hfname = hf_bit16vflags;
5207                                                         process_bitfield(atree, tvb, &temp_values);
5208                                                         ioffset = ioffset + 4;
5209                                                         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5210                                                         ns.nsecs = 0;
5211                                                         proto_tree_add_time_format(atree, hf_es_seconds, tvb, ioffset,
5212                                                                 4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
5213                                                         ioffset = ioffset + 4;
5214                                                         replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
5215                                                         proto_tree_add_item(atree, hf_nds_replica_num, tvb, ioffset,
5216                                                                 2, replica_num);
5217                                                         ioffset = ioffset + 2;
5218                                                         event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
5219                                                         proto_tree_add_item(atree, hf_nds_event_num, tvb, ioffset,
5220                                                                 2, event_num);
5221                                                         ioffset = ioffset + 2;
5222                                                         value5 = tvb_get_letohl(tvb, ioffset); /* length of field */
5223                                                         if(value5 > tvb_length_remaining(tvb, ioffset))
5224                                                         {
5225                                                                  break;
5226                                                         }
5227                                                         ioffset += 4;
5228                                                         tvb_ensure_bytes_exist(tvb, ioffset, value5);
5229                                                         proto_tree_add_bytes(atree, hf_value_bytes, tvb, ioffset, value5, tvb_get_ptr(tvb, ioffset, value5));
5230                                                         ioffset += value5;
5231                                                         ioffset += (value5%2);
5232                                                 }
5233                                         }
5234                                         break;
5235                                 case 4:
5236                                         for (i = 1 ; i <= values->vvalue; i++ )
5237                                         {
5238                                                 value1 = tvb_get_letohl(tvb, ioffset);
5239                                                 values->vstring = (char *)match_strval(value1, nds_syntax);
5240                                                 if (values->vstring == NULL)
5241                                                 {
5242                                                         values->vstring = "No Syntax Found";
5243                                                 }
5244                                                 proto_tree_add_string(ntree, hf_nds_syntax, tvb, ioffset,
5245                                                 4, values->vstring);
5246                                                 ioffset = ioffset + 4;
5247                                                 value2 = tvb_get_letohl(tvb, ioffset);
5248                                                 ioffset = ioffset + 4;
5249                                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
5250                                                 values->vstring = mval_buf.buffer;
5251                                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5252                                                         value2, values->vstring);
5253                                                 ioffset = ioffset + value2;
5254                                                 value3 = tvb_get_letohl(tvb, ioffset);
5255
5256                                                 proto_tree_add_uint_format(ntree, hf_nds_uint32value, tvb, ioffset, 4,
5257                                                         value3, "Number of Values - %d", value3);
5258
5259                                                 ioffset = ioffset + 4;
5260                                                 for (r = 1 ; r <= value3; r++ )
5261                                                 {
5262                                                         ioffset += align_4(tvb, ioffset);
5263                                                         temp_values.vvalue = tvb_get_letohl(tvb, ioffset);
5264                                                         temp_values.vlength = 2;
5265                                                         temp_values.hfname = hf_nds_vflags;
5266                                                         temp_values.voffset = ioffset;
5267                                                         temp_values.vdesc = "Value Flags";
5268                                                         temp_values.bit1 = "Naming";
5269                                                         temp_values.bit1hfname = hf_bit1vflags;
5270                                                         temp_values.bit2 = "Base Class";
5271                                                         temp_values.bit2hfname = hf_bit2vflags;
5272                                                         temp_values.bit3 = "Present";
5273                                                         temp_values.bit3hfname = hf_bit3vflags;
5274                                                         temp_values.bit4 = "Value Damaged";
5275                                                         temp_values.bit4hfname = hf_bit4vflags;
5276                                                         temp_values.bit5 = "Not Defined";
5277                                                         temp_values.bit5hfname = hf_bit5vflags;
5278                                                         temp_values.bit6 = "Not Defined";
5279                                                         temp_values.bit6hfname = hf_bit6vflags;
5280                                                         temp_values.bit7 = "Not Defined";
5281                                                         temp_values.bit7hfname = hf_bit7vflags;
5282                                                         temp_values.bit8 = "Not Defined";
5283                                                         temp_values.bit8hfname = hf_bit8vflags;
5284                                                         temp_values.bit9 = "Not Defined";
5285                                                         temp_values.bit9hfname = hf_bit9vflags;
5286                                                         temp_values.bit10 = "Not Defined";
5287                                                         temp_values.bit10hfname = hf_bit10vflags;
5288                                                         temp_values.bit11 = "Not Defined";
5289                                                         temp_values.bit11hfname = hf_bit11vflags;
5290                                                         temp_values.bit12 = "Not Defined";
5291                                                         temp_values.bit12hfname = hf_bit12vflags;
5292                                                         temp_values.bit13 = "Not Defined";
5293                                                         temp_values.bit13hfname = hf_bit13vflags;
5294                                                         temp_values.bit14 = "Not Defined";
5295                                                         temp_values.bit14hfname = hf_bit14vflags;
5296                                                         temp_values.bit15 = "Not Defined";
5297                                                         temp_values.bit15hfname = hf_bit15vflags;
5298                                                         temp_values.bit16 = "Not Defined";
5299                                                         temp_values.bit16hfname = hf_bit16vflags;
5300                                                         process_bitfield(ntree, tvb, &temp_values);
5301                                                         ioffset = ioffset + 4;
5302                                                         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5303                                                         ns.nsecs = 0;
5304                                                         proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
5305                                                                 4, &ns, "Creation Time: %s", abs_time_to_str(&ns));
5306                                                         ioffset = ioffset + 4;
5307                                                         replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
5308                                                         proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset,
5309                                                                 2, replica_num);
5310                                                         ioffset = ioffset + 2;
5311                                                         event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
5312                                                         proto_tree_add_item(ntree, hf_nds_event_num, tvb, ioffset,
5313                                                                 2, event_num);
5314                                                         ioffset = ioffset + 2;
5315                                                         value1 = tvb_get_letohl(tvb, ioffset);
5316                                                         proto_tree_add_uint(ntree, hf_nds_value_len, tvb, ioffset,
5317                                                                 4, value1);
5318                                                         ioffset = ioffset + 4;
5319                                                 }
5320                                         }
5321                                         break;
5322                                 default:
5323                                         break;
5324                         }
5325                         break;
5326
5327                 case MVTYPE_ATTR_REQUEST2:      /* Attribute Request */
5328                         oldioffset = 0;
5329                         for (i = 1 ; i <= values->vvalue; i++ )
5330                         {
5331                                 if (oldioffset >= ioffset) {
5332                                         proto_tree_add_text(ntree, tvb, 0, 0, "[ Invalid offset: %u ]", ioffset);
5333                                         THROW(ReportedBoundsError);
5334                                 }
5335                                 oldioffset = ioffset;
5336                                 ioffset += align_4(tvb, ioffset);
5337                                 value1 = tvb_get_letohl(tvb, ioffset);
5338                                 proto_tree_add_uint_format(ntree, hf_nds_uint32value, tvb, ioffset,
5339                                         4, value1, "Value %d", value1);
5340                                 ioffset = ioffset + value1;
5341                         }
5342                         break;
5343
5344                 case MVTYPE_ADD_ATTR_REQUEST:   /* Add Attribute Request */
5345                         for (i = 1 ; i <= values->vvalue; i++ )
5346                         {
5347                                 value1 = tvb_get_letohl(tvb, ioffset);
5348                                 ioffset = ioffset + 4;
5349                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
5350                                 values->vstring = mval_buf.buffer;
5351                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5352                                         value1, values->vstring);
5353                                 ioffset = ioffset + value1;
5354                                 ioffset += align_4(tvb, ioffset);
5355                                 values->voffset = ioffset;
5356                                 print_nds_values(ntree, tvb, 9, values);
5357                                 ioffset = values->voffset;
5358                         }
5359                         break;
5360
5361                 case MVTYPE_READ_CLASS_REQ:     /* Read Class Request */
5362                         for (i = 1 ; i <= values->vvalue; i++ )
5363                         {
5364                                 ioffset += align_4(tvb, ioffset);
5365                                 value1 = tvb_get_letohl(tvb, ioffset);
5366                                 ioffset = ioffset + 4;
5367                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
5368                                 values->vstring = mval_buf.buffer;
5369                                 proto_tree_add_string(ntree, hf_nds_base, tvb, ioffset,
5370                                         value1, values->vstring);
5371                                 values->mvtype = MVTYPE_ATTR_REQUEST;
5372                                 ioffset = ioffset + value1;
5373                         }
5374                         break;
5375
5376                 case MVTYPE_READ_REPLICAS:      /* Read Replicas */
5377                         for (i = 1 ; i <= values->vvalue; i++ )
5378                         {
5379
5380                                 bvalue = 0x00000001;
5381
5382                                 for (r = 0 ; r < 9; r++ )
5383                                 {
5384
5385                                         if (values->vflags & bvalue)
5386                                         {
5387                                                 switch(bvalue)
5388                                                 {
5389                                                         case 0x00000001:                /*p3values.bit1 = "Output Flags"*/
5390                                                                 temp_values.vvalue = tvb_get_letohl(tvb, ioffset);
5391                                                                 temp_values.vlength = 2;
5392                                                                 temp_values.hfname = hf_nds_rflags;
5393                                                                 temp_values.voffset = ioffset;
5394                                                                 temp_values.vdesc = "Output Flags";
5395                                                                 temp_values.bit1 = values->bit1;
5396                                                                 temp_values.bit1hfname = hf_bit1outflags;
5397                                                                 temp_values.bit2 = values->bit2;
5398                                                                 temp_values.bit2hfname = hf_bit2outflags;
5399                                                                 temp_values.bit3 = values->bit3;
5400                                                                 temp_values.bit3hfname = hf_bit3outflags;
5401                                                                 temp_values.bit4 = values->bit4;
5402                                                                 temp_values.bit4hfname = hf_bit4outflags;
5403                                                                 temp_values.bit5 = values->bit5;
5404                                                                 temp_values.bit5hfname = hf_bit5outflags;
5405                                                                 temp_values.bit6 = values->bit6;
5406                                                                 temp_values.bit6hfname = hf_bit6outflags;
5407                                                                 temp_values.bit7 = values->bit7;
5408                                                                 temp_values.bit7hfname = hf_bit7outflags;
5409                                                                 temp_values.bit8 = values->bit8;
5410                                                                 temp_values.bit8hfname = hf_bit8outflags;
5411                                                                 temp_values.bit9 = values->bit9;
5412                                                                 temp_values.bit9hfname = hf_bit9outflags;
5413                                                                 temp_values.bit10 = "Not Defined";
5414                                                                 temp_values.bit10hfname = hf_bit10outflags;
5415                                                                 temp_values.bit11 = "Not Defined";
5416                                                                 temp_values.bit11hfname = hf_bit11outflags;
5417                                                                 temp_values.bit12 = "Not Defined";
5418                                                                 temp_values.bit12hfname = hf_bit12outflags;
5419                                                                 temp_values.bit13 = "Not Defined";
5420                                                                 temp_values.bit13hfname = hf_bit13outflags;
5421                                                                 temp_values.bit14 = "Not Defined";
5422                                                                 temp_values.bit14hfname = hf_bit14outflags;
5423                                                                 temp_values.bit15 = "Not Defined";
5424                                                                 temp_values.bit15hfname = hf_bit15outflags;
5425                                                                 temp_values.bit16 = "Not Defined";
5426                                                                 temp_values.bit16hfname = hf_bit16outflags;
5427                                                                 process_bitfield(ntree, tvb, &temp_values);
5428                                                                 ioffset = ioffset + 4;
5429                                                                 break;
5430                                                         case 0x00000002:                /*p3values.bit2 = "Entry ID"*/
5431                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5432                                                                 proto_tree_add_uint_format(ntree, hf_nds_eid, tvb, ioffset,
5433                                                                         4, value1, "Entry ID %08x", value1);
5434                                                                 ioffset = ioffset + 4;
5435                                                                 break;
5436                                                         case 0x00000004:                /*p3values.bit3 = "Replica State"*/
5437                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5438                                                                 temp_values.vstring = (char *)match_strval(value1, nds_replica_state);
5439                                                                 if (temp_values.vstring == NULL)
5440                                                                 {
5441                                                                         temp_values.vstring = "No Replica State Found";
5442                                                                 }
5443                                                                 proto_tree_add_string(ntree, hf_replica_state, tvb, ioffset,
5444                                                                 4, temp_values.vstring);
5445                                                                 ioffset = ioffset + 4;
5446                                                                 break;
5447                                                         case 0x0000008:                 /*p3values.bit4 = "Modification Timestamp"*/
5448                                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5449                                                                 ns.nsecs = 0;
5450                                                                 proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
5451                                                                         4, &ns, "Modification Timestamp: %s", abs_time_to_str(&ns));
5452                                                                 ioffset = ioffset + 4;
5453                                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
5454                                                                 proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset,
5455                                                                         2, replica_num);
5456                                                                 ioffset = ioffset + 2;
5457                                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
5458                                                                 proto_tree_add_item(ntree, hf_nds_event_num, tvb, ioffset,
5459                                                                         2, event_num);
5460                                                                 ioffset = ioffset + 2;
5461                                                                 break;
5462                                                         case 0x00000010:                /*p3values.bit5 = "Purge Time"*/
5463                                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5464                                                                 ns.nsecs = 0;
5465                                                                 proto_tree_add_time_format(ntree, hf_nds_purge, tvb, ioffset,
5466                                                                         4, &ns, "Purge Time: %s", abs_time_to_str(&ns));
5467                                                                 ioffset = ioffset + 4;
5468                                                                 break;
5469                                                         case 0x00000020:                /*p3values.bit6 = "Local Partition ID"*/
5470                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5471                                                                 proto_tree_add_uint_format(ntree, hf_nds_local_partition, tvb, ioffset,
5472                                                                         4, value1, "Local Partition ID %08x", value1);
5473                                                                 ioffset = ioffset + 4;
5474                                                                 break;
5475                                                         case 0x00000040:                /*p3values.bit7 = "Distinguished Name"*/
5476                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5477                                                                 ioffset = ioffset + 4;
5478                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
5479                                                                 temp_values.vstring = mval_buf.buffer;
5480                                                                 proto_tree_add_string(ntree, hf_nds_name, tvb, ioffset,
5481                                                                         value1, temp_values.vstring);
5482                                                                 ioffset = ioffset + value1;
5483                                                                 break;
5484                                                         case 0x00000080:                /*p3values.bit8 = "Replica Type & State"*/
5485                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5486                                                                 value2 = value1 & 0x00ff;
5487                                                                 temp_values.vstring = (char *)match_strval(value2, nds_replica_type);
5488                                                                 if (temp_values.vstring == NULL)
5489                                                                 {
5490                                                                         temp_values.vstring = "No Replica Type Found";
5491                                                                 }
5492                                                                 proto_tree_add_string(ntree, hf_replica_type, tvb, ioffset,
5493                                                                 4, temp_values.vstring);
5494                                                                 value3 = value1 & 0xff00;
5495                                                                 temp_values.vstring = (char *)match_strval(value3, nds_replica_state);
5496                                                                 if (temp_values.vstring == NULL)
5497                                                                 {
5498                                                                         temp_values.vstring = "No Replica State Found";
5499                                                                 }
5500                                                                 proto_tree_add_string(ntree, hf_replica_state, tvb, ioffset,
5501                                                                 4, temp_values.vstring);
5502                                                                 ioffset = ioffset + 4;
5503                                                                 break;
5504                                                         case 0x00000100:                /*p3values.bit9 = "Partition Busy"*/
5505                                                                 value1 = tvb_get_letohs(tvb, ioffset);
5506                                                                 proto_tree_add_boolean(ntree, hf_partition_busy, tvb, ioffset, 4, value1);
5507                                                                 ioffset += 4;
5508                                                                 break;
5509                                                         default:
5510                                                                 break;
5511
5512                                                 }
5513                                         }
5514                                         bvalue = bvalue*2;
5515                                         ioffset += align_4(tvb, ioffset);
5516                                         if(tvb_length_remaining(tvb, ioffset) < 4 )
5517                                         {
5518                                                 break;
5519                                         }
5520                                 }
5521                                 if(tvb_length_remaining(tvb, ioffset) < 4 )
5522                                 {
5523                                         break;
5524                                 }
5525                         }
5526                         break;
5527
5528                 case MVTYPE_MODIFY_ATTR_REQUEST: /* Modify Attribute Request */
5529                         for (i = 0 ; i < values->vvalue; i++ )
5530                         {
5531                                ioffset += align_4(tvb, ioffset);
5532                                value1 = tvb_get_letohl(tvb, ioffset);
5533                                valuestr = match_strval(value1, nds_kind_of_changes);
5534                                if (valuestr == NULL)
5535                                {
5536                                                valuestr="(Kind Change Not Found)";
5537                                }
5538                                tvb_ensure_bytes_exist(tvb, ioffset, values->vlength);
5539                                proto_tree_add_uint_format(ntree, hf_nds_uint32value, tvb, ioffset,
5540                                values->vlength, value1, valuestr, value1);
5541                                ioffset = ioffset+4;
5542                                value2 = tvb_get_letohl(tvb, ioffset);
5543                                ioffset = ioffset + 4;
5544                                get_string(tvb, ioffset, value2, mval_buf.buffer);   /* Name of Attribute */
5545                                temp_values.vstring = mval_buf.buffer;
5546                                proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
5547                                        value2, temp_values.vstring);
5548                                ioffset = ioffset + value2;
5549                                ioffset += align_4(tvb, ioffset);
5550                                if(value1 != 1 && value1 != 6)
5551                                {
5552                                        values->voffset = ioffset;
5553                                        print_nds_values(ntree, tvb, 9, values);
5554                                        ioffset = values->voffset;
5555                                }
5556                         }
5557                         break;
5558
5559                 case MVTYPE_ADDR_REFERRAL_REQUEST: /* Address Referral Request */
5560                         for (i = 0 ; i < values->vvalue; i++ )
5561                         {
5562
5563                                value1 = tvb_get_letohl(tvb, ioffset);
5564                                valuestr = match_strval(value1, nds_protocol_type);
5565                                if (valuestr == NULL)
5566                                {
5567                                                valuestr="(Undefined Protocol)";
5568                                }
5569                                tvb_ensure_bytes_exist(tvb, ioffset, values->vlength);
5570                                proto_tree_add_uint_format(ntree, hf_nds_uint32value, tvb, ioffset,
5571                                values->vlength, value1, valuestr, value1);
5572                                ioffset = ioffset+4;
5573                         }
5574                         break;
5575
5576                 case MVTYPE_ADDR_REFERRAL_REPLY: /* Address Referral Reply */
5577                         number_of_referrals = values->vvalue;
5578
5579                         for (r = 1 ; r <= number_of_referrals; r++ )
5580                         {
5581                                 aitem = proto_tree_add_uint_format(ntree, hf_referral_record, tvb, 6, 0,
5582                                 r, "NDS Referral Record #%u", r);
5583                                 atree = proto_item_add_subtree(aitem, ett_nds);
5584
5585                                 value1 = tvb_get_letohl(tvb, ioffset);
5586
5587                                 proto_tree_add_uint_format(atree, hf_referral_addcount, tvb, ioffset, 4,
5588                                         value1, "Number of Addresses in Referral - %d", value1);
5589
5590                                 ioffset = ioffset + 4;
5591                                 for (i = 1 ; i <= value1; i++ )
5592                                 {
5593                                         value2 = tvb_get_letohl(tvb, ioffset);
5594                                         valuestr = match_strval(value2, nds_protocol_type);
5595                                         if (valuestr == NULL)
5596                                         {
5597                                                valuestr="(Undefined Protocol)";
5598                                         }
5599                                         tvb_ensure_bytes_exist(tvb, ioffset, values->vlength);
5600                                         proto_tree_add_uint_format(atree, hf_nds_uint32value, tvb, ioffset,
5601                                         values->vlength, value2, valuestr, value2);
5602                                         ioffset = ioffset+4;
5603                                         value3 = tvb_get_letohl(tvb, ioffset);
5604                                         ioffset = ioffset+4;
5605                                         switch (value2)
5606                                         {
5607                                                 case NDS_PTYPE_IPX:
5608                                                         proto_tree_add_item(atree, hf_nds_net, tvb, ioffset, 4, FALSE);
5609                                                         proto_tree_add_item(atree, hf_nds_node, tvb, ioffset+4, 6, FALSE);
5610                                                         proto_tree_add_item(atree, hf_nds_socket, tvb, ioffset+10, 2, FALSE);
5611                                                         break;
5612                                                 case NDS_PTYPE_IP:
5613                                                         proto_tree_add_item(atree, hf_nds_port, tvb, ioffset, 2, FALSE);
5614                                                         proto_tree_add_item(atree, hf_add_ref_ip, tvb, ioffset+2, 4, FALSE);
5615                                                         break;
5616                                                 case NDS_PTYPE_UDP:
5617                                                         proto_tree_add_item(atree, hf_nds_port, tvb, ioffset, 2, FALSE);
5618                                                         proto_tree_add_item(atree, hf_add_ref_udp, tvb, ioffset+2, 4, FALSE);
5619                                                         break;
5620                                                 case NDS_PTYPE_TCP:
5621                                                         proto_tree_add_item(atree, hf_nds_port, tvb, ioffset, 2, FALSE);
5622                                                         proto_tree_add_item(atree, hf_add_ref_tcp, tvb, ioffset+2, 4, FALSE);
5623                                                         break;
5624                                                 case NDS_PTYPE_URL:
5625                                                 case NDS_PTYPE_DNS:
5626                                                         get_string(tvb, ioffset, value3, values->vstring);
5627                                                         proto_tree_add_string(atree, hf_value_string, tvb, ioffset,
5628                                                                 value3, values->vstring);
5629                                                         break;
5630                                                 default:
5631                                                         break;
5632                                         }
5633                                         ioffset = ioffset + value3;
5634                                         ioffset += align_4(tvb, ioffset);
5635                                 }
5636
5637                         }
5638                         break;
5639
5640                 case MVTYPE_LOC_ADDR_REFERRAL_REPLY: /* Local Address Referral Reply */
5641                         number_of_referrals = values->vvalue;
5642
5643                         for (r = 1 ; r <= number_of_referrals; r++ )
5644                         {
5645                                 aitem = proto_tree_add_uint_format(ntree, hf_referral_record, tvb, 6, 0,
5646                                 r, "NDS Referral Record #%u", r);
5647                                 atree = proto_item_add_subtree(aitem, ett_nds);
5648
5649                                 value2 = tvb_get_letohl(tvb, ioffset);
5650                                 valuestr = match_strval(value2, nds_protocol_type);
5651                                 if (valuestr == NULL)
5652                                 {
5653                                         valuestr="(Undefined Protocol)";
5654                                 }
5655                                 tvb_ensure_bytes_exist(tvb, ioffset, values->vlength);
5656                                 proto_tree_add_uint_format(atree, hf_nds_uint32value, tvb, ioffset,
5657                                 values->vlength, value2, valuestr, value2);
5658                                 ioffset = ioffset+4;
5659                                 value3 = tvb_get_letohl(tvb, ioffset);
5660                                 ioffset = ioffset+4;
5661
5662                                 switch (value2)
5663                                 {
5664                                         case NDS_PTYPE_IPX:
5665                                                 proto_tree_add_item(atree, hf_nds_net, tvb, ioffset, 4, FALSE);
5666                                                 proto_tree_add_item(atree, hf_nds_node, tvb, ioffset+4, 6, FALSE);
5667                                                 proto_tree_add_item(atree, hf_nds_socket, tvb, ioffset+10, 2, FALSE);
5668                                                 break;
5669                                         case NDS_PTYPE_IP:
5670                                                 proto_tree_add_item(atree, hf_nds_port, tvb, ioffset, 2, FALSE);
5671                                                 proto_tree_add_item(atree, hf_add_ref_ip, tvb, ioffset+2, 4, FALSE);
5672                                                 break;
5673                                         case NDS_PTYPE_UDP:
5674                                                 proto_tree_add_item(atree, hf_nds_port, tvb, ioffset, 2, FALSE);
5675                                                 proto_tree_add_item(atree, hf_add_ref_udp, tvb, ioffset+2, 4, FALSE);
5676                                                 break;
5677                                         case NDS_PTYPE_TCP:
5678                                                 proto_tree_add_item(atree, hf_nds_port, tvb, ioffset, 2, FALSE);
5679                                                 proto_tree_add_item(atree, hf_add_ref_tcp, tvb, ioffset+2, 4, FALSE);
5680                                                 break;
5681                                         case NDS_PTYPE_URL:
5682                                         case NDS_PTYPE_DNS:
5683                                                 get_string(tvb, ioffset, value3, values->vstring);
5684                                                 proto_tree_add_string(atree, hf_value_string, tvb, ioffset,
5685                                                       value3, values->vstring);
5686                                                 break;
5687                                         default:
5688                                                 break;
5689                                 }
5690                                 ioffset = ioffset + value3;
5691                                 ioffset += align_4(tvb, ioffset);
5692                         }
5693                         break;
5694
5695                 case MVTYPE_PROC_ENTRY_SPECIFIERS: /* Process Entry Specifiers */
5696                         value2 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
5697                         values->vstring = (char *)match_strval(value2, es_type);
5698                         if (values->vstring == NULL)
5699                         {
5700                                 values->vstring = "No ES Type Found";
5701                         }
5702                         esitem = proto_tree_add_string_format(ntree, hf_es_type, tvb, ioffset,
5703                                 4, values->vstring, "Output Entry Specifier - %s", values->vstring);
5704                         estree = proto_item_add_subtree(esitem, ett_nds);
5705                         ioffset = ioffset + 4;
5706                         ioffset = print_es_type(estree, tvb, values, value2, ioffset);
5707                         value3 = tvb_get_letohl(tvb, ioffset);   /* ES Type */
5708                         values->vstring = (char *)match_strval(value3, es_type);
5709                         if (values->vstring == NULL)
5710                         {
5711                                 values->vstring = "No ES Type Found";
5712                         }
5713                         esitem = proto_tree_add_string_format(ntree, hf_es_type, tvb, ioffset,
5714                                 4, values->vstring, "Input Entry Specifier - %s", values->vstring);
5715                         estree = proto_item_add_subtree(esitem, ett_nds);
5716                         ioffset = ioffset + 4;
5717                         ioffset = print_es_type(estree, tvb, values, value3, ioffset);
5718                         /* values.vstring is being overwritten. So store the resolve name to a global value */
5719                         g_strlcpy(mv_resolve_name_string, values->vstring, 128);
5720                         value4 = tvb_get_letohl(tvb, ioffset);
5721                                 aitem = proto_tree_add_uint_format(ntree, hf_referral_record, tvb, ioffset, 4,
5722                                     value4, "Referral Protocols - %d", value4);
5723                         atree = proto_item_add_subtree(aitem, ett_nds);
5724                         ioffset += 4;
5725                         for (i = 0 ; i < value4; i++ )
5726                         {
5727                                value5 = tvb_get_letohl(tvb, ioffset);
5728                                valuestr = match_strval(value5, nds_protocol_type);
5729                                if (valuestr == NULL)
5730                                {
5731                                                valuestr="(Undefined Protocol)";
5732                                }
5733                                proto_tree_add_string_format(atree, hf_value_string, tvb, ioffset,
5734                                4, valuestr, "Protocol -> %s", valuestr);
5735                                ioffset = ioffset+4;
5736                         }
5737                         value6 = tvb_get_letohl(tvb, ioffset);
5738                                 aitem = proto_tree_add_uint_format(ntree, hf_referral_record, tvb, ioffset, 4,
5739                                     value6, "Tree Walking Protocols - %d", value6);
5740                         atree = proto_item_add_subtree(aitem, ett_nds);
5741                         ioffset += 4;
5742                         for (i = 0 ; i < value6; i++ )
5743                         {
5744                                value7 = tvb_get_letohl(tvb, ioffset);
5745                                valuestr = match_strval(value7, nds_protocol_type);
5746                                if (valuestr == NULL)
5747                                {
5748                                                valuestr="(Undefined Protocol)";
5749                                }
5750                                proto_tree_add_string_format(atree, hf_value_string, tvb, ioffset,
5751                                4, valuestr, "Protocol -> %s", valuestr);
5752                                ioffset = ioffset+4;
5753                         }
5754                         values->vstring = " ";
5755                         break;
5756
5757                 case MVTYPE_PRINT_TIMESTAMP:    /* Print Timestamp */
5758                         replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
5759                         proto_tree_add_item(ncp_tree, hf_nds_replica_num, tvb, ioffset,
5760                                 2, replica_num);
5761                         ioffset = ioffset + 2;
5762                         event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
5763                         proto_tree_add_item(ncp_tree, hf_nds_event_num, tvb, ioffset,
5764                                 2, event_num);
5765                         ioffset = ioffset + 2;
5766                         /* fall through */
5767
5768                 case MVTYPE_LIST_PARTITIONS:    /* List Partitions */
5769                         number_of_referrals = values->vvalue;
5770                         /* A bad packet could put us in a tight loop so trap for anything
5771                          * over 256 referals.
5772                          */
5773                         if (number_of_referrals > 256) {
5774                             proto_tree_add_text(ntree, tvb, 0, 0, "[ Bad referal at offset: %u ]", ioffset);
5775                             THROW(ReportedBoundsError);
5776                             break;
5777                         }
5778                         for (i = 0; i < number_of_referrals; i++)
5779                         {
5780                                 bvalue = 0x00000001;
5781
5782                                 for (r = 0 ; r < 32; r++ )
5783                                 {
5784                                         oldioffset = ioffset;
5785                                         if (values->vflags & bvalue)
5786                                         {
5787                                                 switch(bvalue)
5788                                                 {
5789                                                         case 0x00000001:                /* Information Flags */
5790                                                                 temp_values.vvalue = tvb_get_letohs(tvb, ioffset);
5791                                                                 temp_values.vtype = VTYPE_BITFIELD;
5792                                                                 temp_values.vstring = mval_buf.buffer;
5793                                                                 temp_values.vdesc = "Information Flags (low) Byte:";
5794                                                                 temp_values.vlength = 2;
5795                                                                 temp_values.hfname= hf_nds_rflags;
5796                                                                 temp_values.voffset = ioffset;
5797                                                                 temp_values.bit1 = "Output Flags";
5798                                                                 temp_values.bit1hfname = hf_bit1infoflagsl;
5799                                                                 temp_values.bit2 = "Entry ID";
5800                                                                 temp_values.bit2hfname = hf_bit2infoflagsl;
5801                                                                 temp_values.bit3 = "Entry Flags";
5802                                                                 temp_values.bit3hfname = hf_bit3infoflagsl;
5803                                                                 temp_values.bit4 = "Subordinate Count";
5804                                                                 temp_values.bit4hfname = hf_bit4infoflagsl;
5805                                                                 temp_values.bit5 = "Modification Time";
5806                                                                 temp_values.bit5hfname = hf_bit5infoflagsl;
5807                                                                 temp_values.bit6 = "Modification Timestamp";
5808                                                                 temp_values.bit6hfname = hf_bit6infoflagsl;
5809                                                                 temp_values.bit7 = "Creation Timestamp";
5810                                                                 temp_values.bit7hfname = hf_bit7infoflagsl;
5811                                                                 temp_values.bit8 = "Partition Root ID";
5812                                                                 temp_values.bit8hfname = hf_bit8infoflagsl;
5813                                                                 temp_values.bit9 = "Parent ID";
5814                                                                 temp_values.bit9hfname = hf_bit9infoflagsl;
5815                                                                 temp_values.bit10 = "Revision Count";
5816                                                                 temp_values.bit10hfname = hf_bit10infoflagsl;
5817                                                                 temp_values.bit11 = "Replica Type";
5818                                                                 temp_values.bit11hfname = hf_bit11infoflagsl;
5819                                                                 temp_values.bit12 = "Base Class";
5820                                                                 temp_values.bit12hfname = hf_bit12infoflagsl;
5821                                                                 temp_values.bit13 = "Relative Distinguished Name";
5822                                                                 temp_values.bit13hfname = hf_bit13infoflagsl;
5823                                                                 temp_values.bit14 = "Distinguished Name";
5824                                                                 temp_values.bit14hfname = hf_bit14infoflagsl;
5825                                                                 temp_values.bit15 = "Root Distinguished Name";
5826                                                                 temp_values.bit15hfname = hf_bit15infoflagsl;
5827                                                                 temp_values.bit16 = "Parent Distinguished Name";
5828                                                                 temp_values.bit16hfname = hf_bit16infoflagsl;
5829                                                                 process_bitfield(ntree, tvb, &temp_values);
5830                                                                 ioffset = ioffset+2;
5831                                                                 temp_values.vvalue = tvb_get_letohs(tvb, ioffset);
5832                                                                 temp_values.vtype = VTYPE_BITFIELD;
5833                                                                 temp_values.vstring = mval_buf.buffer;
5834                                                                 temp_values.vdesc = "Information Flags (high) Byte:";
5835                                                                 temp_values.vlength = 2;
5836                                                                 temp_values.hfname= hf_nds_rflags;
5837                                                                 temp_values.voffset = ioffset;
5838                                                                 temp_values.bit1 = "Purge Time";
5839                                                                 temp_values.bit1hfname = hf_bit1infoflagsh;
5840                                                                 temp_values.bit2 = "Dereference Base Class";
5841                                                                 temp_values.bit2hfname = hf_bit2infoflagsh;
5842                                                                 temp_values.bit3 = "Not Defined";
5843                                                                 temp_values.bit3hfname = hf_bit3infoflagsh;
5844                                                                 temp_values.bit4 = "Not Defined";
5845                                                                 temp_values.bit4hfname = hf_bit4infoflagsh;
5846                                                                 temp_values.bit5 = "Not Defined";
5847                                                                 temp_values.bit5hfname = hf_bit5infoflagsh;
5848                                                                 temp_values.bit6 = "Not Defined";
5849                                                                 temp_values.bit6hfname = hf_bit6infoflagsh;
5850                                                                 temp_values.bit7 = "Not Defined";
5851                                                                 temp_values.bit7hfname = hf_bit7infoflagsh;
5852                                                                 temp_values.bit8 = "Not Defined";
5853                                                                 temp_values.bit8hfname = hf_bit8infoflagsh;
5854                                                                 temp_values.bit9 = "Not Defined";
5855                                                                 temp_values.bit9hfname = hf_bit9infoflagsh;
5856                                                                 temp_values.bit10 = "Not Defined";
5857                                                                 temp_values.bit10hfname = hf_bit10infoflagsh;
5858                                                                 temp_values.bit11 = "Not Defined";
5859                                                                 temp_values.bit11hfname = hf_bit11infoflagsh;
5860                                                                 temp_values.bit12 = "Not Defined";
5861                                                                 temp_values.bit12hfname = hf_bit12infoflagsh;
5862                                                                 temp_values.bit13 = "Not Defined";
5863                                                                 temp_values.bit13hfname = hf_bit13infoflagsh;
5864                                                                 temp_values.bit14 = "Not Defined";
5865                                                                 temp_values.bit14hfname = hf_bit14infoflagsh;
5866                                                                 temp_values.bit15 = "Not Defined";
5867                                                                 temp_values.bit15hfname = hf_bit15infoflagsh;
5868                                                                 temp_values.bit16 = "Not Defined";
5869                                                                 temp_values.bit16hfname = hf_bit16infoflagsh;
5870                                                                 process_bitfield(ntree, tvb, &temp_values);
5871                                                                 ioffset = ioffset+2;
5872                                                                 break;
5873                                                         case 0x00000002:                /* Entry ID */
5874                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5875                                                                 proto_tree_add_uint_format(ntree, hf_nds_eid, tvb, ioffset,
5876                                                                         4, value1, "Entry ID %08x", value1);
5877                                                                 ioffset = ioffset + 4;
5878                                                                 break;
5879                                                         case 0x00000004:                /* Entry Flags */
5880                                                                 temp_values.vvalue = tvb_get_letohl(tvb, ioffset);
5881                                                                 temp_values.vtype = VTYPE_BITFIELD;
5882                                                                 temp_values.vstring = mval_buf.buffer;
5883                                                                 temp_values.vdesc = "Entry Flags:";
5884                                                                 temp_values.vlength = 2;
5885                                                                 temp_values.hfname= hf_nds_eflags;
5886                                                                 temp_values.voffset = ioffset;
5887                                                                 temp_values.bit1 = "Alias Entry";
5888                                                                 temp_values.bit1hfname = hf_bit1eflags;
5889                                                                 temp_values.bit2 = "Partition Root";
5890                                                                 temp_values.bit2hfname = hf_bit2eflags;
5891                                                                 temp_values.bit3 = "Container Entry";
5892                                                                 temp_values.bit3hfname = hf_bit3eflags;
5893                                                                 temp_values.bit4 = "Container Alias";
5894                                                                 temp_values.bit4hfname = hf_bit4eflags;
5895                                                                 temp_values.bit5 = "Matches List Filter";
5896                                                                 temp_values.bit5hfname = hf_bit5eflags;
5897                                                                 temp_values.bit6 = "Reference Entry";
5898                                                                 temp_values.bit6hfname = hf_bit6eflags;
5899                                                                 temp_values.bit7 = "40x Reference Entry";
5900                                                                 temp_values.bit7hfname = hf_bit7eflags;
5901                                                                 temp_values.bit8 = "Back Linked";
5902                                                                 temp_values.bit8hfname = hf_bit8eflags;
5903                                                                 temp_values.bit9 = "New Entry";
5904                                                                 temp_values.bit9hfname = hf_bit9eflags;
5905                                                                 temp_values.bit10 = "Temporary Reference";
5906                                                                 temp_values.bit10hfname = hf_bit10eflags;
5907                                                                 temp_values.bit11 = "Audited";
5908                                                                 temp_values.bit11hfname = hf_bit11eflags;
5909                                                                 temp_values.bit12 = "Entry Not Present";
5910                                                                 temp_values.bit12hfname = hf_bit12eflags;
5911                                                                 temp_values.bit13 = "Entry Verify CTS";
5912                                                                 temp_values.bit13hfname = hf_bit13eflags;
5913                                                                 temp_values.bit14 = "Entry Damaged";
5914                                                                 temp_values.bit14hfname = hf_bit14eflags;
5915                                                                 temp_values.bit15 = "Not Defined";
5916                                                                 temp_values.bit15hfname = hf_bit15eflags;
5917                                                                 temp_values.bit16 = "Not Defined";
5918                                                                 temp_values.bit16hfname = hf_bit16eflags;
5919                                                                 process_bitfield(ntree, tvb, &temp_values);
5920                                                                 ioffset = ioffset+4;
5921                                                                 break;
5922                                                         case 0x0000008:                 /* Subordinate Count */
5923                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5924                                                                 proto_tree_add_uint_format(ntree, hf_sub_count, tvb, ioffset,
5925                                                                         4, value1, "Subordinate Count %d", value1);
5926                                                                 ioffset = ioffset + 4;
5927                                                                 break;
5928                                                         case 0x0000010:                 /* Modification Time */
5929                                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5930                                                                 ns.nsecs = 0;
5931                                                                 proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
5932                                                                         4, &ns, "Modification Time: %s", abs_time_to_str(&ns));
5933                                                                 ioffset = ioffset + 4;
5934                                                                 break;
5935                                                         case 0x0000020:                 /* Modification Timestamp */
5936                                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5937                                                                 ns.nsecs = 0;
5938                                                                 proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
5939                                                                         4, &ns, "Modification Timestamp: %s", abs_time_to_str(&ns));
5940                                                                 ioffset = ioffset + 4;
5941                                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
5942                                                                 proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset,
5943                                                                         2, replica_num);
5944                                                                 ioffset = ioffset + 2;
5945                                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
5946                                                                 proto_tree_add_item(ntree, hf_nds_event_num, tvb, ioffset,
5947                                                                         2, event_num);
5948                                                                 ioffset = ioffset + 2;
5949                                                                 break;
5950                                                         case 0x0000040:                 /* Creation Timestamp */
5951                                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
5952                                                                 ns.nsecs = 0;
5953                                                                 proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
5954                                                                         4, &ns, "Creation Timestamp: %s", abs_time_to_str(&ns));
5955                                                                 ioffset = ioffset + 4;
5956                                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
5957                                                                 proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset,
5958                                                                         2, replica_num);
5959                                                                 ioffset = ioffset + 2;
5960                                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
5961                                                                 proto_tree_add_item(ntree, hf_nds_event_num, tvb, ioffset,
5962                                                                         2, event_num);
5963                                                                 ioffset = ioffset + 2;
5964                                                                 break;
5965                                                         case 0x00000080:                /* Partition Root ID */
5966                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5967                                                                 proto_tree_add_uint_format(ntree, hf_nds_partition_root_id, tvb, ioffset,
5968                                                                         4, value1, "Partition Root ID %08x", value1);
5969                                                                 ioffset = ioffset + 4;
5970                                                                 break;
5971                                                         case 0x00000100:                /* Parent ID */
5972                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5973                                                                 proto_tree_add_uint_format(ntree, hf_nds_parent, tvb, ioffset,
5974                                                                         4, value1, "Parent ID %08x", value1);
5975                                                                 ioffset = ioffset + 4;
5976                                                                 break;
5977                                                         case 0x00000200:                /* Revision Count */
5978                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5979                                                                 proto_tree_add_uint_format(ntree, hf_nds_revision, tvb, ioffset,
5980                                                                         4, value1, "Revision Count %d", value1);
5981                                                                 ioffset = ioffset + 4;
5982                                                                 break;
5983                                                         case 0x00000400:                /* Replica Type & State */
5984                                                                 value1 = tvb_get_letohl(tvb, ioffset);
5985                                                                 value2 = value1 & 0x00ff;
5986                                                                 temp_values.vstring = (char *)match_strval(value2, nds_replica_type);
5987                                                                 if (temp_values.vstring == NULL)
5988                                                                 {
5989                                                                         temp_values.vstring = "No Replica Type Found";
5990                                                                 }
5991                                                                 proto_tree_add_string(ntree, hf_replica_type, tvb, ioffset,
5992                                                                 4, temp_values.vstring);
5993                                                                 value3 = value1 & 0xff00;
5994                                                                 temp_values.vstring = (char *)match_strval(value3, nds_replica_state);
5995                                                                 if (temp_values.vstring == NULL)
5996                                                                 {
5997                                                                         temp_values.vstring = "No Replica State Found";
5998                                                                 }
5999                                                                 proto_tree_add_string(ntree, hf_replica_state, tvb, ioffset,
6000                                                                 4, temp_values.vstring);
6001                                                                 ioffset = ioffset + 4;
6002                                                                 break;
6003                                                         case 0x00000800:                /* Base Class */
6004                                                                 value1 = tvb_get_letohl(tvb, ioffset);
6005                                                                 ioffset = ioffset + 4;
6006                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6007                                                                 temp_values.vstring = mval_buf.buffer;
6008                                                                 proto_tree_add_string(ntree, hf_nds_base, tvb, ioffset,
6009                                                                         value1, temp_values.vstring);
6010                                                                 ioffset = ioffset + value1;
6011                                                                 break;
6012                                                         case 0x00001000:                /* Relative Distinguished Name */
6013                                                                 value1 = tvb_get_letohl(tvb, ioffset);
6014                                                                 ioffset = ioffset + 4;
6015                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6016                                                                 temp_values.vstring = mval_buf.buffer;
6017                                                                 proto_tree_add_string(ntree, hf_nds_relative_dn, tvb, ioffset,
6018                                                                         value1, temp_values.vstring);
6019                                                                 ioffset = ioffset + value1;
6020                                                                 break;
6021                                                         case 0x00002000:                /* Distinguished Name */
6022                                                                 value1 = tvb_get_letohl(tvb, ioffset);
6023                                                                 ioffset = ioffset + 4;
6024                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6025                                                                 temp_values.vstring = mval_buf.buffer;
6026                                                                 proto_tree_add_string(ntree, hf_nds_name, tvb, ioffset,
6027                                                                         value1, temp_values.vstring);
6028                                                                 ioffset = ioffset + value1;
6029                                                                 break;
6030                                                         case 0x00004000:                /* Root Distinguished Name */
6031                                                                 value1 = tvb_get_letohl(tvb, ioffset);
6032                                                                 ioffset = ioffset + 4;
6033                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6034                                                                 temp_values.vstring = mval_buf.buffer;
6035                                                                 proto_tree_add_string(ntree, hf_nds_name, tvb, ioffset,
6036                                                                         value1, temp_values.vstring);
6037                                                                 ioffset = ioffset + value1;
6038                                                                 break;
6039                                                         case 0x00008000:                /* Parent Distinguished Name */
6040                                                                 value1 = tvb_get_letohl(tvb, ioffset);
6041                                                                 ioffset = ioffset + 4;
6042                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6043                                                                 temp_values.vstring = mval_buf.buffer;
6044                                                                 proto_tree_add_string(ntree, hf_nds_name, tvb, ioffset,
6045                                                                         value1, temp_values.vstring);
6046                                                                 ioffset = ioffset + value1;
6047                                                                 break;
6048                                                         case 0x00010000:                /* Purge Time */
6049                                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
6050                                                                 ns.nsecs = 0;
6051                                                                 proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
6052                                                                         4, &ns, "Purge Time: %s", abs_time_to_str(&ns));
6053                                                                 ioffset = ioffset + 4;
6054                                                                 break;
6055                                                         case 0x00020000:                /* Dereference Base Class */
6056                                                                 value1 = tvb_get_letohl(tvb, ioffset);
6057                                                                 ioffset = ioffset + 4;
6058                                                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6059                                                                 temp_values.vstring = mval_buf.buffer;
6060                                                                 proto_tree_add_string(ntree, hf_deref_base, tvb, ioffset,
6061                                                                         value1, temp_values.vstring);
6062                                                                 ioffset = ioffset + value1;
6063                                                                 break;
6064                                                         default:
6065                                                                 break;
6066
6067                                                 }
6068                                                 ioffset += align_4(tvb, ioffset);
6069                                         }
6070                                         bvalue = bvalue*2;
6071                                         /* We could loop forever so check to see if bvalue has wrapped to 0.
6072                                          * if so then just abort loop.
6073                                          */
6074                                         if (bvalue==0) {
6075                                                break;
6076                                         }
6077                                         if(tvb_length_remaining(tvb, ioffset) < 4 )
6078                                         {
6079                                                 break;
6080                                         }
6081                                 }
6082                                 if(tvb_length_remaining(tvb, ioffset) < 4 )
6083                                 {
6084                                         break;
6085                                 }
6086                         }
6087                         break;
6088
6089                 case MVTYPE_CLASS_NAMES:        /* Class Names */
6090                         number_of_referrals = values->vvalue;
6091                         for (i = 0; i < number_of_referrals; i++)
6092                         {
6093                                 ioffset += align_4(tvb, ioffset);
6094                                 value1 = tvb_get_letohl(tvb, ioffset);
6095                                 ioffset = ioffset + 4;
6096                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6097                                 temp_values.vstring = mval_buf.buffer;
6098                                 sub1item = proto_tree_add_string(ntree, hf_nds_base_class, tvb, ioffset,
6099                                         value1, temp_values.vstring);
6100                                 sub1tree = proto_item_add_subtree(sub1item, ett_nds);
6101                                 ioffset = ioffset + value1;
6102                                 ioffset += align_4(tvb, ioffset);
6103                                 if(values->vflags != 0)
6104                                 {
6105                                         temp_values.vvalue = tvb_get_letohl(tvb, ioffset);
6106                                         temp_values.vtype = VTYPE_BITFIELD;
6107                                         temp_values.vstring = mval_buf.buffer;
6108                                         temp_values.vdesc = "Class Flags:";
6109                                         temp_values.vlength = 2;
6110                                         temp_values.hfname= hf_nds_cflags;
6111                                         temp_values.voffset = ioffset;
6112                                         temp_values.bit1 = "Container";
6113                                         temp_values.bit1hfname = hf_bit1cflags;
6114                                         temp_values.bit2 = "Effective";
6115                                         temp_values.bit2hfname = hf_bit2cflags;
6116                                         temp_values.bit3 = "Class Definition Cannot be Removed";
6117                                         temp_values.bit3hfname = hf_bit3cflags;
6118                                         temp_values.bit4 = "Ambiguous Naming";
6119                                         temp_values.bit4hfname = hf_bit4cflags;
6120                                         temp_values.bit5 = "Ambiguous Containment";
6121                                         temp_values.bit5hfname = hf_bit5cflags;
6122                                         temp_values.bit6 = "Auxiliary";
6123                                         temp_values.bit6hfname = hf_bit6cflags;
6124                                         temp_values.bit7 = "Operational";
6125                                         temp_values.bit7hfname = hf_bit7cflags;
6126                                         temp_values.bit8 = "Sparse Required";
6127                                         temp_values.bit8hfname = hf_bit8cflags;
6128                                         temp_values.bit9 = "Sparse Operational";
6129                                         temp_values.bit9hfname = hf_bit9cflags;
6130                                         temp_values.bit10 = "Not Defined";
6131                                         temp_values.bit10hfname = hf_bit10cflags;
6132                                         temp_values.bit11 = "Not Defined";
6133                                         temp_values.bit11hfname = hf_bit11cflags;
6134                                         temp_values.bit12 = "Not Defined";
6135                                         temp_values.bit12hfname = hf_bit12cflags;
6136                                         temp_values.bit13 = "Not Defined";
6137                                         temp_values.bit13hfname = hf_bit13cflags;
6138                                         temp_values.bit14 = "Not Defined";
6139                                         temp_values.bit14hfname = hf_bit14cflags;
6140                                         temp_values.bit15 = "Not Defined";
6141                                         temp_values.bit15hfname = hf_bit15cflags;
6142                                         temp_values.bit16 = "Not Defined";
6143                                         temp_values.bit16hfname = hf_bit16cflags;
6144                                         process_bitfield(sub1tree, tvb, &temp_values);
6145                                         ioffset = ioffset+4;
6146                                         if(values->vflags != 5)
6147                                         {
6148                                                 value1 = tvb_get_letohl(tvb, ioffset); /* length of field */
6149                                                 length_remaining = tvb_length_remaining(tvb, ioffset);
6150                                                 if(length_remaining == -1 || value1 > (guint32) length_remaining)
6151                                                 {
6152                                                          break;
6153                                                 }
6154                                                 ioffset += 4;
6155                                                 tvb_ensure_bytes_exist(tvb, ioffset, value1);
6156                                                 proto_tree_add_bytes(sub1tree, hf_nds_asn1, tvb, ioffset, value1, tvb_get_ptr(tvb, ioffset, value1));
6157                                                 ioffset += value1;
6158                                                 ioffset += (value1%2);
6159                                         }
6160                                         if(values->vflags == 1 || values->vflags == 2 || values->vflags == 4)
6161                                         {
6162                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Super Classes */
6163                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6164                                                         4, value1, "Super Classes %d", value1);
6165                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6166                                                 ioffset = ioffset + 4;
6167                                                 for (r = 0; r < value1; r++)
6168                                                 {
6169                                                         value2 = tvb_get_letohl(tvb, ioffset);
6170                                                         ioffset = ioffset + 4;
6171                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6172                                                         temp_values.vstring = mval_buf.buffer;
6173                                                         proto_tree_add_string(sub2tree, hf_nds_super, tvb, ioffset,
6174                                                                 value2, temp_values.vstring);
6175                                                         ioffset = ioffset + value2;
6176                                                         ioffset += align_4(tvb, ioffset);
6177                                                 }
6178                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Containment Classes */
6179                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6180                                                         4, value1, "Containment Classes %d", value1);
6181                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6182                                                 ioffset = ioffset + 4;
6183                                                 for (r = 0; r < value1; r++)
6184                                                 {
6185                                                         value2 = tvb_get_letohl(tvb, ioffset);
6186                                                         ioffset = ioffset + 4;
6187                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6188                                                         temp_values.vstring = mval_buf.buffer;
6189                                                         proto_tree_add_string(sub2tree, hf_nds_base_class, tvb, ioffset,
6190                                                                 value2, temp_values.vstring);
6191                                                         ioffset = ioffset + value2;
6192                                                         ioffset += align_4(tvb, ioffset);
6193                                                 }
6194                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Naming Attributes */
6195                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6196                                                         4, value1, "Naming Attributes %d", value1);
6197                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6198                                                 ioffset = ioffset + 4;
6199                                                 for (r = 0; r < value1; r++)
6200                                                 {
6201                                                         value2 = tvb_get_letohl(tvb, ioffset);
6202                                                         ioffset = ioffset + 4;
6203                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6204                                                         temp_values.vstring = mval_buf.buffer;
6205                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6206                                                                 value2, temp_values.vstring);
6207                                                         ioffset = ioffset + value2;
6208                                                         ioffset += align_4(tvb, ioffset);
6209                                                 }
6210                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Mandatory Attributes */
6211                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6212                                                         4, value1, "Mandatory Attributes %d", value1);
6213                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6214                                                 ioffset = ioffset + 4;
6215                                                 for (r = 0; r < value1; r++)
6216                                                 {
6217                                                         value2 = tvb_get_letohl(tvb, ioffset);
6218                                                         ioffset = ioffset + 4;
6219                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6220                                                         temp_values.vstring = mval_buf.buffer;
6221                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6222                                                                 value2, temp_values.vstring);
6223                                                         ioffset = ioffset + value2;
6224                                                         ioffset += align_4(tvb, ioffset);
6225                                                 }
6226                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Optional Attributes */
6227                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6228                                                         4, value1, "Optional Attributes %d", value1);
6229                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6230                                                 ioffset = ioffset + 4;
6231                                                 for (r = 0; r < value1; r++)
6232                                                 {
6233                                                         ioffset += align_4(tvb, ioffset);
6234                                                         value2 = tvb_get_letohl(tvb, ioffset);
6235                                                         ioffset = ioffset + 4;
6236                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6237                                                         temp_values.vstring = mval_buf.buffer;
6238                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6239                                                                 value2, temp_values.vstring);
6240                                                         ioffset = ioffset + value2;
6241                                                         if(tvb_length_remaining(tvb, ioffset) < 4 )
6242                                                         {
6243                                                                 break;
6244                                                         }
6245                                                 }
6246                                         }
6247                                         /*if(values->vflags == 2 || values->vflags == 4)*/   /* Class Definitions of Super Classes */
6248                                         if(values->vflags == 4)   /* Class Definitions of Super Classes */
6249                                         {
6250                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Containment Classes */
6251                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6252                                                         4, value1, "Containment Classes %d", value1);
6253                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6254                                                 ioffset = ioffset + 4;
6255                                                 for (r = 0; r < value1; r++)
6256                                                 {
6257                                                         value2 = tvb_get_letohl(tvb, ioffset);
6258                                                         ioffset = ioffset + 4;
6259                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6260                                                         temp_values.vstring = mval_buf.buffer;
6261                                                         proto_tree_add_string(sub2tree, hf_nds_base_class, tvb, ioffset,
6262                                                                 value2, temp_values.vstring);
6263                                                         ioffset = ioffset + value2;
6264                                                         ioffset += align_4(tvb, ioffset);
6265                                                 }
6266                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Naming Attributes */
6267                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6268                                                         4, value1, "Naming Attributes %d", value1);
6269                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6270                                                 ioffset = ioffset + 4;
6271                                                 for (r = 0; r < value1; r++)
6272                                                 {
6273                                                         value2 = tvb_get_letohl(tvb, ioffset);
6274                                                         ioffset = ioffset + 4;
6275                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6276                                                         temp_values.vstring = mval_buf.buffer;
6277                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6278                                                                 value2, temp_values.vstring);
6279                                                         ioffset = ioffset + value2;
6280                                                         ioffset += align_4(tvb, ioffset);
6281                                                 }
6282                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Mandatory Attributes */
6283                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6284                                                         4, value1, "Mandatory Attributes %d", value1);
6285                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6286                                                 ioffset = ioffset + 4;
6287                                                 for (r = 0; r < value1; r++)
6288                                                 {
6289                                                         value2 = tvb_get_letohl(tvb, ioffset);
6290                                                         ioffset = ioffset + 4;
6291                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6292                                                         temp_values.vstring = mval_buf.buffer;
6293                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6294                                                                 value2, temp_values.vstring);
6295                                                         ioffset = ioffset + value2;
6296                                                         ioffset += align_4(tvb, ioffset);
6297                                                 }
6298                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Optional Attributes */
6299                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6300                                                         4, value1, "Optional Attributes %d", value1);
6301                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6302                                                 ioffset = ioffset + 4;
6303                                                 for (r = 0; r < value1; r++)
6304                                                 {
6305                                                         value2 = tvb_get_letohl(tvb, ioffset);
6306                                                         ioffset = ioffset + 4;
6307                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6308                                                         temp_values.vstring = mval_buf.buffer;
6309                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6310                                                                 value2, temp_values.vstring);
6311                                                         ioffset = ioffset + value2;
6312                                                         ioffset += align_4(tvb, ioffset);
6313                                                 }
6314                                                 value1 = tvb_get_letohl(tvb, ioffset);    /* Default ACL */
6315                                                 proto_tree_add_uint_format(sub1tree, hf_nds_eid, tvb, ioffset,
6316                                                         4, value1, "Default ACL %08x", value1);
6317                                                 ioffset = ioffset + 4;
6318                                                 if(tvb_length_remaining(tvb, ioffset) < 4 )
6319                                                 {
6320                                                         break;
6321                                                 }
6322                                         }
6323                                         if(values->vflags == 5)   /* Base Class Definitions */
6324                                         {
6325                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
6326                                                 ns.nsecs = 0;
6327                                                 proto_tree_add_time_format(sub1tree, hf_es_seconds, tvb, ioffset,
6328                                                         4, &ns, "Creation Timestamp: %s", abs_time_to_str(&ns));
6329                                                 ioffset = ioffset + 4;
6330                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
6331                                                 proto_tree_add_item(sub1tree, hf_nds_replica_num, tvb, ioffset,
6332                                                         2, replica_num);
6333                                                 ioffset = ioffset + 2;
6334                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
6335                                                 proto_tree_add_item(sub1tree, hf_nds_event_num, tvb, ioffset,
6336                                                         2, event_num);
6337                                                 ioffset = ioffset + 2;
6338                                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
6339                                                 ns.nsecs = 0;
6340                                                 proto_tree_add_time_format(sub1tree, hf_es_seconds, tvb, ioffset,
6341                                                         4, &ns, "Modification Timestamp: %s", abs_time_to_str(&ns));
6342                                                 ioffset = ioffset + 4;
6343                                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
6344                                                 proto_tree_add_item(sub1tree, hf_nds_replica_num, tvb, ioffset,
6345                                                         2, replica_num);
6346                                                 ioffset = ioffset + 2;
6347                                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
6348                                                 proto_tree_add_item(sub1tree, hf_nds_event_num, tvb, ioffset,
6349                                                         2, event_num);
6350                                                 ioffset = ioffset + 2;
6351                                                 /* Class Definition */
6352                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Super Classes */
6353                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6354                                                         4, value1, "Super Classes %d", value1);
6355                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6356                                                 ioffset = ioffset + 4;
6357                                                 for (r = 0; r < value1; r++)
6358                                                 {
6359                                                         value2 = tvb_get_letohl(tvb, ioffset);
6360                                                         ioffset = ioffset + 4;
6361                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6362                                                         temp_values.vstring = mval_buf.buffer;
6363                                                         proto_tree_add_string(sub2tree, hf_nds_super, tvb, ioffset,
6364                                                                 value2, temp_values.vstring);
6365                                                         ioffset = ioffset + value2;
6366                                                         ioffset += align_4(tvb, ioffset);
6367                                                 }
6368                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Containment Classes */
6369                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6370                                                         4, value1, "Containment Classes %d", value1);
6371                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6372                                                 ioffset = ioffset + 4;
6373                                                 for (r = 0; r < value1; r++)
6374                                                 {
6375                                                         value2 = tvb_get_letohl(tvb, ioffset);
6376                                                         ioffset = ioffset + 4;
6377                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6378                                                         temp_values.vstring = mval_buf.buffer;
6379                                                         proto_tree_add_string(sub2tree, hf_nds_base_class, tvb, ioffset,
6380                                                                 value2, temp_values.vstring);
6381                                                         ioffset = ioffset + value2;
6382                                                         ioffset += align_4(tvb, ioffset);
6383                                                 }
6384                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Naming Attributes */
6385                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6386                                                         4, value1, "Naming Attributes %d", value1);
6387                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6388                                                 ioffset = ioffset + 4;
6389                                                 for (r = 0; r < value1; r++)
6390                                                 {
6391                                                         value2 = tvb_get_letohl(tvb, ioffset);
6392                                                         ioffset = ioffset + 4;
6393                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6394                                                         temp_values.vstring = mval_buf.buffer;
6395                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6396                                                                 value2, temp_values.vstring);
6397                                                         ioffset = ioffset + value2;
6398                                                         ioffset += align_4(tvb, ioffset);
6399                                                 }
6400                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Mandatory Attributes */
6401                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6402                                                         4, value1, "Mandatory Attributes %d", value1);
6403                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6404                                                 ioffset = ioffset + 4;
6405                                                 for (r = 0; r < value1; r++)
6406                                                 {
6407                                                         value2 = tvb_get_letohl(tvb, ioffset);
6408                                                         ioffset = ioffset + 4;
6409                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6410                                                         temp_values.vstring = mval_buf.buffer;
6411                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6412                                                                 value2, temp_values.vstring);
6413                                                         ioffset = ioffset + value2;
6414                                                         ioffset += align_4(tvb, ioffset);
6415                                                 }
6416                                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Optional Attributes */
6417                                                 sub2item = proto_tree_add_uint_format(sub1tree, hf_nds_number_of_items, tvb, ioffset,
6418                                                         4, value1, "Optional Attributes %d", value1);
6419                                                 sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6420                                                 ioffset = ioffset + 4;
6421                                                 for (r = 0; r < value1; r++)
6422                                                 {
6423                                                         value2 = tvb_get_letohl(tvb, ioffset);
6424                                                         ioffset = ioffset + 4;
6425                                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6426                                                         temp_values.vstring = mval_buf.buffer;
6427                                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6428                                                                 value2, temp_values.vstring);
6429                                                         ioffset = ioffset + value2;
6430                                                         ioffset += align_4(tvb, ioffset);
6431                                                 }
6432                                                 value1 = tvb_get_letohl(tvb, ioffset);    /* Default ACL */
6433                                                 proto_tree_add_uint_format(sub1tree, hf_nds_eid, tvb, ioffset,
6434                                                         4, value1, "Default ACL %08x", value1);
6435                                                 ioffset = ioffset + 4;
6436                                                 if(tvb_length_remaining(tvb, ioffset) < 4 )
6437                                                 {
6438                                                         break;
6439                                                 }
6440                                         }
6441                                 }
6442                         }
6443                         break;
6444
6445                 case MVTYPE_MODIFY_CLASS:       /* Modify Class */
6446                         for (i = 1 ; i <= values->vvalue; i++ )   /* Attribute Names to add*/
6447                         {
6448                                 ioffset += align_4(tvb, ioffset);
6449                                 value1 = tvb_get_letohl(tvb, ioffset);
6450                                 ioffset = ioffset + 4;
6451                                 get_string(tvb, ioffset, value1, mval_buf.buffer);
6452                                 values->vstring = mval_buf.buffer;
6453                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
6454                                         value1, values->vstring);
6455                                 ioffset = ioffset + value1;
6456                         }
6457                         if(tvb_length_remaining(tvb, ioffset) < 4 )
6458                         {
6459                                 break;
6460                         }
6461                         ioffset += align_4(tvb, ioffset);
6462                         value1 = tvb_get_letohl(tvb, ioffset);
6463                         proto_tree_add_uint_format(ntree, hf_nds_att_del, tvb, ioffset,
6464                                 4, value1, "Attribute Names to Delete %d", value1);
6465                         ioffset = ioffset + 4;
6466                         for (i = 1 ; i <= value1; i++ )   /* Attribute Names to delete*/
6467                         {
6468                                 ioffset += align_4(tvb, ioffset);
6469                                 value2 = tvb_get_letohl(tvb, ioffset);
6470                                 ioffset = ioffset + 4;
6471                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
6472                                 values->vstring = mval_buf.buffer;
6473                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
6474                                         value2, values->vstring);
6475                                 ioffset = ioffset + value2;
6476                         }
6477                         if(tvb_length_remaining(tvb, ioffset) < 4 )
6478                         {
6479                                 break;
6480                         }
6481                         ioffset += align_4(tvb, ioffset);
6482                         value1 = tvb_get_letohl(tvb, ioffset);
6483                         proto_tree_add_uint_format(ntree, hf_nds_acl_add, tvb, ioffset,
6484                                 4, value1, "ACL Templates to Add %d", value1);
6485                         ioffset = ioffset + 4;
6486                         for (i = 1 ; i <= value1; i++ )   /* ACL templates to add*/
6487                         {
6488                                 ioffset += align_4(tvb, ioffset);
6489                                 value2 = tvb_get_letohl(tvb, ioffset);  /* Attribute Name */
6490                                 ioffset = ioffset + 4;
6491                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
6492                                 values->vstring = mval_buf.buffer;
6493                                 proto_tree_add_string(ntree, hf_nds_attribute_dn, tvb, ioffset,
6494                                         value2, values->vstring);
6495                                 ioffset = ioffset + value2;
6496                                 ioffset += align_4(tvb, ioffset);
6497                                 value2 = tvb_get_letohl(tvb, ioffset);  /* DN of Trustee */
6498                                 ioffset = ioffset + 4;
6499                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
6500                                 values->vstring = mval_buf.buffer;
6501                                 proto_tree_add_string(ntree, hf_nds_trustee_dn, tvb, ioffset,
6502                                         value2, values->vstring);
6503                                 ioffset = ioffset + value2;
6504                                 ioffset += align_4(tvb, ioffset);
6505                                 value1 = tvb_get_letohl(tvb, ioffset);
6506                                 proto_tree_add_uint_format(ntree, hf_nds_privileges, tvb, ioffset,
6507                                         4, value1, "Privileges 0x%08x", value1);
6508                                 ioffset = ioffset + 4;
6509                         }
6510                         if(tvb_length_remaining(tvb, ioffset) < 4 )
6511                         {
6512                                 break;
6513                         }
6514                         ioffset += align_4(tvb, ioffset);
6515                         value1 = tvb_get_letohl(tvb, ioffset);
6516                         proto_tree_add_uint_format(ntree, hf_nds_acl_del, tvb, ioffset,
6517                                 4, value1, "ACL Templates to Delete %d", value1);
6518                         ioffset = ioffset + 4;
6519                         for (i = 1 ; i <= value1; i++ )   /* ACL templates to delete*/
6520                         {
6521                                 ioffset += align_4(tvb, ioffset);
6522                                 value2 = tvb_get_letohl(tvb, ioffset);  /* Attribute Name */
6523                                 ioffset = ioffset + 4;
6524                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
6525                                 values->vstring = mval_buf.buffer;
6526                                 proto_tree_add_string(ntree, hf_nds_attribute_dn, tvb, ioffset,
6527                                         value2, values->vstring);
6528                                 ioffset = ioffset + value2;
6529                                 ioffset += align_4(tvb, ioffset);
6530                                 value2 = tvb_get_letohl(tvb, ioffset);  /* DN of Trustee */
6531                                 ioffset = ioffset + 4;
6532                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
6533                                 values->vstring = mval_buf.buffer;
6534                                 proto_tree_add_string(ntree, hf_nds_trustee_dn, tvb, ioffset,
6535                                         value2, values->vstring);
6536                                 ioffset = ioffset + value2;
6537                                 ioffset += align_4(tvb, ioffset);
6538                                 value1 = tvb_get_letohl(tvb, ioffset);  /* Privileges */
6539                                 proto_tree_add_uint_format(ntree, hf_nds_privileges, tvb, ioffset,
6540                                         4, value1, "Privileges 0x%08x", value1);
6541                                 ioffset = ioffset + 4;
6542                         }
6543                         break;
6544             case MVTYPE_PROCESS_TAGS: /* Process tags and paths depending on name type returned. */
6545                         switch (values->vflags) {
6546
6547                         case 8:  /* Tuned Name */
6548                             proto_tree_add_item(ntree, hf_nds_tune_mark, tvb, ioffset, 2, FALSE);
6549                             ioffset += 2;
6550                             value1 = tvb_get_letohs(tvb, ioffset);
6551                             valuestr = match_strval(value1, nds_tuned_tags);
6552                             if (valuestr == NULL)
6553                             {
6554                                             valuestr="(Undefined Tuned Name Tag)";
6555                             }
6556                             proto_tree_add_string_format(ntree, hf_value_string, tvb, ioffset,
6557                             2, valuestr, "Tuned Name Tag -> %s", valuestr);
6558                             ioffset += 2;
6559                             ioffset += align_4(tvb, ioffset);
6560                             if (value1 == 0) { /* RDN Hint - really just returns the dist name + timestamp info */
6561                                 value2 = tvb_get_letohl(tvb, ioffset);  /* Distinguished Name Len, String[len]*/
6562                                 ioffset = ioffset + 4;
6563                                 get_string(tvb, ioffset, value2, mval_buf.buffer);
6564                                 values->vstring = mval_buf.buffer;
6565                                 proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
6566                                         value2, values->vstring);
6567                                 ioffset += value2;
6568                                 ioffset += align_4(tvb, ioffset);
6569                                 ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
6570                                 ns.nsecs = 0;
6571                                 proto_tree_add_time_format(ntree, hf_es_seconds, tvb, ioffset,
6572                                         4, &ns, "Creation Timestamp: %s", abs_time_to_str(&ns));
6573                                 ioffset += 4;
6574                                 replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
6575                                 proto_tree_add_item(ntree, hf_nds_replica_num, tvb, ioffset,
6576                                         2, replica_num);
6577                                 ioffset = ioffset + 2;
6578                                 event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
6579                                 proto_tree_add_item(ntree, hf_nds_event_num, tvb, ioffset,
6580                                         2, event_num);
6581                                 ioffset = ioffset + 2;
6582                             }
6583                             else /* Process the full RDN history including ancestors */
6584                             {
6585                                 value1 = tvb_get_letohl(tvb, ioffset);
6586                                 sub1item = proto_tree_add_uint_format(ntree, hf_nds_acl_del, tvb, ioffset,
6587                                         4, value1, "Number of RDN Items %d", value1);
6588                                 sub1tree = proto_item_add_subtree(sub1item, ett_nds);
6589                                 ioffset = ioffset + 4;
6590                                 for (i=1; i <= value1; i++) {
6591
6592                                     sub2item = proto_tree_add_text(sub1tree, tvb, ioffset, 0, "Item %d", i);
6593                                     sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6594                                     ioffset += align_4(tvb, ioffset);
6595
6596                                     value5 = tvb_get_letohl(tvb, ioffset);
6597                                     valuestr = match_strval(value5, nds_tuned_item_tags);
6598                                     if (valuestr == NULL)
6599                                     {
6600                                                  valuestr="(Undefined Tuned Name Tag)";
6601                                     }
6602                                     if (value5 == 0) { /* Items are timestamp + Distinguished name (0 value == one entry)*/
6603                                         proto_tree_add_string_format(sub2tree, hf_value_string, tvb, ioffset,
6604                                             4, valuestr, "Item Tag -> %s", valuestr);
6605                                         ioffset += 4;
6606                                         ns.secs = tvb_get_letohl(tvb, ioffset);   /* Seconds */
6607                                         ns.nsecs = 0;
6608                                         proto_tree_add_time_format(sub2tree, hf_es_seconds, tvb, ioffset,
6609                                                 4, &ns, "Timestamp: %s", abs_time_to_str(&ns));
6610                                         ioffset += 4;
6611                                         replica_num = tvb_get_letohs(tvb, ioffset);   /* Replica */
6612                                         proto_tree_add_item(sub2tree, hf_nds_replica_num, tvb, ioffset,
6613                                                 2, replica_num);
6614                                         ioffset = ioffset + 2;
6615                                         event_num = tvb_get_letohs(tvb, ioffset);   /* Event */
6616                                         proto_tree_add_item(sub2tree, hf_nds_event_num, tvb, ioffset,
6617                                                 2, event_num);
6618                                         ioffset = ioffset + 2;
6619                                         value2 = tvb_get_letohl(tvb, ioffset);  /* Distinguished Name Len, String[len]*/
6620                                         ioffset = ioffset + 4;
6621                                         get_string(tvb, ioffset, value2, mval_buf.buffer);
6622                                         values->vstring = mval_buf.buffer;
6623                                         proto_tree_add_string(sub2tree, hf_mv_string, tvb, ioffset,
6624                                                 value2, values->vstring);
6625                                         ioffset += value2;
6626
6627                                     }
6628                             }
6629                             values->voffset=ioffset;
6630                             break;
6631                         default: /* All other name types are just a string */
6632                             get_string(tvb, ioffset, values->vlength, mval_buf.buffer);
6633                             values->vstring = mval_buf.buffer;
6634                             proto_tree_add_string(ntree, hf_mv_string, tvb, ioffset,
6635                                     values->vlength, values->vstring);
6636                             values->voffset=ioffset + values->vlength;
6637                             ioffset = values->voffset;
6638                             ioffset += align_4(tvb, ioffset);
6639                             break;
6640                         }
6641                         break;
6642                 }
6643                 break;
6644             case MVTYPE_PROCESS_ITERATOR: /* Process Iterator subverbs. */
6645                 temp_values.vvalue = tvb_get_letohl(tvb, ioffset);
6646
6647                 temp_values.vstring = (char *)match_strval(temp_values.vvalue, nds_info_type);
6648                 if(temp_values.vstring == NULL)
6649                 {
6650                         temp_values.vstring = "No Info Type Set";
6651                 }
6652                 /*g_strdup(value)*/
6653                 proto_tree_add_string(ntree, hf_nds_info_type, tvb, ioffset, 4, temp_values.vstring);
6654                 ioffset = ioffset + 4;
6655                 temp_values.vvalue = tvb_get_letohs(tvb, ioffset);
6656                 value5 = tvb_get_letohl(tvb, ioffset);
6657                 temp_values.vdesc = "Information Flags (low) Byte:";
6658                 temp_values.vlength = 2;
6659                 temp_values.hfname = hf_nds_rflags;
6660                 temp_values.voffset = ioffset;
6661                 temp_values.bit1 = "Output Flags";
6662                 temp_values.bit1hfname = hf_bit1infoflagsl;
6663                 temp_values.bit2 = "Entry ID";
6664                 temp_values.bit2hfname = hf_bit2infoflagsl;
6665                 temp_values.bit3 = "Entry Flags";
6666                 temp_values.bit3hfname = hf_bit3infoflagsl;
6667                 temp_values.bit4 = "Subordinate Count";
6668                 temp_values.bit4hfname = hf_bit4infoflagsl;
6669                 temp_values.bit5 = "Modification Time";
6670                 temp_values.bit5hfname = hf_bit5infoflagsl;
6671                 temp_values.bit6 = "Modification Timestamp";
6672                 temp_values.bit6hfname = hf_bit6infoflagsl;
6673                 temp_values.bit7 = "Creation Timestamp";
6674                 temp_values.bit7hfname = hf_bit7infoflagsl;
6675                 temp_values.bit8 = "Partition Root ID";
6676                 temp_values.bit8hfname = hf_bit8infoflagsl;
6677                 temp_values.bit9 = "Parent ID";
6678                 temp_values.bit9hfname = hf_bit9infoflagsl;
6679                 temp_values.bit10 = "Revision Count";
6680                 temp_values.bit10hfname = hf_bit10infoflagsl;
6681                 temp_values.bit11 = "Replica Type";
6682                 temp_values.bit11hfname = hf_bit11infoflagsl;
6683                 temp_values.bit12 = "Base Class";
6684                 temp_values.bit12hfname = hf_bit12infoflagsl;
6685                 temp_values.bit13 = "Relative Distinguished Name";
6686                 temp_values.bit13hfname = hf_bit13infoflagsl;
6687                 temp_values.bit14 = "Distinguished Name";
6688                 temp_values.bit14hfname = hf_bit14infoflagsl;
6689                 temp_values.bit15 = "Root Distinguished Name";
6690                 temp_values.bit15hfname = hf_bit15infoflagsl;
6691                 temp_values.bit16 = "Parent Distinguished Name";
6692                 temp_values.bit16hfname = hf_bit16infoflagsl;
6693                 process_bitfield(ntree, tvb, &temp_values);
6694                 ioffset = ioffset+2;
6695                 temp_values.vvalue = tvb_get_letohs(tvb, ioffset);
6696                 temp_values.vtype = VTYPE_BITFIELD;
6697                 temp_values.vdesc = "Information Flags (high) Byte:";
6698                 temp_values.vlength = 2;
6699                 temp_values.hfname= hf_nds_rflags;
6700                 temp_values.voffset = ioffset;
6701                 temp_values.bit1 = "Purge Time";
6702                 temp_values.bit1hfname = hf_bit1infoflagsh;
6703                 temp_values.bit2 = "Dereference Base Class";
6704                 temp_values.bit2hfname = hf_bit2infoflagsh;
6705                 temp_values.bit3 = "Replica Number";
6706                 temp_values.bit3hfname = hf_bit3infoflagsh;
6707                 temp_values.bit4 = "Replica State";
6708                 temp_values.bit4hfname = hf_bit4infoflagsh;
6709                 temp_values.bit5 = "Federation Boundary";
6710                 temp_values.bit5hfname = hf_bit5infoflagsh;
6711                 temp_values.bit6 = "Schema Boundary";
6712                 temp_values.bit6hfname = hf_bit6infoflagsh;
6713                 temp_values.bit7 = "Federation Boundary ID";
6714                 temp_values.bit7hfname = hf_bit7infoflagsh;
6715                 temp_values.bit8 = "Schema Boundary ID";
6716                 temp_values.bit8hfname = hf_bit8infoflagsh;
6717                 temp_values.bit9 = "Current Subcount";
6718                 temp_values.bit9hfname = hf_bit9infoflagsh;
6719                 temp_values.bit10 = "Local Entry Flags";
6720                 temp_values.bit10hfname = hf_bit10infoflagsh;
6721                 temp_values.bit11 = "Not Defined";
6722                 temp_values.bit11hfname = hf_bit11infoflagsh;
6723                 temp_values.bit12 = "Not Defined";
6724                 temp_values.bit12hfname = hf_bit12infoflagsh;
6725                 temp_values.bit13 = "Not Defined";
6726                 temp_values.bit13hfname = hf_bit13infoflagsh;
6727                 temp_values.bit14 = "Not Defined";
6728                 temp_values.bit14hfname = hf_bit14infoflagsh;
6729                 temp_values.bit15 = "Not Defined";
6730                 temp_values.bit15hfname = hf_bit15infoflagsh;
6731                 temp_values.bit16 = "Not Defined";
6732                 temp_values.bit16hfname = hf_bit16infoflagsh;
6733                 ioffset = ioffset+2;
6734                 process_bitfield(ntree, tvb, &temp_values);
6735                 ioffset += 4;
6736                 proto_tree_add_item(ntree, hf_nds_time_filter, tvb, ioffset, 4, FALSE);
6737                 ioffset += 4;
6738                 proto_tree_add_item(ntree, hf_nds_all_attr, tvb, ioffset, 4, FALSE);
6739                 ioffset += 4;
6740                 value2 = tvb_get_letohl(tvb, ioffset);
6741                 sub1item = proto_tree_add_uint_format(ntree, hf_nds_number_of_items, tvb, ioffset,
6742                         4, value2, "Number of Attributes %d", value2);
6743                 sub1tree = proto_item_add_subtree(sub1item, ett_nds);
6744                 ioffset += 4;
6745                 for (i=1; i<=value2; i++) {
6746                     sub2item = proto_tree_add_text(sub1tree, tvb, ioffset, 0, "Attribute %d", i);
6747                     sub2tree = proto_item_add_subtree(sub2item, ett_nds);
6748                     ioffset += align_4(tvb, ioffset);
6749                     value3 = tvb_get_letohl(tvb, ioffset);  /* Attribute Name */
6750                     ioffset = ioffset + 4;
6751                     get_string(tvb, ioffset, value3, mval_buf.buffer);
6752                     values->vstring = mval_buf.buffer;
6753                     proto_tree_add_string(sub2tree, hf_nds_attribute_dn, tvb, ioffset,
6754                             value3, values->vstring);
6755                     ioffset = ioffset + value3;
6756
6757                     if(tvb_length_remaining(tvb, ioffset) < 4 )
6758                     {
6759                             break;
6760                     }
6761                 }
6762                 ioffset += align_4(tvb, ioffset);
6763                 value4 = tvb_get_letohl(tvb, ioffset);
6764                 values->vstring = (char *)match_strval(value4, iterator_subverbs);
6765                 if(values->vstring == NULL)
6766                 {
6767                         values->vstring = "(No Iteration Verb Found)";
6768                 }
6769                 ioffset += 4;
6770                 dissect_nds_iterator(ntree, tvb, pinfo, value4, value5, ioffset, TRUE);
6771
6772                 g_strlcpy(mval_buf.buffer, " (", 1024);
6773                 g_strlcat(mval_buf.buffer, values->vstring, 1024);
6774                 g_strlcat(mval_buf.buffer, ") ", 1024);
6775                 values->vstring = mval_buf.buffer;
6776                 break;
6777             default:
6778                         break;
6779         }
6780 }
6781
6782 static void dissect_ncp_89_6_request(tvbuff_t *tvb, proto_tree *volatile ncp_tree, guint32 offset)
6783 {
6784     guint32 string_len, datatype, count, i;
6785
6786     datatype = tvb_get_letohl(tvb, offset);
6787     proto_tree_add_item(ncp_tree, hf_ncp_data_type_flag, tvb, offset, 1, TRUE);
6788     offset += 1;
6789     proto_tree_add_item(ncp_tree, hf_ncp_reserved5, tvb, offset, 5, TRUE);
6790     offset += 5;
6791     count = tvb_get_guint8(tvb, offset);
6792     proto_tree_add_item(ncp_tree, hf_ncp_path_count, tvb, offset, 1, TRUE);
6793     offset += 1;
6794     for (i=0; i < count; i++) {
6795         if (datatype == 0) {
6796             string_len = (tvb_get_guint8(tvb, offset))+1;
6797             proto_tree_add_item(ncp_tree, hf_ncp_directory_path, tvb, offset+1, string_len-1, TRUE);
6798         }
6799         else
6800         {
6801             string_len = (tvb_get_letohs(tvb, offset))+2;
6802             proto_tree_add_item(ncp_tree, hf_ncp_directory_path, tvb, offset+2, string_len-2, TRUE);
6803         }
6804         offset += string_len;
6805         if(tvb_length_remaining(tvb, offset) < 4 )
6806         {
6807                 break;
6808         }
6809     }
6810 }
6811
6812
6813 void
6814 dissect_ncp_123_11_reply(tvbuff_t *tvb, proto_tree *volatile ncp_tree, ncp_req_hash_value *request_value)
6815 {
6816     int string_len, loffset;
6817
6818     loffset = 76;
6819     if (request_value->length == 7) {
6820         /* Undocumented, if request value length is 7 then the reply is offset by 8 bytes.
6821          * Unknown what these 8 bytes represent */
6822         loffset += 8;
6823     }
6824     string_len = tvb_get_guint8(tvb, loffset);
6825     proto_tree_add_item(ncp_tree, hf_ncp_file_name_12, tvb, loffset+1, string_len, TRUE);
6826     loffset += string_len+1;
6827     string_len = tvb_get_guint8(tvb, loffset);
6828     proto_tree_add_item(ncp_tree, hf_ncp_name12, tvb, loffset+1, string_len, TRUE);
6829     loffset += string_len+1;
6830     string_len = tvb_get_guint8(tvb, loffset);
6831     proto_tree_add_item(ncp_tree, hf_ncp_copyright, tvb, loffset+1, string_len, TRUE);
6832 }
6833
6834 void
6835 dissect_ncp_123_17_reply(tvbuff_t *tvb, proto_tree *volatile ncp_tree)
6836 {
6837     proto_tree              *atree;
6838     proto_item              *aitem;
6839     guint32 loffset, number_of_items, addr_type;
6840     guint16 x;
6841
6842     number_of_items = tvb_get_letohl(tvb, 36);
6843     proto_tree_add_item(ncp_tree, hf_ncp_items_in_packet, tvb, 36, 4, TRUE);
6844     loffset = 40;
6845     for (x = 1; x <= number_of_items; x++)
6846     {
6847         aitem = proto_tree_add_text(ncp_tree, tvb, loffset, -1, "Network Address - %d", x);
6848         atree = proto_item_add_subtree(aitem, ett_ncp);
6849
6850         addr_type = tvb_get_guint8(tvb, loffset);
6851         proto_tree_add_item(atree, hf_ncp_transport_type, tvb, loffset, 1, TRUE);
6852         /* The address type is one byte of a 4 byte value. The next 4 bytes are
6853          * the length of the address. Since we already know the length based upon
6854          * the type of address, we can skip this value. So set the offset accourdingly */
6855         loffset += 8;
6856
6857         switch (addr_type)
6858         {
6859                 case 1:
6860                     proto_tree_add_item(atree, hf_nds_net, tvb, loffset, 4, FALSE);
6861                     proto_tree_add_item(atree, hf_nds_node, tvb, loffset+4, 6, FALSE);
6862                     proto_tree_add_item(atree, hf_nds_socket, tvb, loffset+10, 2, FALSE);
6863                     loffset += 12;
6864                     break;
6865                 case 5:
6866                     proto_tree_add_item(atree, hf_nds_port, tvb, loffset, 2, FALSE);
6867                     proto_tree_add_item(atree, hf_add_ref_udp, tvb, loffset+2, 4, FALSE);
6868                     loffset += 6;
6869                     break;
6870                 case 6:
6871                     proto_tree_add_item(atree, hf_nds_port, tvb, loffset, 2, FALSE);
6872                     proto_tree_add_item(atree, hf_add_ref_tcp, tvb, loffset+2, 4, FALSE);
6873                     loffset += 6;
6874                     break;
6875                 default:
6876                     proto_tree_add_text(atree, tvb, loffset, -1, "Unknown Address Type");
6877                     /* unknown type so read the length field and then
6878                     * just skip the record and move on to the next */
6879                     loffset += tvb_get_letohl(tvb, loffset - 4);
6880                     break;
6881         }
6882         proto_item_set_end(aitem, tvb, loffset);
6883         if(tvb_length_remaining(tvb, loffset) < 4 )
6884         {
6885                 break;
6886         }
6887     }
6888 }
6889
6890 void
6891 dissect_ncp_23_26_reply(tvbuff_t *tvb, proto_tree *volatile ncp_tree)
6892 {
6893     /* For an IP-only server, the 4-byte IP address is placed into the 4-byte NetworkAddress
6894      * field of the NetworkAddressStruct, while the NetworkNodeAddress and NetworkSocket
6895      * fields are left blank. */
6896     if (tvb_get_letohl(tvb, 12)==0) {
6897         /* IP Address */
6898         proto_tree_add_item(ncp_tree, hf_ncp_ip_address, tvb, 8, 4, FALSE);
6899     }
6900     else
6901     {
6902         /* IPX Address */
6903         proto_tree_add_item(ncp_tree, hf_nds_net, tvb, 8, 4, FALSE);
6904         proto_tree_add_item(ncp_tree, hf_nds_node, tvb, 12, 6, FALSE);
6905         proto_tree_add_item(ncp_tree, hf_nds_socket, tvb, 18, 2, FALSE);
6906     }
6907     proto_tree_add_item(ncp_tree, hf_ncp_connection_type, tvb, 20, 1, TRUE);
6908 }
6909
6910 void
6911 dissect_ncp_8x20reply(tvbuff_t *tvb, proto_tree *volatile ncp_tree,
6912                       const ncp_record  *ncp_rec, ncp_req_hash_value *request_value)
6913 {
6914     guint16 x;
6915     guint32 loffset, number_of_items, str_length;
6916         ptvcursor_t                     *ptvc = NULL;
6917     proto_tree              *atree, *btree;
6918     proto_item              *aitem, *bitem;
6919
6920     aitem = proto_tree_add_text(ncp_tree, tvb, 8, 9, "Search Sequence:");
6921     atree = proto_item_add_subtree(aitem, ett_ncp);
6922
6923     proto_tree_add_item(atree, hf_ncp_volume_number, tvb, 8, 1, TRUE);
6924     proto_tree_add_item(atree, hf_ncp_directory_entry_number, tvb, 9, 4, TRUE);
6925     proto_tree_add_item(atree, hf_ncp_sequence_number, tvb, 13, 4, TRUE);
6926
6927     proto_tree_add_item(ncp_tree, hf_ncp_more_flag, tvb, 17, 1, TRUE);
6928     number_of_items = tvb_get_letohs(tvb, 18);
6929     proto_tree_add_item(ncp_tree, hf_ncp_info_count, tvb, 18, 2, TRUE);
6930     loffset = 20;
6931     for (x = 1; x <= number_of_items; x++ )
6932     {
6933         aitem = proto_tree_add_text(ncp_tree, tvb, loffset, -1, "Information Item %d", x);
6934         atree = proto_item_add_subtree(aitem, ett_ncp);
6935         /* Data Stream Space Allocated */
6936         if (request_value->req_mask & 0x0002) {
6937             proto_tree_add_item(atree, hf_ncp_data_stream_space_alloc, tvb, loffset, 4, TRUE);
6938             loffset += 4;
6939         }
6940         else
6941         {
6942             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
6943                 loffset += 4;
6944             }
6945         }
6946         /* Attributes */
6947         if (request_value->req_mask & 0x0004) {
6948             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Attributes");
6949             btree = proto_item_add_subtree(bitem, ett_ncp);
6950             ptvc = ptvcursor_new(btree, tvb, loffset);
6951             process_ptvc_record(ptvc, ptvc_struct_attributes_struct,
6952                     NULL, TRUE, ncp_rec);
6953             ptvcursor_free(ptvc);
6954             loffset += 6;
6955             proto_item_set_end(bitem, tvb, loffset);
6956         }
6957         else
6958         {
6959             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
6960                 loffset += 6;
6961             }
6962         }
6963         /* Data Stream Size */
6964         if (request_value->req_mask & 0x0008) {
6965             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Data Stream Size");
6966             btree = proto_item_add_subtree(bitem, ett_ncp);
6967             proto_tree_add_item(btree, hf_ncp_data_stream_size, tvb, loffset, 4, TRUE);
6968             loffset += 4;
6969             proto_item_set_end(bitem, tvb, loffset);
6970         }
6971         else
6972         {
6973             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
6974                 loffset += 4;
6975             }
6976         }
6977         /* Total Stream Size */
6978         if (request_value->req_mask & 0x0010) {
6979             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Total Stream Size");
6980             btree = proto_item_add_subtree(bitem, ett_ncp);
6981             proto_tree_add_item(btree, hf_ncp_ttl_ds_disk_space_alloc, tvb, loffset, 4, TRUE);
6982             proto_tree_add_item(btree, hf_ncp_number_of_data_streams, tvb, loffset+4, 2, TRUE);
6983             loffset += 6;
6984             proto_item_set_end(bitem, tvb, loffset);
6985         }
6986         else
6987         {
6988             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
6989                 loffset += 6;
6990             }
6991         }
6992         /* Extended Attributes new style location*/
6993         if (request_value->req_mask & 0x0020 && ncp_newstyle) {
6994             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Extended Attributes");
6995             btree = proto_item_add_subtree(bitem, ett_ncp);
6996             ptvc = ptvcursor_new(btree, tvb, loffset);
6997             process_ptvc_record(ptvc, ptvc_struct_ea_info_struct,
6998                     NULL, TRUE, ncp_rec);
6999             ptvcursor_free(ptvc);
7000             loffset += 12;
7001             proto_item_set_end(bitem, tvb, loffset);
7002         }
7003         else
7004         {
7005             if ((request_value->req_mask_ext & 0x8000)==FALSE && ncp_newstyle) {
7006                 loffset += 12;
7007             }
7008         }
7009         /* Creation Information old style location */
7010         if (request_value->req_mask & 0x0100 && !ncp_newstyle) {
7011             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Creation");
7012             btree = proto_item_add_subtree(bitem, ett_ncp);
7013             ptvc = ptvcursor_new(btree, tvb, loffset);
7014             process_ptvc_record(ptvc, ptvc_struct_creation_info_struct,
7015                     NULL, TRUE, ncp_rec);
7016             ptvcursor_free(ptvc);
7017             loffset += 8;
7018             proto_item_set_end(bitem, tvb, loffset);
7019         }
7020         else
7021         {
7022             if ((request_value->req_mask_ext & 0x8000)==FALSE && !ncp_newstyle) {
7023                 loffset += 8;
7024             }
7025         }
7026         /* Modification Information */
7027         if (request_value->req_mask & 0x0080) {
7028             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Modification");
7029             btree = proto_item_add_subtree(bitem, ett_ncp);
7030             ptvc = ptvcursor_new(btree, tvb, loffset);
7031             process_ptvc_record(ptvc, ptvc_struct_modify_info_struct,
7032                     NULL, TRUE, ncp_rec);
7033             ptvcursor_free(ptvc);
7034             loffset += 10;
7035             proto_item_set_end(bitem, tvb, loffset);
7036         }
7037         else
7038         {
7039             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
7040                 loffset += 10;
7041             }
7042         }
7043         /* Creation Information new style location */
7044         if (request_value->req_mask & 0x0100 && ncp_newstyle) {
7045             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Creation");
7046             btree = proto_item_add_subtree(bitem, ett_ncp);
7047             ptvc = ptvcursor_new(btree, tvb, loffset);
7048             process_ptvc_record(ptvc, ptvc_struct_creation_info_struct,
7049                     NULL, TRUE, ncp_rec);
7050             ptvcursor_free(ptvc);
7051             loffset += 8;
7052             proto_item_set_end(bitem, tvb, loffset);
7053         }
7054         else
7055         {
7056             if ((request_value->req_mask_ext & 0x8000)==FALSE && ncp_newstyle) {
7057                 loffset += 8;
7058             }
7059         }
7060         /* Archive Information */
7061         if (request_value->req_mask & 0x0040) {
7062             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Archive");
7063             btree = proto_item_add_subtree(bitem, ett_ncp);
7064             ptvc = ptvcursor_new(btree, tvb, loffset);
7065             process_ptvc_record(ptvc, ptvc_struct_archive_info_struct,
7066                     NULL, TRUE, ncp_rec);
7067             ptvcursor_free(ptvc);
7068             loffset += 8;
7069             proto_item_set_end(bitem, tvb, loffset);
7070         }
7071         else
7072         {
7073             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
7074                 loffset += 8;
7075             }
7076         }
7077         /* Rights Information */
7078         if (request_value->req_mask & 0x0800) {
7079             ptvc = ptvcursor_new(atree, tvb, loffset);
7080             process_ptvc_record(ptvc, ptvc_struct_rights_info_struct,
7081                     NULL, TRUE, ncp_rec);
7082             ptvcursor_free(ptvc);
7083             loffset += 2;
7084         }
7085         else
7086         {
7087             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
7088                 loffset += 2;
7089             }
7090         }
7091         /* Directory Entry */
7092         if (request_value->req_mask & 0x0400) {
7093             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Directory Entry");
7094             btree = proto_item_add_subtree(bitem, ett_ncp);
7095             ptvc = ptvcursor_new(btree, tvb, loffset);
7096             process_ptvc_record(ptvc, ptvc_struct_dir_entry_struct,
7097                     NULL, TRUE, ncp_rec);
7098             ptvcursor_free(ptvc);
7099             loffset += 12;
7100             proto_item_set_end(bitem, tvb, loffset);
7101         }
7102         else
7103         {
7104             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
7105                 loffset += 12;
7106             }
7107         }
7108         /* Extended Attributes oldstyle location*/
7109         if (request_value->req_mask & 0x0020 && !ncp_newstyle) {
7110             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Extended Attributes");
7111             btree = proto_item_add_subtree(bitem, ett_ncp);
7112             ptvc = ptvcursor_new(btree, tvb, loffset);
7113             process_ptvc_record(ptvc, ptvc_struct_ea_info_struct,
7114                     NULL, TRUE, ncp_rec);
7115             ptvcursor_free(ptvc);
7116             loffset += 12;
7117             proto_item_set_end(bitem, tvb, loffset);
7118         }
7119         else
7120         {
7121             if ((request_value->req_mask_ext & 0x8000)==FALSE && !ncp_newstyle) {
7122                 loffset += 12;
7123             }
7124         }
7125         /* Name Space Information */
7126         if (request_value->req_mask & 0x0200) {
7127             proto_tree_add_item(atree, hf_ncp_creator_name_space_number, tvb, loffset, 1, TRUE);
7128             loffset += 4;
7129         }
7130         else
7131         {
7132             if ((request_value->req_mask_ext & 0x8000)==FALSE) {
7133                 loffset += 4;
7134             }
7135         }
7136         if (request_value->req_mask & 0x1000) {
7137             proto_tree_add_item(atree, hf_ncp_curr_ref_id, tvb, loffset, 2, TRUE);
7138             loffset += 2;
7139         }
7140         if (request_value->req_mask & 0x2000) {
7141             proto_tree_add_item(atree, hf_ncp_attr_def_32, tvb, loffset, 1, TRUE);
7142             loffset += 4;
7143         }
7144         if (request_value->req_mask & 0x4000) {
7145             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Actual");
7146             btree = proto_item_add_subtree(bitem, ett_ncp);
7147             proto_tree_add_item(btree, hf_ncp_data_stream_num_long, tvb, loffset, 4, TRUE);
7148             proto_tree_add_item(btree, hf_ncp_data_stream_fat_blks, tvb, loffset+4, 4, TRUE);
7149             loffset += 8;
7150             proto_item_set_end(bitem, tvb, loffset);
7151         }
7152         if (request_value->req_mask & 0x8000) {
7153             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Logical");
7154             btree = proto_item_add_subtree(bitem, ett_ncp);
7155             proto_tree_add_item(btree, hf_ncp_data_stream_num_long, tvb, loffset, 4, TRUE);
7156             proto_tree_add_item(btree, hf_ncp_data_stream_size, tvb, loffset+4, 4, TRUE);
7157             loffset += 8;
7158             proto_item_set_end(bitem, tvb, loffset);
7159         }
7160         if (request_value->req_mask_ext & 0x0001 && ncp_newstyle) {
7161             proto_tree_add_item(atree, hf_ncp_sec_rel_to_y2k, tvb, loffset, 4, TRUE);
7162             loffset += 4;
7163         }
7164         if (request_value->req_mask_ext & 0x0002 && ncp_newstyle) {
7165             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "DOS Name");
7166             btree = proto_item_add_subtree(bitem, ett_ncp);
7167             if (ncp_rec->func == 0x57) {
7168                 str_length = tvb_get_guint8(tvb, loffset);
7169                 loffset += 1;
7170             }
7171             else
7172             {
7173                 str_length = tvb_get_letohs(tvb, loffset);
7174                 loffset += 2;
7175             }
7176             proto_tree_add_item(btree, hf_ncp_file_name_12, tvb, loffset, str_length, FALSE);
7177             loffset += str_length;
7178             proto_item_set_end(bitem, tvb, loffset);
7179         }
7180         if (request_value->req_mask_ext & 0x0004 && ncp_newstyle) {
7181             ptvc = ptvcursor_new(atree, tvb, loffset);
7182             process_ptvc_record(ptvc, ptvc_struct_flush_time_struct,
7183                     NULL, TRUE, ncp_rec);
7184             ptvcursor_free(ptvc);
7185             loffset += 4;
7186         }
7187         if (request_value->req_mask_ext & 0x0008 && ncp_newstyle) {
7188             proto_tree_add_item(atree, hf_ncp_parent_base_id, tvb, loffset, 4, TRUE);
7189             loffset += 4;
7190         }
7191         if (request_value->req_mask_ext & 0x0010 && ncp_newstyle) {
7192             proto_tree_add_item(atree, hf_ncp_mac_finder_info, tvb, loffset, 32, TRUE);
7193             loffset += 32;
7194         }
7195         if (request_value->req_mask_ext & 0x0020 && ncp_newstyle) {
7196             proto_tree_add_item(atree, hf_ncp_sibling_count, tvb, loffset, 4, TRUE);
7197             loffset += 4;
7198         }
7199         if (request_value->req_mask_ext & 0x0040 && ncp_newstyle) {
7200             proto_tree_add_item(atree, hf_ncp_effective_rights, tvb, loffset, 1, TRUE);
7201             loffset += 4;
7202         }
7203         if (request_value->req_mask_ext & 0x0080 && ncp_newstyle) {
7204             bitem = proto_tree_add_text(atree, tvb, loffset, -1, "Mac Date");
7205             btree = proto_item_add_subtree(bitem, ett_ncp);
7206             ptvc = ptvcursor_new(btree, tvb, loffset);
7207             process_ptvc_record(ptvc, ptvc_struct_mac_time_struct,
7208                     NULL, TRUE, ncp_rec);
7209             ptvcursor_free(ptvc);
7210             loffset += 8;
7211             proto_item_set_end(bitem, tvb, loffset);
7212         }
7213         if (request_value->req_mask_ext & 0x0100 && ncp_newstyle) {
7214             ptvc = ptvcursor_new(atree, tvb, loffset);
7215             process_ptvc_record(ptvc, ptvc_struct_last_access_time_struct,
7216                     NULL, TRUE, ncp_rec);
7217             ptvcursor_free(ptvc);
7218             loffset += 2;
7219         }
7220         if (request_value->req_mask_ext & 0x0400 && ncp_newstyle) {
7221             proto_tree_add_item(atree, hf_ncp_f_size_64bit, tvb, loffset, 8, TRUE);
7222             loffset += 8;
7223         }
7224         /* We always return the file name */
7225         if (ncp_rec->func == 0x57) {
7226             str_length = tvb_get_guint8(tvb, loffset);
7227             loffset += 1;
7228         }
7229         else
7230         {
7231             str_length = tvb_get_letohs(tvb, loffset);
7232             loffset += 2;
7233         }
7234         proto_tree_add_item(atree, hf_ncp_file_name_12, tvb, loffset, str_length, FALSE);
7235         loffset += str_length;
7236
7237         proto_item_set_end(aitem, tvb, loffset);
7238
7239         if(tvb_length_remaining(tvb, loffset) < 4 )
7240         {
7241                 break;
7242         }
7243     }
7244 }
7245
7246 void
7247 dissect_ncp_123_62_reply(tvbuff_t *tvb, proto_tree *volatile ncp_tree)
7248 {
7249     char value_format[2]="\0";
7250     char param_string[256]="\0";
7251
7252     build_expert_data(ncp_tree, "ncp.set_cmd_type", value_format, 0, FALSE);
7253     build_expert_data(ncp_tree, "ncp.set_cmd_name", param_string, 0, FALSE);
7254     switch (atoi(value_format)) {
7255     case 0:   /* { 0x00,        "Numeric Value" }, */
7256     case 2:   /* { 0x02,        "Ticks Value" }, */
7257     case 4:   /* { 0x04,        "Time Value" }, */
7258     case 6:   /* { 0x06,        "Trigger Value" }, */
7259     case 7:   /* { 0x07,        "Numeric Value" }, */
7260         proto_tree_add_item(ncp_tree, hf_srvr_param_number, tvb, 37+strlen(param_string), 4, TRUE);
7261         break;
7262     case 1:   /* { 0x01,        "Boolean Value" }, */
7263         proto_tree_add_item(ncp_tree, hf_srvr_param_boolean, tvb, 37+strlen(param_string), 1, TRUE);
7264         break;
7265     case 5:   /* { 0x05,        "String Value" }, */
7266         proto_tree_add_item(ncp_tree, hf_srvr_param_string, tvb, 37+strlen(param_string), -1, TRUE);
7267         break;
7268     default:
7269         break;
7270     }
7271 }
7272
7273 /*
7274  * Defrag logic
7275  *
7276  * NDS fragment not being set to 0xffffffff indicates we are inside or at the
7277  * beginning of a fragment. But when the end of the fragment
7278  * is encounterd the flag is set to 0xffffffff. So we must mark what the
7279  * frame number is of the end fragment so that we will be
7280  * able to redissect if the user clicks on the packet
7281  * or resorts/filters the trace.
7282  *
7283  * Once we are certain that we are in a fragment sequence
7284  * then we can just process each fragment in this conversation
7285  * until we reach the fragment == 0xffffffff packet.
7286  *
7287  * We will be able to easily determine if a conversation is a fragment
7288  * with the exception of the last packet in the fragment. So remember
7289  * the last fragment packet number.
7290  *
7291  * Also the NDS dissection requires the values of NDS Verb, Version, and Flags.
7292  * Without this values being remembered from the first request packet then
7293  * we will be unable to dissect the reply packet. For this reason we remember
7294  * these values on the first fragment and then populate the values in the final
7295  * fragment. We only do this on the first dissection.
7296  */
7297 void
7298 nds_defrag(tvbuff_t *tvb, packet_info *pinfo, guint32 nw_connection, guint8 sequence, guint16 type, proto_tree *tree, struct novell_tap *ncp_tap)
7299 {
7300     int                 i, frag_count=0;
7301     guint                       len=0;
7302     guint32             tid = 1;
7303     tvbuff_t            *frag_tvb = NULL;
7304     fragment_data       *fd_head;
7305     ncp_req_hash_value  *request_value = NULL;
7306     conversation_t      *conversation;
7307     guint32             nds_frag;
7308
7309     for (i = 0; i < 99; i++) {
7310         if (!frags[i].nds_fragmented)
7311         {
7312                 frags[i].nds_frag = 0xfffffff0;
7313         }
7314     }
7315     /* Check to see if defragmentation is enabeled in the dissector */
7316     if (!nds_defragment) {
7317         dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7318         return;
7319     }
7320     /* Has this already been dissected? */
7321     if (!pinfo->fd->flags.visited) {
7322         /* Find the conversation whence the request would have come. */
7323         conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
7324                     PT_NCP, nw_connection, nw_connection, 0);
7325         if (conversation != NULL) {
7326                 /* find the record telling us the request made that caused
7327                    this reply */
7328                 request_value = ncp_hash_lookup(conversation, sequence);
7329                 if (!request_value) {
7330                         dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7331                         return;
7332                 }
7333                 p_add_proto_data(pinfo->fd, proto_ncp, (void*) request_value);
7334         }
7335         /* else... we haven't seen an NCP Request for that conversation and sequence. */
7336         else
7337         {
7338                 dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7339                 return;
7340         }
7341     }
7342     else {
7343         request_value = p_get_proto_data(pinfo->fd, proto_ncp);
7344         if (!request_value) {
7345                 dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7346                 return;
7347         }
7348     }
7349     /* Validate that this is an NDS packet */
7350     /* If this isn't an NDS packet then just return */
7351     if (!request_value->ncp_rec ||
7352          request_value->ncp_rec->func!=104 || request_value->ncp_rec->subfunc!=2) {
7353         dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7354         return;
7355     }
7356     /* Check to see if there is at least enough packet info to get the fragment flag */
7357     if (tvb_reported_length_remaining(tvb, 12) < 4) {
7358         dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7359         return;
7360     }
7361     /* Get the fragment flag */
7362     nds_frag = tvb_get_letohl(tvb, 12);
7363
7364     /* Now we need to find if this is a new fragment or already one defined. */
7365     /* We currently limit the maximum number of simultaneous fragments to 100. */
7366     for (i=0; i<100; i++)
7367     {
7368         if (frags[i].nds_frag == nds_frag || frags[i].nds_frag == 0xfffffff0)
7369         {
7370                 if (frags[i].nds_frag == 0xfffffff0)
7371                 {
7372                         frags[i].nds_length = 0;
7373                         frags[i].nds_frag = nds_frag;
7374                         frags[i].nds_fragmented = TRUE;
7375                 }
7376                 break;
7377         }
7378     }
7379     if (i > 99)
7380         return;
7381
7382     frag_count = i;
7383
7384     /* is this the end of an existing fragment or just another reply */
7385     if (nds_frag == 0xffffffff && request_value->nds_frag_num == 0xffffffff)
7386     {
7387                 dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7388                 return;
7389     }
7390
7391     /* Now we process the fragments */
7392     if (request_value->nds_frag || (request_value->nds_end_frag == pinfo->fd->num))
7393     {
7394         /* Check to see of this is a fragment. If so then mark as a fragment. */
7395         if (frags[frag_count].nds_frag==0xffffffff) {
7396                 request_value->nds_frag = FALSE;
7397                 /* nds_length of 0 means start of fragment */
7398                 frags[frag_count].nds_length = 0;
7399         }
7400         else
7401         {
7402                 if (frags[frag_count].nds_length == 0)
7403                 {
7404                         frags[frag_count].nds_length = tvb_get_letohl(tvb, 0);
7405                 }
7406         }
7407         /*
7408          * Fragment
7409          *
7410          */
7411         tid = (pinfo->srcport+pinfo->destport);
7412         len = tvb_reported_length(tvb);
7413         if (len > 0 && tvb_bytes_exist(tvb, 0, len))
7414         {
7415             if (frags[frag_count].nds_length > len)
7416             {
7417                 /* This is the first fragment so remember the verb, version, and flags. */
7418                 frags[frag_count].nds_frag_verb = request_value->nds_request_verb;
7419                 frags[frag_count].nds_frag_version = request_value->nds_version;
7420                 frags[frag_count].nds_frag_flags = request_value->req_nds_flags;
7421                 frags[frag_count].nds_frag_prot_flags = request_value->req_nds_prot_flags;
7422                 fd_head = fragment_add_seq_next(tvb, 0, pinfo, tid, nds_fragment_table, nds_reassembled_table, len, request_value->nds_frag);
7423                 frags[frag_count].nds_length = 1;
7424             }
7425             else
7426             {
7427                 /* Subsequent fragments should be offset by 16 since we do not need */
7428                 /* the additional fragment handle and size fields in our composite data */
7429                 fd_head = fragment_add_seq_next(tvb, 16, pinfo, tid, nds_fragment_table, nds_reassembled_table, len-16, request_value->nds_frag);
7430             }
7431             if (fd_head != NULL)
7432             {
7433                 /* Is this the last fragment? nds_frag will indicate */
7434                 if (fd_head->next != NULL && !request_value->nds_frag)
7435                 {
7436                     frag_tvb = tvb_new_real_data(fd_head->data,
7437                         fd_head->len, fd_head->len);
7438                     tvb_set_child_real_data_tvbuff(tvb,
7439                         frag_tvb);
7440                     add_new_data_source(pinfo,
7441                         frag_tvb,
7442                         "Reassembled NDS");
7443                     /* Show all fragments. */
7444                     if (tree)
7445                     {
7446                         proto_item *frag_tree_item;
7447                         show_fragment_seq_tree(fd_head,
7448                             &nds_frag_items,
7449                             tree, pinfo,
7450                             frag_tvb, &frag_tree_item);
7451                         tid++;
7452                     }
7453
7454                     if (!pinfo->fd->flags.visited)
7455                     {
7456                          /* Now we need to find the original fragment number. */
7457                          /* Get the fragment flag */
7458                          nds_frag = tvb_get_letohl(frag_tvb, 12);
7459                          for (i=0; i<100; i++)
7460                          {
7461                              if (frags[i].nds_frag == nds_frag)
7462                              {
7463                                      break;
7464                              }
7465                          }
7466                          if (i > 99)
7467                              return;
7468                          if (frags[i].nds_frag == 0xffffffff)
7469                          {
7470                                  /* Error can't find fragment */
7471                                  /*DISSECTOR_ASSERT(0);*/
7472                          }
7473                          frag_count = i;
7474                         /* Remember this fragment information so we can dissect.
7475                          * Only do this on the first dissection. After the first
7476                          * dissection we will just read the memory values.
7477                          */
7478                         request_value->nds_end_frag = pinfo->fd->num;
7479                         request_value->nds_request_verb = frags[frag_count].nds_frag_verb;
7480                         request_value->nds_version = frags[frag_count].nds_frag_version;
7481                         request_value->req_nds_flags = frags[frag_count].nds_frag_flags;
7482                         request_value->req_nds_prot_flags = frags[frag_count].nds_frag_prot_flags;
7483                     }
7484
7485                 }
7486                 else
7487                 {
7488                     /* This is either a beggining or middle fragment on second dissection */
7489                     frag_tvb = tvb_new_subset(tvb, 0, -1, -1);
7490                     if (check_col(pinfo->cinfo, COL_INFO))
7491                     {
7492                       if (request_value->nds_frag)
7493                       {
7494                         col_add_fstr(pinfo->cinfo, COL_INFO, "[NDS Fragment %08x]", frags[frag_count].nds_frag);
7495                       }
7496                     }
7497                 }
7498             }
7499             else
7500             {
7501                 /* Fragment from first pass of dissection */
7502                 if (check_col(pinfo->cinfo, COL_INFO))
7503                 {
7504                   if (request_value->nds_frag)
7505                   {
7506                      col_add_fstr(pinfo->cinfo, COL_INFO, "[NDS Fragment %08x]", frags[frag_count].nds_frag);
7507                   }
7508                 }
7509                 frag_tvb = NULL;
7510             }
7511         }
7512         else
7513         {
7514             /*
7515              * There are no bytes so Dissect this
7516              */
7517             frag_tvb = tvb_new_subset(tvb, 0, -1, -1);
7518         }
7519         if (frag_tvb == NULL)
7520         {
7521             /* This is a fragment packet */
7522                 frag_tvb = tvb_new_subset (tvb, 0, -1, -1);
7523                 nds_data_handle = find_dissector("data");
7524                 call_dissector(nds_data_handle, frag_tvb, pinfo, tree);
7525         }
7526         else
7527         {
7528             /* This is the end fragment so dissect */
7529             if (!request_value->nds_frag) {
7530                 frags[frag_count].nds_length = 0;
7531                 dissect_ncp_reply(frag_tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7532             }
7533         }
7534     }
7535     else
7536     {
7537         /* This is not any fragment packet */
7538         frags[frag_count].nds_length = 0;
7539         request_value->nds_frag = FALSE;
7540         dissect_ncp_reply(tvb, pinfo, nw_connection, sequence, type, tree, ncp_tap);
7541     }
7542 }
7543
7544 void
7545 dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo,
7546                 guint32 nw_connection, guint8 sequence,
7547                 guint16 type, proto_tree *volatile ncp_tree)
7548 {
7549         volatile guint8                 func=0;
7550         volatile guint8         subfunc = 0;
7551         gboolean                requires_subfunc = FALSE;
7552         gboolean                has_length = FALSE;
7553         ncp_req_hash_value      *volatile request_value = NULL;
7554         const ncp_record        *volatile ncp_rec = NULL;
7555         conversation_t          *conversation;
7556         ptvcursor_t             *volatile ptvc = NULL;
7557         proto_tree              *temp_tree = NULL;
7558         volatile gboolean       run_req_cond = FALSE;
7559         volatile gboolean       run_info_str = FALSE;
7560         guint32                 length_remaining;
7561         guint32                 testvar;
7562         volatile unsigned long  except_code;
7563         const char              *volatile message;
7564
7565
7566         /* Determine which ncp_record to use. */
7567         switch (type) {
7568                 case NCP_ALLOCATE_SLOT:
7569                         length_remaining = tvb_length_remaining(tvb, 4);
7570                         if (length_remaining > 4)
7571                         {
7572                                 testvar = tvb_get_ntohl(tvb, 4);
7573                                 if( testvar == 0x4c495020)
7574                                 {
7575                                         ncp_rec = &ncplip_echo;
7576                                 }
7577                                 else
7578                                 {
7579                                                 ncp_rec = &ncp1111_request;
7580                                     if (ncp_echo_conn) {
7581                                         expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Connection Request");
7582                                     }
7583                                 }
7584                         }
7585                         else
7586                         {
7587                                         ncp_rec = &ncp1111_request;
7588                             if (ncp_echo_conn) {
7589                                 expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Connection Request");
7590                             }
7591                         }
7592                         break;
7593                 case NCP_SERVICE_REQUEST:
7594             func = tvb_get_guint8(tvb, 6);
7595                         requires_subfunc = ncp_requires_subfunc(func);
7596                         has_length = ncp_has_length_parameter(func);
7597                         if (requires_subfunc) {
7598                                 if (has_length) {
7599                                         subfunc = tvb_get_guint8(tvb, 9);
7600                                 }
7601                                 else {
7602                                         subfunc = tvb_get_guint8(tvb, 7);
7603                                 }
7604                         }
7605                         ncp_rec = ncp_record_find(func, subfunc);
7606                         break;
7607                 case NCP_DEALLOCATE_SLOT:
7608                         ncp_rec = &ncp5555_request;
7609             if (ncp_echo_conn) {
7610                 expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Destroy Connection %d Request", nw_connection);
7611             }
7612                         break;
7613                 case NCP_BROADCAST_SLOT:
7614                         ncp_rec = &ncpbbbb_request;
7615                         break;
7616                 case NCP_LIP_ECHO:
7617                         ncp_rec = &ncplip_echo;
7618                         break;
7619                 default:
7620                         ncp_rec = NULL;
7621                         break;
7622         }
7623
7624         /* Fill in the INFO column. */
7625         if (check_col(pinfo->cinfo, COL_INFO)) {
7626                 if (ncp_rec) {
7627                         col_add_fstr(pinfo->cinfo, COL_INFO, "C %s", ncp_rec->name);
7628                         if (ncp_rec->req_info_str) {
7629                                 /* We want to add more stuff to the Info
7630                                    column. */
7631                                 run_info_str = TRUE;
7632                         }
7633                 }
7634                 else {
7635                         if (requires_subfunc) {
7636                                 col_add_fstr(pinfo->cinfo, COL_INFO,
7637                                         "C Unknown Function %u %u (0x%02X/0x%02x)",
7638                                         func, subfunc, func, subfunc);
7639                     return;
7640                         }
7641                         else {
7642                                 col_add_fstr(pinfo->cinfo, COL_INFO,
7643                                         "C Unknown Function %u (0x%02x)",
7644                                         func, func);
7645                     return;
7646                         }
7647                 }
7648         }
7649         if (!pinfo->fd->flags.visited) {
7650                 /* This is the first time we've looked at this packet.
7651                    Keep track of the address and connection whence the request
7652                    came, and the address and connection to which the request
7653                    is being sent, so that we can match up calls with replies.
7654                    (We don't include the sequence number, as we may want
7655                    to have all packets over the same connection treated
7656                    as being part of a single conversation so that we can
7657                    let the user select that conversation to be displayed.) */
7658                 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
7659                     PT_NCP, nw_connection, nw_connection, 0);
7660
7661                 if (conversation == NULL) {
7662                         /* It's not part of any conversation - create a new one. */
7663                         conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
7664                             PT_NCP, nw_connection, nw_connection, 0);
7665                 }
7666                 request_value = ncp_hash_insert(conversation, sequence, ncp_rec);
7667                 request_value->req_frame_num = pinfo->fd->num;
7668                 request_value->req_frame_time = pinfo->fd->abs_ts;
7669
7670                 /* If this is the first time we're examining the packet,
7671                  * check to see if this NCP type uses a "request condition".
7672                  * If so, we have to build a proto_tree because request conditions
7673                  * use display filters to work, and without a proto_tree,
7674                  * display filters can't possibly work. */
7675                 if (ncp_rec) {
7676                         if (ncp_rec->req_cond_indexes) {
7677                                 run_req_cond = TRUE;
7678                         }
7679                 }
7680         }
7681
7682         /* If we have to handle a request condition, or have to
7683            add to the Info column, we need to construct a protocol
7684            tree.  If we already have a proto_tree, then wonderful.
7685            If we don't, we need to build one. */
7686         if ((run_info_str || run_req_cond) && !ncp_tree) {
7687                 proto_item *ti;
7688
7689                 temp_tree = proto_tree_create_root();
7690                 proto_tree_set_visible(temp_tree, FALSE);
7691                 ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
7692                 ncp_tree = proto_item_add_subtree(ti, ett_ncp);
7693         }
7694
7695         if (ncp_tree) {
7696                 /* If the dissection throws an exception, be sure to free
7697                  * the temporary proto_tree that was created. Because of the
7698                  * way the CLEANUP_PUSH macro works, we can't put it in an 'if'
7699                  * block; it has to be in the same scope as the terminating
7700                  * CLEANUP_POP or CLEANUP_POP_AND_ALLOC. So, we always
7701                  * call CLEANUP_POP and friends, but the value of temp_tree is
7702                  * NULL if no cleanup is needed, and non-null if cleanup is needed. */
7703                 CLEANUP_PUSH(free_proto_tree, temp_tree);
7704
7705 #ifdef FAKE_TREE_IS_VISIBLE
7706                 PTREE_DATA(ncp_tree)->visible=1;
7707 #endif
7708
7709                 /* Before the dissection, if we're saving data for a request
7710                  * condition, we have to prime the proto tree using the
7711                  * dfilter information */
7712                 if (run_req_cond) {
7713                         const int       *needed;
7714                         dfilter_t       *dfilter;
7715
7716                         needed = ncp_rec->req_cond_indexes;
7717
7718                         while (*needed != -1) {
7719                                 dfilter = req_conds[*needed].dfilter;
7720                                 /* Prime the proto_tree with "interesting fields". */
7721                                 dfilter_prime_proto_tree(dfilter, ncp_tree);
7722                                 needed++;
7723                         }
7724                 }
7725
7726                 /* Before the dissection, if we need a field for the info_str,
7727                  * prime the tree. */
7728                 if (run_info_str) {
7729                         proto_tree_prime_hfid(ncp_tree, *ncp_rec->req_info_str->hf_ptr);
7730                 }
7731
7732                 switch (type) {
7733                         case NCP_BROADCAST_SLOT:
7734                                 ; /* nothing */
7735                                 break;
7736
7737                         case NCP_SERVICE_REQUEST:
7738                                 proto_tree_add_uint_format(ncp_tree, hf_ncp_func, tvb, 6, 1,
7739                                         func, "Function: %u (0x%02X), %s",
7740                                         func, func, ncp_rec ? ncp_rec->name : "Unknown");
7741                                 break;
7742
7743                         default:
7744                                 ; /* nothing */
7745                                 break;
7746                 }
7747         if (request_value) {
7748             request_value->length = 0;
7749         }
7750                 if (requires_subfunc) {
7751                         if (has_length) {
7752                 if (request_value && func==123) {
7753                     request_value->length = tvb_get_ntohs(tvb, 7);
7754                 }
7755                                 proto_tree_add_item(ncp_tree, hf_ncp_length, tvb, 7,
7756                                         2, FALSE);
7757                 proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 9, 1,
7758                                         subfunc, "SubFunction: %u (0x%02x)",
7759                                         subfunc, subfunc);
7760                                 ptvc = ptvcursor_new(ncp_tree, tvb, 10);
7761                         }
7762                         else {
7763                                 proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 7, 1,
7764                                         subfunc, "SubFunction: %u (0x%02x)",
7765                                         subfunc, subfunc);
7766                                 ptvc = ptvcursor_new(ncp_tree, tvb, 8);
7767                         }
7768                 }
7769                 else {
7770                         ptvc = ptvcursor_new(ncp_tree, tvb, 7);
7771                 }
7772
7773         /* The group is not part of the packet, but it's useful
7774                  * information to display anyway. Put it in the tree for filtering and tap use*/
7775                 if (ncp_rec) {
7776                 proto_tree_add_uint_format(ncp_tree, hf_ncp_group, tvb, 0, 0, ncp_rec->group, "Group: %s", ncp_groups[ncp_rec->group]);
7777                 }
7778
7779                 except_code = 0;
7780                 message = NULL;
7781                 if (ncp_rec && ncp_rec->request_ptvc) {
7782                         clear_repeat_vars();
7783                         /*
7784                          * We need to remember the results even if we
7785                          * throw an exception dissecting this request,
7786                          * so that we can properly dissect the reply.
7787                          * We catch any exceptions thrown when
7788                          * dissecting the request, and re-throw them
7789                          * after saving the results of any conditional
7790                          * tests.
7791                          */
7792                         TRY {
7793                                 process_ptvc_record(ptvc, ncp_rec->request_ptvc, NULL, TRUE, ncp_rec);
7794                         } CATCH_ALL {
7795                                 except_code = EXCEPT_CODE;
7796                                 message = GET_MESSAGE;
7797                         }
7798                         ENDTRY;
7799                 }
7800                 ptvcursor_free(ptvc);
7801                 /* SecretStore packets are dessected in packet-ncp-sss.c */
7802                 if (func == 0x5c && ncp_tree) {
7803                         dissect_sss_request(tvb, pinfo, ncp_tree, request_value);
7804                 }
7805                 /* NMAS packets are dessected in packet-ncp-nmas.c */
7806                 if (func == 0x5e && ncp_tree) {
7807                         dissect_nmas_request(tvb, pinfo, ncp_tree, request_value);
7808                 }
7809
7810                 /* Now that the dissection is done, do we need to run
7811                  * some display filters on the resulting tree in order
7812                  * to save results for "request conditions" ? */
7813                 if (run_req_cond) {
7814                         const int       *needed;
7815                         gboolean        *results;
7816                         dfilter_t       *dfilter;
7817
7818                         results = g_new0(gboolean, NUM_REQ_CONDS);
7819                         needed = ncp_rec->req_cond_indexes;
7820
7821                         while (*needed != -1) {
7822                                 /* ncp_tree is not a root proto_tree, but
7823                                  * dfilters will still work on it. */
7824                                 dfilter = req_conds[*needed].dfilter;
7825                                 results[*needed] = dfilter_apply(dfilter, ncp_tree);
7826                                 needed++;
7827                         }
7828
7829                         /* Save the results so the reply packet dissection
7830                          * get to them. */
7831                         request_value->req_cond_results = results;
7832                 }
7833                 /* Construct the info string if necessary */
7834                 if (run_info_str) {
7835                         GPtrArray *parray;
7836                         char*   byte_string;
7837                         char    non_uni_string[1024];
7838                         int i, len;
7839                         field_info *finfo;
7840                         int info_type;
7841
7842                         if (!request_value)
7843                         {
7844                                 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
7845                                     PT_NCP, nw_connection, nw_connection, 0);
7846                                 if (conversation != NULL) {
7847                                         /* find the record telling us the request made that caused
7848                                         this reply */
7849                                         request_value = ncp_hash_lookup(conversation, sequence);
7850                                 }
7851                                 if (!conversation || !request_value)
7852                                 {
7853                                         return;
7854                                 }
7855                         }
7856
7857                         parray = proto_get_finfo_ptr_array(ncp_tree,
7858                                 *ncp_rec->req_info_str->hf_ptr);
7859                         len = g_ptr_array_len(parray);
7860
7861                         if (len > 0) {
7862
7863                                 col_set_str(pinfo->cinfo, COL_INFO, "C ");
7864
7865                                 finfo = g_ptr_array_index(parray, 0);
7866
7867                                 info_type = get_info_type((const gchar*) ncp_rec->req_info_str->first_string);
7868
7869                                 if (info_type != 0) {    /* Is this  a string or not? */
7870
7871                                         if (info_type == 1) {   /* Is this bytes? */
7872                                                 byte_string = bytes_to_str(get_finfo_value_string(finfo), get_finfo_length(finfo));
7873                                                 col_append_fstr(pinfo->cinfo, COL_INFO,
7874                                                         (const gchar*) ncp_rec->req_info_str->first_string,
7875                                                         byte_string);
7876                                         }
7877                                         else
7878                                         {
7879                                                 if (info_type == 2) {   /* Is this a String? */
7880                                                         uni_to_string(get_finfo_value_string(finfo), get_finfo_length(finfo), non_uni_string);
7881                                                         col_append_fstr(pinfo->cinfo, COL_INFO,
7882                                                                 (const gchar*) ncp_rec->req_info_str->first_string,
7883                                                                 non_uni_string);
7884                                                 }
7885                                                 else
7886                                                 {
7887                                                         col_append_fstr(pinfo->cinfo, COL_INFO,
7888                                                                 (const gchar*) ncp_rec->req_info_str->first_string,
7889                                                                 get_finfo_value_string(finfo));
7890                                                 }
7891                                         }
7892                                 }
7893                                 else
7894                                 {
7895                                         col_append_fstr(pinfo->cinfo, COL_INFO,
7896                                                 (const gchar*) ncp_rec->req_info_str->first_string,
7897                                                 get_finfo_value_integer(finfo));
7898                                 }
7899                         }
7900                         if (len > 1) {
7901                                 for (i = 1; i < len; i++) {
7902                                         non_uni_string[0]='\0';
7903                                         finfo = g_ptr_array_index(parray, i);
7904                                         info_type = get_info_type((const gchar*) ncp_rec->req_info_str->repeat_string);
7905
7906                                         if (info_type != 0) {    /* Is this  a string or not? */
7907                                               if (info_type == 1)
7908                                               {   /* Is this bytes? */
7909                                                 byte_string = bytes_to_str(get_finfo_value_string(finfo), get_finfo_length(finfo));
7910                                                 col_append_fstr(pinfo->cinfo, COL_INFO,
7911                                                         (const gchar*) ncp_rec->req_info_str->repeat_string,
7912                                                         byte_string);
7913                                               }
7914                                               else
7915                                               {
7916                                                         if (info_type == 2) {   /* Is this a String? */
7917                                                                 uni_to_string(get_finfo_value_string(finfo), get_finfo_length(finfo), non_uni_string);
7918                                                                 col_append_fstr(pinfo->cinfo, COL_INFO,
7919                                                                         (const gchar*) ncp_rec->req_info_str->repeat_string,
7920                                                                         non_uni_string);
7921                                                         }
7922                                                         else
7923                                                         {
7924                                                                 col_append_fstr(pinfo->cinfo, COL_INFO,
7925                                                                         (const gchar*) ncp_rec->req_info_str->repeat_string,
7926                                                                         get_finfo_value_string(finfo));
7927                                                         }
7928                                               }
7929                                         }
7930                                         else
7931                                         {
7932                                                 col_append_fstr(pinfo->cinfo, COL_INFO,
7933                                                         (const gchar*) ncp_rec->req_info_str->repeat_string,
7934                                                         get_finfo_value_integer(finfo));
7935                                         }
7936                                 }
7937                         }
7938                 }
7939         /* Store NCP request specific flags for manual dissection */
7940         if ((func == 0x57 || func == 0x59) && subfunc == 0x14 && ncp_tree && request_value) {
7941             char ret_info_string[16];
7942             char ret_info_string_ext[16];
7943
7944             build_expert_data(ncp_tree, "ncp.ret_info_mask", ret_info_string, 0, FALSE);
7945             request_value->req_mask = atoi(ret_info_string);
7946             build_expert_data(ncp_tree, "ncp.ext_info", ret_info_string_ext, 0, FALSE);
7947             request_value->req_mask_ext = atoi(ret_info_string_ext);
7948         }
7949         /* NCP function 89/6 passes either ASCII or UTF8 data */
7950         /* Decode manually since it is not possible to SREC the request */
7951         /* packets from the python code */
7952         if (func == 0x59 && subfunc == 0x6) {
7953             dissect_ncp_89_6_request(tvb, ncp_tree, 22);
7954         }
7955         /* Check to see if we need to report to the expert table */
7956         trap_for_expert_event(ncp_tree, pinfo, ncp_rec, 0);
7957                 /* Free the temporary proto_tree */
7958                 CLEANUP_CALL_AND_POP;
7959
7960                 /* Re-throw any exception. */
7961                 if (except_code != 0)
7962                         THROW_MESSAGE(except_code, message);
7963         }
7964 }
7965
7966 static void
7967 dissect_nds_ping_reply(tvbuff_t *tvb, packet_info *pinfo _U_,
7968         proto_tree *ncp_tree, ncp_req_hash_value *request_value)
7969 {
7970         nw_uni_t                        reply_buffer;
7971         guint8                          ping_version;
7972         guint32                         nds_string_len;
7973         guint32                         nds_offset;
7974         guint32                         bvalue;
7975         guint32                         nds_flags;
7976         nds_val                                         pvalues[9];
7977             int                                         i;
7978         nstime_t                        ns;
7979
7980         reply_buffer.buffer[0] = '\0';
7981
7982         ping_version = tvb_get_guint8(tvb, 8);
7983         proto_tree_add_item(ncp_tree, hf_ping_version, tvb, 8, 1, TRUE);
7984         if (ping_version == 9) {
7985                 nds_string_len = tvb_get_ntohl(tvb, 9);
7986                 nds_offset = nds_string_len+16;
7987                 tvb_ensure_bytes_exist(tvb, 16, nds_string_len);
7988                 proto_tree_add_item(ncp_tree, hf_nds_tree_name, tvb, 16, nds_string_len, FALSE);
7989                 proto_tree_add_item(ncp_tree, hf_nds_reply_depth, tvb, nds_offset, 4, FALSE);
7990                 proto_tree_add_item(ncp_tree, hf_nds_reply_rev, tvb, (nds_offset+4), 4, FALSE);
7991                 proto_tree_add_item(ncp_tree, hf_nds_reply_flags, tvb, (nds_offset+8), 4, TRUE);
7992         }
7993         else {
7994                 nds_offset = 12;
7995                 nds_flags = request_value->req_nds_flags;
7996                 bvalue = 0x00000001;
7997
7998                 for (i = 0 ; i < 32; i++ ) {
7999                         if (nds_flags & bvalue)
8000                         {
8001                                 switch(bvalue)
8002                                 {
8003                                         case 0x00000001:   /* Supported Fields */
8004                                                 pvalues[0].vvalue = tvb_get_letohs(tvb, nds_offset);
8005                                                 pvalues[0].vtype = VTYPE_BITFIELD;
8006                                                 pvalues[0].vstring = "";
8007                                                 pvalues[0].vdesc = "Ping (low) Flags:";
8008                                                 pvalues[0].vlength = 2;
8009                                                 pvalues[0].hfname= hf_nds_rflags;
8010                                                 pvalues[0].voffset = nds_offset;
8011                                                 pvalues[0].bit1 = "Supported Fields";
8012                                                 pvalues[0].bit1hfname = hf_bit1pingflags1;
8013                                                 pvalues[0].bit2 = "Depth";
8014                                                 pvalues[0].bit2hfname = hf_bit2pingflags1;
8015                                                 pvalues[0].bit3 = "Build Number";
8016                                                 pvalues[0].bit3hfname = hf_bit3pingflags1;
8017                                                 pvalues[0].bit4 = "Flags";
8018                                                 pvalues[0].bit4hfname = hf_bit4pingflags1;
8019                                                 pvalues[0].bit5 = "Verification Flags";
8020                                                 pvalues[0].bit5hfname = hf_bit5pingflags1;
8021                                                 pvalues[0].bit6 = "Letter Version";
8022                                                 pvalues[0].bit6hfname = hf_bit6pingflags1;
8023                                                 pvalues[0].bit7 = "OS Version";
8024                                                 pvalues[0].bit7hfname = hf_bit7pingflags1;
8025                                                 pvalues[0].bit8 = "License Flags";
8026                                                 pvalues[0].bit8hfname = hf_bit8pingflags1;
8027                                                 pvalues[0].bit9 = "DS Time";
8028                                                 pvalues[0].bit9hfname = hf_bit9pingflags1;
8029                                                 pvalues[0].bit10 = "Server Time";
8030                                                 pvalues[0].bit10hfname = hf_bit10pingflags1;
8031                                                 pvalues[0].bit11 = "Create Time";
8032                                                 pvalues[0].bit11hfname = hf_bit11pingflags1;
8033                                                 pvalues[0].bit12 = "Not Defined";
8034                                                 pvalues[0].bit12hfname = hf_bit12pingflags1;
8035                                                 pvalues[0].bit13 = "Not Defined";
8036                                                 pvalues[0].bit13hfname = hf_bit13pingflags1;
8037                                                 pvalues[0].bit14 = "Not Defined";
8038                                                 pvalues[0].bit14hfname = hf_bit14pingflags1;
8039                                                 pvalues[0].bit15 = "Not Defined";
8040                                                 pvalues[0].bit15hfname = hf_bit15pingflags1;
8041                                                 pvalues[0].bit16 = "Not Defined";
8042                                                 pvalues[0].bit16hfname = hf_bit16pingflags1;
8043
8044                                                 process_bitfield(ncp_tree, tvb, &pvalues[0]);
8045                                                 nds_offset += 2;
8046
8047                                                 pvalues[0].vvalue = tvb_get_letohs(tvb, nds_offset);
8048                                                 pvalues[0].vtype = VTYPE_BITFIELD;
8049                                                 pvalues[0].vstring = "";
8050                                                 pvalues[0].vdesc = "Ping (high) Flags:";
8051                                                 pvalues[0].vlength = 2;
8052                                                 pvalues[0].hfname= hf_nds_rflags;
8053                                                 pvalues[0].voffset = nds_offset;
8054                                                 pvalues[0].bit1 = "Sap Name";
8055                                                 pvalues[0].bit1hfname = hf_bit1pingflags2;
8056                                                 pvalues[0].bit2 = "Tree Name";
8057                                                 pvalues[0].bit2hfname = hf_bit2pingflags2;
8058                                                 pvalues[0].bit3 = "OS Name";
8059                                                 pvalues[0].bit3hfname = hf_bit3pingflags2;
8060                                                 pvalues[0].bit4 = "Hardware Name";
8061                                                 pvalues[0].bit4hfname = hf_bit4pingflags2;
8062                                                 pvalues[0].bit5 = "Vendor Name";
8063                                                 pvalues[0].bit5hfname = hf_bit5pingflags2;
8064                                                 pvalues[0].bit6 = "Not Defined";
8065                                                 pvalues[0].bit6hfname = hf_bit6pingflags2;
8066                                                 pvalues[0].bit7 = "Not Defined";
8067                                                 pvalues[0].bit7hfname = hf_bit7pingflags2;
8068                                                 pvalues[0].bit8 = "Not Defined";
8069                                                 pvalues[0].bit8hfname = hf_bit8pingflags2;
8070                                                 pvalues[0].bit9 = "Not Defined";
8071                                                 pvalues[0].bit9hfname = hf_bit9pingflags2;
8072                                                 pvalues[0].bit10 = "Not Defined";
8073                                                 pvalues[0].bit10hfname = hf_bit10pingflags2;
8074                                                 pvalues[0].bit11 = "Not Defined";
8075                                                 pvalues[0].bit11hfname = hf_bit11pingflags2;
8076                                                 pvalues[0].bit12 = "Not Defined";
8077                                                 pvalues[0].bit12hfname = hf_bit12pingflags2;
8078                                                 pvalues[0].bit13 = "Not Defined";
8079                                                 pvalues[0].bit13hfname = hf_bit13pingflags2;
8080                                                 pvalues[0].bit14 = "Not Defined";
8081                                                 pvalues[0].bit14hfname = hf_bit14pingflags2;
8082                                                 pvalues[0].bit15 = "Not Defined";
8083                                                 pvalues[0].bit15hfname = hf_bit15pingflags2;
8084                                                 pvalues[0].bit16 = "Not Defined";
8085                                                 pvalues[0].bit16hfname = hf_bit16pingflags2;
8086
8087                                                 process_bitfield(ncp_tree, tvb, &pvalues[0]);
8088                                                 nds_offset += 2;
8089                                                 break;
8090                                         case 0x00000002:
8091                                                 proto_tree_add_item(ncp_tree, hf_nds_reply_depth, tvb, nds_offset, 4, TRUE);
8092                                                 nds_offset += 4;
8093                                                 break;
8094                                         case 0x00000004:
8095                                                 proto_tree_add_item(ncp_tree, hf_nds_reply_rev, tvb, nds_offset, 4, TRUE);
8096                                                 nds_offset += 4;
8097                                                 break;
8098                                         case 0x00000008:
8099                                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8100                                                 pvalues[0].vtype = VTYPE_BITFIELD;
8101                                                 pvalues[0].vstring = "";
8102                                                 pvalues[0].vdesc = "Pong Data Flags:";
8103                                                 pvalues[0].vlength = 4;
8104                                                 pvalues[0].hfname= hf_nds_rflags;
8105                                                 pvalues[0].voffset = nds_offset;
8106                                                 pvalues[0].bit1 = "Root Most Master Replica";
8107                                                 pvalues[0].bit1hfname = hf_bit1pingpflags1;
8108                                                 pvalues[0].bit2 = "Time Synchronized?";
8109                                                 pvalues[0].bit2hfname = hf_bit2pingpflags1;
8110                                                 pvalues[0].bit3 = "Time Valid?";
8111                                                 pvalues[0].bit3hfname = hf_bit3pingpflags1;
8112                                                 pvalues[0].bit4 = "DS Time Synchronized?";
8113                                                 pvalues[0].bit4hfname = hf_bit4pingpflags1;
8114                                                 pvalues[0].bit5 = "Agent Has All Replicas?";
8115                                                 pvalues[0].bit5hfname = hf_bit5pingpflags1;
8116                                                 pvalues[0].bit6 = "Not Defined";
8117                                                 pvalues[0].bit6hfname = hf_bit6pingpflags1;
8118                                                 pvalues[0].bit7 = "Not Defined";
8119                                                 pvalues[0].bit7hfname = hf_bit7pingpflags1;
8120                                                 pvalues[0].bit8 = "Not Defined";
8121                                                 pvalues[0].bit8hfname = hf_bit8pingpflags1;
8122                                                 pvalues[0].bit9 = "Not Defined";
8123                                                 pvalues[0].bit9hfname = hf_bit9pingpflags1;
8124                                                 pvalues[0].bit10 = "Not Defined";
8125                                                 pvalues[0].bit10hfname = hf_bit10pingpflags1;
8126                                                 pvalues[0].bit11 = "Not Defined";
8127                                                 pvalues[0].bit11hfname = hf_bit11pingpflags1;
8128                                                 pvalues[0].bit12 = "Not Defined";
8129                                                 pvalues[0].bit12hfname = hf_bit12pingpflags1;
8130                                                 pvalues[0].bit13 = "Not Defined";
8131                                                 pvalues[0].bit13hfname = hf_bit13pingpflags1;
8132                                                 pvalues[0].bit14 = "Not Defined";
8133                                                 pvalues[0].bit14hfname = hf_bit14pingpflags1;
8134                                                 pvalues[0].bit15 = "Not Defined";
8135                                                 pvalues[0].bit15hfname = hf_bit15pingpflags1;
8136                                                 pvalues[0].bit16 = "Not Defined";
8137                                                 pvalues[0].bit16hfname = hf_bit16pingpflags1;
8138
8139                                                 process_bitfield(ncp_tree, tvb, &pvalues[0]);
8140                                                 nds_offset += 4;
8141                                                 break;
8142                                         case 0x00000010:
8143                                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8144                                                 pvalues[0].vtype = VTYPE_BITFIELD;
8145                                                 pvalues[0].vstring = "";
8146                                                 pvalues[0].vdesc = "Verification Flags:";
8147                                                 pvalues[0].vlength = 4;
8148                                                 pvalues[0].hfname= hf_nds_rflags;
8149                                                 pvalues[0].voffset = nds_offset;
8150                                                 pvalues[0].bit1 = "Checksum Verification";
8151                                                 pvalues[0].bit1hfname = hf_bit1pingvflags1;
8152                                                 pvalues[0].bit2 = "CRC32 Verification";
8153                                                 pvalues[0].bit2hfname = hf_bit2pingvflags1;
8154                                                 pvalues[0].bit3 = "Server Verification Enforced";
8155                                                 pvalues[0].bit3hfname = hf_bit3pingvflags1;
8156                                                 pvalues[0].bit4 = "Not Defined";
8157                                                 pvalues[0].bit4hfname = hf_bit4pingvflags1;
8158                                                 pvalues[0].bit5 = "Not Defined";
8159                                                 pvalues[0].bit5hfname = hf_bit5pingvflags1;
8160                                                 pvalues[0].bit6 = "Not Defined";
8161                                                 pvalues[0].bit6hfname = hf_bit6pingvflags1;
8162                                                 pvalues[0].bit7 = "Not Defined";
8163                                                 pvalues[0].bit7hfname = hf_bit7pingvflags1;
8164                                                 pvalues[0].bit8 = "Not Defined";
8165                                                 pvalues[0].bit8hfname = hf_bit8pingvflags1;
8166                                                 pvalues[0].bit9 = "Not Defined";
8167                                                 pvalues[0].bit9hfname = hf_bit9pingvflags1;
8168                                                 pvalues[0].bit10 = "Not Defined";
8169                                                 pvalues[0].bit10hfname = hf_bit10pingvflags1;
8170                                                 pvalues[0].bit11 = "Not Defined";
8171                                                 pvalues[0].bit11hfname = hf_bit11pingvflags1;
8172                                                 pvalues[0].bit12 = "Not Defined";
8173                                                 pvalues[0].bit12hfname = hf_bit12pingvflags1;
8174                                                 pvalues[0].bit13 = "Not Defined";
8175                                                 pvalues[0].bit13hfname = hf_bit13pingvflags1;
8176                                                 pvalues[0].bit14 = "Not Defined";
8177                                                 pvalues[0].bit14hfname = hf_bit14pingvflags1;
8178                                                 pvalues[0].bit15 = "Not Defined";
8179                                                 pvalues[0].bit15hfname = hf_bit15pingvflags1;
8180                                                 pvalues[0].bit16 = "Not Defined";
8181                                                 pvalues[0].bit16hfname = hf_bit16pingvflags1;
8182
8183                                                 process_bitfield(ncp_tree, tvb, &pvalues[0]);
8184                                                 nds_offset += 4;
8185                                                 break;
8186                                         case 0x00000020:
8187                                                 proto_tree_add_item(ncp_tree, hf_nds_letter_ver, tvb, nds_offset, 4, TRUE);
8188                                                 nds_offset += 4;
8189                                                 break;
8190                                         case 0x00000040:
8191                                                 proto_tree_add_item(ncp_tree, hf_nds_os_majver, tvb, nds_offset, 4, TRUE);
8192                                                 nds_offset += 4;
8193                                                 proto_tree_add_item(ncp_tree, hf_nds_os_minver, tvb, nds_offset, 4, TRUE);
8194                                                 nds_offset += 4;
8195                                                 proto_tree_add_item(ncp_tree, hf_ncp_os_revision, tvb, nds_offset, 4, TRUE);
8196                                                 nds_offset += 4;
8197                                                 break;
8198                                         case 0x00000100:
8199                                                 proto_tree_add_item(ncp_tree, hf_nds_lic_flags, tvb, nds_offset, 4, TRUE);
8200                                                 nds_offset += 4;
8201                                                 break;
8202                                         case 0x00000200:
8203                                                 ns.secs = tvb_get_letohl(tvb, nds_offset);
8204                                                 ns.nsecs = 0;
8205                                                 proto_tree_add_time(ncp_tree, hf_nds_ds_time, tvb, nds_offset, 4, &ns);
8206                                                 nds_offset += 4;
8207                                                 break;
8208                                         case 0x00000400:
8209                                                 ns.secs = tvb_get_letohl(tvb, nds_offset);
8210                                                 ns.nsecs = 0;
8211                                                 proto_tree_add_time(ncp_tree, hf_nds_svr_time, tvb, nds_offset, 4, &ns);
8212                                                 nds_offset += 4;
8213                                                 break;
8214                                         case 0x00000800:
8215                                                 ns.secs = tvb_get_letohl(tvb, nds_offset);
8216                                                 ns.nsecs = 0;
8217                                                 proto_tree_add_time(ncp_tree, hf_nds_crt_time, tvb, nds_offset, 4, &ns);
8218                                                 nds_offset += 4;
8219                                                 break;
8220                                         case 0x00010000:
8221                                                 if(tvb_get_guint8(tvb, nds_offset) == 0x00)
8222                                                 {
8223                                                         nds_offset += 2;
8224                                                 }
8225                                                 nds_string_len = tvb_get_letohl(tvb, nds_offset);
8226                                                 nds_offset += 4;
8227                                                 get_string(tvb, nds_offset, nds_string_len, reply_buffer.buffer);
8228                                                 tvb_ensure_bytes_exist(tvb, nds_offset, nds_string_len);
8229                                                 proto_tree_add_text(ncp_tree, tvb, nds_offset, nds_string_len, "SAP Name: %s", reply_buffer.buffer);
8230                                                 nds_offset += nds_string_len;
8231                                                 nds_offset += align_4(tvb, nds_offset);
8232                                                 break;
8233                                         case 0x00020000:
8234                                                 if(tvb_get_guint8(tvb, nds_offset) == 0x00)
8235                                                 {
8236                                                         nds_offset += 2;
8237                                                 }
8238                                                 nds_string_len = tvb_get_letohl(tvb, nds_offset);
8239                                                 nds_offset += 4;
8240                                                 get_string(tvb, nds_offset, nds_string_len, reply_buffer.buffer);
8241                                                 tvb_ensure_bytes_exist(tvb, nds_offset, nds_string_len);
8242                                                 proto_tree_add_text(ncp_tree, tvb, nds_offset, nds_string_len, "NDS Tree Name: %s", reply_buffer.buffer);
8243                                                 nds_offset += nds_string_len;
8244                                                 nds_offset += align_4(tvb, nds_offset);
8245                                                 break;
8246                                         case 0x00040000:
8247                                                 if(tvb_get_guint8(tvb, nds_offset) == 0x00)
8248                                                 {
8249                                                         nds_offset += 2;
8250                                                 }
8251                                                 nds_string_len = tvb_get_letohl(tvb, nds_offset);
8252                                                 nds_offset += 4;
8253                                                 get_string(tvb, nds_offset, nds_string_len, reply_buffer.buffer);
8254                                                 tvb_ensure_bytes_exist(tvb, nds_offset, nds_string_len);
8255                                                 proto_tree_add_text(ncp_tree, tvb, nds_offset, nds_string_len, "OS Name: %s", reply_buffer.buffer);
8256                                                 nds_offset += nds_string_len;
8257                                                 nds_offset += align_4(tvb, nds_offset);
8258                                                 break;
8259                                         case 0x00080000:
8260                                                 if(tvb_get_guint8(tvb, nds_offset) == 0x00)
8261                                                 {
8262                                                         nds_offset += 2;
8263                                                 }
8264                                                 nds_string_len = tvb_get_letohl(tvb, nds_offset);
8265                                                 nds_offset += 4;
8266                                                 get_string(tvb, nds_offset, nds_string_len, reply_buffer.buffer);
8267                                                 tvb_ensure_bytes_exist(tvb, nds_offset, nds_string_len);
8268                                                 proto_tree_add_text(ncp_tree, tvb, nds_offset, nds_string_len, "Hardware Name: %s", reply_buffer.buffer);
8269                                                 nds_offset += nds_string_len;
8270                                                 nds_offset += align_4(tvb, nds_offset);
8271                                                 break;
8272                                         case 0x00100000:
8273                                                 if(tvb_get_guint8(tvb, nds_offset) == 0x00)
8274                                                 {
8275                                                         nds_offset += 2;
8276                                                 }
8277                                                 nds_string_len = tvb_get_letohl(tvb, nds_offset);
8278                                                 nds_offset += 4;
8279                                                 get_string(tvb, nds_offset, nds_string_len, reply_buffer.buffer);
8280                                                 tvb_ensure_bytes_exist(tvb, nds_offset, nds_string_len);
8281                                                 proto_tree_add_text(ncp_tree, tvb, nds_offset, nds_string_len, "Vendor Name: %s", reply_buffer.buffer);
8282                                                 nds_offset += nds_string_len;
8283                                                 nds_offset += align_4(tvb, nds_offset);
8284                                                 break;
8285                                         default:
8286                                                 break;
8287                                 }
8288                         }
8289                         bvalue = bvalue*2;
8290                 }
8291         }
8292 }
8293
8294 static void
8295 dissect_nds_reply(tvbuff_t *tvb, packet_info *pinfo,
8296         proto_tree *ncp_tree, guint32 nds_error_code,
8297         const char *nds_error_string, ncp_req_hash_value *request_value,
8298         conversation_t *conversation)
8299 {
8300         guint32                         nds_offset;
8301         guint32                         nds_reply_buffer;
8302         guint32                         nds_frag;
8303         const char                      *verb_string;
8304         nds_val                         pvalues[9];
8305         char                            string_buffer[9][1024];
8306         gboolean                        resolve_eid=FALSE;
8307         guint32                         global_eid=0;
8308         gboolean                        add_eid = FALSE;
8309         char                            global_object_name[256];
8310         ncp_req_eid_hash_value              *request_eid_value = NULL;
8311         int                                             i;
8312
8313         global_object_name[0] = '\0';
8314
8315         nds_offset = 8;
8316
8317         nds_reply_buffer = tvb_get_letohl(tvb, nds_offset);
8318         proto_tree_add_uint(ncp_tree, hf_ncp_fragment_size, tvb, nds_offset,
8319                 4, nds_reply_buffer);
8320         nds_offset += 4;
8321         nds_frag = tvb_get_letohl(tvb, nds_offset);
8322         proto_tree_add_uint(ncp_tree, hf_ncp_fragment_handle, tvb, nds_offset,
8323                 4, nds_frag);
8324         nds_offset += 4;
8325         /*
8326          * Is the possibly-reassembled reply large enough to have a completion
8327          * code?  (We can't check the fragment size as this might just be the
8328          * last fragment.)
8329          */
8330         if (tvb_reported_length_remaining(tvb, nds_offset) >= 4)
8331         {
8332                 /* Yes - process the completion code. */
8333                 expert_item = proto_tree_add_uint_format(ncp_tree, hf_nds_reply_error, tvb, nds_offset,
8334                         4, nds_error_code, "NDS Completion Code: 0x%08x, %s",
8335                         nds_error_code, nds_error_string);
8336
8337                 if (nds_error_code != 0 && ncp_echo_err) {
8338                         expert_add_info_format(pinfo, expert_item, PI_RESPONSE_CODE, PI_ERROR, "NDS Error: 0x%08x %s", nds_error_code, nds_error_string);
8339                 }
8340         }
8341         if (request_value && nds_error_code == 0x00000000)
8342         {
8343             nds_offset = 20;
8344             for (i = 0; i < 9; i++) {
8345                         pvalues[i].vtype = 0;
8346                             pvalues[i].vvalue = 0;
8347                             pvalues[i].vlength = 0;
8348                             pvalues[i].voffset = 0;
8349                             pvalues[i].hfname = 0;
8350                             pvalues[i].vdesc = "";
8351                             string_buffer[i][0] = '\0';
8352                             pvalues[i].vstring = string_buffer[i];
8353                             pvalues[i].mvtype = 0;
8354                     }
8355             verb_string = val_to_str(request_value->nds_request_verb,
8356                     ncp_nds_verb_vals, "Continuation Fragment");
8357             if(request_value->req_nds_prot_flags & 0x4000)
8358             {
8359                 /* CRC is included in the NDS header so justify the offset */
8360                 proto_tree_add_item(ncp_tree, hf_nds_crc, tvb, nds_offset, 4, TRUE);
8361                 nds_offset += 4;
8362             }
8363             switch (request_value->nds_request_verb)
8364                 {
8365                         case 0x01:
8366                                         pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8367                                         pvalues[0].vstring = (char *)match_strval(pvalues[0].vvalue, nds_tags);
8368                                         if(pvalues[0].vstring == NULL)
8369                                         {
8370                                                 pvalues[0].vstring = "No Tags Set";
8371                                         }
8372                                         pvalues[0].vtype = VTYPE_STRING;
8373                                         pvalues[0].vdesc = "Tag: %s";
8374                                         pvalues[0].vlength = 4;
8375                                         pvalues[0].voffset = nds_offset;
8376                                         pvalues[0].hfname = hf_nds_tag_string;
8377                                         nds_offset = nds_offset+pvalues[0].vlength;
8378                                         switch(pvalues[0].vvalue)
8379                                         {
8380                                                 case NDS_TAG_NO_SUCH_ENTRY:
8381                                                         break;
8382                                                 case NDS_TAG_LOCAL_ENTRY:
8383                                                         pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8384                                                         pvalues[1].vtype = VTYPE_UINT32;
8385                                                         pvalues[1].vdesc = "Entry ID: 0x%08x";
8386                                                         add_eid = TRUE;
8387                                                         resolve_eid = TRUE;
8388                                                         g_strlcpy(global_object_name, request_value->object_name, 256);
8389                                                         global_eid = pvalues[1].vvalue;
8390                                                         pvalues[1].vlength = 4;
8391                                                         pvalues[1].voffset = nds_offset;
8392                                                         pvalues[1].hfname = hf_nds_eid;
8393                                                         nds_offset = nds_offset+pvalues[1].vlength;
8394                                                         pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8395                                                         pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
8396                                                         pvalues[2].vdesc = "Referral Records: %u";
8397                                                         pvalues[2].vlength = 4;
8398                                                         pvalues[2].voffset = nds_offset;
8399                                                         pvalues[2].hfname = hf_nds_referrals;
8400                                                         pvalues[2].mvtype = MVTYPE_LOC_ADDR_REFERRAL_REPLY;
8401                                                         break;
8402                                                 case NDS_TAG_REMOTE_ENTRY:
8403                                                         nds_offset += 4;   /* GUINT32 reserved field */
8404                                                         pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8405                                                         pvalues[1].vtype = VTYPE_UINT32;
8406                                                         pvalues[1].vdesc = "Entry ID: 0x%08x";
8407                                                         pvalues[1].vlength = 4;
8408                                                         pvalues[1].voffset = nds_offset;
8409                                                         pvalues[1].hfname = hf_nds_eid;
8410                                                         nds_offset = nds_offset+pvalues[1].vlength;
8411                                                         pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8412                                                         pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
8413                                                         pvalues[2].vdesc = "Referral Records: %u";
8414                                                         pvalues[2].vlength = 4;
8415                                                         pvalues[2].voffset = nds_offset;
8416                                                         pvalues[2].hfname = hf_nds_referrals;
8417                                                         pvalues[2].mvtype = MVTYPE_LOC_ADDR_REFERRAL_REPLY;
8418                                                         break;
8419                                                 case NDS_TAG_ALIAS_ENTRY:
8420                                                         pvalues[1].vtype = VTYPE_STRING;
8421                                                         pvalues[1].vdesc = "Alias Name: %s";
8422                                                         pvalues[1].mvtype = MVTYPE_ATTR_REQUEST;
8423                                                         pvalues[1].vvalue = 0;
8424                                                         pvalues[1].vlength = 256;
8425                                                         pvalues[1].vlength = tvb_get_letohl(tvb, nds_offset);
8426                                                         if (pvalues[1].vlength == 0x00)
8427                                                         {
8428                                                                 pvalues[1].vtype = VTYPE_NONE;
8429                                                                 break;
8430                                                         }
8431                                                         pvalues[1].voffset = nds_offset+4;
8432                                                         nds_offset += 4;
8433                                                         get_string(tvb, pvalues[1].voffset, pvalues[1].vlength, pvalues[1].vstring);
8434                                                         nds_offset += pvalues[1].vlength;
8435                                                         nds_offset += align_4(tvb, nds_offset);
8436                                                         pvalues[1].hfname= hf_nds_name;
8437                                                         break;
8438                                                 case NDS_TAG_REFERRAL_INFORMATION:
8439                                                         pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8440                                                         pvalues[1].vtype = VTYPE_UINT32;
8441                                                         pvalues[1].vdesc = "Distance Object is From Root: 0x%08x";
8442                                                         pvalues[1].vlength = 4;
8443                                                         pvalues[1].voffset = nds_offset;
8444                                                         pvalues[1].hfname = hf_nds_eid;
8445                                                         nds_offset = nds_offset+pvalues[1].vlength;
8446                                                         pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8447                                                         pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
8448                                                         pvalues[2].vdesc = "Referral Records: %u";
8449                                                         pvalues[2].vlength = 4;
8450                                                         pvalues[2].voffset = nds_offset;
8451                                                         pvalues[2].hfname = hf_nds_depth;
8452                                                         pvalues[2].mvtype = MVTYPE_ADDR_REFERRAL_REPLY;
8453                                                         break;
8454                                                 case NDS_TAG_ENTRY_AND_REFERRALS:
8455                                                         pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8456                                                         pvalues[1].vtype = VTYPE_UINT32;
8457                                                         pvalues[1].vdesc = "Result Flags: 0x%08x";
8458                                                         pvalues[1].vlength = 4;
8459                                                         pvalues[1].voffset = nds_offset;
8460                                                         pvalues[1].hfname = hf_nds_result_flags;
8461                                                         nds_offset = nds_offset+pvalues[1].vlength;
8462                                                         pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8463                                                         pvalues[2].vtype = VTYPE_UINT32;
8464                                                         pvalues[2].vdesc = "Entry ID: 0x%08x";
8465                                                         add_eid = TRUE;
8466                                                         resolve_eid = TRUE;
8467                                                         global_eid = pvalues[2].vvalue;
8468                                                         g_strlcpy(global_object_name, request_value->object_name, 256);
8469                                                         pvalues[2].vlength = 4;
8470                                                         pvalues[2].voffset = nds_offset;
8471                                                         pvalues[2].hfname = hf_nds_eid;
8472                                                         nds_offset = nds_offset+pvalues[2].vlength;
8473                                                         pvalues[3].vvalue = tvb_get_letohl(tvb, nds_offset);
8474                                                         pvalues[3].vtype = VTYPE_MULTIVALUE_UINT32;
8475                                                         pvalues[3].vdesc = "Referral Records: %u";
8476                                                         pvalues[3].vlength = 4;
8477                                                         pvalues[3].voffset = nds_offset;
8478                                                         pvalues[3].mvtype = MVTYPE_ADDR_REFERRAL_REPLY;
8479                                                         pvalues[3].hfname = hf_nds_referrals;
8480                                                         break;
8481                                                 default:
8482                                                         break;
8483                                         }
8484                                         break;
8485                         case 0x02:
8486                                         nds_offset -= 4;
8487                                         pvalues[0].vvalue = 1;
8488                                         pvalues[0].vtype = VTYPE_MULTIVALUE_UINT32;
8489                                         pvalues[0].vdesc = "Entry Information";
8490                                         pvalues[0].vlength = 0;
8491                                         pvalues[0].voffset = nds_offset;
8492                                         pvalues[0].hfname = hf_nds_name;
8493                                         pvalues[0].mvtype = MVTYPE_LIST_PARTITIONS;
8494                                         pvalues[0].vflags = request_value->req_nds_flags;
8495                                         break;
8496                         case 0x03:
8497                                         pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8498                                         pvalues[0].vtype = VTYPE_UINT32;
8499                                         pvalues[0].vdesc = "Iteration Handle: 0x%08x";
8500                                         pvalues[0].vlength = 4;
8501                                         pvalues[0].voffset = nds_offset;
8502                                         pvalues[0].hfname = hf_nds_iteration;
8503                                         nds_offset = nds_offset+pvalues[0].vlength;
8504                                         pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8505                                         pvalues[1].vstring = (char *)match_strval(pvalues[1].vvalue, nds_info_type);
8506                                         if(pvalues[1].vstring == NULL)
8507                                         {
8508                                                 pvalues[1].vstring = "No Info Type Set";
8509                                         }
8510                                         pvalues[1].vtype = VTYPE_STRING;
8511                                         pvalues[1].vdesc = "Info Type: %s";
8512                                         pvalues[1].vlength = 4;
8513                                         pvalues[1].voffset = nds_offset;
8514                                         pvalues[1].hfname = hf_nds_info_type;
8515                                         nds_offset = nds_offset+pvalues[1].vlength;
8516                                         pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8517                                         pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
8518                                         pvalues[2].vdesc = "Number of Attributes: %u";
8519                                         pvalues[2].vlength = 4;
8520                                         pvalues[2].voffset = nds_offset;
8521                                         pvalues[2].hfname = hf_nds_attr;
8522                                         pvalues[2].mvtype = MVTYPE_ATTR_REPLY;
8523                                         pvalues[2].vflags = request_value->req_nds_flags;
8524                                         pvalues[2].nds_version = request_value->nds_version;
8525                                         break;
8526                         case 0x04:
8527                                 pvalues[0].vvalue = tvb_get_guint8(tvb, nds_offset);
8528                                 if (pvalues[0].vvalue == 0)
8529                                 {
8530                                         pvalues[0].vstring = "Did Not Match";
8531                                 }
8532                                 else
8533                                 {
8534                                         pvalues[0].vstring = "Matched";
8535                                 }
8536                                 pvalues[0].vtype = VTYPE_STRING;
8537                                 pvalues[0].vdesc = "Compare Values Returned - %s";
8538                                 pvalues[0].vlength = 1;
8539                                 pvalues[0].voffset = nds_offset;
8540                                 pvalues[0].mvtype = 0;
8541                                 pvalues[0].hfname= hf_nds_compare_results;
8542                                 nds_offset += pvalues[0].vlength;
8543                                 break;
8544                         case 0x05:
8545                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8546                                 pvalues[0].vtype = VTYPE_UINT32;
8547                                 pvalues[0].vdesc = "Iteration Handle: 0x%08x";
8548                                 pvalues[0].vlength = 4;
8549                                 pvalues[0].voffset = nds_offset;
8550                                 pvalues[0].hfname = hf_nds_iteration;
8551                                 nds_offset = nds_offset+pvalues[0].vlength;
8552                                 pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8553                                 pvalues[1].vtype = VTYPE_MULTIVALUE_UINT32;
8554                                 pvalues[1].vdesc = "Entry Information";
8555                                 pvalues[1].vlength = 0;
8556                                 pvalues[1].voffset = nds_offset;
8557                                 pvalues[1].hfname = hf_nds_name;
8558                                 pvalues[1].mvtype = MVTYPE_LIST_PARTITIONS;
8559                                 pvalues[1].vflags = request_value->req_nds_flags;
8560                                 break;
8561                         case 0x06:
8562                                 break;
8563                         case 0x07:
8564                                 break;
8565                         case 0x08:
8566                                 break;
8567                         case 0x09:
8568                                 break;
8569                         case 0x0a:
8570                                 break;
8571                         case 0x0b:
8572                                 break;
8573                         case 0x0c:
8574                                 break;
8575                         case 0x0d:
8576                                 break;
8577                         case 0x0e:
8578                                 break;
8579                         case 0x0f:
8580                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8581                                 pvalues[0].vtype = VTYPE_UINT32;
8582                                 pvalues[0].vdesc = "Iteration Handle: 0x%08x";
8583                                 pvalues[0].vlength = 4;
8584                                 pvalues[0].voffset = nds_offset;
8585                                 pvalues[0].hfname = hf_nds_iteration;
8586                                 nds_offset = nds_offset+pvalues[0].vlength;
8587                                 pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8588                                 pvalues[1].vstring = (char *)match_strval(pvalues[1].vvalue, class_def_type);
8589                                 if(pvalues[1].vstring == NULL)
8590                                 {
8591                                         pvalues[1].vstring = "No Class Definition Type Set";
8592                                 }
8593                                 pvalues[1].vtype = VTYPE_STRING;
8594                                 pvalues[1].vdesc = "Class Definition Type: %s";
8595                                 pvalues[1].vlength = 4;
8596                                 pvalues[1].voffset = nds_offset;
8597                                 pvalues[1].mvtype = 0;
8598                                 pvalues[1].hfname= hf_nds_class_def_type;
8599                                 nds_offset = nds_offset + pvalues[1].vlength;
8600                                 pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);;
8601                                 pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
8602                                 pvalues[2].vdesc = "Class Definitions %u";
8603                                 pvalues[2].vlength = 0;
8604                                 pvalues[2].voffset = nds_offset;
8605                                 pvalues[2].hfname = hf_nds_classes;
8606                                 pvalues[2].mvtype = MVTYPE_CLASS_NAMES;
8607                                 pvalues[2].vflags = request_value->req_nds_flags;
8608                                 break;
8609                         case 0x10:
8610                                 break;
8611                         case 0x11:
8612                                 break;
8613                         case 0x12:
8614                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8615                                 pvalues[0].vtype = VTYPE_UINT32;
8616                                 pvalues[0].vdesc = "Iteration Handle: 0x%08x";
8617                                 pvalues[0].vlength = 4;
8618                                 pvalues[0].voffset = nds_offset;
8619                                 pvalues[0].hfname = hf_nds_iteration;
8620                                 nds_offset = nds_offset+pvalues[0].vlength;
8621                                 pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8622                                 pvalues[1].vtype = VTYPE_MULTIVALUE_UINT32;
8623                                 pvalues[1].vdesc = "Classes: %u";
8624                                 pvalues[1].vlength = 4;
8625                                 pvalues[1].voffset = nds_offset;
8626                                 pvalues[1].mvtype = MVTYPE_READ_CLASS_REQ;
8627                                 pvalues[1].hfname= hf_nds_classes;
8628                                 break;
8629                         case 0x13:
8630                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8631                                 pvalues[0].vtype = VTYPE_UINT32;
8632                                 pvalues[0].vdesc = "Privileges: 0x%08x";
8633                                 pvalues[0].vlength = 4;
8634                                 pvalues[0].voffset = nds_offset;
8635                                 pvalues[0].hfname = hf_nds_privileges;
8636                                 nds_offset = nds_offset+pvalues[0].vlength;
8637                                 break;
8638                         case 0x14:
8639                                 break;
8640                         case 0x15:
8641                                 break;
8642                         case 0x16:
8643                                 pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8644                                 pvalues[0].vtype = VTYPE_UINT32;
8645                                 pvalues[0].vdesc = "Iteration Handle: 0x%08x";
8646                                 pvalues[0].vlength = 4;
8647                                 pvalues[0].voffset = nds_offset;
8648                                 pvalues[0].hfname = hf_nds_iteration;
8649                                 nds_offset = nds_offset+pvalues[0].vlength;
8650                                 pvalues[1].vtype = VTYPE_STRING;
8651                                 pvalues[1].vdesc = "Server Distinguished Name: %s";
8652                                 pvalues[1].mvtype = MVTYPE_ATTR_REQUEST;
8653                                 pvalues[1].vvalue = 0;
8654                                 pvalues[1].vlength = 256;
8655                                 pvalues[1].vlength = tvb_get_letohl(tvb, nds_offset);
8656                                 if (pvalues[1].vlength == 0x00)
8657                                 {
8658                                         pvalues[1].vtype = VTYPE_NONE;
8659                                         break;
8660                                 }
8661                                 pvalues[1].voffset = nds_offset+4;
8662                                 nds_offset += 4;
8663                                 get_string(tvb, pvalues[1].voffset, pvalues[1].vlength, pvalues[1].vstring);
8664                                 nds_offset += pvalues[1].vlength;
8665                                 nds_offset += align_4(tvb, nds_offset);
8666                                 pvalues[1].hfname= hf_nds_name;
8667                                 nds_offset += align_4(tvb, nds_offset);
8668                                 pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8669                                 pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
8670                                 pvalues[2].vdesc = "Replicas: %u";
8671                                 pvalues[2].vlength = 4;
8672                                 pvalues[2].voffset = nds_offset;
8673                                 pvalues[2].hfname = hf_nds_replicas;
8674                                 pvalues[2].mvtype = MVTYPE_READ_REPLICAS;
8675                                 pvalues[2].bit1 = "Output Flags";
8676                                 pvalues[2].bit2 = "Entry ID";
8677                                 pvalues[2].bit3 = "Replica State";
8678                                 pvalues[2].bit4 = "Modification Timestamp";
8679                                 pvalues[2].bit5 = "Purge Time";
8680                                 pvalues[2].bit6 = "Local Partition ID";
8681                                 pvalues[2].bit7 = "Distinguished Name";
8682                                 pvalues[2].bit8 = "Replica Type";
8683                                 pvalues[2].bit9 = "Partition Busy";
8684                                 pvalues[2].vflags = request_value->req_nds_flags;
8685                                 break;
8686                         case 0x17:
8687                                 break;
8688                         case 0x18:
8689                                 break;
8690                         case 0x19:
8691                                 break;
8692                         case 0x1a:
8693                                 break;
8694                         case 0x1b:
8695                                 pvalues[0].vvalue = tvb_get_ntohl(tvb, nds_offset);
8696                                 pvalues[0].vtype = VTYPE_UINT32;
8697                                 pvalues[0].vdesc = "File Handle: 0x%08x";
8698                                 pvalues[0].vlength = 4;
8699                                 pvalues[0].voffset = nds_offset;
8700                                 pvalues[0].hfname = hf_nds_file_handle;
8701                                 nds_offset = nds_offset+pvalues[0].vlength;
8702                                 pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8703                                 pvalues[1].vtype = VTYPE_UINT32;
8704                                 pvalues[1].vdesc = "File Size: %u";
8705                                 pvalues[1].vlength = 4;
8706                                 pvalues[1].voffset = nds_offset;
8707                                 pvalues[1].hfname = hf_nds_file_size;
8708                                 nds_offset = nds_offset+pvalues[1].vlength;
8709                                 break;
8710                         case 0x1c:
8711                                 break;
8712                         case 0x1d:
8713                                 break;
8714                         case 0x1e:
8715                                 break;
8716                         case 0x1f:
8717                                 break;
8718                         case 0x20:
8719                                 break;
8720                         case 0x21:
8721                                 break;
8722                         case 0x22:
8723                                 break;
8724                         case 0x23:
8725                                 break;
8726                         case 0x24:
8727                                 break;
8728                         case 0x25:
8729                                 break;
8730                         case 0x26:
8731                                 break;
8732                         case 0x27:
8733                                 break;
8734                         case 0x28:
8735                                 break;
8736                         case 0x29:
8737                                 break;
8738                         case 0x2a:
8739                                 break;
8740                         case 0x2b:
8741                                 break;
8742                         case 0x2c:
8743                                 break;
8744                         case 0x2d:
8745                                 break;
8746                         case 0x2e:
8747                                 break;
8748                         case 0x2f:
8749                                 break;
8750                         case 0x30:
8751                                 break;
8752                         case 0x31:
8753                                 break;
8754                         case 0x32:
8755                                 break;
8756                         case 0x33:
8757                                 break;
8758                         case 0x34:
8759                                 break;
8760                         case 0x35:
8761                                 pvalues[0].vtype = VTYPE_MULTIVALUE_UINT32;
8762                                 pvalues[0].vdesc = "Server Name";
8763                                 pvalues[0].mvtype = MVTYPE_PROCESS_TAGS;
8764                                 pvalues[0].vflags = request_value->req_nds_flags;
8765                                 pvalues[0].hfname = hf_nds_svr_dst_name;
8766                                 pvalues[0].vlength = tvb_get_letohl(tvb, nds_offset);
8767                                 if (pvalues[0].vlength == 0x00)
8768                                 {
8769                                         pvalues[0].vtype = VTYPE_NONE;
8770                                         break;
8771                                 }
8772                                 pvalues[0].voffset = nds_offset;
8773                                 nds_offset += pvalues[0].vlength + 4;
8774                                 nds_offset += align_4(tvb, nds_offset);
8775                                 pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8776                                 pvalues[1].vtype = VTYPE_MULTIVALUE_UINT32;
8777                                 pvalues[1].vdesc = "Referral Records: %u";
8778                                 pvalues[1].vlength = 4;
8779                                 pvalues[1].voffset = nds_offset;
8780                                 pvalues[1].hfname = hf_nds_referrals;
8781                                 pvalues[1].mvtype = MVTYPE_LOC_ADDR_REFERRAL_REPLY;
8782                                 break;
8783                         case 0x36:
8784                                 break;
8785                         case 0x37:
8786                                 break;
8787                         case 0x38:
8788                                 break;
8789                         case 0x39:
8790                                 pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8791                                 pvalues[1].vtype = VTYPE_UINT32;
8792                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
8793                                 add_eid = TRUE;
8794                                 resolve_eid = TRUE;
8795                                 g_strlcpy(global_object_name, request_value->object_name, 256);
8796                                 global_eid = pvalues[1].vvalue;
8797                                 pvalues[1].vlength = 4;
8798                                 pvalues[1].voffset = nds_offset;
8799                                 pvalues[1].hfname = hf_nds_eid;
8800                                 nds_offset = nds_offset+pvalues[1].vlength;
8801                                 break;
8802                         case 0x3a:
8803                                 break;
8804                         case 0x3b:
8805                                 break;
8806                         case 0x3c:
8807                                 break;
8808                         case 0x3d:
8809                                 break;
8810                         case 0x3e:
8811                                 break;
8812                         case 0x3f:
8813                                 break;
8814                         case 0x40:
8815                                 break;
8816                         case 0x41:
8817                                 break;
8818                         case 0x42:
8819                                 break;
8820                         case 0x43:
8821                                 break;
8822                         case 0x44:
8823                                 break;
8824                         case 0x45:
8825                                 break;
8826                         case 0x46:
8827                                 break;
8828                         case 0x47:
8829                                 break;
8830                         case 0x48:
8831                                 break;
8832                         case 0x49:
8833                                 break;
8834                         case 0x4a:
8835                                 break;
8836                         case 0x4b:
8837                                 break;
8838                         case 0x4c:
8839                                 break;
8840                         case 0x4d:
8841                                 break;
8842                         case 0x6e:
8843                             pvalues[0].vvalue = tvb_get_letohl(tvb, nds_offset);
8844                             pvalues[0].vtype = VTYPE_UINT32;
8845                             pvalues[0].vdesc = "Iteration Handle: 0x%08x";
8846                             pvalues[0].vlength = 4;
8847                             pvalues[0].voffset = nds_offset;
8848                             pvalues[0].hfname= hf_nds_iteration;
8849                             nds_offset = nds_offset+pvalues[0].vlength;
8850                             pvalues[1].vvalue = tvb_get_letohl(tvb, nds_offset);
8851                             pvalues[1].vtype = VTYPE_NONE;
8852                             pvalues[1].vdesc = "Iteration Completion Code: 0x%08x";
8853                             pvalues[1].vlength = 4;
8854                             pvalues[1].voffset = nds_offset;
8855                             pvalues[1].hfname = hf_iter_completion_code;
8856                             expert_item = proto_tree_add_uint_format(ncp_tree, pvalues[1].hfname, tvb, nds_offset,
8857                                     4, pvalues[1].vvalue, "NDS Iteration Completion Code: 0x%08x, %s",
8858                                     pvalues[1].vvalue, match_strval(pvalues[1].vvalue, nds_reply_errors));
8859
8860                             if (pvalues[1].vvalue != 0 && ncp_echo_err) {
8861                                     expert_add_info_format(pinfo, expert_item, PI_RESPONSE_CODE, PI_ERROR, "NDS Iteration Error: 0x%08x %s", pvalues[1].vvalue, match_strval(pvalues[1].vvalue, nds_reply_errors));
8862                             }
8863                             nds_offset = nds_offset+pvalues[1].vlength;
8864                             pvalues[2].vvalue = tvb_get_letohl(tvb, nds_offset);
8865                             pvalues[2].vtype = VTYPE_ITEM;
8866                             pvalues[2].vlength = 4;
8867                             pvalues[2].voffset = nds_offset;
8868                             pvalues[2].mvtype = MVTYPE_PROCESS_ITERATOR;
8869                             pvalues[2].hfname = hf_ncp_nds_iterverb;
8870                             nds_offset = nds_offset + pvalues[2].vlength;
8871                             break;
8872                         default:
8873                                 break;
8874                         }
8875                         if(request_value->nds_request_verb != 0)
8876                         {
8877                                 proto_tree_add_uint_format(ncp_tree,
8878                                     hf_ncp_nds_verb, tvb, 6, 0,
8879                                     request_value->nds_request_verb,
8880                                     "NDS Verb: %d, %s",
8881                                     request_value->nds_request_verb, verb_string);
8882                         }
8883                         /* NDS Entry ID's (EID) is identified in the reply
8884                          * packet of an NDS resolve name. We need to store
8885                          * this EID and its associated name into our hash
8886                          * so that we can resolve the name for other NDS
8887                          * requests. */
8888                         if (!pinfo->fd->flags.visited) {
8889                                 if(add_eid)
8890                                 {
8891                                         request_eid_value = ncp_eid_hash_lookup(conversation, global_eid);
8892                                         if (!request_eid_value) {
8893                                                 request_eid_value = ncp_eid_hash_insert(global_eid);
8894                                                 g_strlcpy(request_eid_value->object_name, global_object_name, 256);
8895                                         }
8896                                 }
8897                         }
8898                         /* Echo EID data to expert Chat window */
8899                         if (add_eid && nds_echo_eid) {
8900                             expert_add_info_format(pinfo, NULL,
8901                                 PI_RESPONSE_CODE, PI_CHAT,
8902                                 "EID (%08x) = %s", global_eid, global_object_name);
8903                         }
8904                         /* For NDS requests with just an EID, resolve name
8905                          * from hash table. */
8906                         if(resolve_eid)
8907                         {
8908                                 request_eid_value = ncp_eid_hash_lookup(conversation, global_eid);
8909                                 if (request_eid_value) {
8910                                         g_strlcpy(global_object_name, request_eid_value->object_name, 256);
8911                                         proto_tree_add_string_format(ncp_tree,
8912                                             hf_nds_name, tvb, 6, 0,
8913                                             global_object_name,
8914                                             "NDS Name for EID - %s",
8915                                             global_object_name);
8916                                 }
8917                         }
8918                         for (i = 0; i < 9; i++) {
8919                                 switch (pvalues[i].vtype) {
8920
8921                                 case VTYPE_NONE: /* no value */
8922                                         break;
8923
8924                 case VTYPE_ITEM:
8925                     if (pvalues[i].mvtype == MVTYPE_PROCESS_ITERATOR)
8926                     {
8927                         dissect_nds_iterator(ncp_tree, tvb, pinfo, pvalues[i].vvalue, 0, nds_offset, FALSE);
8928                     }
8929                     else
8930                     {
8931                         proto_tree_add_item(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
8932                             pvalues[i].vlength, TRUE);
8933                     }
8934                                         break;
8935                                 case VTYPE_UINT8:
8936                                         proto_tree_add_uint_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
8937                                             pvalues[i].vlength, pvalues[i].vtype, "NDS Parameter not defined %u",
8938                                             pvalues[i].vtype);
8939                                         break;
8940
8941                                 case VTYPE_UINT16:
8942                                         proto_tree_add_uint_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
8943                                             pvalues[i].vlength, pvalues[i].vtype, "NDS Parameter not defined %u",
8944                                             pvalues[i].vtype);
8945                                         break;
8946
8947                                 case VTYPE_UINT32:
8948                                         proto_tree_add_uint_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
8949                                             pvalues[i].vlength, pvalues[i].vvalue, pvalues[i].vdesc,
8950                                             pvalues[i].vvalue);
8951                                         break;
8952
8953                                 case VTYPE_STRING:
8954                                         proto_tree_add_string_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
8955                                             pvalues[i].vlength, pvalues[i].vstring, pvalues[i].vdesc,
8956                                             pvalues[i].vstring);
8957                                         break;
8958
8959                                 case VTYPE_BITFIELD:
8960                                         process_bitfield(ncp_tree, tvb, &pvalues[i]);
8961                                         break;
8962
8963                 case VTYPE_MULTIVALUE_UINT32:
8964                     process_multivalues(ncp_tree, tvb, pinfo, &pvalues[i]);
8965                                         break;
8966
8967                                 default:
8968                                         proto_tree_add_uint_format(ncp_tree, hf_nds_p1type, tvb, pvalues[i].voffset,
8969                                             pvalues[i].vlength, pvalues[i].vtype, "NDS Parameter not defined %u",
8970                                             pvalues[i].vtype);
8971                                         break;
8972                                 }
8973                 }
8974         }
8975 }
8976
8977 void
8978 dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo,
8979         guint32 nw_connection, guint8 sequence, guint16 type,
8980         proto_tree *ncp_tree, struct novell_tap *ncp_tap)
8981 {
8982         conversation_t                  *conversation = NULL;
8983         ncp_req_hash_value              *request_value = NULL;
8984         const ncp_record                *ncp_rec = NULL;
8985         int                             *req_cond_results;
8986         guint8                          completion_code=0;
8987         ptvcursor_t                     *ptvc = NULL;
8988         const char                      *error_string;
8989         guint32                         nds_offset = 0;
8990         guint32                         nds_error_code = 0;
8991         guint32                         nds_reply_buffer = 0;
8992         const char                      *nds_error_string = NULL;
8993         guint32                         nds_frag=0;
8994
8995 #ifdef FAKE_TREE_IS_VISIBLE
8996         if (ncp_tree) {
8997                 PTREE_DATA(ncp_tree)->visible=1;
8998         }
8999 #endif
9000
9001         if (!pinfo->fd->flags.visited) {
9002                 /* Find the conversation whence the request would have come. */
9003                 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
9004                             PT_NCP, nw_connection, nw_connection, 0);
9005                 if (conversation != NULL) {
9006                         /* find the record telling us the request made that caused
9007                            this reply */
9008                         request_value = ncp_hash_lookup(conversation, sequence);
9009                         if (request_value) {
9010                                 ncp_rec = request_value->ncp_rec;
9011                         }
9012                         p_add_proto_data(pinfo->fd, proto_ncp, (void*) request_value);
9013                 }
9014                 /* else... we haven't seen an NCP Request for that conversation
9015                    and sequence.
9016                    Create Service request packets do not contain nw_connection.
9017                    The initial value is set to 65535 or 0. The reply packet has the
9018                    valid connection. So, we can't find the request packet in
9019                    our conversation list. To trap for this we can just perform
9020                    the search again with 65535 to see if we can locate the
9021                    proper request packet. */
9022                 else {
9023                         conversation = find_conversation(pinfo->fd->num,
9024                             &pinfo->src, &pinfo->dst, PT_NCP, 65535, 65535, 0);
9025                         if (conversation != NULL) {
9026                                 /* find the record telling us the request made
9027                                    that caused this reply */
9028                                 request_value = ncp_hash_lookup(conversation,
9029                                     sequence);
9030                                 if (request_value) {
9031                                         ncp_rec = request_value->ncp_rec;
9032                                 }
9033                                 p_add_proto_data(pinfo->fd, proto_ncp,
9034                                     (void*) request_value);
9035                         }
9036             else {
9037                 conversation = find_conversation(pinfo->fd->num,
9038                     &pinfo->src, &pinfo->dst, PT_NCP, 0, 0, 0);
9039                 if (conversation != NULL) {
9040                     /* find the record telling us the request made
9041                        that caused this reply */
9042                     request_value = ncp_hash_lookup(conversation,
9043                         sequence);
9044                     if (request_value) {
9045                         ncp_rec = request_value->ncp_rec;
9046                     }
9047                     p_add_proto_data(pinfo->fd, proto_ncp,
9048                         (void*) request_value);
9049                 }
9050                 /* else... we haven't seen an NCP Request for that
9051                    conversation and sequence. */
9052             }
9053                 }
9054         }
9055         else {
9056                 request_value = p_get_proto_data(pinfo->fd, proto_ncp);
9057                 if (request_value) {
9058                         ncp_rec = request_value->ncp_rec;
9059                 }
9060         }
9061
9062         /*
9063          * Tap the packet before the dissectors are called so we
9064          * still get the tap listener called even if there is an
9065          * exception.
9066          */
9067         tap_queue_packet(ncp_tap->stat, pinfo, request_value);
9068
9069         if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
9070                 if (ncp_rec && ncp_rec->func==0x68 &&
9071                     (ncp_rec->subfunc==0x02 || ncp_rec->subfunc==0x01)) {
9072                         col_set_str(pinfo->cinfo, COL_PROTOCOL, "NDS");
9073                 }
9074         }
9075
9076         /* A completion code of 0 always means OK. Non-zero means failure,
9077          * but each non-zero value has a different meaning. And the same value
9078          * can have different meanings, depending on the ncp.func (and ncp.subfunc)
9079          * value. */
9080         completion_code = tvb_get_guint8(tvb, 6);
9081         if (completion_code == 0) {
9082                 if(type == NCP_POSITIVE_ACK)
9083                 {
9084                         error_string = "Server Busy, Request Being Processed";
9085                 }
9086                 else
9087                 {
9088                         error_string = "OK";
9089                 }
9090         } else {
9091                 if (ncp_rec && ncp_rec->errors) {
9092                         error_string = ncp_error_string(ncp_rec->errors, completion_code);
9093                 }
9094                 else {
9095                         error_string = "Original Request Packet not Found";
9096                 }
9097         }
9098         if (type == NCP_SERVICE_REPLY && ncp_rec && ncp_rec->func==0x68 &&
9099             ncp_rec->subfunc==0x02 && (tvb_reported_length_remaining(tvb, 8) >= 8))
9100         {
9101                 nds_offset = 8;
9102                 nds_reply_buffer = tvb_get_letohl(tvb, nds_offset);
9103                 nds_offset += 4;
9104                 nds_frag = tvb_get_letohl(tvb, nds_offset);
9105                 nds_offset += 4;
9106                 /*
9107                  * Is the possibly-reassembled reply large enough to have
9108                  * a completion code?  (We can't check the fragment size
9109                  * as this might just be the last fragment.)
9110                  */
9111                 if (tvb_reported_length_remaining(tvb, nds_offset) >= 4)
9112                 {
9113                         /* Yes - process the completion code. */
9114                         nds_error_code = tvb_get_letohl(tvb, nds_offset);
9115                         nds_error_string = match_strval(nds_error_code, nds_reply_errors);
9116                         if (nds_error_string == NULL)
9117                         {
9118                                 nds_error_string = "NDS Error - No Definition Found";
9119                         }
9120                 }
9121         }
9122         if (check_col(pinfo->cinfo, COL_INFO)) {
9123                 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
9124                     type == NCP_SERVICE_REPLY ? "R" : "ACK",
9125                     nds_error_string ? nds_error_string : error_string);
9126         }
9127
9128         if (ncp_tree) {
9129
9130                 if (request_value) {
9131                         nstime_t ns;
9132
9133                         proto_tree_add_uint(ncp_tree, hf_ncp_req_frame_num, tvb, 0, 0,
9134                                 request_value->req_frame_num);
9135                         nstime_delta(&ns, &pinfo->fd->abs_ts, &request_value->req_frame_time);
9136                         proto_tree_add_time(ncp_tree, hf_ncp_req_frame_time, tvb, 0, 0, &ns);
9137                 }
9138
9139                 /* Put the func (and maybe subfunc) from the request packet
9140                  * in the proto tree, but hidden. That way filters on ncp.func
9141                  * or ncp.subfunc will find both the requests and the replies.
9142                  */
9143                 if (ncp_rec) {
9144                         proto_tree_add_uint_format(ncp_tree, hf_ncp_func, tvb, 6, 0,
9145                                 ncp_rec->func, "Function: %u (0x%02X), %s",
9146                                 ncp_rec->func, ncp_rec->func, ncp_rec->name);
9147                         if (ncp_requires_subfunc(ncp_rec->func)) {
9148                                 proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 6, 0,
9149                                         ncp_rec->subfunc, "SubFunction: %u (0x%02x)",
9150                                         ncp_rec->subfunc, ncp_rec->subfunc);
9151                         }
9152                 }
9153         }
9154
9155         expert_item = proto_tree_add_uint_format(ncp_tree, hf_ncp_completion_code, tvb, 6, 1,
9156                 completion_code, "Completion Code: %d (0x89%02x), %s",
9157                 completion_code, completion_code, error_string);
9158         if ((completion_code != 0 || type == NCP_POSITIVE_ACK) && ncp_echo_err) {
9159                 expert_add_info_format(pinfo, expert_item,
9160                     PI_RESPONSE_CODE, PI_ERROR,
9161                     "Error: %d (0x89%02x) %s", completion_code,
9162                     completion_code, error_string);
9163         }
9164
9165         if (ncp_tree) {
9166         guint8    conn_stat;
9167
9168         conn_stat = tvb_get_guint8(tvb, 7);
9169                 expert_item = proto_tree_add_item(ncp_tree, hf_ncp_connection_status, tvb,
9170                     7, 1, FALSE);
9171         if (conn_stat != 0 && conn_stat != 0x40 ) {
9172             if (check_col(pinfo->cinfo, COL_INFO)) {
9173                 col_set_str(pinfo->cinfo, COL_INFO,
9174                     "Error: Bad Connection Status");
9175             }
9176             if (ncp_echo_err) {
9177                 expert_add_info_format(pinfo, expert_item,
9178                     PI_RESPONSE_CODE, PI_ERROR,
9179                     "Error: Bad Connection Status");
9180             }
9181             return;
9182         }
9183         }
9184         /*
9185          * Unless this is a successful reply, that's all there
9186          * is to parse.
9187          */
9188         if (type != NCP_SERVICE_REPLY || completion_code != 0)
9189                 return;
9190
9191         if (ncp_rec) {
9192                 /* Dissect SSS Reply packets */
9193                 if (ncp_rec->func == 0x5c && request_value)
9194                 {
9195                         dissect_sss_reply(tvb, pinfo, ncp_tree, ncp_rec->subfunc, request_value);
9196                 }
9197                 /* Dissect NMAS Reply packets */
9198                 if (ncp_rec->func == 0x5e && request_value)
9199                 {
9200                         dissect_nmas_reply(tvb, pinfo, ncp_tree, ncp_rec->func, ncp_rec->subfunc, request_value);
9201                 }
9202                 /* Dissect NDS Ping packets */
9203                 if (ncp_rec->func == 0x68 && ncp_rec->subfunc == 0x01)
9204                 {
9205                         dissect_nds_ping_reply(tvb, pinfo, ncp_tree,
9206                             request_value);
9207                 }
9208                 /* Dissect NDS Reply packets */
9209                 if (ncp_rec->func == 0x68 && ncp_rec->subfunc == 0x02)
9210                 {
9211                         dissect_nds_reply(tvb, pinfo, ncp_tree, nds_error_code,
9212                             nds_error_string, request_value, conversation);
9213                 }
9214                 /* Due to lack of group repeat fields in reply structure, decode this ncp 87/20 reply manually here. */
9215                 if ((ncp_rec->func == 0x57 || ncp_rec->func == 0x59) && ncp_rec->subfunc == 0x14) {
9216                         dissect_ncp_8x20reply(tvb, ncp_tree, ncp_rec, request_value);
9217                 }
9218                 /* Process ncp 23/26 address records manually to format correctly. */
9219                 if (ncp_rec->func == 0x17 && ncp_rec->subfunc == 0x1a) {
9220                         dissect_ncp_23_26_reply(tvb, ncp_tree);
9221                 }
9222                 if (ncp_rec->func == 5 && ncp_echo_conn) {
9223                     expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Connection Destroyed");
9224                 }
9225                 if (ncp_rec->reply_ptvc) {
9226                         /* If we're not building a protocol tree, quit;
9227                          * "process_ptvc_record()" assumes we're building
9228                          * a protocol tree, and we don't support putting
9229                          * stuff in the Info column in replies, and no
9230                          * state information is currently updated for
9231                          * replies by "process_ptvc_record()", so we
9232                          * can't, and don't have a reason to, dissect
9233                          * any further if we're not building a protocol
9234                          * tree. */
9235                         if (!ncp_tree)
9236                                 return;
9237
9238                         /* If a non-zero completion code was found, it is
9239                          * legal to not have any fields, even if the packet
9240                          * type is defined as having fields.
9241                          *
9242                          * XXX - we already know that the completion code
9243                          * is 0, as we checked it above.  Is there any
9244                          * reason why we'd want to do a full dissection
9245                          * if the completion code isn't 0? */
9246                         if (completion_code != 0 && tvb_length(tvb) == 8) {
9247                                 return;
9248                         }
9249
9250                         /* Any request condition results? */
9251                         if (request_value) {
9252                                 req_cond_results = request_value->req_cond_results;
9253                         }
9254                         else {
9255                                 req_cond_results = NULL;
9256                         }
9257                         clear_repeat_vars();
9258                         ptvc = ptvcursor_new(ncp_tree, tvb, 8);
9259                         process_ptvc_record(ptvc, ncp_rec->reply_ptvc,
9260                                 req_cond_results, TRUE, ncp_rec);
9261                         ptvcursor_free(ptvc);
9262
9263                         /* Echo the NDS EID and name for NCP 22,51 replies to expert tap */
9264                         if (!pinfo->fd->flags.visited && ncp_rec->func == 0x16 && ncp_rec->subfunc == 0x33) {
9265
9266                             char    eid_string[10];
9267                             char    global_object_name[256];
9268
9269                             build_expert_data(ncp_tree, "ncp.directory_services_object_id", eid_string, 0, TRUE);
9270                             build_expert_data(ncp_tree, "ncp.volume_name_len", global_object_name, 0, FALSE);
9271
9272                             /* Echo EID data to expert Chat window */
9273                             if (nds_echo_eid) {
9274                                 expert_add_info_format(pinfo, NULL,
9275                                     PI_RESPONSE_CODE, PI_CHAT,
9276                                     "EID (%s) = %s", eid_string, global_object_name);
9277                             }
9278                         }
9279                         /* Process ncp 123/17 address records manually to format correctly. */
9280                         if (ncp_rec->func == 0x7b && ncp_rec->subfunc == 0x11) {
9281                                 dissect_ncp_123_17_reply(tvb, ncp_tree);
9282                         }
9283                         /* Process ncp 123/11 NLM names manually to format correctly. */
9284                         if (ncp_rec->func == 0x7b && ncp_rec->subfunc == 0x0b && request_value) {
9285                                 dissect_ncp_123_11_reply(tvb, ncp_tree, request_value);
9286                         }
9287                         /* Process ncp 123/62 server set parameter values manually to format correctly. */
9288                         if (ncp_rec->func == 0x7b && ncp_rec->subfunc == 0x3e) {
9289                                 dissect_ncp_123_62_reply(tvb, ncp_tree);
9290                         }
9291                 }
9292                 /* Check to see if we need to report to the expert table */
9293                 trap_for_expert_event(ncp_tree, pinfo, ncp_rec, 1);
9294         } else {
9295                 if (tvb_length(tvb) > 8) {
9296                         expert_item = proto_tree_add_text(ncp_tree, tvb, 8, -1,
9297                             "No request record found. Parsing is impossible.");
9298                         if (ncp_echo_err) {
9299                             expert_add_info_format(pinfo, expert_item, PI_SEQUENCE, PI_NOTE, "No request record found.");
9300                         }
9301                 }
9302         }
9303 }
9304
9305 void
9306 dissect_nds_request(tvbuff_t *tvb, packet_info *pinfo,
9307                 guint32 nw_connection, guint8 sequence,
9308                 guint16 type, proto_tree *ncp_tree)
9309 {
9310         guint8                  func, subfunc = 0;
9311         ncp_req_hash_value      *request_value = NULL;
9312         ncp_req_eid_hash_value  *request_eid_value = NULL;
9313         const ncp_record        *ncp_rec = NULL;
9314         conversation_t          *conversation;
9315         ptvcursor_t             *ptvc = NULL;
9316         proto_tree              *temp_tree = NULL;
9317         gboolean                run_req_cond = FALSE;
9318         gboolean                run_info_str = FALSE;
9319         guint8                  nds_verb = 0;
9320         const char              *verb_string = "";
9321         guint32                 nds_frag = 0;
9322         gboolean                added_arrow;
9323         nds_val                 pvalues[9], prot_flags[1];
9324         char                    string_buffer[9][1024];
9325         guint8                  nds_version = 0;
9326         guint32                 foffset = 0;
9327         nw_uni_t                req_buffer;
9328         char                    global_object_name[256];
9329         guint32                 global_eid=0;
9330         gboolean                resolve_eid=FALSE;
9331         guint32                 global_flags=0, nds_prot_flags=0;
9332         int                                 i;
9333
9334         for (i = 0; i < 9; i++) {
9335                 pvalues[i].vtype = 0;
9336                 pvalues[i].vvalue = 0;
9337                 pvalues[i].vlength = 0;
9338                 pvalues[i].voffset = 0;
9339                 pvalues[i].hfname = 0;
9340                 pvalues[i].vdesc = "";
9341                 string_buffer[i][0] = '\0';
9342                 pvalues[i].vstring = string_buffer[i];
9343                 pvalues[i].mvtype = 0;
9344                 pvalues[i].vflags = 0;
9345         }
9346
9347         req_buffer.buffer[0] = '\0';
9348         global_object_name[0] = '\0';
9349
9350         func = tvb_get_guint8(tvb, 6);
9351         subfunc = tvb_get_guint8(tvb, 7);
9352
9353         ncp_rec = ncp_record_find(func, subfunc);
9354
9355         /* Check to see if this is a fragment packet */
9356         nds_frag = tvb_get_letohl(tvb, 8);
9357
9358         /* Get NDS Verb */
9359         if (nds_frag == 0xffffffff) {
9360                 /* First fragment or only fragment. */
9361                 nds_verb = tvb_get_guint8(tvb, 24);
9362                 if (nds_verb == 0xfe)
9363                 {
9364                         nds_version = nds_verb;
9365                         nds_verb = tvb_get_guint8(tvb, 32);
9366                         foffset = 36;
9367                 }
9368                 else
9369                 {
9370                         nds_version = 0;
9371                         foffset = 28;
9372                 }
9373                 if (type == NCP_SERVICE_REQUEST) {
9374                         proto_tree_add_item(ncp_tree, hf_nds_buffer_size, tvb, foffset,
9375                                             4, TRUE);
9376                 }
9377                 foffset = foffset+4;
9378                 verb_string = val_to_str(nds_verb, ncp_nds_verb_vals,
9379                     "Continuation Fragment");
9380                 switch(nds_verb) {
9381
9382                         case 0x01:
9383                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
9384                                 pvalues[0].vtype = VTYPE_UINT32;
9385                                 pvalues[0].vdesc = "Version: %u";
9386                                 pvalues[0].vlength = 4;
9387                                 pvalues[0].hfname = hf_nds_ver;
9388                                 pvalues[0].voffset = foffset;
9389                                 foffset = foffset+pvalues[0].vlength;
9390                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9391                                 pvalues[1].vtype = VTYPE_BITFIELD;
9392                                 pvalues[1].vdesc = "Flags:";
9393                                 pvalues[1].vlength = 2;
9394                                 pvalues[1].hfname= hf_nds_nflags;
9395                                 pvalues[1].voffset = foffset;
9396                                 pvalues[1].bit1 = "Entry ID";
9397                                 pvalues[1].bit1hfname = hf_bit1nflags;
9398                                 pvalues[1].bit2 = "Readable";
9399                                 pvalues[1].bit2hfname = hf_bit2nflags;
9400                                 pvalues[1].bit3 = "Writeable";
9401                                 pvalues[1].bit3hfname = hf_bit3nflags;
9402                                 pvalues[1].bit4 = "Master";
9403                                 pvalues[1].bit4hfname = hf_bit4nflags;
9404                                 pvalues[1].bit5 = "Create ID";
9405                                 pvalues[1].bit5hfname = hf_bit5nflags;
9406                                 pvalues[1].bit6 = "Walk Tree";
9407                                 pvalues[1].bit6hfname = hf_bit6nflags;
9408                                 pvalues[1].bit7 = "Dereference Alias";
9409                                 pvalues[1].bit7hfname = hf_bit7nflags;
9410                                 pvalues[1].bit8 = "Not Defined";
9411                                 pvalues[1].bit8hfname = hf_bit8nflags;
9412                                 pvalues[1].bit9 = "Not Defined";
9413                                 pvalues[1].bit9hfname = hf_bit9nflags;
9414                                 pvalues[1].bit10 = "Not Defined";
9415                                 pvalues[1].bit10hfname = hf_bit10nflags;
9416                                 pvalues[1].bit11= "Not Defined";
9417                                 pvalues[1].bit11hfname = hf_bit11nflags;
9418                                 pvalues[1].bit12 = "Not Defined";
9419                                 pvalues[1].bit12hfname = hf_bit12nflags;
9420                                 pvalues[1].bit13 = "Not Defined";
9421                                 pvalues[1].bit13hfname = hf_bit13nflags;
9422                                 pvalues[1].bit14 = "Prefer Referrals";
9423                                 pvalues[1].bit14hfname = hf_bit14nflags;
9424                                 pvalues[1].bit15 = "Prefer Only Referrals";
9425                                 pvalues[1].bit15hfname = hf_bit15nflags;
9426                                 pvalues[1].bit16 = "Not Defined";
9427                                 pvalues[1].bit16hfname = hf_bit16nflags;
9428                                 foffset = foffset+4;
9429                                 if (pvalues[0].vvalue == 0 || pvalues[0].vvalue == 1)
9430                                 {
9431                                         pvalues[2].vtype = VTYPE_UINT32;
9432                                         pvalues[2].vdesc = "Scope: %u";
9433                                         pvalues[2].vlength = 4;
9434                                         pvalues[2].voffset = foffset;
9435                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
9436                                         pvalues[2].hfname= hf_nds_scope;
9437                                         foffset = foffset+pvalues[2].vlength;
9438                                         pvalues[3].vtype = VTYPE_STRING;
9439                                         pvalues[3].vdesc = "Name: %s";
9440                                         pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
9441                                         pvalues[3].vvalue = 0;
9442                                         pvalues[3].vlength = 256;
9443                                         pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
9444                                         if (pvalues[3].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
9445                                         {
9446                                                 pvalues[3].vtype = VTYPE_NONE;
9447                                                 break;
9448                                         }
9449                                         pvalues[3].voffset = foffset+4;
9450                                         foffset = foffset + 4;
9451                                         get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, req_buffer.buffer);
9452                                         pvalues[3].vstring = req_buffer.buffer;
9453                                         g_strlcpy(global_object_name, req_buffer.buffer, 256);
9454                                         pvalues[3].hfname= hf_nds_name;
9455                                         foffset = foffset+pvalues[3].vlength;
9456                                         foffset += align_4(tvb, foffset);
9457                                         pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
9458                                         pvalues[4].vtype = VTYPE_MULTIVALUE_UINT32;
9459                                         pvalues[4].vdesc = "Communications Transports: %u";
9460                                         pvalues[4].vlength = 4;
9461                                         pvalues[4].hfname= hf_nds_comm_trans;
9462                                         pvalues[4].voffset = foffset;
9463                                         pvalues[4].mvtype = MVTYPE_ADDR_REFERRAL_REQUEST;
9464                                         foffset = foffset + (pvalues[4].vvalue * 4) + 4;
9465                                         pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
9466                                         pvalues[5].vtype = VTYPE_MULTIVALUE_UINT32;
9467                                         pvalues[5].vdesc = "Tree Walker Transport Type: %u";
9468                                         pvalues[5].vlength = 4;
9469                                         pvalues[5].mvtype = MVTYPE_ADDR_REFERRAL_REQUEST;
9470                                         pvalues[5].hfname= hf_nds_tree_trans;
9471                                         pvalues[5].voffset = foffset;
9472                                 }
9473                                 else
9474                                 {
9475                                         pvalues[2].vtype = VTYPE_UINT32;
9476                                         pvalues[2].vdesc = "Minimum DS Version: %u";
9477                                         pvalues[2].vlength = 4;
9478                                         pvalues[2].voffset = foffset;
9479                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
9480                                         pvalues[2].hfname= hf_min_nds_ver;
9481                                         foffset = foffset+pvalues[2].vlength;
9482                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
9483                                         pvalues[3].vtype = VTYPE_MULTIVALUE_UINT32;
9484                                         pvalues[3].vdesc = "Number of Versions to Include: %u";
9485                                         pvalues[3].vlength = 4;
9486                                         pvalues[3].mvtype = MVTYPE_ATTR_REQUEST2;
9487                                         pvalues[3].voffset = foffset;
9488                                         pvalues[3].hfname= hf_nds_ver_include;
9489                                         foffset += (pvalues[3].vvalue * 4) + 4;
9490                                         pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
9491                                         pvalues[4].vtype = VTYPE_MULTIVALUE_UINT32;
9492                                         pvalues[4].vdesc = "Number of Versions to Exclude: %u";
9493                                         pvalues[4].vlength = 4;
9494                                         pvalues[4].mvtype = MVTYPE_ATTR_REQUEST2;
9495                                         pvalues[4].hfname= hf_nds_ver_exclude;
9496                                         pvalues[4].voffset = foffset;
9497                                         foffset += 4;
9498                                         pvalues[5].vtype = VTYPE_UINT32;
9499                                         pvalues[5].vdesc = "DN Output Type: %u";
9500                                         pvalues[5].vlength = 4;
9501                                         pvalues[5].voffset = foffset;
9502                                         pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
9503                                         pvalues[5].hfname= hf_nds_dn_output_type;
9504                                         foffset = foffset+pvalues[5].vlength;
9505                                         pvalues[6].vtype = VTYPE_UINT32;
9506                                         pvalues[6].vdesc = "Nested Output Type: %u";
9507                                         pvalues[6].vlength = 4;
9508                                         pvalues[6].voffset = foffset;
9509                                         pvalues[6].vvalue = tvb_get_letohl(tvb, foffset);
9510                                         pvalues[6].hfname= hf_nds_nested_output_type;
9511                                         foffset = foffset+pvalues[6].vlength;
9512                                         pvalues[7].vtype = VTYPE_STRING;
9513                                         pvalues[7].vdesc = "Output Delimiter: %s";
9514                                         pvalues[7].mvtype = MVTYPE_ATTR_REQUEST;
9515                                         pvalues[7].vvalue = 0;
9516                                         pvalues[7].vlength = 256;
9517                                         pvalues[7].vlength = tvb_get_letohl(tvb, foffset);
9518                                         pvalues[7].voffset = foffset+4;
9519                                         foffset = foffset + 4;
9520                                         get_string(tvb, pvalues[7].voffset, pvalues[7].vlength, req_buffer.buffer);
9521                                         pvalues[7].vstring = req_buffer.buffer;
9522                                         pvalues[7].hfname= hf_nds_output_delimiter;
9523                                         foffset = foffset+pvalues[7].vlength;
9524                                         foffset += align_4(tvb, foffset);
9525                                         pvalues[8].vvalue = tvb_get_letohl(tvb, foffset);
9526                                         pvalues[8].vtype = VTYPE_MULTIVALUE_UINT32;
9527                                         pvalues[8].vdesc = "Size of Entry Specifier: %u";
9528                                         pvalues[8].vlength = 4;
9529                                         pvalues[8].mvtype = MVTYPE_PROC_ENTRY_SPECIFIERS;
9530                                         pvalues[8].hfname= hf_nds_output_entry_specifier;
9531                                         pvalues[8].voffset = foffset;
9532                                 }
9533                                 break;
9534                         case 0x02:
9535                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
9536                                 pvalues[0].vtype = VTYPE_UINT32;
9537                                 pvalues[0].vdesc = "Version: %u";
9538                                 pvalues[0].vlength = 4;
9539                                 pvalues[0].voffset = foffset;
9540                                 pvalues[0].hfname= hf_nds_ver;
9541                                 foffset = foffset+pvalues[0].vlength;
9542                                 switch(pvalues[0].vvalue)
9543                                 {
9544                                         case 0:
9545                                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9546                                                 pvalues[1].vtype = VTYPE_UINT32;
9547                                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
9548                                                 pvalues[1].vlength = 4;
9549                                                 resolve_eid = TRUE;
9550                                                 global_eid = pvalues[1].vvalue;
9551                                                 pvalues[1].voffset = foffset;
9552                                                 pvalues[1].hfname = hf_nds_eid;
9553                                                 foffset = foffset+pvalues[1].vlength;
9554                                                 break;
9555                                         case 1:
9556                                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9557                                                 pvalues[1].vtype = VTYPE_BITFIELD;
9558                                                 pvalues[1].vdesc = "Request Flags:";
9559                                                 pvalues[1].vlength = 2;
9560                                                 pvalues[1].hfname= hf_nds_rflags;
9561                                                 pvalues[1].voffset = foffset;
9562                                                 pvalues[1].bit1 = "Typeless";
9563                                                 pvalues[1].bit1hfname = hf_bit1rflags;
9564                                                 pvalues[1].bit2 = "Slashed";
9565                                                 pvalues[1].bit2hfname = hf_bit2rflags;
9566                                                 pvalues[1].bit3 = "Dotted";
9567                                                 pvalues[1].bit3hfname = hf_bit3rflags;
9568                                                 pvalues[1].bit4 = "Tuned";
9569                                                 pvalues[1].bit4hfname = hf_bit4rflags;
9570                                                 pvalues[1].bit5 = "Not Defined";
9571                                                 pvalues[1].bit5hfname = hf_bit5rflags;
9572                                                 pvalues[1].bit6 = "Not Defined";
9573                                                 pvalues[1].bit6hfname = hf_bit6rflags;
9574                                                 pvalues[1].bit7 = "Not Defined";
9575                                                 pvalues[1].bit7hfname = hf_bit7rflags;
9576                                                 pvalues[1].bit8 = "Not Defined";
9577                                                 pvalues[1].bit8hfname = hf_bit8rflags;
9578                                                 pvalues[1].bit9 = "Not Defined";
9579                                                 pvalues[1].bit9hfname = hf_bit9rflags;
9580                                                 pvalues[1].bit10 = "Not Defined";
9581                                                 pvalues[1].bit10hfname = hf_bit10rflags;
9582                                                 pvalues[1].bit11 = "Not Defined";
9583                                                 pvalues[1].bit11hfname = hf_bit11rflags;
9584                                                 pvalues[1].bit12 = "Not Defined";
9585                                                 pvalues[1].bit12hfname = hf_bit12rflags;
9586                                                 pvalues[1].bit13 = "Not Defined";
9587                                                 pvalues[1].bit13hfname = hf_bit13rflags;
9588                                                 pvalues[1].bit14 = "Not Defined";
9589                                                 pvalues[1].bit14hfname = hf_bit14rflags;
9590                                                 pvalues[1].bit15 = "Not Defined";
9591                                                 pvalues[1].bit15hfname = hf_bit15rflags;
9592                                                 pvalues[1].bit16 = "Not Defined";
9593                                                 pvalues[1].bit16hfname = hf_bit16rflags;
9594                                                 if((pvalues[1].vvalue&&0xf000) == 0xc000)
9595                                                 {
9596                                                         pvalues[2].vtype = VTYPE_STRING;
9597                                                         pvalues[2].vdesc = "Name Type: %s";
9598                                                         pvalues[2].vstring = "Partial";
9599                                                         pvalues[2].mvtype = 0;
9600                                                         pvalues[2].vvalue = 0;
9601                                                         pvalues[2].vlength = 0;
9602                                                         pvalues[2].voffset = 0;
9603                                                         pvalues[2].hfname= hf_nds_name_type;
9604                                                 }
9605                                                 else
9606                                                 {
9607                                                         pvalues[2].vtype = VTYPE_STRING;
9608                                                         pvalues[2].vdesc = "Name Type: %s";
9609                                                         pvalues[2].vstring = "Full";
9610                                                         pvalues[2].vvalue = 0;
9611                                                         pvalues[2].mvtype = 0;
9612                                                         pvalues[2].vlength = 0;
9613                                                         pvalues[2].voffset = 0;
9614                                                         pvalues[2].hfname= hf_nds_name_type;
9615                                                 }
9616                                                 foffset = foffset+4;
9617                                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
9618                                                 pvalues[3].vtype = VTYPE_UINT32;
9619                                                 pvalues[3].vdesc = "Entry ID: 0x%08x";
9620                                                 pvalues[3].vlength = 4;
9621                                                 pvalues[3].voffset = foffset;
9622                                                 resolve_eid = TRUE;
9623                                                 global_eid = pvalues[3].vvalue;
9624                                                 pvalues[3].hfname = hf_nds_eid;
9625                                                 foffset = foffset+pvalues[3].vlength;
9626                                                 break;
9627                                         case 2:
9628                                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9629                                                 pvalues[1].vtype = VTYPE_BITFIELD;
9630                                                 pvalues[1].vdesc = "Request Flags:";
9631                                                 pvalues[1].vlength = 2;
9632                                                 pvalues[1].hfname= hf_nds_rflags;
9633                                                 pvalues[1].voffset = foffset;
9634                                                 pvalues[1].bit1 = "Typeless";
9635                                                 pvalues[1].bit1hfname = hf_bit1rflags;
9636                                                 pvalues[1].bit2 = "Slashed";
9637                                                 pvalues[1].bit2hfname = hf_bit2rflags;
9638                                                 pvalues[1].bit3 = "Dotted";
9639                                                 pvalues[1].bit3hfname = hf_bit3rflags;
9640                                                 pvalues[1].bit4 = "Tuned";
9641                                                 pvalues[1].bit4hfname = hf_bit4rflags;
9642                                                 pvalues[1].bit5 = "Not Defined";
9643                                                 pvalues[1].bit5hfname = hf_bit5rflags;
9644                                                 pvalues[1].bit6 = "Not Defined";
9645                                                 pvalues[1].bit6hfname = hf_bit6rflags;
9646                                                 pvalues[1].bit7 = "Not Defined";
9647                                                 pvalues[1].bit7hfname = hf_bit7rflags;
9648                                                 pvalues[1].bit8 = "Not Defined";
9649                                                 pvalues[1].bit8hfname = hf_bit8rflags;
9650                                                 pvalues[1].bit9 = "Not Defined";
9651                                                 pvalues[1].bit9hfname = hf_bit9rflags;
9652                                                 pvalues[1].bit10 = "Not Defined";
9653                                                 pvalues[1].bit10hfname = hf_bit10rflags;
9654                                                 pvalues[1].bit11 = "Not Defined";
9655                                                 pvalues[1].bit11hfname = hf_bit11rflags;
9656                                                 pvalues[1].bit12 = "Not Defined";
9657                                                 pvalues[1].bit12hfname = hf_bit12rflags;
9658                                                 pvalues[1].bit13 = "Not Defined";
9659                                                 pvalues[1].bit13hfname = hf_bit13rflags;
9660                                                 pvalues[1].bit14 = "Not Defined";
9661                                                 pvalues[1].bit14hfname = hf_bit14rflags;
9662                                                 pvalues[1].bit15 = "Not Defined";
9663                                                 pvalues[1].bit15hfname = hf_bit15rflags;
9664                                                 pvalues[1].bit16 = "Not Defined";
9665                                                 pvalues[1].bit16hfname = hf_bit16rflags;
9666                                                 if((pvalues[1].vvalue&&0xf000) == 0xc000)
9667                                                 {
9668                                                         pvalues[2].vtype = VTYPE_STRING;
9669                                                         pvalues[2].vdesc = "Name Type: %s";
9670                                                         pvalues[2].vstring = "Return Partion Name";
9671                                                         pvalues[2].vvalue = 0;
9672                                                         pvalues[2].vlength = 4;
9673                                                         pvalues[2].voffset = pvalues[1].voffset;
9674                                                         pvalues[2].mvtype = 0;
9675                                                         pvalues[2].hfname= hf_nds_name_type;
9676                                                 }
9677                                                 else
9678                                                 {
9679                                                         pvalues[2].vtype = VTYPE_STRING;
9680                                                         pvalues[2].vdesc = "Name Type: %s";
9681                                                         pvalues[2].vstring = "Return Full Name";
9682                                                         pvalues[2].vvalue = 0;
9683                                                         pvalues[2].vlength = 4;
9684                                                         pvalues[2].mvtype = 0;
9685                                                         pvalues[2].voffset = pvalues[1].voffset;
9686                                                         pvalues[2].hfname= hf_nds_name_type;
9687                                                 }
9688                                                 foffset = foffset+4;
9689                                                 pvalues[3].vvalue = tvb_get_letohs(tvb, foffset);
9690                                                 global_flags = tvb_get_letohl(tvb, foffset);
9691                                                 pvalues[3].vtype = VTYPE_BITFIELD;
9692                                                 pvalues[3].vdesc = "Information Flags (low) Byte:";
9693                                                 pvalues[3].vlength = 2;
9694                                                 pvalues[3].hfname= hf_nds_rflags;
9695                                                 pvalues[3].voffset = foffset;
9696                                                 pvalues[3].bit1 = "Output Flags";
9697                                                 pvalues[3].bit1hfname = hf_bit1infoflagsl;
9698                                                 pvalues[3].bit2 = "Entry ID";
9699                                                 pvalues[3].bit2hfname = hf_bit2infoflagsl;
9700                                                 pvalues[3].bit3 = "Entry Flags";
9701                                                 pvalues[3].bit3hfname = hf_bit3infoflagsl;
9702                                                 pvalues[3].bit4 = "Subordinate Count";
9703                                                 pvalues[3].bit4hfname = hf_bit4infoflagsl;
9704                                                 pvalues[3].bit5 = "Modification Time";
9705                                                 pvalues[3].bit5hfname = hf_bit5infoflagsl;
9706                                                 pvalues[3].bit6 = "Modification Timestamp";
9707                                                 pvalues[3].bit6hfname = hf_bit6infoflagsl;
9708                                                 pvalues[3].bit7 = "Creation Timestamp";
9709                                                 pvalues[3].bit7hfname = hf_bit7infoflagsl;
9710                                                 pvalues[3].bit8 = "Partition Root ID";
9711                                                 pvalues[3].bit8hfname = hf_bit8infoflagsl;
9712                                                 pvalues[3].bit9 = "Parent ID";
9713                                                 pvalues[3].bit9hfname = hf_bit9infoflagsl;
9714                                                 pvalues[3].bit10 = "Revision Count";
9715                                                 pvalues[3].bit10hfname = hf_bit10infoflagsl;
9716                                                 pvalues[3].bit11 = "Replica Type";
9717                                                 pvalues[3].bit11hfname = hf_bit11infoflagsl;
9718                                                 pvalues[3].bit12 = "Base Class";
9719                                                 pvalues[3].bit12hfname = hf_bit12infoflagsl;
9720                                                 pvalues[3].bit13 = "Relative Distinguished Name";
9721                                                 pvalues[3].bit13hfname = hf_bit13infoflagsl;
9722                                                 pvalues[3].bit14 = "Distinguished Name";
9723                                                 pvalues[3].bit14hfname = hf_bit14infoflagsl;
9724                                                 pvalues[3].bit15 = "Root Distinguished Name";
9725                                                 pvalues[3].bit15hfname = hf_bit15infoflagsl;
9726                                                 pvalues[3].bit16 = "Parent Distinguished Name";
9727                                                 pvalues[3].bit16hfname = hf_bit16infoflagsl;
9728                                                 foffset = foffset+2;
9729                                                 pvalues[4].vvalue = tvb_get_letohs(tvb, foffset);
9730                                                 pvalues[4].vtype = VTYPE_BITFIELD;
9731                                                 pvalues[4].vdesc = "Information Flags (high) Byte:";
9732                                                 pvalues[4].vlength = 2;
9733                                                 pvalues[4].hfname= hf_nds_rflags;
9734                                                 pvalues[4].voffset = foffset;
9735                                                 pvalues[4].bit1 = "Purge Time";
9736                                                 pvalues[4].bit1hfname = hf_bit1infoflagsh;
9737                                                 pvalues[4].bit2 = "Dereference Base Class";
9738                                                 pvalues[4].bit2hfname = hf_bit2infoflagsh;
9739                                                 pvalues[4].bit3 = "Replica Number";
9740                                                 pvalues[4].bit3hfname = hf_bit3infoflagsh;
9741                                                 pvalues[4].bit4 = "Replica State";
9742                                                 pvalues[4].bit4hfname = hf_bit4infoflagsh;
9743                                                 pvalues[4].bit5 = "Federation Boundary";
9744                                                 pvalues[4].bit5hfname = hf_bit5infoflagsh;
9745                                                 pvalues[4].bit6 = "Schema Boundary";
9746                                                 pvalues[4].bit6hfname = hf_bit6infoflagsh;
9747                                                 pvalues[4].bit7 = "Federation Boundary ID";
9748                                                 pvalues[4].bit7hfname = hf_bit7infoflagsh;
9749                                                 pvalues[4].bit8 = "Schema Boundary ID";
9750                                                 pvalues[4].bit8hfname = hf_bit8infoflagsh;
9751                                                 pvalues[4].bit9 = "Current Subcount";
9752                                                 pvalues[4].bit9hfname = hf_bit9infoflagsh;
9753                                                 pvalues[4].bit10 = "Local Entry Flags";
9754                                                 pvalues[4].bit10hfname = hf_bit10infoflagsh;
9755                                                 pvalues[4].bit11 = "Not Defined";
9756                                                 pvalues[4].bit11hfname = hf_bit11infoflagsh;
9757                                                 pvalues[4].bit12 = "Not Defined";
9758                                                 pvalues[4].bit12hfname = hf_bit12infoflagsh;
9759                                                 pvalues[4].bit13 = "Not Defined";
9760                                                 pvalues[4].bit13hfname = hf_bit13infoflagsh;
9761                                                 pvalues[4].bit14 = "Not Defined";
9762                                                 pvalues[4].bit14hfname = hf_bit14infoflagsh;
9763                                                 pvalues[4].bit15 = "Not Defined";
9764                                                 pvalues[4].bit15hfname = hf_bit15infoflagsh;
9765                                                 pvalues[4].bit16 = "Not Defined";
9766                                                 pvalues[4].bit16hfname = hf_bit16infoflagsh;
9767                                                 foffset = foffset+2;
9768                                                 pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
9769                                                 pvalues[5].vtype = VTYPE_UINT32;
9770                                                 pvalues[5].vdesc = "Entry ID: 0x%08x";
9771                                                 pvalues[5].vlength = 4;
9772                                                 pvalues[5].voffset = foffset;
9773                                                 resolve_eid = TRUE;
9774                                                 global_eid = pvalues[5].vvalue;
9775                                                 pvalues[5].hfname = hf_nds_eid;
9776                                                 foffset = foffset+pvalues[5].vlength;
9777                                                 break;
9778                                         default:
9779                                                 break;
9780                                 }
9781
9782                                 break;
9783                         case 0x03:
9784                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
9785                                 pvalues[0].vtype = VTYPE_UINT32;
9786                                 pvalues[0].vdesc = "Version: %u";
9787                                 pvalues[0].vlength = 4;
9788                                 pvalues[0].voffset = foffset;
9789                                 pvalues[0].hfname= hf_nds_ver;
9790                                 foffset = foffset+pvalues[0].vlength;
9791                                 if(pvalues[0].vvalue == 0)
9792                                 {
9793                                         pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9794                                         pvalues[1].vtype = VTYPE_UINT32;
9795                                         pvalues[1].vdesc = "Iteration Handle: 0x%08x";
9796                                         pvalues[1].vlength = 4;
9797                                         pvalues[1].voffset = foffset;
9798                                         pvalues[1].hfname= hf_nds_iteration;
9799                                         foffset = foffset+pvalues[1].vlength;
9800                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
9801                                         pvalues[2].vtype = VTYPE_UINT32;
9802                                         pvalues[2].vdesc = "Entry ID: 0x%08x";
9803                                         pvalues[2].vlength = 4;
9804                                         resolve_eid = TRUE;
9805                                         global_eid = pvalues[2].vvalue;
9806                                         pvalues[2].voffset = foffset;
9807                                         pvalues[2].hfname= hf_nds_eid;
9808                                         foffset = foffset+pvalues[2].vlength;
9809                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
9810                                         pvalues[3].vstring = (char *)match_strval(pvalues[3].vvalue, nds_info_type);
9811                                         global_flags = pvalues[3].vvalue;
9812                                         if(pvalues[3].vstring == NULL)
9813                                         {
9814                                                 pvalues[3].vstring = "No Info Type Set";
9815                                         }
9816                                         pvalues[3].vtype = VTYPE_STRING;
9817                                         pvalues[3].vdesc = "Info Type: %s";
9818                                         pvalues[3].vlength = 4;
9819                                         pvalues[3].voffset = foffset;
9820                                         pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
9821                                         pvalues[3].hfname= hf_nds_info_type;
9822                                         foffset = foffset + pvalues[3].vlength;
9823                                         pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
9824                                         pvalues[4].vtype = VTYPE_UINT32;
9825                                         pvalues[4].vdesc = "All Attributes: %u";
9826                                         pvalues[4].vlength = 4;
9827                                         pvalues[4].voffset = foffset;
9828                                         pvalues[4].hfname= hf_nds_all_attr;
9829                                         foffset = foffset+pvalues[4].vlength;
9830                                         pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
9831                                         pvalues[5].vtype = VTYPE_MULTIVALUE_UINT32;
9832                                         pvalues[5].vdesc = "Attributes: %u";
9833                                         pvalues[5].vlength = 4;
9834                                         pvalues[5].voffset = foffset;
9835                                         pvalues[5].mvtype = MVTYPE_ATTR_REQUEST;
9836                                         pvalues[5].hfname= hf_nds_attr;
9837                                 }
9838                                 else
9839                                 {
9840                                         pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9841                                         pvalues[1].vtype = VTYPE_UINT32;
9842                                         pvalues[1].vdesc = "Request Flags: 0x%08x";
9843                                         pvalues[1].vlength = 4;
9844                                         pvalues[1].voffset = foffset;
9845                                         pvalues[1].hfname= hf_nds_req_flags;
9846                                         foffset = foffset+pvalues[1].vlength;
9847                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
9848                                         pvalues[2].vtype = VTYPE_UINT32;
9849                                         pvalues[2].vdesc = "Iteration Handle: 0x%08x";
9850                                         pvalues[2].vlength = 4;
9851                                         pvalues[2].voffset = foffset;
9852                                         pvalues[2].hfname= hf_nds_iteration;
9853                                         foffset = foffset+pvalues[2].vlength;
9854                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
9855                                         pvalues[3].vtype = VTYPE_UINT32;
9856                                         pvalues[3].vdesc = "Entry ID: 0x%08x";
9857                                         pvalues[3].vlength = 4;
9858                                         resolve_eid = TRUE;
9859                                         global_eid = pvalues[3].vvalue;
9860                                         pvalues[3].voffset = foffset;
9861                                         pvalues[3].hfname= hf_nds_eid;
9862                                         foffset = foffset+pvalues[3].vlength;
9863                                         pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
9864                                         pvalues[4].vstring = (char *)match_strval(pvalues[4].vvalue, nds_info_type);
9865                                         global_flags = pvalues[4].vvalue;
9866                                         if(pvalues[4].vstring == NULL)
9867                                         {
9868                                                 pvalues[4].vstring = "No Info Type Set";
9869                                         }
9870                                         pvalues[4].vtype = VTYPE_STRING;
9871                                         pvalues[4].vdesc = "Info Type: %s";
9872                                         pvalues[4].vlength = 4;
9873                                         pvalues[4].voffset = foffset;
9874                                         pvalues[4].hfname= hf_nds_info_type;
9875                                         pvalues[4].mvtype = MVTYPE_ATTR_REQUEST;
9876                                         foffset = foffset+pvalues[4].vlength;
9877                                         pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
9878                                         pvalues[5].vtype = VTYPE_UINT32;
9879                                         pvalues[5].vdesc = "All Attributes: %u";
9880                                         pvalues[5].vlength = 4;
9881                                         pvalues[5].voffset = foffset;
9882                                         pvalues[5].hfname= hf_nds_all_attr;
9883                                         foffset = foffset+pvalues[5].vlength;
9884                                         pvalues[6].vvalue = tvb_get_letohl(tvb, foffset);
9885                                         pvalues[6].vtype = VTYPE_MULTIVALUE_UINT32;
9886                                         pvalues[6].vdesc = "Attributes: %u";
9887                                         pvalues[6].vlength = 4;
9888                                         pvalues[6].voffset = foffset;
9889                                         pvalues[6].mvtype = MVTYPE_ATTR_REQUEST;
9890                                         pvalues[6].hfname= hf_nds_attr;
9891                                 }
9892                                 break;
9893                         case 0x04:
9894                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
9895                                 pvalues[0].vtype = VTYPE_UINT32;
9896                                 pvalues[0].vdesc = "Version: %u";
9897                                 pvalues[0].vlength = 4;
9898                                 pvalues[0].voffset = foffset;
9899                                 pvalues[0].hfname= hf_nds_ver;
9900                                 foffset = foffset+pvalues[0].vlength;
9901                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9902                                 pvalues[1].vtype = VTYPE_UINT32;
9903                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
9904                                 pvalues[1].vlength = 4;
9905                                 resolve_eid = TRUE;
9906                                 global_eid = pvalues[1].vvalue;
9907                                 pvalues[1].voffset = foffset;
9908                                 pvalues[1].hfname = hf_nds_eid;
9909                                 foffset = foffset+pvalues[1].vlength;
9910                                 foffset += 4;       /* Attribute Count = 1 */
9911                                 pvalues[2].vtype = VTYPE_STRING;
9912                                 pvalues[2].vdesc = "Attribute Name Being Compared: %s";
9913                                 pvalues[2].mvtype = MVTYPE_ATTR_REQUEST;
9914                                 pvalues[2].vvalue = 0;
9915                                 pvalues[2].vlength = 256;
9916                                 pvalues[2].vlength = tvb_get_letohl(tvb, foffset);
9917                                 if (pvalues[2].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[2].vlength))
9918                                 {
9919                                         pvalues[2].vtype = VTYPE_NONE;
9920                                         break;
9921                                 }
9922                                 pvalues[2].voffset = foffset+4;
9923                                 foffset = foffset + 4;
9924                                 get_string(tvb, pvalues[2].voffset, pvalues[2].vlength, req_buffer.buffer);
9925                                 pvalues[2].vstring = req_buffer.buffer;
9926                                 g_strlcpy(global_object_name, req_buffer.buffer, 256);
9927                                 pvalues[2].hfname= hf_nds_name;
9928                                 foffset = foffset+pvalues[2].vlength;
9929                                 foffset += align_4(tvb, foffset);
9930                                 foffset += 4;       /* Attribute Value Count = 1 */
9931                                 pvalues[3].vtype = VTYPE_STRING;
9932                                 pvalues[3].vdesc = "Attribute Value: %s";
9933                                 pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
9934                                 pvalues[3].vvalue = 0;
9935                                 pvalues[3].vlength = 256;
9936                                 pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
9937                                 pvalues[3].voffset = foffset+4;
9938                                 foffset = foffset + 4;
9939                                 get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, pvalues[3].vstring);
9940                                 pvalues[3].hfname= hf_value_string;
9941                                 foffset = foffset+pvalues[3].vlength;
9942                                 break;
9943                         case 0x05:
9944                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
9945                                 pvalues[0].vtype = VTYPE_UINT32;
9946                                 pvalues[0].vdesc = "Version: %u";
9947                                 pvalues[0].vlength = 4;
9948                                 pvalues[0].voffset = foffset;
9949                                 pvalues[0].hfname= hf_nds_ver;
9950                                 foffset = foffset+pvalues[0].vlength;
9951                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
9952                                 pvalues[1].vtype = VTYPE_BITFIELD;
9953                                 pvalues[1].vdesc = "Request Flags:";
9954                                 pvalues[1].vlength = 2;
9955                                 pvalues[1].hfname= hf_nds_rflags;
9956                                 pvalues[1].voffset = foffset;
9957                                 pvalues[1].bit1 = "List Typeless";
9958                                 pvalues[1].bit1hfname = hf_bit1lflags;
9959                                 pvalues[1].bit2 = "List Containers";
9960                                 pvalues[1].bit2hfname = hf_bit2lflags;
9961                                 pvalues[1].bit3 = "List Slashed";
9962                                 pvalues[1].bit3hfname = hf_bit3lflags;
9963                                 pvalues[1].bit4 = "List Dotted";
9964                                 pvalues[1].bit4hfname = hf_bit4lflags;
9965                                 pvalues[1].bit5 = "Dereference Alias";
9966                                 pvalues[1].bit5hfname = hf_bit5lflags;
9967                                 pvalues[1].bit6 = "List All Containers";
9968                                 pvalues[1].bit6hfname = hf_bit6lflags;
9969                                 pvalues[1].bit7 = "List Obsolete";
9970                                 pvalues[1].bit7hfname = hf_bit7lflags;
9971                                 pvalues[1].bit8 = "List Tuned Output";
9972                                 pvalues[1].bit8hfname = hf_bit8lflags;
9973                                 pvalues[1].bit9 = "List External Reference";
9974                                 pvalues[1].bit9hfname = hf_bit9lflags;
9975                                 pvalues[1].bit10 = "Not Defined";
9976                                 pvalues[1].bit10hfname = hf_bit10lflags;
9977                                 pvalues[1].bit11 = "Not Defined";
9978                                 pvalues[1].bit11hfname = hf_bit11lflags;
9979                                 pvalues[1].bit12 = "Not Defined";
9980                                 pvalues[1].bit12hfname = hf_bit12lflags;
9981                                 pvalues[1].bit13 = "Not Defined";
9982                                 pvalues[1].bit13hfname = hf_bit13lflags;
9983                                 pvalues[1].bit14 = "Not Defined";
9984                                 pvalues[1].bit14hfname = hf_bit14lflags;
9985                                 pvalues[1].bit15 = "Not Defined";
9986                                 pvalues[1].bit15hfname = hf_bit15lflags;
9987                                 pvalues[1].bit16 = "Not Defined";
9988                                 pvalues[1].bit16hfname = hf_bit16lflags;
9989                                 foffset = foffset+pvalues[1].vlength;
9990                                 foffset += 2;
9991                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
9992                                 pvalues[2].vtype = VTYPE_UINT32;
9993                                 pvalues[2].vdesc = "Iteration Handle: 0x%08x";
9994                                 pvalues[2].vlength = 4;
9995                                 pvalues[2].voffset = foffset;
9996                                 pvalues[2].hfname= hf_nds_iteration;
9997                                 foffset = foffset+pvalues[2].vlength;
9998                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
9999                                 pvalues[3].vtype = VTYPE_UINT32;
10000                                 pvalues[3].vdesc = "Parent ID: 0x%08x";
10001                                 pvalues[3].vlength = 4;
10002                                 pvalues[3].voffset = foffset;
10003                                 pvalues[3].hfname= hf_nds_parent;
10004                                 foffset = foffset+pvalues[3].vlength;
10005                                 pvalues[4].vvalue = tvb_get_letohs(tvb, foffset);
10006                                 global_flags = tvb_get_letohl(tvb, foffset);
10007                                 pvalues[4].vtype = VTYPE_BITFIELD;
10008                                 pvalues[4].vdesc = "Information Flags (low) Byte:";
10009                                 pvalues[4].vlength = 2;
10010                                 pvalues[4].hfname= hf_nds_rflags;
10011                                 pvalues[4].voffset = foffset;
10012                                 pvalues[4].bit1 = "Output Flags";
10013                                 pvalues[4].bit1hfname = hf_bit1infoflagsl;
10014                                 pvalues[4].bit2 = "Entry ID";
10015                                 pvalues[4].bit2hfname = hf_bit2infoflagsl;
10016                                 pvalues[4].bit3 = "Entry Flags";
10017                                 pvalues[4].bit3hfname = hf_bit3infoflagsl;
10018                                 pvalues[4].bit4 = "Subordinate Count";
10019                                 pvalues[4].bit4hfname = hf_bit4infoflagsl;
10020                                 pvalues[4].bit5 = "Modification Time";
10021                                 pvalues[4].bit5hfname = hf_bit5infoflagsl;
10022                                 pvalues[4].bit6 = "Modification Timestamp";
10023                                 pvalues[4].bit6hfname = hf_bit6infoflagsl;
10024                                 pvalues[4].bit7 = "Creation Timestamp";
10025                                 pvalues[4].bit7hfname = hf_bit7infoflagsl;
10026                                 pvalues[4].bit8 = "Partition Root ID";
10027                                 pvalues[4].bit8hfname = hf_bit8infoflagsl;
10028                                 pvalues[4].bit9 = "Parent ID";
10029                                 pvalues[4].bit9hfname = hf_bit9infoflagsl;
10030                                 pvalues[4].bit10 = "Revision Count";
10031                                 pvalues[4].bit10hfname = hf_bit10infoflagsl;
10032                                 pvalues[4].bit11 = "Replica Type";
10033                                 pvalues[4].bit11hfname = hf_bit11infoflagsl;
10034                                 pvalues[4].bit12 = "Base Class";
10035                                 pvalues[4].bit12hfname = hf_bit12infoflagsl;
10036                                 pvalues[4].bit13 = "Relative Distinguished Name";
10037                                 pvalues[4].bit13hfname = hf_bit13infoflagsl;
10038                                 pvalues[4].bit14 = "Distinguished Name";
10039                                 pvalues[4].bit14hfname = hf_bit14infoflagsl;
10040                                 pvalues[4].bit15 = "Root Distinguished Name";
10041                                 pvalues[4].bit15hfname = hf_bit15infoflagsl;
10042                                 pvalues[4].bit16 = "Parent Distinguished Name";
10043                                 pvalues[4].bit16hfname = hf_bit16infoflagsl;
10044                                 foffset = foffset+2;
10045                                 pvalues[5].vvalue = tvb_get_letohs(tvb, foffset);
10046                                 pvalues[5].vtype = VTYPE_BITFIELD;
10047                                 pvalues[5].vdesc = "Information Flags (high) Byte:";
10048                                 pvalues[5].vlength = 2;
10049                                 pvalues[5].hfname= hf_nds_rflags;
10050                                 pvalues[5].voffset = foffset;
10051                                 pvalues[5].bit1 = "Purge Time";
10052                                 pvalues[5].bit1hfname = hf_bit1infoflagsh;
10053                                 pvalues[5].bit2 = "Dereference Base Class";
10054                                 pvalues[5].bit2hfname = hf_bit2infoflagsh;
10055                                 pvalues[5].bit3 = "Not Defined";
10056                                 pvalues[5].bit3hfname = hf_bit3infoflagsh;
10057                                 pvalues[5].bit4 = "Not Defined";
10058                                 pvalues[5].bit4hfname = hf_bit4infoflagsh;
10059                                 pvalues[5].bit5 = "Not Defined";
10060                                 pvalues[5].bit5hfname = hf_bit5infoflagsh;
10061                                 pvalues[5].bit6 = "Not Defined";
10062                                 pvalues[5].bit6hfname = hf_bit6infoflagsh;
10063                                 pvalues[5].bit7 = "Not Defined";
10064                                 pvalues[5].bit7hfname = hf_bit7infoflagsh;
10065                                 pvalues[5].bit8 = "Not Defined";
10066                                 pvalues[5].bit8hfname = hf_bit8infoflagsh;
10067                                 pvalues[5].bit9 = "Not Defined";
10068                                 pvalues[5].bit9hfname = hf_bit9infoflagsh;
10069                                 pvalues[5].bit10 = "Not Defined";
10070                                 pvalues[5].bit10hfname = hf_bit10infoflagsh;
10071                                 pvalues[5].bit11 = "Not Defined";
10072                                 pvalues[5].bit11hfname = hf_bit11infoflagsh;
10073                                 pvalues[5].bit12 = "Not Defined";
10074                                 pvalues[5].bit12hfname = hf_bit12infoflagsh;
10075                                 pvalues[5].bit13 = "Not Defined";
10076                                 pvalues[5].bit13hfname = hf_bit13infoflagsh;
10077                                 pvalues[5].bit14 = "Not Defined";
10078                                 pvalues[5].bit14hfname = hf_bit14infoflagsh;
10079                                 pvalues[5].bit15 = "Not Defined";
10080                                 pvalues[5].bit15hfname = hf_bit15infoflagsh;
10081                                 pvalues[5].bit16 = "Not Defined";
10082                                 pvalues[5].bit16hfname = hf_bit16infoflagsh;
10083                                 foffset = foffset+2;
10084                                 pvalues[6].vtype = VTYPE_STRING;
10085                                 pvalues[6].vdesc = "Name Filter: %s";
10086                                 pvalues[6].mvtype = MVTYPE_ATTR_REQUEST;
10087                                 pvalues[6].vvalue = 0;
10088                                 pvalues[6].vlength = 256;
10089                                 pvalues[6].vlength = tvb_get_letohl(tvb, foffset);
10090                                 pvalues[6].voffset = foffset+4;
10091                                 foffset = foffset + 4;
10092                                 get_string(tvb, pvalues[6].voffset, pvalues[6].vlength, pvalues[6].vstring);
10093                                 pvalues[6].hfname= hf_nds_name_filter;
10094                                 foffset = foffset+pvalues[6].vlength;
10095                                 if(pvalues[0].vvalue == 0)
10096                                 {
10097                                         break;
10098                                 }
10099                                 foffset += align_4(tvb, foffset);
10100                                 pvalues[7].vtype = VTYPE_STRING;
10101                                 pvalues[7].vdesc = "Class Filter: %s";
10102                                 pvalues[7].mvtype = MVTYPE_ATTR_REQUEST;
10103                                 pvalues[7].vvalue = 0;
10104                                 pvalues[7].vlength = 256;
10105                                 pvalues[7].vlength = tvb_get_letohl(tvb, foffset);
10106                                 pvalues[7].voffset = foffset+4;
10107                                 foffset = foffset + 4;
10108                                 get_string(tvb, pvalues[7].voffset, pvalues[7].vlength, pvalues[7].vstring);
10109                                 pvalues[7].hfname= hf_nds_class_filter;
10110                                 foffset = foffset+pvalues[7].vlength;
10111                                 if(pvalues[0].vvalue == 1)
10112                                 {
10113                                         break;
10114                                 }
10115                                 foffset += align_4(tvb, foffset);
10116                                 pvalues[8].vvalue = tvb_get_letohl(tvb, foffset);
10117                                 pvalues[8].vtype = VTYPE_MULTIVALUE_UINT32;
10118                                 pvalues[8].vdesc = "Seconds: %u";
10119                                 pvalues[8].vlength = 4;
10120                                 pvalues[8].mvtype = MVTYPE_PRINT_TIMESTAMP;
10121                                 pvalues[8].hfname= hf_nds_time_filter;
10122                                 pvalues[8].voffset = foffset;
10123                                 break;
10124                         case 0x06:
10125                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10126                                 pvalues[0].vstring = "";
10127                                 pvalues[0].vtype = VTYPE_UINT32;
10128                                 pvalues[0].vdesc = "Version: %u";
10129                                 pvalues[0].vlength = 4;
10130                                 pvalues[0].voffset = foffset;
10131                                 pvalues[0].hfname= hf_nds_ver;
10132                                 foffset = foffset+pvalues[0].vlength;
10133                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10134                                 pvalues[1].vtype = VTYPE_UINT32;
10135                                 pvalues[1].vstring = "";
10136                                 pvalues[1].vdesc = "Request Flags: 0x%08x";
10137                                 pvalues[1].vlength = 4;
10138                                 pvalues[1].hfname= hf_nds_rflags;
10139                                 pvalues[1].voffset = foffset;
10140                                 foffset = foffset+4;
10141                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10142                                 pvalues[2].vtype = VTYPE_UINT32;
10143                                 pvalues[2].vdesc = "Iteration Handle: 0x%08x";
10144                                 pvalues[2].vlength = 4;
10145                                 pvalues[2].voffset = foffset;
10146                                 pvalues[2].hfname= hf_nds_iteration;
10147                                 foffset = foffset+pvalues[2].vlength;
10148                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
10149                                 pvalues[3].vstring = "";
10150                                 pvalues[3].vtype = VTYPE_UINT32;
10151                                 pvalues[3].vdesc = "Base Entry ID: 0x%08x";
10152                                 pvalues[3].vlength = 4;
10153                                 resolve_eid = FALSE;
10154                                 global_eid = pvalues[3].vvalue;
10155                                 pvalues[3].voffset = foffset;
10156                                 pvalues[3].hfname= hf_nds_eid;
10157                                 foffset = foffset+pvalues[3].vlength;
10158                                 pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
10159                                 pvalues[4].vstring = (char *)match_strval(pvalues[4].vvalue, nds_search_scope);
10160                                 if(pvalues[4].vstring == NULL)
10161                                 {
10162                                         pvalues[4].vstring = "No Search Scope Defined";
10163                                 }
10164                                 pvalues[4].vtype = VTYPE_STRING;
10165                                 pvalues[4].vdesc = "Replica Type: %s";
10166                                 pvalues[4].vlength = 4;
10167                                 pvalues[4].voffset = foffset;
10168                                 pvalues[4].mvtype = 0;
10169                                 pvalues[4].hfname= hf_nds_search_scope;
10170                                 foffset = foffset + pvalues[4].vlength;
10171                                 pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
10172                                 pvalues[5].vtype = VTYPE_UINT32;
10173                                 pvalues[5].vdesc = "Number of Objects to Search: 0x%08x";
10174                                 pvalues[5].vlength = 4;
10175                                 pvalues[5].voffset = foffset;
10176                                 pvalues[5].hfname= hf_nds_num_objects;
10177                                 foffset = foffset+pvalues[5].vlength;
10178                                 pvalues[6].vvalue = tvb_get_letohl(tvb, foffset);
10179                                 pvalues[6].vtype = VTYPE_BITFIELD;
10180                                 pvalues[6].vdesc = "Information Types:";
10181                                 pvalues[6].vlength = 2;
10182                                 pvalues[6].hfname= hf_nds_nflags;
10183                                 pvalues[6].voffset = foffset;
10184                                 pvalues[6].bit1 = "Names";
10185                                 pvalues[6].bit1hfname = hf_bit1siflags;
10186                                 pvalues[6].bit2 = "Names and Values";
10187                                 pvalues[6].bit2hfname = hf_bit2siflags;
10188                                 pvalues[6].bit3 = "Effective Privileges";
10189                                 pvalues[6].bit3hfname = hf_bit3siflags;
10190                                 pvalues[6].bit4 = "Value Info";
10191                                 pvalues[6].bit4hfname = hf_bit4siflags;
10192                                 pvalues[6].bit5 = "Abbreviated Value";
10193                                 pvalues[6].bit5hfname = hf_bit5siflags;
10194                                 pvalues[6].bit6 = "Not Defined";
10195                                 pvalues[6].bit6hfname = hf_bit6siflags;
10196                                 pvalues[6].bit7 = "Not Defined";
10197                                 pvalues[6].bit7hfname = hf_bit7siflags;
10198                                 pvalues[6].bit8 = "Not Defined";
10199                                 pvalues[6].bit8hfname = hf_bit8siflags;
10200                                 pvalues[6].bit9 = "Expanded Class";
10201                                 pvalues[6].bit9hfname = hf_bit9siflags;
10202                                 pvalues[6].bit10 = "Not Defined";
10203                                 pvalues[6].bit10hfname = hf_bit10siflags;
10204                                 pvalues[6].bit11= "Not Defined";
10205                                 pvalues[6].bit11hfname = hf_bit11siflags;
10206                                 pvalues[6].bit12 = "Not Defined";
10207                                 pvalues[6].bit12hfname = hf_bit12siflags;
10208                                 pvalues[6].bit13 = "Not Defined";
10209                                 pvalues[6].bit13hfname = hf_bit13siflags;
10210                                 pvalues[6].bit14 = "Not Defined";
10211                                 pvalues[6].bit14hfname = hf_bit14siflags;
10212                                 pvalues[6].bit15 = "Not Defined";
10213                                 pvalues[6].bit15hfname = hf_bit15siflags;
10214                                 pvalues[6].bit16 = "Not Defined";
10215                                 pvalues[6].bit16hfname = hf_bit16siflags;
10216                                 foffset = foffset+4;
10217                                 if(pvalues[0].vvalue != 2)
10218                                 {
10219                                         pvalues[7].vvalue = tvb_get_letohs(tvb, foffset);
10220                                         global_flags = tvb_get_letohl(tvb, foffset);
10221                                         pvalues[7].vtype = VTYPE_BITFIELD;
10222                                         pvalues[7].vdesc = "Information Flags (low) Byte:";
10223                                         pvalues[7].vlength = 2;
10224                                         pvalues[7].hfname= hf_nds_rflags;
10225                                         pvalues[7].voffset = foffset;
10226                                         pvalues[7].bit1 = "Output Flags";
10227                                         pvalues[7].bit1hfname = hf_bit1infoflagsl;
10228                                         pvalues[7].bit2 = "Entry ID";
10229                                         pvalues[7].bit2hfname = hf_bit2infoflagsl;
10230                                         pvalues[7].bit3 = "Entry Flags";
10231                                         pvalues[7].bit3hfname = hf_bit3infoflagsl;
10232                                         pvalues[7].bit4 = "Subordinate Count";
10233                                         pvalues[7].bit4hfname = hf_bit4infoflagsl;
10234                                         pvalues[7].bit5 = "Modification Time";
10235                                         pvalues[7].bit5hfname = hf_bit5infoflagsl;
10236                                         pvalues[7].bit6 = "Modification Timestamp";
10237                                         pvalues[7].bit6hfname = hf_bit6infoflagsl;
10238                                         pvalues[7].bit7 = "Creation Timestamp";
10239                                         pvalues[7].bit7hfname = hf_bit7infoflagsl;
10240                                         pvalues[7].bit8 = "Partition Root ID";
10241                                         pvalues[7].bit8hfname = hf_bit8infoflagsl;
10242                                         pvalues[7].bit9 = "Parent ID";
10243                                         pvalues[7].bit9hfname = hf_bit9infoflagsl;
10244                                         pvalues[7].bit10 = "Revision Count";
10245                                         pvalues[7].bit10hfname = hf_bit10infoflagsl;
10246                                         pvalues[7].bit11 = "Replica Type";
10247                                         pvalues[7].bit11hfname = hf_bit11infoflagsl;
10248                                         pvalues[7].bit12 = "Base Class";
10249                                         pvalues[7].bit12hfname = hf_bit12infoflagsl;
10250                                         pvalues[7].bit13 = "Relative Distinguished Name";
10251                                         pvalues[7].bit13hfname = hf_bit13infoflagsl;
10252                                         pvalues[7].bit14 = "Distinguished Name";
10253                                         pvalues[7].bit14hfname = hf_bit14infoflagsl;
10254                                         pvalues[7].bit15 = "Root Distinguished Name";
10255                                         pvalues[7].bit15hfname = hf_bit15infoflagsl;
10256                                         pvalues[7].bit16 = "Parent Distinguished Name";
10257                                         pvalues[7].bit16hfname = hf_bit16infoflagsl;
10258                                         foffset = foffset+2;
10259                                         pvalues[8].vvalue = tvb_get_letohs(tvb, foffset);
10260                                         pvalues[8].vtype = VTYPE_BITFIELD;
10261                                         pvalues[8].vdesc = "Information Flags (high) Byte:";
10262                                         pvalues[8].vlength = 2;
10263                                         pvalues[8].hfname= hf_nds_rflags;
10264                                         pvalues[8].voffset = foffset;
10265                                         pvalues[8].bit1 = "Purge Time";
10266                                         pvalues[8].bit1hfname = hf_bit1infoflagsh;
10267                                         pvalues[8].bit2 = "Dereference Base Class";
10268                                         pvalues[8].bit2hfname = hf_bit2infoflagsh;
10269                                         pvalues[8].bit3 = "Not Defined";
10270                                         pvalues[8].bit3hfname = hf_bit3infoflagsh;
10271                                         pvalues[8].bit4 = "Not Defined";
10272                                         pvalues[8].bit4hfname = hf_bit4infoflagsh;
10273                                         pvalues[8].bit5 = "Not Defined";
10274                                         pvalues[8].bit5hfname = hf_bit5infoflagsh;
10275                                         pvalues[8].bit6 = "Not Defined";
10276                                         pvalues[8].bit6hfname = hf_bit6infoflagsh;
10277                                         pvalues[8].bit7 = "Not Defined";
10278                                         pvalues[8].bit7hfname = hf_bit7infoflagsh;
10279                                         pvalues[8].bit8 = "Not Defined";
10280                                         pvalues[8].bit8hfname = hf_bit8infoflagsh;
10281                                         pvalues[8].bit9 = "Not Defined";
10282                                         pvalues[8].bit9hfname = hf_bit9infoflagsh;
10283                                         pvalues[8].bit10 = "Not Defined";
10284                                         pvalues[8].bit10hfname = hf_bit10infoflagsh;
10285                                         pvalues[8].bit11 = "Not Defined";
10286                                         pvalues[8].bit11hfname = hf_bit11infoflagsh;
10287                                         pvalues[8].bit12 = "Not Defined";
10288                                         pvalues[8].bit12hfname = hf_bit12infoflagsh;
10289                                         pvalues[8].bit13 = "Not Defined";
10290                                         pvalues[8].bit13hfname = hf_bit13infoflagsh;
10291                                         pvalues[8].bit14 = "Not Defined";
10292                                         pvalues[8].bit14hfname = hf_bit14infoflagsh;
10293                                         pvalues[8].bit15 = "Not Defined";
10294                                         pvalues[8].bit15hfname = hf_bit15infoflagsh;
10295                                         pvalues[8].bit16 = "Not Defined";
10296                                         pvalues[8].bit16hfname = hf_bit16infoflagsh;
10297                                         foffset = foffset+2;
10298                                 }
10299                                 break;
10300                         case 0x07:
10301                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10302                                 pvalues[0].vstring = "";
10303                                 pvalues[0].vtype = VTYPE_UINT32;
10304                                 pvalues[0].vdesc = "Version: %u";
10305                                 pvalues[0].vlength = 4;
10306                                 pvalues[0].voffset = foffset;
10307                                 pvalues[0].hfname= hf_nds_ver;
10308                                 foffset = foffset+pvalues[0].vlength;
10309                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10310                                 pvalues[1].vtype = VTYPE_UINT32;
10311                                 pvalues[1].vstring = "";
10312                                 pvalues[1].vdesc = "Request Flags: 0x%08x";
10313                                 pvalues[1].vlength = 4;
10314                                 pvalues[1].hfname= hf_nds_rflags;
10315                                 pvalues[1].voffset = foffset;
10316                                 foffset = foffset+4;
10317                                 if(pvalues[0].vvalue == 0)
10318                                 {
10319                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10320                                         pvalues[2].vstring = "";
10321                                         pvalues[2].vtype = VTYPE_UINT32;
10322                                         pvalues[2].vdesc = "Parent Entry ID: 0x%08x";
10323                                         pvalues[2].vlength = 4;
10324                                         resolve_eid = FALSE;
10325                                         global_eid = pvalues[2].vvalue;
10326                                         pvalues[2].voffset = foffset;
10327                                         pvalues[2].hfname= hf_nds_eid;
10328                                         foffset = foffset+pvalues[2].vlength;
10329                                         pvalues[3].vtype = VTYPE_STRING;
10330                                         pvalues[3].vdesc = "Relative Distinguished Name: %s";
10331                                         pvalues[3].vstring = "";
10332                                         pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
10333                                         pvalues[3].vvalue = 0;
10334                                         pvalues[3].vlength = 256;
10335                                         pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
10336                                         if (pvalues[3].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
10337                                         {
10338                                                 pvalues[3].vtype = VTYPE_NONE;
10339                                                 break;
10340                                         }
10341                                         pvalues[3].voffset = foffset+4;
10342                                         foffset = foffset + 4;
10343                                         get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, req_buffer.buffer);
10344                                         pvalues[3].vstring = req_buffer.buffer;
10345                                         g_strlcpy(global_object_name, req_buffer.buffer, 256);
10346                                         pvalues[3].hfname= hf_nds_relative_dn;
10347                                         foffset = foffset+pvalues[3].vlength;
10348                                         foffset += align_4(tvb, foffset);
10349                                         pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
10350                                         pvalues[4].vtype = VTYPE_MULTIVALUE_UINT32;
10351                                         pvalues[4].vstring = "";
10352                                         pvalues[4].vdesc = "Attributes: %u";
10353                                         pvalues[4].vlength = 4;
10354                                         pvalues[4].voffset = foffset;
10355                                         pvalues[4].mvtype = MVTYPE_ADD_ATTR_REQUEST;
10356                                         pvalues[4].hfname= hf_nds_attr;
10357                                 }
10358                                 else
10359                                 {
10360                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10361                                         pvalues[2].vstring = "";
10362                                         pvalues[2].vtype = VTYPE_UINT32;
10363                                         pvalues[2].vdesc = "Iteration Handle: 0x%08x";
10364                                         pvalues[2].vlength = 4;
10365                                         pvalues[2].voffset = foffset;
10366                                         pvalues[2].hfname= hf_nds_iteration;
10367                                         foffset = foffset+pvalues[2].vlength;
10368                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
10369                                         pvalues[3].vstring = "";
10370                                         pvalues[3].vtype = VTYPE_UINT32;
10371                                         pvalues[3].vdesc = "Parent Entry ID: 0x%08x";
10372                                         pvalues[3].vlength = 4;
10373                                         resolve_eid = FALSE;
10374                                         global_eid = pvalues[3].vvalue;
10375                                         pvalues[3].voffset = foffset;
10376                                         pvalues[3].hfname= hf_nds_eid;
10377                                         foffset = foffset+pvalues[3].vlength;
10378                                         pvalues[4].vtype = VTYPE_STRING;
10379                                         pvalues[4].vdesc = "Relative Distinguished Name: %s";
10380                                         pvalues[4].vstring = "";
10381                                         pvalues[4].mvtype = MVTYPE_ATTR_REQUEST;
10382                                         pvalues[4].vvalue = 0;
10383                                         pvalues[4].vlength = 256;
10384                                         pvalues[4].vlength = tvb_get_letohl(tvb, foffset);
10385                                         if (pvalues[4].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[4].vlength))
10386                                         {
10387                                                 pvalues[4].vtype = VTYPE_NONE;
10388                                                 break;
10389                                         }
10390                                         pvalues[4].voffset = foffset+4;
10391                                         foffset = foffset + 4;
10392                                         get_string(tvb, pvalues[4].voffset, pvalues[4].vlength, req_buffer.buffer);
10393                                         pvalues[4].vstring = req_buffer.buffer;
10394                                         g_strlcpy(global_object_name, req_buffer.buffer, 256);
10395                                         pvalues[4].hfname= hf_nds_relative_dn;
10396                                         foffset = foffset+pvalues[4].vlength;
10397                                         foffset += align_4(tvb, foffset);
10398                                         pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
10399                                         pvalues[5].vtype = VTYPE_MULTIVALUE_UINT32;
10400                                         pvalues[5].vstring = "";
10401                                         pvalues[5].vdesc = "Attributes: %u";
10402                                         pvalues[5].vlength = 4;
10403                                         pvalues[5].voffset = foffset;
10404                                         pvalues[5].mvtype = MVTYPE_ADD_ATTR_REQUEST;
10405                                         pvalues[5].hfname= hf_nds_attr;
10406                                 }
10407                                 break;
10408                         case 0x08:
10409                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10410                                 pvalues[0].vtype = VTYPE_UINT32;
10411                                 pvalues[0].vdesc = "Version: %u";
10412                                 pvalues[0].vlength = 4;
10413                                 pvalues[0].voffset = foffset;
10414                                 pvalues[0].hfname= hf_nds_ver;
10415                                 foffset = foffset+pvalues[0].vlength;
10416                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10417                                 pvalues[1].vtype = VTYPE_UINT32;
10418                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
10419                                 pvalues[1].vlength = 4;
10420                                 resolve_eid = TRUE;
10421                                 global_eid = pvalues[1].vvalue;
10422                                 pvalues[1].voffset = foffset;
10423                                 pvalues[1].hfname= hf_nds_eid;
10424                                 foffset = foffset+pvalues[1].vlength;
10425                                 break;
10426                         case 0x09:
10427                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10428                                 pvalues[0].vtype = VTYPE_UINT32;
10429                                 pvalues[0].vdesc = "Version: %u";
10430                                 pvalues[0].vlength = 4;
10431                                 pvalues[0].voffset = foffset;
10432                                 pvalues[0].hfname= hf_nds_ver;
10433                                 foffset = foffset+pvalues[0].vlength;
10434                                 if(pvalues[0].vvalue == 0)
10435                                 {
10436                                         pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10437                                         pvalues[1].vtype = VTYPE_UINT32;
10438                                         pvalues[1].vstring = "";
10439                                         pvalues[1].vdesc = "Iteration Handle: 0x%08x";  /* always 0 */
10440                                         pvalues[1].vlength = 4;
10441                                         pvalues[1].hfname= hf_nds_iteration;
10442                                         pvalues[1].voffset = foffset;
10443                                         foffset = foffset+4;
10444                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10445                                         pvalues[2].vstring = "";
10446                                         pvalues[2].vtype = VTYPE_UINT32;
10447                                         pvalues[2].vdesc = "Entry ID: 0x%08x";
10448                                         pvalues[2].vlength = 4;
10449                                         pvalues[2].voffset = foffset;
10450                                         resolve_eid = TRUE;
10451                                         global_eid = pvalues[2].vvalue;
10452                                         pvalues[2].hfname = hf_nds_eid;
10453                                         foffset = foffset+pvalues[2].vlength;
10454                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
10455                                         pvalues[3].vtype = VTYPE_MULTIVALUE_UINT32;
10456                                         pvalues[3].vstring = "";
10457                                         pvalues[3].vdesc = "Number of Attributes to Change %u";
10458                                         pvalues[3].vlength = 4;
10459                                         pvalues[3].mvtype = MVTYPE_MODIFY_ATTR_REQUEST;
10460                                         pvalues[3].hfname= hf_nds_number_of_changes;
10461                                         pvalues[3].voffset = foffset;
10462                                 }
10463                                 else
10464                                 {
10465                                         pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10466                                         pvalues[1].vtype = VTYPE_UINT32;
10467                                         pvalues[1].vstring = "";
10468                                         pvalues[1].vdesc = "Request Flags: 0x%08x";  /* always 0 */
10469                                         pvalues[1].vlength = 4;
10470                                         pvalues[1].hfname= hf_nds_rflags;
10471                                         pvalues[1].voffset = foffset;
10472                                         foffset = foffset+4;
10473                                         pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10474                                         pvalues[2].vtype = VTYPE_UINT32;
10475                                         pvalues[2].vstring = "";
10476                                         pvalues[2].vdesc = "Iteration Handle: 0x%08x";  /* always 0 */
10477                                         pvalues[2].vlength = 4;
10478                                         pvalues[2].hfname= hf_nds_iteration;
10479                                         pvalues[2].voffset = foffset;
10480                                         foffset = foffset+4;
10481                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
10482                                         pvalues[3].vstring = "";
10483                                         pvalues[3].vtype = VTYPE_UINT32;
10484                                         pvalues[3].vdesc = "Entry ID: 0x%08x";
10485                                         pvalues[3].vlength = 4;
10486                                         pvalues[3].voffset = foffset;
10487                                         resolve_eid = TRUE;
10488                                         global_eid = pvalues[3].vvalue;
10489                                         pvalues[3].hfname = hf_nds_eid;
10490                                         foffset = foffset+pvalues[3].vlength;
10491                                         pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
10492                                         pvalues[4].vtype = VTYPE_MULTIVALUE_UINT32;
10493                                         pvalues[4].vstring = "";
10494                                         pvalues[4].vdesc = "Number of Attributes to Change %u";
10495                                         pvalues[4].vlength = 4;
10496                                         pvalues[4].mvtype = MVTYPE_MODIFY_ATTR_REQUEST;
10497                                         pvalues[4].hfname= hf_nds_number_of_changes;
10498                                         pvalues[4].voffset = foffset;
10499                                 }
10500                                 break;
10501                         case 0x0a:
10502                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10503                                 pvalues[0].vtype = VTYPE_UINT32;
10504                                 pvalues[0].vdesc = "Version: %u";
10505                                 pvalues[0].vlength = 4;
10506                                 pvalues[0].voffset = foffset;
10507                                 pvalues[0].hfname= hf_nds_ver;
10508                                 foffset = foffset+pvalues[0].vlength;
10509                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10510                                 pvalues[1].vtype = VTYPE_UINT32;
10511                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
10512                                 pvalues[1].vlength = 4;
10513                                 resolve_eid = TRUE;
10514                                 global_eid = pvalues[1].vvalue;
10515                                 pvalues[1].voffset = foffset;
10516                                 pvalues[1].hfname = hf_nds_eid;
10517                                 foffset = foffset+pvalues[1].vlength;
10518                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10519                                 pvalues[2].vtype = VTYPE_BOOLEAN;
10520                                 pvalues[2].vdesc = "Keep Original RDN: %s";
10521                                 pvalues[2].vlength = 4;
10522                                 pvalues[2].voffset = foffset;
10523                                 pvalues[2].mvtype = 0;
10524                                 pvalues[2].hfname= hf_nds_keep;
10525                                 foffset = foffset+4;
10526                                 foffset += align_4(tvb, foffset);
10527                                 pvalues[3].vtype = VTYPE_STRING;
10528                                 pvalues[3].vdesc = "New RDN: %s";
10529                                 pvalues[3].mvtype = 0;
10530                                 pvalues[3].vvalue = 0;
10531                                 pvalues[3].vlength = 256;
10532                                 pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
10533                                 pvalues[3].voffset = foffset+4;
10534                                 foffset = foffset + 4;
10535                                 get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, pvalues[3].vstring);
10536                                 pvalues[3].hfname= hf_nds_new_rdn;
10537                                 foffset = foffset+pvalues[3].vlength;
10538                                 break;
10539                         case 0x0b:
10540                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10541                                 pvalues[0].vtype = VTYPE_UINT32;
10542                                 pvalues[0].vdesc = "Version: %u";
10543                                 pvalues[0].vlength = 4;
10544                                 pvalues[0].voffset = foffset;
10545                                 pvalues[0].hfname= hf_nds_ver;
10546                                 foffset = foffset+pvalues[0].vlength;
10547                                 pvalues[1].vvalue = tvb_get_letohs(tvb, foffset);
10548                                 global_flags = tvb_get_letohl(tvb, foffset);
10549                                 pvalues[1].vtype = VTYPE_BITFIELD;
10550                                 pvalues[1].vdesc = "Attribute Constraints:";
10551                                 pvalues[1].vlength = 2;
10552                                 pvalues[1].hfname= hf_nds_acflags;
10553                                 pvalues[1].voffset = foffset;
10554                                 pvalues[1].bit1 = "Single Valued";
10555                                 pvalues[1].bit1hfname = hf_bit1acflags;
10556                                 pvalues[1].bit2 = "Sized";
10557                                 pvalues[1].bit2hfname = hf_bit2acflags;
10558                                 pvalues[1].bit3 = "Non-Removable";
10559                                 pvalues[1].bit3hfname = hf_bit3acflags;
10560                                 pvalues[1].bit4 = "Read Only";
10561                                 pvalues[1].bit4hfname = hf_bit4acflags;
10562                                 pvalues[1].bit5 = "Hidden";
10563                                 pvalues[1].bit5hfname = hf_bit5acflags;
10564                                 pvalues[1].bit6 = "String";
10565                                 pvalues[1].bit6hfname = hf_bit6acflags;
10566                                 pvalues[1].bit7 = "Synchronize Immediate";
10567                                 pvalues[1].bit7hfname = hf_bit7acflags;
10568                                 pvalues[1].bit8 = "Public Read";
10569                                 pvalues[1].bit8hfname = hf_bit8acflags;
10570                                 pvalues[1].bit9 = "Server Read";
10571                                 pvalues[1].bit9hfname = hf_bit9acflags;
10572                                 pvalues[1].bit10 = "Write Managed";
10573                                 pvalues[1].bit10hfname = hf_bit10acflags;
10574                                 pvalues[1].bit11 = "Per Replica";
10575                                 pvalues[1].bit11hfname = hf_bit11acflags;
10576                                 pvalues[1].bit12 = "Never Schedule Synchronization";
10577                                 pvalues[1].bit12hfname = hf_bit12acflags;
10578                                 pvalues[1].bit13 = "Operational";
10579                                 pvalues[1].bit13hfname = hf_bit13acflags;
10580                                 pvalues[1].bit14 = "Not Defined";
10581                                 pvalues[1].bit14hfname = hf_bit14acflags;
10582                                 pvalues[1].bit15 = "Not Defined";
10583                                 pvalues[1].bit15hfname = hf_bit15acflags;
10584                                 pvalues[1].bit16 = "Not Defined";
10585                                 pvalues[1].bit16hfname = hf_bit16acflags;
10586                                 foffset = foffset+4;
10587                                 pvalues[2].vtype = VTYPE_STRING;
10588                                 pvalues[2].vdesc = "Attribute Name: %s";
10589                                 pvalues[2].mvtype = MVTYPE_ATTR_REQUEST;
10590                                 pvalues[2].vvalue = 0;
10591                                 pvalues[2].vlength = 256;
10592                                 pvalues[2].vlength = tvb_get_letohl(tvb, foffset);
10593                                 if (pvalues[2].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[2].vlength))
10594                                 {
10595                                         pvalues[2].vtype = VTYPE_NONE;
10596                                         break;
10597                                 }
10598                                 pvalues[2].voffset = foffset+4;
10599                                 foffset = foffset + 4;
10600                                 get_string(tvb, pvalues[2].voffset, pvalues[2].vlength, req_buffer.buffer);
10601                                 pvalues[2].vstring = req_buffer.buffer;
10602                                 g_strlcpy(global_object_name, req_buffer.buffer, 256);
10603                                 pvalues[2].hfname= hf_nds_name;
10604                                 foffset = foffset+pvalues[2].vlength;
10605                                 foffset += align_4(tvb, foffset);
10606                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
10607                                 pvalues[3].vstring = (char *)match_strval(pvalues[3].vvalue, nds_syntax);
10608                                 if(pvalues[3].vstring == NULL)
10609                                 {
10610                                         pvalues[3].vstring = "No Syntax Found";
10611                                 }
10612                                 pvalues[3].vtype = VTYPE_STRING;
10613                                 pvalues[3].vdesc = "Syntax: %s";
10614                                 pvalues[3].vlength = 4;
10615                                 pvalues[3].voffset = foffset;
10616                                 pvalues[3].hfname= hf_nds_syntax;
10617                                 pvalues[3].mvtype = 0;
10618                                 foffset = foffset+pvalues[3].vlength;
10619                                 pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
10620                                 pvalues[4].vtype = VTYPE_UINT32;
10621                                 pvalues[4].vdesc = "Lower Limit Value %u";
10622                                 pvalues[4].vlength = 4;
10623                                 pvalues[4].voffset = foffset;
10624                                 pvalues[4].hfname = hf_nds_lower;
10625                                 foffset += 4;
10626                                 pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
10627                                 pvalues[5].vtype = VTYPE_UINT32;
10628                                 pvalues[5].vdesc = "Upper Limit Value %u";
10629                                 pvalues[5].vlength = 4;
10630                                 pvalues[5].voffset = foffset;
10631                                 pvalues[5].hfname = hf_nds_upper;
10632                                 foffset += 4;
10633                                 pvalues[6].vvalue = tvb_get_letohl(tvb, foffset); /* Length of bytes field */
10634                                 foffset += 4;
10635                                 pvalues[6].vtype = VTYPE_BYTES;
10636                                 pvalues[6].vdesc = "ASN.1 ID";
10637                                 pvalues[6].vlength = pvalues[6].vvalue;
10638                                 pvalues[6].voffset = foffset;
10639                                 pvalues[6].hfname = hf_nds_asn1;
10640                                 break;
10641                         case 0x0c:
10642                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
10643                                 break;
10644                         case 0x0d:
10645                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10646                                 pvalues[0].vtype = VTYPE_UINT32;
10647                                 pvalues[0].vdesc = "Version: %u";
10648                                 pvalues[0].vlength = 4;
10649                                 pvalues[0].voffset = foffset;
10650                                 pvalues[0].hfname= hf_nds_ver;
10651                                 foffset = foffset+pvalues[0].vlength;
10652                                 pvalues[1].vtype = VTYPE_STRING;
10653                                 pvalues[1].vdesc = "Attribute Name: %s";
10654                                 pvalues[1].mvtype = MVTYPE_ATTR_REQUEST;
10655                                 pvalues[1].vvalue = 0;
10656                                 pvalues[1].vlength = 256;
10657                                 pvalues[1].vlength = tvb_get_letohl(tvb, foffset);
10658                                 if (pvalues[1].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[1].vlength))
10659                                 {
10660                                         pvalues[1].vtype = VTYPE_NONE;
10661                                         break;
10662                                 }
10663                                 pvalues[1].voffset = foffset+4;
10664                                 foffset = foffset + 4;
10665                                 get_string(tvb, pvalues[1].voffset, pvalues[1].vlength, req_buffer.buffer);
10666                                 pvalues[1].vstring = req_buffer.buffer;
10667                                 g_strlcpy(global_object_name, req_buffer.buffer, 256);
10668                                 pvalues[1].hfname= hf_nds_attribute_dn;
10669                                 break;
10670                         case 0x0e:
10671                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
10672                                 break;
10673                         case 0x0f:
10674                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10675                                 pvalues[0].vtype = VTYPE_UINT32;
10676                                 pvalues[0].vdesc = "Version: %u";
10677                                 pvalues[0].vlength = 4;
10678                                 pvalues[0].voffset = foffset;
10679                                 pvalues[0].hfname= hf_nds_ver;
10680                                 foffset = foffset+pvalues[0].vlength;
10681                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10682                                 pvalues[1].vtype = VTYPE_UINT32;
10683                                 pvalues[1].vdesc = "Iteration Handle: 0x%08x";
10684                                 pvalues[1].vlength = 4;
10685                                 pvalues[1].voffset = foffset;
10686                                 pvalues[1].hfname= hf_nds_iteration;
10687                                 foffset = foffset+pvalues[1].vlength;
10688                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10689                                 global_flags = pvalues[2].vvalue;
10690                                 pvalues[2].vstring = (char *)match_strval(pvalues[2].vvalue, class_def_type);
10691                                 if(pvalues[2].vstring == NULL)
10692                                 {
10693                                         pvalues[2].vstring = "No Class Definition Type Set";
10694                                 }
10695                                 pvalues[2].vtype = VTYPE_STRING;
10696                                 pvalues[2].vdesc = "Class Definition Type: %s";
10697                                 pvalues[2].vlength = 4;
10698                                 pvalues[2].voffset = foffset;
10699                                 pvalues[2].mvtype = 0;
10700                                 pvalues[2].hfname= hf_nds_class_def_type;
10701                                 foffset = foffset + pvalues[2].vlength;
10702                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
10703                                 if (pvalues[3].vvalue == 0x00000000)
10704                                 {
10705                                         pvalues[3].vstring = "Do Not Return All Classes";
10706                                         pvalues[3].mvtype = 0;
10707                                 }
10708                                 else
10709                                 {
10710                                         pvalues[3].vstring = "Return All Classes";
10711                                         pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
10712                                 }
10713                                 pvalues[3].vtype = VTYPE_STRING;
10714                                 pvalues[3].vdesc = "%s";
10715                                 pvalues[3].vlength = 4;
10716                                 pvalues[3].voffset = foffset;
10717                                 pvalues[3].hfname= hf_nds_return_all_classes;
10718                                 foffset = foffset + pvalues[3].vlength;
10719                                 foffset += align_4(tvb, foffset);
10720                                 pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
10721                                 pvalues[4].vtype = VTYPE_MULTIVALUE_UINT32;
10722                                 pvalues[4].vdesc = "Classes: %d";
10723                                 pvalues[4].vlength = 4;
10724                                 pvalues[4].voffset = foffset;
10725                                 pvalues[4].mvtype = MVTYPE_READ_CLASS_REQ;
10726                                 pvalues[4].hfname= hf_nds_classes;
10727                                 break;
10728                         case 0x10:
10729                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10730                                 pvalues[0].vtype = VTYPE_UINT32;
10731                                 pvalues[0].vdesc = "Version: %u";
10732                                 pvalues[0].vlength = 4;
10733                                 pvalues[0].voffset = foffset;
10734                                 pvalues[0].hfname= hf_nds_ver;
10735                                 foffset = foffset+pvalues[0].vlength;
10736                                 pvalues[1].vtype = VTYPE_STRING;
10737                                 pvalues[1].vdesc = "Class Name: %s";
10738                                 pvalues[1].mvtype = MVTYPE_ATTR_REQUEST;
10739                                 pvalues[1].vvalue = 0;
10740                                 pvalues[1].vlength = 256;
10741                                 pvalues[1].vlength = tvb_get_letohl(tvb, foffset);
10742                                 if (pvalues[1].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[1].vlength))
10743                                 {
10744                                         pvalues[1].vtype = VTYPE_NONE;
10745                                         break;
10746                                 }
10747                                 pvalues[1].voffset = foffset+4;
10748                                 foffset = foffset + 4;
10749                                 get_string(tvb, pvalues[1].voffset, pvalues[1].vlength, req_buffer.buffer);
10750                                 pvalues[1].vstring = req_buffer.buffer;
10751                                 g_strlcpy(global_object_name, req_buffer.buffer, 256);
10752                                 pvalues[1].hfname= hf_nds_base_class;
10753                                 foffset = foffset+pvalues[1].vlength;
10754                                 foffset += align_4(tvb, foffset);
10755                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10756                                 pvalues[2].vtype = VTYPE_MULTIVALUE_UINT32;
10757                                 pvalues[2].vdesc = "Number of Attributes to Add: %u";
10758                                 pvalues[2].vlength = 4;
10759                                 pvalues[2].voffset = foffset;
10760                                 pvalues[2].mvtype = MVTYPE_MODIFY_CLASS;
10761                                 pvalues[2].hfname= hf_nds_att_add;
10762                                 break;
10763                         case 0x11:
10764                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10765                                 pvalues[0].vtype = VTYPE_UINT32;
10766                                 pvalues[0].vdesc = "Version: %u";
10767                                 pvalues[0].vlength = 4;
10768                                 pvalues[0].voffset = foffset;
10769                                 pvalues[0].hfname= hf_nds_ver;
10770                                 foffset = foffset+pvalues[0].vlength;
10771                                 pvalues[1].vtype = VTYPE_STRING;
10772                                 pvalues[1].vdesc = "Class Name: %s";
10773                                 pvalues[1].mvtype = MVTYPE_ATTR_REQUEST;
10774                                 pvalues[1].vvalue = 0;
10775                                 pvalues[1].vlength = 256;
10776                                 pvalues[1].vlength = tvb_get_letohl(tvb, foffset);
10777                                 if (pvalues[1].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[1].vlength))
10778                                 {
10779                                         pvalues[1].vtype = VTYPE_NONE;
10780                                         break;
10781                                 }
10782                                 pvalues[1].voffset = foffset+4;
10783                                 foffset = foffset + 4;
10784                                 get_string(tvb, pvalues[1].voffset, pvalues[1].vlength, req_buffer.buffer);
10785                                 pvalues[1].vstring = req_buffer.buffer;
10786                                 g_strlcpy(global_object_name, req_buffer.buffer, 256);
10787                                 pvalues[1].hfname= hf_nds_base;
10788                                 break;
10789                         case 0x12:
10790                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10791                                 pvalues[0].vtype = VTYPE_UINT32;
10792                                 pvalues[0].vdesc = "Version: %u";
10793                                 pvalues[0].vlength = 4;
10794                                 pvalues[0].voffset = foffset;
10795                                 pvalues[0].hfname= hf_nds_ver;
10796                                 foffset = foffset+pvalues[0].vlength;
10797                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10798                                 pvalues[1].vtype = VTYPE_UINT32;
10799                                 pvalues[1].vdesc = "Iteration Handle: 0x%08x";
10800                                 pvalues[1].vlength = 4;
10801                                 pvalues[1].voffset = foffset;
10802                                 pvalues[1].hfname= hf_nds_iteration;
10803                                 foffset = foffset+pvalues[1].vlength;
10804                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10805                                 pvalues[2].vtype = VTYPE_UINT32;
10806                                 pvalues[2].vdesc = "Entry ID: 0x%08x";
10807                                 pvalues[2].vlength = 4;
10808                                 resolve_eid = TRUE;
10809                                 global_eid = pvalues[2].vvalue;
10810                                 pvalues[2].voffset = foffset;
10811                                 pvalues[2].hfname= hf_nds_eid;
10812                                 foffset = foffset+pvalues[2].vlength;
10813                                 break;
10814                         case 0x13:
10815                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10816                                 pvalues[0].vtype = VTYPE_UINT32;
10817                                 pvalues[0].vdesc = "Version: %u";
10818                                 pvalues[0].vlength = 4;
10819                                 pvalues[0].voffset = foffset;
10820                                 pvalues[0].hfname= hf_nds_ver;
10821                                 foffset = foffset+pvalues[0].vlength;
10822                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10823                                 pvalues[1].vtype = VTYPE_UINT32;
10824                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
10825                                 pvalues[1].vlength = 4;
10826                                 resolve_eid = TRUE;
10827                                 global_eid = pvalues[1].vvalue;
10828                                 pvalues[1].voffset = foffset;
10829                                 pvalues[1].hfname= hf_nds_eid;
10830                                 foffset = foffset+pvalues[1].vlength;
10831                                 pvalues[2].vtype = VTYPE_STRING;
10832                                 pvalues[2].vdesc = "Trustee Name: %s";
10833                                 pvalues[2].mvtype = MVTYPE_ATTR_REQUEST;
10834                                 pvalues[2].vvalue = 0;
10835                                 pvalues[2].vlength = 256;
10836                                 pvalues[2].vlength = tvb_get_letohl(tvb, foffset);
10837                                 if (pvalues[2].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[2].vlength))
10838                                 {
10839                                         pvalues[2].vtype = VTYPE_NONE;
10840                                         break;
10841                                 }
10842                                 pvalues[2].voffset = foffset+4;
10843                                 foffset = foffset + 4;
10844                                 get_string(tvb, pvalues[2].voffset, pvalues[2].vlength, req_buffer.buffer);
10845                                 pvalues[2].vstring = req_buffer.buffer;
10846                                 pvalues[2].hfname= hf_nds_name;
10847                                 foffset = foffset+pvalues[2].vlength;
10848                                 foffset += align_4(tvb, foffset);
10849                                 pvalues[3].vtype = VTYPE_STRING;
10850                                 pvalues[3].vdesc = "Attribute to be Checked: %s";
10851                                 pvalues[3].mvtype = 0;
10852                                 pvalues[3].vvalue = 0;
10853                                 pvalues[3].vlength = 256;
10854                                 pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
10855                                 if (pvalues[3].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
10856                                 {
10857                                         pvalues[3].vtype = VTYPE_NONE;
10858                                         break;
10859                                 }
10860                                 pvalues[3].voffset = foffset+4;
10861                                 foffset = foffset + 4;
10862                                 get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, pvalues[3].vstring);
10863                                 pvalues[3].hfname= hf_nds_name;
10864                                 foffset = foffset+pvalues[3].vlength;
10865                                 foffset += align_4(tvb, foffset);
10866                                 if(pvalues[0].vvalue != 0)
10867                                 {
10868                                         pvalues[4].vtype = VTYPE_STRING;
10869                                         pvalues[4].vdesc = "Security Equivalence: %s";
10870                                         pvalues[4].mvtype = MVTYPE_ATTR_REQUEST;
10871                                         pvalues[4].vvalue = 0;
10872                                         pvalues[4].vlength = 256;
10873                                         pvalues[4].vlength = tvb_get_letohl(tvb, foffset);
10874                                         if (pvalues[4].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[4].vlength))
10875                                         {
10876                                                 pvalues[4].vtype = VTYPE_NONE;
10877                                                 break;
10878                                         }
10879                                         pvalues[4].voffset = foffset+4;
10880                                         foffset = foffset + 4;
10881                                         get_string(tvb, pvalues[4].voffset, pvalues[4].vlength, pvalues[4].vstring);
10882                                         pvalues[4].hfname= hf_nds_name;
10883                                         foffset = foffset+pvalues[4].vlength;
10884                                         foffset += align_4(tvb, foffset);
10885                                 }
10886                                 break;
10887                         case 0x14:
10888                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
10889                                 break;
10890                         case 0x15:
10891                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
10892                                 break;
10893                         case 0x16:
10894                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
10895                                 pvalues[0].vtype = VTYPE_UINT32;
10896                                 pvalues[0].vdesc = "Version: %u";
10897                                 pvalues[0].vlength = 4;
10898                                 pvalues[0].voffset = foffset;
10899                                 pvalues[0].hfname= hf_nds_ver;
10900                                 foffset = foffset+pvalues[0].vlength;
10901                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
10902                                 pvalues[1].vtype = VTYPE_BITFIELD;
10903                                 pvalues[1].vdesc = "Request Flags:";
10904                                 pvalues[1].vlength = 2;
10905                                 pvalues[1].hfname= hf_nds_rflags;
10906                                 pvalues[1].voffset = foffset;
10907                                 pvalues[1].bit1 = "Typeless";
10908                                 pvalues[1].bit1hfname = hf_nds_bit1;
10909                                 pvalues[1].bit2 = "All Containers";
10910                                 pvalues[1].bit2hfname = hf_nds_bit2;
10911                                 pvalues[1].bit3 = "Slashed";
10912                                 pvalues[1].bit3hfname = hf_nds_bit3;
10913                                 pvalues[1].bit4 = "Dotted";
10914                                 pvalues[1].bit4hfname = hf_nds_bit4;
10915                                 pvalues[1].bit5 = "Tuned";
10916                                 pvalues[1].bit5hfname = hf_nds_bit5;
10917                                 pvalues[1].bit6 = "Not Defined";
10918                                 pvalues[1].bit6hfname = hf_nds_bit6;
10919                                 pvalues[1].bit7 = "Not Defined";
10920                                 pvalues[1].bit7hfname = hf_nds_bit7;
10921                                 pvalues[1].bit8 = "Not Defined";
10922                                 pvalues[1].bit8hfname = hf_nds_bit8;
10923                                 pvalues[1].bit9 = "Not Defined";
10924                                 pvalues[1].bit9hfname = hf_nds_bit9;
10925                                 pvalues[1].bit10 = "Not Defined";
10926                                 pvalues[1].bit10hfname = hf_nds_bit10;
10927                                 pvalues[1].bit11 = "Not Defined";
10928                                 pvalues[1].bit11hfname = hf_nds_bit11;
10929                                 pvalues[1].bit12 = "Not Defined";
10930                                 pvalues[1].bit12hfname = hf_nds_bit12;
10931                                 pvalues[1].bit13 = "Not Defined";
10932                                 pvalues[1].bit13hfname = hf_nds_bit13;
10933                                 pvalues[1].bit14 = "Not Defined";
10934                                 pvalues[1].bit14hfname = hf_nds_bit14;
10935                                 pvalues[1].bit15 = "Not Defined";
10936                                 pvalues[1].bit15hfname = hf_nds_bit15;
10937                                 pvalues[1].bit16 = "Not Defined";
10938                                 pvalues[1].bit16hfname = hf_nds_bit16;
10939                                 foffset = foffset+pvalues[1].vlength;
10940                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
10941                                 pvalues[2].vtype = VTYPE_UINT32;
10942                                 pvalues[2].vdesc = "Iteration Handle: 0x%08x";
10943                                 pvalues[2].vlength = 4;
10944                                 pvalues[2].voffset = foffset;
10945                                 pvalues[2].hfname= hf_nds_iteration;
10946                                 foffset = foffset+pvalues[2].vlength;
10947                                 if(pvalues[0].vvalue == 0)
10948                                 {
10949                                         global_flags = 0x000000c0;
10950                                         break;
10951                                 }
10952                                 pvalues[3].vvalue = tvb_get_letohs(tvb, foffset);
10953                                 pvalues[3].vtype = VTYPE_BITFIELD;
10954                                 pvalues[3].vdesc = "Information Flags (low) Byte:";
10955                                 pvalues[3].vlength = 2;
10956                                 pvalues[3].hfname= hf_nds_rflags;
10957                                 pvalues[3].voffset = foffset;
10958                                 pvalues[3].bit1 = "Output Flags";
10959                                 pvalues[3].bit1hfname = hf_bit1l1flagsl;
10960                                 pvalues[3].bit2 = "Entry ID";
10961                                 pvalues[3].bit2hfname = hf_bit2l1flagsl;
10962                                 pvalues[3].bit3 = "Replica State";
10963                                 pvalues[3].bit3hfname = hf_bit3l1flagsl;
10964                                 pvalues[3].bit4 = "Modification Timestamp";
10965                                 pvalues[3].bit4hfname = hf_bit4l1flagsl;
10966                                 pvalues[3].bit5 = "Purge Time";
10967                                 pvalues[3].bit5hfname = hf_bit5l1flagsl;
10968                                 pvalues[3].bit6 = "Local Partition ID";
10969                                 pvalues[3].bit6hfname = hf_bit6l1flagsl;
10970                                 pvalues[3].bit7 = "Distinguished Name";
10971                                 pvalues[3].bit7hfname = hf_bit7l1flagsl;
10972                                 pvalues[3].bit8 = "Replica Type";
10973                                 pvalues[3].bit8hfname = hf_bit8l1flagsl;
10974                                 pvalues[3].bit9 = "Partition Busy";
10975                                 pvalues[3].bit9hfname = hf_bit9l1flagsl;
10976                                 pvalues[3].bit10 = "Not Defined";
10977                                 pvalues[3].bit10hfname = hf_bit10l1flagsl;
10978                                 pvalues[3].bit11 = "Not Defined";
10979                                 pvalues[3].bit11hfname = hf_bit11l1flagsl;
10980                                 pvalues[3].bit12 = "Not Defined";
10981                                 pvalues[3].bit12hfname = hf_bit12l1flagsl;
10982                                 pvalues[3].bit13 = "Not Defined";
10983                                 pvalues[3].bit13hfname = hf_bit13l1flagsl;
10984                                 pvalues[3].bit14 = "Not Defined";
10985                                 pvalues[3].bit14hfname = hf_bit14l1flagsl;
10986                                 pvalues[3].bit15 = "Not Defined";
10987                                 pvalues[3].bit15hfname = hf_bit15l1flagsl;
10988                                 pvalues[3].bit16 = "Not Defined";
10989                                 pvalues[3].bit16hfname = hf_bit16l1flagsl;
10990                                 global_flags = pvalues[3].vvalue;
10991                                 foffset = foffset+2;
10992                                 pvalues[4].vvalue = tvb_get_letohs(tvb, foffset);
10993                                 pvalues[4].vtype = VTYPE_BITFIELD;
10994                                 pvalues[4].vdesc = "Information Flags (high) Byte:";
10995                                 pvalues[4].vlength = 2;
10996                                 pvalues[4].hfname= hf_nds_rflags;
10997                                 pvalues[4].voffset = foffset;
10998                                 pvalues[4].bit1 = "Not Defined";
10999                                 pvalues[4].bit1hfname = hf_bit1l1flagsl;
11000                                 pvalues[4].bit2 = "Not Defined";
11001                                 pvalues[4].bit2hfname = hf_bit2l1flagsl;
11002                                 pvalues[4].bit3 = "Not Defined";
11003                                 pvalues[4].bit3hfname = hf_bit3l1flagsl;
11004                                 pvalues[4].bit4 = "Not Defined";
11005                                 pvalues[4].bit4hfname = hf_bit4l1flagsl;
11006                                 pvalues[4].bit5 = "Not Defined";
11007                                 pvalues[4].bit5hfname = hf_bit5l1flagsl;
11008                                 pvalues[4].bit6 = "Not Defined";
11009                                 pvalues[4].bit6hfname = hf_bit6l1flagsl;
11010                                 pvalues[4].bit7 = "Not Defined";
11011                                 pvalues[4].bit7hfname = hf_bit7l1flagsl;
11012                                 pvalues[4].bit8 = "Not Defined";
11013                                 pvalues[4].bit8hfname = hf_bit8l1flagsl;
11014                                 pvalues[4].bit9 = "Not Defined";
11015                                 pvalues[4].bit9hfname = hf_bit9l1flagsl;
11016                                 pvalues[4].bit10 = "Not Defined";
11017                                 pvalues[4].bit10hfname = hf_bit10l1flagsl;
11018                                 pvalues[4].bit11 = "Not Defined";
11019                                 pvalues[4].bit11hfname = hf_bit11l1flagsl;
11020                                 pvalues[4].bit12 = "Not Defined";
11021                                 pvalues[4].bit12hfname = hf_bit12l1flagsl;
11022                                 pvalues[4].bit13 = "Not Defined";
11023                                 pvalues[4].bit13hfname = hf_bit13l1flagsl;
11024                                 pvalues[4].bit14 = "Not Defined";
11025                                 pvalues[4].bit14hfname = hf_bit14l1flagsl;
11026                                 pvalues[4].bit15 = "Not Defined";
11027                                 pvalues[4].bit15hfname = hf_bit15l1flagsl;
11028                                 pvalues[4].bit16 = "Not Defined";
11029                                 pvalues[4].bit16hfname = hf_bit16l1flagsl;
11030                                 foffset = foffset+2;
11031                                 if(pvalues[0].vvalue == 1)
11032                                 {
11033                                         break;
11034                                 }
11035                                 pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
11036                                 pvalues[5].vtype = VTYPE_UINT32;
11037                                 pvalues[5].vdesc = "Partition Root ID: 0x%08x";
11038                                 pvalues[5].vlength = 4;
11039                                 pvalues[5].voffset = foffset;
11040                                 pvalues[5].hfname= hf_nds_partition_root_id;
11041                                 foffset = foffset+pvalues[5].vlength;
11042                                 break;
11043                         case 0x17:
11044                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11045                                 pvalues[0].vtype = VTYPE_UINT32;
11046                                 pvalues[0].vdesc = "Version: %u";
11047                                 pvalues[0].vlength = 4;
11048                                 pvalues[0].hfname = hf_nds_ver;
11049                                 pvalues[0].voffset = foffset;
11050                                 foffset = foffset+pvalues[0].vlength;
11051                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11052                                 pvalues[1].vtype = VTYPE_UINT32;
11053                                 pvalues[1].vdesc = "Flags: 0x%08x";
11054                                 pvalues[1].vlength = 4;
11055                                 pvalues[1].hfname = hf_nds_req_flags;
11056                                 pvalues[1].voffset = foffset;
11057                                 foffset = foffset+pvalues[1].vlength;
11058                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11059                                 pvalues[2].vtype = VTYPE_UINT32;
11060                                 pvalues[2].vdesc = "New Partition Root ID: 0x%08x";
11061                                 pvalues[2].vlength = 4;
11062                                 pvalues[2].voffset = foffset;
11063                                 pvalues[2].hfname= hf_nds_new_part_id;
11064                                 foffset = foffset+pvalues[2].vlength;
11065                                 break;
11066                         case 0x18:
11067                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11068                                 pvalues[0].vtype = VTYPE_UINT32;
11069                                 pvalues[0].vdesc = "Version: %u";
11070                                 pvalues[0].vlength = 4;
11071                                 pvalues[0].hfname = hf_nds_ver;
11072                                 pvalues[0].voffset = foffset;
11073                                 foffset = foffset+pvalues[0].vlength;
11074                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11075                                 pvalues[1].vtype = VTYPE_UINT32;
11076                                 pvalues[1].vdesc = "Flags: 0x%08x";
11077                                 pvalues[1].vlength = 4;
11078                                 pvalues[1].hfname = hf_nds_req_flags;
11079                                 pvalues[1].voffset = foffset;
11080                                 foffset = foffset+pvalues[1].vlength;
11081                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11082                                 pvalues[2].vtype = VTYPE_UINT32;
11083                                 pvalues[2].vdesc = "Child Partition Root ID: 0x%08x";
11084                                 pvalues[2].vlength = 4;
11085                                 pvalues[2].voffset = foffset;
11086                                 pvalues[2].hfname= hf_nds_child_part_id;
11087                                 foffset = foffset+pvalues[2].vlength;
11088                                 break;
11089                         case 0x19:
11090                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11091                                 pvalues[0].vtype = VTYPE_UINT32;
11092                                 pvalues[0].vdesc = "Version: %u";
11093                                 pvalues[0].vlength = 4;
11094                                 pvalues[0].hfname = hf_nds_ver;
11095                                 pvalues[0].voffset = foffset;
11096                                 foffset = foffset+pvalues[0].vlength;
11097                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11098                                 pvalues[1].vtype = VTYPE_UINT32;
11099                                 pvalues[1].vdesc = "Flags: 0x%08x";
11100                                 pvalues[1].vlength = 4;
11101                                 pvalues[1].hfname = hf_nds_req_flags;
11102                                 pvalues[1].voffset = foffset;
11103                                 foffset = foffset+pvalues[1].vlength;
11104                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11105                                 pvalues[2].vtype = VTYPE_UINT32;
11106                                 pvalues[2].vdesc = "Master Partition Root ID: 0x%08x";
11107                                 pvalues[2].vlength = 4;
11108                                 pvalues[2].voffset = foffset;
11109                                 pvalues[2].hfname= hf_nds_master_part_id;
11110                                 foffset = foffset+pvalues[2].vlength;
11111                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
11112                                 pvalues[3].vstring = (char *)match_strval(pvalues[3].vvalue, nds_replica_type);
11113                                 if(pvalues[3].vstring == NULL)
11114                                 {
11115                                         pvalues[3].vstring = "No Replica Type Found";
11116                                 }
11117                                 pvalues[3].vtype = VTYPE_STRING;
11118                                 pvalues[3].vdesc = "Replica Type: %s";
11119                                 pvalues[3].vlength = 4;
11120                                 pvalues[3].voffset = foffset;
11121                                 pvalues[3].mvtype = 0;
11122                                 pvalues[3].hfname= hf_replica_type;
11123                                 foffset = foffset + pvalues[3].vlength;
11124                                 pvalues[4].vtype = VTYPE_STRING;
11125                                 pvalues[4].vdesc = "Target Server Name: %s";
11126                                 pvalues[4].mvtype = 0;
11127                                 pvalues[4].vvalue = 0;
11128                                 pvalues[4].vlength = 256;
11129                                 pvalues[4].vlength = tvb_get_letohl(tvb, foffset);
11130                                 if (pvalues[4].vlength == 0x00 && !tvb_bytes_exist(tvb, foffset, pvalues[4].vlength))
11131                                 {
11132                                         pvalues[4].vtype = VTYPE_NONE;
11133                                         break;
11134                                 }
11135                                 pvalues[4].voffset = foffset+4;
11136                                 foffset = foffset + 4;
11137                                 get_string(tvb, pvalues[4].voffset, pvalues[4].vlength, pvalues[4].vstring);
11138                                 pvalues[4].hfname= hf_nds_target_name;
11139                                 break;
11140                         case 0x1a:
11141                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11142                                 break;
11143                         case 0x1b:
11144                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11145                                 pvalues[0].vtype = VTYPE_UINT32;
11146                                 pvalues[0].vdesc = "Version: %u";
11147                                 pvalues[0].vlength = 4;
11148                                 pvalues[0].hfname = hf_nds_ver;
11149                                 pvalues[0].voffset = foffset;
11150                                 foffset = foffset+pvalues[0].vlength;
11151                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11152                                 pvalues[1].vtype = VTYPE_UINT32;
11153                                 pvalues[1].vdesc = "Streams Flags: 0x%08x";
11154                                 pvalues[1].vlength = 4;
11155                                 pvalues[1].hfname = hf_nds_stream_flags;
11156                                 pvalues[1].voffset = foffset;
11157                                 foffset = foffset+pvalues[1].vlength;
11158                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11159                                 pvalues[2].vtype = VTYPE_UINT32;
11160                                 pvalues[2].vdesc = "Entry ID: 0x%08x";
11161                                 pvalues[2].vlength = 4;
11162                                 resolve_eid = TRUE;
11163                                 global_eid = pvalues[2].vvalue;
11164                                 pvalues[2].voffset = foffset;
11165                                 pvalues[2].hfname= hf_nds_eid;
11166                                 foffset = foffset+pvalues[2].vlength;
11167                                 pvalues[3].vtype = VTYPE_STRING;
11168                                 pvalues[3].vdesc = "Stream Name: %s";
11169                                 pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
11170                                 pvalues[3].vvalue = 0;
11171                                 pvalues[3].vlength = 256;
11172                                 pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
11173                                 if (pvalues[3].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
11174                                 {
11175                                         pvalues[3].vtype = VTYPE_NONE;
11176                                         break;
11177                                 }
11178                                 pvalues[3].voffset = foffset+4;
11179                                 foffset += 4;
11180                                 get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, pvalues[3].vstring);
11181                                 foffset += pvalues[3].vlength;
11182                                 foffset += align_4(tvb, foffset);
11183                                 pvalues[3].hfname= hf_nds_stream_name;
11184                                 break;
11185                         case 0x1c:
11186                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11187                                 break;
11188                         case 0x1d:
11189                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11190                                 break;
11191                         case 0x1e:
11192                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11193                                 break;
11194                         case 0x1f:
11195                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11196                                 break;
11197                         case 0x20:
11198                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11199                                 break;
11200                         case 0x21:
11201                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11202                                 break;
11203                         case 0x22:
11204                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11205                                 break;
11206                         case 0x23:
11207                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11208                                 break;
11209                         case 0x24:
11210                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11211                                 break;
11212                         case 0x25:
11213                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11214                                 break;
11215                         case 0x26:
11216                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11217                                 pvalues[0].vtype = VTYPE_UINT32;
11218                                 pvalues[0].vdesc = "Version: %u";
11219                                 pvalues[0].vlength = 4;
11220                                 pvalues[0].hfname = hf_nds_ver;
11221                                 pvalues[0].voffset = foffset;
11222                                 foffset = foffset+pvalues[0].vlength;
11223                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11224                                 pvalues[1].vtype = VTYPE_UINT32;
11225                                 pvalues[1].vdesc = "Flags: 0x%08x";
11226                                 pvalues[1].vlength = 4;
11227                                 pvalues[1].hfname = hf_nds_req_flags;
11228                                 pvalues[1].voffset = foffset;
11229                                 foffset = foffset+pvalues[1].vlength;
11230                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11231                                 pvalues[2].vtype = VTYPE_UINT32;
11232                                 pvalues[2].vdesc = "Time Delay in Seconds: %u";
11233                                 pvalues[2].vlength = 4;
11234                                 pvalues[2].voffset = foffset;
11235                                 pvalues[2].hfname= hf_nds_time_delay;
11236                                 foffset = foffset+pvalues[2].vlength;
11237                                 if(pvalues[0].vvalue == 0)
11238                                 {
11239                                         pvalues[3].vtype = VTYPE_STRING;
11240                                         pvalues[3].vdesc = "Root Most Object Name: %s";
11241                                         pvalues[3].mvtype = MVTYPE_ATTR_REQUEST;
11242                                         pvalues[3].vvalue = 0;
11243                                         pvalues[3].vlength = 256;
11244                                         pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
11245                                         if (pvalues[3].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
11246                                         {
11247                                                 pvalues[3].vtype = VTYPE_NONE;
11248                                                 break;
11249                                         }
11250                                         pvalues[3].voffset = foffset+4;
11251                                         foffset += 4;
11252                                         get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, pvalues[3].vstring);
11253                                         foffset += pvalues[3].vlength;
11254                                         foffset += align_4(tvb, foffset);
11255                                         pvalues[3].hfname= hf_nds_root_name;
11256                                 }
11257                                 else
11258                                 {
11259                                         pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
11260                                         pvalues[3].vtype = VTYPE_UINT32;
11261                                         pvalues[3].vdesc = "Entry ID: 0x%08x";
11262                                         pvalues[3].vlength = 4;
11263                                         resolve_eid = TRUE;
11264                                         global_eid = pvalues[3].vvalue;
11265                                         pvalues[3].voffset = foffset;
11266                                         pvalues[3].hfname= hf_nds_eid;
11267                                         foffset = foffset+pvalues[3].vlength;
11268                                         resolve_eid = TRUE;
11269                                         global_eid = pvalues[3].vvalue;
11270                                 }
11271                                 break;
11272                         case 0x27:
11273                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11274                                 break;
11275                         case 0x28:
11276                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11277                                 break;
11278                         case 0x29:
11279                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11280                                 break;
11281                         case 0x2a:
11282                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11283                                 pvalues[0].vtype = VTYPE_UINT32;
11284                                 pvalues[0].vdesc = "Version: %u";
11285                                 pvalues[0].vlength = 4;
11286                                 pvalues[0].hfname = hf_nds_ver;
11287                                 pvalues[0].voffset = foffset;
11288                                 foffset = foffset+pvalues[0].vlength;
11289                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11290                                 pvalues[1].vtype = VTYPE_UINT32;
11291                                 pvalues[1].vdesc = "Flags: 0x%08x";
11292                                 pvalues[1].vlength = 4;
11293                                 pvalues[1].hfname = hf_nds_req_flags;
11294                                 pvalues[1].voffset = foffset;
11295                                 foffset = foffset+pvalues[1].vlength;
11296                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11297                                 pvalues[2].vtype = VTYPE_UINT32;
11298                                 pvalues[2].vdesc = "Destination Parent Entry ID: 0x%08x";
11299                                 pvalues[2].vlength = 4;
11300                                 resolve_eid = TRUE;
11301                                 global_eid = pvalues[2].vvalue;
11302                                 pvalues[2].voffset = foffset;
11303                                 pvalues[2].hfname= hf_nds_eid;
11304                                 foffset = foffset+pvalues[2].vlength;
11305                                 resolve_eid = TRUE;
11306                                 global_eid = pvalues[2].vvalue;
11307                                 pvalues[3].vtype = VTYPE_STRING;
11308                                 pvalues[3].vdesc = "New RDN: %s";
11309                                 pvalues[3].mvtype = 0;
11310                                 pvalues[3].vvalue = 0;
11311                                 pvalues[3].vlength = 256;
11312                                 pvalues[3].vlength = tvb_get_letohl(tvb, foffset);
11313                                 pvalues[3].voffset = foffset+4;
11314                                 foffset = foffset + 4;
11315                                 get_string(tvb, pvalues[3].voffset, pvalues[3].vlength, pvalues[3].vstring);
11316                                 pvalues[3].hfname= hf_nds_new_rdn;
11317                                 foffset = foffset+pvalues[3].vlength;
11318                                 foffset += align_4(tvb, foffset);
11319                                 pvalues[4].vtype = VTYPE_STRING;
11320                                 pvalues[4].vdesc = "Source Server Name: %s";
11321                                 pvalues[4].mvtype = 0;
11322                                 pvalues[4].vvalue = 0;
11323                                 pvalues[4].vlength = 256;
11324                                 pvalues[4].vlength = tvb_get_letohl(tvb, foffset);
11325                                 if (pvalues[4].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
11326                                 {
11327                                         pvalues[4].vtype = VTYPE_NONE;
11328                                         break;
11329                                 }
11330                                 pvalues[4].voffset = foffset+4;
11331                                 foffset = foffset + 4;
11332                                 get_string(tvb, pvalues[4].voffset, pvalues[4].vlength, pvalues[4].vstring);
11333                                 pvalues[4].hfname= hf_nds_target_name;
11334                                 break;
11335                         case 0x2b:
11336                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11337                                 pvalues[0].vtype = VTYPE_UINT32;
11338                                 pvalues[0].vdesc = "Version: %u";
11339                                 pvalues[0].vlength = 4;
11340                                 pvalues[0].hfname = hf_nds_ver;
11341                                 pvalues[0].voffset = foffset;
11342                                 foffset = foffset+pvalues[0].vlength;
11343                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11344                                 pvalues[1].vtype = VTYPE_UINT32;
11345                                 pvalues[1].vdesc = (char *)match_strval(pvalues[1].vvalue, nds_verb2b_flag_vals);
11346                                 if(pvalues[1].vdesc == NULL)
11347                                 {
11348                                         pvalues[1].vdesc = "No Flag Definition Found";
11349                                 }
11350                                 pvalues[1].vlength = 4;
11351                                 pvalues[1].hfname = hf_nds_verb2b_req_flags;
11352                                 pvalues[1].voffset = foffset;
11353                                 foffset = foffset+pvalues[1].vlength;
11354                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11355                                 pvalues[2].vtype = VTYPE_UINT32;
11356                                 pvalues[2].vdesc = "Source Entry ID: 0x%08x";
11357                                 pvalues[2].vlength = 4;
11358                                 resolve_eid = TRUE;
11359                                 global_eid = pvalues[2].vvalue;
11360                                 pvalues[2].voffset = foffset;
11361                                 pvalues[2].hfname= hf_nds_eid;
11362                                 foffset = foffset+pvalues[2].vlength;
11363                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
11364                                 pvalues[3].vtype = VTYPE_UINT32;
11365                                 pvalues[3].vdesc = "Destination Parent Entry ID: 0x%08x";
11366                                 pvalues[3].vlength = 4;
11367                                 pvalues[3].voffset = foffset;
11368                                 pvalues[3].hfname= hf_nds_eid;
11369                                 foffset = foffset+pvalues[3].vlength;
11370                                 pvalues[4].vtype = VTYPE_STRING;
11371                                 pvalues[4].vdesc = "New RDN: %s";
11372                                 pvalues[4].mvtype = 0;
11373                                 pvalues[4].vvalue = 0;
11374                                 pvalues[4].vlength = 256;
11375                                 pvalues[4].vlength = tvb_get_letohl(tvb, foffset);
11376                                 pvalues[4].voffset = foffset+4;
11377                                 foffset = foffset + 4;
11378                                 get_string(tvb, pvalues[4].voffset, pvalues[4].vlength, pvalues[4].vstring);
11379                                 pvalues[4].hfname= hf_nds_new_rdn;
11380                                 foffset = foffset+pvalues[4].vlength;
11381                                 foffset += align_4(tvb, foffset);
11382                                 pvalues[5].vtype = VTYPE_STRING;
11383                                 pvalues[5].vdesc = "Source Server Name: %s";
11384                                 pvalues[5].mvtype = 0;
11385                                 pvalues[5].vvalue = 0;
11386                                 pvalues[5].vlength = 256;
11387                                 pvalues[5].vlength = tvb_get_letohl(tvb, foffset);
11388                                 if (pvalues[5].vlength == 0x00 || !tvb_bytes_exist(tvb, foffset, pvalues[3].vlength))
11389                                 {
11390                                         pvalues[5].vtype = VTYPE_NONE;
11391                                         break;
11392                                 }
11393                                 pvalues[5].voffset = foffset+4;
11394                                 foffset = foffset + 4;
11395                                 get_string(tvb, pvalues[5].voffset, pvalues[5].vlength, pvalues[5].vstring);
11396                                 pvalues[5].hfname= hf_nds_target_name;
11397                                 break;
11398                         case 0x2c:
11399                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11400                                 break;
11401                         case 0x2d:
11402                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11403                                 break;
11404                         case 0x2e:
11405                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11406                                 break;
11407                         case 0x2f:
11408                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11409                                 break;
11410                         case 0x30:
11411                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11412                                 break;
11413                         case 0x31:
11414                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11415                                 break;
11416                         case 0x32:
11417                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11418                                 pvalues[0].vtype = VTYPE_UINT32;
11419                                 pvalues[0].vdesc = "Version: %u";
11420                                 pvalues[0].vlength = 4;
11421                                 pvalues[0].hfname = hf_nds_ver;
11422                                 pvalues[0].voffset = foffset;
11423                                 foffset = foffset+pvalues[0].vlength;
11424                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11425                                 pvalues[2].vtype = VTYPE_UINT32;
11426                                 pvalues[2].vdesc = "Iteration Handle: 0x%08x";
11427                                 pvalues[2].vlength = 4;
11428                                 pvalues[2].voffset = foffset;
11429                                 pvalues[2].hfname= hf_nds_iteration;
11430                                 foffset = foffset+pvalues[2].vlength;
11431                                 pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
11432                                 pvalues[3].vtype = VTYPE_STRING;
11433                                 pvalues[3].vdesc = "NDS Verb: %s";
11434                                 pvalues[3].vstring = (char *)match_strval(pvalues[3].vvalue, ncp_nds_verb_vals);
11435                                 pvalues[3].vlength = 4;
11436                                 pvalues[3].voffset = foffset;
11437                                 pvalues[3].hfname= hf_mv_string;
11438                                 foffset = foffset+pvalues[3].vlength;
11439                                 break;
11440                         case 0x33:
11441                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11442                                 break;
11443                         case 0x34:
11444                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11445                                 break;
11446                         case 0x35:
11447                                 if (nds_version != 0)
11448                                 {
11449                                     pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11450                                     pvalues[0].vtype = VTYPE_UINT32;
11451                                     pvalues[0].vdesc = "Version: %u";
11452                                     pvalues[0].vlength = 4;
11453                                     pvalues[0].hfname = hf_nds_ver;
11454                                     pvalues[0].voffset = foffset;
11455                                     foffset = foffset+pvalues[0].vlength;
11456                                     pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11457                                     global_flags = pvalues[1].vvalue;
11458                                     pvalues[1].vtype = VTYPE_BITFIELD;
11459                                     pvalues[1].vdesc = "Request Flags:";
11460                                     pvalues[1].vlength = 2;
11461                                     pvalues[1].hfname= hf_nds_rflags;
11462                                     pvalues[1].voffset = foffset;
11463                                     pvalues[1].bit1 = "Typeless";
11464                                     pvalues[1].bit1hfname = hf_bit1rflags;
11465                                     pvalues[1].bit2 = "Slashed";
11466                                     pvalues[1].bit2hfname = hf_bit2rflags;
11467                                     pvalues[1].bit3 = "Dotted";
11468                                     pvalues[1].bit3hfname = hf_bit3rflags;
11469                                     pvalues[1].bit4 = "Tuned";
11470                                     pvalues[1].bit4hfname = hf_bit4rflags;
11471                                     pvalues[1].bit5 = "Not Defined";
11472                                     pvalues[1].bit5hfname = hf_bit5rflags;
11473                                     pvalues[1].bit6 = "Not Defined";
11474                                     pvalues[1].bit6hfname = hf_bit6rflags;
11475                                     pvalues[1].bit7 = "Not Defined";
11476                                     pvalues[1].bit7hfname = hf_bit7rflags;
11477                                     pvalues[1].bit8 = "Not Defined";
11478                                     pvalues[1].bit8hfname = hf_bit8rflags;
11479                                     pvalues[1].bit9 = "Not Defined";
11480                                     pvalues[1].bit9hfname = hf_bit9rflags;
11481                                     pvalues[1].bit10 = "Not Defined";
11482                                     pvalues[1].bit10hfname = hf_bit10rflags;
11483                                     pvalues[1].bit11 = "Not Defined";
11484                                     pvalues[1].bit11hfname = hf_bit11rflags;
11485                                     pvalues[1].bit12 = "Not Defined";
11486                                     pvalues[1].bit12hfname = hf_bit12rflags;
11487                                     pvalues[1].bit13 = "Not Defined";
11488                                     pvalues[1].bit13hfname = hf_bit13rflags;
11489                                     pvalues[1].bit14 = "Not Defined";
11490                                     pvalues[1].bit14hfname = hf_bit14rflags;
11491                                     pvalues[1].bit15 = "Not Defined";
11492                                     pvalues[1].bit15hfname = hf_bit15rflags;
11493                                     pvalues[1].bit16 = "Not Defined";
11494                                     pvalues[1].bit16hfname = hf_bit16rflags;
11495                                 }
11496                                 break;
11497                         case 0x36:
11498                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11499                                 break;
11500                         case 0x37:
11501                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11502                                 break;
11503                         case 0x38:
11504                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11505                                 break;
11506                         case 0x39:
11507                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11508                                 pvalues[0].vtype = VTYPE_UINT32;
11509                                 pvalues[0].vdesc = "Version: %u";
11510                                 pvalues[0].vlength = 4;
11511                                 pvalues[0].voffset = foffset;
11512                                 pvalues[0].hfname= hf_nds_ver;
11513                                 foffset = foffset+pvalues[0].vlength;
11514                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11515                                 pvalues[1].vtype = VTYPE_UINT32;
11516                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
11517                                 pvalues[1].vlength = 4;
11518                                 resolve_eid = TRUE;
11519                                 global_eid = pvalues[1].vvalue;
11520                                 pvalues[1].voffset = foffset;
11521                                 pvalues[1].hfname= hf_nds_eid;
11522                                 foffset = foffset+pvalues[1].vlength;
11523                                 break;
11524                         case 0x3a:
11525                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11526                                 pvalues[0].vtype = VTYPE_UINT32;
11527                                 pvalues[0].vdesc = "Reply Buffer Size: %u";
11528                                 pvalues[0].vlength = 4;
11529                                 pvalues[0].voffset = foffset;
11530                                 pvalues[0].hfname= hf_nds_buffer_size;
11531                                 foffset = foffset+pvalues[0].vlength;
11532                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11533                                 pvalues[1].vtype = VTYPE_UINT32;
11534                                 pvalues[1].vdesc = "Version: %u";
11535                                 pvalues[1].vlength = 4;
11536                                 pvalues[1].voffset = foffset;
11537                                 pvalues[1].hfname= hf_nds_ver;
11538                                 foffset = foffset+pvalues[1].vlength;
11539                                 pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11540                                 pvalues[2].vtype = VTYPE_UINT32;
11541                                 pvalues[2].vdesc = "Entry ID: 0x%08x";
11542                                 pvalues[2].vlength = 4;
11543                                 resolve_eid = TRUE;
11544                                 global_eid = pvalues[2].vvalue;
11545                                 pvalues[2].voffset = foffset;
11546                                 pvalues[2].hfname= hf_nds_eid;
11547                                 foffset = foffset+pvalues[2].vlength;
11548                                 break;
11549                         case 0x3b:
11550                                 pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11551                                 pvalues[0].vtype = VTYPE_UINT32;
11552                                 pvalues[0].vdesc = "Version: %u";
11553                                 pvalues[0].vlength = 4;
11554                                 pvalues[0].voffset = foffset;
11555                                 pvalues[0].hfname= hf_nds_ver;
11556                                 foffset = foffset+pvalues[0].vlength;
11557                                 pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11558                                 pvalues[1].vtype = VTYPE_UINT32;
11559                                 pvalues[1].vdesc = "Entry ID: 0x%08x";
11560                                 pvalues[1].vlength = 4;
11561                                 resolve_eid = TRUE;
11562                                 global_eid = pvalues[1].vvalue;
11563                                 pvalues[1].voffset = foffset;
11564                                 pvalues[1].hfname= hf_nds_eid;
11565                                 foffset = foffset+pvalues[1].vlength;
11566                                 break;
11567                         case 0x3c:
11568                                 break;
11569                         case 0x3d:
11570                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11571                                 break;
11572                         case 0x3e:
11573                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11574                                 break;
11575                         case 0x3f:
11576                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11577                                 break;
11578                         case 0x40:
11579                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11580                                 break;
11581                         case 0x41:
11582                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11583                                 break;
11584                         case 0x42:
11585                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11586                                 break;
11587                         case 0x43:
11588                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11589                                 break;
11590                         case 0x44:
11591                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11592                                 break;
11593                         case 0x45:
11594                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11595                                 break;
11596                         case 0x46:
11597                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11598                                 break;
11599                         case 0x47:
11600                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11601                                 break;
11602                         case 0x48:
11603                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11604                                 break;
11605                         case 0x49:
11606                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11607                                 break;
11608                         case 0x4a:
11609                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11610                                 break;
11611                         case 0x4b:
11612                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11613                                 break;
11614                         case 0x4c:
11615                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11616                                 break;
11617                         case 0x4d:
11618                                 pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11619                                 break;
11620                         case 0x6e:
11621                             pvalues[0].vvalue = tvb_get_letohl(tvb, foffset);
11622                             pvalues[0].vtype = VTYPE_UINT32;
11623                             pvalues[0].vdesc = "Version: %u";
11624                             pvalues[0].vlength = 4;
11625                             pvalues[0].hfname = hf_nds_ver;
11626                             pvalues[0].voffset = foffset;
11627                             foffset = foffset+pvalues[0].vlength;
11628                             pvalues[1].vvalue = tvb_get_letohl(tvb, foffset);
11629                             global_flags = pvalues[1].vvalue;
11630                             pvalues[1].vtype = VTYPE_BITFIELD;
11631                             pvalues[1].vdesc = "Request Flags:";
11632                             pvalues[1].vlength = 2;
11633                             pvalues[1].hfname= hf_nds_rflags;
11634                             pvalues[1].voffset = foffset;
11635                             pvalues[1].bit1 = "Typeless";
11636                             pvalues[1].bit1hfname = hf_bit1rflags;
11637                             pvalues[1].bit2 = "Slashed";
11638                             pvalues[1].bit2hfname = hf_bit2rflags;
11639                             pvalues[1].bit3 = "Dotted";
11640                             pvalues[1].bit3hfname = hf_bit3rflags;
11641                             pvalues[1].bit4 = "Tuned";
11642                             pvalues[1].bit4hfname = hf_bit4rflags;
11643                             pvalues[1].bit5 = "Not Defined";
11644                             pvalues[1].bit5hfname = hf_bit5rflags;
11645                             pvalues[1].bit6 = "Not Defined";
11646                             pvalues[1].bit6hfname = hf_bit6rflags;
11647                             pvalues[1].bit7 = "Not Defined";
11648                             pvalues[1].bit7hfname = hf_bit7rflags;
11649                             pvalues[1].bit8 = "Not Defined";
11650                             pvalues[1].bit8hfname = hf_bit8rflags;
11651                             pvalues[1].bit9 = "Not Defined";
11652                             pvalues[1].bit9hfname = hf_bit9rflags;
11653                             pvalues[1].bit10 = "Not Defined";
11654                             pvalues[1].bit10hfname = hf_bit10rflags;
11655                             pvalues[1].bit11 = "Not Defined";
11656                             pvalues[1].bit11hfname = hf_bit11rflags;
11657                             pvalues[1].bit12 = "Not Defined";
11658                             pvalues[1].bit12hfname = hf_bit12rflags;
11659                             pvalues[1].bit13 = "Not Defined";
11660                             pvalues[1].bit13hfname = hf_bit13rflags;
11661                             pvalues[1].bit14 = "Not Defined";
11662                             pvalues[1].bit14hfname = hf_bit14rflags;
11663                             pvalues[1].bit15 = "Not Defined";
11664                             pvalues[1].bit15hfname = hf_bit15rflags;
11665                             pvalues[1].bit16 = "Not Defined";
11666                             pvalues[1].bit16hfname = hf_bit16rflags;
11667                             foffset = foffset+pvalues[1].vlength+2;
11668                             pvalues[2].vvalue = tvb_get_letohl(tvb, foffset);
11669                             pvalues[2].vtype = VTYPE_UINT32;
11670                             pvalues[2].vdesc = "Iteration Handle: 0x%08x";
11671                             pvalues[2].vlength = 4;
11672                             pvalues[2].voffset = foffset;
11673                             pvalues[2].hfname= hf_nds_iteration;
11674                             foffset = foffset+pvalues[2].vlength;
11675                             pvalues[3].vvalue = tvb_get_letohl(tvb, foffset);
11676                             pvalues[3].vtype = VTYPE_UINT32;
11677                             pvalues[3].vdesc = "Base Entry ID: 0x%08x";
11678                             pvalues[3].vlength = 4;
11679                             resolve_eid = TRUE;
11680                             global_eid = pvalues[3].vvalue;
11681                             pvalues[3].voffset = foffset;
11682                             pvalues[3].hfname= hf_nds_eid;
11683                             foffset = foffset+pvalues[3].vlength;
11684                             pvalues[4].vvalue = tvb_get_letohl(tvb, foffset);
11685                             pvalues[4].vtype = VTYPE_UINT32;
11686                             pvalues[4].vdesc = (char *)match_strval(pvalues[4].vvalue, nds_scope_vals);
11687                             if(pvalues[4].vdesc == NULL)
11688                             {
11689                                     pvalues[4].vdesc = "Unknown Scope Defined";
11690                             }
11691                             pvalues[4].vlength = 4;
11692                             pvalues[4].hfname = hf_nds_scope;
11693                             pvalues[4].voffset = foffset;
11694                             foffset = foffset+pvalues[4].vlength;
11695                             pvalues[5].vvalue = tvb_get_letohl(tvb, foffset);
11696                             pvalues[5].vtype = VTYPE_MULTIVALUE_UINT32;
11697                             pvalues[5].vdesc = "Iterator: 0x%08x";
11698                             pvalues[5].vlength = 4;
11699                             pvalues[5].voffset = foffset;
11700                             pvalues[5].hfname= hf_nds_iterator;
11701                             pvalues[5].mvtype = MVTYPE_PROCESS_ITERATOR;
11702                             foffset = foffset+pvalues[5].vlength;
11703                             break;
11704                         default:
11705                             pvalues[0].vtype = VTYPE_NONE; /* Not Defined */
11706                             break;
11707                 }
11708         }
11709         /* Fill in the INFO column. */
11710         if (check_col(pinfo->cinfo, COL_INFO)) {
11711                 if (ncp_rec) {
11712                         col_set_str(pinfo->cinfo, COL_PROTOCOL, "NDS");
11713                         if (nds_frag != 0xffffffff) {
11714                                 col_add_fstr(pinfo->cinfo, COL_INFO, "C Continue NDS Fragment %08x", nds_frag);
11715                         }
11716                         else {
11717                                 col_add_fstr(pinfo->cinfo, COL_INFO, "C NDS %s", verb_string);
11718                         }
11719                         run_info_str = TRUE;
11720                 }
11721                 else {
11722                         col_add_fstr(pinfo->cinfo, COL_INFO,
11723                                 "C Unknown Function %d (0x%02x)",
11724                                 func, func);
11725                 }
11726
11727         }
11728         /* Keep track of the address and connection whence the request
11729            came, and the address and connection to which the request
11730            is being sent, so that we can match up calls with replies.
11731            (We don't include the sequence number, as we may want
11732            to have all packets over the same connection treated
11733            as being part of a single conversation so that we can
11734            let the user select that conversation to be displayed.) */
11735
11736         conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
11737                     PT_NCP, nw_connection, nw_connection, 0);
11738         if (conversation == NULL) {
11739                 /* It's not part of any conversation - create a new one. */
11740                 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
11741                     PT_NCP, nw_connection, nw_connection, 0);
11742         }
11743
11744         if (!pinfo->fd->flags.visited) {
11745                 request_value = ncp_hash_insert(conversation, sequence, ncp_rec);
11746                 request_value->req_frame_num = pinfo->fd->num;
11747                 request_value->req_frame_time=pinfo->fd->abs_ts;
11748
11749                 /* If this is the first time we're examining the packet,
11750                  * check to see if this NCP type uses a "request condition".
11751                  * If so, we have to build a proto_tree because request conditions
11752                  * use display filters to work, and without a proto_tree,
11753                  * display filters can't possibly work. If we already have
11754                  * a proto_tree, then wonderful. If we don't, we need to build
11755                  * one. */
11756                 if (ncp_rec && !ncp_tree) {
11757                         run_req_cond = TRUE;
11758                 }
11759                 /* Keep track of the Fragment number in the request for defrag logic */
11760                 request_value->nds_frag_num = nds_frag;
11761         }
11762
11763         /* If we have to handle a request condition, or have to
11764            add to the Info column, we need to construct a protocol
11765            tree.  If we already have a proto_tree, then wonderful.
11766            If we don't, we need to build one. */
11767         if ((run_info_str || run_req_cond) && !ncp_tree) {
11768                 proto_item *ti;
11769
11770                 temp_tree = proto_tree_create_root();
11771                 proto_tree_set_visible(temp_tree, FALSE);
11772                 ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
11773                 ncp_tree = proto_item_add_subtree(ti, ett_ncp);
11774         }
11775
11776         if (ncp_tree) {
11777                 /* If the dissection throws an exception, be sure to free
11778                  * the temporary proto_tree that was created. Because of the
11779                  * way the CLEANUP_PUSH macro works, we can't put it in an 'if'
11780                  * block; it has to be in the same scope as the terminating
11781                  * CLEANUP_POP or CLEANUP_POP_AND_ALLOC. So, we always
11782                  * call CLEANUP_POP and friends, but the value of temp_tree is
11783                  * NULL if no cleanup is needed, and non-null if cleanup is needed.
11784                  */
11785                 CLEANUP_PUSH(free_proto_tree, temp_tree);
11786
11787 #ifdef FAKE_TREE_IS_VISIBLE
11788                 PTREE_DATA(ncp_tree)->visible=1;
11789 #endif
11790
11791                 request_value = ncp_hash_lookup(conversation, sequence);
11792                 switch (type) {
11793                         case NCP_BROADCAST_SLOT:
11794                                 ; /* nothing */
11795                                 break;
11796
11797                         case NCP_SERVICE_REQUEST:
11798
11799                                 ptvc = ptvcursor_new(ncp_tree, tvb, 7);
11800                                 if (ncp_rec && ncp_rec->request_ptvc)
11801                                 {
11802                                         clear_repeat_vars();
11803                                         process_ptvc_record(ptvc, ncp_rec->request_ptvc, NULL, TRUE, ncp_rec);
11804                                 }
11805                                 proto_tree_add_uint_format(ncp_tree, hf_ncp_func, tvb, 6, 1,
11806                                         func, "Function: %d (0x%02X), %s",
11807                                         func, func, ncp_rec ? ncp_rec->name : "Unknown");
11808
11809                                 proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 7, 1,
11810                                         subfunc, "SubFunction: %d (0x%02x)",
11811                                         subfunc, subfunc);
11812
11813                                 proto_tree_add_uint(ncp_tree, hf_ncp_fragment_handle, tvb, 8, 4,
11814                                         nds_frag);
11815
11816                                 if (nds_frag == 0xffffffff) {
11817
11818                                         proto_tree_add_item(ncp_tree, hf_ncp_fragment_size, tvb, 12, 4, TRUE);
11819
11820                                         proto_tree_add_item(ncp_tree, hf_ncp_message_size, tvb, 16, 4, TRUE);
11821
11822                         nds_prot_flags = tvb_get_letohs(tvb, 22);
11823                         prot_flags[0].vvalue = nds_prot_flags;
11824                         prot_flags[0].vtype = VTYPE_BITFIELD;
11825                         prot_flags[0].vdesc = "NDS Protocol Flags:";
11826                         prot_flags[0].vlength = 2;
11827                         prot_flags[0].hfname= hf_ncp_nds_flag;
11828                         prot_flags[0].voffset = 22;
11829                         prot_flags[0].bit1 = "Not Defined";
11830                         prot_flags[0].bit1hfname = hf_ndsprot1flag;
11831                         prot_flags[0].bit2 = "Not Defined";
11832                         prot_flags[0].bit2hfname = hf_ndsprot2flag;
11833                         prot_flags[0].bit3 = "Not Defined";
11834                         prot_flags[0].bit3hfname = hf_ndsprot3flag;
11835                         prot_flags[0].bit4 = "Not Defined";
11836                         prot_flags[0].bit4hfname = hf_ndsprot4flag;
11837                         prot_flags[0].bit5 = "Not Defined";
11838                         prot_flags[0].bit5hfname = hf_ndsprot5flag;
11839                         prot_flags[0].bit6 = "Not Defined";
11840                         prot_flags[0].bit6hfname = hf_ndsprot6flag;
11841                         prot_flags[0].bit7 = "Not Defined";
11842                         prot_flags[0].bit7hfname = hf_ndsprot7flag;
11843                         prot_flags[0].bit8 = "Not Defined";
11844                         prot_flags[0].bit8hfname = hf_ndsprot8flag;
11845                         prot_flags[0].bit9 = "Not Defined";
11846                         prot_flags[0].bit9hfname = hf_ndsprot9flag;
11847                         prot_flags[0].bit10 = "Not Defined";
11848                         prot_flags[0].bit10hfname = hf_ndsprot10flag;
11849                         prot_flags[0].bit11= "Not Defined";
11850                         prot_flags[0].bit11hfname = hf_ndsprot11flag;
11851                         prot_flags[0].bit12 = "Not Defined";
11852                         prot_flags[0].bit12hfname = hf_ndsprot12flag;
11853                         prot_flags[0].bit13 = "Not Defined";
11854                         prot_flags[0].bit13hfname = hf_ndsprot13flag;
11855                         prot_flags[0].bit14 = "Not Defined";
11856                         prot_flags[0].bit14hfname = hf_ndsprot14flag;
11857                         prot_flags[0].bit15 = "Include CRC in NDS Header";
11858                         prot_flags[0].bit15hfname = hf_ndsprot15flag;
11859                         prot_flags[0].bit16 = "Client is a Server";
11860                         prot_flags[0].bit16hfname = hf_ndsprot16flag;
11861
11862                         process_bitfield(ncp_tree, tvb, &prot_flags[0]);
11863
11864                         if (nds_version == 0) {
11865                             proto_tree_add_uint_format(ncp_tree, hf_ncp_nds_verb, tvb, 24, 4,
11866                                     nds_verb, "NDS Verb: %d, (0x%02x), %s",
11867                                     nds_verb, nds_verb, verb_string);
11868                         }
11869                         else {
11870                             proto_tree_add_uint_format(ncp_tree, hf_ncp_nds_verb, tvb, 32, 4,
11871                                     nds_verb, "NDS Verb: %d, (0x%02x), %s",
11872                                     nds_verb, nds_verb, verb_string);
11873                         }
11874                         added_arrow = FALSE;
11875                                         for (i = 0; i < 9; i++) {
11876                                                 switch (pvalues[i].vtype) {
11877
11878                                                 case VTYPE_NONE: /* no value */
11879                                                         break;
11880
11881                                                 case VTYPE_UINT8:
11882                                                         proto_tree_add_uint_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
11883                                                             pvalues[i].vlength, pvalues[i].vtype, "NDS Parameter not defined %d",
11884                                                             pvalues[i].vtype);
11885                                                         break;
11886
11887                                                 case VTYPE_UINT16:
11888                                                         proto_tree_add_uint_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
11889                                                             pvalues[i].vlength, pvalues[i].vtype, "NDS Parameter not defined %d",
11890                                                             pvalues[i].vtype);
11891                                                         break;
11892
11893                                                 case VTYPE_UINT32:
11894                                                         proto_tree_add_uint_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
11895                                                             pvalues[i].vlength, pvalues[i].vvalue, pvalues[i].vdesc,
11896                                                             pvalues[i].vvalue);
11897                                                         break;
11898
11899                                                 case VTYPE_STRING:
11900                                                         proto_tree_add_string_format(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
11901                                                             pvalues[i].vlength, pvalues[i].vstring, pvalues[i].vdesc, pvalues[i].vstring);
11902                                                         if (pvalues[i].mvtype == MVTYPE_ATTR_REQUEST) {
11903                                                                 /*
11904                                                                  * The "vstring" value is set to the input ES type
11905                                                                  * for MVTYPE_PROC_ENTRY_SPECIFIERS,
11906                                                                  * to add string to columninfo
11907                                                                  */
11908                                                                 if (check_col(pinfo->cinfo, COL_INFO)) {
11909                                                                         if (!added_arrow) {
11910                                                                                 col_append_str(pinfo->cinfo, COL_INFO, " -> ");
11911                                                                                 added_arrow = TRUE;
11912                                                                         }
11913                                                                         col_append_str(pinfo->cinfo, COL_INFO, pvalues[i].vstring);
11914                                                                 }
11915                                                         }
11916                                                         break;
11917
11918                                                 case VTYPE_BITFIELD:
11919                                                         process_bitfield(ncp_tree, tvb, &pvalues[i]);
11920                                                         break;
11921
11922                                                 case VTYPE_MULTIVALUE_UINT32:
11923                                                         process_multivalues(ncp_tree, tvb, pinfo, &pvalues[i]);
11924                                                         if (pvalues[i].mvtype == MVTYPE_PROC_ENTRY_SPECIFIERS) {
11925                                                                 /*
11926                                                                  * The "vstring" value is set to the input ES type
11927                                                                  * by "process_multivalues()".
11928                                                                  */
11929                                                                 g_strlcpy(global_object_name, mv_resolve_name_string, 256);
11930                                                         }
11931                                                         if (pvalues[i].mvtype == MVTYPE_ATTR_REQUEST || pvalues[i].mvtype == MVTYPE_PROC_ENTRY_SPECIFIERS || pvalues[i].mvtype == MVTYPE_PROCESS_ITERATOR) {
11932                                                                 /*
11933                                                                  * The "vstring" value is set to the input ES type
11934                                                                  * for MVTYPE_PROC_ENTRY_SPECIFIERS,
11935                                                                  * and the last string for MVTYPE_ATTR_REQUEST,
11936                                                                  * by "process_multivalues()".
11937                                                                  */
11938                                                                 if (check_col(pinfo->cinfo, COL_INFO)) {
11939                                                                         col_append_str(pinfo->cinfo, COL_INFO, pvalues[i].vstring);
11940                                     if (pvalues[i].mvtype != MVTYPE_PROCESS_ITERATOR) {
11941                                         if (!added_arrow) {
11942                                             col_append_str(pinfo->cinfo, COL_INFO, " -> ");
11943                                             added_arrow = TRUE;
11944                                         }
11945                                         col_append_str(pinfo->cinfo, COL_INFO, mv_resolve_name_string);
11946                                     }
11947                                                                 }
11948                                                         }
11949                                                         break;
11950
11951                                                 case VTYPE_BYTES:
11952                                                         proto_tree_add_bytes(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset,
11953                                                             pvalues[i].vlength, tvb_get_ptr(tvb, pvalues[i].voffset, pvalues[i].vvalue));
11954                                                         break;
11955
11956                                                 case VTYPE_BOOLEAN:
11957                                                         proto_tree_add_item(ncp_tree, pvalues[i].hfname, tvb, pvalues[i].voffset, pvalues[i].vlength, TRUE);
11958                                                         break;
11959
11960                                                 default:
11961                                                         proto_tree_add_uint_format(ncp_tree, hf_nds_p1type, tvb, pvalues[i].voffset,
11962                                                             pvalues[i].vlength, pvalues[i].vtype, "NDS Parameter not defined %u",
11963                                                             pvalues[i].vtype);
11964                                                         break;
11965                                                 }
11966                                                 /* For NDS requests with just an EID, resolve name from hash table. */
11967                                         }
11968                                         request_eid_value = ncp_eid_hash_lookup(conversation, global_eid);
11969                                         if(resolve_eid) {
11970                                                 if (request_eid_value) {
11971                                                         g_strlcpy(global_object_name, request_eid_value->object_name, 256);
11972                                                         if (check_col(pinfo->cinfo, COL_INFO))
11973                                                         {
11974                                                                 col_append_str(pinfo->cinfo, COL_INFO, ", Object Name - ");
11975                                                                 col_append_str(pinfo->cinfo, COL_INFO, global_object_name);
11976                                                         }
11977                                                 }
11978                                         }
11979                                         if (request_value)
11980                                         {
11981                                                 request_value->nds_request_verb = nds_verb;
11982                                                 request_value->nds_version = nds_version;
11983                                                 g_strlcpy(request_value->object_name, global_object_name, 256);
11984                                                 request_value->req_nds_flags = global_flags;
11985                                                 request_value->req_nds_prot_flags = nds_prot_flags;
11986                                         }
11987                                 }
11988                                 break;
11989
11990                         default:
11991                                 ; /* nothing */
11992                                 break;
11993                 }
11994                 ptvcursor_free(ptvc);
11995
11996                 /* Free the temporary proto_tree */
11997                 CLEANUP_CALL_AND_POP;
11998         }
11999 }
12000
12001 /*
12002  * XXX - this duplicates stuff in "dissect_ncp_request()"; could
12003  * "dissect_ncp_request()" not just call "dissect_ping_req()" if
12004  * the operation is an NCP ping, and "dissect_ping_req()" just dissect
12005  * ping portion?
12006  */
12007 void
12008 dissect_ping_req(tvbuff_t *tvb, packet_info *pinfo,
12009                 guint32 nw_connection, guint8 sequence,
12010                 guint16 type, proto_tree *ncp_tree)
12011 {
12012         guint8                  func, subfunc = 0;
12013         ncp_req_hash_value      *request_value = NULL;
12014         const ncp_record        *ncp_rec = NULL;
12015         conversation_t          *conversation;
12016         ptvcursor_t             *ptvc = NULL;
12017         proto_tree              *temp_tree = NULL;
12018         gint                    length_remaining = 0;
12019         guint32                 nds_flags;
12020         guint32                 ping_version;
12021         nds_val                 pvalue;
12022         char                    string_buffer[1024];
12023
12024 #ifdef FAKE_TREE_IS_VISIBLE
12025     if (ncp_tree) {
12026         PTREE_DATA(ncp_tree)->visible=1;
12027     }
12028 #endif
12029
12030         pvalue.vvalue = 0;
12031         pvalue.vlength = 0;
12032         pvalue.voffset = 0;
12033         pvalue.hfname = 0;
12034         pvalue.vdesc = "";
12035         string_buffer[0] = '\0';
12036         pvalue.vstring = string_buffer;
12037         pvalue.mvtype = 0;
12038
12039         func = tvb_get_guint8(tvb, 6);
12040         subfunc = tvb_get_guint8(tvb, 7);
12041
12042         ncp_rec = ncp_record_find(func, subfunc);
12043
12044         /* Fill in the INFO column. */
12045         if (check_col(pinfo->cinfo, COL_INFO))
12046         {
12047                 if (ncp_rec)
12048                 {
12049
12050                         col_set_str(pinfo->cinfo, COL_PROTOCOL, "NDS");
12051                         col_set_str(pinfo->cinfo, COL_INFO, "C Ping for NDS");
12052                 }
12053
12054         }
12055         if (!pinfo->fd->flags.visited)
12056         {
12057
12058                 /* This is the first time we've looked at this packet.
12059                 Keep track of the address and connection whence the request
12060                 came, and the address and connection to which the request
12061                 is being sent, so that we can match up calls with replies.
12062                 (We don't include the sequence number, as we may want
12063                 to have all packets over the same connection treated
12064                 as being part of a single conversation so that we can
12065                 let the user select that conversation to be displayed.) */
12066
12067                 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
12068                     PT_NCP, nw_connection, nw_connection, 0);
12069
12070                 if (conversation == NULL)
12071                 {
12072                         /* It's not part of any conversation - create a new one. */
12073                         conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
12074                             PT_NCP, nw_connection, nw_connection, 0);
12075                 }
12076
12077                 request_value = ncp_hash_insert(conversation, sequence, ncp_rec);
12078                 request_value->req_frame_num = pinfo->fd->num;
12079                     request_value->req_frame_time=pinfo->fd->abs_ts;
12080
12081                 /* If this is the first time we're examining the packet,
12082                  * check to see if this NCP type uses a "request condition".
12083                  * If so, we have to build a proto_tree because request conditions
12084                  * use display filters to work, and without a proto_tree,
12085                  * display filters can't possibly work. If we already have
12086                  * a proto_tree, then wonderful. If we don't, we need to build
12087                  * one. */
12088                 if (ncp_rec && !ncp_tree) {
12089                         proto_item *ti;
12090
12091                         temp_tree = proto_tree_create_root();
12092                         proto_tree_set_visible(temp_tree, FALSE);
12093                         ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
12094                         ncp_tree = proto_item_add_subtree(ti, ett_ncp);
12095                 }
12096         }
12097
12098         if (ncp_tree) {
12099                 /* If the dissection throws an exception, be sure to free
12100                  * the temporary proto_tree that was created. Because of the
12101                  * way the CLEANUP_PUSH macro works, we can't put it in an 'if'
12102                  * block; it has to be in the same scope as the terminating
12103                  * CLEANUP_POP or CLEANUP_POP_AND_ALLOC. So, we always
12104                  * call CLEANUP_POP and friends, but the value of temp_tree is
12105                  * NULL if no cleanup is needed, and non-null if cleanup is needed.
12106                  */
12107                 CLEANUP_PUSH(free_proto_tree, temp_tree);
12108
12109         switch (type) {
12110
12111                 case NCP_BROADCAST_SLOT:
12112                         ; /* nothing */
12113                         break;
12114
12115                 case NCP_SERVICE_REQUEST:
12116                         proto_tree_add_uint_format(ncp_tree, hf_ncp_func, tvb, 6, 1,
12117                                 func, "Function: %u (0x%02X), %s",
12118                                 func, func, ncp_rec ? ncp_rec->name : "Unknown");
12119
12120                         proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 7, 1,
12121                                 subfunc, "SubFunction: %u (0x%02x)",
12122                                 subfunc, subfunc);
12123
12124                         length_remaining = tvb_reported_length_remaining(tvb, 8);
12125
12126                         if (length_remaining >= 8) {
12127                                 ping_version = tvb_get_letohl(tvb, 8);
12128                                 proto_tree_add_uint(ncp_tree, hf_nds_ping_version, tvb, 8,
12129                                     4, ping_version);
12130                                 nds_flags = tvb_get_letohl(tvb, 12);
12131                                 if (request_value){
12132                     request_value->nds_request_verb = 0xf0;
12133                     request_value->req_nds_flags = nds_flags;
12134                 }
12135                     proto_tree_add_uint_hidden(ncp_tree, hf_ncp_nds_verb, tvb, 0, 0,
12136                         240);
12137
12138
12139                                 pvalue.vvalue = tvb_get_letohs(tvb, 12);
12140                                 pvalue.vtype = VTYPE_BITFIELD;
12141                                 pvalue.vstring = "";
12142                                 pvalue.vdesc = "Ping (low) Request Flags:";
12143                                 pvalue.vlength = 2;
12144                                 pvalue.hfname= hf_nds_rflags;
12145                                 pvalue.voffset = 12;
12146                                 pvalue.bit1 = "Supported Fields";   /* 0x0001 */
12147                                 pvalue.bit1hfname = hf_bit1pingflags1;
12148                                 pvalue.bit2 = "Depth";              /* 0x0002 */
12149                                 pvalue.bit2hfname = hf_bit2pingflags1;
12150                                 pvalue.bit3 = "Build Number";       /* 0x0004 */
12151                                 pvalue.bit3hfname = hf_bit3pingflags1;
12152                                 pvalue.bit4 = "Flags";              /* 0x0008 */
12153                                 pvalue.bit4hfname = hf_bit4pingflags1;
12154                                 pvalue.bit5 = "Verification Flags"; /* 0x0010 */
12155                                 pvalue.bit5hfname = hf_bit5pingflags1;
12156                                 pvalue.bit6 = "Letter Version";     /* 0x0020 */
12157                                 pvalue.bit6hfname = hf_bit6pingflags1;
12158                                 pvalue.bit7 = "OS Version";         /* 0x0040 */
12159                                 pvalue.bit7hfname = hf_bit7pingflags1;
12160                                 pvalue.bit8 = "Not Defined";        /* 0x0080 */
12161                                 pvalue.bit8hfname = hf_bit8pingflags1;
12162                                 pvalue.bit9 = "License Flags";      /* 0x0100 */
12163                                 pvalue.bit9hfname = hf_bit9pingflags1;
12164                                 pvalue.bit10 = "DS Time";           /* 0x0200 */
12165                                 pvalue.bit10hfname = hf_bit10pingflags1;
12166                                 pvalue.bit11 = "Server Time";       /* 0x0400 */
12167                                 pvalue.bit11hfname = hf_bit11pingflags1;
12168                                 pvalue.bit12 = "Create Time";       /* 0x0800 */
12169                                 pvalue.bit12hfname = hf_bit12pingflags1;
12170                                 pvalue.bit13 = "Not Defined";
12171                                 pvalue.bit13hfname = hf_bit13pingflags1;
12172                                 pvalue.bit14 = "Not Defined";
12173                                 pvalue.bit14hfname = hf_bit14pingflags1;
12174                                 pvalue.bit15 = "Not Defined";
12175                                 pvalue.bit15hfname = hf_bit15pingflags1;
12176                                 pvalue.bit16 = "Not Defined";
12177                                 pvalue.bit16hfname = hf_bit16pingflags1;
12178
12179                                 process_bitfield(ncp_tree, tvb, &pvalue);
12180
12181                                 pvalue.vvalue = tvb_get_letohs(tvb, 14);
12182                                 pvalue.vtype = VTYPE_BITFIELD;
12183                                 pvalue.vstring = "";
12184                                 pvalue.vdesc = "Ping (high) Request Flags:";
12185                                 pvalue.vlength = 2;
12186                                 pvalue.hfname= hf_nds_rflags;
12187                                 pvalue.voffset = 14;
12188                                 pvalue.bit1 = "Sap Name";           /* 0x0001 */
12189                                 pvalue.bit1hfname = hf_bit1pingflags2;
12190                                 pvalue.bit2 = "Tree Name";          /* 0x0002 */
12191                                 pvalue.bit2hfname = hf_bit2pingflags2;
12192                                 pvalue.bit3 = "OS Name";            /* 0x0004 */
12193                                 pvalue.bit3hfname = hf_bit3pingflags2;
12194                                 pvalue.bit4 = "Hardware Name";      /* 0x0008 */
12195                                 pvalue.bit4hfname = hf_bit4pingflags2;
12196                                 pvalue.bit5 = "Vendor Name";        /* 0x0010 */
12197                                 pvalue.bit5hfname = hf_bit5pingflags2;
12198                                 pvalue.bit6 = "Not Defined";
12199                                 pvalue.bit6hfname = hf_bit6pingflags2;
12200                                 pvalue.bit7 = "Not Defined";
12201                                 pvalue.bit7hfname = hf_bit7pingflags2;
12202                                 pvalue.bit8 = "Not Defined";
12203                                 pvalue.bit8hfname = hf_bit8pingflags2;
12204                                 pvalue.bit9 = "Not Defined";
12205                                 pvalue.bit9hfname = hf_bit9pingflags2;
12206                                 pvalue.bit10 = "Not Defined";
12207                                 pvalue.bit10hfname = hf_bit10pingflags2;
12208                                 pvalue.bit11 = "Not Defined";
12209                                 pvalue.bit11hfname = hf_bit11pingflags2;
12210                                 pvalue.bit12 = "Not Defined";
12211                                 pvalue.bit12hfname = hf_bit12pingflags2;
12212                                 pvalue.bit13 = "Not Defined";
12213                                 pvalue.bit13hfname = hf_bit13pingflags2;
12214                                 pvalue.bit14 = "Not Defined";
12215                                 pvalue.bit14hfname = hf_bit14pingflags2;
12216                                 pvalue.bit15 = "Not Defined";
12217                                 pvalue.bit15hfname = hf_bit15pingflags2;
12218                                 pvalue.bit16 = "Not Defined";
12219                                 pvalue.bit16hfname = hf_bit16pingflags2;
12220
12221                                 process_bitfield(ncp_tree, tvb, &pvalue);
12222                         }
12223                         break;
12224
12225                 default:
12226                         ; /* nothing */
12227                         break;
12228                 }
12229                 ptvc = ptvcursor_new(ncp_tree, tvb, 7);
12230                 if (ncp_rec && ncp_rec->request_ptvc) {
12231                         clear_repeat_vars();
12232                         process_ptvc_record(ptvc, ncp_rec->request_ptvc, NULL, TRUE, ncp_rec);
12233                 }
12234                 ptvcursor_free(ptvc);
12235
12236                 /* Free the temporary proto_tree */
12237                 CLEANUP_CALL_AND_POP;
12238         }
12239 }