2 * Routines for rpc dissection
3 * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-smb.c
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/packet.h>
37 #include <epan/conversation.h>
38 #include <epan/emem.h>
39 #include "packet-rpc.h"
40 #include "packet-frame.h"
41 #include "packet-tcp.h"
42 #include <epan/prefs.h>
43 #include <epan/reassemble.h>
44 #include <epan/dissectors/rpc_defrag.h>
45 #include "packet-nfs.h"
47 #include <epan/strutil.h>
48 #include <epan/garrayfix.h>
53 * RFC 1831, "RPC: Remote Procedure Call Protocol Specification
56 * RFC 1832, "XDR: External Data Representation Standard";
58 * RFC 2203, "RPCSEC_GSS Protocol Specification".
62 * RFC 2695, "Authentication Mechanisms for ONC RPC"
64 * although we don't currently dissect AUTH_DES or AUTH_KERB.
67 /* desegmentation of RPC over TCP */
68 static gboolean rpc_desegment = TRUE;
70 /* defragmentation of fragmented RPC over TCP records */
71 static gboolean rpc_defragment = TRUE;
73 /* try to dissect RPC packets for programs that are not known
74 * (proprietary ones) by wireshark.
76 static gboolean rpc_dissect_unknown_programs = FALSE;
78 /* try to find RPC fragment start if normal decode fails
79 * (good when starting decode of mid-stream capture)
81 static gboolean rpc_find_fragment_start = FALSE;
83 static int rpc_tap = -1;
85 static const value_string rpc_msg_type[] = {
87 { RPC_REPLY, "Reply" },
91 static const value_string rpc_reply_state[] = {
92 { MSG_ACCEPTED, "accepted" },
93 { MSG_DENIED, "denied" },
97 const value_string rpc_auth_flavor[] = {
98 { AUTH_NULL, "AUTH_NULL" },
99 { AUTH_UNIX, "AUTH_UNIX" },
100 { AUTH_SHORT, "AUTH_SHORT" },
101 { AUTH_DES, "AUTH_DES" },
102 { RPCSEC_GSS, "RPCSEC_GSS" },
103 { AUTH_GSSAPI, "AUTH_GSSAPI" },
104 { RPCSEC_GSS_KRB5, "RPCSEC_GSS_KRB5" },
105 { RPCSEC_GSS_KRB5I, "RPCSEC_GSS_KRB5I" },
106 { RPCSEC_GSS_KRB5P, "RPCSEC_GSS_KRB5P" },
107 { RPCSEC_GSS_LIPKEY, "RPCSEC_GSS_LIPKEY" },
108 { RPCSEC_GSS_LIPKEY_I, "RPCSEC_GSS_LIPKEY_I" },
109 { RPCSEC_GSS_LIPKEY_P, "RPCSEC_GSS_LIPKEY_P" },
110 { RPCSEC_GSS_SPKM3, "RPCSEC_GSS_SPKM3" },
111 { RPCSEC_GSS_SPKM3I, "RPCSEC_GSS_SPKM3I" },
112 { RPCSEC_GSS_SPKM3P, "RPCSEC_GSS_SPKM3P" },
116 static const value_string rpc_authgss_proc[] = {
117 { RPCSEC_GSS_DATA, "RPCSEC_GSS_DATA" },
118 { RPCSEC_GSS_INIT, "RPCSEC_GSS_INIT" },
119 { RPCSEC_GSS_CONTINUE_INIT, "RPCSEC_GSS_CONTINUE_INIT" },
120 { RPCSEC_GSS_DESTROY, "RPCSEC_GSS_DESTROY" },
124 static const value_string rpc_authgssapi_proc[] = {
125 { AUTH_GSSAPI_EXIT, "AUTH_GSSAPI_EXIT" },
126 { AUTH_GSSAPI_INIT, "AUTH_GSSAPI_INIT" },
127 { AUTH_GSSAPI_CONTINUE_INIT, "AUTH_GSSAPI_CONTINUE_INIT" },
128 { AUTH_GSSAPI_MSG, "AUTH_GSSAPI_MSG" },
129 { AUTH_GSSAPI_DESTROY, "AUTH_GSSAPI_DESTROY" },
133 const value_string rpc_authgss_svc[] = {
134 { RPCSEC_GSS_SVC_NONE, "rpcsec_gss_svc_none" },
135 { RPCSEC_GSS_SVC_INTEGRITY, "rpcsec_gss_svc_integrity" },
136 { RPCSEC_GSS_SVC_PRIVACY, "rpcsec_gss_svc_privacy" },
140 static const value_string rpc_accept_state[] = {
141 { SUCCESS, "RPC executed successfully" },
142 { PROG_UNAVAIL, "remote hasn't exported program" },
143 { PROG_MISMATCH, "remote can't support version #" },
144 { PROC_UNAVAIL, "program can't support procedure" },
145 { GARBAGE_ARGS, "procedure can't decode params" },
146 { SYSTEM_ERROR, "system errors like memory allocation failure" },
150 static const value_string rpc_reject_state[] = {
151 { RPC_MISMATCH, "RPC_MISMATCH" },
152 { AUTH_ERROR, "AUTH_ERROR" },
156 static const value_string rpc_auth_state[] = {
157 { AUTH_BADCRED, "bad credential (seal broken)" },
158 { AUTH_REJECTEDCRED, "client must begin new session" },
159 { AUTH_BADVERF, "bad verifier (seal broken)" },
160 { AUTH_REJECTEDVERF, "verifier expired or replayed" },
161 { AUTH_TOOWEAK, "rejected for security reasons" },
162 { RPCSEC_GSSCREDPROB, "GSS credential problem" },
163 { RPCSEC_GSSCTXPROB, "GSS context problem" },
167 static const value_string rpc_authdes_namekind[] = {
168 { AUTHDES_NAMEKIND_FULLNAME, "ADN_FULLNAME" },
169 { AUTHDES_NAMEKIND_NICKNAME, "ADN_NICKNAME" },
173 /* the protocol number */
174 static int proto_rpc = -1;
175 static int hf_rpc_reqframe = -1;
176 static int hf_rpc_repframe = -1;
177 static int hf_rpc_lastfrag = -1;
178 static int hf_rpc_fraglen = -1;
179 static int hf_rpc_xid = -1;
180 static int hf_rpc_msgtype = -1;
181 static int hf_rpc_version = -1;
182 static int hf_rpc_version_min = -1;
183 static int hf_rpc_version_max = -1;
184 static int hf_rpc_program = -1;
185 static int hf_rpc_programversion = -1;
186 static int hf_rpc_programversion_min = -1;
187 static int hf_rpc_programversion_max = -1;
188 static int hf_rpc_procedure = -1;
189 static int hf_rpc_auth_flavor = -1;
190 static int hf_rpc_auth_length = -1;
191 static int hf_rpc_auth_machinename = -1;
192 static int hf_rpc_auth_stamp = -1;
193 static int hf_rpc_auth_uid = -1;
194 static int hf_rpc_auth_gid = -1;
195 static int hf_rpc_authgss_v = -1;
196 static int hf_rpc_authgss_proc = -1;
197 static int hf_rpc_authgss_seq = -1;
198 static int hf_rpc_authgss_svc = -1;
199 static int hf_rpc_authgss_ctx = -1;
200 static int hf_rpc_authgss_major = -1;
201 static int hf_rpc_authgss_minor = -1;
202 static int hf_rpc_authgss_window = -1;
203 static int hf_rpc_authgss_token_length = -1;
204 static int hf_rpc_authgss_data_length = -1;
205 static int hf_rpc_authgss_data = -1;
206 static int hf_rpc_authgss_token = -1;
207 static int hf_rpc_authgss_checksum = -1;
208 static int hf_rpc_authgssapi_v = -1;
209 static int hf_rpc_authgssapi_msg = -1;
210 static int hf_rpc_authgssapi_msgv = -1;
211 static int hf_rpc_authgssapi_handle = -1;
212 static int hf_rpc_authgssapi_isn = -1;
213 static int hf_rpc_authdes_namekind = -1;
214 static int hf_rpc_authdes_netname = -1;
215 static int hf_rpc_authdes_convkey = -1;
216 static int hf_rpc_authdes_window = -1;
217 static int hf_rpc_authdes_nickname = -1;
218 static int hf_rpc_authdes_timestamp = -1;
219 static int hf_rpc_authdes_windowverf = -1;
220 static int hf_rpc_authdes_timeverf = -1;
221 static int hf_rpc_state_accept = -1;
222 static int hf_rpc_state_reply = -1;
223 static int hf_rpc_state_reject = -1;
224 static int hf_rpc_state_auth = -1;
225 static int hf_rpc_dup = -1;
226 static int hf_rpc_call_dup = -1;
227 static int hf_rpc_reply_dup = -1;
228 static int hf_rpc_value_follows = -1;
229 static int hf_rpc_array_len = -1;
230 static int hf_rpc_time = -1;
231 static int hf_rpc_fragments = -1;
232 static int hf_rpc_fragment = -1;
233 static int hf_rpc_fragment_overlap = -1;
234 static int hf_rpc_fragment_overlap_conflict = -1;
235 static int hf_rpc_fragment_multiple_tails = -1;
236 static int hf_rpc_fragment_too_long_fragment = -1;
237 static int hf_rpc_fragment_error = -1;
239 static gint ett_rpc = -1;
240 static gint ett_rpc_unknown_program = -1;
241 static gint ett_rpc_fragments = -1;
242 static gint ett_rpc_fragment = -1;
243 static gint ett_rpc_fraghdr = -1;
244 static gint ett_rpc_string = -1;
245 static gint ett_rpc_cred = -1;
246 static gint ett_rpc_verf = -1;
247 static gint ett_rpc_gids = -1;
248 static gint ett_rpc_gss_token = -1;
249 static gint ett_rpc_gss_data = -1;
250 static gint ett_rpc_array = -1;
251 static gint ett_rpc_authgssapi_msg = -1;
253 static dissector_handle_t rpc_tcp_handle;
254 static dissector_handle_t rpc_handle;
255 static dissector_handle_t gssapi_handle;
256 static dissector_handle_t data_handle;
258 static guint max_rpc_tcp_pdu_size = 4 * 1024 * 1024;
260 static const fragment_items rpc_frag_items = {
265 &hf_rpc_fragment_overlap,
266 &hf_rpc_fragment_overlap_conflict,
267 &hf_rpc_fragment_multiple_tails,
268 &hf_rpc_fragment_too_long_fragment,
269 &hf_rpc_fragment_error,
274 /* Hash table with info on RPC program numbers */
275 GHashTable *rpc_progs = NULL;
277 /* Hash table with info on RPC procedure numbers */
278 GHashTable *rpc_procs = NULL;
280 static void dissect_rpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
281 static void dissect_rpc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
283 /***********************************/
284 /* Hash array with procedure names */
285 /***********************************/
289 rpc_proc_equal(gconstpointer k1, gconstpointer k2)
291 const rpc_proc_info_key* key1 = (const rpc_proc_info_key*) k1;
292 const rpc_proc_info_key* key2 = (const rpc_proc_info_key*) k2;
294 return ((key1->prog == key2->prog &&
295 key1->vers == key2->vers &&
296 key1->proc == key2->proc) ?
300 /* calculate a hash key */
302 rpc_proc_hash(gconstpointer k)
304 const rpc_proc_info_key* key = (const rpc_proc_info_key*) k;
306 return (key->prog ^ (key->vers<<16) ^ (key->proc<<24));
310 /* insert some entries */
312 rpc_init_proc_table(guint prog, guint vers, const vsff *proc_table,
315 rpc_prog_info_key rpc_prog_key;
316 rpc_prog_info_value *rpc_prog;
320 * Add the operation number hfinfo value for this version of the
323 rpc_prog_key.prog = prog;
324 rpc_prog = g_hash_table_lookup(rpc_progs, &rpc_prog_key);
325 DISSECTOR_ASSERT(rpc_prog != NULL);
326 rpc_prog->procedure_hfs = g_array_set_size(rpc_prog->procedure_hfs,
328 g_array_insert_val(rpc_prog->procedure_hfs, vers, procedure_hf);
330 for (proc = proc_table ; proc->strptr!=NULL; proc++) {
331 rpc_proc_info_key *key;
332 rpc_proc_info_value *value;
334 key = (rpc_proc_info_key *) g_malloc(sizeof(rpc_proc_info_key));
337 key->proc = proc->value;
339 value = (rpc_proc_info_value *) g_malloc(sizeof(rpc_proc_info_value));
340 value->name = proc->strptr;
341 value->dissect_call = proc->dissect_call;
342 value->dissect_reply = proc->dissect_reply;
344 g_hash_table_insert(rpc_procs,key,value);
349 /* return the name associated with a previously registered procedure. */
351 rpc_proc_name(guint32 prog, guint32 vers, guint32 proc)
353 rpc_proc_info_key key;
354 rpc_proc_info_value *value;
357 procname=ep_alloc(20);
362 if ((value = g_hash_table_lookup(rpc_procs,&key)) != NULL)
363 procname = (char *)value->name;
365 /* happens only with strange program versions or
366 non-existing dissectors */
367 g_snprintf(procname, 20, "proc-%u", key.proc);
372 /*----------------------------------------*/
373 /* end of Hash array with procedure names */
374 /*----------------------------------------*/
377 /*********************************/
378 /* Hash array with program names */
379 /*********************************/
383 rpc_prog_equal(gconstpointer k1, gconstpointer k2)
385 const rpc_prog_info_key* key1 = (const rpc_prog_info_key*) k1;
386 const rpc_prog_info_key* key2 = (const rpc_prog_info_key*) k2;
388 return ((key1->prog == key2->prog) ?
393 /* calculate a hash key */
395 rpc_prog_hash(gconstpointer k)
397 const rpc_prog_info_key* key = (const rpc_prog_info_key*) k;
404 rpc_init_prog(int proto, guint32 prog, int ett)
406 rpc_prog_info_key *key;
407 rpc_prog_info_value *value;
409 key = (rpc_prog_info_key *) g_malloc(sizeof(rpc_prog_info_key));
412 value = (rpc_prog_info_value *) g_malloc(sizeof(rpc_prog_info_value));
413 value->proto = find_protocol_by_id(proto);
414 value->proto_id = proto;
416 value->progname = proto_get_protocol_short_name(value->proto);
417 value->procedure_hfs = g_array_new(FALSE, TRUE, sizeof (int));
419 g_hash_table_insert(rpc_progs,key,value);
424 /* return the hf_field associated with a previously registered program.
426 int rpc_prog_hf(guint32 prog, guint32 vers)
428 rpc_prog_info_key rpc_prog_key;
429 rpc_prog_info_value *rpc_prog;
431 rpc_prog_key.prog = prog;
432 if ((rpc_prog = g_hash_table_lookup(rpc_progs,&rpc_prog_key))) {
433 return g_array_index(rpc_prog->procedure_hfs, int, vers);
438 /* return the name associated with a previously registered program. This
439 should probably eventually be expanded to use the rpc YP/NIS map
440 so that it can give names for programs not handled by wireshark */
441 const char *rpc_prog_name(guint32 prog)
443 const char *progname = NULL;
444 rpc_prog_info_key rpc_prog_key;
445 rpc_prog_info_value *rpc_prog;
447 rpc_prog_key.prog = prog;
448 if ((rpc_prog = g_hash_table_lookup(rpc_progs,&rpc_prog_key)) == NULL) {
449 progname = "Unknown";
452 progname = rpc_prog->progname;
458 /*--------------------------------------*/
459 /* end of Hash array with program names */
460 /*--------------------------------------*/
462 /* One of these structures are created for each conversation that contains
463 * RPC and contains the state we need to maintain for the conversation.
465 typedef struct _rpc_conv_info_t {
471 rpc_roundup(unsigned int a)
473 unsigned int mod = a % 4;
475 ret = a + ((mod)? 4-mod : 0);
476 /* Check for overflow */
478 THROW(ReportedBoundsError);
484 dissect_rpc_bool(tvbuff_t *tvb, proto_tree *tree,
485 int hfindex, int offset)
488 proto_tree_add_item(tree, hfindex, tvb, offset, 4, FALSE);
494 dissect_rpc_uint32(tvbuff_t *tvb, proto_tree *tree,
495 int hfindex, int offset)
498 proto_tree_add_item(tree, hfindex, tvb, offset, 4, FALSE);
504 dissect_rpc_uint64(tvbuff_t *tvb, proto_tree *tree,
505 int hfindex, int offset)
507 header_field_info *hfinfo;
509 hfinfo = proto_registrar_get_nth(hfindex);
510 DISSECTOR_ASSERT(hfinfo->type == FT_UINT64);
512 proto_tree_add_item(tree, hfindex, tvb, offset, 8, FALSE);
518 * We want to make this function available outside this file and
519 * allow callers to pass a dissection function for the opaque data
522 dissect_rpc_opaque_data(tvbuff_t *tvb, int offset,
526 gboolean fixed_length, guint32 length,
527 gboolean string_data, char **string_buffer_ret,
528 dissect_function_t *dissect_it)
531 proto_item *string_item = NULL;
532 proto_tree *string_tree = NULL;
534 guint32 string_length;
535 guint32 string_length_full;
536 guint32 string_length_packet;
537 guint32 string_length_captured;
538 guint32 string_length_copy;
542 guint32 fill_length_packet;
543 guint32 fill_length_captured;
544 guint32 fill_length_copy;
548 char *string_buffer = NULL;
549 char *string_buffer_print = NULL;
552 string_length = length;
553 data_offset = offset;
556 string_length = tvb_get_ntohl(tvb,offset+0);
557 data_offset = offset + 4;
559 string_length_captured = tvb_length_remaining(tvb, data_offset);
560 string_length_packet = tvb_reported_length_remaining(tvb, data_offset);
561 string_length_full = rpc_roundup(string_length);
562 if (string_length_captured < string_length) {
563 /* truncated string */
564 string_length_copy = string_length_captured;
567 fill_length_copy = 0;
568 if (string_length_packet < string_length)
569 exception = ReportedBoundsError;
571 exception = BoundsError;
574 /* full string data */
575 string_length_copy = string_length;
576 fill_length = string_length_full - string_length;
577 fill_length_captured = tvb_length_remaining(tvb,
578 data_offset + string_length);
579 fill_length_packet = tvb_reported_length_remaining(tvb,
580 data_offset + string_length);
581 if (fill_length_captured < fill_length) {
582 /* truncated fill bytes */
583 fill_length_copy = fill_length_packet;
585 if (fill_length_packet < fill_length)
586 exception = ReportedBoundsError;
588 exception = BoundsError;
591 /* full fill bytes */
592 fill_length_copy = fill_length;
598 * If we were passed a dissection routine, make a TVB of the data
599 * and call the dissection routine
603 tvbuff_t *opaque_tvb;
605 opaque_tvb = tvb_new_subset(tvb, data_offset, string_length_copy,
608 return (*dissect_it)(opaque_tvb, offset, pinfo, tree);
614 tmpstr = tvb_get_ephemeral_string(tvb, data_offset, string_length_copy);
615 string_buffer = memcpy(ep_alloc(string_length_copy+1), tmpstr, string_length_copy);
617 string_buffer = tvb_memcpy(tvb, ep_alloc(string_length_copy+1), data_offset, string_length_copy);
619 string_buffer[string_length_copy] = '\0';
620 /* calculate a nice printable string */
622 if (string_length != string_length_copy) {
626 formatted = format_text(string_buffer, strlen(string_buffer));
627 /* copy over the data and append <TRUNCATED> */
628 string_buffer_print=ep_strdup_printf("%s%s", formatted, RPC_STRING_TRUNCATED);
630 string_buffer_print=RPC_STRING_DATA RPC_STRING_TRUNCATED;
634 string_buffer_print =
635 ep_strdup(format_text(string_buffer, strlen(string_buffer)));
637 string_buffer_print=RPC_STRING_DATA;
641 string_buffer_print=RPC_STRING_EMPTY;
645 string_item = proto_tree_add_text(tree, tvb,offset+0, -1,
646 "%s: %s", proto_registrar_get_name(hfindex),
647 string_buffer_print);
648 string_tree = proto_item_add_subtree(string_item,
653 proto_tree_add_text(string_tree, tvb,offset+0,4,
654 "length: %u", string_length);
660 proto_tree_add_string_format(string_tree,
661 hfindex, tvb, offset, string_length_copy,
663 "contents: %s", string_buffer_print);
665 proto_tree_add_bytes_format(string_tree,
666 hfindex, tvb, offset, string_length_copy,
668 "contents: %s", string_buffer_print);
672 offset += string_length_copy;
676 if (fill_truncated) {
677 proto_tree_add_text(string_tree, tvb,
678 offset,fill_length_copy,
679 "fill bytes: opaque data<TRUNCATED>");
682 proto_tree_add_text(string_tree, tvb,
683 offset,fill_length_copy,
684 "fill bytes: opaque data");
687 offset += fill_length_copy;
691 proto_item_set_end(string_item, tvb, offset);
693 if (string_buffer_ret != NULL)
694 *string_buffer_ret = string_buffer_print;
697 * If the data was truncated, throw the appropriate exception,
698 * so that dissection stops and the frame is properly marked.
707 dissect_rpc_string(tvbuff_t *tvb, proto_tree *tree,
708 int hfindex, int offset, char **string_buffer_ret)
710 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL,
711 hfindex, FALSE, 0, TRUE, string_buffer_ret, NULL);
717 dissect_rpc_data(tvbuff_t *tvb, proto_tree *tree,
718 int hfindex, int offset)
720 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL,
721 hfindex, FALSE, 0, FALSE, NULL, NULL);
727 dissect_rpc_bytes(tvbuff_t *tvb, proto_tree *tree,
728 int hfindex, int offset, guint32 length,
729 gboolean string_data, char **string_buffer_ret)
731 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL,
732 hfindex, TRUE, length, string_data, string_buffer_ret, NULL);
738 dissect_rpc_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
739 int offset, dissect_function_t *rpc_list_dissector)
741 guint32 value_follows;
744 value_follows = tvb_get_ntohl(tvb, offset+0);
745 proto_tree_add_boolean(tree,hf_rpc_value_follows, tvb,
746 offset+0, 4, value_follows);
748 if (value_follows == 1) {
749 offset = rpc_list_dissector(tvb, offset, pinfo, tree);
760 dissect_rpc_array(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
761 int offset, dissect_function_t *rpc_array_dissector,
764 proto_item* lock_item;
765 proto_tree* lock_tree;
768 num = tvb_get_ntohl(tvb, offset);
771 proto_tree_add_none_format(tree, hfindex, tvb, offset, 4,
778 lock_item = proto_tree_add_item(tree, hfindex, tvb, offset, -1, FALSE);
780 lock_tree = proto_item_add_subtree(lock_item, ett_rpc_array);
782 offset = dissect_rpc_uint32(tvb, lock_tree,
783 hf_rpc_array_len, offset);
786 offset = rpc_array_dissector(tvb, offset, pinfo, lock_tree);
789 proto_item_set_end(lock_item, tvb, offset);
794 dissect_rpc_authunix_cred(tvbuff_t* tvb, proto_tree* tree, int offset)
803 proto_tree *gtree = NULL;
805 stamp = tvb_get_ntohl(tvb,offset+0);
807 proto_tree_add_uint(tree, hf_rpc_auth_stamp, tvb,
811 offset = dissect_rpc_string(tvb, tree,
812 hf_rpc_auth_machinename, offset, NULL);
814 uid = tvb_get_ntohl(tvb,offset+0);
816 proto_tree_add_uint(tree, hf_rpc_auth_uid, tvb,
820 gid = tvb_get_ntohl(tvb,offset+0);
822 proto_tree_add_uint(tree, hf_rpc_auth_gid, tvb,
826 gids_count = tvb_get_ntohl(tvb,offset+0);
828 gitem = proto_tree_add_text(tree, tvb,
829 offset, 4+gids_count*4, "Auxiliary GIDs");
830 gtree = proto_item_add_subtree(gitem, ett_rpc_gids);
834 for (gids_i = 0 ; gids_i < gids_count ; gids_i++) {
835 gids_entry = tvb_get_ntohl(tvb,offset+0);
837 proto_tree_add_uint(gtree, hf_rpc_auth_gid, tvb,
838 offset, 4, gids_entry);
841 /* how can I NOW change the gitem to print a list with
842 the first 16 gids? */
848 dissect_rpc_authgss_cred(tvbuff_t* tvb, proto_tree* tree, int offset)
855 agc_v = tvb_get_ntohl(tvb, offset+0);
857 proto_tree_add_uint(tree, hf_rpc_authgss_v,
858 tvb, offset+0, 4, agc_v);
861 agc_proc = tvb_get_ntohl(tvb, offset+0);
863 proto_tree_add_uint(tree, hf_rpc_authgss_proc,
864 tvb, offset+0, 4, agc_proc);
867 agc_seq = tvb_get_ntohl(tvb, offset+0);
869 proto_tree_add_uint(tree, hf_rpc_authgss_seq,
870 tvb, offset+0, 4, agc_seq);
873 agc_svc = tvb_get_ntohl(tvb, offset+0);
875 proto_tree_add_uint(tree, hf_rpc_authgss_svc,
876 tvb, offset+0, 4, agc_svc);
879 offset = dissect_rpc_data(tvb, tree, hf_rpc_authgss_ctx,
886 dissect_rpc_authdes_desblock(tvbuff_t *tvb, proto_tree *tree,
887 int hfindex, int offset)
892 value_high = tvb_get_ntohl(tvb, offset + 0);
893 value_low = tvb_get_ntohl(tvb, offset + 4);
896 proto_tree_add_text(tree, tvb, offset, 8,
897 "%s: 0x%x%08x", proto_registrar_get_name(hfindex), value_high,
905 dissect_rpc_authdes_cred(tvbuff_t* tvb, proto_tree* tree, int offset)
911 adc_namekind = tvb_get_ntohl(tvb, offset+0);
913 proto_tree_add_uint(tree, hf_rpc_authdes_namekind,
914 tvb, offset+0, 4, adc_namekind);
919 case AUTHDES_NAMEKIND_FULLNAME:
920 offset = dissect_rpc_string(tvb, tree,
921 hf_rpc_authdes_netname, offset, NULL);
922 offset = dissect_rpc_authdes_desblock(tvb, tree,
923 hf_rpc_authdes_convkey, offset);
924 window = tvb_get_ntohl(tvb, offset+0);
925 proto_tree_add_uint(tree, hf_rpc_authdes_window, tvb, offset+0, 4,
930 case AUTHDES_NAMEKIND_NICKNAME:
931 nickname = tvb_get_ntohl(tvb, offset+0);
932 proto_tree_add_uint(tree, hf_rpc_authdes_nickname, tvb, offset+0, 4,
942 dissect_rpc_authgssapi_cred(tvbuff_t* tvb, proto_tree* tree, int offset)
947 agc_v = tvb_get_ntohl(tvb, offset+0);
949 proto_tree_add_uint(tree, hf_rpc_authgssapi_v,
950 tvb, offset+0, 4, agc_v);
953 agc_msg = tvb_get_ntohl(tvb, offset+0);
955 proto_tree_add_boolean(tree, hf_rpc_authgssapi_msg,
956 tvb, offset+0, 4, agc_msg);
959 offset = dissect_rpc_data(tvb, tree, hf_rpc_authgssapi_handle,
966 dissect_rpc_cred(tvbuff_t* tvb, proto_tree* tree, int offset)
974 flavor = tvb_get_ntohl(tvb,offset+0);
975 length = tvb_get_ntohl(tvb,offset+4);
976 length = rpc_roundup(length);
979 citem = proto_tree_add_text(tree, tvb, offset,
980 8+length, "Credentials");
981 ctree = proto_item_add_subtree(citem, ett_rpc_cred);
982 proto_tree_add_uint(ctree, hf_rpc_auth_flavor, tvb,
983 offset+0, 4, flavor);
984 proto_tree_add_uint(ctree, hf_rpc_auth_length, tvb,
985 offset+4, 4, length);
989 dissect_rpc_authunix_cred(tvb, ctree, offset+8);
997 dissect_rpc_authdes_cred(tvb, ctree, offset+8);
1001 dissect_rpc_authgss_cred(tvb, ctree, offset+8);
1005 dissect_rpc_authgssapi_cred(tvb, ctree, offset+8);
1010 proto_tree_add_text(ctree, tvb, offset+8,
1011 length,"opaque data");
1015 offset += 8 + length;
1021 * XDR opaque object, the contents of which are interpreted as a GSS-API
1025 dissect_rpc_authgss_token(tvbuff_t* tvb, proto_tree* tree, int offset,
1026 packet_info *pinfo, int hfindex)
1028 guint32 opaque_length, rounded_length;
1029 gint len_consumed, length, reported_length;
1033 proto_tree *gtree = NULL;
1035 opaque_length = tvb_get_ntohl(tvb, offset+0);
1036 rounded_length = rpc_roundup(opaque_length);
1038 gitem = proto_tree_add_item(tree, hfindex, tvb, offset, 4+rounded_length, FALSE);
1039 gtree = proto_item_add_subtree(gitem, ett_rpc_gss_token);
1040 proto_tree_add_uint(gtree, hf_rpc_authgss_token_length,
1041 tvb, offset+0, 4, opaque_length);
1044 if (opaque_length != 0) {
1045 length = tvb_length_remaining(tvb, offset);
1046 reported_length = tvb_reported_length_remaining(tvb, offset);
1047 DISSECTOR_ASSERT(length >= 0);
1048 DISSECTOR_ASSERT(reported_length >= 0);
1049 if (length > reported_length)
1050 length = reported_length;
1051 if ((guint32)length > opaque_length)
1052 length = opaque_length;
1053 if ((guint32)reported_length > opaque_length)
1054 reported_length = opaque_length;
1055 new_tvb = tvb_new_subset(tvb, offset, length, reported_length);
1056 len_consumed = call_dissector(gssapi_handle, new_tvb, pinfo, gtree);
1057 offset += len_consumed;
1059 offset = rpc_roundup(offset);
1063 /* AUTH_DES verifiers are asymmetrical, so we need to know what type of
1064 * verifier we're decoding (CALL or REPLY).
1067 dissect_rpc_verf(tvbuff_t* tvb, proto_tree* tree, int offset, int msg_type,
1076 flavor = tvb_get_ntohl(tvb,offset+0);
1077 length = tvb_get_ntohl(tvb,offset+4);
1078 length = rpc_roundup(length);
1081 vitem = proto_tree_add_text(tree, tvb, offset,
1082 8+length, "Verifier");
1083 vtree = proto_item_add_subtree(vitem, ett_rpc_verf);
1084 proto_tree_add_uint(vtree, hf_rpc_auth_flavor, tvb,
1085 offset+0, 4, flavor);
1089 proto_tree_add_uint(vtree, hf_rpc_auth_length, tvb,
1090 offset+4, 4, length);
1091 dissect_rpc_authunix_cred(tvb, vtree, offset+8);
1094 proto_tree_add_uint(vtree, hf_rpc_auth_length, tvb,
1095 offset+4, 4, length);
1097 if (msg_type == RPC_CALL)
1101 dissect_rpc_authdes_desblock(tvb, vtree,
1102 hf_rpc_authdes_timestamp, offset+8);
1103 window = tvb_get_ntohl(tvb, offset+16);
1104 proto_tree_add_uint(vtree, hf_rpc_authdes_windowverf, tvb,
1105 offset+16, 4, window);
1109 /* must be an RPC_REPLY */
1112 dissect_rpc_authdes_desblock(tvb, vtree,
1113 hf_rpc_authdes_timeverf, offset+8);
1114 nickname = tvb_get_ntohl(tvb, offset+16);
1115 proto_tree_add_uint(vtree, hf_rpc_authdes_nickname, tvb,
1116 offset+16, 4, nickname);
1120 dissect_rpc_authgss_token(tvb, vtree, offset+4, pinfo, hf_rpc_authgss_token);
1123 proto_tree_add_uint(vtree, hf_rpc_auth_length, tvb,
1124 offset+4, 4, length);
1126 proto_tree_add_text(vtree, tvb, offset+8,
1127 length, "opaque data");
1131 offset += 8 + length;
1137 dissect_rpc_authgss_initarg(tvbuff_t* tvb, proto_tree* tree, int offset,
1140 return dissect_rpc_authgss_token(tvb, tree, offset, pinfo, hf_rpc_authgss_token);
1144 dissect_rpc_authgss_initres(tvbuff_t* tvb, proto_tree* tree, int offset,
1147 int major, minor, window;
1149 offset = dissect_rpc_data(tvb, tree, hf_rpc_authgss_ctx,
1152 major = tvb_get_ntohl(tvb,offset+0);
1154 proto_tree_add_uint(tree, hf_rpc_authgss_major, tvb,
1155 offset+0, 4, major);
1158 minor = tvb_get_ntohl(tvb,offset+0);
1160 proto_tree_add_uint(tree, hf_rpc_authgss_minor, tvb,
1161 offset+0, 4, minor);
1164 window = tvb_get_ntohl(tvb,offset+0);
1166 proto_tree_add_uint(tree, hf_rpc_authgss_window, tvb,
1167 offset+0, 4, window);
1170 offset = dissect_rpc_authgss_token(tvb, tree, offset, pinfo, hf_rpc_authgss_token);
1176 dissect_rpc_authgssapi_initarg(tvbuff_t* tvb, proto_tree* tree, int offset,
1181 proto_tree *mtree = NULL;
1184 mitem = proto_tree_add_text(tree, tvb, offset, -1,
1186 mtree = proto_item_add_subtree(mitem, ett_rpc_authgssapi_msg);
1188 version = tvb_get_ntohl(tvb, offset+0);
1190 proto_tree_add_uint(mtree, hf_rpc_authgssapi_msgv, tvb,
1191 offset+0, 4, version);
1195 offset = dissect_rpc_authgss_token(tvb, mtree, offset, pinfo, hf_rpc_authgss_token);
1201 dissect_rpc_authgssapi_initres(tvbuff_t* tvb, proto_tree* tree, int offset,
1207 proto_tree *mtree = NULL;
1210 mitem = proto_tree_add_text(tree, tvb, offset, -1,
1212 mtree = proto_item_add_subtree(mitem, ett_rpc_authgssapi_msg);
1215 version = tvb_get_ntohl(tvb,offset+0);
1217 proto_tree_add_uint(mtree, hf_rpc_authgssapi_msgv, tvb,
1218 offset+0, 4, version);
1222 offset = dissect_rpc_data(tvb, mtree, hf_rpc_authgssapi_handle,
1225 major = tvb_get_ntohl(tvb,offset+0);
1227 proto_tree_add_uint(mtree, hf_rpc_authgss_major, tvb,
1228 offset+0, 4, major);
1232 minor = tvb_get_ntohl(tvb,offset+0);
1234 proto_tree_add_uint(mtree, hf_rpc_authgss_minor, tvb,
1235 offset+0, 4, minor);
1239 offset = dissect_rpc_authgss_token(tvb, mtree, offset, pinfo, hf_rpc_authgss_token);
1241 offset = dissect_rpc_data(tvb, mtree, hf_rpc_authgssapi_isn, offset);
1247 dissect_auth_gssapi_data(tvbuff_t *tvb, proto_tree *tree, int offset)
1249 offset = dissect_rpc_data(tvb, tree, hf_rpc_authgss_data,
1255 call_dissect_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1256 int offset, dissect_function_t* dissect_function, const char *progname)
1258 const char *saved_proto;
1260 tvb_ensure_length_remaining(tvb, offset);
1261 if (dissect_function != NULL) {
1262 /* set the current protocol name */
1263 saved_proto = pinfo->current_proto;
1264 if (progname != NULL)
1265 pinfo->current_proto = progname;
1267 /* call the dissector for the next level */
1268 offset = dissect_function(tvb, offset, pinfo, tree);
1270 /* restore the protocol name */
1271 pinfo->current_proto = saved_proto;
1279 dissect_rpc_authgss_integ_data(tvbuff_t *tvb, packet_info *pinfo,
1280 proto_tree *tree, int offset,
1281 dissect_function_t* dissect_function,
1282 const char *progname)
1284 guint32 length, rounded_length, seq;
1287 proto_tree *gtree = NULL;
1289 length = tvb_get_ntohl(tvb, offset+0);
1290 rounded_length = rpc_roundup(length);
1291 seq = tvb_get_ntohl(tvb, offset+4);
1294 gitem = proto_tree_add_text(tree, tvb, offset,
1295 4+rounded_length, "GSS Data");
1296 gtree = proto_item_add_subtree(gitem, ett_rpc_gss_data);
1297 proto_tree_add_uint(gtree, hf_rpc_authgss_data_length,
1298 tvb, offset+0, 4, length);
1299 proto_tree_add_uint(gtree, hf_rpc_authgss_seq,
1300 tvb, offset+4, 4, seq);
1304 if (dissect_function != NULL) {
1306 call_dissect_function(tvb, pinfo, gtree, offset,
1307 dissect_function, progname);
1309 offset += rounded_length - 4;
1310 offset = dissect_rpc_authgss_token(tvb, tree, offset, pinfo, hf_rpc_authgss_checksum);
1317 dissect_rpc_authgss_priv_data(tvbuff_t *tvb, proto_tree *tree, int offset)
1319 offset = dissect_rpc_data(tvb, tree, hf_rpc_authgss_data,
1325 * Dissect the arguments to an indirect call; used by the portmapper/RPCBIND
1326 * dissector for the CALLIT procedure.
1328 * Record these in the same table as the direct calls
1329 * so we can find it when dissecting an indirect call reply.
1330 * (There should not be collissions between xid between direct and
1334 dissect_rpc_indir_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1335 int offset, int args_id, guint32 prog, guint32 vers, guint32 proc)
1337 conversation_t* conversation;
1338 static address null_address = { AT_NONE, 0, NULL };
1339 rpc_proc_info_key key;
1340 rpc_proc_info_value *value;
1341 rpc_call_info_value *rpc_call;
1342 dissect_function_t *dissect_function = NULL;
1343 rpc_conv_info_t *rpc_conv_info=NULL;
1349 if ((value = g_hash_table_lookup(rpc_procs,&key)) != NULL) {
1350 dissect_function = value->dissect_call;
1352 /* Keep track of the address whence the call came, and the
1353 port to which the call is being sent, so that we can
1354 match up calls with replies.
1356 If the transport is connection-oriented (we check, for
1357 now, only for "pinfo->ptype" of PT_TCP), we also take
1358 into account the port from which the call was sent
1359 and the address to which the call was sent, because
1360 the addresses and ports of the two endpoints should be
1361 the same for all calls and replies. (XXX - what if
1362 the connection is broken and re-established?)
1364 If the transport is connectionless, we don't worry
1365 about the address to which the call was sent and from
1366 which the reply was sent, because there's no
1367 guarantee that the reply will come from the address
1368 to which the call was sent. We also don't worry about
1369 the port *from* which the call was sent and *to* which
1370 the reply was sent, because some clients (*cough* OS X
1371 NFS client *cough) might send retransmissions from a
1372 different port from the original request. */
1373 if (pinfo->ptype == PT_TCP) {
1374 conversation = find_conversation(pinfo->fd->num, &pinfo->src,
1375 &pinfo->dst, pinfo->ptype, pinfo->srcport,
1376 pinfo->destport, 0);
1379 * XXX - you currently still have to pass a non-null
1380 * pointer for the second address argument even
1381 * if you use NO_ADDR_B.
1383 conversation = find_conversation(pinfo->fd->num, &pinfo->src,
1384 &null_address, pinfo->ptype, pinfo->destport,
1385 0, NO_ADDR_B|NO_PORT_B);
1387 if (conversation == NULL) {
1388 /* It's not part of any conversation - create a new
1391 XXX - this should never happen, as we should've
1392 created a conversation for it in the RPC
1394 if (pinfo->ptype == PT_TCP) {
1395 conversation = conversation_new(pinfo->fd->num, &pinfo->src,
1396 &pinfo->dst, pinfo->ptype, pinfo->srcport,
1397 pinfo->destport, 0);
1399 conversation = conversation_new(pinfo->fd->num, &pinfo->src,
1400 &null_address, pinfo->ptype, pinfo->destport,
1401 0, NO_ADDR2|NO_PORT2);
1405 * Do we already have a state structure for this conv
1407 rpc_conv_info = conversation_get_proto_data(conversation, proto_rpc);
1408 if (!rpc_conv_info) {
1409 /* No. Attach that information to the conversation, and add
1410 * it to the list of information structures.
1412 rpc_conv_info = se_alloc(sizeof(rpc_conv_info_t));
1413 rpc_conv_info->xids=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "rpc_xids");
1415 conversation_add_proto_data(conversation, proto_rpc, rpc_conv_info);
1418 /* Make the dissector for this conversation the non-heuristic
1420 conversation_set_dissector(conversation,
1421 (pinfo->ptype == PT_TCP) ? rpc_tcp_handle : rpc_handle);
1423 /* Dissectors for RPC procedure calls and replies shouldn't
1424 create new tvbuffs, and we don't create one ourselves,
1425 so we should have been handed the tvbuff for this RPC call;
1426 as such, the XID is at offset 0 in this tvbuff. */
1427 /* look up the request */
1428 xid = tvb_get_ntohl(tvb, offset + 0);
1429 rpc_call = se_tree_lookup32(rpc_conv_info->xids, xid);
1430 if (rpc_call == NULL) {
1431 /* We didn't find it; create a new entry.
1432 Prepare the value data.
1433 Not all of it is needed for handling indirect
1434 calls, so we set a bunch of items to 0. */
1435 rpc_call = se_alloc(sizeof(rpc_call_info_value));
1436 rpc_call->req_num = 0;
1437 rpc_call->rep_num = 0;
1438 rpc_call->prog = prog;
1439 rpc_call->vers = vers;
1440 rpc_call->proc = proc;
1441 rpc_call->private_data = NULL;
1444 * XXX - what about RPCSEC_GSS?
1445 * Do we have to worry about it?
1447 rpc_call->flavor = FLAVOR_NOT_GSSAPI;
1448 rpc_call->gss_proc = 0;
1449 rpc_call->gss_svc = 0;
1450 rpc_call->proc_info = value;
1452 se_tree_insert32(rpc_conv_info->xids, xid, (void *)rpc_call);
1456 /* We don't know the procedure.
1457 Happens only with strange program versions or
1458 non-existing dissectors.
1459 Just show the arguments as opaque data. */
1460 offset = dissect_rpc_data(tvb, tree, args_id,
1467 proto_tree_add_text(tree, tvb, offset, 4,
1468 "Argument length: %u",
1469 tvb_get_ntohl(tvb, offset));
1473 /* Dissect the arguments */
1474 offset = call_dissect_function(tvb, pinfo, tree, offset,
1475 dissect_function, NULL);
1480 * Dissect the results in an indirect reply; used by the portmapper/RPCBIND
1484 dissect_rpc_indir_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1485 int offset, int result_id, int prog_id, int vers_id, int proc_id)
1487 conversation_t* conversation;
1488 static address null_address = { AT_NONE, 0, NULL };
1489 rpc_call_info_value *rpc_call;
1490 char *procname=NULL;
1491 dissect_function_t *dissect_function = NULL;
1492 rpc_conv_info_t *rpc_conv_info=NULL;
1495 /* Look for the matching call in the xid table.
1496 A reply must match a call that we've seen, and the
1497 reply must be sent to the same address that the call came
1498 from, and must come from the port to which the call was sent.
1500 If the transport is connection-oriented (we check, for
1501 now, only for "pinfo->ptype" of PT_TCP), we take
1502 into account the port from which the call was sent
1503 and the address to which the call was sent, because
1504 the addresses and ports of the two endpoints should be
1505 the same for all calls and replies.
1507 If the transport is connectionless, we don't worry
1508 about the address to which the call was sent and from
1509 which the reply was sent, because there's no
1510 guarantee that the reply will come from the address
1511 to which the call was sent. We also don't worry about
1512 the port *from* which the call was sent and *to* which
1513 the reply was sent, because some clients (*cough* OS X
1514 NFS client *cough) might send retransmissions from a
1515 different port from the original request. */
1516 if (pinfo->ptype == PT_TCP) {
1517 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
1518 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
1521 * XXX - you currently still have to pass a non-null
1522 * pointer for the second address argument even
1523 * if you use NO_ADDR_B.
1525 conversation = find_conversation(pinfo->fd->num, &pinfo->dst, &null_address,
1526 pinfo->ptype, pinfo->srcport, 0, NO_ADDR_B|NO_PORT_B);
1528 if (conversation == NULL) {
1529 /* We haven't seen an RPC call for that conversation,
1530 so we can't check for a reply to that call.
1531 Just show the reply stuff as opaque data. */
1532 offset = dissect_rpc_data(tvb, tree, result_id,
1537 * Do we already have a state structure for this conv
1539 rpc_conv_info = conversation_get_proto_data(conversation, proto_rpc);
1540 if (!rpc_conv_info) {
1541 /* No. Attach that information to the conversation, and add
1542 * it to the list of information structures.
1544 rpc_conv_info = se_alloc(sizeof(rpc_conv_info_t));
1545 rpc_conv_info->xids=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "rpc_xids");
1546 conversation_add_proto_data(conversation, proto_rpc, rpc_conv_info);
1549 /* The XIDs of the call and reply must match. */
1550 xid = tvb_get_ntohl(tvb, 0);
1551 rpc_call = se_tree_lookup32(rpc_conv_info->xids, xid);
1552 if (rpc_call == NULL) {
1553 /* The XID doesn't match a call from that
1554 conversation, so it's probably not an RPC reply.
1555 Just show the reply stuff as opaque data. */
1556 offset = dissect_rpc_data(tvb, tree, result_id,
1561 if (rpc_call->proc_info != NULL) {
1562 dissect_function = rpc_call->proc_info->dissect_reply;
1563 if (rpc_call->proc_info->name != NULL) {
1564 procname = (char *)rpc_call->proc_info->name;
1567 procname=ep_alloc(20);
1568 g_snprintf(procname, 20, "proc-%u", rpc_call->proc);
1573 dissect_function = NULL;
1575 procname=ep_alloc(20);
1576 g_snprintf(procname, 20, "proc-%u", rpc_call->proc);
1581 proto_item *tmp_item;
1583 /* Put the program, version, and procedure into the tree. */
1584 tmp_item=proto_tree_add_uint_format(tree, prog_id, tvb,
1585 0, 0, rpc_call->prog, "Program: %s (%u)",
1586 rpc_prog_name(rpc_call->prog), rpc_call->prog);
1587 PROTO_ITEM_SET_GENERATED(tmp_item);
1589 tmp_item=proto_tree_add_uint(tree, vers_id, tvb, 0, 0, rpc_call->vers);
1590 PROTO_ITEM_SET_GENERATED(tmp_item);
1592 tmp_item=proto_tree_add_uint_format(tree, proc_id, tvb,
1593 0, 0, rpc_call->proc, "Procedure: %s (%u)",
1594 procname, rpc_call->proc);
1595 PROTO_ITEM_SET_GENERATED(tmp_item);
1598 if (dissect_function == NULL) {
1599 /* We don't know how to dissect the reply procedure.
1600 Just show the reply stuff as opaque data. */
1601 offset = dissect_rpc_data(tvb, tree, result_id,
1607 /* Put the length of the reply value into the tree. */
1608 proto_tree_add_text(tree, tvb, offset, 4,
1609 "Argument length: %u",
1610 tvb_get_ntohl(tvb, offset));
1614 /* Dissect the return value */
1615 offset = call_dissect_function(tvb, pinfo, tree, offset,
1616 dissect_function, NULL);
1621 * Just mark this as a continuation of an earlier packet.
1624 dissect_rpc_continuation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1626 proto_item *rpc_item;
1627 proto_tree *rpc_tree;
1629 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPC");
1630 if (check_col(pinfo->cinfo, COL_INFO))
1631 col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
1634 rpc_item = proto_tree_add_item(tree, proto_rpc, tvb, 0, -1,
1636 rpc_tree = proto_item_add_subtree(rpc_item, ett_rpc);
1637 proto_tree_add_text(rpc_tree, tvb, 0, -1, "Continuation data");
1643 * Produce a dummy RPC program entry for the given RPC program key
1644 * and version values.
1647 static void make_fake_rpc_prog_if_needed (rpc_prog_info_key *prpc_prog_key,
1651 rpc_prog_info_value *rpc_prog = NULL;
1654 /* sanity check: no one uses versions > 10 */
1659 if( (rpc_prog = g_hash_table_lookup(rpc_progs, prpc_prog_key)) == NULL) {
1660 /* ok this is not a known rpc program so we
1661 * will have to fake it.
1663 int proto_rpc_unknown_program;
1664 char *NAME, *Name, *name;
1665 static const vsff unknown_proc[] = {
1666 { 0,"NULL",NULL,NULL },
1667 { 0,NULL,NULL,NULL }
1673 g_snprintf(NAME, 36, "Unknown RPC Program:%d",prpc_prog_key->prog);
1674 g_snprintf(Name, 32, "RPC:%d",prpc_prog_key->prog);
1675 g_snprintf(name, 32, "rpc%d",prpc_prog_key->prog);
1676 proto_rpc_unknown_program = proto_register_protocol(NAME, Name, name);
1678 rpc_init_prog(proto_rpc_unknown_program, prpc_prog_key->prog, ett_rpc_unknown_program);
1679 rpc_init_proc_table(prpc_prog_key->prog, prog_ver, unknown_proc, hf_rpc_procedure);
1686 dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1687 tvbuff_t *frag_tvb, fragment_data *ipfd_head, gboolean is_tcp,
1688 guint32 rpc_rm, gboolean first_pdu)
1691 rpc_call_info_value *rpc_call = NULL;
1692 rpc_prog_info_value *rpc_prog = NULL;
1693 rpc_prog_info_key rpc_prog_key;
1696 unsigned int rpcvers;
1697 unsigned int prog = 0;
1698 unsigned int vers = 0;
1699 unsigned int proc = 0;
1700 flavor_t flavor = FLAVOR_UNKNOWN;
1701 unsigned int gss_proc = 0;
1702 unsigned int gss_svc = 0;
1703 protocol_t *proto = NULL;
1708 unsigned int reply_state;
1709 unsigned int accept_state;
1710 unsigned int reject_state;
1712 const char *msg_type_name = NULL;
1713 const char *progname = NULL;
1714 char *procname = NULL;
1716 unsigned int vers_low;
1717 unsigned int vers_high;
1719 unsigned int auth_state;
1721 proto_item *rpc_item = NULL;
1722 proto_tree *rpc_tree = NULL;
1724 proto_item *pitem = NULL;
1725 proto_tree *ptree = NULL;
1726 int offset = (is_tcp && tvb == frag_tvb) ? 4 : 0;
1728 rpc_proc_info_key key;
1729 rpc_proc_info_value *value = NULL;
1730 conversation_t* conversation;
1731 static address null_address = { AT_NONE, 0, NULL };
1734 dissect_function_t *dissect_function = NULL;
1735 gboolean dissect_rpc = TRUE;
1737 rpc_conv_info_t *rpc_conv_info=NULL;
1741 * Check to see whether this looks like an RPC call or reply.
1743 if (!tvb_bytes_exist(tvb, offset, 8)) {
1744 /* Captured data in packet isn't enough to let us tell. */
1748 /* both directions need at least this */
1749 msg_type = tvb_get_ntohl(tvb, offset + 4);
1754 /* check for RPC call */
1755 if (!tvb_bytes_exist(tvb, offset, 16)) {
1756 /* Captured data in packet isn't enough to let us
1761 /* XID can be anything, so dont check it.
1762 We already have the message type.
1763 Check whether an RPC version number of 2 is in the
1764 location where it would be, and that an RPC program
1765 number we know about is in the location where it would be.
1767 XXX - Sun's snoop appears to recognize as RPC even calls
1768 to stuff it doesn't dissect; does it just look for a 2
1769 at that location, which seems far to weak a heuristic
1770 (too many false positives), or does it have some additional
1773 We could conceivably check for any of the program numbers
1776 ftp://ftp.tau.ac.il/pub/users/eilon/rpc/rpc
1778 and report it as RPC (but not dissect the payload if
1779 we don't have a subdissector) if it matches. */
1780 rpc_prog_key.prog = tvb_get_ntohl(tvb, offset + 12);
1782 /* we only dissect version 2 */
1783 if (tvb_get_ntohl(tvb, offset + 8) != 2 ){
1786 /* let the user be able to weaken the heuristics if he need
1787 * to look at proprietary protocols not known
1790 if(rpc_dissect_unknown_programs){
1793 /* if the user has specified that he wants to try to
1794 * dissect even completely unknown RPC program numbers
1795 * then let him do that.
1796 * In this case we only check that the program number
1797 * is neither 0 nor -1 which is better than nothing.
1799 if(rpc_prog_key.prog==0 || rpc_prog_key.prog==0xffffffff){
1802 version=tvb_get_ntohl(tvb, offset+16);
1803 make_fake_rpc_prog_if_needed (&rpc_prog_key, version);
1805 if( (rpc_prog = g_hash_table_lookup(rpc_progs, &rpc_prog_key)) == NULL) {
1806 /* They're not, so it's probably not an RPC call. */
1812 /* Check for RPC reply. A reply must match a call that
1813 we've seen, and the reply must be sent to the same
1814 address that the call came from, and must come from
1815 the port to which the call was sent.
1817 If the transport is connection-oriented (we check, for
1818 now, only for "pinfo->ptype" of PT_TCP), we take
1819 into account the port from which the call was sent
1820 and the address to which the call was sent, because
1821 the addresses and ports of the two endpoints should be
1822 the same for all calls and replies.
1824 If the transport is connectionless, we don't worry
1825 about the address to which the call was sent and from
1826 which the reply was sent, because there's no
1827 guarantee that the reply will come from the address
1828 to which the call was sent. We also don't worry about
1829 the port *from* which the call was sent and *to* which
1830 the reply was sent, because some clients (*cough* OS X
1831 NFS client *cough) might send retransmissions from a
1832 different port from the original request. */
1833 if (pinfo->ptype == PT_TCP) {
1834 conversation = find_conversation(pinfo->fd->num, &pinfo->src,
1835 &pinfo->dst, pinfo->ptype, pinfo->srcport,
1836 pinfo->destport, 0);
1839 * XXX - you currently still have to pass a non-null
1840 * pointer for the second address argument even
1841 * if you use NO_ADDR_B.
1843 conversation = find_conversation(pinfo->fd->num, &pinfo->dst,
1844 &null_address, pinfo->ptype, pinfo->srcport,
1845 0, NO_ADDR_B|NO_PORT_B);
1847 if (conversation == NULL) {
1848 /* We haven't seen an RPC call for that conversation,
1849 so we can't check for a reply to that call. */
1853 * Do we already have a state structure for this conv
1855 rpc_conv_info = conversation_get_proto_data(conversation, proto_rpc);
1856 if (!rpc_conv_info) {
1857 /* No. Attach that information to the conversation, and add
1858 * it to the list of information structures.
1860 rpc_conv_info = se_alloc(sizeof(rpc_conv_info_t));
1861 rpc_conv_info->xids=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "rpc_xids");
1863 conversation_add_proto_data(conversation, proto_rpc, rpc_conv_info);
1866 /* The XIDs of the call and reply must match. */
1867 xid = tvb_get_ntohl(tvb, offset + 0);
1868 rpc_call = se_tree_lookup32(rpc_conv_info->xids, xid);
1869 if (rpc_call == NULL) {
1870 /* The XID doesn't match a call from that
1871 conversation, so it's probably not an RPC reply. */
1873 /* unless we're permitted to scan for embedded records
1874 * and this is a connection-oriented transport, give up */
1875 if ((! rpc_find_fragment_start) || (pinfo->ptype != PT_TCP)) {
1879 /* in parse-partials, so define a dummy conversation for this reply */
1880 rpc_call = se_alloc(sizeof(rpc_call_info_value));
1881 rpc_call->req_num = 0;
1882 rpc_call->rep_num = pinfo->fd->num;
1886 rpc_call->private_data = NULL;
1887 rpc_call->xid = xid;
1888 rpc_call->flavor = FLAVOR_NOT_GSSAPI; /* total punt */
1889 rpc_call->gss_proc = 0;
1890 rpc_call->gss_svc = 0;
1891 rpc_call->proc_info = value;
1892 rpc_call->req_time = pinfo->fd->abs_ts;
1895 se_tree_insert32(rpc_conv_info->xids, xid, (void *)rpc_call);
1897 /* and fake up a matching program */
1898 rpc_prog_key.prog = rpc_call->prog;
1901 /* pass rpc_info to subdissectors */
1902 rpc_call->request=FALSE;
1903 pinfo->private_data=rpc_call;
1907 /* The putative message type field contains neither
1908 RPC_CALL nor RPC_REPLY, so it's not an RPC call or
1915 * This is RPC-over-TCP; check if this is the last
1918 if (!(rpc_rm & RPC_RM_LASTFRAG)) {
1920 * This isn't the last fragment.
1921 * If we're doing reassembly, just return
1922 * TRUE to indicate that this looks like
1923 * the beginning of an RPC message,
1924 * and let them do fragment reassembly.
1931 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPC");
1934 rpc_item = proto_tree_add_item(tree, proto_rpc, tvb, 0, -1,
1936 rpc_tree = proto_item_add_subtree(rpc_item, ett_rpc);
1939 show_rpc_fraginfo(tvb, frag_tvb, rpc_tree, rpc_rm,
1944 xid = tvb_get_ntohl(tvb, offset + 0);
1946 proto_tree_add_uint_format(rpc_tree,hf_rpc_xid, tvb,
1947 offset+0, 4, xid, "XID: 0x%x (%u)", xid, xid);
1950 msg_type_name = val_to_str(msg_type,rpc_msg_type,"%u");
1952 proto_tree_add_uint(rpc_tree, hf_rpc_msgtype, tvb,
1953 offset+4, 4, msg_type);
1954 proto_item_append_text(rpc_item, ", Type:%s XID:0x%08x", msg_type_name, xid);
1962 /* we know already the proto-entry, the ETT-const,
1964 proto = rpc_prog->proto;
1965 proto_id = rpc_prog->proto_id;
1966 ett = rpc_prog->ett;
1967 progname = rpc_prog->progname;
1969 rpcvers = tvb_get_ntohl(tvb, offset + 0);
1971 proto_tree_add_uint(rpc_tree,
1972 hf_rpc_version, tvb, offset+0, 4, rpcvers);
1975 prog = tvb_get_ntohl(tvb, offset + 4);
1978 proto_tree_add_uint_format(rpc_tree,
1979 hf_rpc_program, tvb, offset+4, 4, prog,
1980 "Program: %s (%u)", progname, prog);
1983 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
1984 /* Set the protocol name to the underlying
1986 col_set_str(pinfo->cinfo, COL_PROTOCOL, progname);
1989 vers = tvb_get_ntohl(tvb, offset+8);
1991 proto_tree_add_uint(rpc_tree,
1992 hf_rpc_programversion, tvb, offset+8, 4, vers);
1995 proc = tvb_get_ntohl(tvb, offset+12);
2001 if ((value = g_hash_table_lookup(rpc_procs,&key)) != NULL) {
2002 dissect_function = value->dissect_call;
2003 procname = (char *)value->name;
2006 /* happens only with strange program versions or
2007 non-existing dissectors */
2009 dissect_function = NULL;
2011 procname=ep_alloc(20);
2012 g_snprintf(procname, 20, "proc-%u", proc);
2015 /* Check for RPCSEC_GSS and AUTH_GSSAPI */
2016 if (tvb_bytes_exist(tvb, offset+16, 4)) {
2017 switch (tvb_get_ntohl(tvb, offset+16)) {
2021 * It's GSS-API authentication...
2023 if (tvb_bytes_exist(tvb, offset+28, 8)) {
2025 * ...and we have the procedure
2026 * and service information for it.
2028 flavor = FLAVOR_GSSAPI;
2029 gss_proc = tvb_get_ntohl(tvb, offset+28);
2030 gss_svc = tvb_get_ntohl(tvb, offset+36);
2033 * ...but the procedure and service
2034 * information isn't available.
2036 flavor = FLAVOR_GSSAPI_NO_INFO;
2042 * AUTH_GSSAPI flavor. If auth_msg is TRUE,
2043 * then this is an AUTH_GSSAPI message and
2044 * not an application level message.
2046 if (tvb_bytes_exist(tvb, offset+28, 4)) {
2047 if (tvb_get_ntohl(tvb, offset+28)) {
2048 flavor = FLAVOR_AUTHGSSAPI_MSG;
2051 val_to_str(gss_proc,
2052 rpc_authgssapi_proc, "Unknown (%d)");
2054 flavor = FLAVOR_AUTHGSSAPI;
2061 * It's not GSS-API authentication.
2063 flavor = FLAVOR_NOT_GSSAPI;
2069 proto_tree_add_uint_format(rpc_tree,
2070 hf_rpc_procedure, tvb, offset+12, 4, proc,
2071 "Procedure: %s (%u)", procname, proc);
2074 if (check_col(pinfo->cinfo, COL_INFO)) {
2076 col_clear(pinfo->cinfo, COL_INFO);
2078 col_append_str(pinfo->cinfo, COL_INFO, " ; ");
2079 col_append_fstr(pinfo->cinfo, COL_INFO,"V%u %s %s",
2085 /* Keep track of the address whence the call came, and the
2086 port to which the call is being sent, so that we can
2087 match up calls with replies.
2089 If the transport is connection-oriented (we check, for
2090 now, only for "pinfo->ptype" of PT_TCP), we also take
2091 into account the port from which the call was sent
2092 and the address to which the call was sent, because
2093 the addresses and ports of the two endpoints should be
2094 the same for all calls and replies. (XXX - what if
2095 the connection is broken and re-established?)
2097 If the transport is connectionless, we don't worry
2098 about the address to which the call was sent and from
2099 which the reply was sent, because there's no
2100 guarantee that the reply will come from the address
2101 to which the call was sent. We also don't worry about
2102 the port *from* which the call was sent and *to* which
2103 the reply was sent, because some clients (*cough* OS X
2104 NFS client *cough) might send retransmissions from a
2105 different port from the original request. */
2106 if (pinfo->ptype == PT_TCP) {
2107 conversation = find_conversation(pinfo->fd->num, &pinfo->src,
2108 &pinfo->dst, pinfo->ptype, pinfo->srcport,
2109 pinfo->destport, 0);
2112 * XXX - you currently still have to pass a non-null
2113 * pointer for the second address argument even
2114 * if you use NO_ADDR_B.
2116 conversation = find_conversation(pinfo->fd->num, &pinfo->src,
2117 &null_address, pinfo->ptype, pinfo->destport,
2118 0, NO_ADDR_B|NO_PORT_B);
2120 if (conversation == NULL) {
2121 /* It's not part of any conversation - create a new
2123 if (pinfo->ptype == PT_TCP) {
2124 conversation = conversation_new(pinfo->fd->num, &pinfo->src,
2125 &pinfo->dst, pinfo->ptype, pinfo->srcport,
2126 pinfo->destport, 0);
2128 conversation = conversation_new(pinfo->fd->num, &pinfo->src,
2129 &null_address, pinfo->ptype, pinfo->destport,
2130 0, NO_ADDR2|NO_PORT2);
2134 * Do we already have a state structure for this conv
2136 rpc_conv_info = conversation_get_proto_data(conversation, proto_rpc);
2137 if (!rpc_conv_info) {
2138 /* No. Attach that information to the conversation, and add
2139 * it to the list of information structures.
2141 rpc_conv_info = se_alloc(sizeof(rpc_conv_info_t));
2142 rpc_conv_info->xids=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "rpc_xids");
2144 conversation_add_proto_data(conversation, proto_rpc, rpc_conv_info);
2148 /* Make the dissector for this conversation the non-heuristic
2150 conversation_set_dissector(conversation,
2151 (pinfo->ptype == PT_TCP) ? rpc_tcp_handle : rpc_handle);
2153 /* look up the request */
2154 rpc_call = se_tree_lookup32(rpc_conv_info->xids, xid);
2156 /* We've seen a request with this XID, with the same
2157 source and destination, before - but was it
2159 if (pinfo->fd->num != rpc_call->req_num) {
2160 /* No, so it's a duplicate request.
2162 if (check_col(pinfo->cinfo, COL_INFO)) {
2163 col_prepend_fstr(pinfo->cinfo, COL_INFO,
2164 "[RPC retransmission of #%d]", rpc_call->req_num);
2166 proto_tree_add_item(rpc_tree,
2167 hf_rpc_dup, tvb, 0,0, TRUE);
2168 proto_tree_add_uint(rpc_tree,
2169 hf_rpc_call_dup, tvb, 0,0, rpc_call->req_num);
2171 if(rpc_call->rep_num){
2172 if (check_col(pinfo->cinfo, COL_INFO)) {
2173 col_append_fstr(pinfo->cinfo, COL_INFO," (Reply In %d)", rpc_call->rep_num);
2177 /* Prepare the value data.
2178 "req_num" and "rep_num" are frame numbers;
2179 frame numbers are 1-origin, so we use 0
2180 to mean "we don't yet know in which frame
2181 the reply for this call appears". */
2182 rpc_call = se_alloc(sizeof(rpc_call_info_value));
2183 rpc_call->req_num = pinfo->fd->num;
2184 rpc_call->rep_num = 0;
2185 rpc_call->prog = prog;
2186 rpc_call->vers = vers;
2187 rpc_call->proc = proc;
2188 rpc_call->private_data = NULL;
2189 rpc_call->xid = xid;
2190 rpc_call->flavor = flavor;
2191 rpc_call->gss_proc = gss_proc;
2192 rpc_call->gss_svc = gss_svc;
2193 rpc_call->proc_info = value;
2194 rpc_call->req_time = pinfo->fd->abs_ts;
2197 se_tree_insert32(rpc_conv_info->xids, xid, (void *)rpc_call);
2200 if(rpc_call && rpc_call->rep_num){
2201 proto_item *tmp_item;
2203 tmp_item=proto_tree_add_uint_format(rpc_tree, hf_rpc_reqframe,
2204 tvb, 0, 0, rpc_call->rep_num,
2205 "The reply to this request is in frame %u",
2207 PROTO_ITEM_SET_GENERATED(tmp_item);
2212 offset = dissect_rpc_cred(tvb, rpc_tree, offset);
2213 offset = dissect_rpc_verf(tvb, rpc_tree, offset, msg_type, pinfo);
2215 /* pass rpc_info to subdissectors */
2216 rpc_call->request=TRUE;
2217 pinfo->private_data=rpc_call;
2219 /* go to the next dissector */
2221 break; /* end of RPC call */
2224 /* we know already the type from the calling routine,
2225 and we already have "rpc_call" set above. */
2226 prog = rpc_call->prog;
2227 vers = rpc_call->vers;
2228 proc = rpc_call->proc;
2229 flavor = rpc_call->flavor;
2230 gss_proc = rpc_call->gss_proc;
2231 gss_svc = rpc_call->gss_svc;
2233 if (rpc_call->proc_info != NULL) {
2234 dissect_function = rpc_call->proc_info->dissect_reply;
2235 if (rpc_call->proc_info->name != NULL) {
2236 procname = (char *)rpc_call->proc_info->name;
2239 procname=ep_alloc(20);
2240 g_snprintf(procname, 20, "proc-%u", proc);
2245 dissect_function = NULL;
2247 procname=ep_alloc(20);
2248 g_snprintf(procname, 20, "proc-%u", proc);
2252 * If this is an AUTH_GSSAPI message, then the RPC procedure
2253 * is not an application procedure, but rather an auth level
2254 * procedure, so it would be misleading to print the RPC
2255 * procname. Replace the RPC procname with the corresponding
2256 * AUTH_GSSAPI procname.
2258 if (flavor == FLAVOR_AUTHGSSAPI_MSG) {
2259 procname = (char *)match_strval(gss_proc, rpc_authgssapi_proc);
2262 rpc_prog_key.prog = prog;
2263 if ((rpc_prog = g_hash_table_lookup(rpc_progs,&rpc_prog_key)) == NULL) {
2267 progname = "Unknown";
2270 proto = rpc_prog->proto;
2271 proto_id = rpc_prog->proto_id;
2272 ett = rpc_prog->ett;
2273 progname = rpc_prog->progname;
2275 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
2276 /* Set the protocol name to the underlying
2278 col_set_str(pinfo->cinfo, COL_PROTOCOL, progname);
2282 if (check_col(pinfo->cinfo, COL_INFO)) {
2284 col_clear(pinfo->cinfo, COL_INFO);
2286 col_append_str(pinfo->cinfo, COL_INFO, " ; ");
2287 col_append_fstr(pinfo->cinfo, COL_INFO,"V%u %s %s",
2294 proto_item *tmp_item;
2295 tmp_item=proto_tree_add_uint_format(rpc_tree,
2296 hf_rpc_program, tvb, 0, 0, prog,
2297 "Program: %s (%u)", progname, prog);
2298 PROTO_ITEM_SET_GENERATED(tmp_item);
2299 tmp_item=proto_tree_add_uint(rpc_tree,
2300 hf_rpc_programversion, tvb, 0, 0, vers);
2301 PROTO_ITEM_SET_GENERATED(tmp_item);
2302 tmp_item=proto_tree_add_uint_format(rpc_tree,
2303 hf_rpc_procedure, tvb, 0, 0, proc,
2304 "Procedure: %s (%u)", procname, proc);
2305 PROTO_ITEM_SET_GENERATED(tmp_item);
2308 reply_state = tvb_get_ntohl(tvb,offset+0);
2310 proto_tree_add_uint(rpc_tree, hf_rpc_state_reply, tvb,
2311 offset+0, 4, reply_state);
2315 /* Indicate the frame to which this is a reply. */
2316 if(rpc_call && rpc_call->req_num){
2317 proto_item *tmp_item;
2319 tmp_item=proto_tree_add_uint_format(rpc_tree, hf_rpc_repframe,
2320 tvb, 0, 0, rpc_call->req_num,
2321 "This is a reply to a request in frame %u",
2323 PROTO_ITEM_SET_GENERATED(tmp_item);
2325 nstime_delta(&ns, &pinfo->fd->abs_ts, &rpc_call->req_time);
2326 tmp_item=proto_tree_add_time(rpc_tree, hf_rpc_time, tvb, offset, 0,
2328 PROTO_ITEM_SET_GENERATED(tmp_item);
2330 if (check_col(pinfo->cinfo, COL_INFO)) {
2331 col_append_fstr(pinfo->cinfo, COL_INFO," (Call In %d)", rpc_call->req_num);
2336 if ((!rpc_call) || (rpc_call->rep_num == 0)) {
2337 /* We have not yet seen a reply to that call, so
2338 this must be the first reply; remember its
2340 rpc_call->rep_num = pinfo->fd->num;
2342 /* We have seen a reply to this call - but was it
2344 if (rpc_call->rep_num != pinfo->fd->num) {
2345 proto_item *tmp_item;
2347 /* No, so it's a duplicate reply.
2349 if (check_col(pinfo->cinfo, COL_INFO)) {
2350 col_prepend_fstr(pinfo->cinfo, COL_INFO,
2351 "[RPC duplicate of #%d]", rpc_call->rep_num);
2353 tmp_item=proto_tree_add_item(rpc_tree,
2354 hf_rpc_dup, tvb, 0,0, TRUE);
2355 PROTO_ITEM_SET_GENERATED(tmp_item);
2357 tmp_item=proto_tree_add_uint(rpc_tree,
2358 hf_rpc_reply_dup, tvb, 0,0, rpc_call->rep_num);
2359 PROTO_ITEM_SET_GENERATED(tmp_item);
2363 switch (reply_state) {
2366 offset = dissect_rpc_verf(tvb, rpc_tree, offset, msg_type, pinfo);
2367 accept_state = tvb_get_ntohl(tvb,offset+0);
2369 proto_tree_add_uint(rpc_tree, hf_rpc_state_accept, tvb,
2370 offset+0, 4, accept_state);
2373 switch (accept_state) {
2376 /* go to the next dissector */
2380 vers_low = tvb_get_ntohl(tvb,offset+0);
2381 vers_high = tvb_get_ntohl(tvb,offset+4);
2383 proto_tree_add_uint(rpc_tree,
2384 hf_rpc_programversion_min,
2385 tvb, offset+0, 4, vers_low);
2386 proto_tree_add_uint(rpc_tree,
2387 hf_rpc_programversion_max,
2388 tvb, offset+4, 4, vers_high);
2393 * There's no protocol reply, so don't
2394 * try to dissect it.
2396 dissect_rpc = FALSE;
2401 * There's no protocol reply, so don't
2402 * try to dissect it.
2404 dissect_rpc = FALSE;
2410 reject_state = tvb_get_ntohl(tvb,offset+0);
2412 proto_tree_add_uint(rpc_tree,
2413 hf_rpc_state_reject, tvb, offset+0, 4,
2418 if (reject_state==RPC_MISMATCH) {
2419 vers_low = tvb_get_ntohl(tvb,offset+0);
2420 vers_high = tvb_get_ntohl(tvb,offset+4);
2422 proto_tree_add_uint(rpc_tree,
2424 tvb, offset+0, 4, vers_low);
2425 proto_tree_add_uint(rpc_tree,
2427 tvb, offset+4, 4, vers_high);
2430 } else if (reject_state==AUTH_ERROR) {
2431 auth_state = tvb_get_ntohl(tvb,offset+0);
2433 proto_tree_add_uint(rpc_tree,
2434 hf_rpc_state_auth, tvb, offset+0, 4,
2441 * There's no protocol reply, so don't
2442 * try to dissect it.
2444 dissect_rpc = FALSE;
2449 * This isn't a valid reply state, so we have
2450 * no clue what's going on; don't try to dissect
2451 * the protocol reply.
2453 dissect_rpc = FALSE;
2456 break; /* end of RPC reply */
2460 * The switch statement at the top returned if
2461 * this was neither an RPC call nor a reply.
2463 DISSECTOR_ASSERT_NOT_REACHED();
2466 /* now we know, that RPC was shorter */
2469 THROW(ReportedBoundsError);
2470 tvb_ensure_bytes_exist(tvb, offset, 0);
2471 proto_item_set_end(rpc_item, tvb, offset);
2476 * There's no RPC call or reply here; just dissect
2477 * whatever's left as data.
2479 call_dissector(data_handle,
2480 tvb_new_subset(tvb, offset, -1, -1), pinfo, rpc_tree);
2484 /* we must queue this packet to the tap system before we actually
2485 call the subdissectors since short packets (i.e. nfs read reply)
2486 will cause an exception and execution would never reach the call
2487 to tap_queue_packet() in that case
2489 tap_queue_packet(rpc_tap, pinfo, rpc_call);
2491 /* create here the program specific sub-tree */
2492 if (tree && (flavor != FLAVOR_AUTHGSSAPI_MSG)) {
2493 pitem = proto_tree_add_item(tree, proto_id, tvb, offset, -1,
2496 ptree = proto_item_add_subtree(pitem, ett);
2500 proto_item *tmp_item;
2502 tmp_item=proto_tree_add_uint(ptree,
2503 hf_rpc_programversion, tvb, 0, 0, vers);
2504 PROTO_ITEM_SET_GENERATED(tmp_item);
2505 if (rpc_prog && (rpc_prog->procedure_hfs->len > vers) )
2506 procedure_hf = g_array_index(rpc_prog->procedure_hfs, int, vers);
2509 * No such element in the GArray.
2513 if (procedure_hf != 0 && procedure_hf != -1) {
2514 tmp_item=proto_tree_add_uint(ptree,
2515 procedure_hf, tvb, 0, 0, proc);
2516 PROTO_ITEM_SET_GENERATED(tmp_item);
2518 tmp_item=proto_tree_add_uint_format(ptree,
2519 hf_rpc_procedure, tvb, 0, 0, proc,
2520 "Procedure: %s (%u)", procname, proc);
2521 PROTO_ITEM_SET_GENERATED(tmp_item);
2526 /* proto==0 if this is an unknown program */
2527 if( (proto==0) || !proto_is_protocol_enabled(proto)){
2528 dissect_function = NULL;
2532 * Don't call any subdissector if we have no more date to dissect.
2534 if (tvb_length_remaining(tvb, offset) == 0) {
2539 * Handle RPCSEC_GSS and AUTH_GSSAPI specially.
2543 case FLAVOR_UNKNOWN:
2545 * We don't know the authentication flavor, so we can't
2546 * dissect the payload.
2548 proto_tree_add_text(ptree, tvb, offset, -1,
2549 "Unknown authentication flavor - cannot dissect");
2552 case FLAVOR_NOT_GSSAPI:
2554 * It's not GSS-API authentication. Just dissect the
2557 offset = call_dissect_function(tvb, pinfo, ptree, offset,
2558 dissect_function, progname);
2561 case FLAVOR_GSSAPI_NO_INFO:
2563 * It's GSS-API authentication, but we don't have the
2564 * procedure and service information, so we can't dissect
2567 proto_tree_add_text(ptree, tvb, offset, -1,
2568 "GSS-API authentication, but procedure and service unknown - cannot dissect");
2573 * It's GSS-API authentication, and we have the procedure
2574 * and service information; process the GSS-API stuff,
2575 * and process the payload if there is any.
2579 case RPCSEC_GSS_INIT:
2580 case RPCSEC_GSS_CONTINUE_INIT:
2581 if (msg_type == RPC_CALL) {
2582 offset = dissect_rpc_authgss_initarg(tvb,
2583 ptree, offset, pinfo);
2586 offset = dissect_rpc_authgss_initres(tvb,
2587 ptree, offset, pinfo);
2591 case RPCSEC_GSS_DATA:
2592 if (gss_svc == RPCSEC_GSS_SVC_NONE) {
2593 offset = call_dissect_function(tvb,
2594 pinfo, ptree, offset,
2598 else if (gss_svc == RPCSEC_GSS_SVC_INTEGRITY) {
2599 offset = dissect_rpc_authgss_integ_data(tvb,
2600 pinfo, ptree, offset,
2604 else if (gss_svc == RPCSEC_GSS_SVC_PRIVACY) {
2605 offset = dissect_rpc_authgss_priv_data(tvb,
2615 case FLAVOR_AUTHGSSAPI_MSG:
2617 * This is an AUTH_GSSAPI message. It contains data
2618 * only for the authentication procedure and not for the
2619 * application level RPC procedure. Reset the column
2620 * protocol and info fields to indicate that this is
2621 * an RPC auth level message, then process the args.
2623 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
2624 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPC");
2626 if (check_col(pinfo->cinfo, COL_INFO)) {
2627 col_clear(pinfo->cinfo, COL_INFO);
2628 col_append_fstr(pinfo->cinfo, COL_INFO,
2630 val_to_str(gss_proc, rpc_authgssapi_proc, "Unknown (%d)"),
2631 msg_type_name, xid);
2636 case AUTH_GSSAPI_INIT:
2637 case AUTH_GSSAPI_CONTINUE_INIT:
2638 case AUTH_GSSAPI_MSG:
2639 if (msg_type == RPC_CALL) {
2640 offset = dissect_rpc_authgssapi_initarg(tvb,
2641 rpc_tree, offset, pinfo);
2643 offset = dissect_rpc_authgssapi_initres(tvb,
2644 rpc_tree, offset, pinfo);
2648 case AUTH_GSSAPI_DESTROY:
2649 offset = dissect_rpc_data(tvb, rpc_tree,
2650 hf_rpc_authgss_data, offset);
2653 case AUTH_GSSAPI_EXIT:
2657 /* Adjust the length to account for the auth message. */
2659 proto_item_set_end(rpc_item, tvb, offset);
2663 case FLAVOR_AUTHGSSAPI:
2665 * An RPC with AUTH_GSSAPI authentication. The data
2666 * portion is always private, so don't call the dissector.
2668 offset = dissect_auth_gssapi_data(tvb, ptree, offset);
2672 if (tvb_length_remaining(tvb, offset) > 0) {
2674 * dissect any remaining bytes (incomplete dissection) as pure
2678 call_dissector(data_handle,
2679 tvb_new_subset(tvb, offset, -1, -1), pinfo, ptree);
2682 /* XXX this should really loop over all fhandles registred for the frame */
2683 if(nfs_fhandle_reqrep_matching){
2686 if(rpc_call && rpc_call->rep_num){
2687 dissect_fhandle_hidden(pinfo,
2688 ptree, rpc_call->rep_num);
2692 if(rpc_call && rpc_call->req_num){
2693 dissect_fhandle_hidden(pinfo,
2694 ptree, rpc_call->req_num);
2704 dissect_rpc_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2706 return dissect_rpc_message(tvb, pinfo, tree, NULL, NULL, FALSE, 0,
2711 dissect_rpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2713 if (!dissect_rpc_message(tvb, pinfo, tree, NULL, NULL, FALSE, 0,
2715 if (tvb_length(tvb) != 0)
2716 dissect_rpc_continuation(tvb, pinfo, tree);
2721 /* Defragmentation of RPC-over-TCP records */
2722 /* table to hold defragmented RPC records */
2723 static GHashTable *rpc_fragment_table = NULL;
2725 static GHashTable *rpc_reassembly_table = NULL;
2727 typedef struct _rpc_fragment_key {
2737 rpc_fragment_hash(gconstpointer k)
2739 const rpc_fragment_key *key = (const rpc_fragment_key *)k;
2741 return key->conv_id + key->seq;
2745 rpc_fragment_equal(gconstpointer k1, gconstpointer k2)
2747 const rpc_fragment_key *key1 = (const rpc_fragment_key *)k1;
2748 const rpc_fragment_key *key2 = (const rpc_fragment_key *)k2;
2750 return key1->conv_id == key2->conv_id &&
2751 key1->seq == key2->seq && key1->port == key2->port;
2755 show_rpc_fragheader(tvbuff_t *tvb, proto_tree *tree, guint32 rpc_rm)
2757 proto_item *hdr_item;
2758 proto_tree *hdr_tree;
2762 fraglen = rpc_rm & RPC_RM_FRAGLEN;
2764 hdr_item = proto_tree_add_text(tree, tvb, 0, 4,
2765 "Fragment header: %s%u %s",
2766 (rpc_rm & RPC_RM_LASTFRAG) ? "Last fragment, " : "",
2767 fraglen, plurality(fraglen, "byte", "bytes"));
2768 hdr_tree = proto_item_add_subtree(hdr_item, ett_rpc_fraghdr);
2770 proto_tree_add_boolean(hdr_tree, hf_rpc_lastfrag, tvb, 0, 4,
2772 proto_tree_add_uint(hdr_tree, hf_rpc_fraglen, tvb, 0, 4,
2778 show_rpc_fragment(tvbuff_t *tvb, proto_tree *tree, guint32 rpc_rm)
2782 * Show the fragment header and the data for the fragment.
2784 show_rpc_fragheader(tvb, tree, rpc_rm);
2785 proto_tree_add_text(tree, tvb, 4, -1, "Fragment Data");
2790 make_frag_tree(tvbuff_t *tvb, proto_tree *tree, int proto, gint ett,
2793 proto_item *frag_item;
2794 proto_tree *frag_tree;
2797 return; /* nothing to do */
2799 frag_item = proto_tree_add_protocol_format(tree, proto, tvb, 0, -1,
2800 "%s Fragment", proto_get_protocol_name(proto));
2801 frag_tree = proto_item_add_subtree(frag_item, ett);
2802 show_rpc_fragment(tvb, frag_tree, rpc_rm);
2806 show_rpc_fraginfo(tvbuff_t *tvb, tvbuff_t *frag_tvb, proto_tree *tree,
2807 guint32 rpc_rm, fragment_data *ipfd_head, packet_info *pinfo)
2809 proto_item *frag_tree_item;
2812 return; /* don't do any work */
2814 if (tvb != frag_tvb) {
2816 * This message was not all in one fragment,
2817 * so show the fragment header *and* the data
2818 * for the fragment (which is the last fragment),
2819 * and a tree with information about all fragments.
2821 show_rpc_fragment(frag_tvb, tree, rpc_rm);
2824 * Show a tree with information about all fragments.
2826 show_fragment_tree(ipfd_head, &rpc_frag_items, tree, pinfo, tvb, &frag_tree_item);
2829 * This message was all in one fragment, so just show
2830 * the fragment header.
2832 show_rpc_fragheader(tvb, tree, rpc_rm);
2837 call_message_dissector(tvbuff_t *tvb, tvbuff_t *rec_tvb, packet_info *pinfo,
2838 proto_tree *tree, tvbuff_t *frag_tvb, rec_dissector_t dissector,
2839 fragment_data *ipfd_head, guint32 rpc_rm, gboolean first_pdu)
2841 const char *saved_proto;
2842 volatile gboolean rpc_succeeded;
2845 * Catch the ReportedBoundsError exception; if
2846 * this particular message happens to get a
2847 * ReportedBoundsError exception, that doesn't
2848 * mean that we should stop dissecting RPC
2849 * messages within this frame or chunk of
2852 * If it gets a BoundsError, we can stop, as there's
2853 * nothing more to see, so we just re-throw it.
2855 saved_proto = pinfo->current_proto;
2856 rpc_succeeded = FALSE;
2858 rpc_succeeded = (*dissector)(rec_tvb, pinfo, tree,
2859 frag_tvb, ipfd_head, TRUE, rpc_rm, first_pdu);
2861 CATCH(BoundsError) {
2864 CATCH(ReportedBoundsError) {
2865 show_reported_bounds_error(tvb, pinfo, tree);
2866 pinfo->current_proto = saved_proto;
2869 * We treat this as a "successful" dissection of
2870 * an RPC packet, as "dissect_rpc_message()"
2871 * *did* decide it was an RPC packet, throwing
2872 * an exception while dissecting it as such.
2874 rpc_succeeded = TRUE;
2877 return rpc_succeeded;
2881 dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo,
2882 proto_tree *tree, rec_dissector_t dissector, gboolean is_heur,
2883 int proto, int ett, gboolean defragment, gboolean first_pdu)
2885 struct tcpinfo *tcpinfo;
2888 volatile guint32 len;
2890 gint tvb_len, tvb_reported_len;
2892 gboolean rpc_succeeded;
2893 gboolean save_fragmented;
2894 rpc_fragment_key old_rfk, *rfk, *new_rfk;
2895 conversation_t *conversation;
2896 fragment_data *ipfd_head;
2899 if (pinfo == NULL || pinfo->private_data == NULL) {
2902 tcpinfo = pinfo->private_data;
2904 if (tcpinfo == NULL) {
2907 seq = tcpinfo->seq + offset;
2910 * Get the record mark.
2912 if (!tvb_bytes_exist(tvb, offset, 4)) {
2914 * XXX - we should somehow arrange to handle
2915 * a record mark split across TCP segments.
2917 return 0; /* not enough to tell if it's valid */
2919 rpc_rm = tvb_get_ntohl(tvb, offset);
2921 len = rpc_rm & RPC_RM_FRAGLEN;
2924 * Do TCP desegmentation, if enabled.
2926 * reject fragments bigger than this preference setting.
2927 * This is arbitrary, but should at least prevent
2928 * some crashes from either packets with really
2929 * large RPC-over-TCP fragments or from stuff that's
2930 * not really valid for this protocol.
2932 if (len > max_rpc_tcp_pdu_size)
2933 return 0; /* pretend it's not valid */
2934 if (rpc_desegment) {
2935 seglen = tvb_length_remaining(tvb, offset + 4);
2937 if ((gint)len > seglen && pinfo->can_desegment) {
2939 * This frame doesn't have all of the
2940 * data for this message, but we can do
2943 * If this is a heuristic dissector, just
2944 * return 0 - we don't want to try to get
2945 * more data, as that's too likely to cause
2946 * us to misidentify this as valid.
2948 * XXX - this means that we won't
2949 * recognize the first fragment of a
2950 * multi-fragment RPC operation unless
2951 * we've already identified this
2952 * conversation as being an RPC
2953 * conversation (and thus aren't running
2954 * heuristically) - that would be a problem
2955 * if, for example, the first segment were
2956 * the beginning of a large NFS WRITE.
2958 * If this isn't a heuristic dissector,
2959 * we've already identified this conversation
2960 * as containing data for this protocol, as we
2961 * saw valid data in previous frames. Try to
2965 return 0; /* not valid */
2967 pinfo->desegment_offset = offset;
2968 pinfo->desegment_len = len - seglen;
2969 return -((gint32) pinfo->desegment_len);
2973 len += 4; /* include record mark */
2974 tvb_len = tvb_length_remaining(tvb, offset);
2975 tvb_reported_len = tvb_reported_length_remaining(tvb, offset);
2976 if (tvb_len > (gint)len)
2978 if (tvb_reported_len > (gint)len)
2979 tvb_reported_len = len;
2980 frag_tvb = tvb_new_subset(tvb, offset, tvb_len,
2984 * If we're not defragmenting, just hand this to the
2989 * This is the first fragment we've seen, and it's also
2990 * the last fragment; that means the record wasn't
2991 * fragmented. Hand the dissector the tvbuff for the
2992 * fragment as the tvbuff for the record.
2998 * Mark this as fragmented, so if somebody throws an
2999 * exception, we don't report it as a malformed frame.
3001 save_fragmented = pinfo->fragmented;
3002 pinfo->fragmented = TRUE;
3003 rpc_succeeded = call_message_dissector(tvb, rec_tvb, pinfo,
3004 tree, frag_tvb, dissector, ipfd_head, rpc_rm, first_pdu);
3005 pinfo->fragmented = save_fragmented;
3007 return 0; /* not RPC */
3012 * First, we check to see if this fragment is part of a record
3013 * that we're in the process of defragmenting.
3015 * The key is the conversation ID for the conversation to which
3016 * the packet belongs and the current sequence number.
3017 * We must first find the conversation and, if we don't find
3018 * one, create it. We know this is running over TCP, so the
3019 * conversation should not wildcard either address or port.
3021 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
3022 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
3023 if (conversation == NULL) {
3025 * It's not part of any conversation - create a new one.
3027 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
3028 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
3030 old_rfk.conv_id = conversation->index;
3032 old_rfk.port = pinfo->srcport;
3033 rfk = g_hash_table_lookup(rpc_reassembly_table, &old_rfk);
3037 * This fragment was not found in our table, so it doesn't
3038 * contain a continuation of a higher-level PDU.
3039 * Is it the last fragment?
3041 if (!(rpc_rm & RPC_RM_LASTFRAG)) {
3043 * This isn't the last fragment, so we don't
3044 * have the complete record.
3046 * It's the first fragment we've seen, so if
3047 * it's truly the first fragment of the record,
3048 * and it has enough data, the dissector can at
3049 * least check whether it looks like a valid
3050 * message, as it contains the start of the
3053 * The dissector should not dissect anything
3054 * if the "last fragment" flag isn't set in
3055 * the record marker, so it shouldn't throw
3058 if (!(*dissector)(frag_tvb, pinfo, tree, frag_tvb,
3059 NULL, TRUE, rpc_rm, first_pdu))
3060 return 0; /* not valid */
3063 * OK, now start defragmentation with that
3064 * fragment. Add this fragment, and set up
3065 * next packet/sequence number as well.
3067 * We must remember this fragment.
3070 rfk = se_alloc(sizeof(rpc_fragment_key));
3071 rfk->conv_id = conversation->index;
3073 rfk->port = pinfo->srcport;
3075 rfk->start_seq = seq;
3076 g_hash_table_insert(rpc_reassembly_table, rfk, rfk);
3079 * Start defragmentation.
3081 ipfd_head = fragment_add_multiple_ok(tvb, offset + 4,
3082 pinfo, rfk->start_seq, rpc_fragment_table,
3083 rfk->offset, len - 4, TRUE);
3086 * Make sure that defragmentation isn't complete;
3087 * it shouldn't be, as this is the first fragment
3088 * we've seen, and the "last fragment" bit wasn't
3091 if (ipfd_head == NULL) {
3092 new_rfk = se_alloc(sizeof(rpc_fragment_key));
3093 new_rfk->conv_id = rfk->conv_id;
3094 new_rfk->seq = seq + len;
3095 new_rfk->port = pinfo->srcport;
3096 new_rfk->offset = rfk->offset + len - 4;
3097 new_rfk->start_seq = rfk->start_seq;
3098 g_hash_table_insert(rpc_reassembly_table, new_rfk,
3102 * This is part of a fragmented record,
3103 * but it's not the first part.
3104 * Show it as a record marker plus data, under
3105 * a top-level tree for this protocol.
3107 make_frag_tree(frag_tvb, tree, proto, ett,rpc_rm);
3110 * No more processing need be done, as we don't
3111 * have a complete record.
3115 /* oddly, we have a first fragment, not marked as last,
3116 * but which the defragmenter thinks is complete.
3117 * So rather than creating a fragment reassembly tree,
3118 * we simply throw away the partial fragment structure
3119 * and fall though to our "sole fragment" processing below.
3125 * This is the first fragment we've seen, and it's also
3126 * the last fragment; that means the record wasn't
3127 * fragmented. Hand the dissector the tvbuff for the
3128 * fragment as the tvbuff for the record.
3134 * OK, this fragment was found, which means it continues
3135 * a record. This means we must defragment it.
3136 * Add it to the defragmentation lists.
3138 ipfd_head = fragment_add_multiple_ok(tvb, offset + 4, pinfo,
3139 rfk->start_seq, rpc_fragment_table,
3140 rfk->offset, len - 4, !(rpc_rm & RPC_RM_LASTFRAG));
3142 if (ipfd_head == NULL) {
3144 * fragment_add_multiple_ok() returned NULL.
3145 * This means that defragmentation is not
3148 * We must add an entry to the hash table with
3149 * the sequence number following this fragment
3150 * as the starting sequence number, so that when
3151 * we see that fragment we'll find that entry.
3153 * XXX - as TCP stream data is not currently
3154 * guaranteed to be provided in order to dissectors,
3155 * RPC fragments aren't guaranteed to be provided
3158 new_rfk = se_alloc(sizeof(rpc_fragment_key));
3159 new_rfk->conv_id = rfk->conv_id;
3160 new_rfk->seq = seq + len;
3161 new_rfk->port = pinfo->srcport;
3162 new_rfk->offset = rfk->offset + len - 4;
3163 new_rfk->start_seq = rfk->start_seq;
3164 g_hash_table_insert(rpc_reassembly_table, new_rfk,
3168 * This is part of a fragmented record,
3169 * but it's not the first part.
3170 * Show it as a record marker plus data, under
3171 * a top-level tree for this protocol,
3172 * but don't hand it to the dissector
3174 make_frag_tree(frag_tvb, tree, proto, ett, rpc_rm);
3177 * No more processing need be done, as we don't
3178 * have a complete record.
3184 * It's completely defragmented.
3186 * We only call subdissector for the last fragment.
3187 * XXX - this assumes in-order delivery of RPC
3188 * fragments, which requires in-order delivery of TCP
3191 if (!(rpc_rm & RPC_RM_LASTFRAG)) {
3193 * Well, it's defragmented, but this isn't
3194 * the last fragment; this probably means
3195 * this isn't the first pass, so we don't
3196 * need to start defragmentation.
3198 * This is part of a fragmented record,
3199 * but it's not the first part.
3200 * Show it as a record marker plus data, under
3201 * a top-level tree for this protocol,
3202 * but don't show it to the dissector.
3204 make_frag_tree(frag_tvb, tree, proto, ett, rpc_rm);
3207 * No more processing need be done, as we
3208 * only disssect the data with the last
3215 * OK, this is the last segment.
3216 * Create a tvbuff for the defragmented
3221 * Create a new TVB structure for
3222 * defragmented data.
3224 rec_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
3225 ipfd_head->datalen, ipfd_head->datalen);
3228 * Add defragmented data to the data source list.
3230 add_new_data_source(pinfo, rec_tvb, "Defragmented");
3234 * We have something to hand to the RPC message
3237 if (!call_message_dissector(tvb, rec_tvb, pinfo, tree,
3238 frag_tvb, dissector, ipfd_head, rpc_rm, first_pdu))
3239 return 0; /* not RPC */
3241 } /* end of dissect_rpc_fragment() */
3244 * Scans tvb, starting at given offset, to see if we can find
3245 * what looks like a valid RPC-over-TCP reply header.
3247 * @param tvb Buffer to inspect for RPC reply header.
3248 * @param offset Offset to begin search of tvb at.
3250 * @return -1 if no reply header found, else offset to start of header
3251 * (i.e., to the RPC record mark field).
3255 find_rpc_over_tcp_reply_start(tvbuff_t *tvb, int offset)
3259 * Looking for partial header sequence. From beginning of
3260 * stream-style header, including "record mark", full ONC-RPC
3262 * BE int32 record mark (rfc 1831 sec. 10)
3263 * ? int32 XID (rfc 1831 sec. 8)
3264 * BE int32 msg_type (ibid sec. 8, call = 0, reply = 1)
3266 * -------------------------------------------------------------
3267 * Then reply-specific fields are
3268 * BE int32 reply_stat (ibid, accept = 0, deny = 1)
3270 * Then, assuming accepted,
3272 * BE int32 auth_flavor (ibid, none = 0)
3273 * BE int32 ? auth_len (ibid, none = 0)
3275 * BE int32 accept_stat (ibid, success = 0, errs are 1..5 in rpc v2)
3277 * -------------------------------------------------------------
3278 * Or, call-specific fields are
3279 * BE int32 rpc_vers (rfc 1831 sec 8, always == 2)
3280 * BE int32 prog (NFS == 000186A3)
3281 * BE int32 prog_ver (NFS v2/3 == 2 or 3)
3282 * BE int32 proc_id (NFS, <= 256 ???)
3287 /* Initially, we search only for something matching the template
3288 * of a successful reply with no auth verifier.
3289 * Our first qualification test is search for a string of zero bytes,
3290 * corresponding the four guint32 values
3296 * If this string of zeros matches, then we go back and check the
3297 * preceding msg_type and record_mark fields.
3300 const gint cbZeroTail = 4 * 4; /* four guint32s of zeros */
3301 const gint ibPatternStart = 3 * 4; /* offset of zero fill from reply start */
3302 const guint8 * pbWholeBuf; /* all of tvb, from offset onwards */
3303 const int NoMatch = -1;
3305 gint ibSearchStart; /* offset of search start, in case of false hits. */
3307 const guint8 * pbBuf;
3309 gint cbInBuf; /* bytes in tvb, from offset onwards */
3317 cbInBuf = tvb_reported_length_remaining(tvb, offset);
3319 /* start search at first possible location */
3320 ibSearchStart = ibPatternStart;
3322 if (cbInBuf < (cbZeroTail + ibSearchStart)) {
3323 /* nothing to search, so claim no RPC */
3327 pbWholeBuf = tvb_get_ptr(tvb, offset, cbInBuf);
3328 if (pbWholeBuf == NULL) {
3329 /* probably never take this, as get_ptr seems to assert */
3333 while ((cbInBuf - ibSearchStart) > cbZeroTail) {
3334 /* First test for long tail of zeros, starting at the back.
3335 * A failure lets us skip the maximum possible buffer amount.
3337 pbBuf = pbWholeBuf + ibSearchStart + cbZeroTail - 1;
3338 for (i = cbZeroTail; i > 0; i --)
3342 /* match failure. Since we need N contiguous zeros,
3343 * we can increment next match start so zero testing
3344 * begins right after this failure spot.
3354 if (pbBuf == NULL) {
3358 /* got a match in zero-fill region, verify reply ID and
3359 * record mark fields */
3360 ulMsgType = pntohl (pbWholeBuf + ibSearchStart - 4);
3361 ulRecMark = pntohl (pbWholeBuf + ibSearchStart - ibPatternStart);
3363 if ((ulMsgType == RPC_REPLY) &&
3364 ((ulRecMark & ~0x80000000) <= (unsigned) max_rpc_tcp_pdu_size)) {
3365 /* looks ok, try dissect */
3366 return (offset + ibSearchStart - ibPatternStart);
3369 /* no match yet, nor egregious miss either. Inch along to next try */
3375 } /* end of find_rpc_over_tcp_reply_start() */
3378 * Scans tvb for what looks like a valid RPC call / reply header.
3379 * If found, calls standard dissect_rpc_fragment() logic to digest
3380 * the (hopefully valid) fragment.
3382 * With any luck, one invocation of this will be sufficient to get
3383 * us back in alignment with the stream, and no further calls to
3384 * this routine will be needed for a given conversation. As if. :-)
3387 * Same as dissect_rpc_fragment(). Will return zero (no frame)
3388 * if no valid RPC header is found.
3392 find_and_dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo,
3393 proto_tree *tree, rec_dissector_t dissector,
3395 int proto, int ett, gboolean defragment)
3402 offReply = find_rpc_over_tcp_reply_start(tvb, offset);
3404 /* could search for request, but not needed (or testable) thus far */
3405 return (0); /* claim no RPC */
3408 len = dissect_rpc_fragment(tvb, offReply,
3410 dissector, is_heur, proto, ett,
3412 TRUE /* force first-pdu state */);
3414 /* misses are reported as-is */
3420 /* returning a non-zero length, correct it to reflect the extra offset
3421 * we found necessary
3424 len += offReply - offset;
3427 /* negative length seems to only be used as a flag,
3428 * don't mess it up until found necessary
3430 /* len -= offReply - offset; */
3435 } /* end of find_and_dissect_rpc_fragment */
3441 * NEED_MORE_DATA, if we don't have enough data to dissect anything;
3443 * IS_RPC, if we dissected at least one message in its entirety
3446 * IS_NOT_RPC, if we found no RPC message.
3454 static rpc_tcp_return_t
3455 dissect_rpc_tcp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
3459 gboolean saw_rpc = FALSE;
3460 gboolean first_pdu = TRUE;
3463 while (tvb_reported_length_remaining(tvb, offset) != 0) {
3465 * Process this fragment.
3467 len = dissect_rpc_fragment(tvb, offset, pinfo, tree,
3468 dissect_rpc_message, is_heur, proto_rpc, ett_rpc,
3469 rpc_defragment, first_pdu);
3471 if ((len == 0) && first_pdu && rpc_find_fragment_start) {
3473 * Try discarding some leading bytes from tvb, on assumption
3474 * that we are looking at the middle of a stream-based transfer
3476 len = find_and_dissect_rpc_fragment(tvb, offset, pinfo, tree,
3477 dissect_rpc_message, is_heur, proto_rpc, ett_rpc,
3484 * We need more data from the TCP stream for
3487 return NEED_MORE_DATA;
3491 * It's not RPC. Stop processing.
3497 If the length indicates that the PDU continues beyond
3498 the end of this tvb, then tell TCP about it so that it
3499 knows where the next PDU starts.
3500 This is to help TCP detect when PDUs are not aligned to
3501 segment boundaries and allow it to find RPC headers
3502 that starts in the middle of a TCP segment.
3504 if(!pinfo->fd->flags.visited){
3505 if(len>tvb_reported_length_remaining(tvb, offset)){
3506 pinfo->want_pdu_tracking=2;
3507 pinfo->bytes_until_next_pdu=len-tvb_reported_length_remaining(tvb, offset);
3513 return saw_rpc ? IS_RPC : IS_NOT_RPC;
3517 dissect_rpc_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3519 switch (dissect_rpc_tcp_common(tvb, pinfo, tree, TRUE)) {
3528 /* "Can't happen" */
3529 DISSECTOR_ASSERT_NOT_REACHED();
3535 dissect_rpc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3537 if (dissect_rpc_tcp_common(tvb, pinfo, tree, FALSE) == IS_NOT_RPC)
3538 dissect_rpc_continuation(tvb, pinfo, tree);
3541 /* Discard any state we've saved. */
3543 rpc_init_protocol(void)
3545 if (rpc_reassembly_table != NULL) {
3546 g_hash_table_destroy(rpc_reassembly_table);
3547 rpc_reassembly_table = NULL;
3550 rpc_reassembly_table = g_hash_table_new(rpc_fragment_hash,
3551 rpc_fragment_equal);
3553 fragment_table_init(&rpc_fragment_table);
3556 /* will be called once from register.c at startup time */
3558 proto_register_rpc(void)
3560 static hf_register_info hf[] = {
3561 { &hf_rpc_reqframe, {
3562 "Request Frame", "rpc.reqframe", FT_FRAMENUM, BASE_NONE,
3563 NULL, 0, NULL, HFILL }},
3564 { &hf_rpc_repframe, {
3565 "Reply Frame", "rpc.repframe", FT_FRAMENUM, BASE_NONE,
3566 NULL, 0, NULL, HFILL }},
3567 { &hf_rpc_lastfrag, {
3568 "Last Fragment", "rpc.lastfrag", FT_BOOLEAN, 32,
3569 TFS(&tfs_yes_no), RPC_RM_LASTFRAG, NULL, HFILL }},
3570 { &hf_rpc_fraglen, {
3571 "Fragment Length", "rpc.fraglen", FT_UINT32, BASE_DEC,
3572 NULL, RPC_RM_FRAGLEN, NULL, HFILL }},
3574 "XID", "rpc.xid", FT_UINT32, BASE_HEX,
3575 NULL, 0, NULL, HFILL }},
3576 { &hf_rpc_msgtype, {
3577 "Message Type", "rpc.msgtyp", FT_UINT32, BASE_DEC,
3578 VALS(rpc_msg_type), 0, NULL, HFILL }},
3579 { &hf_rpc_state_reply, {
3580 "Reply State", "rpc.replystat", FT_UINT32, BASE_DEC,
3581 VALS(rpc_reply_state), 0, NULL, HFILL }},
3582 { &hf_rpc_state_accept, {
3583 "Accept State", "rpc.state_accept", FT_UINT32, BASE_DEC,
3584 VALS(rpc_accept_state), 0, NULL, HFILL }},
3585 { &hf_rpc_state_reject, {
3586 "Reject State", "rpc.state_reject", FT_UINT32, BASE_DEC,
3587 VALS(rpc_reject_state), 0, NULL, HFILL }},
3588 { &hf_rpc_state_auth, {
3589 "Auth State", "rpc.state_auth", FT_UINT32, BASE_DEC,
3590 VALS(rpc_auth_state), 0, NULL, HFILL }},
3591 { &hf_rpc_version, {
3592 "RPC Version", "rpc.version", FT_UINT32, BASE_DEC,
3593 NULL, 0, NULL, HFILL }},
3594 { &hf_rpc_version_min, {
3595 "RPC Version (Minimum)", "rpc.version.min", FT_UINT32,
3596 BASE_DEC, NULL, 0, "Program Version (Minimum)", HFILL }},
3597 { &hf_rpc_version_max, {
3598 "RPC Version (Maximum)", "rpc.version.max", FT_UINT32,
3599 BASE_DEC, NULL, 0, NULL, HFILL }},
3600 { &hf_rpc_program, {
3601 "Program", "rpc.program", FT_UINT32, BASE_DEC,
3602 NULL, 0, NULL, HFILL }},
3603 { &hf_rpc_programversion, {
3604 "Program Version", "rpc.programversion", FT_UINT32,
3605 BASE_DEC, NULL, 0, NULL, HFILL }},
3606 { &hf_rpc_programversion_min, {
3607 "Program Version (Minimum)", "rpc.programversion.min", FT_UINT32,
3608 BASE_DEC, NULL, 0, NULL, HFILL }},
3609 { &hf_rpc_programversion_max, {
3610 "Program Version (Maximum)", "rpc.programversion.max", FT_UINT32,
3611 BASE_DEC, NULL, 0, NULL, HFILL }},
3612 { &hf_rpc_procedure, {
3613 "Procedure", "rpc.procedure", FT_UINT32, BASE_DEC,
3614 NULL, 0, NULL, HFILL }},
3615 { &hf_rpc_auth_flavor, {
3616 "Flavor", "rpc.auth.flavor", FT_UINT32, BASE_DEC,
3617 VALS(rpc_auth_flavor), 0, NULL, HFILL }},
3618 { &hf_rpc_auth_length, {
3619 "Length", "rpc.auth.length", FT_UINT32, BASE_DEC,
3620 NULL, 0, NULL, HFILL }},
3621 { &hf_rpc_auth_stamp, {
3622 "Stamp", "rpc.auth.stamp", FT_UINT32, BASE_HEX,
3623 NULL, 0, NULL, HFILL }},
3624 { &hf_rpc_auth_uid, {
3625 "UID", "rpc.auth.uid", FT_UINT32, BASE_DEC,
3626 NULL, 0, NULL, HFILL }},
3627 { &hf_rpc_auth_gid, {
3628 "GID", "rpc.auth.gid", FT_UINT32, BASE_DEC,
3629 NULL, 0, NULL, HFILL }},
3630 { &hf_rpc_authgss_v, {
3631 "GSS Version", "rpc.authgss.version", FT_UINT32,
3632 BASE_DEC, NULL, 0, NULL, HFILL }},
3633 { &hf_rpc_authgss_proc, {
3634 "GSS Procedure", "rpc.authgss.procedure", FT_UINT32,
3635 BASE_DEC, VALS(rpc_authgss_proc), 0, NULL, HFILL }},
3636 { &hf_rpc_authgss_seq, {
3637 "GSS Sequence Number", "rpc.authgss.seqnum", FT_UINT32,
3638 BASE_DEC, NULL, 0, NULL, HFILL }},
3639 { &hf_rpc_authgss_svc, {
3640 "GSS Service", "rpc.authgss.service", FT_UINT32,
3641 BASE_DEC, VALS(rpc_authgss_svc), 0, NULL, HFILL }},
3642 { &hf_rpc_authgss_ctx, {
3643 "GSS Context", "rpc.authgss.context", FT_BYTES,
3644 BASE_NONE, NULL, 0, NULL, HFILL }},
3645 { &hf_rpc_authgss_major, {
3646 "GSS Major Status", "rpc.authgss.major", FT_UINT32,
3647 BASE_DEC, NULL, 0, NULL, HFILL }},
3648 { &hf_rpc_authgss_minor, {
3649 "GSS Minor Status", "rpc.authgss.minor", FT_UINT32,
3650 BASE_DEC, NULL, 0, NULL, HFILL }},
3651 { &hf_rpc_authgss_window, {
3652 "GSS Sequence Window", "rpc.authgss.window", FT_UINT32,
3653 BASE_DEC, NULL, 0, NULL, HFILL }},
3654 { &hf_rpc_authgss_token_length, {
3655 "GSS Token Length", "rpc.authgss.token_length", FT_UINT32,
3656 BASE_DEC, NULL, 0, NULL, HFILL }},
3657 { &hf_rpc_authgss_data_length, {
3658 "Length", "rpc.authgss.data.length", FT_UINT32,
3659 BASE_DEC, NULL, 0, NULL, HFILL }},
3660 { &hf_rpc_authgss_data, {
3661 "GSS Data", "rpc.authgss.data", FT_BYTES,
3662 BASE_NONE, NULL, 0, NULL, HFILL }},
3663 { &hf_rpc_authgss_checksum, {
3664 "GSS Checksum", "rpc.authgss.checksum", FT_BYTES,
3665 BASE_NONE, NULL, 0, NULL, HFILL }},
3666 { &hf_rpc_authgss_token, {
3667 "GSS Token", "rpc.authgss.token", FT_BYTES,
3668 BASE_NONE, NULL, 0, NULL, HFILL }},
3669 { &hf_rpc_authgssapi_v, {
3670 "AUTH_GSSAPI Version", "rpc.authgssapi.version",
3671 FT_UINT32, BASE_DEC, NULL, 0, NULL,
3673 { &hf_rpc_authgssapi_msg, {
3674 "AUTH_GSSAPI Message", "rpc.authgssapi.message",
3675 FT_BOOLEAN, BASE_NONE, TFS(&tfs_yes_no), 0x0, NULL,
3677 { &hf_rpc_authgssapi_msgv, {
3678 "Msg Version", "rpc.authgssapi.msgversion",
3679 FT_UINT32, BASE_DEC, NULL, 0, NULL,
3681 { &hf_rpc_authgssapi_handle, {
3682 "Client Handle", "rpc.authgssapi.handle",
3683 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
3684 { &hf_rpc_authgssapi_isn, {
3685 "Signed ISN", "rpc.authgssapi.isn",
3686 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
3687 { &hf_rpc_authdes_namekind, {
3688 "Namekind", "rpc.authdes.namekind", FT_UINT32, BASE_DEC,
3689 VALS(rpc_authdes_namekind), 0, NULL, HFILL }},
3690 { &hf_rpc_authdes_netname, {
3691 "Netname", "rpc.authdes.netname", FT_STRING,
3692 BASE_NONE, NULL, 0, NULL, HFILL }},
3693 { &hf_rpc_authdes_convkey, {
3694 "Conversation Key (encrypted)", "rpc.authdes.convkey", FT_UINT32,
3695 BASE_HEX, NULL, 0, NULL, HFILL }},
3696 { &hf_rpc_authdes_window, {
3697 "Window (encrypted)", "rpc.authdes.window", FT_UINT32,
3698 BASE_HEX, NULL, 0, "Windows (encrypted)", HFILL }},
3699 { &hf_rpc_authdes_nickname, {
3700 "Nickname", "rpc.authdes.nickname", FT_UINT32,
3701 BASE_HEX, NULL, 0, NULL, HFILL }},
3702 { &hf_rpc_authdes_timestamp, {
3703 "Timestamp (encrypted)", "rpc.authdes.timestamp", FT_UINT32,
3704 BASE_HEX, NULL, 0, NULL, HFILL }},
3705 { &hf_rpc_authdes_windowverf, {
3706 "Window verifier (encrypted)", "rpc.authdes.windowverf", FT_UINT32,
3707 BASE_HEX, NULL, 0, NULL, HFILL }},
3708 { &hf_rpc_authdes_timeverf, {
3709 "Timestamp verifier (encrypted)", "rpc.authdes.timeverf", FT_UINT32,
3710 BASE_HEX, NULL, 0, NULL, HFILL }},
3711 { &hf_rpc_auth_machinename, {
3712 "Machine Name", "rpc.auth.machinename", FT_STRING,
3713 BASE_NONE, NULL, 0, NULL, HFILL }},
3715 "Duplicate Call/Reply", "rpc.dup", FT_NONE, BASE_NONE,
3716 NULL, 0, NULL, HFILL }},
3717 { &hf_rpc_call_dup, {
3718 "Duplicate to the call in", "rpc.call.dup", FT_FRAMENUM, BASE_NONE,
3719 NULL, 0, "This is a duplicate to the call in frame", HFILL }},
3720 { &hf_rpc_reply_dup, {
3721 "Duplicate to the reply in", "rpc.reply.dup", FT_FRAMENUM, BASE_NONE,
3722 NULL, 0, "This is a duplicate to the reply in frame", HFILL }},
3723 { &hf_rpc_value_follows, {
3724 "Value Follows", "rpc.value_follows", FT_BOOLEAN, BASE_NONE,
3725 TFS(&tfs_yes_no), 0x0, NULL, HFILL }},
3726 { &hf_rpc_array_len, {
3727 "num", "rpc.array.len", FT_UINT32, BASE_DEC,
3728 NULL, 0, "Length of RPC array", HFILL }},
3731 "Time from request", "rpc.time", FT_RELATIVE_TIME, BASE_NONE,
3732 NULL, 0, "Time between Request and Reply for ONC-RPC calls", HFILL }},
3734 { &hf_rpc_fragment_overlap,
3735 { "Fragment overlap", "rpc.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3736 "Fragment overlaps with other fragments", HFILL }},
3738 { &hf_rpc_fragment_overlap_conflict,
3739 { "Conflicting data in fragment overlap", "rpc.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3740 "Overlapping fragments contained conflicting data", HFILL }},
3742 { &hf_rpc_fragment_multiple_tails,
3743 { "Multiple tail fragments found", "rpc.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3744 "Several tails were found when defragmenting the packet", HFILL }},
3746 { &hf_rpc_fragment_too_long_fragment,
3747 { "Fragment too long", "rpc.fragment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3748 "Fragment contained data past end of packet", HFILL }},
3750 { &hf_rpc_fragment_error,
3751 { "Defragmentation error", "rpc.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3752 "Defragmentation error due to illegal fragments", HFILL }},
3755 { "RPC Fragment", "rpc.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3758 { &hf_rpc_fragments,
3759 { "RPC Fragments", "rpc.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
3762 static gint *ett[] = {
3774 &ett_rpc_authgssapi_msg,
3775 &ett_rpc_unknown_program,
3777 module_t *rpc_module;
3779 proto_rpc = proto_register_protocol("Remote Procedure Call",
3781 /* this is a dummy dissector for all those unknown rpc programs */
3782 proto_register_field_array(proto_rpc, hf, array_length(hf));
3783 proto_register_subtree_array(ett, array_length(ett));
3784 register_init_routine(&rpc_init_protocol);
3786 rpc_module = prefs_register_protocol(proto_rpc, NULL);
3787 prefs_register_bool_preference(rpc_module, "desegment_rpc_over_tcp",
3788 "Reassemble RPC over TCP messages\nspanning multiple TCP segments",
3789 "Whether the RPC dissector should reassemble messages spanning multiple TCP segments."
3790 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3792 prefs_register_bool_preference(rpc_module, "defragment_rpc_over_tcp",
3793 "Reassemble fragmented RPC-over-TCP messages",
3794 "Whether the RPC dissector should defragment RPC-over-TCP messages.",
3797 prefs_register_uint_preference(rpc_module, "max_tcp_pdu_size", "Maximum size of a RPC-over-TCP PDU",
3798 "Set the maximum size of RPCoverTCP PDUs. "
3799 " If the size field of the record marker is larger "
3800 "than this value it will not be considered a valid RPC PDU.",
3801 10, &max_rpc_tcp_pdu_size);
3803 prefs_register_bool_preference(rpc_module, "dissect_unknown_programs",
3804 "Dissect unknown RPC program numbers",
3805 "Whether the RPC dissector should attempt to dissect RPC PDUs containing programs that are not known to Wireshark. This will make the heuristics significantly weaker and elevate the risk for falsely identifying and misdissecting packets significantly.",
3806 &rpc_dissect_unknown_programs);
3808 prefs_register_bool_preference(rpc_module, "find_fragment_start",
3809 "Attempt to locate start-of-fragment in partial RPC-over-TCP captures",
3810 "Whether the RPC dissector should attempt to locate RPC PDU boundaries when initial fragment alignment is not known. This may cause false positives, or slow operation.",
3811 &rpc_find_fragment_start);
3813 register_dissector("rpc", dissect_rpc, proto_rpc);
3814 register_dissector("rpc-tcp", dissect_rpc_tcp, proto_rpc);
3815 rpc_tap = register_tap("rpc");
3818 * Init the hash tables. Dissectors for RPC protocols must
3819 * have a "handoff registration" routine that registers the
3820 * protocol with RPC; they must not do it in their protocol
3821 * registration routine, as their protocol registration
3822 * routine might be called before this routine is called and
3823 * thus might be called before the hash tables are initialized,
3824 * but it's guaranteed that all protocol registration routines
3825 * will be called before any handoff registration routines
3828 rpc_progs = g_hash_table_new(rpc_prog_hash, rpc_prog_equal);
3829 rpc_procs = g_hash_table_new(rpc_proc_hash, rpc_proc_equal);
3833 proto_reg_handoff_rpc(void)
3835 /* tcp/udp port 111 is used by portmapper which is an onc-rpc service.
3836 we register onc-rpc on this port so that we can choose RPC in
3837 the list offered by DecodeAs, and so that traffic to or from
3838 port 111 from or to a higher-numbered port is dissected as RPC
3839 even if there's a dissector registered on the other port (it's
3840 probably RPC traffic from some randomly-chosen port that happens
3841 to match some port for which we have a dissector)
3843 rpc_tcp_handle = find_dissector("rpc-tcp");
3844 dissector_add("tcp.port", 111, rpc_tcp_handle);
3845 rpc_handle = find_dissector("rpc");
3846 dissector_add("udp.port", 111, rpc_handle);
3848 heur_dissector_add("tcp", dissect_rpc_tcp_heur, proto_rpc);
3849 heur_dissector_add("udp", dissect_rpc_heur, proto_rpc);
3850 gssapi_handle = find_dissector("gssapi");
3851 data_handle = find_dissector("data");
3860 * indent-tabs-mode: t
3863 * ex: set shiftwidth=8 tabstop=8 noexpandtab
3864 * :indentSize=8:tabSize=8:noTabs=false: