Add support for Exif decoding (initial framework).
[obnox/wireshark/wip.git] / packet-portmap.c
1 /* packet-portmap.c
2  * Routines for portmap dissection
3  *
4  * $Id: packet-portmap.c,v 1.42 2004/01/09 00:56:04 guy Exp $
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 "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;
80         guint32 prog;
81
82         /* make sure we remember protocol type until the reply packet */
83         if(!pinfo->fd->flags.visited){
84                 rpc_call_info_value *rpc_call=pinfo->private_data;
85                 if(rpc_call){
86                         proto = tvb_get_ntohl(tvb, offset+8);
87                         if(proto==IP_PROTO_UDP){  /* only do this for UDP */
88                                 rpc_call->private_data=(void *)PT_UDP;
89                         }
90                 }
91         }
92
93         if ( tree )
94         {
95                 prog = tvb_get_ntohl(tvb, offset+0);
96                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
97                         offset, 4, prog, "Program: %s (%u)",
98                         rpc_prog_name(prog), prog);
99                 proto_tree_add_item(tree, hf_portmap_version, tvb,
100                         offset+4, 4, FALSE);
101
102                 proto = tvb_get_ntohl(tvb, offset+8);
103                 proto_tree_add_uint_format(tree, hf_portmap_proto, tvb,
104                         offset+8, 4, proto, "Proto: %s (%u)", ipprotostr(proto), proto);
105
106                 proto_tree_add_item(tree, hf_portmap_port, tvb,
107                         offset+12, 4, FALSE);
108         }
109
110         return offset+16;
111 }
112
113 static int
114 dissect_getport_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
115         proto_tree *tree)
116 {
117         /* we might have learnt a <ipaddr><protocol><port> mapping for ONC-RPC*/
118         if(!pinfo->fd->flags.visited){
119                 rpc_call_info_value *rpc_call=pinfo->private_data;
120                 /* only do this for UDP, TCP does not need anything like this */
121                 if(rpc_call && ((int)rpc_call->private_data==PT_UDP) ){
122                         guint32 port;
123                         port=tvb_get_ntohl(tvb, offset);
124                         if(port){
125                                 conversation_t *conv;
126                                 conv=find_conversation(&pinfo->src, &pinfo->dst, (port_type)rpc_call->private_data, port, 0, NO_ADDR_B|NO_PORT_B);
127                                 if(!conv){
128                                         conv=conversation_new(&pinfo->src, &pinfo->dst, (port_type)rpc_call->private_data, port, 0, NO_ADDR2|NO_PORT2);
129                                 }
130                                 conversation_set_dissector(conv, rpc_handle);
131                         }
132                 }
133         }
134
135         offset = dissect_rpc_uint32(tvb, tree, hf_portmap_port,
136             offset);
137         return offset;
138 }
139
140 /* Dissect a 'set' call */
141 static int
142 dissect_set_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
143         proto_tree *tree)
144 {
145         guint32 proto;
146         guint32 prog;
147
148         if ( tree )
149         {
150                 prog = tvb_get_ntohl(tvb, offset+0);
151                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
152                         offset, 4, prog, "Program: %s (%d)",
153                         rpc_prog_name(prog), prog);
154                 proto_tree_add_item(tree, hf_portmap_version, tvb,
155                         offset+4, 4, FALSE);
156
157                 proto = tvb_get_ntohl(tvb, offset+8);
158                 proto_tree_add_uint_format(tree, hf_portmap_proto,tvb,
159                         offset+8, 4, proto, "Proto: %s (%d)", ipprotostr(proto), proto);
160
161                 proto_tree_add_item(tree, hf_portmap_port, tvb,
162                         offset+12, 4, FALSE);
163         }
164
165         return offset+16;
166 }
167
168 /* Dissect a 'unset' call */
169 static int
170 dissect_unset_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
171         proto_tree *tree)
172 {
173         guint32 proto;
174         guint32 prog;
175
176         if ( tree )
177         {
178                 prog = tvb_get_ntohl(tvb, offset+0);
179                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
180                         offset, 4, prog, "Program: %s (%d)",
181                         rpc_prog_name(prog), prog);
182                 proto_tree_add_item(tree, hf_portmap_version, tvb,
183                         offset+4, 4, FALSE);
184
185                 proto = tvb_get_ntohl(tvb, offset+8);
186                 proto_tree_add_uint(tree, hf_portmap_proto, tvb,
187                         offset+8, 4, proto);
188
189                 proto_tree_add_item(tree, hf_portmap_port, tvb,
190                         offset+12, 4, FALSE);
191         }
192
193         return offset+16;
194 }
195
196 static int
197 dissect_set_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
198         proto_tree *tree)
199 {
200         offset = dissect_rpc_bool(tvb, tree, hf_portmap_answer,
201             offset);
202         return offset;
203 }
204
205 static int
206 dissect_dump_entry(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
207         proto_tree *tree)
208 {
209         int prog, version, proto, port;
210         proto_item *ti, *subtree;
211
212         prog = tvb_get_ntohl(tvb, offset+0);
213         version = tvb_get_ntohl(tvb, offset+4);
214         proto = tvb_get_ntohl(tvb, offset+8);
215         port = tvb_get_ntohl(tvb, offset+12);
216         if ( tree )
217         {
218                 ti = proto_tree_add_text(tree, tvb, offset, 16,
219                         "Map Entry: %s (%u) V%d",
220                         rpc_prog_name(prog), prog, version);
221                 subtree = proto_item_add_subtree(ti, ett_portmap_entry);
222
223                 proto_tree_add_uint_format(subtree, hf_portmap_prog, tvb,
224                         offset+0, 4, prog,
225                         "Program: %s (%u)", rpc_prog_name(prog), prog);
226                 proto_tree_add_uint(subtree, hf_portmap_version, tvb,
227                         offset+4, 4, version);
228                 proto_tree_add_uint_format(subtree, hf_portmap_proto, tvb,
229                         offset+8, 4, proto,
230                         "Protocol: %s (0x%02x)", ipprotostr(proto), proto);
231                 proto_tree_add_uint(subtree, hf_portmap_port, tvb,
232                         offset+12, 4, port);
233         }
234         offset += 16;
235         return offset;
236 }
237
238 static int
239 dissect_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
240         proto_tree *tree)
241 {
242         offset = dissect_rpc_list(tvb, pinfo, tree, offset,
243                 dissect_dump_entry);
244         return offset;
245 }
246
247 /* Dissect a callit call */
248 static int
249 dissect_callit_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
250         proto_tree *tree)
251 {
252         guint32 prog, vers, proc;
253
254         prog = tvb_get_ntohl(tvb, offset+0);
255         if ( tree )
256         {
257                 proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
258                         offset, 4, prog, "Program: %s (%u)",
259                         rpc_prog_name(prog), prog);
260         }
261
262         vers = tvb_get_ntohl(tvb, offset+4);
263         if ( tree )
264         {
265                 proto_tree_add_uint(tree, hf_portmap_version, tvb,
266                         offset+4, 4, vers);
267         }
268
269         proc = tvb_get_ntohl(tvb, offset+8);
270         if ( tree )
271         {
272                 proto_tree_add_uint_format(tree, hf_portmap_proc, tvb,
273                         offset+8, 4, proc, "Procedure: %s (%u)",
274                         rpc_proc_name(prog, vers, proc), proc);
275         }
276
277         offset += 12;
278
279         /* Dissect the arguments for this procedure.
280            Make the columns non-writable, so the dissector won't change
281            them out from under us. */
282         col_set_writable(pinfo->cinfo, FALSE);
283         offset = dissect_rpc_indir_call(tvb, pinfo, tree, offset,
284                 hf_portmap_args, prog, vers, proc);
285
286         return offset;
287 }
288
289 /* Dissect a callit reply */
290 static int
291 dissect_callit_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
292         proto_tree *tree)
293 {
294         if ( tree )
295         {
296                 proto_tree_add_item(tree, hf_portmap_port, tvb,
297                         offset, 4, FALSE);
298         }
299         offset += 4;
300
301         /* Dissect the result of this procedure.
302            Make the columns non-writable, so the dissector won't change
303            them out from under us. */
304         col_set_writable(pinfo->cinfo, FALSE);
305         offset = dissect_rpc_indir_reply(tvb, pinfo, tree, offset,
306                 hf_portmap_result, hf_portmap_prog, hf_portmap_version,
307                 hf_portmap_proc);
308
309         return offset;
310 }
311
312 /* proc number, "proc name", dissect_request, dissect_reply */
313 /* NULL as function pointer means: type of arguments is "void". */
314 static const vsff portmap1_proc[] = {
315         { PORTMAPPROC_NULL,     "NULL",         NULL,   NULL },
316         { PORTMAPPROC_SET,      "SET",          NULL,   NULL },
317         { PORTMAPPROC_UNSET,    "UNSET",        NULL,   NULL },
318         { PORTMAPPROC_GETPORT,  "GETPORT",      NULL,   NULL },
319         { PORTMAPPROC_DUMP,     "DUMP",         NULL,   NULL },
320         { PORTMAPPROC_CALLIT,   "CALLIT",       NULL,   NULL },
321         { 0,                    NULL,           NULL,   NULL }
322 };
323 static const value_string portmap1_proc_vals[] = {
324         { PORTMAPPROC_NULL,     "NULL" },
325         { PORTMAPPROC_SET,      "SET" },
326         { PORTMAPPROC_UNSET,    "UNSET" },
327         { PORTMAPPROC_GETPORT,  "GETPORT" },
328         { PORTMAPPROC_DUMP,     "DUMP" },
329         { PORTMAPPROC_CALLIT,   "CALLIT" },
330         { 0,                    NULL }
331 };
332 /* end of Portmap version 1 */
333
334 static const vsff portmap2_proc[] = {
335         { PORTMAPPROC_NULL, "NULL",
336                 NULL, NULL },
337         { PORTMAPPROC_SET, "SET",
338                 dissect_set_call, dissect_set_reply },
339         { PORTMAPPROC_UNSET, "UNSET",
340                 dissect_unset_call, dissect_set_reply },
341         { PORTMAPPROC_GETPORT,  "GETPORT",
342                 dissect_getport_call, dissect_getport_reply },
343         { PORTMAPPROC_DUMP, "DUMP",
344                 NULL, dissect_dump_reply },
345         { PORTMAPPROC_CALLIT, "CALLIT",
346                 dissect_callit_call, dissect_callit_reply },
347         { 0, NULL, NULL, NULL }
348 };
349 static const value_string portmap2_proc_vals[] = {
350         { PORTMAPPROC_NULL, "NULL" },
351         { PORTMAPPROC_SET, "SET" },
352         { PORTMAPPROC_UNSET, "UNSET" },
353         { PORTMAPPROC_GETPORT,  "GETPORT" },
354         { PORTMAPPROC_DUMP, "DUMP" },
355         { PORTMAPPROC_CALLIT, "CALLIT" },
356         { 0, NULL }
357 };
358 /* end of Portmap version 2 */
359
360
361 /* RFC 1833, Page 3 */
362 static int
363 dissect_rpcb(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
364 {
365         proto_item* rpcb_item = NULL;
366         proto_tree* rpcb_tree = NULL;
367         int old_offset = offset;
368         guint32 prog;
369
370         if (tree) {
371                 rpcb_item = proto_tree_add_item(tree, hf_portmap_rpcb, tvb,
372                         offset, -1, FALSE);
373                 if (rpcb_item)
374                         rpcb_tree = proto_item_add_subtree(rpcb_item, ett_portmap_rpcb);
375         }
376
377         prog = tvb_get_ntohl(tvb, offset);
378         if (rpcb_tree)
379                 proto_tree_add_uint_format(rpcb_tree, hf_portmap_rpcb_prog, tvb,
380                         offset, 4, prog,
381                         "Program: %s (%u)", rpc_prog_name(prog), prog);
382         offset += 4;
383
384         offset = dissect_rpc_uint32(tvb, rpcb_tree,
385             hf_portmap_rpcb_version, offset);
386         offset = dissect_rpc_string(tvb, rpcb_tree,
387             hf_portmap_rpcb_netid, offset, NULL);
388         offset = dissect_rpc_string(tvb, rpcb_tree,
389             hf_portmap_rpcb_addr, offset, NULL);
390         offset = dissect_rpc_string(tvb, rpcb_tree,
391             hf_portmap_rpcb_owner, offset, NULL);
392
393         /* now we know, that rpcb is shorter */
394         if (rpcb_item) {
395                 proto_item_set_len(rpcb_item, offset - old_offset);
396         }
397
398         return offset;
399 }
400
401
402
403 /* RFC 1833, Page 7 */
404 static int
405 dissect_rpcb3_getaddr_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
406         proto_tree *tree)
407 {
408         offset = dissect_rpcb(tvb, offset, pinfo, tree);
409
410         return offset;
411 }
412
413
414 /* RFC 1833, Page 7 */
415 static int
416 dissect_rpcb3_getaddr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
417         proto_tree *tree)
418 {
419         offset = dissect_rpc_string(tvb, tree,
420             hf_portmap_uaddr, offset, NULL);
421
422         return offset;
423 }
424
425
426 /* RFC 1833, Page 7 */
427 static int
428 dissect_rpcb3_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
429         proto_tree *tree)
430 {
431         offset = dissect_rpc_list(tvb, pinfo, tree, offset, dissect_rpcb);
432         return offset;
433 }
434
435 /* RFC 1833, page 4 */
436 static int
437 dissect_rpcb_rmtcallres(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
438         proto_tree *tree)
439 {
440         /* Dissect the remote universal address. */
441         offset = dissect_rpc_string(tvb, tree,
442             hf_portmap_rpcb_addr, offset, NULL);
443
444         /* Dissect the result of this procedure.
445            Make the columns non-writable, so the dissector won't change
446            them out from under us. */
447         col_set_writable(pinfo->cinfo, FALSE);
448         offset = dissect_rpc_indir_reply(tvb, pinfo, tree, offset,
449                 hf_portmap_result, hf_portmap_prog, hf_portmap_version,
450                 hf_portmap_proc);
451
452         return offset;
453 }
454
455
456 /* Portmapper version 3, RFC 1833, Page 7 */
457 static const vsff portmap3_proc[] = {
458         { RPCBPROC_NULL,        "NULL",
459                 NULL, NULL },
460         { RPCBPROC_SET,         "SET",
461                 NULL, NULL },
462         { RPCBPROC_UNSET,       "UNSET",
463                 NULL, NULL },
464         { RPCBPROC_GETADDR,     "GETADDR",
465                 dissect_rpcb3_getaddr_call, dissect_rpcb3_getaddr_reply},
466         { RPCBPROC_DUMP,        "DUMP",
467                 NULL, dissect_rpcb3_dump_reply },
468         { RPCBPROC_CALLIT,      "CALLIT",
469                 dissect_callit_call, dissect_rpcb_rmtcallres },
470         { RPCBPROC_GETTIME,     "GETTIME",
471                 NULL, NULL },
472         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR",
473                 NULL, NULL },
474         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR",
475                 NULL, NULL },
476         { 0, NULL, NULL, NULL }
477 };
478 static const value_string portmap3_proc_vals[] = {
479         { RPCBPROC_NULL,        "NULL" },
480         { RPCBPROC_SET,         "SET" },
481         { RPCBPROC_UNSET,       "UNSET" },
482         { RPCBPROC_GETADDR,     "GETADDR" },
483         { RPCBPROC_DUMP,        "DUMP" },
484         { RPCBPROC_CALLIT,      "CALLIT" },
485         { RPCBPROC_GETTIME,     "GETTIME" },
486         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR" },
487         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR" },
488         { 0, NULL }
489 };
490 /* end of Portmap version 3 */
491
492
493 /* Portmapper version 4, RFC 1833, Page 8 */
494 static const vsff portmap4_proc[] = {
495         { RPCBPROC_NULL,        "NULL",
496                 NULL, NULL },
497         { RPCBPROC_SET,         "SET",
498                 NULL, NULL },
499         { RPCBPROC_UNSET,       "UNSET",
500                 NULL, NULL },
501         { RPCBPROC_GETADDR,     "GETADDR",
502                 dissect_rpcb3_getaddr_call, dissect_rpcb3_getaddr_reply},
503         { RPCBPROC_DUMP,        "DUMP",
504                 NULL, dissect_rpcb3_dump_reply },
505         { RPCBPROC_BCAST,       "BCAST",
506                 dissect_callit_call, dissect_rpcb_rmtcallres },
507         { RPCBPROC_GETTIME,     "GETTIME",
508                 NULL, NULL },
509         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR",
510                 NULL, NULL },
511         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR",
512                 NULL, NULL },
513         { RPCBPROC_GETVERSADDR, "GETVERSADDR",
514                 NULL, NULL },
515         { RPCBPROC_INDIRECT,    "INDIRECT",
516                 dissect_callit_call, dissect_rpcb_rmtcallres },
517         { RPCBPROC_GETADDRLIST, "GETADDRLIST",
518                 NULL, NULL },
519         { RPCBPROC_GETSTAT,     "GETSTAT",
520                 NULL, NULL },
521         { 0, NULL, NULL, NULL }
522 };
523 static const value_string portmap4_proc_vals[] = {
524         { RPCBPROC_NULL,        "NULL" },
525         { RPCBPROC_SET,         "SET" },
526         { RPCBPROC_UNSET,       "UNSET" },
527         { RPCBPROC_GETADDR,     "GETADDR" },
528         { RPCBPROC_DUMP,        "DUMP" },
529         { RPCBPROC_BCAST,       "BCAST" },
530         { RPCBPROC_GETTIME,     "GETTIME" },
531         { RPCBPROC_UADDR2TADDR, "UADDR2TADDR" },
532         { RPCBPROC_TADDR2UADDR, "TADDR2UADDR" },
533         { RPCBPROC_GETVERSADDR, "GETVERSADDR" },
534         { RPCBPROC_INDIRECT,    "INDIRECT" },
535         { RPCBPROC_GETADDRLIST, "GETADDRLIST" },
536         { RPCBPROC_GETSTAT,     "GETSTAT" },
537         { 0, NULL }
538 };
539 /* end of Portmap version 4 */
540
541 void
542 proto_register_portmap(void)
543 {
544         static hf_register_info hf[] = {
545                 { &hf_portmap_procedure_v1, {
546                         "V1 Procedure", "portmap.procedure_v1", FT_UINT32, BASE_DEC,
547                         VALS(portmap1_proc_vals), 0, "V1 Procedure", HFILL }},
548                 { &hf_portmap_procedure_v2, {
549                         "V2 Procedure", "portmap.procedure_v2", FT_UINT32, BASE_DEC,
550                         VALS(portmap2_proc_vals), 0, "V2 Procedure", HFILL }},
551                 { &hf_portmap_procedure_v3, {
552                         "V3 Procedure", "portmap.procedure_v3", FT_UINT32, BASE_DEC,
553                         VALS(portmap3_proc_vals), 0, "V3 Procedure", HFILL }},
554                 { &hf_portmap_procedure_v4, {
555                         "V4 Procedure", "portmap.procedure_v4", FT_UINT32, BASE_DEC,
556                         VALS(portmap4_proc_vals), 0, "V4 Procedure", HFILL }},
557                 { &hf_portmap_prog, {
558                         "Program", "portmap.prog", FT_UINT32, BASE_DEC,
559                         NULL, 0, "Program", HFILL }},
560                 { &hf_portmap_port, {
561                         "Port", "portmap.port", FT_UINT32, BASE_DEC,
562                         NULL, 0, "Port", HFILL }},
563                 { &hf_portmap_proc, {
564                         "Procedure", "portmap.proc", FT_UINT32, BASE_DEC,
565                         NULL, 0, "Procedure", HFILL }},
566                 { &hf_portmap_proto, {
567                         "Protocol", "portmap.proto", FT_UINT32, BASE_DEC,
568                         NULL, 0, "Protocol", HFILL }},
569                 { &hf_portmap_version, {
570                         "Version", "portmap.version", FT_UINT32, BASE_DEC,
571                         NULL, 0, "Version", HFILL }},
572                 { &hf_portmap_answer, {
573                         "Answer", "portmap.answer", FT_BOOLEAN, BASE_DEC,
574                         NULL, 0, "Answer", HFILL }},
575                 { &hf_portmap_args, {
576                         "Arguments", "portmap.args", FT_BYTES, BASE_HEX,
577                         NULL, 0, "Arguments", HFILL }},
578                 { &hf_portmap_result, {
579                         "Result", "portmap.result", FT_BYTES, BASE_HEX,
580                         NULL, 0, "Result", HFILL }},
581                 { &hf_portmap_rpcb, {
582                         "RPCB", "portmap.rpcb", FT_NONE, 0,
583                         NULL, 0, "RPCB", HFILL }},
584                 { &hf_portmap_rpcb_prog, {
585                         "Program", "portmap.rpcb.prog", FT_UINT32, BASE_DEC,
586                         NULL, 0, "Program", HFILL }},
587                 { &hf_portmap_rpcb_version, {
588                         "Version", "portmap.rpcb.version", FT_UINT32, BASE_DEC,
589                         NULL, 0, "Version", HFILL }},
590                 { &hf_portmap_rpcb_netid, {
591                         "Network Id", "portmap.rpcb.netid", FT_STRING, BASE_DEC,
592                         NULL, 0, "Network Id", HFILL }},
593                 { &hf_portmap_rpcb_addr, {      /* address in rpcb structure in request */
594                         "Universal Address", "portmap.rpcb.addr", FT_STRING, BASE_DEC,
595                         NULL, 0, "Universal Address", HFILL }},
596                 { &hf_portmap_rpcb_owner, {
597                         "Owner of this Service", "portmap.rpcb.owner", FT_STRING, BASE_DEC,
598                         NULL, 0, "Owner of this Service", HFILL }},
599                 { &hf_portmap_uaddr, {  /* address in RPCBPROC_GETADDR reply */
600                         "Universal Address", "portmap.uaddr", FT_STRING, BASE_DEC,
601                         NULL, 0, "Universal Address", HFILL }},
602         };
603         static gint *ett[] = {
604                 &ett_portmap,
605                 &ett_portmap_rpcb,
606                 &ett_portmap_entry
607         };
608
609         proto_portmap = proto_register_protocol("Portmap", "Portmap", "portmap");
610         proto_register_field_array(proto_portmap, hf, array_length(hf));
611         proto_register_subtree_array(ett, array_length(ett));
612 }
613
614 void
615 proto_reg_handoff_portmap(void)
616 {
617         /* Register the protocol as RPC */
618         rpc_init_prog(proto_portmap, PORTMAP_PROGRAM, ett_portmap);
619         /* Register the procedure tables */
620         rpc_init_proc_table(PORTMAP_PROGRAM, 1, portmap1_proc, hf_portmap_procedure_v1);
621         rpc_init_proc_table(PORTMAP_PROGRAM, 2, portmap2_proc, hf_portmap_procedure_v2);
622         rpc_init_proc_table(PORTMAP_PROGRAM, 3, portmap3_proc, hf_portmap_procedure_v3);
623         rpc_init_proc_table(PORTMAP_PROGRAM, 4, portmap4_proc, hf_portmap_procedure_v4);
624         rpc_handle = find_dissector("rpc");
625         rpc_tcp_handle = find_dissector("rpc-tcp");
626 }