make dissect_ber_choice take a guint* that will return the
[obnox/wireshark/wip.git] / epan / dissectors / packet-portmap.c
1 /* packet-portmap.c
2  * Routines for portmap dissection
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * Copied from packet-smb.c
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31
32
33 #include "packet-rpc.h"
34 #include "packet-portmap.h"
35 #include <epan/ipproto.h>
36 #include "epan/conversation.h"
37 #include "epan/packet_info.h"
38
39 /*
40  * See:
41  *
42  *      RFC 1833, "Binding Protocols for ONC RPC Version 2".
43  */
44
45 static int proto_portmap = -1;
46 static int hf_portmap_procedure_v1 = -1;
47 static int hf_portmap_procedure_v2 = -1;
48 static int hf_portmap_procedure_v3 = -1;
49 static int hf_portmap_procedure_v4 = -1;
50 static int hf_portmap_proto = -1;
51 static int hf_portmap_prog = -1;
52 static int hf_portmap_proc = -1;
53 static int hf_portmap_version = -1;
54 static int hf_portmap_port = -1;
55 static int hf_portmap_answer = -1;
56 static int hf_portmap_args = -1;
57 static int hf_portmap_result = -1;
58 static int hf_portmap_rpcb = -1;
59 static int hf_portmap_rpcb_prog = -1;
60 static int hf_portmap_rpcb_version = -1;
61 static int hf_portmap_rpcb_netid = -1;
62 static int hf_portmap_rpcb_addr = -1;
63 static int hf_portmap_rpcb_owner = -1;
64 static int hf_portmap_uaddr = -1;
65
66
67 static gint ett_portmap = -1;
68 static gint ett_portmap_rpcb = -1;
69 static gint ett_portmap_entry = -1;
70
71 static dissector_handle_t rpc_handle;
72 static dissector_handle_t rpc_tcp_handle;
73
74 /* Dissect a getport call */
75 static int
76 dissect_getport_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
77         proto_tree *tree)
78 {
79         guint32 proto, version;
80         guint32 prog;
81         char *prog_name, *proto_name;
82
83         /* make sure we remember protocol type until the reply packet */
84         if(!pinfo->fd->flags.visited){
85                 rpc_call_info_value *rpc_call=pinfo->private_data;
86                 if(rpc_call){
87                         proto = tvb_get_ntohl(tvb, offset+8);
88                         if(proto==IP_PROTO_UDP){  /* only do this for UDP */
89                                 rpc_call->private_data=(void *)PT_UDP;
90                         }
91                 }
92         }
93
94         /* program */
95         prog = tvb_get_ntohl(tvb, offset+0);
96         prog_name = rpc_prog_name(prog);
97         proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
98                 offset, 4, prog, "Program: %s (%u)",
99                 prog_name, prog);
100         if (check_col(pinfo->cinfo, COL_INFO)) {
101                 col_append_fstr(pinfo->cinfo, COL_INFO,  " %s(%u)", prog_name, prog);
102
103         }
104         proto_item_append_text(tree, " GETPORT Call %s(%u)", prog_name, prog);
105
106         /* version */
107         version = tvb_get_ntohl(tvb, offset+4);
108         proto_tree_add_item(tree, hf_portmap_version, tvb,
109                 offset+4, 4, FALSE);
110         if (check_col(pinfo->cinfo, COL_INFO)) {
111                 col_append_fstr(pinfo->cinfo, COL_INFO,  " V:%d", version);
112
113         }
114         proto_item_append_text(tree, " Version:%d", version);
115
116
117         /* protocol */
118         proto = tvb_get_ntohl(tvb, offset+8);
119         proto_name = (char *)ipprotostr(proto);
120         proto_tree_add_uint_format(tree, hf_portmap_proto, tvb,
121                 offset+8, 4, proto, "Proto: %s (%u)", proto_name, proto);
122         if (check_col(pinfo->cinfo, COL_INFO)) {
123                 col_append_fstr(pinfo->cinfo, COL_INFO,  " %s", proto_name);
124
125         }
126         proto_item_append_text(tree, " %s", proto_name);
127
128         /* port */
129         proto_tree_add_item(tree, hf_portmap_port, tvb,
130                 offset+12, 4, FALSE);
131
132         return offset+16;
133 }
134
135 static int
136 dissect_getport_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
137         proto_tree *tree)
138 {
139         guint32 port;
140
141         /* we might have learnt a <ipaddr><protocol><port> mapping for ONC-RPC*/
142         if(!pinfo->fd->flags.visited){
143                 rpc_call_info_value *rpc_call=pinfo->private_data;
144                 /* only do this for UDP, TCP does not need anything like this */
145                 if(rpc_call && (GPOINTER_TO_UINT(rpc_call->private_data)==PT_UDP) ){
146                         guint32 port;
147                         port=tvb_get_ntohl(tvb, offset);
148                         if(port){
149                                 conversation_t *conv;
150                                 conv=find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, (port_type)rpc_call->private_data, port, 0, NO_ADDR_B|NO_PORT_B);
151                                 if(!conv){
152                                         conv=conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, (port_type)rpc_call->private_data, port, 0, NO_ADDR2|NO_PORT2);
153                                 }
154                                 conversation_set_dissector(conv, rpc_handle);
155                         }
156                 }
157         }
158
159         port = tvb_get_ntohl(tvb, offset);
160         offset = dissect_rpc_uint32(tvb, tree, hf_portmap_port,
161             offset);
162         proto_item_append_text(tree, " GETPORT Reply Port:%d", port);
163         if(port){
164                 if (check_col(pinfo->cinfo, COL_INFO)) {
165                         col_append_fstr(pinfo->cinfo, COL_INFO,  " Port:%d", port);
166                 }
167                 proto_item_append_text(tree, " Port:%d", port);
168         } else {
169                 if (check_col(pinfo->cinfo, COL_INFO)) {
170                         col_append_fstr(pinfo->cinfo, COL_INFO,  " PROGRAM_NOT_AVAILABLE");
171                 }
172                 proto_item_append_text(tree, " PROGRAM_NOT_AVAILABLE");
173         }
174
175         return offset;
176 }
177
178 /* Dissect a 'set' call */
179 static int
180 dissect_set_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
181         proto_tree *tree)
182 {
183         guint32 proto;
184         guint32 prog;
185
186         if ( tree )
187         {
188                 prog = tvb_get_ntohl(tvb, offset+0);
189                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
190                         offset, 4, prog, "Program: %s (%d)",
191                         rpc_prog_name(prog), prog);
192                 proto_tree_add_item(tree, hf_portmap_version, tvb,
193                         offset+4, 4, FALSE);
194
195                 proto = tvb_get_ntohl(tvb, offset+8);
196                 proto_tree_add_uint_format(tree, hf_portmap_proto,tvb,
197                         offset+8, 4, proto, "Proto: %s (%d)", ipprotostr(proto), proto);
198
199                 proto_tree_add_item(tree, hf_portmap_port, tvb,
200                         offset+12, 4, FALSE);
201         }
202
203         return offset+16;
204 }
205
206 /* Dissect a 'unset' call */
207 static int
208 dissect_unset_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
209         proto_tree *tree)
210 {
211         guint32 proto;
212         guint32 prog;
213
214         if ( tree )
215         {
216                 prog = tvb_get_ntohl(tvb, offset+0);
217                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
218                         offset, 4, prog, "Program: %s (%d)",
219                         rpc_prog_name(prog), prog);
220                 proto_tree_add_item(tree, hf_portmap_version, tvb,
221                         offset+4, 4, FALSE);
222
223                 proto = tvb_get_ntohl(tvb, offset+8);
224                 proto_tree_add_uint(tree, hf_portmap_proto, tvb,
225                         offset+8, 4, proto);
226
227                 proto_tree_add_item(tree, hf_portmap_port, tvb,
228                         offset+12, 4, FALSE);
229         }
230
231         return offset+16;
232 }
233
234 static int
235 dissect_set_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
236         proto_tree *tree)
237 {
238         offset = dissect_rpc_bool(tvb, tree, hf_portmap_answer,
239             offset);
240         return offset;
241 }
242
243 static int
244 dissect_dump_entry(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
245         proto_tree *tree)
246 {
247         int prog, version, proto, port;
248         proto_item *ti, *subtree;
249
250         prog = tvb_get_ntohl(tvb, offset+0);
251         version = tvb_get_ntohl(tvb, offset+4);
252         proto = tvb_get_ntohl(tvb, offset+8);
253         port = tvb_get_ntohl(tvb, offset+12);
254         if ( tree )
255         {
256                 ti = proto_tree_add_text(tree, tvb, offset, 16,
257                         "Map Entry: %s (%u) V%d",
258                         rpc_prog_name(prog), prog, version);
259                 subtree = proto_item_add_subtree(ti, ett_portmap_entry);
260
261                 proto_tree_add_uint_format(subtree, hf_portmap_prog, tvb,
262                         offset+0, 4, prog,
263                         "Program: %s (%u)", rpc_prog_name(prog), prog);
264                 proto_tree_add_uint(subtree, hf_portmap_version, tvb,
265                         offset+4, 4, version);
266                 proto_tree_add_uint_format(subtree, hf_portmap_proto, tvb,
267                         offset+8, 4, proto,
268                         "Protocol: %s (0x%02x)", ipprotostr(proto), proto);
269                 proto_tree_add_uint(subtree, hf_portmap_port, tvb,
270                         offset+12, 4, port);
271         }
272         offset += 16;
273         return offset;
274 }
275
276 static int
277 dissect_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
278         proto_tree *tree)
279 {
280         offset = dissect_rpc_list(tvb, pinfo, tree, offset,
281                 dissect_dump_entry);
282         return offset;
283 }
284
285 /* Dissect a callit call */
286 static int
287 dissect_callit_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
288         proto_tree *tree)
289 {
290         guint32 prog, vers, proc;
291
292         prog = tvb_get_ntohl(tvb, offset+0);
293         if ( tree )
294         {
295                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
296                         offset, 4, prog, "Program: %s (%u)",
297                         rpc_prog_name(prog), prog);
298         }
299
300         vers = tvb_get_ntohl(tvb, offset+4);
301         if ( tree )
302         {
303                 proto_tree_add_uint(tree, hf_portmap_version, tvb,
304                         offset+4, 4, vers);
305         }
306
307         proc = tvb_get_ntohl(tvb, offset+8);
308         if ( tree )
309         {
310                 proto_tree_add_uint_format(tree, hf_portmap_proc, tvb,
311                         offset+8, 4, proc, "Procedure: %s (%u)",
312                         rpc_proc_name(prog, vers, proc), proc);
313         }
314
315         offset += 12;
316
317         /* Dissect the arguments for this procedure.
318            Make the columns non-writable, so the dissector won't change
319            them out from under us. */
320         col_set_writable(pinfo->cinfo, FALSE);
321         offset = dissect_rpc_indir_call(tvb, pinfo, tree, offset,
322                 hf_portmap_args, prog, vers, proc);
323
324         return offset;
325 }
326
327 /* Dissect a callit reply */
328 static int
329 dissect_callit_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
330         proto_tree *tree)
331 {
332         if ( tree )
333         {
334                 proto_tree_add_item(tree, hf_portmap_port, tvb,
335                         offset, 4, FALSE);
336         }
337         offset += 4;
338
339         /* Dissect the result of this procedure.
340            Make the columns non-writable, so the dissector won't change
341            them out from under us. */
342         col_set_writable(pinfo->cinfo, FALSE);
343         offset = dissect_rpc_indir_reply(tvb, pinfo, tree, offset,
344                 hf_portmap_result, hf_portmap_prog, hf_portmap_version,
345                 hf_portmap_proc);
346
347         return offset;
348 }
349
350 /* proc number, "proc name", dissect_request, dissect_reply */
351 /* NULL as function pointer means: type of arguments is "void". */
352 static const vsff portmap1_proc[] = {
353         { PORTMAPPROC_NULL,     "NULL",         NULL,   NULL },
354         { PORTMAPPROC_SET,      "SET",          NULL,   NULL },
355         { PORTMAPPROC_UNSET,    "UNSET",        NULL,   NULL },
356         { PORTMAPPROC_GETPORT,  "GETPORT",      NULL,   NULL },
357         { PORTMAPPROC_DUMP,     "DUMP",         NULL,   NULL },
358         { PORTMAPPROC_CALLIT,   "CALLIT",       NULL,   NULL },
359         { 0,                    NULL,           NULL,   NULL }
360 };
361 static const value_string portmap1_proc_vals[] = {
362         { PORTMAPPROC_NULL,     "NULL" },
363         { PORTMAPPROC_SET,      "SET" },
364         { PORTMAPPROC_UNSET,    "UNSET" },
365         { PORTMAPPROC_GETPORT,  "GETPORT" },
366         { PORTMAPPROC_DUMP,     "DUMP" },
367         { PORTMAPPROC_CALLIT,   "CALLIT" },
368         { 0,                    NULL }
369 };
370 /* end of Portmap version 1 */
371
372 static const vsff portmap2_proc[] = {
373         { PORTMAPPROC_NULL, "NULL",
374                 NULL, NULL },
375         { PORTMAPPROC_SET, "SET",
376                 dissect_set_call, dissect_set_reply },
377         { PORTMAPPROC_UNSET, "UNSET",
378                 dissect_unset_call, dissect_set_reply },
379         { PORTMAPPROC_GETPORT,  "GETPORT",
380                 dissect_getport_call, dissect_getport_reply },
381         { PORTMAPPROC_DUMP, "DUMP",
382                 NULL, dissect_dump_reply },
383         { PORTMAPPROC_CALLIT, "CALLIT",
384                 dissect_callit_call, dissect_callit_reply },
385         { 0, NULL, NULL, NULL }
386 };
387 static const value_string portmap2_proc_vals[] = {
388         { PORTMAPPROC_NULL, "NULL" },
389         { PORTMAPPROC_SET, "SET" },
390         { PORTMAPPROC_UNSET, "UNSET" },
391         { PORTMAPPROC_GETPORT,  "GETPORT" },
392         { PORTMAPPROC_DUMP, "DUMP" },
393         { PORTMAPPROC_CALLIT, "CALLIT" },
394         { 0, NULL }
395 };
396 /* end of Portmap version 2 */
397
398
399 /* RFC 1833, Page 3 */
400 static int
401 dissect_rpcb(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
402 {
403         proto_item* rpcb_item = NULL;
404         proto_tree* rpcb_tree = NULL;
405         int old_offset = offset;
406         guint32 prog;
407
408         if (tree) {
409                 rpcb_item = proto_tree_add_item(tree, hf_portmap_rpcb, tvb,
410                         offset, -1, FALSE);
411                 if (rpcb_item)
412                         rpcb_tree = proto_item_add_subtree(rpcb_item, ett_portmap_rpcb);
413         }
414
415         prog = tvb_get_ntohl(tvb, offset);
416         if (rpcb_tree)
417                 proto_tree_add_uint_format(rpcb_tree, hf_portmap_rpcb_prog, tvb,
418                         offset, 4, prog,
419                         "Program: %s (%u)", rpc_prog_name(prog), prog);
420         offset += 4;
421
422         offset = dissect_rpc_uint32(tvb, rpcb_tree,
423             hf_portmap_rpcb_version, offset);
424         offset = dissect_rpc_string(tvb, rpcb_tree,
425             hf_portmap_rpcb_netid, offset, NULL);
426         offset = dissect_rpc_string(tvb, rpcb_tree,
427             hf_portmap_rpcb_addr, offset, NULL);
428         offset = dissect_rpc_string(tvb, rpcb_tree,
429             hf_portmap_rpcb_owner, offset, NULL);
430
431         /* now we know, that rpcb is shorter */
432         if (rpcb_item) {
433                 proto_item_set_len(rpcb_item, offset - old_offset);
434         }
435
436         return offset;
437 }
438
439
440
441 /* RFC 1833, Page 7 */
442 static int
443 dissect_rpcb3_getaddr_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
444         proto_tree *tree)
445 {
446         offset = dissect_rpcb(tvb, offset, pinfo, tree);
447
448         return offset;
449 }
450
451
452 /* RFC 1833, Page 7 */
453 static int
454 dissect_rpcb3_getaddr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
455         proto_tree *tree)
456 {
457         offset = dissect_rpc_string(tvb, tree,
458             hf_portmap_uaddr, offset, NULL);
459
460         return offset;
461 }
462
463
464 /* RFC 1833, Page 7 */
465 static int
466 dissect_rpcb3_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
467         proto_tree *tree)
468 {
469         offset = dissect_rpc_list(tvb, pinfo, tree, offset, dissect_rpcb);
470         return offset;
471 }
472
473 /* RFC 1833, page 4 */
474 static int
475 dissect_rpcb_rmtcallres(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
476         proto_tree *tree)
477 {
478         /* Dissect the remote universal address. */
479         offset = dissect_rpc_string(tvb, tree,
480             hf_portmap_rpcb_addr, offset, NULL);
481
482         /* Dissect the result of this procedure.
483            Make the columns non-writable, so the dissector won't change
484            them out from under us. */
485         col_set_writable(pinfo->cinfo, FALSE);
486         offset = dissect_rpc_indir_reply(tvb, pinfo, tree, offset,
487                 hf_portmap_result, hf_portmap_prog, hf_portmap_version,
488                 hf_portmap_proc);
489
490         return offset;
491 }
492
493
494 /* Portmapper version 3, RFC 1833, Page 7 */
495 static const vsff portmap3_proc[] = {
496         { RPCBPROC_NULL,        "NULL",
497                 NULL, NULL },
498         { RPCBPROC_SET,         "SET",
499                 NULL, NULL },
500         { RPCBPROC_UNSET,       "UNSET",
501                 NULL, NULL },
502         { RPCBPROC_GETADDR,     "GETADDR",
503                 dissect_rpcb3_getaddr_call, dissect_rpcb3_getaddr_reply},
504         { RPCBPROC_DUMP,        "DUMP",
505                 NULL, dissect_rpcb3_dump_reply },
506         { RPCBPROC_CALLIT,      "CALLIT",
507                 dissect_callit_call, dissect_rpcb_rmtcallres },
508         { RPCBPROC_GETTIME,     "GETTIME",
509                 NULL, NULL },
510         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR",
511                 NULL, NULL },
512         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR",
513                 NULL, NULL },
514         { 0, NULL, NULL, NULL }
515 };
516 static const value_string portmap3_proc_vals[] = {
517         { RPCBPROC_NULL,        "NULL" },
518         { RPCBPROC_SET,         "SET" },
519         { RPCBPROC_UNSET,       "UNSET" },
520         { RPCBPROC_GETADDR,     "GETADDR" },
521         { RPCBPROC_DUMP,        "DUMP" },
522         { RPCBPROC_CALLIT,      "CALLIT" },
523         { RPCBPROC_GETTIME,     "GETTIME" },
524         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR" },
525         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR" },
526         { 0, NULL }
527 };
528 /* end of Portmap version 3 */
529
530
531 /* Portmapper version 4, RFC 1833, Page 8 */
532 static const vsff portmap4_proc[] = {
533         { RPCBPROC_NULL,        "NULL",
534                 NULL, NULL },
535         { RPCBPROC_SET,         "SET",
536                 NULL, NULL },
537         { RPCBPROC_UNSET,       "UNSET",
538                 NULL, NULL },
539         { RPCBPROC_GETADDR,     "GETADDR",
540                 dissect_rpcb3_getaddr_call, dissect_rpcb3_getaddr_reply},
541         { RPCBPROC_DUMP,        "DUMP",
542                 NULL, dissect_rpcb3_dump_reply },
543         { RPCBPROC_BCAST,       "BCAST",
544                 dissect_callit_call, dissect_rpcb_rmtcallres },
545         { RPCBPROC_GETTIME,     "GETTIME",
546                 NULL, NULL },
547         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR",
548                 NULL, NULL },
549         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR",
550                 NULL, NULL },
551         { RPCBPROC_GETVERSADDR, "GETVERSADDR",
552                 NULL, NULL },
553         { RPCBPROC_INDIRECT,    "INDIRECT",
554                 dissect_callit_call, dissect_rpcb_rmtcallres },
555         { RPCBPROC_GETADDRLIST, "GETADDRLIST",
556                 NULL, NULL },
557         { RPCBPROC_GETSTAT,     "GETSTAT",
558                 NULL, NULL },
559         { 0, NULL, NULL, NULL }
560 };
561 static const value_string portmap4_proc_vals[] = {
562         { RPCBPROC_NULL,        "NULL" },
563         { RPCBPROC_SET,         "SET" },
564         { RPCBPROC_UNSET,       "UNSET" },
565         { RPCBPROC_GETADDR,     "GETADDR" },
566         { RPCBPROC_DUMP,        "DUMP" },
567         { RPCBPROC_BCAST,       "BCAST" },
568         { RPCBPROC_GETTIME,     "GETTIME" },
569         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR" },
570         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR" },
571         { RPCBPROC_GETVERSADDR, "GETVERSADDR" },
572         { RPCBPROC_INDIRECT,    "INDIRECT" },
573         { RPCBPROC_GETADDRLIST, "GETADDRLIST" },
574         { RPCBPROC_GETSTAT,     "GETSTAT" },
575         { 0, NULL }
576 };
577 /* end of Portmap version 4 */
578
579 void
580 proto_register_portmap(void)
581 {
582         static hf_register_info hf[] = {
583                 { &hf_portmap_procedure_v1, {
584                         "V1 Procedure", "portmap.procedure_v1", FT_UINT32, BASE_DEC,
585                         VALS(portmap1_proc_vals), 0, "V1 Procedure", HFILL }},
586                 { &hf_portmap_procedure_v2, {
587                         "V2 Procedure", "portmap.procedure_v2", FT_UINT32, BASE_DEC,
588                         VALS(portmap2_proc_vals), 0, "V2 Procedure", HFILL }},
589                 { &hf_portmap_procedure_v3, {
590                         "V3 Procedure", "portmap.procedure_v3", FT_UINT32, BASE_DEC,
591                         VALS(portmap3_proc_vals), 0, "V3 Procedure", HFILL }},
592                 { &hf_portmap_procedure_v4, {
593                         "V4 Procedure", "portmap.procedure_v4", FT_UINT32, BASE_DEC,
594                         VALS(portmap4_proc_vals), 0, "V4 Procedure", HFILL }},
595                 { &hf_portmap_prog, {
596                         "Program", "portmap.prog", FT_UINT32, BASE_DEC,
597                         NULL, 0, "Program", HFILL }},
598                 { &hf_portmap_port, {
599                         "Port", "portmap.port", FT_UINT32, BASE_DEC,
600                         NULL, 0, "Port", HFILL }},
601                 { &hf_portmap_proc, {
602                         "Procedure", "portmap.proc", FT_UINT32, BASE_DEC,
603                         NULL, 0, "Procedure", HFILL }},
604                 { &hf_portmap_proto, {
605                         "Protocol", "portmap.proto", FT_UINT32, BASE_DEC,
606                         NULL, 0, "Protocol", HFILL }},
607                 { &hf_portmap_version, {
608                         "Version", "portmap.version", FT_UINT32, BASE_DEC,
609                         NULL, 0, "Version", HFILL }},
610                 { &hf_portmap_answer, {
611                         "Answer", "portmap.answer", FT_BOOLEAN, BASE_DEC,
612                         NULL, 0, "Answer", HFILL }},
613                 { &hf_portmap_args, {
614                         "Arguments", "portmap.args", FT_BYTES, BASE_HEX,
615                         NULL, 0, "Arguments", HFILL }},
616                 { &hf_portmap_result, {
617                         "Result", "portmap.result", FT_BYTES, BASE_HEX,
618                         NULL, 0, "Result", HFILL }},
619                 { &hf_portmap_rpcb, {
620                         "RPCB", "portmap.rpcb", FT_NONE, 0,
621                         NULL, 0, "RPCB", HFILL }},
622                 { &hf_portmap_rpcb_prog, {
623                         "Program", "portmap.rpcb.prog", FT_UINT32, BASE_DEC,
624                         NULL, 0, "Program", HFILL }},
625                 { &hf_portmap_rpcb_version, {
626                         "Version", "portmap.rpcb.version", FT_UINT32, BASE_DEC,
627                         NULL, 0, "Version", HFILL }},
628                 { &hf_portmap_rpcb_netid, {
629                         "Network Id", "portmap.rpcb.netid", FT_STRING, BASE_DEC,
630                         NULL, 0, "Network Id", HFILL }},
631                 { &hf_portmap_rpcb_addr, {      /* address in rpcb structure in request */
632                         "Universal Address", "portmap.rpcb.addr", FT_STRING, BASE_DEC,
633                         NULL, 0, "Universal Address", HFILL }},
634                 { &hf_portmap_rpcb_owner, {
635                         "Owner of this Service", "portmap.rpcb.owner", FT_STRING, BASE_DEC,
636                         NULL, 0, "Owner of this Service", HFILL }},
637                 { &hf_portmap_uaddr, {  /* address in RPCBPROC_GETADDR reply */
638                         "Universal Address", "portmap.uaddr", FT_STRING, BASE_DEC,
639                         NULL, 0, "Universal Address", HFILL }},
640         };
641         static gint *ett[] = {
642                 &ett_portmap,
643                 &ett_portmap_rpcb,
644                 &ett_portmap_entry
645         };
646
647         proto_portmap = proto_register_protocol("Portmap", "Portmap", "portmap");
648         proto_register_field_array(proto_portmap, hf, array_length(hf));
649         proto_register_subtree_array(ett, array_length(ett));
650 }
651
652 void
653 proto_reg_handoff_portmap(void)
654 {
655         /* Register the protocol as RPC */
656         rpc_init_prog(proto_portmap, PORTMAP_PROGRAM, ett_portmap);
657         /* Register the procedure tables */
658         rpc_init_proc_table(PORTMAP_PROGRAM, 1, portmap1_proc, hf_portmap_procedure_v1);
659         rpc_init_proc_table(PORTMAP_PROGRAM, 2, portmap2_proc, hf_portmap_procedure_v2);
660         rpc_init_proc_table(PORTMAP_PROGRAM, 3, portmap3_proc, hf_portmap_procedure_v3);
661         rpc_init_proc_table(PORTMAP_PROGRAM, 4, portmap4_proc, hf_portmap_procedure_v4);
662         rpc_handle = find_dissector("rpc");
663         rpc_tcp_handle = find_dissector("rpc-tcp");
664 }