1999-10-29 01:11:23 +00:00
/* packet-rpc.c
* Routines for rpc dissection
* Copyright 1999 , Uwe Girlich < Uwe . Girlich @ philosys . de >
2002-08-28 21:04:11 +00:00
*
2004-07-18 00:24:25 +00:00
* $ Id $
2002-08-28 21:04:11 +00:00
*
2006-05-21 04:49:01 +00:00
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
1999-10-29 01:11:23 +00:00
* Copyright 1998 Gerald Combs
2002-08-28 21:04:11 +00:00
*
1999-10-29 01:11:23 +00:00
* Copied from packet - smb . c
2002-08-28 21:04:11 +00:00
*
1999-10-29 01:11:23 +00:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2002-08-28 21:04:11 +00:00
*
1999-10-29 01:11:23 +00:00
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
2002-08-28 21:04:11 +00:00
*
1999-10-29 01:11:23 +00:00
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include <glib.h>
# include <stdio.h>
# include <string.h>
1999-11-15 14:57:38 +00:00
# include <ctype.h>
2002-01-21 07:37:49 +00:00
# include <epan/packet.h>
# include <epan/conversation.h>
2006-03-20 10:52:53 +00:00
# include <epan/emem.h>
1999-10-29 01:11:23 +00:00
# include "packet-rpc.h"
2002-01-07 00:59:26 +00:00
# include "packet-frame.h"
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
# include "packet-tcp.h"
2004-09-27 22:55:15 +00:00
# include <epan/prefs.h>
2005-02-09 23:38:00 +00:00
# include <epan/reassemble.h>
2005-09-17 00:31:15 +00:00
# include <epan/dissectors/rpc_defrag.h>
2002-05-21 10:17:30 +00:00
# include "packet-nfs.h"
2004-09-29 00:06:36 +00:00
# include <epan/tap.h>
2005-08-13 22:08:22 +00:00
# include <epan/strutil.h>
2007-04-30 19:24:25 +00:00
# include <epan/garrayfix.h>
1999-10-29 01:11:23 +00:00
2000-08-24 23:09:37 +00:00
/*
* See :
*
* RFC 1831 , " RPC: Remote Procedure Call Protocol Specification
* Version 2 " ;
*
* RFC 1832 , " XDR: External Data Representation Standard " ;
*
* RFC 2203 , " RPCSEC_GSS Protocol Specification " .
*
* See also
*
* RFC 2695 , " Authentication Mechanisms for ONC RPC "
*
2001-01-18 06:33:23 +00:00
* although we don ' t currently dissect AUTH_DES or AUTH_KERB .
2000-08-24 23:09:37 +00:00
*/
1999-10-29 01:11:23 +00:00
2001-09-13 07:56:53 +00:00
/* desegmentation of RPC over TCP */
2001-09-17 02:07:00 +00:00
static gboolean rpc_desegment = TRUE ;
2001-09-13 07:56:53 +00:00
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
/* defragmentation of fragmented RPC over TCP records */
2005-09-28 22:15:38 +00:00
static gboolean rpc_defragment = TRUE ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
2004-04-03 00:29:08 +00:00
/* try to dissect RPC packets for programs that are not known
2006-05-21 04:49:01 +00:00
* ( proprietary ones ) by wireshark .
2004-04-03 00:29:08 +00:00
*/
static gboolean rpc_dissect_unknown_programs = FALSE ;
2005-10-17 18:56:27 +00:00
/* try to find RPC fragment start if normal decode fails
2005-08-08 09:52:59 +00:00
* ( good when starting decode of mid - stream capture )
*/
static gboolean rpc_find_fragment_start = FALSE ;
2004-04-03 00:29:08 +00:00
1999-11-19 13:09:56 +00:00
static struct true_false_string yesno = { " Yes " , " No " } ;
2002-09-04 09:40:29 +00:00
static int rpc_tap = - 1 ;
1999-11-19 13:09:56 +00:00
2000-07-17 20:34:00 +00:00
static const value_string rpc_msg_type [ ] = {
1999-10-29 01:11:23 +00:00
{ RPC_CALL , " Call " } ,
{ RPC_REPLY , " Reply " } ,
{ 0 , NULL }
} ;
2000-07-17 20:34:00 +00:00
static const value_string rpc_reply_state [ ] = {
1999-10-29 01:11:23 +00:00
{ MSG_ACCEPTED , " accepted " } ,
{ MSG_DENIED , " denied " } ,
{ 0 , NULL }
} ;
1999-11-19 23:23:41 +00:00
const value_string rpc_auth_flavor [ ] = {
1999-10-29 01:11:23 +00:00
{ AUTH_NULL , " AUTH_NULL " } ,
{ AUTH_UNIX , " AUTH_UNIX " } ,
{ AUTH_SHORT , " AUTH_SHORT " } ,
{ AUTH_DES , " AUTH_DES " } ,
2000-08-24 22:58:56 +00:00
{ RPCSEC_GSS , " RPCSEC_GSS " } ,
2003-05-02 21:58:23 +00:00
{ AUTH_GSSAPI , " AUTH_GSSAPI " } ,
2006-11-21 08:53:11 +00:00
{ RPCSEC_GSS_KRB5 , " RPCSEC_GSS_KRB5 " } ,
{ RPCSEC_GSS_KRB5I , " RPCSEC_GSS_KRB5I " } ,
{ RPCSEC_GSS_KRB5P , " RPCSEC_GSS_KRB5P " } ,
{ RPCSEC_GSS_LIPKEY , " RPCSEC_GSS_LIPKEY " } ,
{ RPCSEC_GSS_LIPKEY_I , " RPCSEC_GSS_LIPKEY_I " } ,
{ RPCSEC_GSS_LIPKEY_P , " RPCSEC_GSS_LIPKEY_P " } ,
{ RPCSEC_GSS_SPKM3 , " RPCSEC_GSS_SPKM3 " } ,
{ RPCSEC_GSS_SPKM3I , " RPCSEC_GSS_SPKM3I " } ,
{ RPCSEC_GSS_SPKM3P , " RPCSEC_GSS_SPKM3P " } ,
1999-10-29 01:11:23 +00:00
{ 0 , NULL }
} ;
2000-07-17 20:34:00 +00:00
static const value_string rpc_authgss_proc [ ] = {
2000-08-24 22:58:56 +00:00
{ RPCSEC_GSS_DATA , " RPCSEC_GSS_DATA " } ,
{ RPCSEC_GSS_INIT , " RPCSEC_GSS_INIT " } ,
{ RPCSEC_GSS_CONTINUE_INIT , " RPCSEC_GSS_CONTINUE_INIT " } ,
{ RPCSEC_GSS_DESTROY , " RPCSEC_GSS_DESTROY " } ,
2000-07-17 20:34:00 +00:00
{ 0 , NULL }
} ;
2003-05-02 21:58:23 +00:00
static const value_string rpc_authgssapi_proc [ ] = {
{ AUTH_GSSAPI_EXIT , " AUTH_GSSAPI_EXIT " } ,
{ AUTH_GSSAPI_INIT , " AUTH_GSSAPI_INIT " } ,
{ AUTH_GSSAPI_CONTINUE_INIT , " AUTH_GSSAPI_CONTINUE_INIT " } ,
{ AUTH_GSSAPI_MSG , " AUTH_GSSAPI_MSG " } ,
{ AUTH_GSSAPI_DESTROY , " AUTH_GSSAPI_DESTROY " } ,
{ 0 , NULL }
} ;
2001-10-29 20:49:28 +00:00
value_string rpc_authgss_svc [ ] = {
2000-08-24 22:58:56 +00:00
{ RPCSEC_GSS_SVC_NONE , " rpcsec_gss_svc_none " } ,
{ RPCSEC_GSS_SVC_INTEGRITY , " rpcsec_gss_svc_integrity " } ,
{ RPCSEC_GSS_SVC_PRIVACY , " rpcsec_gss_svc_privacy " } ,
2000-07-17 20:34:00 +00:00
{ 0 , NULL }
} ;
static const value_string rpc_accept_state [ ] = {
1999-10-29 01:11:23 +00:00
{ SUCCESS , " RPC executed successfully " } ,
{ PROG_UNAVAIL , " remote hasn't exported program " } ,
{ PROG_MISMATCH , " remote can't support version # " } ,
{ PROC_UNAVAIL , " program can't support procedure " } ,
{ GARBAGE_ARGS , " procedure can't decode params " } ,
2005-05-04 13:09:46 +00:00
{ SYSTEM_ERROR , " system errors like memory allocation failure " } ,
1999-10-29 01:11:23 +00:00
{ 0 , NULL }
} ;
2000-07-17 20:34:00 +00:00
static const value_string rpc_reject_state [ ] = {
1999-10-29 01:11:23 +00:00
{ RPC_MISMATCH , " RPC_MISMATCH " } ,
{ AUTH_ERROR , " AUTH_ERROR " } ,
{ 0 , NULL }
} ;
2000-07-17 20:34:00 +00:00
static const value_string rpc_auth_state [ ] = {
1999-10-29 01:11:23 +00:00
{ AUTH_BADCRED , " bad credential (seal broken) " } ,
{ AUTH_REJECTEDCRED , " client must begin new session " } ,
{ AUTH_BADVERF , " bad verifier (seal broken) " } ,
{ AUTH_REJECTEDVERF , " verifier expired or replayed " } ,
{ AUTH_TOOWEAK , " rejected for security reasons " } ,
2000-08-24 22:58:56 +00:00
{ RPCSEC_GSSCREDPROB , " GSS credential problem " } ,
{ RPCSEC_GSSCTXPROB , " GSS context problem " } ,
1999-10-29 01:11:23 +00:00
{ 0 , NULL }
} ;
2001-05-25 20:13:04 +00:00
static const value_string rpc_authdes_namekind [ ] = {
{ AUTHDES_NAMEKIND_FULLNAME , " ADN_FULLNAME " } ,
{ AUTHDES_NAMEKIND_NICKNAME , " ADN_NICKNAME " } ,
{ 0 , NULL }
} ;
1999-10-29 01:11:23 +00:00
/* the protocol number */
static int proto_rpc = - 1 ;
2002-12-19 02:58:53 +00:00
static int hf_rpc_reqframe = - 1 ;
static int hf_rpc_repframe = - 1 ;
1999-11-19 13:09:56 +00:00
static int hf_rpc_lastfrag = - 1 ;
static int hf_rpc_fraglen = - 1 ;
1999-11-15 14:57:38 +00:00
static int hf_rpc_xid = - 1 ;
static int hf_rpc_msgtype = - 1 ;
1999-11-15 17:16:51 +00:00
static int hf_rpc_version = - 1 ;
static int hf_rpc_version_min = - 1 ;
static int hf_rpc_version_max = - 1 ;
1999-11-15 14:57:38 +00:00
static int hf_rpc_program = - 1 ;
static int hf_rpc_programversion = - 1 ;
1999-11-15 17:16:51 +00:00
static int hf_rpc_programversion_min = - 1 ;
static int hf_rpc_programversion_max = - 1 ;
1999-11-15 14:57:38 +00:00
static int hf_rpc_procedure = - 1 ;
1999-11-15 17:16:51 +00:00
static int hf_rpc_auth_flavor = - 1 ;
static int hf_rpc_auth_length = - 1 ;
static int hf_rpc_auth_machinename = - 1 ;
static int hf_rpc_auth_stamp = - 1 ;
static int hf_rpc_auth_uid = - 1 ;
static int hf_rpc_auth_gid = - 1 ;
2000-07-17 20:34:00 +00:00
static int hf_rpc_authgss_v = - 1 ;
static int hf_rpc_authgss_proc = - 1 ;
static int hf_rpc_authgss_seq = - 1 ;
static int hf_rpc_authgss_svc = - 1 ;
static int hf_rpc_authgss_ctx = - 1 ;
static int hf_rpc_authgss_major = - 1 ;
static int hf_rpc_authgss_minor = - 1 ;
static int hf_rpc_authgss_window = - 1 ;
2002-08-22 20:22:22 +00:00
static int hf_rpc_authgss_token_length = - 1 ;
2000-07-17 20:34:00 +00:00
static int hf_rpc_authgss_data_length = - 1 ;
static int hf_rpc_authgss_data = - 1 ;
static int hf_rpc_authgss_checksum = - 1 ;
2003-05-02 21:58:23 +00:00
static int hf_rpc_authgssapi_v = - 1 ;
static int hf_rpc_authgssapi_msg = - 1 ;
static int hf_rpc_authgssapi_msgv = - 1 ;
static int hf_rpc_authgssapi_handle = - 1 ;
static int hf_rpc_authgssapi_isn = - 1 ;
2001-05-25 20:13:04 +00:00
static int hf_rpc_authdes_namekind = - 1 ;
static int hf_rpc_authdes_netname = - 1 ;
static int hf_rpc_authdes_convkey = - 1 ;
static int hf_rpc_authdes_window = - 1 ;
static int hf_rpc_authdes_nickname = - 1 ;
static int hf_rpc_authdes_timestamp = - 1 ;
static int hf_rpc_authdes_windowverf = - 1 ;
static int hf_rpc_authdes_timeverf = - 1 ;
1999-11-15 17:16:51 +00:00
static int hf_rpc_state_accept = - 1 ;
static int hf_rpc_state_reply = - 1 ;
static int hf_rpc_state_reject = - 1 ;
static int hf_rpc_state_auth = - 1 ;
1999-12-14 11:43:59 +00:00
static int hf_rpc_dup = - 1 ;
static int hf_rpc_call_dup = - 1 ;
static int hf_rpc_reply_dup = - 1 ;
2000-03-09 12:09:53 +00:00
static int hf_rpc_value_follows = - 1 ;
2001-05-07 20:36:39 +00:00
static int hf_rpc_array_len = - 1 ;
2001-12-28 20:18:45 +00:00
static int hf_rpc_time = - 1 ;
2002-06-05 11:32:14 +00:00
static int hf_rpc_fragments = - 1 ;
static int hf_rpc_fragment = - 1 ;
static int hf_rpc_fragment_overlap = - 1 ;
static int hf_rpc_fragment_overlap_conflict = - 1 ;
static int hf_rpc_fragment_multiple_tails = - 1 ;
static int hf_rpc_fragment_too_long_fragment = - 1 ;
static int hf_rpc_fragment_error = - 1 ;
1999-10-29 01:11:23 +00:00
1999-11-16 11:44:20 +00:00
static gint ett_rpc = - 1 ;
2004-04-03 00:29:08 +00:00
static gint ett_rpc_unknown_program = - 1 ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
static gint ett_rpc_fragments = - 1 ;
2002-06-05 11:32:14 +00:00
static gint ett_rpc_fragment = - 1 ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
static gint ett_rpc_fraghdr = - 1 ;
1999-11-16 11:44:20 +00:00
static gint ett_rpc_string = - 1 ;
static gint ett_rpc_cred = - 1 ;
static gint ett_rpc_verf = - 1 ;
static gint ett_rpc_gids = - 1 ;
2002-08-22 20:22:22 +00:00
static gint ett_rpc_gss_token = - 1 ;
2000-07-17 20:34:00 +00:00
static gint ett_rpc_gss_data = - 1 ;
2001-05-07 20:36:39 +00:00
static gint ett_rpc_array = - 1 ;
2003-05-02 21:58:23 +00:00
static gint ett_rpc_authgssapi_msg = - 1 ;
1999-10-29 01:11:23 +00:00
2001-11-27 07:13:32 +00:00
static dissector_handle_t rpc_tcp_handle ;
static dissector_handle_t rpc_handle ;
2002-08-22 20:22:22 +00:00
static dissector_handle_t gssapi_handle ;
2001-11-26 04:52:51 +00:00
static dissector_handle_t data_handle ;
2005-07-09 00:53:17 +00:00
static guint max_rpc_tcp_pdu_size = 262144 ;
2003-08-25 10:17:38 +00:00
2002-10-24 06:17:36 +00:00
static const fragment_items rpc_frag_items = {
2002-06-05 11:32:14 +00:00
& ett_rpc_fragment ,
& ett_rpc_fragments ,
& hf_rpc_fragments ,
& hf_rpc_fragment ,
& hf_rpc_fragment_overlap ,
& hf_rpc_fragment_overlap_conflict ,
& hf_rpc_fragment_multiple_tails ,
& hf_rpc_fragment_too_long_fragment ,
2002-06-07 10:11:41 +00:00
& hf_rpc_fragment_error ,
2003-04-20 11:36:16 +00:00
NULL ,
2002-06-07 10:11:41 +00:00
" fragments "
2002-06-05 11:32:14 +00:00
} ;
1999-10-29 01:11:23 +00:00
/* Hash table with info on RPC program numbers */
2005-10-17 18:56:27 +00:00
GHashTable * rpc_progs = NULL ;
1999-10-29 01:11:23 +00:00
/* Hash table with info on RPC procedure numbers */
2005-10-17 18:56:27 +00:00
GHashTable * rpc_procs = NULL ;
2001-01-28 03:39:48 +00:00
2001-09-12 08:13:33 +00:00
static void dissect_rpc ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ) ;
2001-09-13 07:56:53 +00:00
static void dissect_rpc_tcp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ) ;
2001-02-09 06:49:29 +00:00
1999-10-29 01:11:23 +00:00
/***********************************/
/* Hash array with procedure names */
/***********************************/
/* compare 2 keys */
2002-04-01 23:56:41 +00:00
static gint
1999-10-29 01:11:23 +00:00
rpc_proc_equal ( gconstpointer k1 , gconstpointer k2 )
{
2002-12-02 23:43:30 +00:00
const rpc_proc_info_key * key1 = ( const rpc_proc_info_key * ) k1 ;
const rpc_proc_info_key * key2 = ( const rpc_proc_info_key * ) k2 ;
1999-10-29 01:11:23 +00:00
2002-08-28 21:04:11 +00:00
return ( ( key1 - > prog = = key2 - > prog & &
1999-10-29 01:11:23 +00:00
key1 - > vers = = key2 - > vers & &
key1 - > proc = = key2 - > proc ) ?
TRUE : FALSE ) ;
}
/* calculate a hash key */
2002-04-01 23:56:41 +00:00
static guint
1999-10-29 01:11:23 +00:00
rpc_proc_hash ( gconstpointer k )
{
2002-12-02 23:43:30 +00:00
const rpc_proc_info_key * key = ( const rpc_proc_info_key * ) k ;
1999-10-29 01:11:23 +00:00
return ( key - > prog ^ ( key - > vers < < 16 ) ^ ( key - > proc < < 24 ) ) ;
}
/* insert some entries */
void
2002-10-23 21:17:03 +00:00
rpc_init_proc_table ( guint prog , guint vers , const vsff * proc_table ,
int procedure_hf )
1999-10-29 01:11:23 +00:00
{
2002-10-23 21:17:03 +00:00
rpc_prog_info_key rpc_prog_key ;
rpc_prog_info_value * rpc_prog ;
1999-10-29 01:11:23 +00:00
const vsff * proc ;
2002-10-23 21:17:03 +00:00
/*
* Add the operation number hfinfo value for this version of the
* program .
*/
rpc_prog_key . prog = prog ;
rpc_prog = g_hash_table_lookup ( rpc_progs , & rpc_prog_key ) ;
2005-06-10 18:28:22 +00:00
DISSECTOR_ASSERT ( rpc_prog ! = NULL ) ;
2002-10-23 21:17:03 +00:00
rpc_prog - > procedure_hfs = g_array_set_size ( rpc_prog - > procedure_hfs ,
vers ) ;
g_array_insert_val ( rpc_prog - > procedure_hfs , vers , procedure_hf ) ;
1999-10-29 01:11:23 +00:00
for ( proc = proc_table ; proc - > strptr ! = NULL ; proc + + ) {
rpc_proc_info_key * key ;
rpc_proc_info_value * value ;
key = ( rpc_proc_info_key * ) g_malloc ( sizeof ( rpc_proc_info_key ) ) ;
key - > prog = prog ;
key - > vers = vers ;
key - > proc = proc - > value ;
value = ( rpc_proc_info_value * ) g_malloc ( sizeof ( rpc_proc_info_value ) ) ;
value - > name = proc - > strptr ;
2001-05-30 06:01:02 +00:00
value - > dissect_call = proc - > dissect_call ;
value - > dissect_reply = proc - > dissect_reply ;
1999-10-29 01:11:23 +00:00
g_hash_table_insert ( rpc_procs , key , value ) ;
}
}
2003-09-05 10:26:44 +00:00
2001-02-09 06:49:29 +00:00
/* return the name associated with a previously registered procedure. */
2005-07-29 03:49:23 +00:00
const char *
rpc_proc_name ( guint32 prog , guint32 vers , guint32 proc )
2001-02-09 06:49:29 +00:00
{
rpc_proc_info_key key ;
rpc_proc_info_value * value ;
2005-08-20 00:27:46 +00:00
char * procname ;
2001-02-09 06:49:29 +00:00
2005-08-20 00:27:46 +00:00
procname = ep_alloc ( 20 ) ;
2001-02-09 06:49:29 +00:00
key . prog = prog ;
key . vers = vers ;
key . proc = proc ;
if ( ( value = g_hash_table_lookup ( rpc_procs , & key ) ) ! = NULL )
2005-08-20 00:27:46 +00:00
procname = ( char * ) value - > name ;
2001-02-09 06:49:29 +00:00
else {
/* happens only with strange program versions or
non - existing dissectors */
2005-08-20 00:27:46 +00:00
g_snprintf ( procname , 20 , " proc-%u " , key . proc ) ;
2001-02-09 06:49:29 +00:00
}
return procname ;
}
1999-10-29 01:11:23 +00:00
/*----------------------------------------*/
/* end of Hash array with procedure names */
/*----------------------------------------*/
/*********************************/
/* Hash array with program names */
/*********************************/
/* compare 2 keys */
2002-04-01 23:56:41 +00:00
static gint
1999-10-29 01:11:23 +00:00
rpc_prog_equal ( gconstpointer k1 , gconstpointer k2 )
{
2002-12-02 23:43:30 +00:00
const rpc_prog_info_key * key1 = ( const rpc_prog_info_key * ) k1 ;
const rpc_prog_info_key * key2 = ( const rpc_prog_info_key * ) k2 ;
1999-10-29 01:11:23 +00:00
return ( ( key1 - > prog = = key2 - > prog ) ?
TRUE : FALSE ) ;
}
/* calculate a hash key */
2002-04-01 23:56:41 +00:00
static guint
1999-10-29 01:11:23 +00:00
rpc_prog_hash ( gconstpointer k )
{
2002-12-02 23:43:30 +00:00
const rpc_prog_info_key * key = ( const rpc_prog_info_key * ) k ;
1999-10-29 01:11:23 +00:00
return ( key - > prog ) ;
}
void
rpc_init_prog ( int proto , guint32 prog , int ett )
{
rpc_prog_info_key * key ;
rpc_prog_info_value * value ;
key = ( rpc_prog_info_key * ) g_malloc ( sizeof ( rpc_prog_info_key ) ) ;
key - > prog = prog ;
value = ( rpc_prog_info_value * ) g_malloc ( sizeof ( rpc_prog_info_value ) ) ;
2003-11-16 23:17:27 +00:00
value - > proto = find_protocol_by_id ( proto ) ;
value - > proto_id = proto ;
1999-10-29 01:11:23 +00:00
value - > ett = ett ;
2003-11-16 23:17:27 +00:00
value - > progname = proto_get_protocol_short_name ( value - > proto ) ;
2002-10-23 21:17:03 +00:00
value - > procedure_hfs = g_array_new ( FALSE , TRUE , sizeof ( int ) ) ;
1999-10-29 01:11:23 +00:00
g_hash_table_insert ( rpc_progs , key , value ) ;
}
2003-09-05 10:26:44 +00:00
/* return the hf_field associated with a previously registered program.
*/
int rpc_prog_hf ( guint32 prog , guint32 vers )
{
rpc_prog_info_key rpc_prog_key ;
rpc_prog_info_value * rpc_prog ;
rpc_prog_key . prog = prog ;
if ( ( rpc_prog = g_hash_table_lookup ( rpc_progs , & rpc_prog_key ) ) ) {
return g_array_index ( rpc_prog - > procedure_hfs , int , vers ) ;
}
return - 1 ;
}
1999-11-11 21:22:00 +00:00
/* return the name associated with a previously registered program. This
should probably eventually be expanded to use the rpc YP / NIS map
2006-05-21 04:49:01 +00:00
so that it can give names for programs not handled by wireshark */
2005-07-24 19:01:28 +00:00
const char * rpc_prog_name ( guint32 prog )
1999-11-11 21:22:00 +00:00
{
2005-07-24 19:01:28 +00:00
const char * progname = NULL ;
1999-11-11 21:22:00 +00:00
rpc_prog_info_key rpc_prog_key ;
rpc_prog_info_value * rpc_prog ;
rpc_prog_key . prog = prog ;
if ( ( rpc_prog = g_hash_table_lookup ( rpc_progs , & rpc_prog_key ) ) = = NULL ) {
progname = " Unknown " ;
}
else {
progname = rpc_prog - > progname ;
}
return progname ;
}
1999-10-29 01:11:23 +00:00
/*--------------------------------------*/
/* end of Hash array with program names */
/*--------------------------------------*/
2006-08-21 12:41:59 +00:00
/* One of these structures are created for each conversation that contains
* RPC and contains the state we need to maintain for the conversation .
*/
typedef struct _rpc_conv_info_t {
emem_tree_t * xids ;
} rpc_conv_info_t ;
1999-10-29 01:11:23 +00:00
unsigned int
1999-11-15 14:17:20 +00:00
rpc_roundup ( unsigned int a )
1999-10-29 01:11:23 +00:00
{
unsigned int mod = a % 4 ;
2006-07-07 22:39:23 +00:00
unsigned int ret ;
ret = a + ( ( mod ) ? 4 - mod : 0 ) ;
/* Check for overflow */
2006-07-09 22:12:02 +00:00
if ( ret < a )
THROW ( ReportedBoundsError ) ;
return ret ;
1999-10-29 01:11:23 +00:00
}
1999-12-14 11:43:59 +00:00
int
2002-04-03 13:24:13 +00:00
dissect_rpc_bool ( tvbuff_t * tvb , proto_tree * tree ,
2000-08-08 06:19:52 +00:00
int hfindex , int offset )
{
if ( tree )
proto_tree_add_item ( tree , hfindex , tvb , offset , 4 , FALSE ) ;
return offset + 4 ;
}
1999-11-05 07:16:23 +00:00
int
2002-04-03 13:24:13 +00:00
dissect_rpc_uint32 ( tvbuff_t * tvb , proto_tree * tree ,
2000-08-08 06:19:52 +00:00
int hfindex , int offset )
{
if ( tree )
proto_tree_add_item ( tree , hfindex , tvb , offset , 4 , FALSE ) ;
return offset + 4 ;
}
1999-11-05 07:16:23 +00:00
int
2002-04-03 13:24:13 +00:00
dissect_rpc_uint64 ( tvbuff_t * tvb , proto_tree * tree ,
2000-08-08 06:19:52 +00:00
int hfindex , int offset )
{
2001-10-29 21:13:13 +00:00
header_field_info * hfinfo ;
hfinfo = proto_registrar_get_nth ( hfindex ) ;
2005-06-10 18:28:22 +00:00
DISSECTOR_ASSERT ( hfinfo - > type = = FT_UINT64 ) ;
2001-10-29 21:13:13 +00:00
if ( tree )
proto_tree_add_item ( tree , hfindex , tvb , offset , 8 , FALSE ) ;
2000-08-08 06:19:52 +00:00
return offset + 8 ;
}
2003-05-21 02:48:40 +00:00
/*
2005-10-17 18:56:27 +00:00
* We want to make this function available outside this file and
2003-05-21 02:48:40 +00:00
* allow callers to pass a dissection function for the opaque data
2005-10-17 18:56:27 +00:00
*/
2003-05-21 02:48:40 +00:00
int
2002-04-03 13:24:13 +00:00
dissect_rpc_opaque_data ( tvbuff_t * tvb , int offset ,
2003-05-21 02:48:40 +00:00
proto_tree * tree ,
packet_info * pinfo ,
int hfindex ,
2002-11-13 21:45:59 +00:00
gboolean fixed_length , guint32 length ,
2003-05-21 02:48:40 +00:00
gboolean string_data , char * * string_buffer_ret ,
dissect_function_t * dissect_it )
1999-11-11 16:20:25 +00:00
{
2004-02-25 09:31:07 +00:00
int data_offset ;
1999-11-19 13:09:56 +00:00
proto_item * string_item = NULL ;
1999-11-11 16:20:25 +00:00
proto_tree * string_tree = NULL ;
2002-01-20 01:13:41 +00:00
guint32 string_length ;
1999-12-02 10:20:42 +00:00
guint32 string_length_full ;
1999-11-19 13:09:56 +00:00
guint32 string_length_packet ;
2002-01-20 01:13:41 +00:00
guint32 string_length_captured ;
guint32 string_length_copy ;
int fill_truncated ;
guint32 fill_length ;
guint32 fill_length_packet ;
guint32 fill_length_captured ;
guint32 fill_length_copy ;
1999-12-02 10:20:42 +00:00
2002-01-20 01:13:41 +00:00
int exception = 0 ;
1999-12-02 10:20:42 +00:00
1999-11-19 13:09:56 +00:00
char * string_buffer = NULL ;
char * string_buffer_print = NULL ;
2002-11-13 21:45:59 +00:00
if ( fixed_length ) {
string_length = length ;
2004-02-25 09:31:07 +00:00
data_offset = offset ;
2002-11-13 21:45:59 +00:00
}
else {
2003-05-20 07:35:09 +00:00
string_length = tvb_get_ntohl ( tvb , offset + 0 ) ;
2004-02-25 09:31:07 +00:00
data_offset = offset + 4 ;
2002-11-13 21:45:59 +00:00
}
2004-02-25 09:31:07 +00:00
string_length_captured = tvb_length_remaining ( tvb , data_offset ) ;
string_length_packet = tvb_reported_length_remaining ( tvb , data_offset ) ;
2002-11-13 21:45:59 +00:00
string_length_full = rpc_roundup ( string_length ) ;
2002-01-20 01:13:41 +00:00
if ( string_length_captured < string_length ) {
2001-01-28 03:39:48 +00:00
/* truncated string */
2002-01-20 01:13:41 +00:00
string_length_copy = string_length_captured ;
2001-01-28 03:39:48 +00:00
fill_truncated = 2 ;
fill_length = 0 ;
fill_length_copy = 0 ;
2002-01-20 01:13:41 +00:00
if ( string_length_packet < string_length )
exception = ReportedBoundsError ;
else
exception = BoundsError ;
2001-01-28 03:39:48 +00:00
}
else {
/* full string data */
string_length_copy = string_length ;
fill_length = string_length_full - string_length ;
2004-02-25 09:31:07 +00:00
fill_length_captured = tvb_length_remaining ( tvb ,
data_offset + string_length ) ;
fill_length_packet = tvb_reported_length_remaining ( tvb ,
data_offset + string_length ) ;
2002-01-20 01:13:41 +00:00
if ( fill_length_captured < fill_length ) {
2001-01-28 03:39:48 +00:00
/* truncated fill bytes */
fill_length_copy = fill_length_packet ;
fill_truncated = 1 ;
2002-01-20 01:13:41 +00:00
if ( fill_length_packet < fill_length )
exception = ReportedBoundsError ;
else
exception = BoundsError ;
1999-11-19 13:09:56 +00:00
}
else {
2001-01-28 03:39:48 +00:00
/* full fill bytes */
fill_length_copy = fill_length ;
fill_truncated = 0 ;
1999-11-19 13:09:56 +00:00
}
2001-01-28 03:39:48 +00:00
}
2003-05-21 02:48:40 +00:00
/*
* If we were passed a dissection routine , make a TVB of the data
* and call the dissection routine
*/
if ( dissect_it ) {
tvbuff_t * opaque_tvb ;
2004-02-25 09:31:07 +00:00
opaque_tvb = tvb_new_subset ( tvb , data_offset , string_length_copy ,
string_length ) ;
2003-05-21 02:48:40 +00:00
return ( * dissect_it ) ( opaque_tvb , offset , pinfo , tree ) ;
}
2004-02-25 09:31:07 +00:00
if ( string_data ) {
2005-07-22 23:33:12 +00:00
char * tmpstr ;
2005-08-10 13:41:13 +00:00
tmpstr = tvb_get_ephemeral_string ( tvb , data_offset , string_length_copy ) ;
2005-08-13 22:08:22 +00:00
string_buffer = memcpy ( ep_alloc ( string_length_copy + 1 ) , tmpstr , string_length_copy ) ;
2004-02-25 09:31:07 +00:00
} else {
2005-08-13 22:08:22 +00:00
string_buffer = tvb_memcpy ( tvb , ep_alloc ( string_length_copy + 1 ) , data_offset , string_length_copy ) ;
2004-02-25 09:31:07 +00:00
}
2005-08-13 22:08:22 +00:00
string_buffer [ string_length_copy ] = ' \0 ' ;
2001-01-28 03:39:48 +00:00
/* calculate a nice printable string */
if ( string_length ) {
if ( string_length ! = string_length_copy ) {
if ( string_data ) {
2005-08-13 22:08:22 +00:00
char * formatted ;
formatted = format_text ( string_buffer , strlen ( string_buffer ) ) ;
2001-01-28 03:39:48 +00:00
/* alloc maximum data area */
2005-10-15 22:36:59 +00:00
# define STRING_BUFFER_PRINT_MAX_LEN (strlen(formatted)+12+1)
string_buffer_print = ( char * ) ep_alloc ( STRING_BUFFER_PRINT_MAX_LEN ) ;
/* copy over the data and append <TRUNCATED> */
g_snprintf ( string_buffer_print , STRING_BUFFER_PRINT_MAX_LEN , " %s<TRUNCATED> " , formatted ) ;
2005-07-22 23:33:12 +00:00
} else {
string_buffer_print = " <DATA><TRUNCATED> " ;
1999-11-19 13:09:56 +00:00
}
2005-07-22 23:33:12 +00:00
} else {
2001-01-28 03:39:48 +00:00
if ( string_data ) {
2005-08-13 22:08:22 +00:00
string_buffer_print =
ep_strdup ( format_text ( string_buffer , strlen ( string_buffer ) ) ) ;
2005-07-22 23:33:12 +00:00
} else {
string_buffer_print = " <DATA> " ;
2001-01-28 03:39:48 +00:00
}
1999-11-19 13:09:56 +00:00
}
2005-07-22 23:33:12 +00:00
} else {
string_buffer_print = " <EMPTY> " ;
1999-11-19 13:09:56 +00:00
}
1999-11-11 16:20:25 +00:00
if ( tree ) {
2002-02-01 07:07:46 +00:00
string_item = proto_tree_add_text ( tree , tvb , offset + 0 , - 1 ,
2003-05-20 07:56:46 +00:00
" %s: %s " , proto_registrar_get_name ( hfindex ) ,
string_buffer_print ) ;
string_tree = proto_item_add_subtree ( string_item ,
ett_rpc_string ) ;
1999-11-11 16:20:25 +00:00
}
2002-11-13 21:45:59 +00:00
if ( ! fixed_length ) {
2003-05-20 07:37:37 +00:00
if ( string_tree )
proto_tree_add_text ( string_tree , tvb , offset + 0 , 4 ,
" length: %u " , string_length ) ;
offset + = 4 ;
2002-11-13 21:45:59 +00:00
}
1999-12-02 10:20:42 +00:00
2002-01-20 01:13:41 +00:00
if ( string_tree ) {
if ( string_data ) {
proto_tree_add_string_format ( string_tree ,
hfindex , tvb , offset , string_length_copy ,
2003-05-20 07:56:46 +00:00
string_buffer ,
" contents: %s " , string_buffer_print ) ;
2002-01-20 01:13:41 +00:00
} else {
proto_tree_add_bytes_format ( string_tree ,
hfindex , tvb , offset , string_length_copy ,
2003-05-20 07:56:46 +00:00
string_buffer ,
" contents: %s " , string_buffer_print ) ;
2002-01-20 01:13:41 +00:00
}
}
2003-05-22 21:39:44 +00:00
2002-01-20 01:13:41 +00:00
offset + = string_length_copy ;
2003-05-22 21:39:44 +00:00
2002-01-20 01:13:41 +00:00
if ( fill_length ) {
2001-05-21 08:52:17 +00:00
if ( string_tree ) {
2002-01-20 01:13:41 +00:00
if ( fill_truncated ) {
proto_tree_add_text ( string_tree , tvb ,
offset , fill_length_copy ,
" fill bytes: opaque data<TRUNCATED> " ) ;
2001-05-21 08:52:17 +00:00
}
2002-01-20 01:13:41 +00:00
else {
proto_tree_add_text ( string_tree , tvb ,
offset , fill_length_copy ,
" fill bytes: opaque data " ) ;
1999-12-02 10:20:42 +00:00
}
1999-11-19 13:09:56 +00:00
}
2002-01-20 01:13:41 +00:00
offset + = fill_length_copy ;
1999-11-11 16:20:25 +00:00
}
2002-08-28 21:04:11 +00:00
2003-05-20 07:56:46 +00:00
if ( string_item )
2003-05-02 21:58:23 +00:00
proto_item_set_end ( string_item , tvb , offset ) ;
1999-11-19 13:09:56 +00:00
2005-07-22 23:33:12 +00:00
if ( string_buffer_ret ! = NULL )
* string_buffer_ret = string_buffer_print ;
2002-01-20 01:13:41 +00:00
/*
* If the data was truncated , throw the appropriate exception ,
* so that dissection stops and the frame is properly marked .
*/
if ( exception ! = 0 )
THROW ( exception ) ;
1999-11-11 16:20:25 +00:00
return offset ;
}
1999-11-05 07:16:23 +00:00
1999-12-02 10:20:42 +00:00
int
2002-04-03 13:24:13 +00:00
dissect_rpc_string ( tvbuff_t * tvb , proto_tree * tree ,
2001-01-28 03:39:48 +00:00
int hfindex , int offset , char * * string_buffer_ret )
2000-08-08 06:19:52 +00:00
{
2005-10-17 18:56:27 +00:00
offset = dissect_rpc_opaque_data ( tvb , offset , tree , NULL ,
2003-05-21 02:48:40 +00:00
hfindex , FALSE , 0 , TRUE , string_buffer_ret , NULL ) ;
2000-08-08 06:19:52 +00:00
return offset ;
}
1999-12-02 10:20:42 +00:00
int
2002-04-03 13:24:13 +00:00
dissect_rpc_data ( tvbuff_t * tvb , proto_tree * tree ,
2001-01-28 03:39:48 +00:00
int hfindex , int offset )
2000-08-08 06:19:52 +00:00
{
2005-10-17 18:56:27 +00:00
offset = dissect_rpc_opaque_data ( tvb , offset , tree , NULL ,
2003-05-21 02:48:40 +00:00
hfindex , FALSE , 0 , FALSE , NULL , NULL ) ;
2002-11-13 21:45:59 +00:00
return offset ;
}
2000-08-08 06:19:52 +00:00
2002-11-13 21:45:59 +00:00
int
dissect_rpc_bytes ( tvbuff_t * tvb , proto_tree * tree ,
int hfindex , int offset , guint32 length ,
gboolean string_data , char * * string_buffer_ret )
{
2003-05-21 02:48:40 +00:00
offset = dissect_rpc_opaque_data ( tvb , offset , tree , NULL ,
hfindex , TRUE , length , string_data , string_buffer_ret , NULL ) ;
2000-08-08 06:19:52 +00:00
return offset ;
}
2000-03-09 12:09:53 +00:00
int
2001-05-30 06:01:02 +00:00
dissect_rpc_list ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
2001-01-28 03:39:48 +00:00
int offset , dissect_function_t * rpc_list_dissector )
{
guint32 value_follows ;
while ( 1 ) {
value_follows = tvb_get_ntohl ( tvb , offset + 0 ) ;
proto_tree_add_boolean ( tree , hf_rpc_value_follows , tvb ,
offset + 0 , 4 , value_follows ) ;
offset + = 4 ;
if ( value_follows = = 1 ) {
offset = rpc_list_dissector ( tvb , offset , pinfo , tree ) ;
}
else {
break ;
}
}
return offset ;
}
2001-05-07 20:36:39 +00:00
int
2001-05-30 06:01:02 +00:00
dissect_rpc_array ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
2001-05-07 20:36:39 +00:00
int offset , dissect_function_t * rpc_array_dissector ,
int hfindex )
{
proto_item * lock_item ;
proto_tree * lock_tree ;
guint32 num ;
num = tvb_get_ntohl ( tvb , offset ) ;
if ( num = = 0 ) {
proto_tree_add_none_format ( tree , hfindex , tvb , offset , 4 ,
" no values " ) ;
offset + = 4 ;
return offset ;
}
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
lock_item = proto_tree_add_item ( tree , hfindex , tvb , offset , - 1 , FALSE ) ;
2001-05-07 20:36:39 +00:00
2002-08-28 21:04:11 +00:00
lock_tree = proto_item_add_subtree ( lock_item , ett_rpc_array ) ;
2001-05-07 20:36:39 +00:00
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_uint32 ( tvb , lock_tree ,
2001-05-07 20:36:39 +00:00
hf_rpc_array_len , offset ) ;
while ( num - - ) {
offset = rpc_array_dissector ( tvb , offset , pinfo , lock_tree ) ;
}
2003-05-02 21:58:23 +00:00
proto_item_set_end ( lock_item , tvb , offset ) ;
2001-05-07 20:36:39 +00:00
return offset ;
}
2000-07-17 20:34:00 +00:00
static int
2002-04-03 13:24:13 +00:00
dissect_rpc_authunix_cred ( tvbuff_t * tvb , proto_tree * tree , int offset )
1999-10-29 01:11:23 +00:00
{
2000-07-17 20:34:00 +00:00
guint stamp ;
guint uid ;
guint gid ;
guint gids_count ;
guint gids_i ;
guint gids_entry ;
proto_item * gitem ;
proto_tree * gtree = NULL ;
1999-10-29 01:11:23 +00:00
2000-11-21 14:58:07 +00:00
stamp = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( tree , hf_rpc_auth_stamp , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , stamp ) ;
offset + = 4 ;
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_string ( tvb , tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_auth_machinename , offset , NULL ) ;
2000-07-17 20:34:00 +00:00
2000-11-21 14:58:07 +00:00
uid = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( tree , hf_rpc_auth_uid , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , uid ) ;
offset + = 4 ;
1999-10-29 01:11:23 +00:00
2000-11-21 14:58:07 +00:00
gid = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( tree , hf_rpc_auth_gid , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , gid ) ;
offset + = 4 ;
2000-11-21 14:58:07 +00:00
gids_count = tvb_get_ntohl ( tvb , offset + 0 ) ;
1999-10-29 01:11:23 +00:00
if ( tree ) {
2000-11-21 14:58:07 +00:00
gitem = proto_tree_add_text ( tree , tvb ,
offset , 4 + gids_count * 4 , " Auxiliary GIDs " ) ;
2000-07-17 20:34:00 +00:00
gtree = proto_item_add_subtree ( gitem , ett_rpc_gids ) ;
1999-10-29 01:11:23 +00:00
}
2000-07-17 20:34:00 +00:00
offset + = 4 ;
2002-08-28 21:04:11 +00:00
2000-07-17 20:34:00 +00:00
for ( gids_i = 0 ; gids_i < gids_count ; gids_i + + ) {
2000-11-21 14:58:07 +00:00
gids_entry = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( gtree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( gtree , hf_rpc_auth_gid , tvb ,
2000-07-17 20:34:00 +00:00
offset , 4 , gids_entry ) ;
offset + = 4 ;
}
/* how can I NOW change the gitem to print a list with
the first 16 gids ? */
1999-10-29 01:11:23 +00:00
2000-07-17 20:34:00 +00:00
return offset ;
}
1999-10-29 01:11:23 +00:00
2000-07-17 20:34:00 +00:00
static int
2002-04-03 13:24:13 +00:00
dissect_rpc_authgss_cred ( tvbuff_t * tvb , proto_tree * tree , int offset )
2000-07-17 20:34:00 +00:00
{
guint agc_v ;
guint agc_proc ;
guint agc_seq ;
guint agc_svc ;
1999-10-29 01:11:23 +00:00
2000-11-21 14:58:07 +00:00
agc_v = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
proto_tree_add_uint ( tree , hf_rpc_authgss_v ,
2000-11-21 14:58:07 +00:00
tvb , offset + 0 , 4 , agc_v ) ;
2000-07-17 20:34:00 +00:00
offset + = 4 ;
2002-08-28 21:04:11 +00:00
2000-11-21 14:58:07 +00:00
agc_proc = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
proto_tree_add_uint ( tree , hf_rpc_authgss_proc ,
2000-11-21 14:58:07 +00:00
tvb , offset + 0 , 4 , agc_proc ) ;
2000-07-17 20:34:00 +00:00
offset + = 4 ;
2002-08-28 21:04:11 +00:00
2000-11-21 14:58:07 +00:00
agc_seq = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
proto_tree_add_uint ( tree , hf_rpc_authgss_seq ,
2000-11-21 14:58:07 +00:00
tvb , offset + 0 , 4 , agc_seq ) ;
2000-07-17 20:34:00 +00:00
offset + = 4 ;
2002-08-28 21:04:11 +00:00
2000-11-21 14:58:07 +00:00
agc_svc = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
proto_tree_add_uint ( tree , hf_rpc_authgss_svc ,
2000-11-21 14:58:07 +00:00
tvb , offset + 0 , 4 , agc_svc ) ;
2000-07-17 20:34:00 +00:00
offset + = 4 ;
2002-08-28 21:04:11 +00:00
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , hf_rpc_authgss_ctx ,
2000-11-21 14:58:07 +00:00
offset ) ;
2002-08-28 21:04:11 +00:00
2000-07-17 20:34:00 +00:00
return offset ;
}
1999-10-29 01:11:23 +00:00
2002-04-01 23:56:41 +00:00
static int
2002-04-03 13:24:13 +00:00
dissect_rpc_authdes_desblock ( tvbuff_t * tvb , proto_tree * tree ,
2001-05-25 20:13:04 +00:00
int hfindex , int offset )
{
guint32 value_low ;
guint32 value_high ;
value_high = tvb_get_ntohl ( tvb , offset + 0 ) ;
value_low = tvb_get_ntohl ( tvb , offset + 4 ) ;
if ( tree ) {
proto_tree_add_text ( tree , tvb , offset , 8 ,
2002-08-28 21:04:11 +00:00
" %s: 0x%x%08x " , proto_registrar_get_name ( hfindex ) , value_high ,
2001-05-25 20:13:04 +00:00
value_low ) ;
}
return offset + 8 ;
}
static int
2002-04-03 13:24:13 +00:00
dissect_rpc_authdes_cred ( tvbuff_t * tvb , proto_tree * tree , int offset )
2001-05-25 20:13:04 +00:00
{
guint adc_namekind ;
guint window = 0 ;
guint nickname = 0 ;
adc_namekind = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( tree )
proto_tree_add_uint ( tree , hf_rpc_authdes_namekind ,
tvb , offset + 0 , 4 , adc_namekind ) ;
offset + = 4 ;
switch ( adc_namekind )
{
case AUTHDES_NAMEKIND_FULLNAME :
2002-08-28 21:04:11 +00:00
offset = dissect_rpc_string ( tvb , tree ,
2001-05-25 20:13:04 +00:00
hf_rpc_authdes_netname , offset , NULL ) ;
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_authdes_desblock ( tvb , tree ,
2001-05-25 20:13:04 +00:00
hf_rpc_authdes_convkey , offset ) ;
window = tvb_get_ntohl ( tvb , offset + 0 ) ;
proto_tree_add_uint ( tree , hf_rpc_authdes_window , tvb , offset + 0 , 4 ,
window ) ;
offset + = 4 ;
break ;
case AUTHDES_NAMEKIND_NICKNAME :
nickname = tvb_get_ntohl ( tvb , offset + 0 ) ;
proto_tree_add_uint ( tree , hf_rpc_authdes_nickname , tvb , offset + 0 , 4 ,
2002-11-23 03:38:00 +00:00
nickname ) ;
2001-05-25 20:13:04 +00:00
offset + = 4 ;
break ;
}
return offset ;
}
2003-05-02 21:58:23 +00:00
static int
dissect_rpc_authgssapi_cred ( tvbuff_t * tvb , proto_tree * tree , int offset )
{
guint agc_v ;
guint agc_msg ;
agc_v = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( tree )
proto_tree_add_uint ( tree , hf_rpc_authgssapi_v ,
tvb , offset + 0 , 4 , agc_v ) ;
offset + = 4 ;
agc_msg = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( tree )
proto_tree_add_boolean ( tree , hf_rpc_authgssapi_msg ,
tvb , offset + 0 , 4 , agc_msg ) ;
offset + = 4 ;
offset = dissect_rpc_data ( tvb , tree , hf_rpc_authgssapi_handle ,
offset ) ;
return offset ;
}
2000-07-17 20:34:00 +00:00
static int
2002-04-03 13:24:13 +00:00
dissect_rpc_cred ( tvbuff_t * tvb , proto_tree * tree , int offset )
2000-07-17 20:34:00 +00:00
{
guint flavor ;
guint length ;
1999-10-29 01:11:23 +00:00
2000-07-17 20:34:00 +00:00
proto_item * citem ;
proto_tree * ctree ;
1999-10-29 01:11:23 +00:00
2000-11-21 14:58:07 +00:00
flavor = tvb_get_ntohl ( tvb , offset + 0 ) ;
length = tvb_get_ntohl ( tvb , offset + 4 ) ;
2000-07-17 20:34:00 +00:00
length = rpc_roundup ( length ) ;
if ( tree ) {
2000-11-21 14:58:07 +00:00
citem = proto_tree_add_text ( tree , tvb , offset ,
2000-07-17 20:34:00 +00:00
8 + length , " Credentials " ) ;
ctree = proto_item_add_subtree ( citem , ett_rpc_cred ) ;
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( ctree , hf_rpc_auth_flavor , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , flavor ) ;
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( ctree , hf_rpc_auth_length , tvb ,
2000-07-17 20:34:00 +00:00
offset + 4 , 4 , length ) ;
switch ( flavor ) {
case AUTH_UNIX :
2002-04-03 13:24:13 +00:00
dissect_rpc_authunix_cred ( tvb , ctree , offset + 8 ) ;
2000-07-17 20:34:00 +00:00
break ;
1999-10-29 01:11:23 +00:00
/*
case AUTH_SHORT :
break ;
*/
case AUTH_DES :
2002-04-03 13:24:13 +00:00
dissect_rpc_authdes_cred ( tvb , ctree , offset + 8 ) ;
2001-05-25 20:13:04 +00:00
break ;
2002-08-28 21:04:11 +00:00
2000-08-24 22:58:56 +00:00
case RPCSEC_GSS :
2002-04-03 13:24:13 +00:00
dissect_rpc_authgss_cred ( tvb , ctree , offset + 8 ) ;
2000-07-17 20:34:00 +00:00
break ;
2003-05-02 21:58:23 +00:00
case AUTH_GSSAPI :
dissect_rpc_authgssapi_cred ( tvb , ctree , offset + 8 ) ;
break ;
1999-10-29 01:11:23 +00:00
default :
2000-07-17 20:34:00 +00:00
if ( length )
2000-11-21 14:58:07 +00:00
proto_tree_add_text ( ctree , tvb , offset + 8 ,
2000-07-17 20:34:00 +00:00
length , " opaque data " ) ;
2000-11-21 14:58:07 +00:00
break ;
}
2000-07-17 20:34:00 +00:00
}
offset + = 8 + length ;
return offset ;
1999-10-29 01:11:23 +00:00
}
2003-05-21 02:48:40 +00:00
/*
* XDR opaque object , the contents of which are interpreted as a GSS - API
* token .
*/
static int
dissect_rpc_authgss_token ( tvbuff_t * tvb , proto_tree * tree , int offset ,
packet_info * pinfo )
{
guint32 opaque_length , rounded_length ;
gint len_consumed , length , reported_length ;
tvbuff_t * new_tvb ;
proto_item * gitem ;
proto_tree * gtree = NULL ;
opaque_length = tvb_get_ntohl ( tvb , offset + 0 ) ;
rounded_length = rpc_roundup ( opaque_length ) ;
if ( tree ) {
gitem = proto_tree_add_text ( tree , tvb , offset ,
4 + rounded_length , " GSS Token " ) ;
gtree = proto_item_add_subtree ( gitem , ett_rpc_gss_token ) ;
proto_tree_add_uint ( gtree , hf_rpc_authgss_token_length ,
tvb , offset + 0 , 4 , opaque_length ) ;
}
offset + = 4 ;
2006-08-25 08:10:35 +00:00
if ( opaque_length ! = 0 ) {
length = tvb_length_remaining ( tvb , offset ) ;
reported_length = tvb_reported_length_remaining ( tvb , offset ) ;
DISSECTOR_ASSERT ( length > = 0 ) ;
DISSECTOR_ASSERT ( reported_length > = 0 ) ;
if ( length > reported_length )
length = reported_length ;
if ( ( guint32 ) length > opaque_length )
length = opaque_length ;
if ( ( guint32 ) reported_length > opaque_length )
reported_length = opaque_length ;
new_tvb = tvb_new_subset ( tvb , offset , length , reported_length ) ;
len_consumed = call_dissector ( gssapi_handle , new_tvb , pinfo , gtree ) ;
offset + = len_consumed ;
}
2003-05-22 17:11:18 +00:00
offset = rpc_roundup ( offset ) ;
2003-05-21 02:48:40 +00:00
return offset ;
}
2001-05-25 20:13:04 +00:00
/* AUTH_DES verifiers are asymmetrical, so we need to know what type of
* verifier we ' re decoding ( CALL or REPLY ) .
*/
2000-07-17 20:34:00 +00:00
static int
2003-05-21 02:48:40 +00:00
dissect_rpc_verf ( tvbuff_t * tvb , proto_tree * tree , int offset , int msg_type ,
packet_info * pinfo )
1999-10-29 01:11:23 +00:00
{
2000-07-17 20:34:00 +00:00
guint flavor ;
1999-10-29 01:11:23 +00:00
guint length ;
2002-08-28 21:04:11 +00:00
2000-07-17 20:34:00 +00:00
proto_item * vitem ;
proto_tree * vtree ;
1999-10-29 01:11:23 +00:00
2000-11-21 14:58:07 +00:00
flavor = tvb_get_ntohl ( tvb , offset + 0 ) ;
length = tvb_get_ntohl ( tvb , offset + 4 ) ;
2000-07-17 20:34:00 +00:00
length = rpc_roundup ( length ) ;
1999-10-29 01:11:23 +00:00
if ( tree ) {
2000-11-21 14:58:07 +00:00
vitem = proto_tree_add_text ( tree , tvb , offset ,
2000-07-17 20:34:00 +00:00
8 + length , " Verifier " ) ;
vtree = proto_item_add_subtree ( vitem , ett_rpc_verf ) ;
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( vtree , hf_rpc_auth_flavor , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , flavor ) ;
switch ( flavor ) {
case AUTH_UNIX :
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( vtree , hf_rpc_auth_length , tvb ,
2000-07-17 20:34:00 +00:00
offset + 4 , 4 , length ) ;
2002-04-03 13:24:13 +00:00
dissect_rpc_authunix_cred ( tvb , vtree , offset + 8 ) ;
2000-07-17 20:34:00 +00:00
break ;
2001-05-25 20:13:04 +00:00
case AUTH_DES :
proto_tree_add_uint ( vtree , hf_rpc_auth_length , tvb ,
offset + 4 , 4 , length ) ;
if ( msg_type = = RPC_CALL )
{
guint window ;
2002-04-03 13:24:13 +00:00
dissect_rpc_authdes_desblock ( tvb , vtree ,
2001-05-25 20:13:04 +00:00
hf_rpc_authdes_timestamp , offset + 8 ) ;
window = tvb_get_ntohl ( tvb , offset + 16 ) ;
2002-08-28 21:04:11 +00:00
proto_tree_add_uint ( vtree , hf_rpc_authdes_windowverf , tvb ,
2001-05-25 20:13:04 +00:00
offset + 16 , 4 , window ) ;
}
else
{
/* must be an RPC_REPLY */
guint nickname ;
2002-04-03 13:24:13 +00:00
dissect_rpc_authdes_desblock ( tvb , vtree ,
2001-05-25 20:13:04 +00:00
hf_rpc_authdes_timeverf , offset + 8 ) ;
nickname = tvb_get_ntohl ( tvb , offset + 16 ) ;
2002-08-28 21:04:11 +00:00
proto_tree_add_uint ( vtree , hf_rpc_authdes_nickname , tvb ,
2001-05-25 20:13:04 +00:00
offset + 16 , 4 , nickname ) ;
}
break ;
2000-08-24 22:58:56 +00:00
case RPCSEC_GSS :
2003-05-21 02:48:40 +00:00
dissect_rpc_authgss_token ( tvb , vtree , offset + 4 , pinfo ) ;
2000-07-17 20:34:00 +00:00
break ;
default :
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( vtree , hf_rpc_auth_length , tvb ,
2000-07-17 20:34:00 +00:00
offset + 4 , 4 , length ) ;
if ( length )
2000-11-21 14:58:07 +00:00
proto_tree_add_text ( vtree , tvb , offset + 8 ,
2000-07-17 20:34:00 +00:00
length , " opaque data " ) ;
break ;
}
1999-10-29 01:11:23 +00:00
}
2000-07-17 20:34:00 +00:00
offset + = 8 + length ;
1999-10-29 01:11:23 +00:00
return offset ;
}
2002-08-21 21:10:10 +00:00
static int
2002-08-22 20:22:22 +00:00
dissect_rpc_authgss_initarg ( tvbuff_t * tvb , proto_tree * tree , int offset ,
packet_info * pinfo )
2002-08-21 21:10:10 +00:00
{
2002-08-22 20:22:22 +00:00
return dissect_rpc_authgss_token ( tvb , tree , offset , pinfo ) ;
2002-08-21 21:10:10 +00:00
}
2000-07-17 20:34:00 +00:00
static int
2002-08-22 20:22:22 +00:00
dissect_rpc_authgss_initres ( tvbuff_t * tvb , proto_tree * tree , int offset ,
packet_info * pinfo )
1999-10-29 01:11:23 +00:00
{
2000-07-17 20:34:00 +00:00
int major , minor , window ;
2002-08-28 21:04:11 +00:00
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , hf_rpc_authgss_ctx ,
2000-11-21 14:58:07 +00:00
offset ) ;
2002-08-28 21:04:11 +00:00
2000-11-21 14:58:07 +00:00
major = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( tree , hf_rpc_authgss_major , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , major ) ;
offset + = 4 ;
1999-10-29 01:11:23 +00:00
2000-11-21 14:58:07 +00:00
minor = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( tree , hf_rpc_authgss_minor , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , minor ) ;
offset + = 4 ;
2000-11-21 14:58:07 +00:00
window = tvb_get_ntohl ( tvb , offset + 0 ) ;
2000-07-17 20:34:00 +00:00
if ( tree )
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( tree , hf_rpc_authgss_window , tvb ,
2000-07-17 20:34:00 +00:00
offset + 0 , 4 , window ) ;
offset + = 4 ;
2002-08-22 20:22:22 +00:00
offset = dissect_rpc_authgss_token ( tvb , tree , offset , pinfo ) ;
2000-11-21 14:58:07 +00:00
return offset ;
}
2003-05-02 21:58:23 +00:00
static int
dissect_rpc_authgssapi_initarg ( tvbuff_t * tvb , proto_tree * tree , int offset ,
packet_info * pinfo )
{
guint version ;
proto_item * mitem ;
proto_tree * mtree = NULL ;
if ( tree ) {
mitem = proto_tree_add_text ( tree , tvb , offset , - 1 ,
" AUTH_GSSAPI Msg " ) ;
mtree = proto_item_add_subtree ( mitem , ett_rpc_authgssapi_msg ) ;
}
version = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( mtree ) {
proto_tree_add_uint ( mtree , hf_rpc_authgssapi_msgv , tvb ,
offset + 0 , 4 , version ) ;
}
offset + = 4 ;
offset = dissect_rpc_authgss_token ( tvb , mtree , offset , pinfo ) ;
return offset ;
}
static int
dissect_rpc_authgssapi_initres ( tvbuff_t * tvb , proto_tree * tree , int offset ,
packet_info * pinfo )
{
guint version ;
guint major , minor ;
proto_item * mitem ;
proto_tree * mtree = NULL ;
if ( tree ) {
mitem = proto_tree_add_text ( tree , tvb , offset , - 1 ,
" AUTH_GSSAPI Msg " ) ;
mtree = proto_item_add_subtree ( mitem , ett_rpc_authgssapi_msg ) ;
}
version = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( mtree ) {
proto_tree_add_uint ( mtree , hf_rpc_authgssapi_msgv , tvb ,
offset + 0 , 4 , version ) ;
}
offset + = 4 ;
offset = dissect_rpc_data ( tvb , mtree , hf_rpc_authgssapi_handle ,
offset ) ;
major = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( mtree ) {
proto_tree_add_uint ( mtree , hf_rpc_authgss_major , tvb ,
offset + 0 , 4 , major ) ;
}
offset + = 4 ;
minor = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( mtree ) {
proto_tree_add_uint ( mtree , hf_rpc_authgss_minor , tvb ,
offset + 0 , 4 , minor ) ;
}
offset + = 4 ;
offset = dissect_rpc_authgss_token ( tvb , mtree , offset , pinfo ) ;
offset = dissect_rpc_data ( tvb , mtree , hf_rpc_authgssapi_isn , offset ) ;
return offset ;
}
static int
dissect_auth_gssapi_data ( tvbuff_t * tvb , proto_tree * tree , int offset )
{
offset = dissect_rpc_data ( tvb , tree , hf_rpc_authgss_data ,
offset ) ;
return offset ;
}
2000-11-21 14:58:07 +00:00
2001-02-09 06:49:29 +00:00
static int
2001-01-18 06:33:23 +00:00
call_dissect_function ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
2001-05-30 06:01:02 +00:00
int offset , dissect_function_t * dissect_function , const char * progname )
2000-11-21 14:58:07 +00:00
{
2001-01-18 06:33:23 +00:00
const char * saved_proto ;
2001-05-30 06:01:02 +00:00
if ( dissect_function ! = NULL ) {
2001-01-18 06:33:23 +00:00
/* set the current protocol name */
saved_proto = pinfo - > current_proto ;
2001-02-06 06:46:10 +00:00
if ( progname ! = NULL )
pinfo - > current_proto = progname ;
2001-01-18 06:33:23 +00:00
2000-11-21 14:58:07 +00:00
/* call the dissector for the next level */
2001-05-30 06:01:02 +00:00
offset = dissect_function ( tvb , offset , pinfo , tree ) ;
2000-11-21 14:58:07 +00:00
2001-01-18 06:33:23 +00:00
/* restore the protocol name */
pinfo - > current_proto = saved_proto ;
2000-11-21 14:58:07 +00:00
}
2000-07-17 20:34:00 +00:00
return offset ;
}
2000-11-21 14:58:07 +00:00
2000-07-17 20:34:00 +00:00
static int
2000-11-21 14:58:07 +00:00
dissect_rpc_authgss_integ_data ( tvbuff_t * tvb , packet_info * pinfo ,
2001-01-28 03:39:48 +00:00
proto_tree * tree , int offset ,
dissect_function_t * dissect_function ,
2001-01-18 06:33:23 +00:00
const char * progname )
2000-07-17 20:34:00 +00:00
{
2002-08-22 20:22:22 +00:00
guint32 length , rounded_length , seq ;
2002-08-28 21:04:11 +00:00
2000-07-17 20:34:00 +00:00
proto_item * gitem ;
2001-01-18 06:33:23 +00:00
proto_tree * gtree = NULL ;
2000-07-17 20:34:00 +00:00
2000-11-21 14:58:07 +00:00
length = tvb_get_ntohl ( tvb , offset + 0 ) ;
2002-08-22 20:22:22 +00:00
rounded_length = rpc_roundup ( length ) ;
2000-11-21 14:58:07 +00:00
seq = tvb_get_ntohl ( tvb , offset + 4 ) ;
1999-10-29 01:11:23 +00:00
if ( tree ) {
2000-11-21 14:58:07 +00:00
gitem = proto_tree_add_text ( tree , tvb , offset ,
2002-08-22 20:22:22 +00:00
4 + rounded_length , " GSS Data " ) ;
2000-07-17 20:34:00 +00:00
gtree = proto_item_add_subtree ( gitem , ett_rpc_gss_data ) ;
proto_tree_add_uint ( gtree , hf_rpc_authgss_data_length ,
2000-11-21 14:58:07 +00:00
tvb , offset + 0 , 4 , length ) ;
2000-07-17 20:34:00 +00:00
proto_tree_add_uint ( gtree , hf_rpc_authgss_seq ,
2000-11-21 14:58:07 +00:00
tvb , offset + 4 , 4 , seq ) ;
2001-01-18 06:33:23 +00:00
}
2001-08-30 18:33:30 +00:00
offset + = 8 ;
2001-05-30 06:01:02 +00:00
if ( dissect_function ! = NULL ) {
2001-01-18 06:33:23 +00:00
/* offset = */
call_dissect_function ( tvb , pinfo , gtree , offset ,
2001-05-30 06:01:02 +00:00
dissect_function , progname ) ;
1999-10-29 01:11:23 +00:00
}
2002-08-22 20:22:22 +00:00
offset + = rounded_length - 4 ;
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , hf_rpc_authgss_checksum ,
2000-11-21 14:58:07 +00:00
offset ) ;
1999-10-29 01:11:23 +00:00
return offset ;
}
2000-11-21 14:58:07 +00:00
2000-07-17 20:34:00 +00:00
static int
2002-04-03 13:24:13 +00:00
dissect_rpc_authgss_priv_data ( tvbuff_t * tvb , proto_tree * tree , int offset )
2000-07-17 20:34:00 +00:00
{
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , hf_rpc_authgss_data ,
2000-11-21 14:58:07 +00:00
offset ) ;
2000-07-17 20:34:00 +00:00
return offset ;
}
1999-10-29 01:11:23 +00:00
2001-02-09 06:49:29 +00:00
/*
* Dissect the arguments to an indirect call ; used by the portmapper / RPCBIND
2006-08-21 12:41:59 +00:00
* dissector for the CALLIT procedure .
2001-02-09 07:59:00 +00:00
*
2006-08-21 12:41:59 +00:00
* Record these in the same table as the direct calls
* so we can find it when dissecting an indirect call reply .
* ( There should not be collissions between xid between direct and
* indirect calls . )
2001-02-09 06:49:29 +00:00
*/
int
dissect_rpc_indir_call ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
2001-02-09 07:59:00 +00:00
int offset , int args_id , guint32 prog , guint32 vers , guint32 proc )
2001-02-09 06:49:29 +00:00
{
2001-02-09 07:59:00 +00:00
conversation_t * conversation ;
static address null_address = { AT_NONE , 0 , NULL } ;
2001-02-09 06:49:29 +00:00
rpc_proc_info_key key ;
rpc_proc_info_value * value ;
2001-02-09 07:59:00 +00:00
rpc_call_info_value * rpc_call ;
2001-02-09 06:49:29 +00:00
dissect_function_t * dissect_function = NULL ;
2006-08-21 12:41:59 +00:00
rpc_conv_info_t * rpc_conv_info = NULL ;
guint32 xid ;
2001-02-09 06:49:29 +00:00
key . prog = prog ;
key . vers = vers ;
key . proc = proc ;
if ( ( value = g_hash_table_lookup ( rpc_procs , & key ) ) ! = NULL ) {
2001-05-30 06:01:02 +00:00
dissect_function = value - > dissect_call ;
2001-02-09 07:59:00 +00:00
2004-10-20 23:38:31 +00:00
/* Keep track of the address whence the call came, and the
port to which the call is being sent , so that we can
match up calls with replies .
2001-09-12 08:13:33 +00:00
If the transport is connection - oriented ( we check , for
2004-10-20 23:38:31 +00:00
now , only for " pinfo->ptype " of PT_TCP ) , we also take
into account the port from which the call was sent
2001-09-12 08:13:33 +00:00
and the address to which the call was sent , because
2004-10-20 23:38:31 +00:00
the addresses and ports of the two endpoints should be
the same for all calls and replies . ( XXX - what if
the connection is broken and re - established ? )
2001-09-12 08:13:33 +00:00
If the transport is connectionless , we don ' t worry
2001-02-09 07:59:00 +00:00
about the address to which the call was sent and from
which the reply was sent , because there ' s no
guarantee that the reply will come from the address
2004-10-20 23:38:31 +00:00
to which the call was sent . We also don ' t worry about
the port * from * which the call was sent and * to * which
the reply was sent , because some clients ( * cough * OS X
NFS client * cough ) might send retransmissions from a
different port from the original request . */
2001-09-12 08:13:33 +00:00
if ( pinfo - > ptype = = PT_TCP ) {
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src ,
2001-09-12 08:13:33 +00:00
& pinfo - > dst , pinfo - > ptype , pinfo - > srcport ,
pinfo - > destport , 0 ) ;
} else {
/*
2004-10-20 23:38:31 +00:00
* XXX - you currently still have to pass a non - null
2001-09-12 08:13:33 +00:00
* pointer for the second address argument even
2004-10-20 23:38:31 +00:00
* if you use NO_ADDR_B .
2001-09-12 08:13:33 +00:00
*/
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src ,
2004-10-20 23:38:31 +00:00
& null_address , pinfo - > ptype , pinfo - > destport ,
0 , NO_ADDR_B | NO_PORT_B ) ;
2001-09-12 08:13:33 +00:00
}
2001-02-09 07:59:00 +00:00
if ( conversation = = NULL ) {
/* It's not part of any conversation - create a new
one .
XXX - this should never happen , as we should ' ve
created a conversation for it in the RPC
dissector . */
2001-09-12 08:13:33 +00:00
if ( pinfo - > ptype = = PT_TCP ) {
2005-02-02 20:07:03 +00:00
conversation = conversation_new ( pinfo - > fd - > num , & pinfo - > src ,
2001-09-12 08:13:33 +00:00
& pinfo - > dst , pinfo - > ptype , pinfo - > srcport ,
pinfo - > destport , 0 ) ;
} else {
2005-02-02 20:07:03 +00:00
conversation = conversation_new ( pinfo - > fd - > num , & pinfo - > src ,
2004-10-20 23:38:31 +00:00
& null_address , pinfo - > ptype , pinfo - > destport ,
0 , NO_ADDR2 | NO_PORT2 ) ;
2001-09-12 08:13:33 +00:00
}
2001-02-09 07:59:00 +00:00
}
2006-08-21 12:41:59 +00:00
/*
* Do we already have a state structure for this conv
*/
rpc_conv_info = conversation_get_proto_data ( conversation , proto_rpc ) ;
if ( ! rpc_conv_info ) {
/* No. Attach that information to the conversation, and add
* it to the list of information structures .
*/
rpc_conv_info = se_alloc ( sizeof ( rpc_conv_info_t ) ) ;
rpc_conv_info - > xids = se_tree_create_non_persistent ( EMEM_TREE_TYPE_RED_BLACK , " rpc_xids " ) ;
conversation_add_proto_data ( conversation , proto_rpc , rpc_conv_info ) ;
}
2001-02-09 07:59:00 +00:00
2001-09-12 08:13:33 +00:00
/* Make the dissector for this conversation the non-heuristic
RPC dissector . */
2001-09-13 07:56:53 +00:00
conversation_set_dissector ( conversation ,
2001-11-27 07:13:32 +00:00
( pinfo - > ptype = = PT_TCP ) ? rpc_tcp_handle : rpc_handle ) ;
2001-09-12 08:13:33 +00:00
2006-08-21 12:41:59 +00:00
/* Dissectors for RPC procedure calls and replies shouldn't
2001-02-09 07:59:00 +00:00
create new tvbuffs , and we don ' t create one ourselves ,
so we should have been handed the tvbuff for this RPC call ;
as such , the XID is at offset 0 in this tvbuff . */
/* look up the request */
2006-08-21 12:41:59 +00:00
xid = tvb_get_ntohl ( tvb , offset + 0 ) ;
rpc_call = se_tree_lookup32 ( rpc_conv_info - > xids , xid ) ;
2001-02-09 07:59:00 +00:00
if ( rpc_call = = NULL ) {
/* We didn't find it; create a new entry.
Prepare the value data .
Not all of it is needed for handling indirect
calls , so we set a bunch of items to 0. */
2005-08-13 01:29:31 +00:00
rpc_call = se_alloc ( sizeof ( rpc_call_info_value ) ) ;
2001-02-09 07:59:00 +00:00
rpc_call - > req_num = 0 ;
rpc_call - > rep_num = 0 ;
rpc_call - > prog = prog ;
rpc_call - > vers = vers ;
rpc_call - > proc = proc ;
2002-05-09 12:10:06 +00:00
rpc_call - > private_data = NULL ;
2001-09-02 22:49:56 +00:00
/*
* XXX - what about RPCSEC_GSS ?
* Do we have to worry about it ?
*/
2001-09-02 23:57:33 +00:00
rpc_call - > flavor = FLAVOR_NOT_GSSAPI ;
2001-02-09 07:59:00 +00:00
rpc_call - > gss_proc = 0 ;
rpc_call - > gss_svc = 0 ;
rpc_call - > proc_info = value ;
/* store it */
2006-08-21 12:41:59 +00:00
se_tree_insert32 ( rpc_conv_info - > xids , xid , ( void * ) rpc_call ) ;
2001-02-09 07:59:00 +00:00
}
}
else {
/* We don't know the procedure.
Happens only with strange program versions or
non - existing dissectors .
Just show the arguments as opaque data . */
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , args_id ,
2001-02-09 07:59:00 +00:00
offset ) ;
return offset ;
}
if ( tree )
{
proto_tree_add_text ( tree , tvb , offset , 4 ,
" Argument length: %u " ,
tvb_get_ntohl ( tvb , offset ) ) ;
}
offset + = 4 ;
/* Dissect the arguments */
offset = call_dissect_function ( tvb , pinfo , tree , offset ,
2001-05-30 06:01:02 +00:00
dissect_function , NULL ) ;
2001-02-09 07:59:00 +00:00
return offset ;
}
/*
* Dissect the results in an indirect reply ; used by the portmapper / RPCBIND
* dissector .
*/
int
dissect_rpc_indir_reply ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
int offset , int result_id , int prog_id , int vers_id , int proc_id )
{
conversation_t * conversation ;
static address null_address = { AT_NONE , 0 , NULL } ;
rpc_call_info_value * rpc_call ;
2005-08-20 00:27:46 +00:00
char * procname = NULL ;
2001-02-09 07:59:00 +00:00
dissect_function_t * dissect_function = NULL ;
2006-08-21 12:41:59 +00:00
rpc_conv_info_t * rpc_conv_info = NULL ;
guint32 xid ;
2001-02-09 07:59:00 +00:00
2006-08-21 12:41:59 +00:00
/* Look for the matching call in the xid table.
A reply must match a call that we ' ve seen , and the
2004-10-20 23:38:31 +00:00
reply must be sent to the same address that the call came
from , and must come from the port to which the call was sent .
2001-09-12 08:13:33 +00:00
If the transport is connection - oriented ( we check , for
now , only for " pinfo->ptype " of PT_TCP ) , we take
2004-10-20 23:38:31 +00:00
into account the port from which the call was sent
2001-09-12 08:13:33 +00:00
and the address to which the call was sent , because
2004-10-20 23:38:31 +00:00
the addresses and ports of the two endpoints should be
the same for all calls and replies .
2001-09-12 08:13:33 +00:00
If the transport is connectionless , we don ' t worry
about the address to which the call was sent and from
which the reply was sent , because there ' s no
guarantee that the reply will come from the address
2004-10-20 23:38:31 +00:00
to which the call was sent . We also don ' t worry about
the port * from * which the call was sent and * to * which
the reply was sent , because some clients ( * cough * OS X
NFS client * cough ) might send retransmissions from a
different port from the original request . */
2001-09-12 08:13:33 +00:00
if ( pinfo - > ptype = = PT_TCP ) {
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src , & pinfo - > dst ,
2001-09-12 08:13:33 +00:00
pinfo - > ptype , pinfo - > srcport , pinfo - > destport , 0 ) ;
} else {
/*
2004-10-20 23:38:31 +00:00
* XXX - you currently still have to pass a non - null
2001-09-12 08:13:33 +00:00
* pointer for the second address argument even
2004-10-20 23:38:31 +00:00
* if you use NO_ADDR_B .
2001-09-12 08:13:33 +00:00
*/
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > dst , & null_address ,
2004-10-20 23:38:31 +00:00
pinfo - > ptype , pinfo - > srcport , 0 , NO_ADDR_B | NO_PORT_B ) ;
2001-09-12 08:13:33 +00:00
}
2001-02-09 07:59:00 +00:00
if ( conversation = = NULL ) {
/* We haven't seen an RPC call for that conversation,
so we can ' t check for a reply to that call .
Just show the reply stuff as opaque data . */
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , result_id ,
2001-02-09 07:59:00 +00:00
offset ) ;
return offset ;
}
2006-08-21 12:41:59 +00:00
/*
* Do we already have a state structure for this conv
*/
rpc_conv_info = conversation_get_proto_data ( conversation , proto_rpc ) ;
if ( ! rpc_conv_info ) {
/* No. Attach that information to the conversation, and add
* it to the list of information structures .
*/
rpc_conv_info = se_alloc ( sizeof ( rpc_conv_info_t ) ) ;
rpc_conv_info - > xids = se_tree_create_non_persistent ( EMEM_TREE_TYPE_RED_BLACK , " rpc_xids " ) ;
conversation_add_proto_data ( conversation , proto_rpc , rpc_conv_info ) ;
}
2001-02-09 07:59:00 +00:00
/* The XIDs of the call and reply must match. */
2006-08-21 12:41:59 +00:00
xid = tvb_get_ntohl ( tvb , 0 ) ;
rpc_call = se_tree_lookup32 ( rpc_conv_info - > xids , xid ) ;
2001-02-09 07:59:00 +00:00
if ( rpc_call = = NULL ) {
/* The XID doesn't match a call from that
conversation , so it ' s probably not an RPC reply .
Just show the reply stuff as opaque data . */
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , result_id ,
2001-02-09 07:59:00 +00:00
offset ) ;
return offset ;
}
if ( rpc_call - > proc_info ! = NULL ) {
2001-05-30 06:01:02 +00:00
dissect_function = rpc_call - > proc_info - > dissect_reply ;
2001-02-09 07:59:00 +00:00
if ( rpc_call - > proc_info - > name ! = NULL ) {
2005-08-20 00:27:46 +00:00
procname = ( char * ) rpc_call - > proc_info - > name ;
2001-02-09 07:59:00 +00:00
}
else {
2005-08-20 00:27:46 +00:00
procname = ep_alloc ( 20 ) ;
g_snprintf ( procname , 20 , " proc-%u " , rpc_call - > proc ) ;
2001-02-09 07:59:00 +00:00
}
2001-02-09 06:49:29 +00:00
}
else {
#if 0
dissect_function = NULL ;
# endif
2005-08-20 00:27:46 +00:00
procname = ep_alloc ( 20 ) ;
g_snprintf ( procname , 20 , " proc-%u " , rpc_call - > proc ) ;
2001-02-09 07:59:00 +00:00
}
if ( tree )
{
2006-02-28 10:10:08 +00:00
proto_item * tmp_item ;
2001-02-09 07:59:00 +00:00
/* Put the program, version, and procedure into the tree. */
2006-02-28 10:10:08 +00:00
tmp_item = proto_tree_add_uint_format ( tree , prog_id , tvb ,
2001-02-09 07:59:00 +00:00
0 , 0 , rpc_call - > prog , " Program: %s (%u) " ,
rpc_prog_name ( rpc_call - > prog ) , rpc_call - > prog ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
tmp_item = proto_tree_add_uint ( tree , vers_id , tvb , 0 , 0 , rpc_call - > vers ) ;
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
tmp_item = proto_tree_add_uint_format ( tree , proc_id , tvb ,
2001-02-09 07:59:00 +00:00
0 , 0 , rpc_call - > proc , " Procedure: %s (%u) " ,
procname , rpc_call - > proc ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2001-02-09 07:59:00 +00:00
}
2001-05-30 06:01:02 +00:00
if ( dissect_function = = NULL ) {
2001-02-09 07:59:00 +00:00
/* We don't know how to dissect the reply procedure.
Just show the reply stuff as opaque data . */
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_data ( tvb , tree , result_id ,
2001-02-09 07:59:00 +00:00
offset ) ;
return offset ;
2001-02-09 06:49:29 +00:00
}
2001-02-09 07:59:00 +00:00
if ( tree ) {
/* Put the length of the reply value into the tree. */
proto_tree_add_text ( tree , tvb , offset , 4 ,
" Argument length: %u " ,
tvb_get_ntohl ( tvb , offset ) ) ;
}
offset + = 4 ;
/* Dissect the return value */
2001-02-09 06:49:29 +00:00
offset = call_dissect_function ( tvb , pinfo , tree , offset ,
2001-05-30 06:01:02 +00:00
dissect_function , NULL ) ;
2001-02-09 06:49:29 +00:00
return offset ;
}
2000-11-21 14:58:07 +00:00
2001-09-12 08:13:33 +00:00
/*
* Just mark this as a continuation of an earlier packet .
*/
static void
dissect_rpc_continuation ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree )
{
proto_item * rpc_item ;
proto_tree * rpc_tree ;
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_PROTOCOL ) )
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " RPC " ) ;
if ( check_col ( pinfo - > cinfo , COL_INFO ) )
col_set_str ( pinfo - > cinfo , COL_INFO , " Continuation " ) ;
2001-09-12 08:13:33 +00:00
if ( tree ) {
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
rpc_item = proto_tree_add_item ( tree , proto_rpc , tvb , 0 , - 1 ,
FALSE ) ;
2001-09-12 08:13:33 +00:00
rpc_tree = proto_item_add_subtree ( rpc_item , ett_rpc ) ;
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
proto_tree_add_text ( rpc_tree , tvb , 0 , - 1 , " Continuation data " ) ;
2001-09-12 08:13:33 +00:00
}
}
2005-08-08 09:52:59 +00:00
/**
2005-10-17 18:56:27 +00:00
* Produce a dummy RPC program entry for the given RPC program key
2005-08-08 09:52:59 +00:00
* and version values .
*/
static void make_fake_rpc_prog_if_needed ( rpc_prog_info_key * prpc_prog_key ,
guint prog_ver )
{
rpc_prog_info_value * rpc_prog = NULL ;
2005-08-11 09:20:23 +00:00
/* sanity check: no one uses versions > 10 */
if ( prog_ver > 10 ) {
return ;
}
2005-08-08 09:52:59 +00:00
if ( ( rpc_prog = g_hash_table_lookup ( rpc_progs , prpc_prog_key ) ) = = NULL ) {
/* ok this is not a known rpc program so we
* will have to fake it .
*/
int proto_rpc_unknown_program ;
char * NAME , * Name , * name ;
static const vsff unknown_proc [ ] = {
{ 0 , " NULL " , NULL , NULL } ,
{ 0 , NULL , NULL , NULL }
} ;
NAME = g_malloc ( 36 ) ;
Name = g_malloc ( 32 ) ;
name = g_malloc ( 32 ) ;
2005-08-20 00:27:46 +00:00
g_snprintf ( NAME , 36 , " Unknown RPC Program:%d " , prpc_prog_key - > prog ) ;
g_snprintf ( Name , 32 , " RPC:%d " , prpc_prog_key - > prog ) ;
g_snprintf ( name , 32 , " rpc%d " , prpc_prog_key - > prog ) ;
2005-08-08 09:52:59 +00:00
proto_rpc_unknown_program = proto_register_protocol ( NAME , Name , name ) ;
rpc_init_prog ( proto_rpc_unknown_program , prpc_prog_key - > prog , ett_rpc_unknown_program ) ;
rpc_init_proc_table ( prpc_prog_key - > prog , prog_ver , unknown_proc , hf_rpc_procedure ) ;
}
}
Remove more "CHECK_DISPLAY_AS_DATA()" calls and "pinfo->current_proto ="
statements.
Move the setting of the Protocol column in various dissectors before
anything is fetched from the packet, and also clear the Info column at
that point in those and some other dissectors, so that if an exception
is thrown, the columns don't reflect the previous protocol.
Don't use
col_add_fstr(..., "%s", string);
Use
col_add_str(..., string);
as it does the same thing, but doesn't drag all the heavy *printf
machinery in.
Fix the DDTP dissector to set the Info column regardless of whether
we're building a protocol tree or not, and to set it to "Encrypted
payload" if the payload is encrypted. Also fix a typo in a field name.
Register the FTP data dissector as being associated with the FTP data
protocol, not the FTP protocol (the removed "CHECK_DISPLAY_AS_DATA()"
call checked "proto_ftp_data", and the removed "pinfo->current_proto ="
line set it to "FTP-DATA", so it should be associated with
"proto_ftp_data").
Make the H1 dissector check whether the frame has at least 2 bytes in it
before checking the first two bytes; heuristic dissectors must not throw
exceptions until they've accepted the packet as one of theirs.
Use "tvb_format_text()" rather than "tvb_get_ptr()" and "format_text()"
in some dissectors where the result of "tvb_get_ptr()" is used only in
the "format_text()" call.
In the Quake dissector, don't check whether there are at least 4 bytes
in the packet - if we return, the packet won't be dissected at all (it's
not as if some other dissector will get to handle it), and, if we don't
return, we'll throw an exception if there aren't at least 4 bytes in the
packet, so the packet will be marked as short or malformed, as
appropriate.
In the RIPng dissector, associate the table of strings for the command
field with the command field, so that the dissector doesn't have to
format the string for the protocol tree entry itself, and so that the
filter construction dialog box can let you select "Request" or
"Response" from a list rather than requiring you to know the values for
"Request" and "Response".
Make "dissect_rpc()" static, as it's called only through a heuristic
dissector list.
Use "col_set_str()" to set the COL_PROTOCOL column for RPC protocols;
the string used is from a table provided by the dissector, and is a
string constant.
Don't format the Info column for WSP into a buffer and then format that
buffer into the column with "%s" - "col_add_fstr()" can do the
formatting for you, without having to allocate your own buffer (or run
through the *printf machinery twice).
Don't fetch fields from the WTP packet until you're ready to use them,
so that you don't throw an exception before you even set the Protocol
column or clear the Info column.
Use "pinfo->destport", not "pi.destport", in the Zebra dissector when
checking whether the packet is a request or reply, and do the check by
comparing with "pinfo->match_port" rather than TCP_PORT_ZEBRA (so that
if the dissector is ever registered on another port, it still correctly
determines whether the packet is a request or reply - the Network
Monitor HTTP dissector has port 80 wired into its brain, which is a bit
irritating if you're trying to get it to dissect HTTP proxy traffic on
port 3128 or proxy administration UI traffic on port 3132).
svn path=/trunk/; revision=2931
2001-01-22 08:03:46 +00:00
static gboolean
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
dissect_rpc_message ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
tvbuff_t * frag_tvb , fragment_data * ipfd_head , gboolean is_tcp ,
2003-04-21 08:13:18 +00:00
guint32 rpc_rm , gboolean first_pdu )
1999-10-29 01:11:23 +00:00
{
1999-11-14 20:44:52 +00:00
guint32 msg_type ;
2001-01-18 00:13:18 +00:00
rpc_call_info_value * rpc_call = NULL ;
1999-11-14 20:44:52 +00:00
rpc_prog_info_value * rpc_prog = NULL ;
rpc_prog_info_key rpc_prog_key ;
1999-10-29 01:11:23 +00:00
unsigned int xid ;
unsigned int rpcvers ;
1999-11-15 17:16:51 +00:00
unsigned int prog = 0 ;
1999-10-29 01:11:23 +00:00
unsigned int vers = 0 ;
unsigned int proc = 0 ;
2001-09-02 23:57:33 +00:00
flavor_t flavor = FLAVOR_UNKNOWN ;
2000-07-17 20:34:00 +00:00
unsigned int gss_proc = 0 ;
unsigned int gss_svc = 0 ;
2003-11-16 23:17:27 +00:00
protocol_t * proto = NULL ;
int proto_id = 0 ;
1999-10-29 01:11:23 +00:00
int ett = 0 ;
2002-10-23 21:17:03 +00:00
int procedure_hf ;
1999-10-29 01:11:23 +00:00
unsigned int reply_state ;
unsigned int accept_state ;
unsigned int reject_state ;
2005-06-26 19:56:52 +00:00
const char * msg_type_name = NULL ;
2005-07-24 19:01:28 +00:00
const char * progname = NULL ;
2005-08-20 00:27:46 +00:00
char * procname = NULL ;
1999-10-29 01:11:23 +00:00
unsigned int vers_low ;
unsigned int vers_high ;
unsigned int auth_state ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
proto_item * rpc_item = NULL ;
1999-10-29 01:11:23 +00:00
proto_tree * rpc_tree = NULL ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
proto_item * pitem = NULL ;
1999-10-29 01:11:23 +00:00
proto_tree * ptree = NULL ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
int offset = ( is_tcp & & tvb = = frag_tvb ) ? 4 : 0 ;
1999-10-29 01:11:23 +00:00
rpc_proc_info_key key ;
rpc_proc_info_value * value = NULL ;
conversation_t * conversation ;
For ONC RPC, when constructing conversations, use a null address as the
destination address for calls and the source address of the reply - we
should't require the server address to be the same for a call and reply,
as they may not be on a multi-homed server (clients presumably check the
XID only, or perhaps the XID and the port whence the reply came,
although with TI-RPC I don't think they can check the port without
checking the address as well).
This requires that the conversation code not assume that the source and
destination addresses for a given packet in a conversation have the same
type, so, when comparing addresses for equality, it must explicitly
check the address types.
In said code, also check the port numbers before we check the addresses
- testing ports is cheaper, as they're just integers, and there's
probably a decent chance that you won't see two conversations between
different pairs of hosts and the *same* pair of ports in a capture file,
so the cheaper port tests are probably decently likely to fail first.
svn path=/trunk/; revision=1031
1999-11-14 21:16:58 +00:00
static address null_address = { AT_NONE , 0 , NULL } ;
2001-12-28 20:18:45 +00:00
nstime_t ns ;
1999-10-29 01:11:23 +00:00
dissect_function_t * dissect_function = NULL ;
2002-05-15 23:01:51 +00:00
gboolean dissect_rpc = TRUE ;
1999-10-29 01:11:23 +00:00
2006-08-21 12:41:59 +00:00
rpc_conv_info_t * rpc_conv_info = NULL ;
2004-04-03 00:29:08 +00:00
1999-11-14 20:44:52 +00:00
/*
* Check to see whether this looks like an RPC call or reply .
*/
2000-11-21 14:58:07 +00:00
if ( ! tvb_bytes_exist ( tvb , offset , 8 ) ) {
1999-11-14 20:44:52 +00:00
/* Captured data in packet isn't enough to let us tell. */
return FALSE ;
}
/* both directions need at least this */
2000-11-21 14:58:07 +00:00
msg_type = tvb_get_ntohl ( tvb , offset + 4 ) ;
1999-11-14 20:44:52 +00:00
switch ( msg_type ) {
case RPC_CALL :
/* check for RPC call */
2000-11-21 14:58:07 +00:00
if ( ! tvb_bytes_exist ( tvb , offset , 16 ) ) {
1999-11-14 20:44:52 +00:00
/* Captured data in packet isn't enough to let us
tell . */
return FALSE ;
}
2004-04-03 00:29:08 +00:00
/* XID can be anything, so dont check it.
1999-11-14 20:44:52 +00:00
We already have the message type .
Check whether an RPC version number of 2 is in the
location where it would be , and that an RPC program
2003-07-17 23:08:52 +00:00
number we know about is in the location where it would be .
XXX - Sun ' s snoop appears to recognize as RPC even calls
to stuff it doesn ' t dissect ; does it just look for a 2
at that location , which seems far to weak a heuristic
( too many false positives ) , or does it have some additional
checks it does ?
We could conceivably check for any of the program numbers
in the list at
ftp : //ftp.tau.ac.il/pub/users/eilon/rpc/rpc
and report it as RPC ( but not dissect the payload if
we don ' t have a subdissector ) if it matches . */
2000-11-21 14:58:07 +00:00
rpc_prog_key . prog = tvb_get_ntohl ( tvb , offset + 12 ) ;
2004-04-03 00:29:08 +00:00
/* we only dissect version 2 */
if ( tvb_get_ntohl ( tvb , offset + 8 ) ! = 2 ) {
return FALSE ;
}
/* let the user be able to weaken the heuristics if he need
* to look at proprietary protocols not known
2006-05-21 04:49:01 +00:00
* to wireshark .
2004-04-03 00:29:08 +00:00
*/
if ( rpc_dissect_unknown_programs ) {
2005-08-11 09:20:23 +00:00
guint32 version ;
2005-10-17 18:56:27 +00:00
/* if the user has specified that he wants to try to
2004-04-03 00:29:08 +00:00
* dissect even completely unknown RPC program numbers
* then let him do that .
2005-10-17 18:56:27 +00:00
* In this case we only check that the program number
2004-04-03 00:29:08 +00:00
* is neither 0 nor - 1 which is better than nothing .
*/
if ( rpc_prog_key . prog = = 0 | | rpc_prog_key . prog = = 0xffffffff ) {
return FALSE ;
}
2005-08-11 09:20:23 +00:00
version = tvb_get_ntohl ( tvb , offset + 16 ) ;
make_fake_rpc_prog_if_needed ( & rpc_prog_key , version ) ;
2004-04-03 00:29:08 +00:00
}
if ( ( rpc_prog = g_hash_table_lookup ( rpc_progs , & rpc_prog_key ) ) = = NULL ) {
1999-11-14 20:44:52 +00:00
/* They're not, so it's probably not an RPC call. */
return FALSE ;
}
break ;
case RPC_REPLY :
For ONC RPC, when constructing conversations, use a null address as the
destination address for calls and the source address of the reply - we
should't require the server address to be the same for a call and reply,
as they may not be on a multi-homed server (clients presumably check the
XID only, or perhaps the XID and the port whence the reply came,
although with TI-RPC I don't think they can check the port without
checking the address as well).
This requires that the conversation code not assume that the source and
destination addresses for a given packet in a conversation have the same
type, so, when comparing addresses for equality, it must explicitly
check the address types.
In said code, also check the port numbers before we check the addresses
- testing ports is cheaper, as they're just integers, and there's
probably a decent chance that you won't see two conversations between
different pairs of hosts and the *same* pair of ports in a capture file,
so the cheaper port tests are probably decently likely to fail first.
svn path=/trunk/; revision=1031
1999-11-14 21:16:58 +00:00
/* Check for RPC reply. A reply must match a call that
we ' ve seen , and the reply must be sent to the same
2004-10-20 23:38:31 +00:00
address that the call came from , and must come from
the port to which the call was sent .
2001-09-12 08:13:33 +00:00
If the transport is connection - oriented ( we check , for
now , only for " pinfo->ptype " of PT_TCP ) , we take
2004-10-20 23:38:31 +00:00
into account the port from which the call was sent
2001-09-12 08:13:33 +00:00
and the address to which the call was sent , because
2004-10-20 23:38:31 +00:00
the addresses and ports of the two endpoints should be
the same for all calls and replies .
2001-09-12 08:13:33 +00:00
If the transport is connectionless , we don ' t worry
about the address to which the call was sent and from
which the reply was sent , because there ' s no
guarantee that the reply will come from the address
2004-10-20 23:38:31 +00:00
to which the call was sent . We also don ' t worry about
the port * from * which the call was sent and * to * which
the reply was sent , because some clients ( * cough * OS X
NFS client * cough ) might send retransmissions from a
different port from the original request . */
2001-09-12 08:13:33 +00:00
if ( pinfo - > ptype = = PT_TCP ) {
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src ,
2001-09-12 08:13:33 +00:00
& pinfo - > dst , pinfo - > ptype , pinfo - > srcport ,
pinfo - > destport , 0 ) ;
} else {
/*
2004-10-20 23:38:31 +00:00
* XXX - you currently still have to pass a non - null
2001-09-12 08:13:33 +00:00
* pointer for the second address argument even
2004-10-20 23:38:31 +00:00
* if you use NO_ADDR_B .
2001-09-12 08:13:33 +00:00
*/
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > dst ,
2004-10-20 23:38:31 +00:00
& null_address , pinfo - > ptype , pinfo - > srcport ,
0 , NO_ADDR_B | NO_PORT_B ) ;
2001-09-12 08:13:33 +00:00
}
1999-11-14 20:44:52 +00:00
if ( conversation = = NULL ) {
/* We haven't seen an RPC call for that conversation,
so we can ' t check for a reply to that call . */
return FALSE ;
}
2006-08-21 12:41:59 +00:00
/*
* Do we already have a state structure for this conv
*/
rpc_conv_info = conversation_get_proto_data ( conversation , proto_rpc ) ;
if ( ! rpc_conv_info ) {
/* No. Attach that information to the conversation, and add
* it to the list of information structures .
*/
rpc_conv_info = se_alloc ( sizeof ( rpc_conv_info_t ) ) ;
rpc_conv_info - > xids = se_tree_create_non_persistent ( EMEM_TREE_TYPE_RED_BLACK , " rpc_xids " ) ;
conversation_add_proto_data ( conversation , proto_rpc , rpc_conv_info ) ;
}
For ONC RPC, when constructing conversations, use a null address as the
destination address for calls and the source address of the reply - we
should't require the server address to be the same for a call and reply,
as they may not be on a multi-homed server (clients presumably check the
XID only, or perhaps the XID and the port whence the reply came,
although with TI-RPC I don't think they can check the port without
checking the address as well).
This requires that the conversation code not assume that the source and
destination addresses for a given packet in a conversation have the same
type, so, when comparing addresses for equality, it must explicitly
check the address types.
In said code, also check the port numbers before we check the addresses
- testing ports is cheaper, as they're just integers, and there's
probably a decent chance that you won't see two conversations between
different pairs of hosts and the *same* pair of ports in a capture file,
so the cheaper port tests are probably decently likely to fail first.
svn path=/trunk/; revision=1031
1999-11-14 21:16:58 +00:00
/* The XIDs of the call and reply must match. */
2006-08-21 12:41:59 +00:00
xid = tvb_get_ntohl ( tvb , offset + 0 ) ;
rpc_call = se_tree_lookup32 ( rpc_conv_info - > xids , xid ) ;
2001-01-18 00:13:18 +00:00
if ( rpc_call = = NULL ) {
1999-11-14 20:44:52 +00:00
/* The XID doesn't match a call from that
conversation , so it ' s probably not an RPC reply . */
2005-08-08 09:52:59 +00:00
/* unless we're permitted to scan for embedded records
* and this is a connection - oriented transport , give up */
if ( ( ! rpc_find_fragment_start ) | | ( pinfo - > ptype ! = PT_TCP ) ) {
1999-11-14 20:44:52 +00:00
return FALSE ;
}
2005-08-08 09:52:59 +00:00
/* in parse-partials, so define a dummy conversation for this reply */
2005-08-13 01:29:31 +00:00
rpc_call = se_alloc ( sizeof ( rpc_call_info_value ) ) ;
2005-08-08 09:52:59 +00:00
rpc_call - > req_num = 0 ;
rpc_call - > rep_num = pinfo - > fd - > num ;
rpc_call - > prog = 0 ;
rpc_call - > vers = 0 ;
rpc_call - > proc = 0 ;
rpc_call - > private_data = NULL ;
2006-08-21 12:41:59 +00:00
rpc_call - > xid = xid ;
2005-08-08 09:52:59 +00:00
rpc_call - > flavor = FLAVOR_NOT_GSSAPI ; /* total punt */
rpc_call - > gss_proc = 0 ;
rpc_call - > gss_svc = 0 ;
rpc_call - > proc_info = value ;
2005-08-24 21:31:56 +00:00
rpc_call - > req_time = pinfo - > fd - > abs_ts ;
2005-08-08 09:52:59 +00:00
/* store it */
2006-08-21 12:41:59 +00:00
se_tree_insert32 ( rpc_conv_info - > xids , xid , ( void * ) rpc_call ) ;
2005-08-08 09:52:59 +00:00
/* and fake up a matching program */
rpc_prog_key . prog = rpc_call - > prog ;
}
2002-01-12 10:24:47 +00:00
/* pass rpc_info to subdissectors */
rpc_call - > request = FALSE ;
pinfo - > private_data = rpc_call ;
1999-11-14 20:44:52 +00:00
break ;
default :
/* The putative message type field contains neither
RPC_CALL nor RPC_REPLY , so it ' s not an RPC call or
reply . */
return FALSE ;
}
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
if ( is_tcp ) {
/*
* This is RPC - over - TCP ; check if this is the last
* fragment .
*/
if ( ! ( rpc_rm & RPC_RM_LASTFRAG ) ) {
/*
* This isn ' t the last fragment .
* If we ' re doing reassembly , just return
* TRUE to indicate that this looks like
* the beginning of an RPC message ,
* and let them do fragment reassembly .
*/
if ( rpc_defragment )
return TRUE ;
}
}
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_PROTOCOL ) )
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " RPC " ) ;
1999-10-29 01:11:23 +00:00
if ( tree ) {
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
rpc_item = proto_tree_add_item ( tree , proto_rpc , tvb , 0 , - 1 ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
FALSE ) ;
rpc_tree = proto_item_add_subtree ( rpc_item , ett_rpc ) ;
1999-10-29 01:11:23 +00:00
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
if ( is_tcp ) {
show_rpc_fraginfo ( tvb , frag_tvb , rpc_tree , rpc_rm ,
2002-06-05 11:32:14 +00:00
ipfd_head , pinfo ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
}
1999-11-19 13:09:56 +00:00
}
2000-11-21 14:58:07 +00:00
xid = tvb_get_ntohl ( tvb , offset + 0 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-11-21 14:58:07 +00:00
proto_tree_add_uint_format ( rpc_tree , hf_rpc_xid , tvb ,
1999-11-15 17:16:51 +00:00
offset + 0 , 4 , xid , " XID: 0x%x (%u) " , xid , xid ) ;
1999-10-29 01:11:23 +00:00
}
1999-11-05 07:16:23 +00:00
msg_type_name = val_to_str ( msg_type , rpc_msg_type , " %u " ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( rpc_tree , hf_rpc_msgtype , tvb ,
1999-11-15 17:16:51 +00:00
offset + 4 , 4 , msg_type ) ;
2003-09-03 07:11:13 +00:00
proto_item_append_text ( rpc_item , " , Type:%s XID:0x%08x " , msg_type_name , xid ) ;
1999-10-29 01:11:23 +00:00
}
offset + = 8 ;
2001-01-18 00:13:18 +00:00
switch ( msg_type ) {
case RPC_CALL :
1999-11-14 20:44:52 +00:00
/* we know already the proto-entry, the ETT-const,
and " rpc_prog " */
1999-10-29 01:11:23 +00:00
proto = rpc_prog - > proto ;
2003-11-16 23:17:27 +00:00
proto_id = rpc_prog - > proto_id ;
1999-10-29 01:11:23 +00:00
ett = rpc_prog - > ett ;
progname = rpc_prog - > progname ;
2000-11-21 14:58:07 +00:00
rpcvers = tvb_get_ntohl ( tvb , offset + 0 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-05-31 05:09:07 +00:00
proto_tree_add_uint ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_version , tvb , offset + 0 , 4 , rpcvers ) ;
1999-10-29 01:11:23 +00:00
}
2000-11-21 14:58:07 +00:00
prog = tvb_get_ntohl ( tvb , offset + 4 ) ;
2002-08-28 21:04:11 +00:00
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-03-12 04:48:32 +00:00
proto_tree_add_uint_format ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_program , tvb , offset + 4 , 4 , prog ,
1999-11-05 07:16:23 +00:00
" Program: %s (%u) " , progname , prog ) ;
1999-10-29 01:11:23 +00:00
}
2002-08-28 21:04:11 +00:00
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_PROTOCOL ) ) {
1999-10-29 02:25:54 +00:00
/* Set the protocol name to the underlying
program name . */
2001-12-10 00:26:21 +00:00
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , progname ) ;
1999-10-29 01:11:23 +00:00
}
2000-11-21 14:58:07 +00:00
vers = tvb_get_ntohl ( tvb , offset + 8 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-05-31 05:09:07 +00:00
proto_tree_add_uint ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_programversion , tvb , offset + 8 , 4 , vers ) ;
1999-10-29 01:11:23 +00:00
}
2000-11-21 14:58:07 +00:00
proc = tvb_get_ntohl ( tvb , offset + 12 ) ;
1999-10-29 01:11:23 +00:00
key . prog = prog ;
key . vers = vers ;
key . proc = proc ;
2000-07-17 20:34:00 +00:00
if ( ( value = g_hash_table_lookup ( rpc_procs , & key ) ) ! = NULL ) {
2001-05-30 06:01:02 +00:00
dissect_function = value - > dissect_call ;
2005-08-20 00:27:46 +00:00
procname = ( char * ) value - > name ;
1999-10-29 01:11:23 +00:00
}
else {
/* happens only with strange program versions or
non - existing dissectors */
2001-01-28 03:39:48 +00:00
#if 0
1999-10-29 01:11:23 +00:00
dissect_function = NULL ;
2001-01-28 03:39:48 +00:00
# endif
2005-08-20 00:27:46 +00:00
procname = ep_alloc ( 20 ) ;
g_snprintf ( procname , 20 , " proc-%u " , proc ) ;
1999-10-29 01:11:23 +00:00
}
2002-08-28 21:04:11 +00:00
2003-05-02 21:58:23 +00:00
/* Check for RPCSEC_GSS and AUTH_GSSAPI */
2001-09-02 22:49:56 +00:00
if ( tvb_bytes_exist ( tvb , offset + 16 , 4 ) ) {
2001-09-02 23:57:33 +00:00
switch ( tvb_get_ntohl ( tvb , offset + 16 ) ) {
case RPCSEC_GSS :
/*
* It ' s GSS - API authentication . . .
*/
if ( tvb_bytes_exist ( tvb , offset + 28 , 8 ) ) {
/*
* . . . and we have the procedure
* and service information for it .
*/
flavor = FLAVOR_GSSAPI ;
gss_proc = tvb_get_ntohl ( tvb , offset + 28 ) ;
gss_svc = tvb_get_ntohl ( tvb , offset + 36 ) ;
} else {
/*
* . . . but the procedure and service
* information isn ' t available .
*/
flavor = FLAVOR_GSSAPI_NO_INFO ;
}
break ;
2003-05-02 21:58:23 +00:00
case AUTH_GSSAPI :
/*
* AUTH_GSSAPI flavor . If auth_msg is TRUE ,
* then this is an AUTH_GSSAPI message and
* not an application level message .
*/
if ( tvb_bytes_exist ( tvb , offset + 28 , 4 ) ) {
if ( tvb_get_ntohl ( tvb , offset + 28 ) ) {
flavor = FLAVOR_AUTHGSSAPI_MSG ;
gss_proc = proc ;
2005-08-20 00:27:46 +00:00
procname = ( char * )
2003-05-02 21:58:23 +00:00
match_strval ( gss_proc ,
rpc_authgssapi_proc ) ;
} else {
flavor = FLAVOR_AUTHGSSAPI ;
}
}
break ;
2001-09-02 23:57:33 +00:00
default :
/*
* It ' s not GSS - API authentication .
*/
flavor = FLAVOR_NOT_GSSAPI ;
break ;
2001-09-02 22:49:56 +00:00
}
}
2003-05-02 21:58:23 +00:00
if ( rpc_tree ) {
proto_tree_add_uint_format ( rpc_tree ,
hf_rpc_procedure , tvb , offset + 12 , 4 , proc ,
" Procedure: %s (%u) " , procname , proc ) ;
}
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
if ( first_pdu )
col_clear ( pinfo - > cinfo , COL_INFO ) ;
else
col_append_fstr ( pinfo - > cinfo , COL_INFO , " ; " ) ;
2003-08-17 21:34:22 +00:00
col_append_fstr ( pinfo - > cinfo , COL_INFO , " V%u %s %s " ,
2003-05-02 21:58:23 +00:00
vers ,
procname ,
2003-08-17 21:34:22 +00:00
msg_type_name ) ;
2003-05-02 21:58:23 +00:00
}
2004-10-20 23:38:31 +00:00
/* Keep track of the address whence the call came, and the
port to which the call is being sent , so that we can
match up calls with replies .
2001-09-12 08:13:33 +00:00
If the transport is connection - oriented ( we check , for
2004-10-20 23:38:31 +00:00
now , only for " pinfo->ptype " of PT_TCP ) , we also take
into account the port from which the call was sent
2001-09-12 08:13:33 +00:00
and the address to which the call was sent , because
2004-10-20 23:38:31 +00:00
the addresses and ports of the two endpoints should be
the same for all calls and replies . ( XXX - what if
the connection is broken and re - established ? )
2001-09-12 08:13:33 +00:00
If the transport is connectionless , we don ' t worry
For ONC RPC, when constructing conversations, use a null address as the
destination address for calls and the source address of the reply - we
should't require the server address to be the same for a call and reply,
as they may not be on a multi-homed server (clients presumably check the
XID only, or perhaps the XID and the port whence the reply came,
although with TI-RPC I don't think they can check the port without
checking the address as well).
This requires that the conversation code not assume that the source and
destination addresses for a given packet in a conversation have the same
type, so, when comparing addresses for equality, it must explicitly
check the address types.
In said code, also check the port numbers before we check the addresses
- testing ports is cheaper, as they're just integers, and there's
probably a decent chance that you won't see two conversations between
different pairs of hosts and the *same* pair of ports in a capture file,
so the cheaper port tests are probably decently likely to fail first.
svn path=/trunk/; revision=1031
1999-11-14 21:16:58 +00:00
about the address to which the call was sent and from
which the reply was sent , because there ' s no
guarantee that the reply will come from the address
2004-10-20 23:38:31 +00:00
to which the call was sent . We also don ' t worry about
the port * from * which the call was sent and * to * which
the reply was sent , because some clients ( * cough * OS X
NFS client * cough ) might send retransmissions from a
different port from the original request . */
2001-09-12 08:13:33 +00:00
if ( pinfo - > ptype = = PT_TCP ) {
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src ,
2001-09-12 08:13:33 +00:00
& pinfo - > dst , pinfo - > ptype , pinfo - > srcport ,
pinfo - > destport , 0 ) ;
} else {
/*
2004-10-20 23:38:31 +00:00
* XXX - you currently still have to pass a non - null
2001-09-12 08:13:33 +00:00
* pointer for the second address argument even
2004-10-20 23:38:31 +00:00
* if you use NO_ADDR_B .
2001-09-12 08:13:33 +00:00
*/
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src ,
2004-10-20 23:38:31 +00:00
& null_address , pinfo - > ptype , pinfo - > destport ,
0 , NO_ADDR_B | NO_PORT_B ) ;
2001-09-12 08:13:33 +00:00
}
1999-10-29 01:11:23 +00:00
if ( conversation = = NULL ) {
2000-11-22 01:39:10 +00:00
/* It's not part of any conversation - create a new
one . */
2001-09-12 08:13:33 +00:00
if ( pinfo - > ptype = = PT_TCP ) {
2005-02-02 20:07:03 +00:00
conversation = conversation_new ( pinfo - > fd - > num , & pinfo - > src ,
2001-09-12 08:13:33 +00:00
& pinfo - > dst , pinfo - > ptype , pinfo - > srcport ,
pinfo - > destport , 0 ) ;
} else {
2005-02-02 20:07:03 +00:00
conversation = conversation_new ( pinfo - > fd - > num , & pinfo - > src ,
2004-10-20 23:38:31 +00:00
& null_address , pinfo - > ptype , pinfo - > destport ,
0 , NO_ADDR2 | NO_PORT2 ) ;
2001-09-12 08:13:33 +00:00
}
2003-08-17 21:34:22 +00:00
}
2006-08-21 12:41:59 +00:00
/*
* Do we already have a state structure for this conv
*/
rpc_conv_info = conversation_get_proto_data ( conversation , proto_rpc ) ;
if ( ! rpc_conv_info ) {
/* No. Attach that information to the conversation, and add
* it to the list of information structures .
*/
rpc_conv_info = se_alloc ( sizeof ( rpc_conv_info_t ) ) ;
rpc_conv_info - > xids = se_tree_create_non_persistent ( EMEM_TREE_TYPE_RED_BLACK , " rpc_xids " ) ;
conversation_add_proto_data ( conversation , proto_rpc , rpc_conv_info ) ;
}
2001-09-12 08:13:33 +00:00
2003-09-03 07:11:13 +00:00
/* Make the dissector for this conversation the non-heuristic
RPC dissector . */
conversation_set_dissector ( conversation ,
( pinfo - > ptype = = PT_TCP ) ? rpc_tcp_handle : rpc_handle ) ;
1999-10-29 01:11:23 +00:00
/* look up the request */
2006-08-21 12:41:59 +00:00
rpc_call = se_tree_lookup32 ( rpc_conv_info - > xids , xid ) ;
2003-08-17 21:34:22 +00:00
if ( rpc_call ) {
Instead of keeping in the information about an RPC call a count of the
number of replies seen, keep the frame number of the first request seen
for that call and the first reply seen for that call. Use that to
determine whether a request or reply is a duplicate or not.
That means that we don't have to reset the table of RPC calls on a
rescan of the capture (which didn't even fix all the cases where we'd
have misreported the original call or reply as a duplicate due to having
seen it once on the initial pass through the file and once again when,
for example, the user clicked on the packet); doing so causes plenty of
other problems, so don't do that - and don't clear the "visited" flag on
frames on a rescan, either, as that's only done because we were clearing
out conversations and calling all protocols' "init" routines.
As a free bonus, this means that, for a reply, we know what frame the
request was in; put that information into the protocol tree for the
reply, snoop-style.
Make the table of RPC call information, and the routines that manipulate
it, static to "packet-rpc.c"; nobody outside "packet-rpc.c" uses them.
svn path=/trunk/; revision=2358
2000-08-24 06:19:53 +00:00
/* We've seen a request with this XID, with the same
source and destination , before - but was it
* this * request ? */
2000-11-21 14:58:07 +00:00
if ( pinfo - > fd - > num ! = rpc_call - > req_num ) {
Instead of keeping in the information about an RPC call a count of the
number of replies seen, keep the frame number of the first request seen
for that call and the first reply seen for that call. Use that to
determine whether a request or reply is a duplicate or not.
That means that we don't have to reset the table of RPC calls on a
rescan of the capture (which didn't even fix all the cases where we'd
have misreported the original call or reply as a duplicate due to having
seen it once on the initial pass through the file and once again when,
for example, the user clicked on the packet); doing so causes plenty of
other problems, so don't do that - and don't clear the "visited" flag on
frames on a rescan, either, as that's only done because we were clearing
out conversations and calling all protocols' "init" routines.
As a free bonus, this means that, for a reply, we know what frame the
request was in; put that information into the protocol tree for the
reply, snoop-style.
Make the table of RPC call information, and the routines that manipulate
it, static to "packet-rpc.c"; nobody outside "packet-rpc.c" uses them.
svn path=/trunk/; revision=2358
2000-08-24 06:19:53 +00:00
/* No, so it's a duplicate request.
Mark it as such . */
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
2003-08-17 21:34:22 +00:00
col_prepend_fstr ( pinfo - > cinfo , COL_INFO ,
" [RPC retransmission of #%d] " , rpc_call - > req_num ) ;
1999-12-14 11:43:59 +00:00
}
2003-07-22 11:51:20 +00:00
proto_tree_add_item ( rpc_tree ,
hf_rpc_dup , tvb , 0 , 0 , TRUE ) ;
proto_tree_add_uint ( rpc_tree ,
hf_rpc_call_dup , tvb , 0 , 0 , rpc_call - > req_num ) ;
1999-10-29 01:11:23 +00:00
}
2003-08-17 21:34:22 +00:00
if ( rpc_call - > rep_num ) {
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
col_append_fstr ( pinfo - > cinfo , COL_INFO , " (Reply In %d) " , rpc_call - > rep_num ) ;
}
}
} else {
2000-08-24 08:55:30 +00:00
/* Prepare the value data.
" req_num " and " rep_num " are frame numbers ;
frame numbers are 1 - origin , so we use 0
to mean " we don't yet know in which frame
the reply for this call appears " . */
2005-08-13 01:29:31 +00:00
rpc_call = se_alloc ( sizeof ( rpc_call_info_value ) ) ;
2001-01-18 00:13:18 +00:00
rpc_call - > req_num = pinfo - > fd - > num ;
rpc_call - > rep_num = 0 ;
rpc_call - > prog = prog ;
rpc_call - > vers = vers ;
rpc_call - > proc = proc ;
2002-05-09 12:10:06 +00:00
rpc_call - > private_data = NULL ;
2002-01-12 10:24:47 +00:00
rpc_call - > xid = xid ;
2001-01-18 00:13:18 +00:00
rpc_call - > flavor = flavor ;
rpc_call - > gss_proc = gss_proc ;
rpc_call - > gss_svc = gss_svc ;
rpc_call - > proc_info = value ;
2005-08-24 21:31:56 +00:00
rpc_call - > req_time = pinfo - > fd - > abs_ts ;
2001-12-28 20:18:45 +00:00
1999-10-29 01:11:23 +00:00
/* store it */
2006-08-21 12:41:59 +00:00
se_tree_insert32 ( rpc_conv_info - > xids , xid , ( void * ) rpc_call ) ;
1999-10-29 01:11:23 +00:00
}
2002-05-09 12:10:06 +00:00
if ( rpc_call & & rpc_call - > rep_num ) {
2006-02-28 10:10:08 +00:00
proto_item * tmp_item ;
2006-11-21 08:53:11 +00:00
tmp_item = proto_tree_add_uint_format ( rpc_tree , hf_rpc_reqframe ,
2002-12-19 02:58:53 +00:00
tvb , 0 , 0 , rpc_call - > rep_num ,
2002-05-09 12:10:06 +00:00
" The reply to this request is in frame %u " ,
rpc_call - > rep_num ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2002-05-09 12:10:06 +00:00
}
1999-10-29 01:11:23 +00:00
offset + = 16 ;
2002-04-03 13:24:13 +00:00
offset = dissect_rpc_cred ( tvb , rpc_tree , offset ) ;
2003-05-21 02:48:40 +00:00
offset = dissect_rpc_verf ( tvb , rpc_tree , offset , msg_type , pinfo ) ;
1999-10-29 01:11:23 +00:00
2002-01-12 10:24:47 +00:00
/* pass rpc_info to subdissectors */
rpc_call - > request = TRUE ;
pinfo - > private_data = rpc_call ;
1999-10-29 01:11:23 +00:00
/* go to the next dissector */
2001-01-18 00:13:18 +00:00
break ; /* end of RPC call */
case RPC_REPLY :
1999-11-14 20:44:52 +00:00
/* we know already the type from the calling routine,
and we already have " rpc_call " set above . */
1999-10-29 01:11:23 +00:00
prog = rpc_call - > prog ;
vers = rpc_call - > vers ;
proc = rpc_call - > proc ;
2000-07-17 20:34:00 +00:00
flavor = rpc_call - > flavor ;
gss_proc = rpc_call - > gss_proc ;
gss_svc = rpc_call - > gss_svc ;
1999-10-29 01:11:23 +00:00
if ( rpc_call - > proc_info ! = NULL ) {
2001-05-30 06:01:02 +00:00
dissect_function = rpc_call - > proc_info - > dissect_reply ;
1999-10-29 01:11:23 +00:00
if ( rpc_call - > proc_info - > name ! = NULL ) {
2005-08-20 00:27:46 +00:00
procname = ( char * ) rpc_call - > proc_info - > name ;
1999-10-29 01:11:23 +00:00
}
else {
2005-08-20 00:27:46 +00:00
procname = ep_alloc ( 20 ) ;
g_snprintf ( procname , 20 , " proc-%u " , proc ) ;
1999-10-29 01:11:23 +00:00
}
}
else {
2001-01-28 03:39:48 +00:00
#if 0
1999-10-29 01:11:23 +00:00
dissect_function = NULL ;
2001-01-28 03:39:48 +00:00
# endif
2005-08-20 00:27:46 +00:00
procname = ep_alloc ( 20 ) ;
g_snprintf ( procname , 20 , " proc-%u " , proc ) ;
1999-10-29 01:11:23 +00:00
}
2003-05-02 21:58:23 +00:00
/*
* If this is an AUTH_GSSAPI message , then the RPC procedure
* is not an application procedure , but rather an auth level
* procedure , so it would be misleading to print the RPC
* procname . Replace the RPC procname with the corresponding
* AUTH_GSSAPI procname .
*/
if ( flavor = = FLAVOR_AUTHGSSAPI_MSG ) {
2005-08-20 00:27:46 +00:00
procname = ( char * ) match_strval ( gss_proc , rpc_authgssapi_proc ) ;
2003-05-02 21:58:23 +00:00
}
1999-10-29 01:11:23 +00:00
rpc_prog_key . prog = prog ;
if ( ( rpc_prog = g_hash_table_lookup ( rpc_progs , & rpc_prog_key ) ) = = NULL ) {
2003-11-16 23:17:27 +00:00
proto = NULL ;
proto_id = 0 ;
1999-10-29 01:11:23 +00:00
ett = 0 ;
progname = " Unknown " ;
}
else {
proto = rpc_prog - > proto ;
2003-11-16 23:17:27 +00:00
proto_id = rpc_prog - > proto_id ;
1999-10-29 01:11:23 +00:00
ett = rpc_prog - > ett ;
progname = rpc_prog - > progname ;
1999-10-29 02:25:54 +00:00
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_PROTOCOL ) ) {
1999-10-29 02:25:54 +00:00
/* Set the protocol name to the underlying
program name . */
2001-12-10 00:26:21 +00:00
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , progname ) ;
1999-10-29 02:25:54 +00:00
}
1999-10-29 01:11:23 +00:00
}
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
2003-04-21 08:13:18 +00:00
if ( first_pdu )
col_clear ( pinfo - > cinfo , COL_INFO ) ;
else
2002-12-06 21:01:37 +00:00
col_append_fstr ( pinfo - > cinfo , COL_INFO , " ; " ) ;
2003-08-17 21:34:22 +00:00
col_append_fstr ( pinfo - > cinfo , COL_INFO , " V%u %s %s " ,
1999-10-29 02:25:54 +00:00
vers ,
1999-10-29 01:11:23 +00:00
procname ,
2003-08-17 21:34:22 +00:00
msg_type_name ) ;
1999-10-29 01:11:23 +00:00
}
if ( rpc_tree ) {
2006-02-28 10:10:08 +00:00
proto_item * tmp_item ;
tmp_item = proto_tree_add_uint_format ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_program , tvb , 0 , 0 , prog ,
1999-11-15 17:16:51 +00:00
" Program: %s (%u) " , progname , prog ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
tmp_item = proto_tree_add_uint ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_programversion , tvb , 0 , 0 , vers ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
tmp_item = proto_tree_add_uint_format ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_procedure , tvb , 0 , 0 , proc ,
1999-11-05 07:16:23 +00:00
" Procedure: %s (%u) " , procname , proc ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
1999-10-29 01:11:23 +00:00
}
2002-05-09 12:10:06 +00:00
reply_state = tvb_get_ntohl ( tvb , offset + 0 ) ;
if ( rpc_tree ) {
proto_tree_add_uint ( rpc_tree , hf_rpc_state_reply , tvb ,
offset + 0 , 4 , reply_state ) ;
}
offset + = 4 ;
/* Indicate the frame to which this is a reply. */
if ( rpc_call & & rpc_call - > req_num ) {
2006-02-28 10:10:08 +00:00
proto_item * tmp_item ;
2006-11-21 08:53:11 +00:00
tmp_item = proto_tree_add_uint_format ( rpc_tree , hf_rpc_repframe ,
2002-12-19 02:58:53 +00:00
tvb , 0 , 0 , rpc_call - > req_num ,
2002-05-09 12:10:06 +00:00
" This is a reply to a request in frame %u " ,
rpc_call - > req_num ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2005-08-24 21:31:56 +00:00
nstime_delta ( & ns , & pinfo - > fd - > abs_ts , & rpc_call - > req_time ) ;
2006-02-28 10:10:08 +00:00
tmp_item = proto_tree_add_time ( rpc_tree , hf_rpc_time , tvb , offset , 0 ,
2002-05-09 12:10:06 +00:00
& ns ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2003-08-17 21:34:22 +00:00
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
col_append_fstr ( pinfo - > cinfo , COL_INFO , " (Call In %d) " , rpc_call - > req_num ) ;
}
2002-05-09 12:10:06 +00:00
}
2003-08-17 21:34:22 +00:00
if ( ( ! rpc_call ) | | ( rpc_call - > rep_num = = 0 ) ) {
Instead of keeping in the information about an RPC call a count of the
number of replies seen, keep the frame number of the first request seen
for that call and the first reply seen for that call. Use that to
determine whether a request or reply is a duplicate or not.
That means that we don't have to reset the table of RPC calls on a
rescan of the capture (which didn't even fix all the cases where we'd
have misreported the original call or reply as a duplicate due to having
seen it once on the initial pass through the file and once again when,
for example, the user clicked on the packet); doing so causes plenty of
other problems, so don't do that - and don't clear the "visited" flag on
frames on a rescan, either, as that's only done because we were clearing
out conversations and calling all protocols' "init" routines.
As a free bonus, this means that, for a reply, we know what frame the
request was in; put that information into the protocol tree for the
reply, snoop-style.
Make the table of RPC call information, and the routines that manipulate
it, static to "packet-rpc.c"; nobody outside "packet-rpc.c" uses them.
svn path=/trunk/; revision=2358
2000-08-24 06:19:53 +00:00
/* We have not yet seen a reply to that call, so
this must be the first reply ; remember its
frame number . */
2000-11-21 14:58:07 +00:00
rpc_call - > rep_num = pinfo - > fd - > num ;
Instead of keeping in the information about an RPC call a count of the
number of replies seen, keep the frame number of the first request seen
for that call and the first reply seen for that call. Use that to
determine whether a request or reply is a duplicate or not.
That means that we don't have to reset the table of RPC calls on a
rescan of the capture (which didn't even fix all the cases where we'd
have misreported the original call or reply as a duplicate due to having
seen it once on the initial pass through the file and once again when,
for example, the user clicked on the packet); doing so causes plenty of
other problems, so don't do that - and don't clear the "visited" flag on
frames on a rescan, either, as that's only done because we were clearing
out conversations and calling all protocols' "init" routines.
As a free bonus, this means that, for a reply, we know what frame the
request was in; put that information into the protocol tree for the
reply, snoop-style.
Make the table of RPC call information, and the routines that manipulate
it, static to "packet-rpc.c"; nobody outside "packet-rpc.c" uses them.
svn path=/trunk/; revision=2358
2000-08-24 06:19:53 +00:00
} else {
/* We have seen a reply to this call - but was it
* this * reply ? */
2000-11-21 14:58:07 +00:00
if ( rpc_call - > rep_num ! = pinfo - > fd - > num ) {
2006-02-28 10:10:08 +00:00
proto_item * tmp_item ;
Instead of keeping in the information about an RPC call a count of the
number of replies seen, keep the frame number of the first request seen
for that call and the first reply seen for that call. Use that to
determine whether a request or reply is a duplicate or not.
That means that we don't have to reset the table of RPC calls on a
rescan of the capture (which didn't even fix all the cases where we'd
have misreported the original call or reply as a duplicate due to having
seen it once on the initial pass through the file and once again when,
for example, the user clicked on the packet); doing so causes plenty of
other problems, so don't do that - and don't clear the "visited" flag on
frames on a rescan, either, as that's only done because we were clearing
out conversations and calling all protocols' "init" routines.
As a free bonus, this means that, for a reply, we know what frame the
request was in; put that information into the protocol tree for the
reply, snoop-style.
Make the table of RPC call information, and the routines that manipulate
it, static to "packet-rpc.c"; nobody outside "packet-rpc.c" uses them.
svn path=/trunk/; revision=2358
2000-08-24 06:19:53 +00:00
/* No, so it's a duplicate reply.
Mark it as such . */
2001-12-10 00:26:21 +00:00
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
2003-08-17 21:34:22 +00:00
col_prepend_fstr ( pinfo - > cinfo , COL_INFO ,
2004-04-29 11:58:00 +00:00
" [RPC duplicate of #%d] " , rpc_call - > rep_num ) ;
1999-12-14 11:43:59 +00:00
}
2006-02-28 10:10:08 +00:00
tmp_item = proto_tree_add_item ( rpc_tree ,
2003-07-22 11:51:20 +00:00
hf_rpc_dup , tvb , 0 , 0 , TRUE ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
tmp_item = proto_tree_add_uint ( rpc_tree ,
2003-07-22 11:51:20 +00:00
hf_rpc_reply_dup , tvb , 0 , 0 , rpc_call - > rep_num ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
1999-10-29 01:11:23 +00:00
}
}
2002-05-15 23:01:51 +00:00
switch ( reply_state ) {
case MSG_ACCEPTED :
2003-05-21 02:48:40 +00:00
offset = dissect_rpc_verf ( tvb , rpc_tree , offset , msg_type , pinfo ) ;
2000-11-21 14:58:07 +00:00
accept_state = tvb_get_ntohl ( tvb , offset + 0 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-11-21 14:58:07 +00:00
proto_tree_add_uint ( rpc_tree , hf_rpc_state_accept , tvb ,
1999-11-15 17:16:51 +00:00
offset + 0 , 4 , accept_state ) ;
1999-10-29 01:11:23 +00:00
}
offset + = 4 ;
switch ( accept_state ) {
2001-07-03 02:05:47 +00:00
case SUCCESS :
/* go to the next dissector */
1999-10-29 01:11:23 +00:00
break ;
2001-07-03 02:05:47 +00:00
case PROG_MISMATCH :
vers_low = tvb_get_ntohl ( tvb , offset + 0 ) ;
vers_high = tvb_get_ntohl ( tvb , offset + 4 ) ;
if ( rpc_tree ) {
proto_tree_add_uint ( rpc_tree ,
hf_rpc_programversion_min ,
tvb , offset + 0 , 4 , vers_low ) ;
proto_tree_add_uint ( rpc_tree ,
hf_rpc_programversion_max ,
tvb , offset + 4 , 4 , vers_high ) ;
}
offset + = 8 ;
2002-05-15 23:01:51 +00:00
/*
* There ' s no protocol reply , so don ' t
* try to dissect it .
*/
dissect_rpc = FALSE ;
1999-10-29 01:11:23 +00:00
break ;
2001-07-03 02:05:47 +00:00
default :
2002-05-15 23:01:51 +00:00
/*
* There ' s no protocol reply , so don ' t
* try to dissect it .
*/
dissect_rpc = FALSE ;
1999-10-29 01:11:23 +00:00
break ;
}
2002-05-15 23:01:51 +00:00
break ;
case MSG_DENIED :
2000-11-21 14:58:07 +00:00
reject_state = tvb_get_ntohl ( tvb , offset + 0 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-05-31 05:09:07 +00:00
proto_tree_add_uint ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_state_reject , tvb , offset + 0 , 4 ,
1999-10-29 01:11:23 +00:00
reject_state ) ;
}
offset + = 4 ;
if ( reject_state = = RPC_MISMATCH ) {
2000-11-21 14:58:07 +00:00
vers_low = tvb_get_ntohl ( tvb , offset + 0 ) ;
vers_high = tvb_get_ntohl ( tvb , offset + 4 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-05-31 05:09:07 +00:00
proto_tree_add_uint ( rpc_tree ,
1999-11-15 17:16:51 +00:00
hf_rpc_version_min ,
2000-11-21 14:58:07 +00:00
tvb , offset + 0 , 4 , vers_low ) ;
2000-05-31 05:09:07 +00:00
proto_tree_add_uint ( rpc_tree ,
1999-11-15 17:16:51 +00:00
hf_rpc_version_max ,
2000-11-21 14:58:07 +00:00
tvb , offset + 4 , 4 , vers_high ) ;
1999-10-29 01:11:23 +00:00
}
offset + = 8 ;
} else if ( reject_state = = AUTH_ERROR ) {
2000-11-21 14:58:07 +00:00
auth_state = tvb_get_ntohl ( tvb , offset + 0 ) ;
1999-10-29 01:11:23 +00:00
if ( rpc_tree ) {
2000-05-31 05:09:07 +00:00
proto_tree_add_uint ( rpc_tree ,
2000-11-21 14:58:07 +00:00
hf_rpc_state_auth , tvb , offset + 0 , 4 ,
1999-10-29 01:11:23 +00:00
auth_state ) ;
}
offset + = 4 ;
}
2002-05-15 23:01:51 +00:00
/*
* There ' s no protocol reply , so don ' t
* try to dissect it .
*/
dissect_rpc = FALSE ;
break ;
default :
/*
* This isn ' t a valid reply state , so we have
* no clue what ' s going on ; don ' t try to dissect
* the protocol reply .
*/
dissect_rpc = FALSE ;
break ;
2002-08-28 21:04:11 +00:00
}
2001-01-18 00:13:18 +00:00
break ; /* end of RPC reply */
default :
/*
* The switch statement at the top returned if
* this was neither an RPC call nor a reply .
*/
2005-06-10 18:28:22 +00:00
DISSECTOR_ASSERT_NOT_REACHED ( ) ;
2001-01-18 00:13:18 +00:00
}
1999-10-29 01:11:23 +00:00
/* now we know, that RPC was shorter */
if ( rpc_item ) {
2005-10-16 14:23:56 +00:00
if ( offset < 0 )
THROW ( ReportedBoundsError ) ;
2005-04-15 15:17:55 +00:00
tvb_ensure_bytes_exist ( tvb , offset , 0 ) ;
2003-05-02 21:58:23 +00:00
proto_item_set_end ( rpc_item , tvb , offset ) ;
1999-10-29 01:11:23 +00:00
}
2002-05-15 23:01:51 +00:00
if ( ! dissect_rpc ) {
/*
* There ' s no RPC call or reply here ; just dissect
* whatever ' s left as data .
*/
call_dissector ( data_handle ,
tvb_new_subset ( tvb , offset , - 1 , - 1 ) , pinfo , rpc_tree ) ;
return TRUE ;
}
1999-10-29 01:11:23 +00:00
/* create here the program specific sub-tree */
2003-05-02 21:58:23 +00:00
if ( tree & & ( flavor ! = FLAVOR_AUTHGSSAPI_MSG ) ) {
2003-11-16 23:17:27 +00:00
pitem = proto_tree_add_item ( tree , proto_id , tvb , offset , - 1 ,
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
FALSE ) ;
1999-11-15 17:16:51 +00:00
if ( pitem ) {
1999-10-29 01:11:23 +00:00
ptree = proto_item_add_subtree ( pitem , ett ) ;
}
1999-11-15 17:16:51 +00:00
if ( ptree ) {
2006-02-28 10:10:08 +00:00
proto_item * tmp_item ;
tmp_item = proto_tree_add_uint ( ptree ,
2001-05-30 06:01:02 +00:00
hf_rpc_programversion , tvb , 0 , 0 , vers ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2006-03-09 11:44:56 +00:00
if ( rpc_prog & & ( rpc_prog - > procedure_hfs - > len > vers ) )
2002-10-24 03:54:11 +00:00
procedure_hf = g_array_index ( rpc_prog - > procedure_hfs , int , vers ) ;
else {
/*
* No such element in the GArray .
*/
procedure_hf = 0 ;
}
2002-10-23 21:17:03 +00:00
if ( procedure_hf ! = 0 & & procedure_hf ! = - 1 ) {
2006-02-28 10:10:08 +00:00
tmp_item = proto_tree_add_uint ( ptree ,
2002-10-23 21:17:03 +00:00
procedure_hf , tvb , 0 , 0 , proc ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2002-10-23 21:17:03 +00:00
} else {
2006-02-28 10:10:08 +00:00
tmp_item = proto_tree_add_uint_format ( ptree ,
2002-10-23 21:17:03 +00:00
hf_rpc_procedure , tvb , 0 , 0 , proc ,
" Procedure: %s (%u) " , procname , proc ) ;
2006-02-28 10:10:08 +00:00
PROTO_ITEM_SET_GENERATED ( tmp_item ) ;
2002-10-23 21:17:03 +00:00
}
1999-11-15 17:16:51 +00:00
}
}
2003-04-18 06:34:42 +00:00
/* we must queue this packet to the tap system before we actually
call the subdissectors since short packets ( i . e . nfs read reply )
will cause an exception and execution would never reach the call
to tap_queue_packet ( ) in that case
*/
tap_queue_packet ( rpc_tap , pinfo , rpc_call ) ;
2004-04-03 00:29:08 +00:00
/* proto==0 if this is an unknown program */
if ( ( proto = = 0 ) | | ! proto_is_protocol_enabled ( proto ) ) {
2000-11-21 14:58:07 +00:00
dissect_function = NULL ;
2004-04-03 00:29:08 +00:00
}
2000-11-21 14:58:07 +00:00
2001-09-02 22:49:56 +00:00
/*
2003-05-02 21:58:23 +00:00
* Handle RPCSEC_GSS and AUTH_GSSAPI specially .
2001-09-02 22:49:56 +00:00
*/
2001-09-02 23:57:33 +00:00
switch ( flavor ) {
case FLAVOR_UNKNOWN :
2001-09-02 22:49:56 +00:00
/*
2001-09-02 23:57:33 +00:00
* We don ' t know the authentication flavor , so we can ' t
* dissect the payload .
2001-09-02 22:49:56 +00:00
*/
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
proto_tree_add_text ( ptree , tvb , offset , - 1 ,
2001-09-02 22:49:56 +00:00
" Unknown authentication flavor - cannot dissect " ) ;
return TRUE ;
2001-09-02 23:57:33 +00:00
case FLAVOR_NOT_GSSAPI :
/*
* It ' s not GSS - API authentication . Just dissect the
* payload .
*/
offset = call_dissect_function ( tvb , pinfo , ptree , offset ,
dissect_function , progname ) ;
break ;
case FLAVOR_GSSAPI_NO_INFO :
/*
* It ' s GSS - API authentication , but we don ' t have the
* procedure and service information , so we can ' t dissect
* the payload .
*/
Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff". This can be used if
1) the item covers the entire packet or the remaining payload in
the packet
or
2) the item's length won't be known until it's dissected, and
will be then set with "proto_item_set_len()" - if an
exception is thrown in the dissection, it means the item ran
*past* the end of the tvbuff, so saying it runs to the end of
the tvbuff is reasonable.
Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).
In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).
Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.
Fix some indentation.
svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
proto_tree_add_text ( ptree , tvb , offset , - 1 ,
2001-09-02 23:57:33 +00:00
" GSS-API authentication, but procedure and service unknown - cannot dissect " ) ;
return TRUE ;
case FLAVOR_GSSAPI :
/*
* It ' s GSS - API authentication , and we have the procedure
* and service information ; process the GSS - API stuff ,
* and process the payload if there is any .
*/
2000-07-17 20:34:00 +00:00
switch ( gss_proc ) {
2001-07-03 02:05:47 +00:00
2000-08-24 22:58:56 +00:00
case RPCSEC_GSS_INIT :
case RPCSEC_GSS_CONTINUE_INIT :
2000-07-17 20:34:00 +00:00
if ( msg_type = = RPC_CALL ) {
2000-11-21 14:58:07 +00:00
offset = dissect_rpc_authgss_initarg ( tvb ,
2002-08-22 20:22:22 +00:00
ptree , offset , pinfo ) ;
2000-07-17 20:34:00 +00:00
}
else {
2000-11-21 14:58:07 +00:00
offset = dissect_rpc_authgss_initres ( tvb ,
2002-08-22 20:22:22 +00:00
ptree , offset , pinfo ) ;
2000-07-17 20:34:00 +00:00
}
break ;
2001-07-03 02:05:47 +00:00
2000-08-24 22:58:56 +00:00
case RPCSEC_GSS_DATA :
if ( gss_svc = = RPCSEC_GSS_SVC_NONE ) {
2002-08-28 21:04:11 +00:00
offset = call_dissect_function ( tvb ,
2001-01-18 06:33:23 +00:00
pinfo , ptree , offset ,
dissect_function ,
progname ) ;
2000-07-17 20:34:00 +00:00
}
2000-08-24 22:58:56 +00:00
else if ( gss_svc = = RPCSEC_GSS_SVC_INTEGRITY ) {
2000-11-21 14:58:07 +00:00
offset = dissect_rpc_authgss_integ_data ( tvb ,
pinfo , ptree , offset ,
2001-01-18 06:33:23 +00:00
dissect_function ,
progname ) ;
2000-07-17 20:34:00 +00:00
}
2000-08-24 22:58:56 +00:00
else if ( gss_svc = = RPCSEC_GSS_SVC_PRIVACY ) {
2000-11-21 14:58:07 +00:00
offset = dissect_rpc_authgss_priv_data ( tvb ,
2002-04-03 13:24:13 +00:00
ptree , offset ) ;
2000-07-17 20:34:00 +00:00
}
break ;
2001-07-03 02:05:47 +00:00
2000-07-17 20:34:00 +00:00
default :
break ;
}
2003-05-02 21:58:23 +00:00
break ;
case FLAVOR_AUTHGSSAPI_MSG :
/*
* This is an AUTH_GSSAPI message . It contains data
* only for the authentication procedure and not for the
* application level RPC procedure . Reset the column
* protocol and info fields to indicate that this is
* an RPC auth level message , then process the args .
*/
if ( check_col ( pinfo - > cinfo , COL_PROTOCOL ) ) {
col_set_str ( pinfo - > cinfo , COL_PROTOCOL , " RPC " ) ;
}
if ( check_col ( pinfo - > cinfo , COL_INFO ) ) {
col_clear ( pinfo - > cinfo , COL_INFO ) ;
col_append_fstr ( pinfo - > cinfo , COL_INFO ,
" %s %s XID 0x%x " ,
match_strval ( gss_proc , rpc_authgssapi_proc ) ,
msg_type_name , xid ) ;
}
switch ( gss_proc ) {
case AUTH_GSSAPI_INIT :
case AUTH_GSSAPI_CONTINUE_INIT :
case AUTH_GSSAPI_MSG :
if ( msg_type = = RPC_CALL ) {
2005-10-17 18:56:27 +00:00
offset = dissect_rpc_authgssapi_initarg ( tvb ,
2003-05-02 21:58:23 +00:00
rpc_tree , offset , pinfo ) ;
} else {
2005-10-17 18:56:27 +00:00
offset = dissect_rpc_authgssapi_initres ( tvb ,
2003-05-02 21:58:23 +00:00
rpc_tree , offset , pinfo ) ;
}
break ;
case AUTH_GSSAPI_DESTROY :
offset = dissect_rpc_data ( tvb , rpc_tree ,
hf_rpc_authgss_data , offset ) ;
break ;
case AUTH_GSSAPI_EXIT :
break ;
}
/* Adjust the length to account for the auth message. */
if ( rpc_item ) {
proto_item_set_end ( rpc_item , tvb , offset ) ;
}
break ;
case FLAVOR_AUTHGSSAPI :
/*
* An RPC with AUTH_GSSAPI authentication . The data
* portion is always private , so don ' t call the dissector .
*/
offset = dissect_auth_gssapi_data ( tvb , ptree , offset ) ;
break ;
2000-07-17 20:34:00 +00:00
}
1999-10-29 01:11:23 +00:00
2005-10-17 18:56:27 +00:00
if ( tvb_length_remaining ( tvb , offset ) > 0 ) {
/*
* dissect any remaining bytes ( incomplete dissection ) as pure
* data in the ptree
2003-05-23 17:46:06 +00:00
*/
1999-11-14 20:44:52 +00:00
2003-05-23 17:46:06 +00:00
call_dissector ( data_handle ,
tvb_new_subset ( tvb , offset , - 1 , - 1 ) , pinfo , ptree ) ;
}
2002-05-21 10:17:30 +00:00
/* XXX this should really loop over all fhandles registred for the frame */
if ( nfs_fhandle_reqrep_matching ) {
switch ( msg_type ) {
case RPC_CALL :
if ( rpc_call & & rpc_call - > rep_num ) {
2006-03-06 14:30:34 +00:00
dissect_fhandle_hidden ( pinfo ,
ptree , rpc_call - > rep_num ) ;
2002-05-21 10:17:30 +00:00
}
break ;
case RPC_REPLY :
if ( rpc_call & & rpc_call - > req_num ) {
2006-03-06 14:30:34 +00:00
dissect_fhandle_hidden ( pinfo ,
ptree , rpc_call - > req_num ) ;
2002-05-21 10:17:30 +00:00
}
break ;
}
}
1999-11-14 20:44:52 +00:00
return TRUE ;
1999-10-29 01:11:23 +00:00
}
2001-09-12 08:13:33 +00:00
static gboolean
dissect_rpc_heur ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree )
{
2003-04-21 08:13:18 +00:00
return dissect_rpc_message ( tvb , pinfo , tree , NULL , NULL , FALSE , 0 ,
TRUE ) ;
2001-09-12 08:13:33 +00:00
}
static void
dissect_rpc ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree )
{
2003-04-21 08:13:18 +00:00
if ( ! dissect_rpc_message ( tvb , pinfo , tree , NULL , NULL , FALSE , 0 ,
TRUE ) ) {
if ( tvb_length ( tvb ) ! = 0 )
dissect_rpc_continuation ( tvb , pinfo , tree ) ;
}
2001-09-13 07:56:53 +00:00
}
2002-12-06 21:01:37 +00:00
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
/* Defragmentation of RPC-over-TCP records */
/* table to hold defragmented RPC records */
static GHashTable * rpc_fragment_table = NULL ;
static GHashTable * rpc_reassembly_table = NULL ;
typedef struct _rpc_fragment_key {
guint32 conv_id ;
guint32 seq ;
guint32 offset ;
/* xxx */
guint32 start_seq ;
} rpc_fragment_key ;
static guint
rpc_fragment_hash ( gconstpointer k )
{
2002-12-02 23:43:30 +00:00
const rpc_fragment_key * key = ( const rpc_fragment_key * ) k ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
return key - > conv_id + key - > seq ;
}
static gint
rpc_fragment_equal ( gconstpointer k1 , gconstpointer k2 )
{
2002-12-02 23:43:30 +00:00
const rpc_fragment_key * key1 = ( const rpc_fragment_key * ) k1 ;
const rpc_fragment_key * key2 = ( const rpc_fragment_key * ) k2 ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
return key1 - > conv_id = = key2 - > conv_id & &
key1 - > seq = = key2 - > seq ;
}
static void
show_rpc_fragheader ( tvbuff_t * tvb , proto_tree * tree , guint32 rpc_rm )
{
proto_item * hdr_item ;
proto_tree * hdr_tree ;
guint32 fraglen ;
if ( tree ) {
fraglen = rpc_rm & RPC_RM_FRAGLEN ;
hdr_item = proto_tree_add_text ( tree , tvb , 0 , 4 ,
" Fragment header: %s%u %s " ,
( rpc_rm & RPC_RM_LASTFRAG ) ? " Last fragment, " : " " ,
fraglen , plurality ( fraglen , " byte " , " bytes " ) ) ;
hdr_tree = proto_item_add_subtree ( hdr_item , ett_rpc_fraghdr ) ;
proto_tree_add_boolean ( hdr_tree , hf_rpc_lastfrag , tvb , 0 , 4 ,
rpc_rm ) ;
proto_tree_add_uint ( hdr_tree , hf_rpc_fraglen , tvb , 0 , 4 ,
rpc_rm ) ;
}
}
static void
show_rpc_fragment ( tvbuff_t * tvb , proto_tree * tree , guint32 rpc_rm )
{
if ( tree ) {
/*
* Show the fragment header and the data for the fragment .
*/
show_rpc_fragheader ( tvb , tree , rpc_rm ) ;
proto_tree_add_text ( tree , tvb , 4 , - 1 , " Fragment Data " ) ;
}
}
static void
make_frag_tree ( tvbuff_t * tvb , proto_tree * tree , int proto , gint ett ,
guint32 rpc_rm )
{
proto_item * frag_item ;
proto_tree * frag_tree ;
if ( tree = = NULL )
return ; /* nothing to do */
frag_item = proto_tree_add_protocol_format ( tree , proto , tvb , 0 , - 1 ,
" %s Fragment " , proto_get_protocol_name ( proto ) ) ;
frag_tree = proto_item_add_subtree ( frag_item , ett ) ;
show_rpc_fragment ( tvb , frag_tree , rpc_rm ) ;
}
void
show_rpc_fraginfo ( tvbuff_t * tvb , tvbuff_t * frag_tvb , proto_tree * tree ,
2002-06-05 11:32:14 +00:00
guint32 rpc_rm , fragment_data * ipfd_head , packet_info * pinfo )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
{
2005-06-02 18:52:55 +00:00
proto_item * frag_tree_item ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
if ( tree = = NULL )
return ; /* don't do any work */
if ( tvb ! = frag_tvb ) {
/*
* This message was not all in one fragment ,
* so show the fragment header * and * the data
* for the fragment ( which is the last fragment ) ,
* and a tree with information about all fragments .
*/
show_rpc_fragment ( frag_tvb , tree , rpc_rm ) ;
/*
* Show a tree with information about all fragments .
*/
2005-06-02 18:52:55 +00:00
show_fragment_tree ( ipfd_head , & rpc_frag_items , tree , pinfo , tvb , & frag_tree_item ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
} else {
/*
* This message was all in one fragment , so just show
* the fragment header .
*/
show_rpc_fragheader ( tvb , tree , rpc_rm ) ;
}
}
static gboolean
call_message_dissector ( tvbuff_t * tvb , tvbuff_t * rec_tvb , packet_info * pinfo ,
proto_tree * tree , tvbuff_t * frag_tvb , rec_dissector_t dissector ,
2003-04-21 08:13:18 +00:00
fragment_data * ipfd_head , guint32 rpc_rm , gboolean first_pdu )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
{
const char * saved_proto ;
volatile gboolean rpc_succeeded ;
/*
* Catch the ReportedBoundsError exception ; if
* this particular message happens to get a
* ReportedBoundsError exception , that doesn ' t
* mean that we should stop dissecting RPC
* messages within this frame or chunk of
* reassembled data .
*
* If it gets a BoundsError , we can stop , as there ' s
* nothing more to see , so we just re - throw it .
*/
saved_proto = pinfo - > current_proto ;
rpc_succeeded = FALSE ;
TRY {
rpc_succeeded = ( * dissector ) ( rec_tvb , pinfo , tree ,
2003-04-21 08:13:18 +00:00
frag_tvb , ipfd_head , TRUE , rpc_rm , first_pdu ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
}
CATCH ( BoundsError ) {
RETHROW ;
}
CATCH ( ReportedBoundsError ) {
show_reported_bounds_error ( tvb , pinfo , tree ) ;
pinfo - > current_proto = saved_proto ;
/*
* We treat this as a " successful " dissection of
* an RPC packet , as " dissect_rpc_message() "
* * did * decide it was an RPC packet , throwing
* an exception while dissecting it as such .
*/
rpc_succeeded = TRUE ;
}
ENDTRY ;
return rpc_succeeded ;
}
int
dissect_rpc_fragment ( tvbuff_t * tvb , int offset , packet_info * pinfo ,
proto_tree * tree , rec_dissector_t dissector , gboolean is_heur ,
2003-04-21 08:13:18 +00:00
int proto , int ett , gboolean defragment , gboolean first_pdu )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
{
2005-04-25 16:54:18 +00:00
struct tcpinfo * tcpinfo ;
guint32 seq ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
guint32 rpc_rm ;
2005-07-09 00:53:17 +00:00
volatile guint32 len ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
gint32 seglen ;
gint tvb_len , tvb_reported_len ;
tvbuff_t * frag_tvb ;
gboolean rpc_succeeded ;
gboolean save_fragmented ;
rpc_fragment_key old_rfk , * rfk , * new_rfk ;
conversation_t * conversation ;
fragment_data * ipfd_head ;
tvbuff_t * rec_tvb ;
2005-04-25 16:54:18 +00:00
if ( pinfo = = NULL | | pinfo - > private_data = = NULL ) {
return 0 ;
}
tcpinfo = pinfo - > private_data ;
if ( tcpinfo = = NULL ) {
return 0 ;
}
seq = tcpinfo - > seq + offset ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
/*
* Get the record mark .
*/
if ( ! tvb_bytes_exist ( tvb , offset , 4 ) ) {
/*
* XXX - we should somehow arrange to handle
* a record mark split across TCP segments .
*/
return 0 ; /* not enough to tell if it's valid */
}
rpc_rm = tvb_get_ntohl ( tvb , offset ) ;
len = rpc_rm & RPC_RM_FRAGLEN ;
/*
* Do TCP desegmentation , if enabled .
*
2003-08-25 10:17:38 +00:00
* reject fragments bigger than this preference setting .
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
* This is arbitrary , but should at least prevent
* some crashes from either packets with really
* large RPC - over - TCP fragments or from stuff that ' s
* not really valid for this protocol .
*/
2003-08-25 10:17:38 +00:00
if ( len > max_rpc_tcp_pdu_size )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
return 0 ; /* pretend it's not valid */
if ( rpc_desegment ) {
seglen = tvb_length_remaining ( tvb , offset + 4 ) ;
2005-07-09 00:53:17 +00:00
if ( ( gint ) len > seglen & & pinfo - > can_desegment ) {
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
/*
* This frame doesn ' t have all of the
* data for this message , but we can do
* reassembly on it .
*
* If this is a heuristic dissector , just
* return 0 - we don ' t want to try to get
* more data , as that ' s too likely to cause
* us to misidentify this as valid .
*
2003-09-03 07:11:13 +00:00
* XXX - this means that we won ' t
* recognize the first fragment of a
* multi - fragment RPC operation unless
* we ' ve already identified this
* conversation as being an RPC
* conversation ( and thus aren ' t running
* heuristically ) - that would be a problem
* if , for example , the first segment were
* the beginning of a large NFS WRITE .
*
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
* If this isn ' t a heuristic dissector ,
* we ' ve already identified this conversation
* as containing data for this protocol , as we
* saw valid data in previous frames . Try to
* get more data .
*/
if ( is_heur )
return 0 ; /* not valid */
else {
pinfo - > desegment_offset = offset ;
pinfo - > desegment_len = len - seglen ;
2003-12-28 12:43:40 +00:00
return - ( ( gint32 ) pinfo - > desegment_len ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
}
}
}
len + = 4 ; /* include record mark */
tvb_len = tvb_length_remaining ( tvb , offset ) ;
tvb_reported_len = tvb_reported_length_remaining ( tvb , offset ) ;
2005-07-09 00:53:17 +00:00
if ( tvb_len > ( gint ) len )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
tvb_len = len ;
2005-07-09 00:53:17 +00:00
if ( tvb_reported_len > ( gint ) len )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
tvb_reported_len = len ;
frag_tvb = tvb_new_subset ( tvb , offset , tvb_len ,
tvb_reported_len ) ;
/*
* If we ' re not defragmenting , just hand this to the
* disssector .
*/
if ( ! defragment ) {
/*
* This is the first fragment we ' ve seen , and it ' s also
* the last fragment ; that means the record wasn ' t
* fragmented . Hand the dissector the tvbuff for the
* fragment as the tvbuff for the record .
*/
rec_tvb = frag_tvb ;
ipfd_head = NULL ;
/*
* Mark this as fragmented , so if somebody throws an
* exception , we don ' t report it as a malformed frame .
*/
save_fragmented = pinfo - > fragmented ;
pinfo - > fragmented = TRUE ;
rpc_succeeded = call_message_dissector ( tvb , rec_tvb , pinfo ,
2003-04-21 08:13:18 +00:00
tree , frag_tvb , dissector , ipfd_head , rpc_rm , first_pdu ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
pinfo - > fragmented = save_fragmented ;
if ( ! rpc_succeeded )
return 0 ; /* not RPC */
return len ;
}
/*
* First , we check to see if this fragment is part of a record
* that we ' re in the process of defragmenting .
*
* The key is the conversation ID for the conversation to which
* the packet belongs and the current sequence number .
* We must first find the conversation and , if we don ' t find
* one , create it . We know this is running over TCP , so the
* conversation should not wildcard either address or port .
*/
2005-02-02 20:07:03 +00:00
conversation = find_conversation ( pinfo - > fd - > num , & pinfo - > src , & pinfo - > dst ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
pinfo - > ptype , pinfo - > srcport , pinfo - > destport , 0 ) ;
if ( conversation = = NULL ) {
/*
* It ' s not part of any conversation - create a new one .
*/
2005-02-02 20:07:03 +00:00
conversation = conversation_new ( pinfo - > fd - > num , & pinfo - > src , & pinfo - > dst ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
pinfo - > ptype , pinfo - > srcport , pinfo - > destport , 0 ) ;
}
old_rfk . conv_id = conversation - > index ;
old_rfk . seq = seq ;
rfk = g_hash_table_lookup ( rpc_reassembly_table , & old_rfk ) ;
if ( rfk = = NULL ) {
/*
* This fragment was not found in our table , so it doesn ' t
* contain a continuation of a higher - level PDU .
* Is it the last fragment ?
*/
if ( ! ( rpc_rm & RPC_RM_LASTFRAG ) ) {
/*
* This isn ' t the last fragment , so we don ' t
* have the complete record .
*
* It ' s the first fragment we ' ve seen , so if
* it ' s truly the first fragment of the record ,
* and it has enough data , the dissector can at
* least check whether it looks like a valid
* message , as it contains the start of the
* message .
*
* The dissector should not dissect anything
* if the " last fragment " flag isn ' t set in
* the record marker , so it shouldn ' t throw
* an exception .
*/
if ( ! ( * dissector ) ( frag_tvb , pinfo , tree , frag_tvb ,
2003-04-21 08:13:18 +00:00
NULL , TRUE , rpc_rm , first_pdu ) )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
return 0 ; /* not valid */
/*
* OK , now start defragmentation with that
* fragment . Add this fragment , and set up
* next packet / sequence number as well .
*
* We must remember this fragment .
*/
2005-08-13 01:29:31 +00:00
rfk = se_alloc ( sizeof ( rpc_fragment_key ) ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
rfk - > conv_id = conversation - > index ;
rfk - > seq = seq ;
rfk - > offset = 0 ;
rfk - > start_seq = seq ;
g_hash_table_insert ( rpc_reassembly_table , rfk , rfk ) ;
/*
* Start defragmentation .
*/
2003-04-20 00:27:29 +00:00
ipfd_head = fragment_add_multiple_ok ( tvb , offset + 4 ,
pinfo , rfk - > start_seq , rpc_fragment_table ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
rfk - > offset , len - 4 , TRUE ) ;
/*
* Make sure that defragmentation isn ' t complete ;
* it shouldn ' t be , as this is the first fragment
* we ' ve seen , and the " last fragment " bit wasn ' t
* set on it .
*/
2005-08-08 09:52:59 +00:00
if ( ipfd_head = = NULL ) {
2005-08-13 01:29:31 +00:00
new_rfk = se_alloc ( sizeof ( rpc_fragment_key ) ) ;
2005-08-08 09:52:59 +00:00
new_rfk - > conv_id = rfk - > conv_id ;
new_rfk - > seq = seq + len ;
new_rfk - > offset = rfk - > offset + len - 4 ;
new_rfk - > start_seq = rfk - > start_seq ;
g_hash_table_insert ( rpc_reassembly_table , new_rfk ,
new_rfk ) ;
2005-10-17 18:56:27 +00:00
2005-08-08 09:52:59 +00:00
/*
* This is part of a fragmented record ,
* but it ' s not the first part .
* Show it as a record marker plus data , under
* a top - level tree for this protocol .
*/
make_frag_tree ( frag_tvb , tree , proto , ett , rpc_rm ) ;
2005-10-17 18:56:27 +00:00
2005-08-08 09:52:59 +00:00
/*
* No more processing need be done , as we don ' t
* have a complete record .
*/
return len ;
} else {
/* oddly, we have a first fragment, not marked as last,
* but which the defragmenter thinks is complete .
* So rather than creating a fragment reassembly tree ,
* we simply throw away the partial fragment structure
* and fall though to our " sole fragment " processing below .
2005-10-17 18:56:27 +00:00
*/
2005-08-08 09:52:59 +00:00
}
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
}
/*
* This is the first fragment we ' ve seen , and it ' s also
* the last fragment ; that means the record wasn ' t
* fragmented . Hand the dissector the tvbuff for the
* fragment as the tvbuff for the record .
*/
rec_tvb = frag_tvb ;
ipfd_head = NULL ;
} else {
/*
* OK , this fragment was found , which means it continues
* a record . This means we must defragment it .
* Add it to the defragmentation lists .
*/
2003-04-20 00:27:29 +00:00
ipfd_head = fragment_add_multiple_ok ( tvb , offset + 4 , pinfo ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
rfk - > start_seq , rpc_fragment_table ,
rfk - > offset , len - 4 , ! ( rpc_rm & RPC_RM_LASTFRAG ) ) ;
if ( ipfd_head = = NULL ) {
/*
2003-04-20 00:27:29 +00:00
* fragment_add_multiple_ok ( ) returned NULL .
* This means that defragmentation is not
* completed yet .
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
*
* We must add an entry to the hash table with
* the sequence number following this fragment
* as the starting sequence number , so that when
* we see that fragment we ' ll find that entry .
*
* XXX - as TCP stream data is not currently
* guaranteed to be provided in order to dissectors ,
* RPC fragments aren ' t guaranteed to be provided
* in order , either .
*/
2005-08-13 01:29:31 +00:00
new_rfk = se_alloc ( sizeof ( rpc_fragment_key ) ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
new_rfk - > conv_id = rfk - > conv_id ;
new_rfk - > seq = seq + len ;
new_rfk - > offset = rfk - > offset + len - 4 ;
new_rfk - > start_seq = rfk - > start_seq ;
g_hash_table_insert ( rpc_reassembly_table , new_rfk ,
new_rfk ) ;
/*
* This is part of a fragmented record ,
* but it ' s not the first part .
* Show it as a record marker plus data , under
* a top - level tree for this protocol ,
* but don ' t hand it to the dissector
*/
make_frag_tree ( frag_tvb , tree , proto , ett , rpc_rm ) ;
/*
* No more processing need be done , as we don ' t
* have a complete record .
*/
return len ;
}
/*
* It ' s completely defragmented .
*
* We only call subdissector for the last fragment .
* XXX - this assumes in - order delivery of RPC
* fragments , which requires in - order delivery of TCP
* segments .
*/
if ( ! ( rpc_rm & RPC_RM_LASTFRAG ) ) {
/*
* Well , it ' s defragmented , but this isn ' t
* the last fragment ; this probably means
* this isn ' t the first pass , so we don ' t
* need to start defragmentation .
*
* This is part of a fragmented record ,
* but it ' s not the first part .
* Show it as a record marker plus data , under
* a top - level tree for this protocol ,
* but don ' t show it to the dissector .
*/
make_frag_tree ( frag_tvb , tree , proto , ett , rpc_rm ) ;
/*
* No more processing need be done , as we
* only disssect the data with the last
* fragment .
*/
return len ;
}
/*
* OK , this is the last segment .
* Create a tvbuff for the defragmented
* record .
*/
/*
* Create a new TVB structure for
* defragmented data .
*/
rec_tvb = tvb_new_real_data ( ipfd_head - > data ,
ipfd_head - > datalen , ipfd_head - > datalen ) ;
/*
* Add this tvb as a child to the original
* one .
*/
tvb_set_child_real_data_tvbuff ( tvb , rec_tvb ) ;
/*
* Add defragmented data to the data source list .
*/
2002-06-04 07:03:57 +00:00
add_new_data_source ( pinfo , rec_tvb , " Defragmented " ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
}
/*
* We have something to hand to the RPC message
* dissector .
*/
if ( ! call_message_dissector ( tvb , rec_tvb , pinfo , tree ,
2003-04-21 08:13:18 +00:00
frag_tvb , dissector , ipfd_head , rpc_rm , first_pdu ) )
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
return 0 ; /* not RPC */
return len ;
2005-08-08 09:52:59 +00:00
} /* end of dissect_rpc_fragment() */
/**
* Scans tvb , starting at given offset , to see if we can find
* what looks like a valid RPC - over - TCP reply header .
2005-10-17 18:56:27 +00:00
*
2005-08-08 09:52:59 +00:00
* @ param tvb Buffer to inspect for RPC reply header .
* @ param offset Offset to begin search of tvb at .
2005-10-17 18:56:27 +00:00
*
2005-08-08 09:52:59 +00:00
* @ return - 1 if no reply header found , else offset to start of header
* ( i . e . , to the RPC record mark field ) .
*/
2005-08-14 23:25:20 +00:00
static int
2005-08-08 09:52:59 +00:00
find_rpc_over_tcp_reply_start ( tvbuff_t * tvb , int offset )
{
/*
* Looking for partial header sequence . From beginning of
* stream - style header , including " record mark " , full ONC - RPC
* looks like :
* BE int32 record mark ( rfc 1831 sec . 10 )
* ? int32 XID ( rfc 1831 sec . 8 )
* BE int32 msg_type ( ibid sec . 8 , call = 0 , reply = 1 )
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Then reply - specific fields are
* BE int32 reply_stat ( ibid , accept = 0 , deny = 1 )
*
* Then , assuming accepted ,
* opaque_auth
* BE int32 auth_flavor ( ibid , none = 0 )
* BE int32 ? auth_len ( ibid , none = 0 )
*
* BE int32 accept_stat ( ibid , success = 0 , errs are 1. .5 in rpc v2 )
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Or , call - specific fields are
* BE int32 rpc_vers ( rfc 1831 sec 8 , always = = 2 )
* BE int32 prog ( NFS = = 0001 86 A3 )
* BE int32 prog_ver ( NFS v2 / 3 = = 2 or 3 )
* BE int32 proc_id ( NFS , < = 256 ? ? ? )
* opaque_auth
* . . .
*/
/* Initially, we search only for something matching the template
* of a successful reply with no auth verifier .
* Our first qualification test is search for a string of zero bytes ,
* corresponding the four guint32 values
* reply_stat
* auth_flavor
* auth_len
* accept_stat
*
* If this string of zeros matches , then we go back and check the
* preceding msg_type and record_mark fields .
*/
const gint cbZeroTail = 4 * 4 ; /* four guint32s of zeros */
const gint ibPatternStart = 3 * 4 ; /* offset of zero fill from reply start */
const guint8 * pbWholeBuf ; /* all of tvb, from offset onwards */
const int NoMatch = - 1 ;
gint ibSearchStart ; /* offset of search start, in case of false hits. */
const guint8 * pbBuf ;
gint cbInBuf ; /* bytes in tvb, from offset onwards */
guint32 ulMsgType ;
guint32 ulRecMark ;
int i ;
2005-10-17 18:56:27 +00:00
2005-08-08 09:52:59 +00:00
cbInBuf = tvb_reported_length_remaining ( tvb , offset ) ;
/* start search at first possible location */
ibSearchStart = ibPatternStart ;
if ( cbInBuf < ( cbZeroTail + ibSearchStart ) ) {
/* nothing to search, so claim no RPC */
return ( NoMatch ) ;
}
pbWholeBuf = tvb_get_ptr ( tvb , offset , cbInBuf ) ;
if ( pbWholeBuf = = NULL ) {
/* probably never take this, as get_ptr seems to assert */
return ( NoMatch ) ;
}
while ( ( cbInBuf - ibSearchStart ) > cbZeroTail ) {
/* First test for long tail of zeros, starting at the back.
* A failure lets us skip the maximum possible buffer amount .
*/
pbBuf = pbWholeBuf + ibSearchStart + cbZeroTail - 1 ;
for ( i = cbZeroTail ; i > 0 ; i - - )
{
if ( * pbBuf ! = 0 )
{
/* match failure. Since we need N contiguous zeros,
* we can increment next match start so zero testing
* begins right after this failure spot .
*/
ibSearchStart + = i ;
pbBuf = NULL ;
break ;
}
pbBuf - - ;
}
if ( pbBuf = = NULL ) {
continue ;
}
/* got a match in zero-fill region, verify reply ID and
* record mark fields */
ulMsgType = pntohl ( pbWholeBuf + ibSearchStart - 4 ) ;
ulRecMark = pntohl ( pbWholeBuf + ibSearchStart - ibPatternStart ) ;
if ( ( ulMsgType = = RPC_REPLY ) & &
( ( ulRecMark & ~ 0x80000000 ) < = ( unsigned ) max_rpc_tcp_pdu_size ) ) {
/* looks ok, try dissect */
return ( offset + ibSearchStart - ibPatternStart ) ;
}
/* no match yet, nor egregious miss either. Inch along to next try */
ibSearchStart + + ;
}
return ( NoMatch ) ;
} /* end of find_rpc_over_tcp_reply_start() */
/**
* Scans tvb for what looks like a valid RPC call / reply header .
* If found , calls standard dissect_rpc_fragment ( ) logic to digest
* the ( hopefully valid ) fragment .
*
* With any luck , one invocation of this will be sufficient to get
* us back in alignment with the stream , and no further calls to
* this routine will be needed for a given conversation . As if . : - )
*
* Can return :
* Same as dissect_rpc_fragment ( ) . Will return zero ( no frame )
* if no valid RPC header is found .
*/
2005-08-14 23:25:20 +00:00
static int
2005-08-08 09:52:59 +00:00
find_and_dissect_rpc_fragment ( tvbuff_t * tvb , int offset , packet_info * pinfo ,
proto_tree * tree , rec_dissector_t dissector ,
gboolean is_heur ,
int proto , int ett , gboolean defragment )
{
int offReply ;
int len ;
offReply = find_rpc_over_tcp_reply_start ( tvb , offset ) ;
if ( offReply < 0 ) {
/* could search for request, but not needed (or testable) thus far */
return ( 0 ) ; /* claim no RPC */
}
len = dissect_rpc_fragment ( tvb , offReply ,
pinfo , tree ,
dissector , is_heur , proto , ett ,
defragment ,
TRUE /* force first-pdu state */ ) ;
/* misses are reported as-is */
if ( len = = 0 )
{
return ( 0 ) ;
}
/* returning a non-zero length, correct it to reflect the extra offset
* we found necessary
*/
if ( len > 0 ) {
len + = offReply - offset ;
}
else {
/* negative length seems to only be used as a flag,
* don ' t mess it up until found necessary
*/
/* len -= offReply - offset; */
}
return ( len ) ;
} /* end of find_and_dissect_rpc_fragment */
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
2001-09-13 07:56:53 +00:00
/*
* Can return :
*
* NEED_MORE_DATA , if we don ' t have enough data to dissect anything ;
*
* IS_RPC , if we dissected at least one message in its entirety
* as RPC ;
*
* IS_NOT_RPC , if we found no RPC message .
*/
typedef enum {
NEED_MORE_DATA ,
IS_RPC ,
IS_NOT_RPC
} rpc_tcp_return_t ;
static rpc_tcp_return_t
dissect_rpc_tcp_common ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ,
gboolean is_heur )
{
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
int offset = 0 ;
gboolean saw_rpc = FALSE ;
2003-04-21 08:13:18 +00:00
gboolean first_pdu = TRUE ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
int len ;
2001-09-13 07:56:53 +00:00
while ( tvb_reported_length_remaining ( tvb , offset ) ! = 0 ) {
/*
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
* Process this fragment .
2001-09-13 07:56:53 +00:00
*/
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
len = dissect_rpc_fragment ( tvb , offset , pinfo , tree ,
dissect_rpc_message , is_heur , proto_rpc , ett_rpc ,
2003-04-21 08:13:18 +00:00
rpc_defragment , first_pdu ) ;
2005-08-08 09:52:59 +00:00
if ( ( len = = 0 ) & & first_pdu & & rpc_find_fragment_start ) {
/*
* Try discarding some leading bytes from tvb , on assumption
* that we are looking at the middle of a stream - based transfer
*/
len = find_and_dissect_rpc_fragment ( tvb , offset , pinfo , tree ,
dissect_rpc_message , is_heur , proto_rpc , ett_rpc ,
rpc_defragment ) ;
}
2003-04-21 08:13:18 +00:00
first_pdu = FALSE ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
if ( len < 0 ) {
2001-09-13 07:56:53 +00:00
/*
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
* We need more data from the TCP stream for
* this fragment .
2001-09-13 07:56:53 +00:00
*/
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
return NEED_MORE_DATA ;
2002-01-07 00:59:26 +00:00
}
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
if ( len = = 0 ) {
2002-01-10 08:06:25 +00:00
/*
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
* It ' s not RPC . Stop processing .
2002-01-10 08:06:25 +00:00
*/
break ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
}
2003-04-23 10:31:38 +00:00
/* PDU tracking
If the length indicates that the PDU continues beyond
the end of this tvb , then tell TCP about it so that it
knows where the next PDU starts .
This is to help TCP detect when PDUs are not aligned to
segment boundaries and allow it to find RPC headers
that starts in the middle of a TCP segment .
*/
if ( ! pinfo - > fd - > flags . visited ) {
if ( len > tvb_reported_length_remaining ( tvb , offset ) ) {
pinfo - > want_pdu_tracking = 2 ;
pinfo - > bytes_until_next_pdu = len - tvb_reported_length_remaining ( tvb , offset ) ;
}
}
2001-09-13 07:56:53 +00:00
offset + = len ;
saw_rpc = TRUE ;
}
return saw_rpc ? IS_RPC : IS_NOT_RPC ;
}
static gboolean
dissect_rpc_tcp_heur ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree )
{
switch ( dissect_rpc_tcp_common ( tvb , pinfo , tree , TRUE ) ) {
case IS_RPC :
return TRUE ;
case IS_NOT_RPC :
return FALSE ;
default :
/* "Can't happen" */
2005-06-10 18:28:22 +00:00
DISSECTOR_ASSERT_NOT_REACHED ( ) ;
2001-09-13 07:56:53 +00:00
return FALSE ;
}
}
static void
dissect_rpc_tcp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree )
{
if ( dissect_rpc_tcp_common ( tvb , pinfo , tree , FALSE ) = = IS_NOT_RPC )
2001-09-12 08:46:39 +00:00
dissect_rpc_continuation ( tvb , pinfo , tree ) ;
2001-09-12 08:13:33 +00:00
}
1999-11-19 13:09:56 +00:00
Provide a general mechanism by which dissectors can register "init"
routines, which are called before a dissection pass is made over all the
packets in a capture - the "init" routine would clear out any state
information that needs to be initialized before such a dissection pass.
Make the NCP, SMB, AFS, and ONC RPC dissectors register their "init"
routines with that mechanism, have the code that reads in a capture file
call the routine that calls all registered "init" routines rather than
calling a wired-in set of "init" routines, and also have the code that
runs a filtering or colorizing pass over all the packets call that
routine, as a filtering or colorizing pass is a dissection pass.
Have the ONC RPC "init" routine zero out the table of RPC calls, so that
it completely erases any state from the previous dissection pass (so
that, for example, if you run a filtering pass, it doesn't mark any
non-duplicate packets as duplicates because it remembers them from the
previous pass).
svn path=/trunk/; revision=1050
1999-11-17 21:58:33 +00:00
/* Discard any state we've saved. */
static void
1999-10-29 01:11:23 +00:00
rpc_init_protocol ( void )
{
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
if ( rpc_reassembly_table ! = NULL ) {
g_hash_table_destroy ( rpc_reassembly_table ) ;
rpc_reassembly_table = NULL ;
}
2001-01-18 00:13:18 +00:00
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
rpc_reassembly_table = g_hash_table_new ( rpc_fragment_hash ,
rpc_fragment_equal ) ;
fragment_table_init ( & rpc_fragment_table ) ;
1999-10-29 01:11:23 +00:00
}
/* will be called once from register.c at startup time */
void
proto_register_rpc ( void )
{
1999-11-15 14:57:38 +00:00
static hf_register_info hf [ ] = {
2002-12-19 02:58:53 +00:00
{ & hf_rpc_reqframe , {
" Request Frame " , " rpc.reqframe " , FT_FRAMENUM , BASE_NONE ,
NULL , 0 , " Request Frame " , HFILL } } ,
{ & hf_rpc_repframe , {
" Reply Frame " , " rpc.repframe " , FT_FRAMENUM , BASE_NONE ,
NULL , 0 , " Reply Frame " , HFILL } } ,
1999-11-19 13:09:56 +00:00
{ & hf_rpc_lastfrag , {
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
" Last Fragment " , " rpc.lastfrag " , FT_BOOLEAN , 32 ,
& yesno , RPC_RM_LASTFRAG , " Last Fragment " , HFILL } } ,
1999-11-19 13:09:56 +00:00
{ & hf_rpc_fraglen , {
" Fragment Length " , " rpc.fraglen " , FT_UINT32 , BASE_DEC ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
NULL , RPC_RM_FRAGLEN , " Fragment Length " , HFILL } } ,
1999-11-15 14:57:38 +00:00
{ & hf_rpc_xid , {
" XID " , " rpc.xid " , FT_UINT32 , BASE_HEX ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " XID " , HFILL } } ,
1999-11-15 14:57:38 +00:00
{ & hf_rpc_msgtype , {
1999-11-15 17:16:51 +00:00
" Message Type " , " rpc.msgtyp " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_msg_type ) , 0 , " Message Type " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_state_reply , {
" Reply State " , " rpc.replystat " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_reply_state ) , 0 , " Reply State " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_state_accept , {
" Accept State " , " rpc.state_accept " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_accept_state ) , 0 , " Accept State " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_state_reject , {
" Reject State " , " rpc.state_reject " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_reject_state ) , 0 , " Reject State " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_state_auth , {
" Auth State " , " rpc.state_auth " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_auth_state ) , 0 , " Auth State " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_version , {
" RPC Version " , " rpc.version " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " RPC Version " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_version_min , {
2002-08-28 21:04:11 +00:00
" RPC Version (Minimum) " , " rpc.version.min " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Program Version (Minimum) " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_version_max , {
2002-08-28 21:04:11 +00:00
" RPC Version (Maximum) " , " rpc.version.max " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " RPC Version (Maximum) " , HFILL } } ,
1999-11-15 14:57:38 +00:00
{ & hf_rpc_program , {
1999-11-15 17:16:51 +00:00
" Program " , " rpc.program " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " Program " , HFILL } } ,
1999-11-15 14:57:38 +00:00
{ & hf_rpc_programversion , {
2002-08-28 21:04:11 +00:00
" Program Version " , " rpc.programversion " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Program Version " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_programversion_min , {
2002-08-28 21:04:11 +00:00
" Program Version (Minimum) " , " rpc.programversion.min " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Program Version (Minimum) " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_programversion_max , {
2002-08-28 21:04:11 +00:00
" Program Version (Maximum) " , " rpc.programversion.max " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Program Version (Maximum) " , HFILL } } ,
1999-11-15 14:57:38 +00:00
{ & hf_rpc_procedure , {
1999-11-15 17:16:51 +00:00
" Procedure " , " rpc.procedure " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " Procedure " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_auth_flavor , {
" Flavor " , " rpc.auth.flavor " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_auth_flavor ) , 0 , " Flavor " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_auth_length , {
" Length " , " rpc.auth.length " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " Length " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_auth_stamp , {
" Stamp " , " rpc.auth.stamp " , FT_UINT32 , BASE_HEX ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " Stamp " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_auth_uid , {
" UID " , " rpc.auth.uid " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " UID " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_auth_gid , {
" GID " , " rpc.auth.gid " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " GID " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_v , {
" GSS Version " , " rpc.authgss.version " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " GSS Version " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_proc , {
" GSS Procedure " , " rpc.authgss.procedure " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , VALS ( rpc_authgss_proc ) , 0 , " GSS Procedure " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_seq , {
" GSS Sequence Number " , " rpc.authgss.seqnum " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " GSS Sequence Number " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_svc , {
" GSS Service " , " rpc.authgss.service " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , VALS ( rpc_authgss_svc ) , 0 , " GSS Service " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_ctx , {
" GSS Context " , " rpc.authgss.context " , FT_BYTES ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " GSS Context " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_major , {
" GSS Major Status " , " rpc.authgss.major " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " GSS Major Status " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_minor , {
" GSS Minor Status " , " rpc.authgss.minor " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " GSS Minor Status " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_window , {
" GSS Sequence Window " , " rpc.authgss.window " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " GSS Sequence Window " , HFILL } } ,
2002-08-22 20:22:22 +00:00
{ & hf_rpc_authgss_token_length , {
" GSS Token Length " , " rpc.authgss.token_length " , FT_UINT32 ,
BASE_DEC , NULL , 0 , " GSS Token Length " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_data_length , {
" Length " , " rpc.authgss.data.length " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Length " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_data , {
" GSS Data " , " rpc.authgss.data " , FT_BYTES ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " GSS Data " , HFILL } } ,
2000-07-17 20:34:00 +00:00
{ & hf_rpc_authgss_checksum , {
" GSS Checksum " , " rpc.authgss.checksum " , FT_BYTES ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " GSS Checksum " , HFILL } } ,
2003-05-02 21:58:23 +00:00
{ & hf_rpc_authgssapi_v , {
" AUTH_GSSAPI Version " , " rpc.authgssapi.version " ,
FT_UINT32 , BASE_DEC , NULL , 0 , " AUTH_GSSAPI Version " ,
HFILL } } ,
{ & hf_rpc_authgssapi_msg , {
" AUTH_GSSAPI Message " , " rpc.authgssapi.message " ,
FT_BOOLEAN , BASE_NONE , & yesno , 0 , " AUTH_GSSAPI Message " ,
HFILL } } ,
{ & hf_rpc_authgssapi_msgv , {
" Msg Version " , " rpc.authgssapi.msgversion " ,
FT_UINT32 , BASE_DEC , NULL , 0 , " Msg Version " ,
HFILL } } ,
{ & hf_rpc_authgssapi_handle , {
" Client Handle " , " rpc.authgssapi.handle " ,
FT_BYTES , BASE_HEX , NULL , 0 , " Client Handle " , HFILL } } ,
{ & hf_rpc_authgssapi_isn , {
" Signed ISN " , " rpc.authgssapi.isn " ,
FT_BYTES , BASE_HEX , NULL , 0 , " Signed ISN " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_namekind , {
" Namekind " , " rpc.authdes.namekind " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
VALS ( rpc_authdes_namekind ) , 0 , " Namekind " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_netname , {
" Netname " , " rpc.authdes.netname " , FT_STRING ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Netname " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_convkey , {
" Conversation Key (encrypted) " , " rpc.authdes.convkey " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " Conversation Key (encrypted) " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_window , {
" Window (encrypted) " , " rpc.authdes.window " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " Windows (encrypted) " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_nickname , {
2002-08-28 21:04:11 +00:00
" Nickname " , " rpc.authdes.nickname " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " Nickname " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_timestamp , {
" Timestamp (encrypted) " , " rpc.authdes.timestamp " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " Timestamp (encrypted) " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_windowverf , {
" Window verifier (encrypted) " , " rpc.authdes.windowverf " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " Window verifier (encrypted) " , HFILL } } ,
2001-05-25 20:13:04 +00:00
{ & hf_rpc_authdes_timeverf , {
" Timestamp verifier (encrypted) " , " rpc.authdes.timeverf " , FT_UINT32 ,
2001-06-18 02:18:27 +00:00
BASE_HEX , NULL , 0 , " Timestamp verifier (encrypted) " , HFILL } } ,
1999-11-15 17:16:51 +00:00
{ & hf_rpc_auth_machinename , {
2002-08-28 21:04:11 +00:00
" Machine Name " , " rpc.auth.machinename " , FT_STRING ,
2001-06-18 02:18:27 +00:00
BASE_DEC , NULL , 0 , " Machine Name " , HFILL } } ,
1999-12-14 11:43:59 +00:00
{ & hf_rpc_dup , {
2003-07-22 11:51:20 +00:00
" Duplicate Call/Reply " , " rpc.dup " , FT_NONE , BASE_NONE ,
NULL , 0 , " Duplicate Call/Reply " , HFILL } } ,
1999-12-14 11:43:59 +00:00
{ & hf_rpc_call_dup , {
2003-07-29 07:30:58 +00:00
" Duplicate to the call in " , " rpc.call.dup " , FT_FRAMENUM , BASE_DEC ,
2003-07-22 11:51:20 +00:00
NULL , 0 , " This is a duplicate to the call in frame " , HFILL } } ,
1999-12-14 11:43:59 +00:00
{ & hf_rpc_reply_dup , {
2003-07-29 07:30:58 +00:00
" Duplicate to the reply in " , " rpc.reply.dup " , FT_FRAMENUM , BASE_DEC ,
2003-07-22 11:51:20 +00:00
NULL , 0 , " This is a duplicate to the reply in frame " , HFILL } } ,
2000-03-09 12:09:53 +00:00
{ & hf_rpc_value_follows , {
" Value Follows " , " rpc.value_follows " , FT_BOOLEAN , BASE_NONE ,
2001-06-18 02:18:27 +00:00
& yesno , 0 , " Value Follows " , HFILL } } ,
2001-05-07 20:36:39 +00:00
{ & hf_rpc_array_len , {
" num " , " rpc.array.len " , FT_UINT32 , BASE_DEC ,
2001-06-18 02:18:27 +00:00
NULL , 0 , " Length of RPC array " , HFILL } } ,
2001-12-28 20:18:45 +00:00
{ & hf_rpc_time , {
" Time from request " , " rpc.time " , FT_RELATIVE_TIME , BASE_NONE ,
NULL , 0 , " Time between Request and Reply for ONC-RPC calls " , HFILL } } ,
2002-06-05 11:32:14 +00:00
{ & hf_rpc_fragment_overlap ,
{ " Fragment overlap " , " rpc.fragment.overlap " , FT_BOOLEAN , BASE_NONE , NULL , 0x0 ,
" Fragment overlaps with other fragments " , HFILL } } ,
{ & hf_rpc_fragment_overlap_conflict ,
{ " Conflicting data in fragment overlap " , " rpc.fragment.overlap.conflict " , FT_BOOLEAN , BASE_NONE , NULL , 0x0 ,
" Overlapping fragments contained conflicting data " , HFILL } } ,
{ & hf_rpc_fragment_multiple_tails ,
{ " Multiple tail fragments found " , " rpc.fragment.multipletails " , FT_BOOLEAN , BASE_NONE , NULL , 0x0 ,
" Several tails were found when defragmenting the packet " , HFILL } } ,
{ & hf_rpc_fragment_too_long_fragment ,
{ " Fragment too long " , " rpc.fragment.toolongfragment " , FT_BOOLEAN , BASE_NONE , NULL , 0x0 ,
" Fragment contained data past end of packet " , HFILL } } ,
{ & hf_rpc_fragment_error ,
2002-12-31 07:49:14 +00:00
{ " Defragmentation error " , " rpc.fragment.error " , FT_FRAMENUM , BASE_NONE , NULL , 0x0 ,
2002-06-05 11:32:14 +00:00
" Defragmentation error due to illegal fragments " , HFILL } } ,
{ & hf_rpc_fragment ,
2002-12-31 07:49:14 +00:00
{ " RPC Fragment " , " rpc.fragment " , FT_FRAMENUM , BASE_NONE , NULL , 0x0 ,
2002-06-05 11:32:14 +00:00
" RPC Fragment " , HFILL } } ,
{ & hf_rpc_fragments ,
{ " RPC Fragments " , " rpc.fragments " , FT_NONE , BASE_NONE , NULL , 0x0 ,
" RPC Fragments " , HFILL } } ,
1999-11-15 14:57:38 +00:00
} ;
1999-11-16 11:44:20 +00:00
static gint * ett [ ] = {
& ett_rpc ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
& ett_rpc_fragments ,
2002-06-05 11:32:14 +00:00
& ett_rpc_fragment ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
& ett_rpc_fraghdr ,
1999-11-16 11:44:20 +00:00
& ett_rpc_string ,
& ett_rpc_cred ,
& ett_rpc_verf ,
& ett_rpc_gids ,
2002-08-22 20:22:22 +00:00
& ett_rpc_gss_token ,
2001-08-30 18:33:30 +00:00
& ett_rpc_gss_data ,
2001-05-07 20:36:39 +00:00
& ett_rpc_array ,
2003-05-02 21:58:23 +00:00
& ett_rpc_authgssapi_msg ,
2004-04-03 00:29:08 +00:00
& ett_rpc_unknown_program ,
1999-11-16 11:44:20 +00:00
} ;
2001-09-13 07:56:53 +00:00
module_t * rpc_module ;
1999-11-15 14:57:38 +00:00
2001-01-03 06:56:03 +00:00
proto_rpc = proto_register_protocol ( " Remote Procedure Call " ,
" RPC " , " rpc " ) ;
2004-04-03 00:29:08 +00:00
/* this is a dummy dissector for all those unknown rpc programs */
1999-11-15 14:57:38 +00:00
proto_register_field_array ( proto_rpc , hf , array_length ( hf ) ) ;
1999-11-16 11:44:20 +00:00
proto_register_subtree_array ( ett , array_length ( ett ) ) ;
Provide a general mechanism by which dissectors can register "init"
routines, which are called before a dissection pass is made over all the
packets in a capture - the "init" routine would clear out any state
information that needs to be initialized before such a dissection pass.
Make the NCP, SMB, AFS, and ONC RPC dissectors register their "init"
routines with that mechanism, have the code that reads in a capture file
call the routine that calls all registered "init" routines rather than
calling a wired-in set of "init" routines, and also have the code that
runs a filtering or colorizing pass over all the packets call that
routine, as a filtering or colorizing pass is a dissection pass.
Have the ONC RPC "init" routine zero out the table of RPC calls, so that
it completely erases any state from the previous dissection pass (so
that, for example, if you run a filtering pass, it doesn't mark any
non-duplicate packets as duplicates because it remembers them from the
previous pass).
svn path=/trunk/; revision=1050
1999-11-17 21:58:33 +00:00
register_init_routine ( & rpc_init_protocol ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
2001-09-13 07:56:53 +00:00
rpc_module = prefs_register_protocol ( proto_rpc , NULL ) ;
prefs_register_bool_preference ( rpc_module , " desegment_rpc_over_tcp " ,
2004-08-21 09:02:52 +00:00
" Reassemble RPC over TCP messages \n spanning multiple TCP segments " ,
" Whether the RPC dissector should reassemble messages spanning multiple TCP segments. "
" To use this option, you must also enable \" Allow subdissectors to reassemble TCP streams \" in the TCP protocol settings. " ,
2001-09-13 07:56:53 +00:00
& rpc_desegment ) ;
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
prefs_register_bool_preference ( rpc_module , " defragment_rpc_over_tcp " ,
2004-08-21 09:02:52 +00:00
" Reassemble fragmented RPC-over-TCP messages " ,
" Whether the RPC dissector should defragment RPC-over-TCP messages. " ,
Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.
Show the RPC-over-TCP fragment header as a tree with bitfields below it.
Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.
Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).
When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.
Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled. Also, when we free
them, set the pointers to them to null, so we don't double-free them.
Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.
svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
& rpc_defragment ) ;
2000-04-04 06:46:41 +00:00
2003-08-25 10:17:38 +00:00
prefs_register_uint_preference ( rpc_module , " max_tcp_pdu_size " , " Maximum size of a RPC-over-TCP PDU " ,
" Set the maximum size of RPCoverTCP PDUs. "
" If the size field of the record marker is larger "
2004-08-21 09:02:52 +00:00
" than this value it will not be considered a valid RPC PDU. " ,
2003-08-25 10:17:38 +00:00
10 , & max_rpc_tcp_pdu_size ) ;
2004-04-03 00:29:08 +00:00
prefs_register_bool_preference ( rpc_module , " dissect_unknown_programs " ,
" Dissect unknown RPC program numbers " ,
2006-05-21 04:49:01 +00:00
" 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. " ,
2004-04-03 00:29:08 +00:00
& rpc_dissect_unknown_programs ) ;
2005-08-08 09:52:59 +00:00
prefs_register_bool_preference ( rpc_module , " find_fragment_start " ,
" Attempt to locate start-of-fragment in partial RPC-over-TCP captures " ,
" 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. " ,
& rpc_find_fragment_start ) ;
2002-05-09 12:10:06 +00:00
register_dissector ( " rpc " , dissect_rpc , proto_rpc ) ;
2002-05-11 18:55:22 +00:00
rpc_handle = find_dissector ( " rpc " ) ;
2002-05-09 12:10:06 +00:00
register_dissector ( " rpc-tcp " , dissect_rpc_tcp , proto_rpc ) ;
2002-05-11 18:55:22 +00:00
rpc_tcp_handle = find_dissector ( " rpc-tcp " ) ;
2002-09-04 09:40:29 +00:00
rpc_tap = register_tap ( " rpc " ) ;
2002-05-09 12:10:06 +00:00
2000-04-04 06:46:41 +00:00
/*
* Init the hash tables . Dissectors for RPC protocols must
* have a " handoff registration " routine that registers the
* protocol with RPC ; they must not do it in their protocol
* registration routine , as their protocol registration
* routine might be called before this routine is called and
* thus might be called before the hash tables are initialized ,
* but it ' s guaranteed that all protocol registration routines
* will be called before any handoff registration routines
* are called .
*/
rpc_progs = g_hash_table_new ( rpc_prog_hash , rpc_prog_equal ) ;
rpc_procs = g_hash_table_new ( rpc_proc_hash , rpc_proc_equal ) ;
1999-10-29 01:11:23 +00:00
}
2000-07-14 12:55:58 +00:00
void
proto_reg_handoff_rpc ( void )
{
2003-04-16 12:15:06 +00:00
dissector_handle_t rpc_tcp_handle ;
dissector_handle_t rpc_udp_handle ;
/* tcp/udp port 111 is used by portmapper which is an onc-rpc service.
we register onc - rpc on this port so that we can choose RPC in
2003-04-21 08:13:18 +00:00
the list offered by DecodeAs , and so that traffic to or from
port 111 from or to a higher - numbered port is dissected as RPC
even if there ' s a dissector registered on the other port ( it ' s
probably RPC traffic from some randomly - chosen port that happens
to match some port for which we have a dissector )
2003-04-16 12:15:06 +00:00
*/
rpc_tcp_handle = create_dissector_handle ( dissect_rpc_tcp , proto_rpc ) ;
dissector_add ( " tcp.port " , 111 , rpc_tcp_handle ) ;
rpc_udp_handle = create_dissector_handle ( dissect_rpc , proto_rpc ) ;
dissector_add ( " udp.port " , 111 , rpc_udp_handle ) ;
2001-09-13 07:56:53 +00:00
heur_dissector_add ( " tcp " , dissect_rpc_tcp_heur , proto_rpc ) ;
2001-09-12 08:13:33 +00:00
heur_dissector_add ( " udp " , dissect_rpc_heur , proto_rpc ) ;
2002-08-22 20:22:22 +00:00
gssapi_handle = find_dissector ( " gssapi " ) ;
2001-11-26 04:52:51 +00:00
data_handle = find_dissector ( " data " ) ;
2000-07-14 12:55:58 +00:00
}