7b35248a8f04ce73ee5f81c8eb758143774c6b92
[obnox/wireshark/wip.git] / packet-dcerpc-epm.c
1 /* packet-dcerpc-epm.c
2  * Routines for dcerpc endpoint mapper dissection
3  * Copyright 2001, Todd Sabin <tas@webspan.net>
4  *
5  * $Id: packet-dcerpc-epm.c,v 1.20 2003/06/26 04:30:27 tpot 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
31 #include <string.h>
32
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include "packet-dcerpc.h"
36 #include "packet-dcerpc-nt.h"
37
38
39 static int proto_epm = -1;
40
41 static int hf_epm_opnum = -1;
42 static int hf_epm_inquiry_type = -1;
43 static int hf_epm_object = -1;
44 static int hf_epm_if_id = -1;
45 static int hf_epm_ver_maj = -1;
46 static int hf_epm_ver_min = -1;
47 static int hf_epm_ver_opt = -1;
48 static int hf_epm_hnd = -1;
49 static int hf_epm_max_ents = -1;
50 static int hf_epm_num_ents = -1;
51 static int hf_epm_uuid = -1;
52 static int hf_epm_tower_length = -1;
53 static int hf_epm_tower_data = -1;
54 static int hf_epm_max_towers = -1;
55 static int hf_epm_num_towers = -1;
56 static int hf_epm_rc = -1;
57 static int hf_epm_replace = -1;
58 static int hf_epm_tower_num_floors = -1;
59 static int hf_epm_tower_rhs_len = -1;
60 static int hf_epm_tower_lhs_len = -1;
61 static int hf_epm_tower_proto_id = -1;
62 static int hf_epm_annotation = -1;
63 static int hf_epm_ann_offset = -1;
64 static int hf_epm_ann_len = -1;
65 static int hf_epm_proto_named_pipes = -1;
66 static int hf_epm_proto_netbios_name = -1;
67 static int hf_epm_proto_ip = -1;
68 static int hf_epm_proto_udp_port = -1;
69 static int hf_epm_proto_tcp_port = -1;
70
71 static gint ett_epm = -1;
72 static gint ett_epm_tower_floor = -1;
73 static gint ett_epm_entry = -1;
74
75 static e_uuid_t uuid_epm = { 0xe1af8308, 0x5d1f, 0x11c9, { 0x91, 0xa4, 0x08, 0x00, 0x2b, 0x14, 0xa0, 0xfa } };
76 static guint16  ver_epm = 3;
77
78
79 /* typedef struct {
80       unsigned int tower_len,
81       [size_is(tower_len)] char tower[];
82    } twr_t, *twr_p_t;
83 */
84 static int epm_dissect_tower (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *drep);
85
86
87 static int
88 epm_dissect_pointer_IF_ID(tvbuff_t *tvb, int offset,
89                              packet_info *pinfo, proto_tree *tree,
90                              char *drep)
91 {
92         dcerpc_info *di;
93
94         di=pinfo->private_data;
95         offset = dissect_ndr_uuid_t (tvb, offset, pinfo, tree, drep,
96                                      di->hf_index, NULL);
97         offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
98                                      hf_epm_ver_maj, NULL);
99         offset = dissect_ndr_uint16 (tvb, offset, pinfo, tree, drep,
100                                      hf_epm_ver_min, NULL);
101         return offset;
102 }
103
104 static int
105 epm_dissect_pointer_UUID(tvbuff_t *tvb, int offset,
106                              packet_info *pinfo, proto_tree *tree,
107                              char *drep)
108 {
109         dcerpc_info *di;
110
111         di=pinfo->private_data;
112         offset = dissect_ndr_uuid_t (tvb, offset, pinfo, tree, drep,
113                                      di->hf_index, NULL);
114         return offset;
115 }
116
117 static int
118 epm_dissect_ept_lookup_rqst (tvbuff_t *tvb, int offset,
119                              packet_info *pinfo, proto_tree *tree,
120                              char *drep)
121 {
122     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
123                                  hf_epm_inquiry_type, NULL);
124
125     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
126                              epm_dissect_pointer_UUID, NDR_POINTER_PTR,
127                              "Object:", hf_epm_object);
128
129     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
130                              epm_dissect_pointer_IF_ID, NDR_POINTER_PTR,
131                              "Interface:", hf_epm_if_id);
132
133     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
134                                  hf_epm_ver_opt, NULL);
135
136     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
137                                   hf_epm_hnd, NULL);
138
139     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
140                                  hf_epm_max_ents, NULL);
141     return offset;
142 }
143
144
145 static int
146 epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset,
147                              packet_info *pinfo, proto_tree *parent_tree,
148                              char *drep)
149 {
150     proto_item *item=NULL;
151     proto_tree *tree=NULL;
152     int old_offset=offset;
153     guint32 len;
154     gint strlen;
155     dcerpc_info *di;
156     const char *str;
157     
158     di=pinfo->private_data;
159     if(di->conformant_run){
160         return offset;
161     }
162
163     if(parent_tree){
164         item = proto_tree_add_text(parent_tree, tvb, offset, -1, "Entry:");
165         tree = proto_item_add_subtree(item, ett_epm_entry);
166     }
167
168     offset = dissect_ndr_uuid_t (tvb, offset, pinfo, tree, drep,
169                                  hf_epm_object, NULL);
170
171     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
172                              epm_dissect_tower, NDR_POINTER_PTR,
173                              "Tower pointer:", -1);
174
175     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
176                                  hf_epm_ann_offset, NULL);
177     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
178                                  hf_epm_ann_len, &len);
179     str=(const char *)tvb_get_ptr(tvb, offset, -1);
180     strlen=len;
181     strlen=MIN(strlen,tvb_length_remaining(tvb, offset));
182     proto_tree_add_item(tree, hf_epm_annotation, tvb, offset, len, TRUE);
183     offset += len;
184
185     if(str&&str[0]){
186         if(parent_tree) {
187             proto_item_append_text(item, " Service:%*s ", strlen, str);
188             proto_item_append_text(tree->parent, " Service:%*s ", strlen, str);
189         }
190         if (check_col(pinfo->cinfo, COL_INFO)) {
191             col_append_fstr(pinfo->cinfo, COL_INFO, ", Service:%*s", strlen, str);
192         }
193     }
194
195     proto_item_set_len(item, offset-old_offset);
196     return offset;
197 }
198
199 static int
200 epm_dissect_ept_entry_t_array(tvbuff_t *tvb, int offset,
201                              packet_info *pinfo, proto_tree *tree,
202                              char *drep)
203 {
204     offset = dissect_ndr_ucvarray(tvb, offset, pinfo, tree, drep,
205                              epm_dissect_ept_entry_t);
206
207     return offset;
208 }
209
210 static int
211 epm_dissect_ept_lookup_resp (tvbuff_t *tvb, int offset,
212                              packet_info *pinfo, proto_tree *tree,
213                              char *drep)
214 {
215     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
216                                   hf_epm_hnd, NULL);
217
218     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
219                                  hf_epm_num_ents, NULL);
220
221     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
222                              epm_dissect_ept_entry_t_array, NDR_POINTER_REF,
223                              "Entries:", -1);
224
225     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
226                                  hf_epm_rc, NULL);
227
228     return offset;
229 }
230
231 #if 0
232 static int
233 epm_dissect_uuid (tvbuff_t *tvb, int offset,
234                              packet_info *pinfo, proto_tree *tree,
235                              char *drep)
236 {
237     offset = dissect_ndr_uuid_t (tvb, offset, pinfo, tree, drep,
238                                   hf_epm_uuid, NULL);
239     return offset;
240 }
241 #endif
242
243
244
245 static const value_string proto_id_vals[] = {
246         { 0x00, "OSI OID"},
247         { 0x0d, "UUID"},
248         { 0x05, "OSI TP4"},
249         { 0x06, "OSI CLNS or DNA Routing"},
250         { 0x07, "DOD TCP"},
251         { 0x08, "DOD UDP"},
252         { 0x09, "DOD IP"},
253         { 0x0a, "RPC connectionless protocol"},
254         { 0x0b, "RPC connection-oriented protocol"},
255         { 0x02, "DNA Session Control"},
256         { 0x03, "DNA Session Control V3"},
257         { 0x04, "DNA NSP Transport"},
258         { 0x0f, "Named Pipes"}, 
259         { 0x10, "Named Pipes"},
260         { 0x11, "NetBIOS"},
261         { 0x12, "NetBEUI"},
262         { 0x13, "Netware SPX"},
263         { 0x14, "Netware IPX"},
264         { 0x16, "Appletalk Stream"},
265         { 0x17, "Appletalk Datagram"},
266         { 0x18, "Appletalk"},
267         { 0x19, "NetBIOS"},
268         { 0x1a, "Vines SPP"},
269         { 0x1b, "Vines IPC"},
270         { 0x1c, "StreetTalk"},
271         { 0x20, "Unix Domain Socket"},
272         { 0x21, "null"},
273         { 0x22, "NetBIOS"},
274         { 0, NULL},
275 };
276
277
278 /* XXX this function assumes LE encoding. can not use the NDR routines
279    since they assume padding.
280 */
281 static int
282 epm_dissect_tower_data (tvbuff_t *tvb, int offset,
283                              packet_info *pinfo, proto_tree *tree,
284                              char *drep)
285 {
286     guint16 num_floors, i;
287     dcerpc_info *di;
288
289     di=pinfo->private_data;
290     if(di->conformant_run){
291         return offset;
292     }
293
294     num_floors = tvb_get_letohs(tvb, offset);
295     proto_tree_add_uint(tree, hf_epm_tower_num_floors, tvb, offset, 2, num_floors);
296     offset += 2;
297
298     for(i=1;i<=num_floors;i++){
299         proto_item *it = NULL;
300         proto_tree *tr = NULL;
301         int old_offset = offset;
302         guint16 len;
303         guint8 proto_id;
304         e_uuid_t uuid;
305
306         it = proto_tree_add_text(tree, tvb, offset, 0, "Floor %d  ", i);
307         tr = proto_item_add_subtree(it, ett_epm_tower_floor);
308
309         len = tvb_get_letohs(tvb, offset);
310         proto_tree_add_uint(tr, hf_epm_tower_lhs_len, tvb, offset, 2, len);
311         offset += 2;
312
313         proto_id = tvb_get_guint8(tvb, offset);
314         proto_tree_add_uint(tr, hf_epm_tower_proto_id, tvb, offset, 1, proto_id);
315
316         switch(proto_id){
317         case 0x0d: /* UUID */
318             dcerpc_tvb_get_uuid (tvb, offset+1, drep, &uuid);
319             proto_tree_add_string_format (tr, hf_epm_uuid, tvb, offset+1, 16, "",
320                           "UUID: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
321                           uuid.Data1, uuid.Data2, uuid.Data3,
322                           uuid.Data4[0], uuid.Data4[1],
323                           uuid.Data4[2], uuid.Data4[3],
324                           uuid.Data4[4], uuid.Data4[5],
325                           uuid.Data4[6], uuid.Data4[7]);
326             proto_tree_add_text(tr, tvb, offset+17, 2, "Version %d.%d", tvb_get_guint8(tvb, offset+18), tvb_get_guint8(tvb, offset+17));
327             break;
328         }
329         offset += len;
330
331         len = tvb_get_letohs(tvb, offset);
332         proto_tree_add_uint(tr, hf_epm_tower_rhs_len, tvb, offset, 2, len);
333         offset += 2;
334
335         switch(proto_id){
336         case 0x07: /* TCP this one is always big endian */
337             proto_tree_add_item(tr, hf_epm_proto_tcp_port, tvb, offset, 2, FALSE);
338             proto_item_append_text(tr, "TCP Port:%d", tvb_get_ntohs(tvb, offset));
339             break;
340
341         case 0x08: /* UDP this one is always big endian */
342             proto_tree_add_item(tr, hf_epm_proto_udp_port, tvb, offset, 2, FALSE);
343             proto_item_append_text(tr, "UDP Port:%d", tvb_get_ntohs(tvb, offset));
344             break;
345
346         case 0x09: /* IP this one is always big endian */
347             proto_tree_add_item(tr, hf_epm_proto_ip, tvb, offset, 4, TRUE);
348             proto_item_append_text(tr, "IP:%s", ip_to_str(tvb_get_ptr(tvb, offset, 4)));
349             break;
350
351         case 0x0f: /* \\PIPE\xxx   named pipe */
352             proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, TRUE);
353             proto_item_append_text(tr, "NamedPipe:%*s",MIN(len,tvb_length_remaining(tvb, offset)), tvb_get_ptr(tvb, offset, -1)); 
354             break;
355
356         case 0x10: /* PIPENAME  named pipe */
357             proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, TRUE);
358             proto_item_append_text(tr, "PIPE:%*s",MIN(len,tvb_length_remaining(tvb, offset)), tvb_get_ptr(tvb, offset, -1)); 
359             break;
360
361         case 0x11: /* \\NETBIOS   netbios name */
362             proto_tree_add_item(tr, hf_epm_proto_netbios_name, tvb, offset, len, TRUE);
363             proto_item_append_text(tr, "NetBIOS:%*s",MIN(len,tvb_length_remaining(tvb, offset)), tvb_get_ptr(tvb, offset, -1)); 
364             break;
365         default:
366             if(len){
367                 proto_tree_add_text(tr, tvb, offset, len, "not decoded yet");
368             }
369         }
370         offset += len;
371
372         proto_item_set_len(it, offset-old_offset);
373     }
374     return offset;
375 }
376
377 /* typedef struct {
378       unsigned int tower_len,
379       [size_is(tower_len)] char tower[];
380    } twr_t, *twr_p_t;
381 */
382 static int
383 epm_dissect_tower (tvbuff_t *tvb, int offset,
384                              packet_info *pinfo, proto_tree *tree,
385                              char *drep)
386 {
387     guint32 len;
388     dcerpc_info *di;
389
390     di=pinfo->private_data;
391     if(di->conformant_run){
392         return offset;
393     }
394
395     /* first one is the header of the conformant array, second one is the
396        length field */
397     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
398                                  hf_epm_tower_length, &len);
399     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
400                                  hf_epm_tower_length, NULL);
401     offset = epm_dissect_tower_data(tvb, offset, pinfo, tree, drep);
402
403     return offset;
404 }
405 static int
406 epm_dissect_tower_pointer (tvbuff_t *tvb, int offset,
407                              packet_info *pinfo, proto_tree *tree,
408                              char *drep)
409 {
410     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
411                              epm_dissect_tower, NDR_POINTER_PTR,
412                              "Tower pointer:", -1);
413     return offset;
414 }
415 static int
416 epm_dissect_tower_array (tvbuff_t *tvb, int offset,
417                              packet_info *pinfo, proto_tree *tree,
418                              char *drep)
419 {
420     offset = dissect_ndr_ucvarray(tvb, offset, pinfo, tree, drep,
421                              epm_dissect_tower_pointer);
422
423     return offset;
424 }
425
426 static int
427 epm_dissect_ept_map_rqst (tvbuff_t *tvb, int offset,
428                              packet_info *pinfo, proto_tree *tree,
429                              char *drep)
430 {
431     /* [in] handle_t h */
432     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
433                                   hf_epm_hnd, NULL);
434
435 #if 0
436     /* according to opengroup we should have an uuid pointer here.
437        in my w2k captures i can not see any such thing */
438     /* [in, ptr] uuid_p_t object */
439     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
440                              epm_dissect_uuid, NDR_POINTER_PTR,
441                              "UUID pointer:", -1, 1);
442 #endif
443
444     /* [in, ptr] twr_p_t map_tower */
445     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
446                              epm_dissect_tower, NDR_POINTER_PTR,
447                              "Tower pointer:", -1);
448
449     /* [in, out] ept_lookup_handle_t *entry_handle */
450     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
451                                   hf_epm_hnd, NULL);
452
453     /* [in] unsigned32 max_towers */
454     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
455                                  hf_epm_max_towers, NULL);
456
457     return offset;
458 }
459
460 static int
461 epm_dissect_ept_map_resp (tvbuff_t *tvb, int offset,
462                              packet_info *pinfo, proto_tree *tree,
463                              char *drep)
464 {
465     /* [in, out] ept_lookup_handle_t *entry_handle */
466     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
467                                   hf_epm_hnd, NULL);
468
469     /* [out, ptr] unsigned32 *num_towers */
470     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
471                                  hf_epm_num_towers, NULL);
472
473     /* [out, length_is(*num_towers), size_is(max_towers), ptr] twr_p_t towers[] */
474     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
475                              epm_dissect_tower_array, NDR_POINTER_REF,
476                              "Tower array:", -1);
477
478     /* [out] error_status_t *status */
479     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
480                                  hf_epm_rc, NULL);
481
482     return offset;
483 }
484
485 static int
486 epm_dissect_ept_entry_t_ucarray(tvbuff_t *tvb, int offset,
487                              packet_info *pinfo, proto_tree *tree,
488                              char *drep)
489 {
490     offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep,
491                              epm_dissect_ept_entry_t);
492
493     return offset;
494 }
495
496 static int
497 epm_dissect_ept_insert_rqst (tvbuff_t *tvb, int offset,
498                              packet_info *pinfo, proto_tree *tree,
499                              char *drep)
500 {
501     /* [in, out] ept_lookup_handle_t *entry_handle */
502     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
503                                   hf_epm_hnd, NULL);
504
505     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
506                                  hf_epm_num_ents, NULL);
507
508     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
509                              epm_dissect_ept_entry_t_ucarray, NDR_POINTER_REF,
510                              "Entries:", -1);
511
512     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
513                                  hf_epm_replace, NULL);
514
515     return offset;
516 }
517
518
519
520 static int
521 epm_dissect_ept_insert_resp (tvbuff_t *tvb, int offset,
522                              packet_info *pinfo, proto_tree *tree,
523                              char *drep)
524 {
525     /* [out] error_status_t *status */
526     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
527                                  hf_epm_rc, NULL);
528
529     return offset;
530 }
531
532
533 static int
534 epm_dissect_ept_delete_rqst (tvbuff_t *tvb, int offset,
535                              packet_info *pinfo, proto_tree *tree,
536                              char *drep)
537 {
538     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
539                                   hf_epm_hnd, NULL);
540
541     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
542                                  hf_epm_num_ents, NULL);
543
544     offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
545                              epm_dissect_ept_entry_t_ucarray, NDR_POINTER_REF,
546                              "Entries:", -1);
547
548     return offset;
549 }
550
551
552
553 static int
554 epm_dissect_ept_delete_resp (tvbuff_t *tvb, int offset,
555                              packet_info *pinfo, proto_tree *tree,
556                              char *drep)
557 {
558     /* [out] error_status_t *status */
559     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
560                                  hf_epm_rc, NULL);
561
562     return offset;
563 }
564
565
566
567 static int
568 epm_dissect_ept_lookup_handle_free_rqst (tvbuff_t *tvb, int offset,
569                              packet_info *pinfo, proto_tree *tree,
570                              char *drep)
571 {
572     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
573                                   hf_epm_hnd, NULL);
574
575     return offset;
576 }
577
578 static int
579 epm_dissect_ept_lookup_handle_free_resp (tvbuff_t *tvb, int offset,
580                              packet_info *pinfo, proto_tree *tree,
581                              char *drep)
582 {
583     offset = dissect_ndr_ctx_hnd (tvb, offset, pinfo, tree, drep,
584                                   hf_epm_hnd, NULL);
585
586     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
587                                  hf_epm_rc, NULL);
588
589     return offset;
590 }
591
592
593 static dcerpc_sub_dissector epm_dissectors[] = {
594     { 0, "Insert", 
595         epm_dissect_ept_insert_rqst,
596         epm_dissect_ept_insert_resp },
597     { 1, "Delete",
598         epm_dissect_ept_delete_rqst,
599         epm_dissect_ept_delete_resp },
600     { 2, "Lookup",
601         epm_dissect_ept_lookup_rqst,
602         epm_dissect_ept_lookup_resp },
603     { 3, "Map",
604         epm_dissect_ept_map_rqst,
605         epm_dissect_ept_map_resp },
606     { 4, "LookupHandleFree",
607         epm_dissect_ept_lookup_handle_free_rqst,
608         epm_dissect_ept_lookup_handle_free_resp },
609     { 5, "InqObject", NULL, NULL },
610     { 6, "MgmtDelete", NULL, NULL },
611     { 0, NULL, NULL, NULL }
612 };
613
614 void
615 proto_register_epm (void)
616 {
617         static hf_register_info hf[] = {
618         { &hf_epm_opnum,
619           { "Operation", "epm.opnum", FT_UINT16, BASE_DEC,
620             NULL, 0x0, "Operation", HFILL }},
621         { &hf_epm_inquiry_type,
622           { "Inquiry type", "epm.inq_type", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
623         { &hf_epm_object,
624           { "Object", "epm.object", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
625         { &hf_epm_if_id,
626           { "Interface", "epm.if_id", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
627         { &hf_epm_ver_maj,
628           { "Version Major", "epm.ver_maj", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
629         { &hf_epm_ver_min,
630           { "Version Minor", "epm.ver_min", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
631         { &hf_epm_ver_opt,
632           { "Version Option", "epm.ver_opt", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
633         { &hf_epm_hnd,
634           { "Handle", "epm.hnd", FT_BYTES, BASE_NONE, NULL, 0x0, "Context handle", HFILL }},
635         { &hf_epm_max_ents,
636           { "Max entries", "epm.max_ents", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
637         { &hf_epm_num_ents,
638           { "Num entries", "epm.num_ents", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
639         { &hf_epm_uuid,
640           { "UUID", "epm.uuid", FT_STRING, BASE_NONE, NULL, 0x0, "UUID", HFILL }},
641         { &hf_epm_annotation,
642           { "Annotation", "epm.annotation", FT_STRING, BASE_NONE, NULL, 0x0, "Annotation", HFILL }},
643         { &hf_epm_proto_named_pipes,
644           { "Named Pipe", "epm.proto.named_pipe", FT_STRING, BASE_NONE, NULL, 0x0, "Name of the named pipe for this service", HFILL }},
645         { &hf_epm_proto_netbios_name,
646           { "NetBIOS Name", "epm.proto.netbios_name", FT_STRING, BASE_NONE, NULL, 0x0, "NetBIOS name where this service can be found", HFILL }},
647         { &hf_epm_tower_length,
648           { "Length", "epm.tower.len", FT_UINT32, BASE_DEC, NULL, 0x0, "Length of tower data", HFILL }},
649         { &hf_epm_tower_data,
650           { "Tower", "epm.tower", FT_BYTES, BASE_HEX, NULL, 0x0, "Tower data", HFILL }},
651         { &hf_epm_max_towers,
652           { "Max Towers", "epm.max_towers", FT_UINT32, BASE_DEC, NULL, 0x0, "Maximum number of towers to return", HFILL }},
653         { &hf_epm_num_towers,
654           { "Num Towers", "epm.num_towers", FT_UINT32, BASE_DEC, NULL, 0x0, "Number number of towers to return", HFILL }},
655         { &hf_epm_ann_offset,
656           { "Annotation offset", "epm.ann_offset", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
657         { &hf_epm_ann_len,
658           { "Annotation length", "epm.ann_len", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
659         { &hf_epm_rc,
660           { "Return code", "epm.rc", FT_UINT32, BASE_HEX, NULL, 0x0, "EPM return value", HFILL }},
661         { &hf_epm_replace,
662           { "Replace", "epm.replace", FT_UINT8, BASE_DEC, NULL, 0x0, "Replace existing objects?", HFILL }},
663         { &hf_epm_tower_num_floors,
664           { "Number of floors", "epm.tower.num_floors", FT_UINT16, BASE_DEC, NULL, 0x0, "Number of floors in tower", HFILL }},
665         { &hf_epm_proto_udp_port,
666           { "UDP Port", "epm.proto.udp_port", FT_UINT16, BASE_DEC, NULL, 0x0, "UDP Port where this service can be found", HFILL }},
667         { &hf_epm_proto_tcp_port,
668           { "TCP Port", "epm.proto.tcp_port", FT_UINT16, BASE_DEC, NULL, 0x0, "TCP Port where this service can be found", HFILL }},
669         { &hf_epm_tower_rhs_len,
670           { "RHS Length", "epm.tower.rhs.len", FT_UINT16, BASE_DEC, NULL, 0x0, "Length of RHS data", HFILL }},
671         { &hf_epm_tower_lhs_len,
672           { "LHS Length", "epm.tower.lhs.len", FT_UINT16, BASE_DEC, NULL, 0x0, "Length of LHS data", HFILL }},
673         { &hf_epm_proto_ip,
674           { "IP", "epm.proto.ip", FT_IPv4, BASE_NONE, NULL, 0x0, "IP address where service is located", HFILL }},
675         { &hf_epm_tower_proto_id,
676           { "Protocol", "epm.tower.proto_id", FT_UINT8, BASE_HEX, VALS(proto_id_vals), 0x0, "Protocol identifier", HFILL }}
677     };
678
679         static gint *ett[] = {
680                 &ett_epm,
681                 &ett_epm_tower_floor,
682                 &ett_epm_entry
683         };
684         proto_epm = proto_register_protocol ("DCE/RPC Endpoint Mapper", "EPM", "epm");
685         proto_register_field_array (proto_epm, hf, array_length (hf));
686         proto_register_subtree_array (ett, array_length (ett));
687 }
688
689 void
690 proto_reg_handoff_epm (void)
691 {
692         header_field_info *hf_info;
693
694         /* Register the protocol as dcerpc */
695         dcerpc_init_uuid (proto_epm, ett_epm, &uuid_epm, ver_epm, epm_dissectors, hf_epm_opnum);
696
697         /* Set opnum strings from subdissector list */
698
699         hf_info = proto_registrar_get_nth(hf_epm_opnum);
700         hf_info->strings = value_string_from_subdissectors(
701                 epm_dissectors, array_length(epm_dissectors));
702 }