Make last modifications work with gtk2.
[obnox/wireshark/wip.git] / packet-ndps.c
1 /* packet-ndps.c
2  * Routines for NetWare's NDPS
3  * Greg Morris <gmorris@novell.com>
4  *
5  * $Id: packet-ndps.c,v 1.10 2002/12/02 23:43:27 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <string.h>
31 #include <glib.h>
32 #include <epan/packet.h>
33 #include "prefs.h"
34 #include "packet-ipx.h"
35 #include "packet-tcp.h"
36 #include <epan/conversation.h>
37 #include "packet-ndps.h"
38
39 #define NDPS_PACKET_INIT_COUNT  200
40
41 static void dissect_ndps_request(tvbuff_t*, packet_info*, proto_tree*, guint32, guint32, guint32, int);
42
43 static void dissect_ndps_reply(tvbuff_t *, packet_info*, proto_tree*, guint32, int);
44
45 static int proto_ndps = -1;
46 static int hf_ndps_record_mark = -1;
47 static int hf_ndps_length = -1;
48 static int hf_ndps_xid = -1;
49 static int hf_ndps_packet_type = -1;
50 static int hf_ndps_rpc_version = -1;
51 static int hf_ndps_error = -1;
52 static int hf_ndps_items = -1;
53 static int hf_ndps_sbuffer = -1;
54 static int hf_ndps_rbuffer = -1;
55 static int hf_ndps_pa_name = -1;
56 static int hf_ndps_context = -1;
57 static int hf_ndps_tree = -1;
58 static int hf_ndps_error_val = -1;
59 static int hf_ndps_ext_error = -1;
60 static int hf_ndps_object = -1;
61 static int hf_ndps_cred_type = -1;
62 static int hf_ndps_server_name = -1;
63 static int hf_ndps_connection = -1;
64 static int hf_ndps_auth_null = -1;
65 static int hf_ndps_rpc_accept = -1;
66 static int hf_ndps_rpc_acc_stat = -1;
67 static int hf_ndps_rpc_rej_stat = -1;
68 static int hf_ndps_rpc_acc_results = -1;
69 static int hf_ndps_problem_type = -1;
70 static int hf_security_problem_type = -1;
71 static int hf_service_problem_type = -1;
72 static int hf_access_problem_type = -1;
73 static int hf_printer_problem_type = -1;
74 static int hf_selection_problem_type = -1;
75 static int hf_doc_access_problem_type = -1;
76 static int hf_attribute_problem_type = -1;
77 static int hf_update_problem_type = -1;
78 static int hf_obj_id_type = -1;
79 static int hf_oid_struct_size = -1;
80 static int hf_object_name = -1;
81 static int hf_ndps_document_number = -1;
82 static int hf_ndps_nameorid = -1;
83 static int hf_local_object_name = -1;
84 static int hf_printer_name = -1;
85 static int hf_ndps_qualified_name = -1;
86 static int hf_ndps_item_count = -1;
87 static int hf_ndps_qualifier = -1;
88 static int hf_ndps_lib_error = -1;
89 static int hf_ndps_other_error = -1;
90 static int hf_ndps_other_error_2 = -1;
91 static int hf_ndps_session = -1;
92 static int hf_ndps_abort_flag = -1;
93 static int hf_obj_attribute_type = -1;
94 static int hf_ndps_attribute_value = -1;
95 static int hf_ndps_lower_range = -1;
96 static int hf_ndps_upper_range = -1;
97 static int hf_ndps_n64 = -1;
98 static int hf_ndps_lower_range_n64 = -1;
99 static int hf_ndps_upper_range_n64 = -1;
100 static int hf_ndps_attrib_boolean = -1;
101 static int hf_ndps_realization = -1;
102 static int hf_ndps_xdimension_n64 = -1;
103 static int hf_ndps_ydimension_n64 = -1;
104 static int hf_ndps_dim_value = -1;
105 static int hf_ndps_dim_flag = -1;
106 static int hf_ndps_xydim_value = -1;
107 static int hf_ndps_location_value = -1;
108 static int hf_ndps_xmin_n64 = -1;
109 static int hf_ndps_xmax_n64 = -1;
110 static int hf_ndps_ymin_n64 = -1;
111 static int hf_ndps_ymax_n64 = -1;
112 static int hf_ndps_edge_value = -1;
113 static int hf_ndps_cardinal_or_oid = -1;
114 static int hf_ndps_cardinal_name_or_oid = -1;
115 static int hf_ndps_integer_or_oid = -1;
116 static int hf_ndps_profile_id = -1;
117 static int hf_ndps_persistence = -1;
118 static int hf_ndps_language_id = -1;
119 static int hf_address_type = -1;
120 static int hf_ndps_address = -1;
121 static int hf_ndps_add_bytes = -1;
122 static int hf_ndps_event_type = -1;
123 static int hf_ndps_event_object_identifier = -1;
124 static int hf_ndps_octet_string = -1;
125 static int hf_ndps_scope = -1;
126
127 static int hf_spx_ndps_program = -1;
128 static int hf_spx_ndps_version = -1;
129 static int hf_spx_ndps_func_print = -1;
130 static int hf_spx_ndps_func_registry = -1;
131 static int hf_spx_ndps_func_notify = -1;
132 static int hf_spx_ndps_func_resman = -1;
133 static int hf_spx_ndps_func_delivery = -1;
134 static int hf_spx_ndps_func_broker = -1;
135
136 static gint ett_ndps = -1;
137 static dissector_handle_t ndps_data_handle;
138
139 /* desegmentation of NDPS over TCP */
140 static gboolean ndps_desegment = TRUE;
141
142 static const value_string true_false[] = {
143     { 0x00000000, "Accept" },
144     { 0x00000001, "Deny" },
145     { 0,          NULL }
146 };
147
148 static const value_string accept_stat[] = {
149     { 0x00000000, "Success" },
150     { 0x00000001, "Program Unavailable" },
151     { 0x00000002, "Program Mismatch" },
152     { 0x00000003, "Procedure Unavailable" },
153     { 0x00000004, "Garbage Arguments" },
154     { 0x00000005, "System Error" },
155     { 0,          NULL }
156 };
157
158 static const value_string reject_stat[] = {
159     { 0x00000000, "RPC Mismatch" },
160     { 0x00000001, "Authentication Error" },
161     { 0,          NULL }
162 };
163
164 static const value_string error_type_enum[] = {
165     { 0x00000000, "Security Error" },
166     { 0x00000001, "Service Error" },
167     { 0x00000002, "Access Error" },
168     { 0x00000003, "Printer Error" },
169     { 0x00000004, "Selection Error" },
170     { 0x00000005, "Document Access Error" },
171     { 0x00000006, "Attribute Error" },
172     { 0x00000007, "Update Error" },
173     { 0,          NULL }
174 };
175
176 static const value_string security_problem_enum[] = {
177     { 0x00000000, "Authentication" },
178     { 0x00000001, "Credentials" },
179     { 0x00000002, "Rights" },
180     { 0x00000003, "Invalid PAC" },
181     { 0,          NULL }
182 };
183
184 static const value_string service_problem_enum[] = {
185     { 0x00000000, "Sever Busy" },
186     { 0x00000001, "Server Unavailable" },
187     { 0x00000002, "Complex Operation" },
188     { 0x00000003, "Resource Limit" },
189     { 0x00000004, "Unclassified Server Error" },
190     { 0x00000005, "Too Many Items in List" },
191     { 0x00000006, "Resource not Available" },
192     { 0x00000007, "Cancel Document Support" },
193     { 0x00000008, "Modify Document Support" },
194     { 0x00000009, "Multiple Document Support" },
195     { 0x0000000a, "Parameter Valid Support" },
196     { 0x0000000b, "Invalid Checkpoint" },
197     { 0x0000000c, "Continuation Context" },
198     { 0x0000000d, "Pause Limit Exceeded" },
199     { 0x0000000e, "Unsupported Operation" },
200     { 0x0000000f, "Notify Service Error" },
201     { 0x00000010, "Accounting Service Error" },
202     { 0,          NULL }
203 };
204
205 static const value_string access_problem_enum[] = {
206     { 0x00000000, "Wrong Object Class" },
207     { 0x00000001, "Lack of Access Rights" },
208     { 0x00000002, "Can't Interrupt Job" },
209     { 0x00000003, "Wrong Object State" },
210     { 0x00000004, "Client Not Bound" },
211     { 0x00000005, "Not Available" },
212     { 0x00000006, "Notify Service Not Connected" },
213     { 0x00000007, "PDS Not Connected" },
214     { 0,          NULL }
215 };
216
217 static const value_string printer_problem_enum[] = {
218     { 0x00000000, "Printer Error" },
219     { 0x00000001, "Printer Needs Attention" },
220     { 0x00000002, "Printer Needs Key Operator" },
221     { 0,          NULL }
222 };
223
224 static const value_string selection_problem_enum[] = {
225     { 0x00000000, "Invalid ID" },
226     { 0x00000001, "Unknown ID" },
227     { 0x00000002, "Object Exists" },
228     { 0x00000003, "ID Changed" },
229     { 0,          NULL }
230 };
231
232 static const value_string doc_access_problem_enum[] = {
233     { 0x00000000, "Access Not Available" },
234     { 0x00000001, "Time Expired" },
235     { 0x00000002, "Access Denied" },
236     { 0x00000003, "Unknown Document" },
237     { 0x00000004, "No Documents in Job" },
238     { 0,          NULL }
239 };
240
241 static const value_string attribute_problem_enum[] = {
242     { 0x00000000, "Invalid Syntax" },
243     { 0x00000001, "Undefined Type" },
244     { 0x00000002, "Wrong Matching" },
245     { 0x00000003, "Constraint Violated" },
246     { 0x00000004, "Unsupported Type" },
247     { 0x00000005, "Illegal Modification" },
248     { 0x00000006, "Consists With Other Attribute" },
249     { 0x00000007, "Undefined Attribute Value" },
250     { 0x00000008, "Unsupported Value" },
251     { 0x00000009, "Invalid Noncompulsed Modification" },
252     { 0x0000000a, "Per Job Inadmissible" },
253     { 0x0000000b, "Not Multivalued" },
254     { 0x0000000c, "Mandatory Omitted" },
255     { 0x0000000d, "Illegal For Class" },
256     { 0,          NULL }
257 };
258
259 static const value_string update_problem_enum[] = {
260     { 0x00000000, "No Modifications Allowed" },
261     { 0x00000001, "Insufficient Rights" },
262     { 0x00000002, "Previous Operation Incomplete" },
263     { 0x00000003, "Cancel Not Possible" },
264     { 0,          NULL }
265 };
266
267 static const value_string obj_identification_enum[] = {
268     { 0x00000000, "None" },
269     { 0x00000001, "Printer Contained Object ID" },
270     { 0x00000002, "Document Identifier" },
271     { 0x00000003, "Object Identifier" },
272     { 0x00000004, "Object Name" },
273     { 0x00000005, "Name or Object ID" },
274     { 0x00000006, "Simple Name" },
275     { 0x00000007, "Printer Configuration Object ID" },
276     { 0x00000008, "Qualified Name" },
277     { 0x00000009, "Event Object ID" },
278     { 0,          NULL }
279 };
280
281 static const value_string nameorid_enum[] = {
282     { 0x00000000, "None" },
283     { 0x00000001, "Global" },
284     { 0x00000002, "Local" },
285     { 0,          NULL }
286 };
287
288 static const value_string qualified_name_enum[] = {
289     { 0x00000000, "None" },
290     { 0x00000001, "Simple" },
291     { 0x00000002, "NDS" },
292     { 0,          NULL }
293 };
294
295
296 static const value_string spx_ndps_program_vals[] = {
297     { 0x00060976, "Print Program" },
298     { 0x00060977, "Broker Program" },
299     { 0x00060978, "Registry Program" },
300     { 0x00060979, "Notify Program" },
301     { 0x0006097a, "Resource Manager Program" },
302     { 0x0006097b, "Programatic Delivery Program" },
303     { 0,          NULL }
304 };
305
306 static const value_string spx_ndps_print_func_vals[] = {
307     { 0x00000001, "Bind PSM" },
308     { 0x00000002, "Bind PA" },
309     { 0x00000003, "Unbind" },
310     { 0x00000004, "Print" },
311     { 0x00000005, "Modify Job" },
312     { 0x00000006, "Cancel Job" },
313     { 0x00000007, "List Object Attributes" },
314     { 0x00000008, "Promote Job" },
315     { 0x00000009, "Interrupt" },
316     { 0x0000000a, "Pause" },
317     { 0x0000000b, "Resume" },
318     { 0x0000000c, "Clean" },
319     { 0x0000000d, "Create" },
320     { 0x0000000e, "Delete" },
321     { 0x0000000f, "Disable PA" },
322     { 0x00000010, "Enable PA" },
323     { 0x00000011, "Resubmit Jobs" },
324     { 0x00000012, "Set" },
325     { 0x00000013, "Shutdown PA" },
326     { 0x00000014, "Startup PA" },
327     { 0x00000015, "Reorder Job" },
328     { 0x00000016, "Pause PA" },
329     { 0x00000017, "Resume PA" },
330     { 0x00000018, "Transfer Data" },
331     { 0x00000019, "Device Control" },
332     { 0x0000001a, "Add Event Profile" },
333     { 0x0000001b, "Remove Event Profile" },
334     { 0x0000001c, "Modify Event Profile" },
335     { 0x0000001d, "List Event Profiles" },
336     { 0x0000001e, "Shutdown PSM" },
337     { 0x0000001f, "Cancel PSM Shutdown" },
338     { 0x00000020, "Set Printer DS Information" },
339     { 0x00000021, "Clean User Jobs" },
340     { 0x00000022, "Map GUID to NDS Name" },
341     { 0,          NULL }
342 };
343
344 static const value_string spx_ndps_notify_func_vals[] = {
345     { 0x00000001, "Notify Bind" },
346     { 0x00000002, "Notify Unbind" },
347     { 0x00000003, "Register Supplier" },
348     { 0x00000004, "Deregister Supplier" },
349     { 0x00000005, "Add Profile" },
350     { 0x00000006, "Remove Profile" },
351     { 0x00000007, "Modify Profile" },
352     { 0x00000008, "List Profiles" },
353     { 0x00000009, "Report Event" },
354     { 0x0000000a, "List Supported Languages" },
355     { 0x0000000b, "Report Notification" },
356     { 0x0000000c, "Add Delivery Method" },
357     { 0x0000000d, "Remove Delivery Method" },
358     { 0x0000000e, "List Delivery Methods" },
359     { 0x0000000f, "Get Delivery Method Information" },
360     { 0x00000010, "Get Notify NDS Object Name" },
361     { 0x00000011, "Get Notify Session Information" },
362     { 0,          NULL }
363 };
364
365 static const value_string spx_ndps_deliver_func_vals[] = {
366     { 0x00000001, "Delivery Bind" },
367     { 0x00000002, "Delivery Unbind" },
368     { 0x00000003, "Delivery Send" },
369     { 0x00000004, "Delivery Send2" },
370     { 0,          NULL }
371 };
372
373 static const value_string spx_ndps_registry_func_vals[] = {
374     { 0x00000001, "Bind" },
375     { 0x00000002, "Unbind" },
376     { 0x00000003, "Register Server" },
377     { 0x00000004, "Deregister Server" },
378     { 0x00000005, "Register Registry" },
379     { 0x00000006, "Deregister Registry" },
380     { 0x00000007, "Registry Update" },
381     { 0x00000008, "List Local Servers" },
382     { 0x00000009, "List Servers" },
383     { 0x0000000a, "List Known Registries" },
384     { 0x0000000b, "Get Registry NDS Object Name" },
385     { 0x0000000c, "Get Registry Session Information" },
386     { 0,          NULL }
387 };
388
389 static const value_string spx_ndps_resman_func_vals[] = {
390     { 0x00000001, "Bind" },
391     { 0x00000002, "Unbind" },
392     { 0x00000003, "Add Resource File" },
393     { 0x00000004, "Delete Resource File" },
394     { 0x00000005, "List Resources" },
395     { 0x00000006, "Get Resource File" },
396     { 0x00000007, "Get Resource File Data" },
397     { 0x00000008, "Get Resource Manager NDS Object Name" },
398     { 0x00000009, "Get Resource Manager Session Information" },
399     { 0x0000000a, "Set Resource Language Context" },
400     { 0,          NULL }
401 };
402
403 static const value_string spx_ndps_broker_func_vals[] = {
404     { 0x00000001, "Bind" },
405     { 0x00000002, "Unbind" },
406     { 0x00000003, "List Services" },
407     { 0x00000004, "Enable Service" },
408     { 0x00000005, "Disable Service" },
409     { 0x00000006, "Down Broker" },
410     { 0x00000007, "Get Broker NDS Object Name" },
411     { 0x00000008, "Get Broker Session Information" },
412     { 0,          NULL }
413 };
414
415 static const value_string ndps_packet_types[] = {
416     { 0x00000000, "Request" },
417     { 0x00000001, "Reply" },
418     { 0,          NULL }
419 };
420
421 static const value_string ndps_realization_enum[] = {
422     { 0x00000000, "Logical" },
423     { 0x00000001, "Physical" },
424     { 0x00000002, "Logical & Physical" },
425     { 0,          NULL }
426 };
427
428 static const value_string ndps_dim_value_enum[] = {
429     { 0x00000000, "Numeric" },
430     { 0x00000001, "Named" },
431     { 0,          NULL }
432 };
433
434 static const value_string ndps_xydim_value_enum[] = {
435     { 0x00000000, "Real" },
436     { 0x00000001, "Named" },
437     { 0x00000002, "Cardinal" },
438     { 0,          NULL }
439 };
440
441 static const value_string ndps_location_value_enum[] = {
442     { 0x00000000, "Numeric" },
443     { 0x00000001, "Named" },
444     { 0,          NULL }
445 };
446
447 static const value_string ndps_edge_value_enum[] = {
448     { 0x00000000, "Bottom" },
449     { 0x00000001, "Right" },
450     { 0x00000002, "Top" },
451     { 0x00000003, "Left" },
452     { 0,          NULL }
453 };
454
455 static const value_string ndps_card_or_oid_enum[] = {
456     { 0x00000000, "Number" },
457     { 0x00000001, "ID" },
458     { 0,          NULL }
459 };
460
461 static const value_string ndps_card_name_or_oid_enum[] = {
462     { 0x00000000, "ID" },
463     { 0x00000001, "Name" },
464     { 0,          NULL }
465 };
466
467 static const value_string ndps_integer_or_oid_enum[] = {
468     { 0x00000000, "ID" },
469     { 0x00000001, "Number" },
470     { 0,          NULL }
471 };
472
473 static const value_string ndps_persistence_enum[] = {
474     { 0x00000000, "Permanent" },
475     { 0x00000001, "Volatile" },
476     { 0,          NULL }
477 };
478
479 static const value_string ndps_address_type_enum[] = {
480     { 0x00000000, "User" },
481     { 0x00000001, "Server" },
482     { 0x00000002, "Volume" },
483     { 0x00000003, "Organization Unit" },
484     { 0x00000004, "Organization" },
485     { 0x00000005, "Group" },
486     { 0x00000006, "Distinguished Name" },
487     { 0x00000007, "User or Container" },
488     { 0x00000008, "Case Exact String" },
489     { 0x00000009, "Case Ignore String" },
490     { 0x0000000a, "Numeric String" },
491     { 0x0000000b, "DOS File Name" },
492     { 0x0000000c, "Phone Number" },
493     { 0x0000000d, "Boolean" },
494     { 0x0000000e, "Integer" },
495     { 0x0000000f, "Network Address" },
496     { 0x00000010, "Choice" },
497     { 0x00000011, "Groupwise User" },
498     { 0,          NULL }
499 };
500
501 static const value_string ndps_address_enum[] = {
502     { 0x00000000, "IPX" },
503     { 0x00000001, "IP" },
504     { 0x00000002, "SDLC" },
505     { 0x00000003, "Token Ring to Ethernet" },
506     { 0x00000004, "OSI" },
507     { 0x00000005, "Appletalk" },
508     { 0x00000006, "Count" },
509     { 0,          NULL }
510 };
511
512 static const value_string ndps_event_object_enum[] = {
513     { 0x00000000, "Object" },
514     { 0x00000001, "Filter" },
515     { 0x00000002, "Detail" },
516     { 0,          NULL }
517 };
518
519 static const value_string ndps_attribute_enum[] = {
520     { 0x00000000, "Null" },
521     { 0x00000001, "Text" },
522     { 0x00000002, "Descriptive Name" },
523     { 0x00000003, "Descriptor" },
524     { 0x00000004, "Message" },
525     { 0x00000005, "Error Message" },
526     { 0x00000006, "Simple Name" },
527     { 0x00000007, "Distinguished Name" },
528     { 0x00000008, "Distinguished Name Seq" },
529     { 0x00000009, "Delta Time" },
530     { 0x0000000a, "Time" },
531     { 0x0000000b, "Integer" },
532     { 0x0000000c, "Integer Seq" },
533     { 0x0000000d, "Cardinal" },
534     { 0x0000000e, "Cardinal Seq" },
535     { 0x0000000f, "Positive Integer" },
536     { 0x00000010, "Integer Range" },
537     { 0x00000011, "Cardinal Range" },
538     { 0x00000012, "Maximum Integer" },
539     { 0x00000013, "Minimum Integer" },
540     { 0x00000014, "Integer 64" },
541     { 0x00000015, "Integer 64 Seq" },
542     { 0x00000016, "Cardinal 64" },
543     { 0x00000017, "Cardinal 64 Seq" },
544     { 0x00000018, "Positive Integer 64" },
545     { 0x00000019, "Integer 64 Range" },
546     { 0x0000001a, "Cardinal 64 Range" },
547     { 0x0000001b, "Maximum Integer 64" },
548     { 0x0000001c, "Minimum Integer 64" },
549     { 0x0000001d, "Real" },
550     { 0x0000001e, "Real Seq" },
551     { 0x0000001f, "Non-Negative Real" },
552     { 0x00000020, "Real Range" },
553     { 0x00000021, "Non-Negative Real Range" },
554     { 0x00000022, "Boolean" },
555     { 0x00000023, "Percent" },
556     { 0x00000024, "Object Identifier" },
557     { 0x00000025, "Object Identifier Seq" },
558     { 0x00000026, "Name or OID" },
559     { 0x00000027, "Name or OID Seq" },
560     { 0x00000028, "Distinguished Name" },
561     { 0x00000029, "Relative Distinguished Name Seq" },
562     { 0x0000002a, "Realization" },
563     { 0x0000002b, "Medium Dimensions" },
564     { 0x0000002c, "Dimension" },
565     { 0x0000002d, "XY Dimensions" },
566     { 0x0000002e, "Locations" },
567     { 0x0000002f, "Area" },
568     { 0x00000030, "Area Seq" },
569     { 0x00000031, "Edge" },
570     { 0x00000032, "Font Reference" },
571     { 0x00000033, "Cardinal or OID" },
572     { 0x00000034, "OID Cardinal Map" },
573     { 0x00000035, "Cardinal or Name or OID" },
574     { 0x00000036, "Positive Integer or OID" },
575     { 0x00000037, "Event Handling Profile" },
576     { 0x00000038, "Octet String" },
577     { 0x00000039, "Priority" },
578     { 0x0000003a, "Locale" },
579     { 0x0000003b, "Method Delivery Address" },
580     { 0x0000003c, "Object Identification" },
581     { 0x0000003d, "Results Profile" },
582     { 0x0000003e, "Criteria" },
583     { 0x0000003f, "Job Password" },
584     { 0x00000040, "Job Level" },
585     { 0x00000041, "Job Categories" },
586     { 0x00000042, "Print Checkpoint" },
587     { 0x00000043, "Ignored Attribute" },
588     { 0x00000044, "Resource" },
589     { 0x00000045, "Medium Substitution" },
590     { 0x00000046, "Font Substitution" },
591     { 0x00000047, "Resource Context Seq" },
592     { 0x00000048, "Sides" },
593     { 0x00000049, "Page Select Seq" },
594     { 0x0000004a, "Page Media Select" },
595     { 0x0000004b, "Document Content" },
596     { 0x0000004c, "Page Size" },
597     { 0x0000004d, "Presentation Direction" },
598     { 0x0000004e, "Page Order" },
599     { 0x0000004f, "File Reference" },
600     { 0x00000050, "Medium Source Size" },
601     { 0x00000051, "Input Tray Medium" },
602     { 0x00000052, "Output Bins Chars" },
603     { 0x00000053, "Page ID Type" },
604     { 0x00000054, "Level Range" },
605     { 0x00000055, "Category Set" },
606     { 0x00000056, "Numbers Up Supported" },
607     { 0x00000057, "Finishing" },
608     { 0x00000058, "Print Contained Object ID" },
609     { 0x00000059, "Print Config Object ID" },
610     { 0x0000005a, "Typed Name" },
611     { 0x0000005b, "Network Address" },
612     { 0x0000005c, "XY Dimensions Value" },
613     { 0x0000005d, "Name or OID Dimensions Map" },
614     { 0x0000005e, "Printer State Reason" },
615     { 0x0000005f, "Enumeration" },
616     { 0x00000060, "Qualified Name" },
617     { 0x00000061, "Qualified Name Set" },
618     { 0x00000062, "Colorant Set" },
619     { 0x00000063, "Resource Printer ID" },
620     { 0x00000064, "Event Object ID" },
621     { 0x00000065, "Qualified Name Map" },
622     { 0x00000066, "File Path" },
623     { 0x00000067, "Uniform Resource Identifier" },
624     { 0x00000068, "Cardinal or Enum or Time" },
625     { 0x00000069, "Print Contained Object ID Set" },
626     { 0x0000006a, "Octet String Pair" },
627     { 0x0000006b, "Octet String Integer Pair" },
628     { 0x0000006c, "Extended Resource Identifier" },
629     { 0x0000006d, "Event Handling Profile 2" },
630     { 0,          NULL }
631 };
632
633 static const value_string ndps_error_types[] = {
634     { 0xFFFFFC18, "NWDP_OE_BK_OUT_OF_MEMORY" },      /* Broker Errors */
635     { 0xFFFFFC17, "NWDP_OE_BK_BAD_NETWARE_VERSION" },
636     { 0xFFFFFC16, "NWDP_OE_BK_WRONG_CMD_LINE_ARGS" },
637     { 0xFFFFFC15, "NWDP_OE_BK_BROKER_NAME_NOT_GIVN" },
638     { 0xFFFFFC14, "NWDP_OE_BK_NOT_BROKER_CLASS" },
639     { 0xFFFFFC13, "NWDP_OE_BK_INVALID_BROKER_PWORD" },
640     { 0xFFFFFC12, "NWDP_OE_BK_INVALID_BROKER_NAME" },
641     { 0xFFFFFC11, "NWDP_OE_BK_FAILED_TO_CRTE_THRED" },
642     { 0xFFFFFC10, "NWDP_OE_BK_FAILED_TO_INIT_NUT" },
643     { 0xFFFFFC0F, "NWDP_OE_BK_FAILED_TO_GET_MSGS" },
644     { 0xFFFFFC0E, "NWDP_OE_BK_FAILED_TO_ALLOC_RES" },
645     { 0xFFFFFC0D, "NWDP_OE_BK_SVC_MUST_BE_FULL_DIS" },
646     { 0xFFFFFC0C, "NWDP_OE_BK_UNINITIALIZED_MODULE" },
647     { 0xFFFFFC0B, "NWDP_OE_BK_DS_VAL_SIZE_TOO_LARG" },
648     { 0xFFFFFC0A, "NWDP_OE_BK_NO_ATTRIBUTE_VALUES" },
649     { 0xFFFFFC09, "NWDP_OE_BK_UNKNOWN_SESSION" },
650     { 0xFFFFFC08, "NWDP_OE_BK_SERVICE_DISABLED" },
651     { 0xFFFFFC07, "NWDP_OE_BK_UNKNOWN_MODIFY_OPER" },
652     { 0xFFFFFC06, "NWDP_OE_BK_INVALID_ARGUMENTS" },
653     { 0xFFFFFC05, "NWDP_OE_BK_DUPLICATE_SESSION_ID" },
654     { 0xFFFFFC04, "NWDP_OE_BK_UNKNOWN_SERVICE" },
655     { 0xFFFFFC03, "NWDP_OE_BK_SRVC_ALREADY_ENABLED" },
656     { 0xFFFFFC02, "NWDP_OE_BK_SRVC_ALREADY_DISABLD" },
657     { 0xFFFFFC01, "NWDP_OE_BK_INVALID_CREDENTIAL" },
658     { 0xFFFFFC00, "NWDP_OE_BK_UNKNOWN_DESIGNATOR" },
659     { 0xFFFFFBFF, "NWDP_OE_BK_FAIL_MAKE_CHG_PERMNT" },
660     { 0xFFFFFBFE, "NWDP_OE_BK_NOT_ADMIN_TYPE_SESN" },
661     { 0xFFFFFBFD, "NWDP_OE_BK_OPTION_NOT_SUPPORTED" },
662     { 0xFFFFFBFC, "NWDP_OE_BK_NO_EFFECTIVE_RIGHTS" },
663     { 0xFFFFFBFB, "NWDP_OE_BK_COULD_NOT_FIND_FILE" },
664     { 0xFFFFFBFA, "NWDP_OE_BK_ERROR_READING_FILE" },
665     { 0xFFFFFBF9, "NWDP_OE_BK_NOT_NLM_FILE_FORMAT" },
666     { 0xFFFFFBF8, "NWDP_OE_BK_WRONG_NLM_FILE_VER" },
667     { 0xFFFFFBF7, "NWDP_OE_BK_REENTRANT_INIT_FAIL" },
668     { 0xFFFFFBF6, "NWDP_OE_BK_ALREADY_IN_PROGRESS" },
669     { 0xFFFFFBF5, "NWDP_OE_BK_INITIALIZE_FAILURE" },
670     { 0xFFFFFBF4, "NWDP_OE_BK_INCONSISTNT_FILE_FMT" },
671     { 0xFFFFFBF3, "NWDP_OE_BK_CANT_LOAD_AT_STARTUP" },
672     { 0xFFFFFBF2, "NWDP_OE_BK_AUTO_MODULS_NOT_LOAD" },
673     { 0xFFFFFBF1, "NWDP_OE_BK_UNRESOLVED_EXTERNAL" },
674     { 0xFFFFFBF0, "NWDP_OE_BK_PUBLIC_ALREADY_DEFND" },
675     { 0xFFFFFBEF, "NWDP_OE_BK_OTHER_BRKR_USING_OBJ" },
676     { 0xFFFFFBEE, "NWDP_OE_BK_SRVC_FAILED_TO_INIT" },
677     { 0xFFFFFBB4, "NWDP_OE_RG_OUT_OF_MEMORY" },       /* SRS Errors */
678     { 0xFFFFFBB3, "NWDP_OE_RG_BAD_NETWARE_VERSION" },
679     { 0xFFFFFBB2, "NWDP_OE_RG_FAIL_CREATE_CONTEXT" },
680     { 0xFFFFFBB1, "NWDP_OE_RG_FAIL_LOGIN" },
681     { 0xFFFFFBB0, "NWDP_OE_RG_FAIL_CREATE_THREAD" },
682     { 0xFFFFFBAF, "NWDP_OE_RG_FAIL_GET_MSGS" },
683     { 0xFFFFFBAE, "NWDP_OE_RG_SVC_MUST_BE_FULL_DIS" },
684     { 0xFFFFFBAD, "NWDP_OE_RG_DS_VAL_SIZE_TOO_LARG" },
685     { 0xFFFFFBAC, "NWDP_OE_RG_NO_ATTRIBUTE_VALUES" },
686     { 0xFFFFFBAB, "NWDP_OE_RG_UNKNOWN_SESSION" },
687     { 0xFFFFFBAA, "NWDP_OE_RG_SERVICE_DISABLED" },
688     { 0xFFFFFBA9, "NWDP_OE_RG_UNKNOWN_MODIFY_OPER" },
689     { 0xFFFFFBA8, "NWDP_OE_RG_CANT_START_ADVERTISE" },
690     { 0xFFFFFBA7, "NWDP_OE_RG_DUP_SERVER_ENTRY" },
691     { 0xFFFFFBA6, "NWDP_OE_RG_CANT_BIND_2_REGISTRY" },
692     { 0xFFFFFBA5, "NWDP_OE_RG_CANT_CREATE_CLIENT" },
693     { 0xFFFFFBA4, "NWDP_OE_RG_INVALID_ARGUMENTS" },
694     { 0xFFFFFBA3, "NWDP_OE_RG_DUPLICATE_SESSION_ID" },
695     { 0xFFFFFBA2, "NWDP_OE_RG_UNKNOWN_SERVER_ENTRY" },
696     { 0xFFFFFBA1, "NWDP_OE_RG_INVALID_CREDENTIAL" },
697     { 0xFFFFFBA0, "NWDP_OE_RG_REGIST_TYPE_SESN" },
698     { 0xFFFFFB9F, "NWDP_OE_RG_SERVER_TYPE_SESN" },
699     { 0xFFFFFB9E, "NWDP_OE_RG_NOT_SERVER_TYPE_SESN" },
700     { 0xFFFFFB9D, "NWDP_OE_RG_NOT_REGIST_TYPE_SESN" },
701     { 0xFFFFFB9C, "NWDP_OE_RG_UNKNOWN_DESIGNATOR" },
702     { 0xFFFFFB9B, "NWDP_OE_RG_OPTION_NOT_SUPPORTED" },
703     { 0xFFFFFB9A, "NWDP_OE_RG_NOT_IN_LST_ITERATION" },
704     { 0xFFFFFB99, "NWDP_OE_RG_INVLD_CONTNUATN_HNDL" },
705     { 0xFFFFFB50, "NWDP_OE_NF_OUT_OF_MEMORY" },        /* Notification Service Errors */
706     { 0xFFFFFB4F, "NWDP_OE_NF_BAD_NETWARE_VERSION" },
707     { 0xFFFFFB4E, "NWDP_OE_NF_FAIL_CREATE_THREAD" },
708     { 0xFFFFFB4D, "NWDP_OE_NF_FAIL_GET_MSGS" },
709     { 0xFFFFFB4C, "NWDP_OE_NF_FAIL_CREATE_CONTEXT" },
710     { 0xFFFFFB4B, "NWDP_OE_NF_FAIL_LOGIN" },
711     { 0xFFFFFB4A, "NWDP_OE_NF_SVC_MUST_BE_FULL_DIS" },
712     { 0xFFFFFB49, "NWDP_OE_NF_DS_VAL_SIZE_TOO_LARG" },
713     { 0xFFFFFB48, "NWDP_OE_NF_NO_ATTRIBUTE_VALUES" },
714     { 0xFFFFFB47, "NWDP_OE_NF_UNKNOWN_SESSION" },
715     { 0xFFFFFB46, "NWDP_OE_NF_UNKNOWN_NOTIFY_PROF" },
716     { 0xFFFFFB45, "NWDP_OE_NF_ERROR_READING_FILE" },
717     { 0xFFFFFB44, "NWDP_OE_NF_ERROR_WRITING_FILE" },
718     { 0xFFFFFB43, "NWDP_OE_NF_WRONG_NOTIFY_DB_VERS" },
719     { 0xFFFFFB42, "NWDP_OE_NF_CORRUPTED_NOTIFY_DB" },
720     { 0xFFFFFB41, "NWDP_OE_NF_UNKNOWN_EVENT_OID" },
721     { 0xFFFFFB40, "NWDP_OE_NF_METHOD_ALREADY_INST" },
722     { 0xFFFFFB3F, "NWDP_OE_NF_UNKNOWN_METHOD" },
723     { 0xFFFFFB3E, "NWDP_OE_NF_SERVICE_DISABLED" },
724     { 0xFFFFFB3D, "NWDP_OE_NF_UNKNOWN_MODIFY_OP" },
725     { 0xFFFFFB3C, "NWDP_OE_NF_OUT_OF_NOTIFY_ENTRYS" },
726     { 0xFFFFFB3B, "NWDP_OE_NF_UNKNOWN_LANGUAGE_ID" },
727     { 0xFFFFFB3A, "NWDP_OE_NF_NOTIFY_QUEUE_EMPTY" },
728     { 0xFFFFFB39, "NWDP_OE_NF_CANT_LOAD_DELVR_METH" },
729     { 0xFFFFFB38, "NWDP_OE_NF_INVALID_ARGUMENTS" },
730     { 0xFFFFFB37, "NWDP_OE_NF_DUPLICATE_SESSION_ID" },
731     { 0xFFFFFB36, "NWDP_OE_NF_INVALID_CREDENTIAL" },
732     { 0xFFFFFB35, "NWDP_OE_NF_UNKNOWN_CHOICE" },
733     { 0xFFFFFB34, "NWDP_OE_NF_UNKNOWN_ATTR_VALUE" },
734     { 0xFFFFFB33, "NWDP_OE_NF_ERROR_WRITING_DB" },
735     { 0xFFFFFB32, "NWDP_OE_NF_UNKNOWN_OBJECT_ID" },
736     { 0xFFFFFB31, "NWDP_OE_NF_UNKNOWN_DESIGNATOR" },
737     { 0xFFFFFB30, "NWDP_OE_NF_FAIL_MAKE_CHG_PERMNT" },
738     { 0xFFFFFB2F, "NWDP_OE_NF_UI_NOT_SUPPORTED" },
739     { 0xFFFFFB2E, "NWDP_OE_NF_NOT_SUPPLY_TYPE_SESN" },
740     { 0xFFFFFB2D, "NWDP_OE_NF_NOT_ADMIN_TYPE_SESN" },
741     { 0xFFFFFB2C, "NWDP_OE_NF_NO_SRVC_REGIST_AVAIL" },
742     { 0xFFFFFB2B, "NWDP_OE_NF_FAIL_TO_REG_W_ANY_SR" },
743     { 0xFFFFFB2A, "NWDP_OE_NF_EMPTY_EVENT_OBJ_SET" },
744     { 0xFFFFFB29, "NWDP_OE_NF_UNKNOWN_NTFY_HANDLE" },
745     { 0xFFFFFB28, "NWDP_OE_NF_OPTION_NOT_SUPPORTED" },
746     { 0xFFFFFB27, "NWDP_OE_NF_UNKNOWN_RPC_SESSION" },
747     { 0xFFFFFB26, "NWDP_OE_NF_INITIALIZATION_ERROR" },
748     { 0xFFFFFB25, "NWDP_OE_NF_NO_EFFECTIVE_RIGHTS" },
749     { 0xFFFFFB24, "NWDP_OE_NF_NO_PERSISTENT_STORAG" },
750     { 0xFFFFFB23, "NWDP_OE_NF_BAD_METHOD_FILENAME" },
751     { 0xFFFFFB22, "NWDP_OE_NF_UNKNOWN_CONT_HANDLE" },
752     { 0xFFFFFB21, "NWDP_OE_NF_INVALID_CONT_HANDLE" },
753     { 0xFFFFFB20, "NWDP_OE_NF_COULD_NOT_FIND_FILE" },
754     { 0xFFFFFB1F, "NWDP_OE_NF_L_ERROR_READING_FILE" },
755     { 0xFFFFFB1E, "NWDP_OE_NF_NOT_NLM_FILE_FORMAT" },
756     { 0xFFFFFB1D, "NWDP_OE_NF_WRONG_NLM_FILE_VER" },
757     { 0xFFFFFB1C, "NWDP_OE_NF_REENTRANT_INIT_FAIL" },
758     { 0xFFFFFB1B, "NWDP_OE_NF_ALREADY_IN_PROGRESS" },
759     { 0xFFFFFB1A, "NWDP_OE_NF_INITIALIZE_FAILURE" },
760     { 0xFFFFFB19, "NWDP_OE_NF_INCONSISTNT_FILE_FMT" },
761     { 0xFFFFFB18, "NWDP_OE_NF_CANT_LOAD_AT_STARTUP" },
762     { 0xFFFFFB17, "NWDP_OE_NF_AUTO_MODULS_NOT_LOAD" },
763     { 0xFFFFFB16, "NWDP_OE_NF_UNRESOLVED_EXTERNAL" },
764     { 0xFFFFFB15, "NWDP_OE_NF_PUBLIC_ALREADY_DEFND" },
765     { 0xFFFFFB14, "NWDP_OE_NF_USING_UNKNOWN_METHDS" },
766     { 0xFFFFFB13, "NWDP_OE_NF_SRVC_NOT_FULL_ENABLD" },
767     { 0xFFFFFB12, "NWDP_OE_NF_FOREIGN_NDS_TREE_NAM" },
768     { 0xFFFFFB11, "NWDP_OE_NF_DLVYMETH_REJCTD_ADDR" },
769     { 0xFFFFFB10, "NWDP_OE_NF_UNSUPRT_DLVYADDRTYPE" },
770     { 0xFFFFFB0F, "NWDP_OE_NF_USR_OBJ_NO_DEFLTSERV" },
771     { 0xFFFFFB0E, "NWDP_OE_NF_FAILED_TO_SEND_NOTIF" },
772     { 0xFFFFFB0D, "NWDP_OE_NF_BAD_VOLUME_IN_ADDR" },
773     { 0xFFFFFB0C, "NWDP_OE_NF_BROKER_NO_FILE_RIGHT" },
774     { 0xFFFFFB0B, "NWDP_OE_NF_MAX_METHDS_SUPPORTED" },
775     { 0xFFFFFB0A, "NWDP_OE_NF_NO_FILTER_PROVIDED" },
776     { 0xFFFFFB09, "NE_IPX_NOT_SUPPORTED_BY_METHOD" },
777     { 0xFFFFFB08, "NE_IP_NOT_SUPPORTED_BY_METHOD" },
778     { 0xFFFFFB07, "NE_FAILED_TO_STARTUP_WINSOCK" },
779     { 0xFFFFFB06, "NE_NO_PROTOCOLS_AVAILABLE" },
780     { 0xFFFFFB05, "NE_FAILED_TO_LAUNCH_RPC_SERVER" },
781     { 0xFFFFFB04, "NE_INVALID_SLP_ATTR_FORMAT" },
782     { 0xFFFFFB03, "NE_INVALID_SLP_URL_FORMAT" },
783     { 0xFFFFFB02, "NE_UNKNOWN_ATTRIBUTE_OID" },
784     { 0xFFFFFB01, "NE_DUPLICATE_SESSION_ID" },
785     { 0xFFFFFB00, "NE_FAILED_TO_AUTHENTICATE" },
786     { 0xFFFFFAFF, "NE_FAILED_TO_AUTH_PROTOCOL_MISMATCH" },
787     { 0xFFFFFAFE, "NE_FAILED_TO_AUTH_INTERNAL_ERROR" },
788     { 0xFFFFFAFD, "NE_FAILED_TO_AUTH_CONNECTION_ERROR" },
789     { 0xFFFFFC7C, "NWDP_OE_RM_OUT_OF_MEMORY" },  /* ResMan Errors */
790     { 0xFFFFFC7B, "NWDP_OE_RM_BAD_NETWARE_VERSION" },
791     { 0xFFFFFC7A, "NWDP_OE_RM_WRONG_CMD_LINE_ARGS" },
792     { 0xFFFFFC79, "NWDP_OE_RM_BROKER_NAME_NOT_GIVN" },
793     { 0xFFFFFC78, "NWDP_OE_RM_INVALID_BROKER_PWORD" },
794     { 0xFFFFFC77, "NWDP_OE_RM_INVALID_BROKER_NAME" },
795     { 0xFFFFFC76, "NWDP_OE_RM_FAILED_TO_CRTE_THRED" },
796     { 0xFFFFFC75, "NWDP_OE_RM_SVC_MUST_BE_FULL_DIS" },
797     { 0xFFFFFC74, "NWDP_OE_RM_DS_VAL_SIZE_TOO_LARG" },
798     { 0xFFFFFC73, "NWDP_OE_RM_NO_ATTRIBUTE_VALUES" },
799     { 0xFFFFFC72, "NWDP_OE_RM_UNKNOWN_SESSION" },
800     { 0xFFFFFC71, "NWDP_OE_RM_ERROR_READING_FILE" },
801     { 0xFFFFFC70, "NWDP_OE_RM_ERROR_WRITING_FILE" },
802     { 0xFFFFFC6F, "NWDP_OE_RM_SERVICE_DISABLED" },
803     { 0xFFFFFC6E, "NWDP_OE_RM_UNKNOWN_MODIFY_OPER" },
804     { 0xFFFFFC6D, "NWDP_OE_RM_DUPLICATE_SESSION_ID" },
805     { 0xFFFFFC6C, "NWDP_OE_RM_INVALID_CREDENTIAL" },
806     { 0xFFFFFC6B, "NWDP_OE_RM_NO_SRVC_REGIST_AVAIL" },
807     { 0xFFFFFC6A, "NWDP_OE_RM_FAIL_TO_REG_W_ANY_SR" },
808     { 0xFFFFFC69, "NWDP_OE_RM_FAIL_TO_GET_MSGS" },
809     { 0xFFFFFC68, "NWDP_OE_RM_FAIL_TO_CRTE_CONTEXT" },
810     { 0xFFFFFC67, "NWDP_OE_RM_FAIL_TO_LOGIN" },
811     { 0xFFFFFC66, "NWDP_OE_RM_NPD_FILE_GEN_ERR" },
812     { 0xFFFFFC65, "NWDP_OE_RM_INF_FILE_FORMAT_ERR" },
813     { 0xFFFFFC64, "NWDP_OE_RM_NO_PRT_TYPE_IN_INF" },
814     { 0xFFFFFC63, "NWDP_OE_RM_NO_INF_FILES_PRESENT" },
815     { 0xFFFFFC62, "NWDP_OE_RM_FILE_OPEN_ERROR" },
816     { 0xFFFFFC61, "NWDP_OE_RM_READ_FILE_ERROR" },
817     { 0xFFFFFC60, "NWDP_OE_RM_WRITE_FILE_ERROR" },
818     { 0xFFFFFC5F, "NWDP_OE_RM_RESRC_TYPE_INVALID" },
819     { 0xFFFFFC5E, "NWDP_OE_RM_NO_SUCH_FILENAME" },
820     { 0xFFFFFC5D, "NWDP_OE_RM_BANR_TYPE_INVALID" },
821     { 0xFFFFFC5C, "NWDP_OE_RM_LIST_TYPE_UNKNOWN" },
822     { 0xFFFFFC5B, "NWDP_OE_RM_OS_NOT_SUPPORTED" },
823     { 0xFFFFFC5A, "NWDP_OE_RM_NO_BANR_FILES_PRESNT" },
824     { 0xFFFFFC59, "NWDP_OE_RM_PRN_DEF_TYPE_UNKNOWN" },
825     { 0xFFFFFC58, "NWDP_OE_RM_NO_PRN_TYPES_IN_LIST" },
826     { 0xFFFFFC57, "NWDP_OE_RM_OPTION_NOT_SUPPORTED" },
827     { 0xFFFFFC56, "NWDP_OE_RM_UNICODE_CONV_ERR" },
828     { 0xFFFFFC55, "NWDP_OE_RM_INVALID_ARGUMENTS" },
829     { 0xFFFFFC54, "NWDP_OE_RM_INITIALIZATION_ERROR" },
830     { 0xFFFFFC53, "NWDP_OE_RM_NO_SRV_REG_AVAILABLE" },
831     { 0xFFFFFC52, "NWDP_OE_RM_FAIL_RGSTR_TO_ANY_SR" },
832     { 0xFFFFFC51, "NWDP_OE_RM_UNKNOWN_DESIGNATOR" },
833     { 0xFFFFFC50, "NWDP_OE_RM_NOT_ADMIN_SESSION" },
834     { 0xFFFFFC4F, "NWDP_OE_RM_NO_EFFECTIVE_RIGHTS" },
835     { 0xFFFFFC4E, "NWDP_OE_RM_BAD_FILE_ATTRIBUTE" },
836     { 0xFFFFFC4D, "NWDP_OE_RM_DID_FORMAT_ERROR" },
837     { 0xFFFFFC4C, "NWDP_OE_RM_UNKNOWN_RPC_SESSION" },
838     { 0xFFFFFC4B, "NWDP_OE_RM_SESSN_BEING_REMOVED" },
839     { 0xFFFFFC49, "NWDP_OE_RM_FMGR_IO_ERROR" },
840     { 0xFFFFFC48, "NWDP_OE_RM_FMGR_REENTRANCY" },
841     { 0xFFFFFC47, "NWDP_OE_RM_FMGR_SEQ_ERROR" },
842     { 0xFFFFFC46, "NWDP_OE_RM_FMGR_CRPT_INDEX_FILE" },
843     { 0xFFFFFC45, "NWDP_OE_RM_FMGR_NO_SUCH_FONT" },
844     { 0xFFFFFC44, "NWDP_OE_RM_FMGR_NOT_INITIALIZED" },
845     { 0xFFFFFC43, "NWDP_OE_RM_FMGR_SYSTEM_ERROR" },
846     { 0xFFFFFC42, "NWDP_OE_RM_FMGR_BAD_PARM" },
847     { 0xFFFFFC41, "NWDP_OE_RM_FMGR_PATH_TOO_LONG" },
848     { 0xFFFFFC40, "NWDP_OE_RM_FMGR_FAILURE" },
849     { 0xFFFFFC3F, "NWDP_OE_RM_DUP_TIRPC_SESSION" },
850     { 0xFFFFFC3E, "NWDP_OE_RM_CONN_LOST_RMS_DATA" },
851     { 0xFFFFFC3D, "NWDP_OE_RM_FAIL_START_WINSOCK" },
852     { 0xFFFFFC3C, "NWDP_OE_RM_NO_PROTOCOLS_AVAIL" },
853     { 0xFFFFFC3B, "NWDP_OE_RM_FAIL_LNCH_RPC_SRVR" },
854     { 0xFFFFFC3A, "NWDP_OE_RM_INVALID_SLP_ATTR_FMT" },
855     { 0xFFFFFC39, "NWDP_OE_RM_INVALID_SLP_URL_FMT" },
856     { 0xFFFFFC38, "NWDP_OE_RM_UNRESOLVED_EXTERNAL" },
857     { 0xFFFFFC37, "NWDP_OE_RM_FAILED_TO_AUTHENT" },
858     { 0xFFFFFC36, "NWDP_OE_RM_FAIL_AUTH_PROT_MISMA" },
859     { 0xFFFFFC35, "NWDP_OE_RM_FAIL_AUTH_INT_ERR" },
860     { 0xFFFFFC34, "NWDP_OE_RM_FAIL_AUTH_CONN_ERR" },
861     { 0xFFFFFC33, "NWDP_OE_RM_NO_RIGHTS_REM_RESDIR" },
862     { 0xFFFFFC32, "NWDP_OE_RM_CANT_INIT_NDPS_LIB" },
863     { 0xFFFFFC31, "NWDP_OE_RM_CANT_CREAT_RESREF" },
864     { 0xFFFFFC30, "NWDP_OE_RM_FILE_ZERO_LENGTH" },
865     { 0xFFFFFC2F, "NWDP_OE_RM_FAIL_WRI_INF_IN_ADD" },
866     { 0xFFFFFCDF, "NDPS_E_NO_MEMORY" },               /* NDPSM Errors */
867     { 0xFFFFFCDE, "NDPS_E_MEMORY_NOT_FOUND" },
868     { 0xFFFFFCDD, "NDPS_E_JOB_STORAGE_LIMIT" },
869     { 0xFFFFFCDC, "NDPS_E_JOB_RETENTION_LIMIT" },
870     { 0xFFFFFCDB, "NDPS_E_UNSUPPORTED_TYPE" },
871     { 0xFFFFFCDA, "NDPS_E_UNDEFINED_TYPE" },
872     { 0xFFFFFCD9, "NDPS_E_UNSUPPORTED_OP" },
873     { 0xFFFFFCD8, "NDPS_E_ACCESSING_DB" },
874     { 0xFFFFFCD7, "NDPS_E_NO_PDS" },
875     { 0xFFFFFCD6, "NDPS_E_INVALID_CLASS" },
876     { 0xFFFFFCD5, "NDPS_E_BAD_PARAMETER" },
877     { 0xFFFFFCD4, "NDPS_E_OBJECT_NOT_FOUND" },
878     { 0xFFFFFCD3, "NDPS_E_ATTRIBUTE_NOT_FOUND" },
879     { 0xFFFFFCD2, "NDPS_E_VALUE_NOT_FOUND" },
880     { 0xFFFFFCD1, "NDPS_E_VALUES_NOT_COMPARABLE" },
881     { 0xFFFFFCD0, "NDPS_E_INVALID_VALUE_SYNTAX" },
882     { 0xFFFFFCCF, "NDPS_E_JOB_NOT_FOUND" },
883     { 0xFFFFFCCE, "NDPS_E_COMMUNICATION" },
884     { 0xFFFFFCCD, "NDPS_E_PA_INITIALIZING" },
885     { 0xFFFFFCCC, "NDPS_E_PA_GOING_DOWN" },
886     { 0xFFFFFCCB, "NDPS_E_PA_DISABLED" },
887     { 0xFFFFFCCA, "NDPS_E_PA_PAUSED" },
888     { 0xFFFFFCC9, "NDPS_E_BAD_PA_HANDLE" },
889     { 0xFFFFFCC8, "NDPS_E_OBJECT_NOT_LOCKED" },
890     { 0xFFFFFCC7, "NDPS_E_VERSION_INCOMPATIBLE" },
891     { 0xFFFFFCC6, "NDPS_E_PSM_INITIALIZING" },
892     { 0xFFFFFCC5, "NDPS_E_PSM_GOING_DOWN" },
893     { 0xFFFFFCC4, "NDPS_E_NOTIF_SVC_ERROR" },
894     { 0xFFFFFCC3, "NDPS_E_MEDIUM_NEEDS_MOUNTED" },
895     { 0xFFFFFCC2, "NDPS_E_PDS_NOT_RESPONDING" },
896     { 0xFFFFFCC1, "NDPS_E_SESSION_NOT_FOUND" },
897     { 0xFFFFFCC0, "NDPS_E_RPC_FAILURE" },
898     { 0xFFFFFCBF, "NDPS_E_DUPLICATE_VALUE" },
899     { 0xFFFFFCBE, "NDPS_E_PDS_REFUSES_RENAME" },
900     { 0xFFFFFCBD, "NDPS_E_NO_MANDATORY_ATTR" },
901     { 0xFFFFFCBC, "NDPS_E_ALREADY_ATTACHED" },
902     { 0xFFFFFCBB, "NDPS_E_CANT_ATTACH" },
903     { 0xFFFFFCBA, "NDPS_E_TOO_MANY_NW_SERVERS" },
904     { 0xFFFFFCB9, "NDPS_E_CANT_CREATE_DOC_FILE" },
905     { 0xFFFFFCB8, "NDPS_E_CANT_DELETE_DOC_FILE" },
906     { 0xFFFFFCB7, "NDPS_E_CANT_OPEN_DOC_FILE" },
907     { 0xFFFFFCB6, "NDPS_E_CANT_WRITE_DOC_FILE" },
908     { 0xFFFFFCB5, "NDPS_E_JOB_IS_ACTIVE" },
909     { 0xFFFFFCB4, "NDPS_E_NO_SCHEDULER" },
910     { 0xFFFFFCB3, "NDPS_E_CHANGING_CONNECTION" },
911     { 0xFFFFFCB2, "NDPS_E_COULD_NOT_CREATE_ACC_REF" },
912     { 0xFFFFFCB1, "NDPS_E_ACCTG_SVC_ERROR" },
913     { 0xFFFFFCB0, "NDPS_E_RMS_SVC_ERROR" },
914     { 0xFFFFFCAF, "NDPS_E_FAILED_VALIDATION" },
915     { 0xFFFFFCAE, "NDPS_E_BROKER_SRVR_CONNECTING" },
916     { 0xFFFFFCAD, "NDPS_E_SRS_SVC_ERROR" },
917     { 0xFFFFFD44, "JPM_W_EXECUTE_REQUEST_LATER" },
918     { 0xFFFFFD43, "JPM_E_FAILED_TO_OPEN_DOC" },
919     { 0xFFFFFD42, "JPM_E_FAILED_READ_DOC_FILE" },
920     { 0xFFFFFD41, "JPM_E_BAD_PA_HANDLE" },
921     { 0xFFFFFD40, "JPM_E_BAD_JOB_HANDLE" },
922     { 0xFFFFFD3F, "JPM_E_BAD_DOC_HANDLE" },
923     { 0xFFFFFD3E, "JPM_E_UNSUPPORTED_OP" },
924     { 0xFFFFFD3D, "JPM_E_REQUEST_QUEUE_FULL" },
925     { 0xFFFFFD3C, "JPM_E_PA_NOT_FOUND" },
926     { 0xFFFFFD3B, "JPM_E_INVALID_REQUEST" },
927     { 0xFFFFFD3A, "JPM_E_NOT_ACCEPTING_REQ" },
928     { 0xFFFFFD39, "JPM_E_PA_ALREADY_SERVICED_BY_PDS" },
929     { 0xFFFFFD38, "JPM_E_NO_JOB" },
930     { 0xFFFFFD37, "JPM_E_JOB_NOT_FOUND" },
931     { 0xFFFFFD36, "JPM_E_COULD_NOT_ACCESS_DATA_BASE" },
932     { 0xFFFFFD35, "JPM_E_BAD_OBJ_TYPE" },
933     { 0xFFFFFD34, "JPM_E_JOB_ALREADY_CLOSED" },
934     { 0xFFFFFD33, "JPM_E_DOC_ALREADY_CLOSED" },
935     { 0xFFFFFD32, "JPM_E_PH_NOT_REGISTERED" },
936     { 0xFFFFFD31, "JPM_E_VERSION_INCOMPATIBLE" },
937     { 0xFFFFFD30, "JPM_E_PA_PAUSED" },
938     { 0xFFFFFD2F, "JPM_E_PA_SHUTDOWN" },
939     { 0xFFFFFD2E, "JPM_E_NO_CLIB_CONTEXT" },
940     { 0xFFFFFD2D, "JPM_E_ACCOUNTING_ALREADY_SERVICE" },
941     { 0xFFFFFC7B, "DB_E_CANT_CREATE_FILE" },
942     { 0xFFFFFC7A, "DB_E_CANT_FIND_DATA_FILE" },
943     { 0xFFFFFC79, "DB_E_CANT_OPEN_DATA_FILE" },
944     { 0xFFFFFC78, "DB_E_CANT_OPEN_INDEX_FILE" },
945     { 0xFFFFFC77, "DB_E_INDEX_FILE_NOT_OPEN" },
946     { 0xFFFFFC76, "DB_E_CANT_RENAME_FILE" },
947     { 0xFFFFFC75, "DB_E_CANT_READ_DATA_FILE" },
948     { 0xFFFFFC74, "DB_E_CANT_READ_INDEX_FILE" },
949     { 0xFFFFFC73, "DB_E_CANT_WRITE_DATA_FILE" },
950     { 0xFFFFFC72, "DB_E_CANT_WRITE_INDEX_FILE" },
951     { 0xFFFFFC71, "DB_E_CANT_DELETE_PA_DIR" },
952     { 0xFFFFFC70, "DB_E_ALREADY_DELETED" },
953     { 0xFFFFFC6F, "DB_E_OBJECT_EXISTS" },
954     { 0xFFFFFC6E, "DB_E_DESCRIPTOR_IN_USE" },
955     { 0xFFFFFC6D, "DB_E_DESCRIPTOR_BEING_DELETED" },
956     { 0,          NULL }
957 };
958
959 static const value_string ndps_credential_enum[] = {
960     { 0, "SIMPLE" },
961     { 1, "CERTIFIED" },
962     { 2, "NDPS 0" },
963     { 3, "NDPS 1" },
964     { 4, "NDPS 2" },
965     { 0, NULL }
966 };
967
968 static int
969 align_4(tvbuff_t *tvb, int aoffset)
970 {
971        if(tvb_length_remaining(tvb, aoffset) > 4 )
972        {
973                 return (aoffset%4);
974        }
975        return 0;
976 }
977
978 static int
979 ndps_string(tvbuff_t* tvb, int hfinfo, proto_tree *ndps_tree, int offset)
980 {
981         int     foffset = offset;
982         guint32 str_length;
983         char    buffer[1024];
984         guint32 i;
985         guint16 c_char;
986         guint32 length_remaining = 0;
987         
988         str_length = tvb_get_ntohl(tvb, foffset);
989         foffset += 4;
990         length_remaining = tvb_length_remaining(tvb, foffset);
991         g_assert(length_remaining > 0);
992         if(str_length > (guint)length_remaining || str_length > 1024)
993         {
994                 proto_tree_add_string(ndps_tree, hfinfo, tvb, offset,
995                     length_remaining + 4, "<String too long to process>");
996                 foffset += length_remaining;
997                 return foffset;
998         }
999         if(str_length == 0)
1000         {
1001             proto_tree_add_string(ndps_tree, hfinfo, tvb, offset,
1002                 4, "<Not Specified>");
1003             return foffset;
1004         }
1005         for ( i = 0; i < str_length; i++ )
1006         {
1007                 c_char = tvb_get_guint8(tvb, foffset );
1008                 if (c_char<0x20 || c_char>0x7e)
1009                 {
1010                         if (c_char != 0x00)
1011                         { 
1012                                 c_char = 0x2e;
1013                                 buffer[i] = c_char & 0xff;
1014                         }
1015                         else
1016                         {
1017                                 i--;
1018                                 str_length--;
1019                         }
1020                 }
1021                 else
1022                 {
1023                         buffer[i] = c_char & 0xff;
1024                 }
1025                 foffset++;
1026                 length_remaining--;
1027                 
1028                 if(length_remaining==1)
1029                 {
1030                         i++;
1031                         break;
1032                 }        
1033         }
1034         buffer[i] = '\0';
1035         proto_tree_add_string(ndps_tree, hfinfo, tvb, offset,
1036                 str_length + 4, buffer);
1037         foffset += align_4(tvb, foffset);
1038         return foffset;
1039 }
1040
1041 static int
1042 objectident(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset)
1043 {
1044     guint8      h;
1045     guint8      object_count;
1046     guint32     object_type=0;
1047     guint32     qualified_name_type;
1048     proto_tree  *atree;
1049     proto_item  *aitem;
1050
1051     /*proto_tree_add_item(ndps_tree, hf_ndps_item_count, tvb, foffset, 4, FALSE);*/
1052     object_count = tvb_get_ntohl(tvb, foffset);
1053     
1054
1055     foffset += 4;
1056     object_type = tvb_get_ntohl(tvb, foffset); 
1057     aitem = proto_tree_add_item(ndps_tree, hf_obj_id_type, tvb, foffset, 4, FALSE);
1058     atree = proto_item_add_subtree(aitem, ett_ndps);
1059     foffset += 4;
1060     for (h = 1 ; h <= object_count; h++ )
1061     {
1062         switch(object_type)
1063         {
1064         case 0:         /* None */
1065             break;
1066         case 1:         /* Printer Contained Object ID */
1067             foffset = ndps_string(tvb, hf_printer_name, atree, foffset);
1068             proto_tree_add_item(atree, hf_ndps_object, tvb, foffset, 
1069             4, FALSE);
1070             foffset += 4;
1071             break;
1072         case 2:         /* Document Identifier */
1073             foffset = ndps_string(tvb, hf_printer_name, atree, foffset);
1074             proto_tree_add_item(atree, hf_ndps_object, tvb, foffset, 
1075             4, FALSE);
1076             foffset += 4;
1077             proto_tree_add_item(atree, hf_ndps_document_number, tvb, foffset, 
1078             4, FALSE);
1079             foffset += 4;
1080             break;
1081         case 3:         /* Object Identifier */
1082             proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1083             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1084             if (foffset > tvb_length_remaining(tvb, foffset)) {
1085                 return foffset;
1086             }
1087             foffset += 4;
1088             break;
1089         case 4:         /* Object Name */
1090             foffset = ndps_string(tvb, hf_object_name, atree, foffset);
1091             if (foffset > tvb_length_remaining(tvb, foffset)) {
1092                 return foffset;
1093             }
1094             proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1095             4, FALSE);
1096             foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1097             break;
1098         case 5:         /* Name or Object ID */
1099             proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1100             4, FALSE);
1101             foffset += 4;
1102             foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1103             break;
1104         case 6:         /* Simple Name */
1105             foffset = ndps_string(tvb, hf_object_name, atree, foffset);
1106             break;
1107         case 7:         /* Printer Configuration Object ID */
1108             foffset = ndps_string(tvb, hf_printer_name, atree, foffset);
1109             qualified_name_type = tvb_get_ntohl(tvb, foffset);
1110             proto_tree_add_uint(atree, hf_ndps_qualified_name, tvb, foffset, 
1111             4, qualified_name_type);
1112             foffset += 4;
1113             if (qualified_name_type != 0) {
1114                if (qualified_name_type == 1) {
1115                     foffset = ndps_string(tvb, hf_printer_name, atree, foffset);
1116                 }
1117                 else
1118                 {
1119                     foffset = ndps_string(tvb, hf_ndps_context, atree, foffset);
1120                     foffset = ndps_string(tvb, hf_ndps_tree, atree, foffset);
1121                 }
1122             }
1123             break;
1124         case 8:         /* Qualified Name */
1125             qualified_name_type = tvb_get_ntohl(tvb, foffset);
1126             proto_tree_add_uint(atree, hf_ndps_qualified_name, tvb, foffset, 
1127             4, qualified_name_type);
1128             foffset += 4;
1129             if (qualified_name_type != 0) {
1130                 if (qualified_name_type == 1) {
1131                     foffset = ndps_string(tvb, hf_printer_name, atree, foffset);
1132                 }
1133                 else
1134                 {
1135                     foffset = ndps_string(tvb, hf_ndps_context, atree, foffset);
1136                     foffset = ndps_string(tvb, hf_ndps_tree, atree, foffset);
1137                 }
1138             }
1139             break;
1140         case 9:         /* Event Object ID */
1141             foffset = ndps_string(tvb, hf_object_name, atree, foffset);
1142             proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1143             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1144             if (foffset > tvb_length_remaining(tvb, foffset)) {
1145                 return foffset;
1146             }
1147             foffset += 4;
1148         default:
1149             break;
1150         }
1151     }
1152     return foffset;
1153 }
1154
1155 static int
1156 address_item(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset)
1157 {
1158     guint32     address_type=0;
1159     guint32     qualified_name_type;
1160     guint32     transport_type=0;
1161     guint32     octet_len=0;
1162
1163     address_type = tvb_get_ntohl(tvb, foffset); 
1164     proto_tree_add_uint(ndps_tree, hf_address_type, tvb, foffset, 4, address_type);
1165     foffset += 4;
1166     switch(address_type)
1167     {
1168     case 0:
1169     case 1:
1170     case 2:
1171     case 3:
1172     case 4:
1173     case 5:
1174     case 6:
1175     case 7:
1176         qualified_name_type = tvb_get_ntohl(tvb, foffset);
1177         proto_tree_add_uint(ndps_tree, hf_ndps_qualified_name, tvb, foffset, 
1178         4, qualified_name_type);
1179         foffset += 4;
1180         if (qualified_name_type != 0) {
1181             if (qualified_name_type == 1) {
1182                 foffset = ndps_string(tvb, hf_printer_name, ndps_tree, foffset);
1183             }
1184             else
1185             {
1186                 foffset = ndps_string(tvb, hf_ndps_context, ndps_tree, foffset);
1187                 foffset = ndps_string(tvb, hf_ndps_tree, ndps_tree, foffset);
1188             }
1189         }
1190         break;
1191     case 8:
1192     case 9:
1193     case 10:
1194     case 11:
1195     case 12:
1196         foffset = ndps_string(tvb, hf_object_name, ndps_tree, foffset);
1197         break;
1198     case 13:
1199         proto_tree_add_item(ndps_tree, hf_ndps_attrib_boolean, tvb, foffset, 4, FALSE);
1200         foffset += 4;
1201         break;
1202     case 14:
1203         proto_tree_add_item(ndps_tree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1204         foffset += 4;
1205         break;
1206     case 15:
1207         transport_type=tvb_get_ntohl(tvb, foffset);
1208         proto_tree_add_item(ndps_tree, hf_ndps_address, tvb, foffset, 4, FALSE);
1209         foffset += 4;
1210         octet_len = tvb_get_ntohl(tvb, foffset);
1211         proto_tree_add_item(ndps_tree, hf_ndps_add_bytes, tvb, foffset, 4, FALSE);
1212         foffset += octet_len + 4;
1213         break;
1214     case 16:
1215     case 17:
1216     default:
1217         foffset = ndps_string(tvb, hf_object_name, ndps_tree, foffset);
1218         break;
1219     }
1220     return foffset;
1221 }
1222
1223 static int
1224 attribute_value(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset)
1225 {
1226     guint8      h;
1227     guint8      i;
1228     guint8      j;
1229     guint8      number_of_values=0;
1230     guint8      number_of_items=0;
1231     guint8      number_of_items2=0;
1232     guint32     attribute_type=0;
1233     guint32     qualified_name_type;
1234     guint32     integer_or_oid;
1235     guint32     event_object_type;
1236     proto_tree  *atree;
1237     proto_item  *aitem;
1238     proto_tree  *btree;
1239     proto_item  *bitem;
1240     proto_tree  *ctree;
1241     proto_item  *citem;
1242
1243     number_of_values = tvb_get_ntohl(tvb, foffset);
1244     foffset += 4;
1245     attribute_type = tvb_get_ntohl(tvb, foffset); 
1246     aitem = proto_tree_add_item(ndps_tree, hf_obj_attribute_type, tvb, foffset, 4, FALSE);
1247     atree = proto_item_add_subtree(aitem, ett_ndps);
1248     foffset += 4;
1249     for (h = 1 ; h <= number_of_values; h++ )
1250     {
1251         switch(attribute_type)
1252         {
1253         case 0:         /* Null */
1254             break;
1255         case 1:         /* Text */
1256         case 2:         /* Descriptive Name */
1257         case 3:         /* Descriptor */
1258         case 6:         /* Simple Name */
1259         case 40:         /* Distinguished Name */
1260         case 50:         /* Font Reference */
1261         case 58:         /* Locale */
1262         case 102:         /* File Path */
1263         case 103:         /* Uniform Resource Identifier */
1264         case 108:         /* Extended Resource Identifier */
1265             foffset = ndps_string(tvb, hf_object_name, atree, foffset);
1266             break;
1267         case 4:         /* Message */
1268         case 5:         /* Error Message */
1269         case 38:         /* Name or OID */
1270             proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1271             4, FALSE);
1272             foffset += 4;
1273             foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1274             break;
1275         case 7:         /* Distinguished Name */
1276             foffset = ndps_string(tvb, hf_object_name, atree, foffset);
1277             proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1278             4, FALSE);
1279             foffset += 4;
1280             foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1281             break;
1282         case 8:         /* Distinguished Name Seq */
1283         case 39:         /* Name or OID Seq */
1284             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1285             btree = proto_item_add_subtree(bitem, ett_ndps);
1286             number_of_items = tvb_get_ntohl(tvb, foffset);
1287             foffset += 4;
1288             for (i = 1 ; i <= number_of_items; i++ )
1289             {
1290                 foffset = ndps_string(tvb, hf_object_name, btree, foffset);
1291             }
1292             proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1293             4, FALSE);
1294             foffset += 4;
1295             foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1296             break;
1297         case 9:         /* Delta Time */
1298         case 10:         /* Time */
1299         case 11:         /* Integer */
1300         case 13:         /* Cardinal */
1301         case 15:         /* Positive Integer */
1302         case 18:         /* Maximum Integer */
1303         case 19:         /* Minimum Integer */
1304         case 35:         /* Percent */
1305         case 57:         /* Priority */
1306         case 72:         /* Sides */
1307         case 95:         /* Enumeration */
1308             proto_tree_add_item(atree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1309             foffset += 4;
1310             break;
1311         case 12:         /* Integer Seq */
1312         case 14:         /* Cardinal Seq */
1313             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1314             btree = proto_item_add_subtree(bitem, ett_ndps);
1315             number_of_items = tvb_get_ntohl(tvb, foffset);
1316             foffset += 4;
1317             for (i = 1 ; i <= number_of_items; i++ )
1318             {
1319                 proto_tree_add_item(btree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1320                 foffset += 4;
1321             }
1322             break;
1323         case 16:         /* Integer Range */
1324         case 17:         /* Cardinal Range */
1325             proto_tree_add_item(atree, hf_ndps_lower_range, tvb, foffset, 4, FALSE);
1326             foffset += 4;
1327             proto_tree_add_item(atree, hf_ndps_upper_range, tvb, foffset, 4, FALSE);
1328             foffset += 4;
1329             break;
1330         case 20:         /* Integer 64 */
1331         case 22:         /* Cardinal 64 */
1332         case 24:         /* Positive Integer 64 */
1333         case 31:         /* Non-Negative Real */
1334         case 29:         /* Real */
1335             proto_tree_add_item(atree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1336             foffset += 8;
1337             break;
1338         case 21:         /* Integer 64 Seq */
1339         case 23:         /* Cardinal 64 Seq */
1340         case 30:         /* Real Seq */
1341             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1342             btree = proto_item_add_subtree(bitem, ett_ndps);
1343             number_of_items = tvb_get_ntohl(tvb, foffset);
1344             foffset += 4;
1345             for (i = 1 ; i <= number_of_items; i++ )
1346             {
1347                 proto_tree_add_item(btree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1348                 foffset += 8;
1349             }
1350             break;
1351         case 25:         /* Integer 64 Range */
1352         case 26:         /* Cardinal 64 Range */
1353         case 32:         /* Real Range */
1354         case 33:         /* Non-Negative Real Range */
1355             proto_tree_add_item(atree, hf_ndps_lower_range_n64, tvb, foffset, 4, FALSE);
1356             foffset += 8;
1357             proto_tree_add_item(atree, hf_ndps_upper_range_n64, tvb, foffset, 4, FALSE);
1358             foffset += 8;
1359             break;
1360         case 27:         /* Maximum Integer 64 */
1361             proto_tree_add_item(atree, hf_ndps_lower_range_n64, tvb, foffset, 4, FALSE);
1362             foffset += 8;
1363             break;
1364         case 28:         /* Minimum Integer 64 */
1365             proto_tree_add_item(atree, hf_ndps_upper_range_n64, tvb, foffset, 4, FALSE);
1366             foffset += 8;
1367             break;
1368         case 34:         /* Boolean */
1369             proto_tree_add_item(atree, hf_ndps_attrib_boolean, tvb, foffset, 4, FALSE);
1370             foffset += 4;
1371             break;
1372         case 36:         /* Object Identifier */
1373             proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1374             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1375             if (foffset > tvb_length_remaining(tvb, foffset)) {
1376                 break;
1377             }
1378             foffset += 4;
1379             break;
1380         case 37:         /* Object Identifier Seq */
1381             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1382             btree = proto_item_add_subtree(bitem, ett_ndps);
1383             number_of_items = tvb_get_ntohl(tvb, foffset);
1384             foffset += 4;
1385             for (i = 1 ; i <= number_of_items; i++ )
1386             {
1387                 proto_tree_add_item(btree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1388                 foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1389                 if (foffset > tvb_length_remaining(tvb, foffset)) {
1390                     break;
1391                 }
1392                 foffset += 4;
1393             }
1394             break;
1395         case 41:         /* Relative Distinguished Name Seq */
1396             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1397             btree = proto_item_add_subtree(bitem, ett_ndps);
1398             number_of_items = tvb_get_ntohl(tvb, foffset);
1399             foffset += 4;
1400             for (i = 1 ; i <= number_of_items; i++ )
1401             {
1402                 foffset = ndps_string(tvb, hf_object_name, btree, foffset);
1403             }
1404             break;
1405         case 42:         /* Realization */
1406             proto_tree_add_item(atree, hf_ndps_realization, tvb, foffset, 4, FALSE);
1407             foffset += 4;
1408             break;
1409         case 43:         /* Medium Dimensions */
1410             proto_tree_add_item(atree, hf_ndps_xdimension_n64, tvb, foffset, 4, FALSE);
1411             foffset += 8;
1412             proto_tree_add_item(atree, hf_ndps_ydimension_n64, tvb, foffset, 4, FALSE);
1413             foffset += 8;
1414             break;
1415         case 44:         /* Dimension */
1416             proto_tree_add_item(atree, hf_ndps_dim_value, tvb, foffset, 8, FALSE);
1417             foffset += 4;
1418             if (tvb_get_ntohl(tvb, foffset-4) == 0) {
1419                 proto_tree_add_item(atree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1420                 foffset += 8;
1421             }
1422             else
1423             {
1424                 proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1425                 4, FALSE);
1426                 foffset += 4;
1427                 foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1428             }
1429             proto_tree_add_item(atree, hf_ndps_dim_flag, tvb, foffset, 8, FALSE);
1430             foffset += 4;
1431             proto_tree_add_item(atree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1432             foffset += 8;
1433             break;
1434         case 45:         /* XY Dimensions */
1435             proto_tree_add_item(atree, hf_ndps_xydim_value, tvb, foffset, 8, FALSE);
1436             foffset += 4;
1437             if (tvb_get_ntohl(tvb, foffset-4) == 1) {
1438                 proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1439                 4, FALSE);
1440                 foffset += 4;
1441                 foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1442             }
1443             else
1444             {
1445                 proto_tree_add_item(atree, hf_ndps_xdimension_n64, tvb, foffset, 4, FALSE);
1446                 foffset += 8;
1447                 proto_tree_add_item(atree, hf_ndps_ydimension_n64, tvb, foffset, 4, FALSE);
1448                 foffset += 8;
1449             }
1450             proto_tree_add_item(atree, hf_ndps_dim_flag, tvb, foffset, 8, FALSE);
1451             foffset += 4;
1452             proto_tree_add_item(atree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1453             foffset += 8;
1454             break;
1455         case 46:         /* Locations */
1456             proto_tree_add_item(atree, hf_ndps_location_value, tvb, foffset, 8, FALSE);
1457             foffset += 4;
1458             if (tvb_get_ntohl(tvb, foffset-4) == 0) {
1459                 bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1460                 btree = proto_item_add_subtree(bitem, ett_ndps);
1461                 number_of_items = tvb_get_ntohl(tvb, foffset);
1462                 foffset += 4;
1463                 for (i = 1 ; i <= number_of_items; i++ )
1464                 {
1465                     proto_tree_add_item(btree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1466                     foffset += 8;
1467                 }
1468             }
1469             else
1470             {
1471                 proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1472                 4, FALSE);
1473                 foffset += 4;
1474                 foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1475             }
1476             proto_tree_add_item(atree, hf_ndps_dim_flag, tvb, foffset, 8, FALSE);
1477             foffset += 4;
1478             proto_tree_add_item(atree, hf_ndps_n64, tvb, foffset, 8, FALSE);
1479             foffset += 8;
1480             break;
1481         case 47:         /* Area */
1482             proto_tree_add_item(atree, hf_ndps_xmin_n64, tvb, foffset, 8, FALSE);
1483             foffset += 8;
1484             proto_tree_add_item(atree, hf_ndps_xmax_n64, tvb, foffset, 8, FALSE);
1485             foffset += 8;
1486             proto_tree_add_item(atree, hf_ndps_ymin_n64, tvb, foffset, 8, FALSE);
1487             foffset += 8;
1488             proto_tree_add_item(atree, hf_ndps_ymax_n64, tvb, foffset, 8, FALSE);
1489             foffset += 8;
1490             break;
1491         case 48:         /* Area Seq */
1492             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1493             btree = proto_item_add_subtree(bitem, ett_ndps);
1494             number_of_items = tvb_get_ntohl(tvb, foffset);
1495             foffset += 4;
1496             for (i = 1 ; i <= number_of_items; i++ )
1497             {
1498                 proto_tree_add_item(btree, hf_ndps_xmin_n64, tvb, foffset, 8, FALSE);
1499                 foffset += 8;
1500                 proto_tree_add_item(btree, hf_ndps_xmax_n64, tvb, foffset, 8, FALSE);
1501                 foffset += 8;
1502                 proto_tree_add_item(btree, hf_ndps_ymin_n64, tvb, foffset, 8, FALSE);
1503                 foffset += 8;
1504                 proto_tree_add_item(btree, hf_ndps_ymax_n64, tvb, foffset, 8, FALSE);
1505                 foffset += 8;
1506             }
1507             break;
1508         case 49:         /* Edge */
1509             proto_tree_add_item(atree, hf_ndps_edge_value, tvb, foffset, 4, FALSE);
1510             foffset += 4;
1511             break;
1512         case 51:         /* Cardinal or OID */
1513             proto_tree_add_item(atree, hf_ndps_cardinal_or_oid, tvb, foffset, 4, FALSE);
1514             foffset += 4;
1515             if (tvb_get_ntohl(tvb, foffset-4)==0) {
1516                 proto_tree_add_item(atree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1517                 foffset += 4;
1518             }
1519             else
1520             {
1521                 proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1522                 foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1523                 if (foffset > tvb_length_remaining(tvb, foffset)) {
1524                     break;
1525                 }
1526                 foffset += 4;
1527             }
1528             break;
1529         case 52:         /* OID Cardinal Map */
1530             proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1531             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1532             if (foffset > tvb_length_remaining(tvb, foffset)) {
1533                 break;
1534             }
1535             foffset += 4;
1536             proto_tree_add_item(atree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1537             foffset += 4;
1538             break;
1539         case 53:         /* Cardinal or Name or OID */
1540             proto_tree_add_item(atree, hf_ndps_cardinal_name_or_oid, tvb, foffset, 4, FALSE);
1541             foffset += 4;
1542             if (tvb_get_ntohl(tvb, foffset-4)==0) {
1543                 proto_tree_add_item(atree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1544                 foffset += 4;
1545             }
1546             else
1547             {
1548                 proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
1549                 4, FALSE);
1550                 foffset += 4;
1551                 foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
1552             }
1553             break;
1554         case 54:         /* Positive Integer or OID */
1555             integer_or_oid = tvb_get_ntohl(tvb, foffset);
1556             proto_tree_add_uint(atree, hf_ndps_integer_or_oid, tvb, foffset, 4, integer_or_oid);
1557             foffset += 4;
1558             if (integer_or_oid==0) {
1559                 proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1560                 foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1561                 if (foffset > tvb_length_remaining(tvb, foffset)) {
1562                     break;
1563                 }
1564                 foffset += 4;
1565             }
1566             else
1567             {
1568                 proto_tree_add_item(atree, hf_ndps_attribute_value, tvb, foffset, 4, FALSE);
1569                 foffset += 4;
1570             }
1571             break;
1572         case 55:         /* Event Handling Profile */
1573             proto_tree_add_item(atree, hf_ndps_profile_id, tvb, foffset, 4, FALSE);
1574             foffset += 4;
1575             proto_tree_add_item(atree, hf_ndps_persistence, tvb, foffset, 4, FALSE);
1576             foffset += 4;
1577             qualified_name_type = tvb_get_ntohl(tvb, foffset);
1578             proto_tree_add_uint(atree, hf_ndps_qualified_name, tvb, foffset, 
1579             4, qualified_name_type);
1580             foffset += 4;
1581             if (qualified_name_type != 0) {
1582                 if (qualified_name_type == 1) {
1583                     foffset = ndps_string(tvb, hf_printer_name, atree, foffset);
1584                 }
1585                 else
1586                 {
1587                     foffset = ndps_string(tvb, hf_ndps_context, atree, foffset);
1588                     foffset = ndps_string(tvb, hf_ndps_tree, atree, foffset);
1589                 }
1590             }
1591             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1592             btree = proto_item_add_subtree(bitem, ett_ndps);
1593             number_of_items = tvb_get_ntohl(tvb, foffset);
1594             foffset += 4;
1595             for (i = 1 ; i <= number_of_items; i++ )
1596             {
1597                 proto_tree_add_item(btree, hf_ndps_language_id, tvb, foffset, 4, FALSE);
1598                 foffset += 4;
1599                 proto_tree_add_item(btree, hf_ndps_nameorid, tvb, foffset, 
1600                 4, FALSE);
1601                 foffset += 4;
1602                 foffset = ndps_string(tvb, hf_local_object_name, btree, foffset);
1603             }
1604             bitem = proto_tree_add_item(atree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1605             btree = proto_item_add_subtree(bitem, ett_ndps);
1606             number_of_items = tvb_get_ntohl(tvb, foffset);
1607             foffset += 4;
1608             for (i = 1 ; i <= number_of_items; i++ )
1609             {
1610                 foffset += address_item(tvb, btree, foffset);
1611                 /*proto_tree_add_item(btree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
1612                 foffset += 4;*/
1613                 proto_tree_add_item(btree, hf_ndps_event_type, tvb, foffset, 4, FALSE);
1614                 foffset += 4;
1615                 event_object_type = tvb_get_ntohl(tvb, foffset);
1616                 proto_tree_add_uint(btree, hf_ndps_event_object_identifier, tvb, foffset, 4, event_object_type);
1617                 foffset += 4;
1618                 if(event_object_type==0)
1619                 {
1620                     proto_tree_add_item(btree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1621                     foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1622                     if (foffset > tvb_length_remaining(tvb, foffset)) {
1623                         break;
1624                     }
1625                     foffset += 4;
1626                 }
1627                 else
1628                 {
1629                     number_of_items2 = tvb_get_ntohl(tvb, foffset);
1630                     citem = proto_tree_add_uint(btree, hf_ndps_item_count, tvb, foffset, 4, number_of_items2);
1631                     ctree = proto_item_add_subtree(citem, ett_ndps);
1632                     foffset += 4;
1633                     for (j = 1 ; j <= number_of_items2; j++ )
1634                     {
1635                         proto_tree_add_item(ctree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
1636                         foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
1637                         if (foffset > tvb_length_remaining(tvb, foffset)) {
1638                             break;
1639                         }
1640                         foffset += 4;
1641                         qualified_name_type = tvb_get_ntohl(tvb, foffset);
1642                         proto_tree_add_uint(ctree, hf_ndps_qualified_name, tvb, foffset, 
1643                         4, qualified_name_type);
1644                         foffset += 4;
1645                         if (qualified_name_type != 0) {
1646                             if (qualified_name_type == 1) {
1647                                 foffset = ndps_string(tvb, hf_printer_name, ctree, foffset);
1648                             }
1649                             else
1650                             {
1651                                 foffset = ndps_string(tvb, hf_ndps_context, ctree, foffset);
1652                                 foffset = ndps_string(tvb, hf_ndps_tree, ctree, foffset);
1653                             }
1654                         }
1655                     }
1656                 }
1657             }
1658             break;
1659         case 56:         /* Octet String */
1660             proto_tree_add_item(atree, hf_ndps_octet_string, tvb, foffset, 4, FALSE);
1661             break;
1662         case 59:         /* Method Delivery Address */
1663         case 60:         /* Object Identification */
1664         case 61:         /* Results Profile */
1665         case 62:         /* Criteria */
1666         case 63:         /* Job Password */
1667         case 64:         /* Job Level */
1668         case 65:         /* Job Categories */
1669         case 66:         /* Print Checkpoint */
1670         case 67:         /* Ignored Attribute */
1671         case 68:         /* Resource */
1672         case 69:         /* Medium Substitution */
1673         case 70:         /* Font Substitution */
1674         case 71:         /* Resource Context Seq */
1675         case 73:         /* Page Select Seq */
1676         case 74:         /* Page Media Select */
1677         case 75:         /* Document Content */
1678         case 76:         /* Page Size */
1679         case 77:         /* Presentation Direction */
1680         case 78:         /* Page Order */
1681         case 79:         /* File Reference */
1682         case 80:         /* Medium Source Size */
1683         case 81:         /* Input Tray Medium */
1684         case 82:         /* Output Bins Chars */
1685         case 83:         /* Page ID Type */
1686         case 84:         /* Level Range */
1687         case 85:         /* Category Set */
1688         case 86:         /* Numbers Up Supported */
1689         case 87:         /* Finishing */
1690         case 88:         /* Print Contained Object ID */
1691         case 89:         /* Print Config Object ID */
1692         case 90:         /* Typed Name */
1693         case 91:         /* Network Address */
1694         case 92:         /* XY Dimensions Value */
1695         case 93:         /* Name or OID Dimensions Map */
1696         case 94:         /* Printer State Reason */
1697         case 96:         /* Qualified Name */
1698         case 97:         /* Qualified Name Set */
1699         case 98:         /* Colorant Set */
1700         case 99:         /* Resource Printer ID */
1701         case 100:         /* Event Object ID */
1702         case 101:         /* Qualified Name Map */
1703         case 104:         /* Cardinal or Enum or Time */
1704         case 105:         /* Print Contained Object ID Set */
1705         case 106:         /* Octet String Pair */
1706         case 107:         /* Octet String Integer Pair */
1707         case 109:         /* Event Handling Profile 2 */
1708         default:
1709             break;
1710         }
1711     }
1712     return foffset;
1713 }
1714
1715
1716 /* NDPS packets come in request/reply pairs. The request packets tell the 
1717  * Function and Program numbers. The response, unfortunately, only
1718  * identifies itself via the Exchange ID; you have to know what type of NDPS
1719  * request the request packet contained in order to successfully parse the 
1720  * response. A global method for doing this does not exist in ethereal yet
1721  * (NFS also requires it), so for now the NDPS section will keep its own hash
1722  * table keeping track of NDPS packets.
1723  *
1724  * We construct a conversation specified by the client and server
1725  * addresses and the connection number; the key representing the unique
1726  * NDPS request then is composed of the pointer to the conversation
1727  * structure, cast to a "guint" (which may throw away the upper 32
1728  * bits of the pointer on a P64 platform, but the low-order 32 bits
1729  * are more likely to differ between conversations than the upper 32 bits),
1730  * and the sequence number.
1731  *
1732  * The value stored in the hash table is the ncp_req_hash_value pointer. This
1733  * struct tells us the NDPS Program and Function and gives the NDPS_record pointer.
1734  */
1735 typedef struct {
1736         conversation_t  *conversation;
1737         guint32             ndps_xid;
1738 } ndps_req_hash_key;
1739
1740 typedef struct {
1741         guint32             ndps_prog;
1742         guint32                     ndps_func;
1743 } ndps_req_hash_value;
1744
1745 static GHashTable *ndps_req_hash = NULL;
1746 static GMemChunk *ndps_req_hash_keys = NULL;
1747 static GMemChunk *ndps_req_hash_values = NULL;
1748
1749 /* Hash Functions */
1750 gint
1751 ndps_equal(gconstpointer v, gconstpointer v2)
1752 {
1753         const ndps_req_hash_key *val1 = (const ndps_req_hash_key*)v;
1754         const ndps_req_hash_key *val2 = (const ndps_req_hash_key*)v2;
1755
1756         if (val1->conversation == val2->conversation &&
1757             val1->ndps_xid  == val2->ndps_xid ) {
1758                 return 1;
1759         }
1760         return 0;
1761 }
1762
1763 guint
1764 ndps_hash(gconstpointer v)
1765 {
1766         const ndps_req_hash_key *ndps_key = (const ndps_req_hash_key*)v;
1767         return GPOINTER_TO_UINT(ndps_key->conversation) + ndps_key->ndps_xid;
1768 }
1769
1770 /* Frees memory used by the ndps_req_hash_value's */
1771 static void
1772 ndps_req_hash_cleanup(gpointer key _U_, gpointer value, gpointer user_data _U_)
1773 {
1774         ndps_req_hash_value     *request_value = (ndps_req_hash_value*) value;
1775
1776         /*if (request_value->ndps_func) {
1777                 g_free(request_value->ndps_func);
1778         }*/
1779 }
1780
1781 /* Initializes the hash table and the mem_chunk area each time a new
1782  * file is loaded or re-loaded in ethereal */
1783 static void
1784 ndps_init_protocol(void)
1785 {
1786         if (ndps_req_hash) {
1787                 g_hash_table_foreach(ndps_req_hash, ndps_req_hash_cleanup, NULL);
1788                 g_hash_table_destroy(ndps_req_hash);
1789         }
1790         if (ndps_req_hash_keys)
1791                 g_mem_chunk_destroy(ndps_req_hash_keys);
1792         if (ndps_req_hash_values)
1793                 g_mem_chunk_destroy(ndps_req_hash_values);
1794
1795         ndps_req_hash = g_hash_table_new(ndps_hash, ndps_equal);
1796         ndps_req_hash_keys = g_mem_chunk_new("ndps_req_hash_keys",
1797                         sizeof(ndps_req_hash_key),
1798                         NDPS_PACKET_INIT_COUNT * sizeof(ndps_req_hash_key),
1799                         G_ALLOC_ONLY);
1800         ndps_req_hash_values = g_mem_chunk_new("ndps_req_hash_values",
1801                         sizeof(ndps_req_hash_value),
1802                         NDPS_PACKET_INIT_COUNT * sizeof(ndps_req_hash_value),
1803                         G_ALLOC_ONLY);
1804 }
1805
1806 /* After the sequential run, we don't need the ncp_request hash and keys
1807  * anymore; the lookups have already been done and the vital info
1808  * saved in the reply-packets' private_data in the frame_data struct. */
1809 static void
1810 ndps_postseq_cleanup(void)
1811 {
1812         if (ndps_req_hash) {
1813                 /* Destroy the hash, but don't clean up request_condition data. */
1814                 g_hash_table_destroy(ndps_req_hash);
1815                 ndps_req_hash = NULL;
1816         }
1817         if (ndps_req_hash_keys) {
1818                 g_mem_chunk_destroy(ndps_req_hash_keys);
1819                 ndps_req_hash_keys = NULL;
1820         }
1821         /* Don't free the ncp_req_hash_values, as they're
1822          * needed during random-access processing of the proto_tree.*/
1823 }
1824
1825 ndps_req_hash_value*
1826 ndps_hash_insert(conversation_t *conversation, guint32 ndps_xid)
1827 {
1828         ndps_req_hash_key               *request_key;
1829         ndps_req_hash_value             *request_value;
1830
1831         /* Now remember the request, so we can find it if we later
1832            a reply to it. */
1833         request_key = g_mem_chunk_alloc(ndps_req_hash_keys);
1834         request_key->conversation = conversation;
1835         request_key->ndps_xid = ndps_xid;
1836
1837         request_value = g_mem_chunk_alloc(ndps_req_hash_values);
1838     request_value->ndps_prog = 0;
1839         request_value->ndps_func = 0;
1840        
1841     g_hash_table_insert(ndps_req_hash, request_key, request_value);
1842
1843         return request_value;
1844 }
1845
1846 /* Returns the ncp_rec*, or NULL if not found. */
1847 ndps_req_hash_value*
1848 ndps_hash_lookup(conversation_t *conversation, guint32 ndps_xid)
1849 {
1850         ndps_req_hash_key               request_key;
1851
1852         request_key.conversation = conversation;
1853         request_key.ndps_xid = ndps_xid;
1854
1855         return g_hash_table_lookup(ndps_req_hash, &request_key);
1856 }
1857
1858 /* ================================================================= */
1859 /* NDPS                                                               */
1860 /* ================================================================= */
1861
1862 static void
1863 dissect_ndps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1864 {
1865     proto_tree  *ndps_tree = NULL;
1866     proto_item  *ti;
1867         
1868     guint16     record_mark;
1869     guint16     ndps_length;
1870     guint32     ndps_xid;
1871     guint32     ndps_prog;
1872     guint32     ndps_packet_type;
1873     guint32     ndps_rpc_version;
1874     int         foffset;
1875     guint32     ndps_hfname;
1876     guint32     ndps_func;
1877     const char  *ndps_program_string;
1878     const char  *ndps_func_string;
1879
1880     if (check_col(pinfo->cinfo, COL_PROTOCOL))
1881         col_set_str(pinfo->cinfo, COL_PROTOCOL, "NDPS");
1882
1883     if (check_col(pinfo->cinfo, COL_INFO))
1884         col_clear(pinfo->cinfo, COL_INFO);
1885         
1886     foffset = 0;
1887     if (tree) {
1888         ti = proto_tree_add_item(tree, proto_ndps, tvb, foffset, -1, FALSE);
1889         ndps_tree = proto_item_add_subtree(ti, ett_ndps);
1890     }
1891     if (tvb_length_remaining(tvb, foffset) >= 28)
1892     {
1893         record_mark = tvb_get_ntohs(tvb, foffset);
1894         if (tvb_get_ntohl(tvb, foffset+4) == 0x00000065) /* Check xid if not 65 then fragment packet */
1895         {
1896             /*
1897              * XXX - what is the significance of the record mark?
1898              * Are the first 4 bytes a 31-bit record length plus a
1899              * 1-bit record mark of some sort?  Is that used in case
1900              * something has to be transferred over SPX that's
1901              * bigger than the biggest SPX frame, with the record
1902              * mark being a "last fragment" indication?
1903              */
1904             proto_tree_add_uint(ndps_tree, hf_ndps_record_mark, tvb,
1905                            foffset, 2, record_mark);
1906             foffset += 2;
1907             ndps_length = tvb_get_ntohs(tvb, foffset);
1908             proto_tree_add_uint(ndps_tree, hf_ndps_length, tvb,
1909                            foffset, 2, ndps_length);
1910             foffset += 2;
1911             ndps_xid = tvb_get_ntohl(tvb, foffset);
1912             proto_tree_add_uint(ndps_tree, hf_ndps_xid, tvb, foffset, 4, ndps_xid);
1913             foffset += 4;
1914             ndps_packet_type = tvb_get_ntohl(tvb, foffset);
1915             proto_tree_add_uint(ndps_tree, hf_ndps_packet_type, tvb, foffset, 4, ndps_packet_type);
1916             foffset += 4;
1917             if(ndps_packet_type == 0x00000001)          /* Reply packet */
1918             {
1919                 if (check_col(pinfo->cinfo, COL_INFO))
1920                     col_set_str(pinfo->cinfo, COL_INFO, "R NDPS ");
1921                 proto_tree_add_item(ndps_tree, hf_ndps_rpc_accept, tvb, foffset, 4, FALSE);
1922                 if (tvb_get_ntohl(tvb, foffset)==0) {
1923                     foffset += 4;
1924                     proto_tree_add_item(ndps_tree, hf_ndps_auth_null, tvb, foffset, 8, FALSE);
1925                     foffset += 8;
1926                 }
1927                 else
1928                 {
1929                     foffset += 4;
1930                     proto_tree_add_item(ndps_tree, hf_ndps_rpc_rej_stat, tvb, foffset+4, 4, FALSE);
1931                     foffset += 4;
1932                 }
1933                 dissect_ndps_reply(tvb, pinfo, ndps_tree, ndps_xid, foffset);
1934             }
1935             else
1936             {
1937                 if (check_col(pinfo->cinfo, COL_INFO))
1938                     col_set_str(pinfo->cinfo, COL_INFO, "C NDPS ");
1939                 ndps_rpc_version = tvb_get_ntohl(tvb, foffset);
1940                 proto_tree_add_item(ndps_tree, hf_ndps_rpc_version, tvb, foffset, 4, FALSE);
1941                 foffset += 4;
1942                 ndps_prog = tvb_get_ntohl(tvb, foffset);
1943                 ndps_program_string = match_strval(ndps_prog, spx_ndps_program_vals);
1944                 if( ndps_program_string != NULL)
1945                 {
1946                     proto_tree_add_item(ndps_tree, hf_spx_ndps_program, tvb, foffset, 4, FALSE);
1947                     foffset += 4;
1948                     if (check_col(pinfo->cinfo, COL_INFO))
1949                     {
1950                         col_append_str(pinfo->cinfo, COL_INFO, (const gchar*) ndps_program_string);
1951                         col_append_str(pinfo->cinfo, COL_INFO, ", ");
1952                     }
1953                     proto_tree_add_item(ndps_tree, hf_spx_ndps_version, tvb, foffset, 4, FALSE);
1954                     foffset += 4;
1955                     ndps_func = tvb_get_ntohl(tvb, foffset);
1956                     switch(ndps_prog)
1957                     {
1958                         case 0x060976:
1959                             ndps_hfname = hf_spx_ndps_func_print;
1960                             ndps_func_string = match_strval(ndps_func, spx_ndps_print_func_vals);
1961                             break;
1962                         case 0x060977:
1963                             ndps_hfname = hf_spx_ndps_func_broker;
1964                             ndps_func_string = match_strval(ndps_func, spx_ndps_broker_func_vals);
1965                             break;
1966                         case 0x060978:
1967                             ndps_hfname = hf_spx_ndps_func_registry;
1968                             ndps_func_string = match_strval(ndps_func, spx_ndps_registry_func_vals);
1969                             break;
1970                         case 0x060979:
1971                             ndps_hfname = hf_spx_ndps_func_notify;
1972                             ndps_func_string = match_strval(ndps_func, spx_ndps_notify_func_vals);
1973                             break;
1974                         case 0x06097a:
1975                             ndps_hfname = hf_spx_ndps_func_resman;
1976                             ndps_func_string = match_strval(ndps_func, spx_ndps_resman_func_vals);
1977                             break;
1978                         case 0x06097b:
1979                             ndps_hfname = hf_spx_ndps_func_delivery;
1980                             ndps_func_string = match_strval(ndps_func, spx_ndps_deliver_func_vals);
1981                             break;
1982                         default:
1983                             ndps_hfname = 0;
1984                             ndps_func_string = NULL;
1985                             break;
1986                     }
1987                     if(ndps_hfname != 0)
1988                     {
1989                         proto_tree_add_item(ndps_tree, ndps_hfname, tvb, foffset, 4, FALSE);
1990                         if (ndps_func_string != NULL) 
1991                         {
1992                             if (check_col(pinfo->cinfo, COL_INFO))
1993                                 col_append_str(pinfo->cinfo, COL_INFO, (const gchar*) ndps_func_string);
1994
1995                             foffset += 4;
1996                             proto_tree_add_item(ndps_tree, hf_ndps_auth_null, tvb, foffset, 16, FALSE);
1997                             foffset+=16;
1998                             dissect_ndps_request(tvb, pinfo, ndps_tree, ndps_xid, ndps_prog, ndps_func, foffset);
1999                         }
2000                     }
2001                 }
2002             }
2003         }
2004         else
2005         {
2006             if (check_col(pinfo->cinfo, COL_INFO))
2007                 col_append_str(pinfo->cinfo, COL_INFO, "Continuation Fragment");
2008         }
2009     }
2010 }
2011
2012 static guint
2013 get_ndps_pdu_len(tvbuff_t *tvb, int offset)
2014 {
2015     guint16 plen;
2016
2017     /*
2018      * Get the length of the NDPS packet.
2019      */
2020     plen = tvb_get_ntohs(tvb, offset + 2);
2021
2022     /*
2023      * That length doesn't include the length of the record mark field
2024      * or the length field itself; add that in.
2025      * (XXX - is the field really a 31-bit length with the uppermost bit
2026      * being a record mark bit?)
2027      */
2028     return plen + 4;
2029 }
2030
2031 static void
2032 dissect_ndps_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2033 {
2034     tcp_dissect_pdus(tvb, pinfo, tree, ndps_desegment, 4, get_ndps_pdu_len,
2035         dissect_ndps);
2036 }
2037
2038 static void
2039 dissect_ndps_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ndps_tree, guint32 ndps_xid, guint32 ndps_prog, guint32 ndps_func, int foffset)
2040 {
2041     ndps_req_hash_value *request_value = NULL;
2042     conversation_t              *conversation;
2043     guint32             name_len;
2044     guint32             cred_type;
2045
2046     if (!pinfo->fd->flags.visited) 
2047     {
2048
2049         /* This is the first time we've looked at this packet.
2050         Keep track of the Program and connection whence the request
2051         came, and the address and connection to which the request
2052         is being sent, so that we can match up calls with replies.
2053         (We don't include the sequence number, as we may want
2054         to have all packets over the same connection treated
2055         as being part of a single conversation so that we can
2056         let the user select that conversation to be displayed.) */
2057
2058         conversation = find_conversation(&pinfo->src, &pinfo->dst,
2059             PT_NCP, ndps_xid, ndps_xid, 0);
2060
2061         if (conversation == NULL) 
2062             {
2063             /* It's not part of any conversation - create a new one. */
2064             conversation = conversation_new(&pinfo->src, &pinfo->dst,
2065                 PT_NONE, ndps_xid, ndps_xid, 0);
2066         }
2067
2068         request_value = ndps_hash_insert(conversation, ndps_xid);
2069         request_value->ndps_prog = ndps_prog;
2070         request_value->ndps_func = ndps_func;
2071     }
2072     switch(ndps_prog)
2073     {
2074     case 0x060976:  /* Print */
2075         switch(ndps_func)
2076         {
2077         case 0x00000001:    /* Bind PSM */
2078             break;
2079         case 0x00000002:    /* Bind PA */
2080             cred_type = tvb_get_ntohl(tvb, foffset);
2081             proto_tree_add_item(ndps_tree, hf_ndps_cred_type, tvb, foffset, 4, FALSE);
2082             foffset += 4;
2083             name_len = tvb_get_ntohl(tvb, foffset);
2084             foffset = ndps_string(tvb, hf_ndps_server_name, ndps_tree, foffset);
2085             if(name_len == 0)
2086             {
2087                 foffset += 2;
2088             }
2089             else
2090             {
2091 #if 0
2092                 foffset += 4;
2093 #else
2094                 /*
2095                  * In at least one capture I've seen, this is the correct
2096                  * thing to do.
2097                  */
2098                 foffset += 2;
2099 #endif
2100             }
2101             proto_tree_add_item(ndps_tree, hf_ndps_connection, tvb, foffset, 
2102             2, FALSE);
2103             foffset += 2;
2104             foffset = ndps_string(tvb, hf_ndps_pa_name, ndps_tree, foffset);
2105             foffset += 8;   /* Don't know what these 8 bytes signify */
2106             proto_tree_add_item(ndps_tree, hf_ndps_items, tvb, foffset,
2107             4, FALSE);
2108             foffset += 4;
2109             foffset = ndps_string(tvb, hf_ndps_context, ndps_tree, foffset);
2110             foffset = ndps_string(tvb, hf_ndps_tree, ndps_tree, foffset);
2111             break;
2112         case 0x00000003:    /* Unbind */
2113             proto_tree_add_item(ndps_tree, hf_ndps_object, tvb, foffset, 
2114             4, FALSE);
2115             break;
2116         case 0x00000004:    /* Print */
2117         case 0x00000005:    /* Modify Job */
2118         case 0x00000006:    /* Cancel Job */
2119             break;
2120         case 0x00000007:    /* List Object Attributes */
2121             proto_tree_add_item(ndps_tree, hf_ndps_object, tvb, foffset, 
2122             4, FALSE);
2123             break;
2124         case 0x00000008:    /* Promote Job */
2125         case 0x00000009:    /* Interrupt */
2126         case 0x0000000a:    /* Pause */
2127         case 0x0000000b:    /* Resume */
2128         case 0x0000000c:    /* Clean */
2129         case 0x0000000d:    /* Create */
2130         case 0x0000000e:    /* Delete */
2131         case 0x0000000f:    /* Disable PA */
2132         case 0x00000010:    /* Enable PA */
2133         case 0x00000011:    /* Resubmit Jobs */
2134         case 0x00000012:    /* Set */
2135         case 0x00000013:    /* Shutdown PA */
2136         case 0x00000014:    /* Startup PA */
2137         case 0x00000015:    /* Reorder Job */
2138         case 0x00000016:    /* Pause PA */
2139         case 0x00000017:    /* Resume PA */
2140         case 0x00000018:    /* Transfer Data */
2141         case 0x00000019:    /* Device Control */
2142         case 0x0000001a:    /* Add Event Profile */
2143         case 0x0000001b:    /* Remove Event Profile */
2144         case 0x0000001c:    /* Modify Event Profile */
2145         case 0x0000001d:    /* List Event Profiles */
2146         case 0x0000001e:    /* Shutdown PSM */
2147         case 0x0000001f:    /* Cancel PSM Shutdown */
2148         case 0x00000020:    /* Set Printer DS Information */
2149         case 0x00000021:    /* Clean User Jobs */
2150         case 0x00000022:    /* Map GUID to NDS Name */
2151         default:
2152             break;
2153         }
2154         break;
2155     case 0x060977:  /* Broker */
2156         switch(ndps_func)
2157         {
2158         case 0x00000001:    /* Bind */
2159         case 0x00000002:    /* Unbind */
2160         case 0x00000003:    /* List Services */
2161         case 0x00000004:    /* Enable Service */
2162         case 0x00000005:    /* Disable Service */
2163         case 0x00000006:    /* Down Broker */
2164         case 0x00000007:    /* Get Broker NDS Object Name */
2165         case 0x00000008:    /* Get Broker Session Information */
2166         default:
2167             break;
2168         }
2169         break;
2170     case 0x060978:  /* Registry */
2171         switch(ndps_func)
2172         {
2173         case 0x00000001:    /* Bind */
2174         case 0x00000002:    /* Unbind */
2175         case 0x00000003:    /* Register Server */
2176         case 0x00000004:    /* Deregister Server */
2177         case 0x00000005:    /* Register Registry */
2178         case 0x00000006:    /* Deregister Registry */
2179         case 0x00000007:    /* Registry Update */
2180         case 0x00000008:    /* List Local Servers */
2181         case 0x00000009:    /* List Servers */
2182         case 0x0000000a:    /* List Known Registries */
2183         case 0x0000000b:    /* Get Registry NDS Object Name */
2184         case 0x0000000c:    /* Get Registry Session Information */
2185         default:
2186             break;
2187         }
2188         break;
2189     case 0x060979:  /* Notify */
2190         switch(ndps_func)
2191         {
2192         case 0x00000001:    /* Notify Bind */
2193         case 0x00000002:    /* Notify Unbind */
2194         case 0x00000003:    /* Register Supplier */
2195         case 0x00000004:    /* Deregister Supplier */
2196         case 0x00000005:    /* Add Profile */
2197         case 0x00000006:    /* Remove Profile */
2198         case 0x00000007:    /* Modify Profile */
2199         case 0x00000008:    /* List Profiles */
2200         case 0x00000009:    /* Report Event */
2201         case 0x0000000a:    /* List Supported Languages */
2202         case 0x0000000b:    /* Report Notification */
2203         case 0x0000000c:    /* Add Delivery Method */
2204         case 0x0000000d:    /* Remove Delivery Method */
2205         case 0x0000000e:    /* List Delivery Methods */
2206         case 0x0000000f:    /* Get Delivery Method Information */
2207         case 0x00000010:    /* Get Notify NDS Object Name */
2208         case 0x00000011:    /* Get Notify Session Information */
2209         default:
2210             break;
2211         }
2212         break;
2213     case 0x06097a:  /* Resman */
2214         switch(ndps_func)
2215         {
2216         case 0x00000001:    /* Bind */
2217             proto_tree_add_item(ndps_tree, hf_ndps_cred_type, tvb, foffset, 
2218             4, FALSE);
2219             foffset += 4;
2220             name_len = tvb_get_ntohl(tvb, foffset);
2221             foffset = ndps_string(tvb, hf_ndps_server_name, ndps_tree, foffset);
2222             if(name_len == 0)
2223             {
2224                 foffset += 2;
2225             }
2226             foffset += 2;
2227             proto_tree_add_item(ndps_tree, hf_ndps_connection, tvb, foffset, 
2228             2, FALSE);
2229             foffset += 2;
2230             foffset = ndps_string(tvb, hf_ndps_pa_name, ndps_tree, foffset);
2231             break;
2232         case 0x00000002:    /* Unbind */
2233         case 0x00000003:    /* Add Resource File */
2234         case 0x00000004:    /* Delete Resource File */
2235         case 0x00000005:    /* List Resources */
2236         case 0x00000006:    /* Get Resource File */
2237         case 0x00000007:    /* Get Resource File Data */
2238         case 0x00000008:    /* Get Resource Manager NDS Object Name */
2239         case 0x00000009:    /* Get Resource Manager Session Information */
2240         default:
2241             break;
2242         }
2243         break;
2244     case 0x06097b:  /* Delivery */
2245         switch(ndps_func)
2246         {
2247         case 0x00000001:    /* Delivery Bind */
2248         case 0x00000002:    /* Delivery Unbind */
2249         case 0x00000003:    /* Delivery Send */
2250         case 0x00000004:    /* Delivery Send2 */
2251         default:
2252             break;
2253         }
2254         break;
2255     default:
2256         break;
2257     }
2258     /*proto_tree_add_uint_format(ndps_tree, hf_ndps_xid, tvb, 0, 
2259     0, ndps_xid, "This is a Request Packet, XID %08x, Prog %08x, Func %08x", ndps_xid, ndps_prog, ndps_func);*/
2260     return;
2261 }
2262
2263 static void
2264 dissect_ndps_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ndps_tree, guint32 ndps_xid, int foffset)
2265 {
2266     conversation_t                      *conversation = NULL;
2267     ndps_req_hash_value         *request_value = NULL;
2268     proto_tree              *atree;
2269     proto_item              *aitem;
2270     guint8                  i;
2271     guint8                  number_of_items=0;
2272     guint32                 ndps_func=0;
2273     guint32                 ndps_prog=0;
2274     guint32                 error_val=0;
2275     guint32                 problem_type=0;
2276     
2277     if (!pinfo->fd->flags.visited) {
2278         /* Find the conversation whence the request would have come. */
2279         conversation = find_conversation(&pinfo->src, &pinfo->dst,
2280             PT_NONE, ndps_xid, ndps_xid, 0);
2281         if (conversation != NULL) {
2282             /* find the record telling us the request made that caused
2283             this reply */
2284             request_value = ndps_hash_lookup(conversation, ndps_xid);
2285             p_add_proto_data(pinfo->fd, proto_ndps, (void*) request_value);
2286         }
2287         /* else... we haven't seen an NDPS Request for that conversation. */
2288     }
2289     else {
2290         request_value = p_get_proto_data(pinfo->fd, proto_ndps);
2291     }
2292     if (request_value) {
2293         ndps_prog = request_value->ndps_prog;
2294         ndps_func = request_value->ndps_func;
2295     }
2296     if (tvb_length_remaining(tvb, foffset) < 12)
2297     {
2298         if (check_col(pinfo->cinfo, COL_INFO))
2299                 col_append_str(pinfo->cinfo, COL_INFO, "- Ok");
2300         return;
2301     }
2302     if(ndps_func != 7 && ndps_func != 4 && ndps_func != 8 )
2303     {
2304         proto_tree_add_item(ndps_tree, hf_ndps_rpc_acc_stat, tvb, foffset, 4, FALSE);
2305         foffset += 4;
2306         proto_tree_add_item(ndps_tree, hf_ndps_rpc_acc_results, tvb, foffset, 4, FALSE);
2307         foffset += 4;
2308     }
2309     error_val = tvb_get_ntohl(tvb, foffset);
2310     proto_tree_add_uint(ndps_tree, hf_ndps_error_val, tvb, foffset, 4, error_val);
2311     foffset += 4;
2312     if (error_val == 0) {
2313         if (check_col(pinfo->cinfo, COL_INFO))
2314             col_append_str(pinfo->cinfo, COL_INFO, "- Ok");
2315         switch(ndps_prog)
2316         {
2317         case 0x060976:  /* Print */
2318             switch(ndps_func)
2319             {
2320             case 0x00000001:    /* Bind PSM */
2321                 break;
2322             case 0x00000002:    /* Bind PA */
2323                 proto_tree_add_item(ndps_tree, hf_ndps_object, tvb, foffset, 4, FALSE);
2324                 foffset += 4;
2325                 foffset = ndps_string(tvb, hf_ndps_pa_name, ndps_tree, foffset);
2326                 break;
2327             case 0x00000003:    /* Unbind */
2328             case 0x00000004:    /* Print */
2329             case 0x00000005:    /* Modify Job */
2330             case 0x00000006:    /* Cancel Job */
2331                 break;
2332             case 0x00000007:    /* List Object Attributes */
2333                 proto_tree_add_item(ndps_tree, hf_ndps_session, tvb, foffset, 4, FALSE);
2334                 foffset += 4;
2335                 proto_tree_add_item(ndps_tree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
2336                 number_of_items=tvb_get_ntohl(tvb, foffset);
2337                 foffset += 4;
2338                 for (i = 1 ; i <= number_of_items; i++ )
2339                 {
2340                     foffset += 1;
2341                 }
2342                 foffset += align_4(tvb, foffset);
2343                 foffset += 4;
2344                 proto_tree_add_item(ndps_tree, hf_ndps_abort_flag, tvb, foffset, 4, FALSE);
2345                 foffset += 4;
2346                 foffset = objectident(tvb, ndps_tree, foffset);
2347                 foffset = attribute_value(tvb, ndps_tree, foffset);
2348                 proto_tree_add_item(ndps_tree, hf_ndps_qualifier, tvb, foffset, 4, FALSE);
2349                 foffset += 4;
2350                 /*foffset = attribute_value(tvb, ndps_tree, foffset);
2351                 proto_tree_add_item(ndps_tree, hf_ndps_scope, tvb, foffset, 4, FALSE);
2352                 foffset += 4;
2353                 foffset = objectident(tvb, ndps_tree, foffset);*/
2354                 break;
2355             case 0x00000008:    /* Promote Job */
2356             case 0x00000009:    /* Interrupt */
2357             case 0x0000000a:    /* Pause */
2358             case 0x0000000b:    /* Resume */
2359             case 0x0000000c:    /* Clean */
2360             case 0x0000000d:    /* Create */
2361             case 0x0000000e:    /* Delete */
2362             case 0x0000000f:    /* Disable PA */
2363             case 0x00000010:    /* Enable PA */
2364             case 0x00000011:    /* Resubmit Jobs */
2365             case 0x00000012:    /* Set */
2366             case 0x00000013:    /* Shutdown PA */
2367             case 0x00000014:    /* Startup PA */
2368             case 0x00000015:    /* Reorder Job */
2369             case 0x00000016:    /* Pause PA */
2370             case 0x00000017:    /* Resume PA */
2371             case 0x00000018:    /* Transfer Data */
2372             case 0x00000019:    /* Device Control */
2373             case 0x0000001a:    /* Add Event Profile */
2374             case 0x0000001b:    /* Remove Event Profile */
2375             case 0x0000001c:    /* Modify Event Profile */
2376             case 0x0000001d:    /* List Event Profiles */
2377             case 0x0000001e:    /* Shutdown PSM */
2378             case 0x0000001f:    /* Cancel PSM Shutdown */
2379             case 0x00000020:    /* Set Printer DS Information */
2380             case 0x00000021:    /* Clean User Jobs */
2381             case 0x00000022:    /* Map GUID to NDS Name */
2382             default:
2383                 break;
2384             }
2385             break;
2386         case 0x060977:  /* Broker */
2387             switch(ndps_func)
2388             {
2389             case 0x00000001:    /* Bind */
2390             case 0x00000002:    /* Unbind */
2391             case 0x00000003:    /* List Services */
2392             case 0x00000004:    /* Enable Service */
2393             case 0x00000005:    /* Disable Service */
2394             case 0x00000006:    /* Down Broker */
2395             case 0x00000007:    /* Get Broker NDS Object Name */
2396             case 0x00000008:    /* Get Broker Session Information */
2397             default:
2398                 break;
2399             }
2400             break;
2401         case 0x060978:  /* Registry */
2402             switch(ndps_func)
2403             {
2404             case 0x00000001:    /* Bind */
2405             case 0x00000002:    /* Unbind */
2406             case 0x00000003:    /* Register Server */
2407             case 0x00000004:    /* Deregister Server */
2408             case 0x00000005:    /* Register Registry */
2409             case 0x00000006:    /* Deregister Registry */
2410             case 0x00000007:    /* Registry Update */
2411             case 0x00000008:    /* List Local Servers */
2412             case 0x00000009:    /* List Servers */
2413             case 0x0000000a:    /* List Known Registries */
2414             case 0x0000000b:    /* Get Registry NDS Object Name */
2415             case 0x0000000c:    /* Get Registry Session Information */
2416             default:
2417                 break;
2418             }
2419             break;
2420         case 0x060979:  /* Notify */
2421             switch(ndps_func)
2422             {
2423             case 0x00000001:    /* Notify Bind */
2424             case 0x00000002:    /* Notify Unbind */
2425             case 0x00000003:    /* Register Supplier */
2426             case 0x00000004:    /* Deregister Supplier */
2427             case 0x00000005:    /* Add Profile */
2428             case 0x00000006:    /* Remove Profile */
2429             case 0x00000007:    /* Modify Profile */
2430             case 0x00000008:    /* List Profiles */
2431             case 0x00000009:    /* Report Event */
2432             case 0x0000000a:    /* List Supported Languages */
2433             case 0x0000000b:    /* Report Notification */
2434             case 0x0000000c:    /* Add Delivery Method */
2435             case 0x0000000d:    /* Remove Delivery Method */
2436             case 0x0000000e:    /* List Delivery Methods */
2437             case 0x0000000f:    /* Get Delivery Method Information */
2438             case 0x00000010:    /* Get Notify NDS Object Name */
2439             case 0x00000011:    /* Get Notify Session Information */
2440             default:
2441                 break;
2442             }
2443             break;
2444         case 0x06097a:  /* Resman */
2445             switch(ndps_func)
2446             {
2447             case 0x00000001:    /* Bind */
2448                 break;
2449             case 0x00000002:    /* Unbind */
2450             case 0x00000003:    /* Add Resource File */
2451             case 0x00000004:    /* Delete Resource File */
2452             case 0x00000005:    /* List Resources */
2453             case 0x00000006:    /* Get Resource File */
2454             case 0x00000007:    /* Get Resource File Data */
2455             case 0x00000008:    /* Get Resource Manager NDS Object Name */
2456             case 0x00000009:    /* Get Resource Manager Session Information */
2457             default:
2458                 break;
2459             }
2460             break;
2461         case 0x06097b:  /* Delivery */
2462             switch(ndps_func)
2463             {
2464             case 0x00000001:    /* Delivery Bind */
2465             case 0x00000002:    /* Delivery Unbind */
2466             case 0x00000003:    /* Delivery Send */
2467             case 0x00000004:    /* Delivery Send2 */
2468             default:
2469                 break;
2470             }
2471             break;
2472         default:
2473             break;
2474         }
2475     }
2476     else
2477     {
2478         if (check_col(pinfo->cinfo, COL_INFO))
2479             col_append_str(pinfo->cinfo, COL_INFO, "- Error");
2480         problem_type = tvb_get_ntohl(tvb, foffset);
2481         proto_tree_add_item(ndps_tree, hf_ndps_problem_type, tvb, foffset, 4, FALSE);
2482         foffset += 4;
2483         proto_tree_add_item(ndps_tree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
2484         foffset += 4;
2485         switch(problem_type)
2486         {
2487         case 0:                 /* Security Error */
2488             proto_tree_add_item(ndps_tree, hf_security_problem_type, tvb, foffset, 4, FALSE);
2489             foffset += 4;
2490             foffset = objectident(tvb, ndps_tree, foffset);
2491             break;
2492         case 1:                 /* Service Error */
2493             proto_tree_add_item(ndps_tree, hf_service_problem_type, tvb, foffset, 4, FALSE);
2494             foffset += 4;
2495             proto_tree_add_item(ndps_tree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
2496             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
2497             foffset += 8; 
2498             if (tvb_get_ntohl(tvb, foffset-4) != 0) {
2499                 foffset = objectident(tvb, ndps_tree, foffset);
2500             }
2501             proto_tree_add_item(ndps_tree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
2502             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
2503             foffset += 4;
2504             proto_tree_add_item(ndps_tree, hf_ndps_qualifier, tvb, foffset, 4, FALSE);
2505             foffset += 4;
2506             proto_tree_add_item(ndps_tree, hf_ndps_lib_error, tvb, foffset, 4, FALSE);
2507             foffset += 4;
2508             proto_tree_add_item(ndps_tree, hf_ndps_other_error, tvb, foffset, 4, FALSE);
2509             foffset += 4;
2510             proto_tree_add_item(ndps_tree, hf_ndps_other_error_2, tvb, foffset, 4, FALSE);
2511             foffset += 4;
2512             break;
2513         case 2:                 /* Access Error */
2514             proto_tree_add_item(ndps_tree, hf_access_problem_type, tvb, foffset, 4, FALSE);
2515             foffset += 4;
2516             proto_tree_add_item(ndps_tree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
2517             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
2518             if (foffset > tvb_length_remaining(tvb, foffset)) {
2519                 break;
2520             }
2521             foffset += 4; 
2522             foffset = objectident(tvb, ndps_tree, foffset);
2523             if (foffset > tvb_length_remaining(tvb, foffset)) {
2524                 break;
2525             }
2526             proto_tree_add_item(ndps_tree, hf_ndps_nameorid, tvb, foffset, 
2527             4, FALSE);
2528             foffset = ndps_string(tvb, hf_local_object_name, ndps_tree, foffset);
2529             break;
2530         case 3:                 /* Printer Error */
2531             proto_tree_add_item(ndps_tree, hf_printer_problem_type, tvb, foffset, 4, FALSE);
2532             foffset += 4;
2533             foffset = objectident(tvb, ndps_tree, foffset);
2534             if (foffset > tvb_length_remaining(tvb, foffset)) {
2535                 break;
2536             }
2537             proto_tree_add_item(ndps_tree, hf_ndps_nameorid, tvb, foffset, 
2538             4, FALSE);
2539             foffset += 4;
2540             foffset = ndps_string(tvb, hf_local_object_name, ndps_tree, foffset);
2541             break;
2542         case 4:                 /* Selection Error */
2543             proto_tree_add_item(ndps_tree, hf_selection_problem_type, tvb, foffset, 4, FALSE);
2544             foffset += 4;
2545             foffset = objectident(tvb, ndps_tree, foffset);
2546             /*if (foffset > tvb_length_remaining(tvb, foffset)) {
2547                 break;
2548             }
2549             proto_tree_add_item(ndps_tree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
2550             foffset += tvb_get_ntohl(tvb, foffset);*/   /* Need to decode later */
2551             /*if (foffset > tvb_length_remaining(tvb, foffset)) {
2552                 break;
2553             }
2554             foffset += 4; 
2555             proto_tree_add_item(ndps_tree, hf_ndps_nameorid, tvb, foffset, 
2556             4, FALSE);
2557             foffset += 4;
2558             foffset = ndps_string(tvb, hf_local_object_name, ndps_tree, foffset); */
2559             break;
2560         case 5:                 /* Document Access Error */
2561             proto_tree_add_item(ndps_tree, hf_doc_access_problem_type, tvb, foffset, 4, FALSE);
2562             foffset = objectident(tvb, ndps_tree, foffset);
2563             if (foffset > tvb_length_remaining(tvb, foffset)) {
2564                 break;
2565             }
2566             proto_tree_add_item(ndps_tree, hf_ndps_nameorid, tvb, foffset, 
2567             4, FALSE);
2568             foffset += 4;
2569             foffset = ndps_string(tvb, hf_local_object_name, ndps_tree, foffset);
2570             break;
2571         case 6:                 /* Attribute Error */
2572             proto_tree_add_item(ndps_tree, hf_attribute_problem_type, tvb, foffset, 4, FALSE);
2573             foffset += 4;
2574             aitem = proto_tree_add_item(ndps_tree, hf_ndps_item_count, tvb, foffset, 4, FALSE);
2575             atree = proto_item_add_subtree(aitem, ett_ndps);
2576             foffset += 4;
2577             for (i = 1 ; i <= number_of_items; i++ )
2578             {
2579                 proto_tree_add_item(atree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
2580                 foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
2581                 if (foffset > tvb_length_remaining(tvb, foffset)) {
2582                     break;
2583                 }
2584                 foffset += 4; 
2585                 proto_tree_add_item(atree, hf_ndps_nameorid, tvb, foffset, 
2586                 4, FALSE);
2587                 foffset += 4;
2588                 foffset = ndps_string(tvb, hf_local_object_name, atree, foffset);
2589                 foffset = objectident(tvb, atree, foffset);
2590             }
2591             break;
2592         case 7:                 /* Update Error */
2593             proto_tree_add_item(ndps_tree, hf_update_problem_type, tvb, foffset, 4, FALSE);
2594             proto_tree_add_item(ndps_tree, hf_oid_struct_size, tvb, foffset, 4, FALSE);
2595             foffset += tvb_get_ntohl(tvb, foffset);   /* Need to decode later */
2596             if (foffset > tvb_length_remaining(tvb, foffset)) {
2597                 break;
2598             }
2599             foffset += 4; 
2600             foffset = objectident(tvb, ndps_tree, foffset);
2601             if (foffset > tvb_length_remaining(tvb, foffset)) {
2602                 break;
2603             }
2604             proto_tree_add_item(ndps_tree, hf_ndps_nameorid, tvb, foffset, 
2605             4, FALSE);
2606             foffset += 4;
2607             foffset = ndps_string(tvb, hf_local_object_name, ndps_tree, foffset);
2608             break;
2609         default:
2610             break;
2611         }
2612     }
2613     proto_tree_add_uint_format(ndps_tree, hf_ndps_xid, tvb, 0, 
2614     0, ndps_xid, "This is a Reply Packet, XID %08x, Prog %08x, Func %08x", ndps_xid, ndps_prog, ndps_func);
2615     return;
2616 }
2617
2618 void
2619 proto_register_ndps(void)
2620 {
2621         static hf_register_info hf_ndps[] = {
2622                 { &hf_ndps_record_mark,
2623                 { "Record Mark",                "ndps.record_mark", FT_UINT16, BASE_HEX, NULL, 0x0,
2624                         "Record Mark", HFILL }},
2625
2626         { &hf_ndps_packet_type,
2627         { "Packet Type",    "ndps.packet_type",
2628           FT_UINT32,    BASE_HEX,   VALS(ndps_packet_types),   0x0,
2629           "Packet Type", HFILL }},
2630
2631         { &hf_ndps_length,
2632         { "Record Length",    "ndps.record_length",
2633            FT_UINT16,    BASE_DEC,   NULL,   0x0,
2634            "Record Length", HFILL }},
2635         
2636         { &hf_ndps_xid,
2637         { "Exchange ID",    "ndps.xid",
2638            FT_UINT32,    BASE_HEX,   NULL,   0x0,
2639            "Exchange ID", HFILL }},
2640
2641         { &hf_ndps_rpc_version,
2642         { "RPC Version",    "ndps.rpc_version",
2643            FT_UINT32,    BASE_HEX,   NULL,   0x0,
2644            "RPC Version", HFILL }},
2645
2646         { &hf_spx_ndps_program,
2647         { "NDPS Program Number",    "spx.ndps_program",
2648           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_program_vals),   0x0,
2649           "NDPS Program Number", HFILL }},
2650         
2651         { &hf_spx_ndps_version,
2652         { "Program Version",    "spx.ndps_version",
2653           FT_UINT32,    BASE_DEC,   NULL,   0x0,
2654           "Program Version", HFILL }}, 
2655     
2656         { &hf_ndps_error,
2657         { "NDPS Error",    "spx.ndps_error",
2658           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2659           "NDPS Error", HFILL }}, 
2660         
2661         { &hf_spx_ndps_func_print,
2662         { "Print Program",    "spx.ndps_func_print",
2663           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_print_func_vals),   0x0,
2664           "Print Program", HFILL }},
2665         
2666         { &hf_spx_ndps_func_notify,
2667         { "Notify Program",    "spx.ndps_func_notify",
2668           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_notify_func_vals),   0x0,
2669           "Notify Program", HFILL }},
2670         
2671         { &hf_spx_ndps_func_delivery,
2672         { "Delivery Program",    "spx.ndps_func_delivery",
2673           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_deliver_func_vals),   0x0,
2674           "Delivery Program", HFILL }},
2675         
2676         { &hf_spx_ndps_func_registry,
2677         { "Registry Program",    "spx.ndps_func_registry",
2678           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_registry_func_vals),   0x0,
2679           "Registry Program", HFILL }},
2680         
2681         { &hf_spx_ndps_func_resman,
2682         { "ResMan Program",    "spx.ndps_func_resman",
2683           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_resman_func_vals),   0x0,
2684           "ResMan Program", HFILL }},
2685         
2686         { &hf_spx_ndps_func_broker,
2687         { "Broker Program",    "spx.ndps_func_broker",
2688           FT_UINT32,    BASE_HEX,   VALS(spx_ndps_broker_func_vals),   0x0,
2689           "Broker Program", HFILL }},
2690         
2691         { &hf_ndps_items,
2692         { "Number of Items",    "ndps.items",
2693           FT_UINT32,    BASE_DEC,   NULL,   0x0,
2694           "Number of Items", HFILL }},
2695
2696         { &hf_ndps_sbuffer,
2697         { "Server",    "ndps.sbuffer",
2698           FT_UINT32,    BASE_DEC,   NULL,   0x0,
2699           "Server", HFILL }},
2700         
2701         { &hf_ndps_rbuffer,
2702         { "Connection",    "ndps.rbuffer",
2703           FT_UINT32,    BASE_DEC,   NULL,   0x0,
2704           "Connection", HFILL }},
2705
2706         { &hf_ndps_pa_name,
2707         { "Trustee Name",    "ndps.pa_name",
2708           FT_STRING,    BASE_NONE,   NULL,   0x0,
2709           "Trustee Name", HFILL }},
2710
2711         { &hf_ndps_context,
2712         { "Printer Name",    "ndps.context",
2713           FT_STRING,    BASE_NONE,   NULL,   0x0,
2714           "Printer Name", HFILL }},
2715         
2716         { &hf_ndps_tree,
2717         { "Tree",    "ndps.tree",
2718           FT_STRING,    BASE_NONE,   NULL,   0x0,
2719           "Tree", HFILL }},
2720
2721         { &hf_ndps_error_val,
2722         { "Return Status",    "ndps.error_val",
2723           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2724           "Return Status", HFILL }},
2725
2726         { &hf_ndps_object,
2727         { "Object ID",    "ndps.object",
2728           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2729           "Object ID", HFILL }},
2730
2731         { &hf_ndps_cred_type,
2732         { "Credential Type",    "ndps.cred_type",
2733           FT_UINT32,    BASE_HEX,   VALS(ndps_credential_enum),   0x0,
2734           "Credential Type", HFILL }},
2735
2736         { &hf_ndps_server_name,
2737         { "Server Name",    "ndps.server_name",
2738           FT_STRING,    BASE_DEC,   NULL,   0x0,
2739           "Server Name", HFILL }},
2740
2741         { &hf_ndps_connection,
2742         { "Connection",    "ndps.connection",
2743           FT_UINT16,    BASE_DEC,   NULL,   0x0,
2744           "Connection", HFILL }},
2745
2746         { &hf_ndps_ext_error,
2747         { "Extended Return Status",    "ndps.ext_error",
2748           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2749           "Extended Return Status", HFILL }},
2750
2751         { &hf_ndps_auth_null,
2752         { "Auth Null",    "ndps.auth_null",
2753           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2754           "Auth Null", HFILL }},
2755
2756         { &hf_ndps_rpc_accept,
2757         { "RPC Accept or Deny",    "ndps.rpc_acc",
2758           FT_UINT32,    BASE_HEX,   VALS(true_false),   0x0,
2759           "RPC Accept or Deny", HFILL }},
2760
2761         { &hf_ndps_rpc_acc_stat,
2762         { "RPC Accept Status",    "ndps.rpc_acc_stat",
2763           FT_UINT32,    BASE_HEX,   VALS(accept_stat),   0x0,
2764           "RPC Accept Status", HFILL }},
2765         
2766         { &hf_ndps_rpc_rej_stat,
2767         { "RPC Reject Status",    "ndps.rpc_rej_stat",
2768           FT_UINT32,    BASE_HEX,   VALS(reject_stat),   0x0,
2769           "RPC Reject Status", HFILL }},
2770         
2771         { &hf_ndps_rpc_acc_results,
2772         { "RPC Accept Results",    "ndps.rpc_acc_res",
2773           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2774           "RPC Accept Results", HFILL }},
2775
2776         { &hf_ndps_problem_type,
2777         { "Problem Type",    "ndps.rpc_prob_type",
2778           FT_UINT32,    BASE_HEX,   VALS(error_type_enum),   0x0,
2779           "Problem Type", HFILL }},
2780     
2781         { &hf_security_problem_type,
2782         { "Security Problem",    "ndps.rpc_sec_prob",
2783           FT_UINT32,    BASE_HEX,   VALS(security_problem_enum),   0x0,
2784           "Security Problem", HFILL }},
2785
2786         { &hf_service_problem_type,
2787         { "Service Problem",    "ndps.rpc_serv_prob",
2788           FT_UINT32,    BASE_HEX,   VALS(service_problem_enum),   0x0,
2789           "Service Problem", HFILL }},
2790         
2791         { &hf_access_problem_type,
2792         { "Access Problem",    "ndps.rpc_acc_prob",
2793           FT_UINT32,    BASE_HEX,   VALS(access_problem_enum),   0x0,
2794           "Access Problem", HFILL }},
2795         
2796         { &hf_printer_problem_type,
2797         { "Printer Problem",    "ndps.rpc_print_prob",
2798           FT_UINT32,    BASE_HEX,   VALS(printer_problem_enum),   0x0,
2799           "Printer Problem", HFILL }},
2800         
2801         { &hf_selection_problem_type,
2802         { "Selection Problem",    "ndps.rpc_sel_prob",
2803           FT_UINT32,    BASE_HEX,   VALS(selection_problem_enum),   0x0,
2804           "Selection Problem", HFILL }},
2805         
2806         { &hf_doc_access_problem_type,
2807         { "Document Access Problem",    "ndps.rpc_doc_acc_prob",
2808           FT_UINT32,    BASE_HEX,   VALS(doc_access_problem_enum),   0x0,
2809           "Document Access Problem", HFILL }},
2810         
2811         { &hf_attribute_problem_type,
2812         { "Attribute Problem",    "ndps.rpc_attr_prob",
2813           FT_UINT32,    BASE_HEX,   VALS(attribute_problem_enum),   0x0,
2814           "Attribute Problem", HFILL }},
2815
2816         { &hf_update_problem_type,
2817         { "Update Problem",    "ndps.rpc_update_prob",
2818           FT_UINT32,    BASE_HEX,   VALS(update_problem_enum),   0x0,
2819           "Update Problem", HFILL }},
2820         
2821         { &hf_obj_id_type,
2822         { "Object ID Type",    "ndps.rpc_obj_id_type",
2823           FT_UINT32,    BASE_HEX,   VALS(obj_identification_enum),   0x0,
2824           "Object ID Type", HFILL }},
2825
2826         { &hf_oid_struct_size,
2827         { "OID Struct Size",    "ndps.rpc_oid_struct_size",
2828           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2829           "OID Struct Size", HFILL }},
2830         
2831         { &hf_object_name,
2832         { "Object Name",    "ndps.ndps_object_name",
2833           FT_STRING,    BASE_NONE,   NULL,   0x0,
2834           "Object Name", HFILL }},
2835
2836         { &hf_ndps_document_number,
2837         { "Document Number",    "ndps.ndps_doc_num",
2838           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2839           "Document Number", HFILL }},
2840
2841         { &hf_ndps_nameorid,
2842         { "Name or ID Type",    "ndps.ndps_nameorid",
2843           FT_UINT32,    BASE_HEX,   VALS(nameorid_enum),   0x0,
2844           "Name or ID Type", HFILL }},
2845
2846         { &hf_local_object_name,
2847         { "Local Object Name",    "ndps.ndps_loc_object_name",
2848           FT_STRING,    BASE_NONE,   NULL,   0x0,
2849           "Local Object Name", HFILL }},
2850
2851         { &hf_printer_name,
2852         { "Printer Name",    "ndps.ndps_printer_name",
2853           FT_STRING,    BASE_NONE,   NULL,   0x0,
2854           "Printer Name", HFILL }},
2855
2856         { &hf_ndps_qualified_name,
2857         { "Qualified Name Type",    "ndps.ndps_qual_name_type",
2858           FT_UINT32,    BASE_HEX,   VALS(qualified_name_enum),   0x0,
2859           "Qualified Name Type", HFILL }},
2860
2861         { &hf_ndps_item_count,
2862         { "Number of Items",    "ndps.ndps_item_count",
2863           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2864           "Number of Items", HFILL }},
2865
2866         { &hf_ndps_qualifier,
2867         { "Qualifier",    "ndps.ndps_qual",
2868           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2869           "Qualifier", HFILL }},
2870
2871         { &hf_ndps_lib_error,
2872         { "Lib Error",    "ndps.ndps_lib_error",
2873           FT_UINT32,    BASE_HEX,   VALS(ndps_error_types),   0x0,
2874           "Lib Error", HFILL }},
2875
2876         { &hf_ndps_other_error,
2877         { "Other Error",    "ndps.ndps_other_error",
2878           FT_UINT32,    BASE_HEX,   VALS(ndps_error_types),   0x0,
2879           "Other Error", HFILL }},
2880
2881         { &hf_ndps_other_error_2,
2882         { "Other Error 2",    "ndps.ndps_other_error_2",
2883           FT_UINT32,    BASE_HEX,   VALS(ndps_error_types),   0x0,
2884           "Other Error 2", HFILL }},
2885
2886         { &hf_ndps_session,
2887         { "Session",    "ndps.ndps_session",
2888           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2889           "Session", HFILL }},
2890
2891         { &hf_ndps_abort_flag,
2892         { "Abort?",    "ndps.ndps_abort",
2893           FT_BOOLEAN,    BASE_NONE,   NULL,   0x0,
2894           "Abort?", HFILL }},
2895
2896         { &hf_obj_attribute_type,
2897         { "Attribute Type",    "ndps.ndps_attrib_type",
2898           FT_UINT32,    BASE_HEX,   VALS(ndps_attribute_enum),   0x0,
2899           "Attribute Type", HFILL }},
2900
2901         { &hf_ndps_attribute_value,
2902         { "Value",    "ndps.attribue_value",
2903           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2904           "Value", HFILL }},
2905
2906         { &hf_ndps_lower_range,
2907         { "Lower Range",    "ndps.lower_range",
2908           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2909           "Lower Range", HFILL }},
2910
2911         { &hf_ndps_upper_range,
2912         { "Upper Range",    "ndps.upper_range",
2913           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2914           "Upper Range", HFILL }},
2915
2916         { &hf_ndps_n64,
2917         { "Value",    "ndps.n64",
2918           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2919           "Value", HFILL }},
2920
2921         { &hf_ndps_lower_range_n64,
2922         { "Lower Range",    "ndps.lower_range_n64",
2923           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2924           "Lower Range", HFILL }},
2925
2926         { &hf_ndps_upper_range_n64,
2927         { "Upper Range",    "ndps.upper_range_n64",
2928           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2929           "Upper Range", HFILL }},
2930
2931         { &hf_ndps_attrib_boolean,
2932         { "Value?",    "ndps.ndps_attrib_boolean",
2933           FT_BOOLEAN,    BASE_NONE,   NULL,   0x0,
2934           "Value?", HFILL }},
2935
2936         { &hf_ndps_realization,
2937         { "Realization Type",    "ndps.ndps_realization",
2938           FT_UINT32,    BASE_HEX,   VALS(ndps_realization_enum),   0x0,
2939           "Realization Type", HFILL }},
2940
2941         { &hf_ndps_xdimension_n64,
2942         { "X Dimension",    "ndps.xdimension_n64",
2943           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2944           "X Dimension", HFILL }},
2945
2946         { &hf_ndps_ydimension_n64,
2947         { "Y Dimension",    "ndps.xdimension_n64",
2948           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2949           "Y Dimension", HFILL }},
2950
2951         { &hf_ndps_dim_value,
2952         { "Dimension Value Type",    "ndps.ndps_dim_value",
2953           FT_UINT32,    BASE_HEX,   VALS(ndps_dim_value_enum),   0x0,
2954           "Dimension Value Type", HFILL }},
2955
2956         { &hf_ndps_dim_flag,
2957         { "Dimension Flag",    "ndps.ndps_dim_falg",
2958           FT_UINT32,    BASE_HEX,   NULL,   0x0,
2959           "Dimension Flag", HFILL }},
2960
2961         { &hf_ndps_xydim_value,
2962         { "XY Dimension Value Type",    "ndps.ndps_xydim_value",
2963           FT_UINT32,    BASE_HEX,   VALS(ndps_xydim_value_enum),   0x0,
2964           "XY Dimension Value Type", HFILL }},
2965
2966         { &hf_ndps_location_value,
2967         { "Location Value Type",    "ndps.ndps_location_value",
2968           FT_UINT32,    BASE_HEX,   VALS(ndps_location_value_enum),   0x0,
2969           "Location Value Type", HFILL }},
2970
2971         { &hf_ndps_xmin_n64,
2972         { "Minimum X Dimension",    "ndps.xmin_n64",
2973           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2974           "Minimum X Dimension", HFILL }},
2975
2976         { &hf_ndps_xmax_n64,
2977         { "Maximum X Dimension",    "ndps.xmax_n64",
2978           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2979           "Maximum X Dimension", HFILL }},
2980
2981         { &hf_ndps_ymin_n64,
2982         { "Minimum Y Dimension",    "ndps.ymin_n64",
2983           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2984           "Minimum Y Dimension", HFILL }},
2985
2986         { &hf_ndps_ymax_n64,
2987         { "Maximum Y Dimension",    "ndps.ymax_n64",
2988           FT_BYTES,    BASE_NONE,   NULL,   0x0,
2989           "Maximum Y Dimension", HFILL }},
2990
2991         { &hf_ndps_edge_value,
2992         { "Edge Value",    "ndps.ndps_edge_value",
2993           FT_UINT32,    BASE_HEX,   VALS(ndps_edge_value_enum),   0x0,
2994           "Edge Value", HFILL }},
2995
2996         { &hf_ndps_cardinal_or_oid,
2997         { "Cardinal or OID",    "ndps.ndps_car_or_oid",
2998           FT_UINT32,    BASE_HEX,   VALS(ndps_card_or_oid_enum),   0x0,
2999           "Cardinal or OID", HFILL }},
3000
3001         { &hf_ndps_cardinal_name_or_oid,
3002         { "Cardinal Name or OID",    "ndps.ndps_car_name_or_oid",
3003           FT_UINT32,    BASE_HEX,   VALS(ndps_card_name_or_oid_enum),   0x0,
3004           "Cardinal Name or OID", HFILL }},
3005
3006         { &hf_ndps_integer_or_oid,
3007         { "Integer or OID",    "ndps.ndps_integer_or_oid",
3008           FT_UINT32,    BASE_HEX,   VALS(ndps_integer_or_oid_enum),   0x0,
3009           "Integer or OID", HFILL }},
3010
3011         { &hf_ndps_profile_id,
3012         { "Profile ID",    "ndps.ndps_profile_id",
3013           FT_UINT32,    BASE_HEX,   NULL,   0x0,
3014           "Profile ID", HFILL }},
3015
3016         { &hf_ndps_persistence,
3017         { "Persistence",    "ndps.ndps_persistence",
3018           FT_UINT32,    BASE_HEX,   VALS(ndps_persistence_enum),   0x0,
3019           "Persistence", HFILL }},
3020
3021         { &hf_ndps_language_id,
3022         { "Lanuage ID",    "ndps.ndps_lang_id",
3023           FT_UINT32,    BASE_HEX,   NULL,   0x0,
3024           "Language ID", HFILL }},
3025
3026         { &hf_address_type,
3027         { "Address Type",    "ndps.ndps_address_type",
3028           FT_UINT32,    BASE_HEX,   VALS(ndps_address_type_enum),   0x0,
3029           "Address Type", HFILL }},
3030
3031         { &hf_ndps_address,
3032         { "Address",    "ndps.ndps_address",
3033           FT_UINT32,    BASE_HEX,   VALS(ndps_address_enum),   0x0,
3034           "Address", HFILL }},
3035
3036         { &hf_ndps_add_bytes,
3037         { "Address Bytes",    "ndps.add_bytes",
3038           FT_UINT_BYTES,    BASE_NONE,   NULL,   0x0,
3039           "Address Bytes", HFILL }},
3040
3041         { &hf_ndps_event_type,
3042         { "Event Type",    "ndps.ndps_event_type",
3043           FT_UINT32,    BASE_HEX,   NULL,   0x0,
3044           "Event Type", HFILL }},
3045
3046         { &hf_ndps_event_object_identifier,
3047         { "Event Object Type",    "ndps.ndps_event_object_identifier",
3048           FT_UINT32,    BASE_HEX,   VALS(ndps_event_object_enum),   0x0,
3049           "Event Object Type", HFILL }},
3050
3051         { &hf_ndps_octet_string,
3052         { "Octet String",    "ndps.octet_string",
3053           FT_UINT_BYTES,    BASE_NONE,   NULL,   0x0,
3054           "Octet String", HFILL }},
3055
3056         { &hf_ndps_scope,
3057         { "Scope",    "ndps.scope",
3058           FT_UINT32,    BASE_HEX,   NULL,   0x0,
3059           "Scope", HFILL }},
3060         
3061     };
3062
3063
3064         static gint *ett[] = {
3065                 &ett_ndps,
3066         };
3067         module_t *ndps_module;
3068         
3069         proto_ndps = proto_register_protocol("Novell Distributed Print System", "NDPS", "ndps");
3070         proto_register_field_array(proto_ndps, hf_ndps, array_length(hf_ndps));
3071         proto_register_subtree_array(ett, array_length(ett));
3072
3073         ndps_module = prefs_register_protocol(proto_ndps, NULL);
3074         prefs_register_bool_preference(ndps_module, "desegment_ndps",
3075             "Desegment all NDPS messages spanning multiple TCP segments",
3076             "Whether the NDPS dissector should desegment all messages spanning multiple TCP segments",
3077             &ndps_desegment);
3078
3079         register_init_routine(&ndps_init_protocol);
3080         register_postseq_cleanup_routine(&ndps_postseq_cleanup);
3081 }
3082
3083 void
3084 proto_reg_handoff_ndps(void)
3085 {
3086         dissector_handle_t ndps_handle, ndps_tcp_handle;
3087
3088         ndps_handle = create_dissector_handle(dissect_ndps, proto_ndps);
3089         ndps_tcp_handle = create_dissector_handle(dissect_ndps_tcp, proto_ndps);
3090         
3091         dissector_add("spx.socket", SPX_SOCKET_PA, ndps_handle);
3092         dissector_add("spx.socket", SPX_SOCKET_BROKER, ndps_handle);
3093         dissector_add("spx.socket", SPX_SOCKET_SRS, ndps_handle);
3094         dissector_add("spx.socket", SPX_SOCKET_ENS, ndps_handle);
3095         dissector_add("spx.socket", SPX_SOCKET_RMS, ndps_handle);
3096         dissector_add("spx.socket", SPX_SOCKET_NOTIFY_LISTENER, ndps_handle);
3097         dissector_add("tcp.port", TCP_PORT_PA, ndps_tcp_handle);
3098         dissector_add("tcp.port", TCP_PORT_BROKER, ndps_tcp_handle);
3099         dissector_add("tcp.port", TCP_PORT_SRS, ndps_tcp_handle);
3100         dissector_add("tcp.port", TCP_PORT_ENS, ndps_tcp_handle);
3101         dissector_add("tcp.port", TCP_PORT_RMS, ndps_tcp_handle);
3102         dissector_add("tcp.port", TCP_PORT_NOTIFY_LISTENER, ndps_tcp_handle);
3103         ndps_data_handle = find_dissector("data");
3104 }