1998-11-18 03:04:25 +00:00
|
|
|
/* packet-giop.c
|
|
|
|
* Routines for CORBA GIOP/IIOP packet disassembly
|
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* Initial Code by,
|
2003-01-26 19:35:31 +00:00
|
|
|
* Laurent Deniel <laurent.deniel@free.fr>
|
2003-02-13 01:23:37 +00:00
|
|
|
* Craig Rodrigues <rodrigc@attbi.com>
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* GIOP API extensions by,
|
|
|
|
* Frank Singleton <frank.singleton@ericsson.com>
|
|
|
|
* Trevor Shepherd <eustrsd@am1.ericsson.se>
|
1998-11-18 03:04:25 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1998-11-18 03:04:25 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1998-11-18 03:04:25 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-11-18 03:04:25 +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
|
|
|
*
|
1998-11-18 03:04:25 +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
|
|
|
*
|
1998-11-18 03:04:25 +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.
|
|
|
|
*/
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: -- FS
|
|
|
|
* 1. heuristic giop dissector table [started]
|
|
|
|
* 2. GUI options, see 20
|
2002-08-28 21:04:11 +00:00
|
|
|
* 3. Remove unneccessary reply_status in heuristic dissector calls (now
|
2001-06-18 05:27:18 +00:00
|
|
|
* part of MessageHeader) [done]
|
|
|
|
* 4. get_CDR_xxx should be passed an alignment offset value
|
|
|
|
* rather than GIOP_HEADER_SIZE, as alignment can also change in a
|
|
|
|
* octet stream when eg: encapsulation is used [done]
|
|
|
|
* 5. GIOP users should eventually get there own tvbuff, and
|
|
|
|
* not rely on the GIOP tvbuff, more robust
|
2002-08-28 21:04:11 +00:00
|
|
|
* 6. get_CDR_string,wchar,wstring etc should handle different
|
2001-06-18 05:27:18 +00:00
|
|
|
* GIOP versions [started]
|
|
|
|
* 7. Fix situation where req_id is not unique in a logfile [done, use FN/MFN, needs improving.]
|
|
|
|
*
|
|
|
|
* 8. Keep request_1_2 in step with request_1_1 [started]
|
|
|
|
* 9. Explicit module name dissection [done]
|
|
|
|
* 10. Decode IOR and put in a useful struct [IOR decode started]
|
|
|
|
* 11. Fix encapsulation of IOR etc and boundary [done]
|
|
|
|
* 12. handle get_CDR_typeCode() [started]
|
|
|
|
* 13. Handle different IOR profiles
|
|
|
|
* 14. Change printable_string to RETURN a new string, not to modify the old.
|
|
|
|
* or, new function, make_printable_string [done, make_printable_string]
|
|
|
|
*
|
|
|
|
* 15. Handle "TCKind", and forget about eg: enum translation to symbolic values
|
|
|
|
* otherwise need knowledge of sub dissectors data - YUK [done]
|
|
|
|
* 16. Handle multiple RepoId representations, besides IDL:Echo:1.0 (see 13.)
|
|
|
|
* 17. Pass subset of RepoID to explicit dissector.
|
|
|
|
* eg : If IDL:Mod1/Mod2/Int3:1.0 then pass "Mod1/Mode2/Int3" to sub dissector[done]
|
|
|
|
* 18. Better hashing algorithms
|
|
|
|
* 19. Handle hash collision properly .
|
|
|
|
* 20. Allow users to paste a stringified IOR into the GUI, and tie it
|
|
|
|
* to a sub_dissector.
|
|
|
|
* 21. Add complete_request_packet_list and complete_reply_packet_hash.[done]
|
|
|
|
* 22. Handle case where users click in any order, AND try and match
|
|
|
|
* REPLY msg to the correct REQUEST msg when we have a request_id collision.[done]
|
|
|
|
* 23. Clean up memory management for all those g_malloc's etc
|
|
|
|
* 24. register_giop_user_module could return a key for every distinct Module/Interface
|
|
|
|
* the sub_dissector uses. So, instead of strcmp()'s when handling the
|
|
|
|
* namespace of an operation, we could have a lookup table instead.
|
|
|
|
* 25. A few typedefs in the right place.
|
|
|
|
* 26 Improve handling of gchar * and use const gchar * where possible.
|
|
|
|
* 27. Read/write IOR etc to/from file, allows objkey hash to be built from
|
|
|
|
* external data [read done, write incomplete]
|
|
|
|
* 28. Call sub dissector only if tvb_offset_exists(). [Done, this is checked
|
|
|
|
* inside try_explicit_giop_dissector() ]
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
|
|
|
* 29. Make add/delete routine for objkey hash as it may be useful when say reading
|
2001-06-18 05:27:18 +00:00
|
|
|
* stringified IOR's from a file to add them to our hash. ie: There are other ways
|
|
|
|
* to populate our object key hash besides REPLY's to RESOLVE(request) [done]
|
|
|
|
*
|
|
|
|
* 30. Add routine to encode/decode stringified IOR's [decode done]
|
|
|
|
* 31. Add routine to read IOR's from file [done]
|
|
|
|
* 32. TypeCode -none-, needs decoding.
|
|
|
|
* 33. Complete dissect_data_for_typecode.
|
|
|
|
* 34. For complex TypeCodes need to check final offset against original offset + sequence length.
|
|
|
|
* 35. Update REQUEST/REPLY 1_2 according to IDL (eg; ServiceContextList etc).
|
2002-08-28 21:04:11 +00:00
|
|
|
* 36. Adding decode_ServiceContextList, incomplete.
|
2008-12-17 17:23:37 +00:00
|
|
|
* 37. Helper functions should not ALWAYS rely on header to find current endianness. It should
|
2001-06-18 05:27:18 +00:00
|
|
|
* be passed from user, eg Use stream_is_big_endian. [started]
|
|
|
|
* 38. Remove unwanted/unused function parameters, see decode_IOR [started]
|
2002-08-28 21:04:11 +00:00
|
|
|
* 40. Add sequence <IOP::TaggedComponent> components to IIOP IOR profile. Perhaps
|
2001-06-18 05:27:18 +00:00
|
|
|
* decode_IOP_TaggedComponents as a helper function. [done - NOT helper]
|
|
|
|
*
|
|
|
|
* 41. Make important field searchable from Message header. ie: Remove add_text_
|
|
|
|
* 42. Use sub-tree for decode_ServiceContextList, looks better.
|
|
|
|
* 43. dissect_reply_body, no exception dissector calls
|
|
|
|
* - call subdiss directly, as we already have handle.
|
|
|
|
* - add repoid to heuristic call also.
|
|
|
|
*
|
|
|
|
* 44. typedef using xxx_t in .h file.
|
|
|
|
* 45. Subdissectors should not be passed MessageHeader to find endianness and
|
|
|
|
* version, they should be passed directly ?
|
|
|
|
* 46. get_CDR_wchar and wstring need wide chars decoded (just dumped in
|
|
|
|
* any readable form at present, not handled well at all, suggestions welcome -- FS
|
|
|
|
* 47. Change ...add_text to ...add_xxx (ie use hf fields).
|
|
|
|
*
|
|
|
|
* 48. BUG - file load with a GIOP filter set, causes the FN/MFN data struct to be
|
|
|
|
* not initiated properly. Hit "Reload" as a workaround, til I fix this -- FS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Intended Decode strategy:
|
|
|
|
* =========================
|
|
|
|
*
|
|
|
|
* Initial Pass
|
|
|
|
* ------------
|
|
|
|
* REQUEST: objkey -> Repo_ID -> Module/Interface -> giop_sub_handle_t
|
|
|
|
* and populate complete_request_packet_hash
|
|
|
|
*
|
|
|
|
* REPLY: FN -> MFN (via complete_reply_packet_hash) = Request FN -> giop_sub_handle_t
|
|
|
|
*
|
|
|
|
* User Clicks
|
|
|
|
* -----------
|
|
|
|
*
|
|
|
|
* REQUEST: FN -> giop_sub_handle_t directly (via complete_request_packet_hash)
|
|
|
|
*
|
|
|
|
* REPLY: FN -> MFN (via complete_reply_packet_hash) = Request FN -> giop_sub_handle_t
|
|
|
|
* (via complete_request_packet_hash
|
|
|
|
*
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Limitations.
|
2001-06-18 05:27:18 +00:00
|
|
|
* ============
|
|
|
|
*
|
|
|
|
* 1. Request_ID's are unique only per connection.
|
|
|
|
*
|
|
|
|
* 2. You must be monitoring the network when the client does
|
|
|
|
* a REQUEST(resolve), otherwise I have no knowledge of the
|
2002-08-28 21:04:11 +00:00
|
|
|
* association between object_key and REPOID. I could talk to
|
2001-06-18 05:27:18 +00:00
|
|
|
* a Nameserver, but then I would start "generating" packets.
|
|
|
|
* This is probably not a good thing for a protocol analyser.
|
|
|
|
* Also, how could I decode logfiles offline.
|
|
|
|
*
|
|
|
|
* TODO -- Read stringified IORs from an input file.[done]
|
|
|
|
*
|
|
|
|
* 3. User clicks (REQUEST) is currently handle the same as
|
|
|
|
* the initial pass handling.
|
|
|
|
*
|
|
|
|
* ie: objkey -> Repo_ID -> Module/Interface -> giop_sub_handle_t
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Important Data Structures:
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* giop_module_hash
|
2001-06-18 05:27:18 +00:00
|
|
|
* ----------------
|
|
|
|
*
|
|
|
|
* This is a hash table that maps IDL Module/Interface Names (Key)
|
|
|
|
* to sub_dissector handles, giop_sub_handle_t. It is populated
|
|
|
|
* by subdissectors, via register_giop_user_module(). This
|
|
|
|
* table is used when we have a REPOID, and explicitly wish to
|
|
|
|
* call the subdissector that has registered responsibility for
|
|
|
|
* that IDL module/interface.
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* giop_sub_list
|
|
|
|
* -------------
|
|
|
|
*
|
|
|
|
* This singly linked list is used to hold entries for
|
|
|
|
* heuristic based subdissectors. It is populated by sub_dissectors
|
|
|
|
* wishing to be called via heuristic mechanisms. They do this
|
|
|
|
* via the register_giop_user() function.
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* giop_objkey_hash
|
|
|
|
* ----------------
|
|
|
|
*
|
|
|
|
* This hash table maps object_key's (key) onto REPOID's (val).
|
|
|
|
* Once a client has REQUEST(resolve) an object , it knows about
|
|
|
|
* an object (interface) via its object_key (see IOR). So in order to follow
|
|
|
|
* packets that contain an object_key only, and to be able to forward it
|
|
|
|
* to the correct explicit subdissector, we need this table.
|
|
|
|
*
|
|
|
|
* So, I listen in on REQUEST(resolve) messages between client and
|
|
|
|
* Nameserver, and store the respones (REPLY/Objkey,Repo_ID) here.
|
|
|
|
*
|
|
|
|
* Also, stringified IOR's can be read from a file "IOR.txt" and used
|
|
|
|
* to populate this hash also.
|
|
|
|
*
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Other Data structures
|
2001-06-18 05:27:18 +00:00
|
|
|
* =======================
|
|
|
|
*
|
|
|
|
* These structures have been added to minimise the possibility
|
|
|
|
* of incorrectly interpreted packets when people click all
|
|
|
|
* over the place, in no particular order, when the request_id's are
|
|
|
|
* not unique as captured. If all request_is'd are unique, as captured, then
|
|
|
|
* we would not have to deal with this problem.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* When the logfile or packets are initially being processed, I will
|
|
|
|
* build 2 structures. The intent is to be able to map a REPLY message
|
|
|
|
* back to the most recent REQUEST message with the same Request_ID
|
|
|
|
* (TODO and matching port and IP address ??)
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* Abbrevs:
|
|
|
|
* --------
|
|
|
|
*
|
|
|
|
* FN - Frame Number
|
|
|
|
* MFN - Matching Frame Number
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* complete_request_packet_list
|
|
|
|
* ----------------------------
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* This is a list that contains ALL the FN's that are REQUEST's, along with
|
2001-06-18 05:27:18 +00:00
|
|
|
* operation,request_id and giop_sub_handle_t
|
|
|
|
*
|
|
|
|
* complete_reply_packet_hash
|
|
|
|
* --------------------------
|
|
|
|
*
|
|
|
|
* This is a hash table. It is populated with FN (key) and MFN (val).
|
|
|
|
* This allows me to handle the case, where if you click on any REPLY
|
|
|
|
* message, I can lookup the matching request. This can improve
|
|
|
|
* the match rate between REQUEST and REPLY when people click in
|
2002-08-28 21:04:11 +00:00
|
|
|
* any old fashion, but is NOT foolproof.
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* The algorithm I use to populate this hash during initial pass,
|
2002-08-28 21:04:11 +00:00
|
|
|
* is as follows.
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* If packet is a REPLY, note the reqid, and then traverse backwards
|
|
|
|
* through the complete_request_packet_list from its tail, looking
|
|
|
|
* for a FN that has the same Request_id. Once found, take the found FN
|
|
|
|
* from complete_reply_packet_hash, and insert it into the MFN field
|
|
|
|
* of the complete_reply_packet_hash.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* See TODO for improvements to above algorithm.
|
|
|
|
*
|
|
|
|
* So now when people click on a REQUEST packet, I can call lookup the
|
|
|
|
* giop_sub_handle_t directly from complete_request_packet_list.
|
|
|
|
*
|
|
|
|
* And, when they click on a REPLY, I grab the MFN of this FN from
|
|
|
|
* complete_reply_packet_hash, then look that up in the complete_request_packet_list
|
|
|
|
* and call the sub_dissector directly.
|
|
|
|
*
|
|
|
|
* So, how do I differentiate between the initial processing of incoming
|
|
|
|
* packets, and a user clickin on one ? Good question.
|
|
|
|
*
|
|
|
|
* I leverage the pinfo_fd->flags.visited on a per frame
|
2002-08-28 21:04:11 +00:00
|
|
|
* basis.
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* To quote from the ever helpful development list
|
|
|
|
*
|
|
|
|
* " When a capture file is initially loaded, all "visited" flags
|
2006-05-21 04:49:01 +00:00
|
|
|
* are 0. Wireshark then makes the first pass through file,
|
2001-06-18 05:27:18 +00:00
|
|
|
* sequentially dissecting each packet. After the packet is
|
|
|
|
* dissected the first time, "visited" is 1. (See the end of
|
|
|
|
* dissect_packet() in epan/packet.c; that's the code that
|
|
|
|
* sets "visited" to 1).
|
|
|
|
|
|
|
|
* By the time a user clicks on a packet, "visited" will already
|
2006-05-21 04:49:01 +00:00
|
|
|
* be 1 because Wireshark will have already done its first pass
|
2001-06-18 05:27:18 +00:00
|
|
|
* through the packets.
|
|
|
|
|
|
|
|
* Reload acts just like a normal Close/Open, except that it
|
|
|
|
* doesn't need to ask for a filename. So yes, the reload button
|
|
|
|
* clears the flags and re-dissects the file, just as if the file
|
|
|
|
* had been "opened". "
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <string.h>
|
2001-06-18 05:27:18 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <glib.h>
|
2001-06-18 05:27:18 +00:00
|
|
|
#include <math.h>
|
2001-06-23 19:14:42 +00:00
|
|
|
#ifdef NEED_STRERROR_H
|
2001-06-18 05:27:18 +00:00
|
|
|
#include "strerror.h"
|
2001-06-23 19:14:42 +00:00
|
|
|
#endif
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2004-07-09 23:17:05 +00:00
|
|
|
#include "isprint.h"
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2005-09-01 19:31:48 +00:00
|
|
|
#include <epan/conversation.h>
|
2005-08-12 23:00:01 +00:00
|
|
|
#include <epan/emem.h>
|
2005-09-01 19:31:48 +00:00
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
|
|
|
#include "packet-giop.h"
|
2009-03-03 19:51:08 +00:00
|
|
|
#include "packet-ziop.h"
|
2005-09-01 19:31:48 +00:00
|
|
|
#include "packet-tcp.h"
|
2008-05-22 15:46:27 +00:00
|
|
|
#include <wsutil/file_util.h>
|
2008-02-21 22:11:08 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2001-06-27 20:38:56 +00:00
|
|
|
* Set to 1 for DEBUG output - TODO make this a runtime option
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEBUG 0
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* ------------------------------------------------------------------------------------------+
|
2001-06-18 05:27:18 +00:00
|
|
|
* Private Helper function Declarations
|
|
|
|
* ------------------------------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static void decode_IIOP_IOR_profile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
2008-12-17 17:23:37 +00:00
|
|
|
guint32 boundary, gboolean new_endianness, gchar *repobuf,
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean store_flag);
|
|
|
|
|
2002-05-02 19:39:05 +00:00
|
|
|
static void decode_ServiceContextList(tvbuff_t *tvb, proto_tree *tree, int *offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean stream_is_be, guint32 boundary);
|
|
|
|
|
|
|
|
static void decode_TaggedProfile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
|
|
|
guint32 boundary, gboolean stream_is_big_endian, gchar *repobuf);
|
|
|
|
|
|
|
|
static void decode_IOR(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
|
|
|
guint32 boundary, gboolean stream_is_big_endian );
|
|
|
|
|
|
|
|
static void decode_SystemExceptionReplyBody (tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
|
|
|
gboolean stream_is_big_endian,
|
|
|
|
guint32 boundary);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_objref_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2002-05-02 19:39:05 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_struct_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_union_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header );
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
static void dissect_tk_enum_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2002-05-02 19:39:05 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_sequence_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_array_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_alias_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_except_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_value_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_value_box_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_native_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_abstract_interface_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_typecode_string_param(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean new_stream_is_big_endian, guint32 new_boundary, int hf_id );
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_data_for_typecode(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header, guint32 data_type );
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* ------------------------------------------------------------------------------------------+
|
2001-06-18 05:27:18 +00:00
|
|
|
* Data/Variables/Structs
|
|
|
|
* ------------------------------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
static int proto_giop = -1;
|
2010-02-01 18:16:25 +00:00
|
|
|
static int hf_giop_message_flags = -1;
|
|
|
|
static int hf_giop_message_flags_ziop_enabled = -1;
|
|
|
|
static int hf_giop_message_flags_ziop_supported = -1;
|
|
|
|
static int hf_giop_message_flags_fragment = -1;
|
|
|
|
static int hf_giop_message_flags_little_endian = -1;
|
1999-10-09 13:31:30 +00:00
|
|
|
static int hf_giop_message_type = -1;
|
|
|
|
static int hf_giop_message_size = -1;
|
2001-06-18 05:27:18 +00:00
|
|
|
static int hf_giop_repoid = -1;
|
2004-11-24 21:26:52 +00:00
|
|
|
static int hf_giop_req_id = -1;
|
|
|
|
static int hf_giop_req_operation = -1;
|
2001-06-18 05:27:18 +00:00
|
|
|
static int hf_giop_string_length = -1;
|
|
|
|
static int hf_giop_sequence_length = -1;
|
|
|
|
static int hf_giop_profile_id = -1;
|
|
|
|
static int hf_giop_type_id = -1;
|
|
|
|
static int hf_giop_iiop_v_maj = -1;
|
|
|
|
static int hf_giop_iiop_v_min = -1;
|
2008-12-17 17:23:37 +00:00
|
|
|
static int hf_giop_endianness = -1; /* esp encapsulations */
|
2008-02-21 20:45:09 +00:00
|
|
|
static int hf_giop_compressed = -1;
|
2002-08-28 21:04:11 +00:00
|
|
|
static int hf_giop_IOR_tag = -1;
|
2001-06-18 05:27:18 +00:00
|
|
|
static int hf_giop_IIOP_tag = -1;
|
|
|
|
|
|
|
|
static int hf_giop_TCKind = -1;
|
|
|
|
static int hf_giop_typecode_count = -1;
|
|
|
|
static int hf_giop_typecode_default_used = -1;
|
|
|
|
static int hf_giop_typecode_digits = -1;
|
|
|
|
static int hf_giop_typecode_length = -1;
|
|
|
|
static int hf_giop_typecode_max_length = -1;
|
|
|
|
static int hf_giop_typecode_member_name = -1;
|
|
|
|
static int hf_giop_typecode_name = -1;
|
|
|
|
static int hf_giop_typecode_scale = -1;
|
|
|
|
static int hf_giop_typecode_ValueModifier = -1;
|
|
|
|
static int hf_giop_typecode_Visibility = -1;
|
|
|
|
|
|
|
|
static int hf_giop_type_boolean = -1;
|
|
|
|
static int hf_giop_type_char = -1;
|
|
|
|
static int hf_giop_type_double = -1;
|
|
|
|
static int hf_giop_type_enum = -1;
|
|
|
|
static int hf_giop_type_float = -1;
|
|
|
|
static int hf_giop_type_long = -1;
|
|
|
|
static int hf_giop_type_octet = -1;
|
|
|
|
static int hf_giop_type_short = -1;
|
|
|
|
static int hf_giop_type_string = -1;
|
|
|
|
static int hf_giop_type_ulong = -1;
|
|
|
|
static int hf_giop_type_ushort = -1;
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static int hf_giop_iiop_host = -1;
|
|
|
|
static int hf_giop_iiop_port = -1;
|
2001-06-18 05:27:18 +00:00
|
|
|
static int hf_giop_iop_vscid = -1;
|
|
|
|
static int hf_giop_iop_scid = -1;
|
|
|
|
|
2005-08-11 20:14:41 +00:00
|
|
|
static int hf_giop_reply_status = -1;
|
|
|
|
static int hf_giop_exception_id = -1;
|
2005-09-04 08:53:04 +00:00
|
|
|
static int hf_giop_objekt_key = -1;
|
2005-08-11 20:14:41 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* (sub)Tree declares
|
|
|
|
*/
|
1999-07-29 05:47:07 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint ett_giop = -1;
|
2010-02-01 18:16:25 +00:00
|
|
|
static gint ett_giop_message_flags = -1;
|
2000-11-07 07:46:22 +00:00
|
|
|
static gint ett_giop_reply = -1;
|
|
|
|
static gint ett_giop_request = -1;
|
|
|
|
static gint ett_giop_cancel_request = -1;
|
|
|
|
static gint ett_giop_locate_request = -1;
|
|
|
|
static gint ett_giop_locate_reply = -1;
|
|
|
|
static gint ett_giop_fragment = -1;
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
static gint ett_giop_scl = -1; /* ServiceContextList */
|
2007-03-24 13:46:41 +00:00
|
|
|
static gint ett_giop_scl_st1 = -1;
|
2010-01-18 18:00:23 +00:00
|
|
|
static gint ett_giop_ior = -1; /* IOR */
|
2001-07-03 23:30:01 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
static const int *giop_message_flags[] = {
|
|
|
|
&hf_giop_message_flags_ziop_enabled,
|
|
|
|
&hf_giop_message_flags_ziop_supported,
|
|
|
|
&hf_giop_message_flags_fragment,
|
|
|
|
&hf_giop_message_flags_little_endian,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2001-11-26 04:52:51 +00:00
|
|
|
static dissector_handle_t data_handle;
|
2005-09-01 19:31:48 +00:00
|
|
|
static dissector_handle_t giop_tcp_handle;
|
2010-02-01 18:16:25 +00:00
|
|
|
|
|
|
|
#define GIOP_MESSAGE_FLAGS_ZIOP_ENABLED 0x08
|
|
|
|
#define GIOP_MESSAGE_FLAGS_ZIOP_SUPPORTED 0x04
|
|
|
|
#define GIOP_MESSAGE_FLAGS_FRAGMENT 0x02
|
|
|
|
#define GIOP_MESSAGE_FLAGS_ENDIANNESS 0x01
|
|
|
|
|
2008-12-17 17:23:37 +00:00
|
|
|
/* GIOP endianness */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2008-12-17 17:23:37 +00:00
|
|
|
static const value_string giop_endianness_vals[] = {
|
2001-06-18 05:27:18 +00:00
|
|
|
{ 0x0, "Big Endian" },
|
|
|
|
{ 0x1, "Little Endian" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
2010-02-01 18:16:25 +00:00
|
|
|
|
2008-09-11 19:33:07 +00:00
|
|
|
/*
|
2010-01-18 18:00:23 +00:00
|
|
|
static const value_string sync_scope[] = {
|
|
|
|
{ 0x0, "SYNC_NONE" },
|
|
|
|
{ 0x1, "SYNC_WITH_TRANSPORT"},
|
|
|
|
{ 0x2, "SYNC_WITH_SERVER"},
|
|
|
|
{ 0x3, "SYNC_WITH_TARGET"},
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
2008-09-11 19:33:07 +00:00
|
|
|
Bug fix:
|
|
|
|
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2800
|
|
|
|
http://ethereal.netmirror.org/lists/ethereal-users/200303/msg00135.html
|
|
|
|
*/
|
|
|
|
static const value_string response_flags_vals[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x0, "SyncScope NONE or WITH_TRANSPORT" },
|
|
|
|
{ 0x1, "SyncScope WITH_SERVER"},
|
|
|
|
{ 0x3, "SyncScope WITH_TARGET"},
|
|
|
|
{ 0, NULL}
|
2008-09-11 19:33:07 +00:00
|
|
|
};
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Profile ID's */
|
|
|
|
|
|
|
|
static const value_string profile_id_vals[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x0, "TAG_INTERNET_IOP" },
|
|
|
|
{ 0x1, "TAG_MULTIPLE_COMPONENTS"},
|
|
|
|
{ 0x2, "TAG_SCCP_IOP"},
|
|
|
|
{ 0x3, "TAG_UIPMC"},
|
|
|
|
{ 0, NULL}
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
static const value_string giop_message_types[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x0, "Request" },
|
|
|
|
{ 0x1, "Reply"},
|
|
|
|
{ 0x2, "CancelRequest"},
|
|
|
|
{ 0x3, "LocateRequest"},
|
|
|
|
{ 0x4, "LocateReply"},
|
|
|
|
{ 0x5, "CloseConnection"},
|
|
|
|
{ 0x6, "MessageError"},
|
|
|
|
{ 0x7, "Fragment"},
|
|
|
|
{ 0, NULL}
|
2000-11-07 07:46:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string giop_locate_status_types[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x0, "Unknown Object" },
|
|
|
|
{ 0x1, "Object Here"},
|
|
|
|
{ 0x2, "Object Forward"},
|
|
|
|
{ 0x3, "Object Forward Perm"},
|
|
|
|
{ 0x4, "Loc System Exception"},
|
|
|
|
{ 0x5, "Loc Needs Addressing Mode"},
|
|
|
|
{ 0, NULL }
|
2000-11-07 07:46:22 +00:00
|
|
|
};
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static const value_string tckind_vals[] = {
|
|
|
|
{ 0, "tk_null"},
|
|
|
|
{ 1, "tk_void"},
|
|
|
|
{ 2, "tk_short"},
|
|
|
|
{ 3, "tk_long"},
|
|
|
|
{ 4, "tk_ushort"},
|
|
|
|
{ 5, "tk_ulong"},
|
|
|
|
{ 6, "tk_float"},
|
|
|
|
{ 7, "tk_double"},
|
|
|
|
{ 8, "tk_boolean"},
|
|
|
|
{ 9, "tk_char"},
|
|
|
|
{ 10, "tk_octet"},
|
|
|
|
{ 11, "tk_any"},
|
|
|
|
{ 12, "tk_TypeCode"},
|
|
|
|
{ 13, "tk_Principal"},
|
|
|
|
{ 14, "tk_objref"},
|
|
|
|
{ 15, "tk_struct"},
|
|
|
|
{ 16, "tk_union"},
|
|
|
|
{ 17, "tk_enum"},
|
|
|
|
{ 18, "tk_string"},
|
|
|
|
{ 19, "tk_sequence"},
|
|
|
|
{ 20, "tk_array"},
|
|
|
|
{ 21, "tk_alias"},
|
|
|
|
{ 22, "tk_except"},
|
|
|
|
{ 23, "tk_longlong"},
|
|
|
|
{ 24, "tk_ulonglong"},
|
|
|
|
{ 25, "tk_longdouble"},
|
|
|
|
{ 26, "tk_wchar"},
|
|
|
|
{ 27, "tk_wstring"},
|
|
|
|
{ 28, "tk_fixed"},
|
|
|
|
{ 29, "tk_value"},
|
|
|
|
{ 30, "tk_value_box"},
|
|
|
|
{ 31, "tk_native"},
|
|
|
|
{ 32, "tk_abstract_interface"},
|
2002-08-28 21:04:11 +00:00
|
|
|
{ 0, NULL }
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
/*
|
|
|
|
* These values are taken from the CORBA 3.0.2 standard,
|
|
|
|
* section 13.7.1 "Standard Service Contexts".
|
|
|
|
*/
|
|
|
|
static const guint32 max_service_context_id = 0x10;
|
|
|
|
static const value_string service_context_ids[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x00, "TransactionService" },
|
|
|
|
{ 0x01, "CodeSets"},
|
|
|
|
{ 0x02, "ChainBypassCheck"},
|
|
|
|
{ 0x03, "ChainBypassInfo"},
|
|
|
|
{ 0x04, "LogicalThreadId"},
|
|
|
|
{ 0x05, "BI_DIR_IIOP"},
|
|
|
|
{ 0x06, "SendingContextRunTime"},
|
|
|
|
{ 0x07, "INVOCATION_POLICIES"},
|
|
|
|
{ 0x08, "FORWARDED_IDENTITY"},
|
|
|
|
{ 0x09, "UnknownExceptionInfo"},
|
|
|
|
{ 0x0a, "RTCorbaPriority"},
|
|
|
|
{ 0x0b, "RTCorbaPriorityRange"},
|
|
|
|
{ 0x0c, "FT_GROUP_VERSION"},
|
|
|
|
{ 0x0d, "FT_REQUEST"},
|
|
|
|
{ 0x0e, "ExceptionDetailMessage"},
|
|
|
|
{ 0x0f, "SecurityAttributeService"},
|
|
|
|
{ 0x10, "ActivityService"},
|
|
|
|
{ 0, NULL }
|
2003-02-13 01:23:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
/*
|
2001-06-18 05:27:18 +00:00
|
|
|
* TAGS for IOR Profiles
|
1998-11-18 03:04:25 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* Chapter 13 Corba 2.4.2
|
1998-11-18 03:04:25 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
#define IOP_TAG_INTERNET_IOP 0
|
|
|
|
#define IOP_TAG_MULTIPLE_COMPONENTS 1
|
|
|
|
|
|
|
|
|
|
|
|
/* Max Supported versions */
|
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
static const guint GIOP_MAJOR = 1;
|
|
|
|
static const guint GIOP_MINOR = 2;
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static const value_string reply_status_types[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ NO_EXCEPTION, "No Exception" } ,
|
|
|
|
{ USER_EXCEPTION, "User Exception" } ,
|
|
|
|
{ SYSTEM_EXCEPTION, "System Exception" } ,
|
|
|
|
{ LOCATION_FORWARD, "Location Forward" } ,
|
|
|
|
{ LOCATION_FORWARD_PERM, "Location Forward Perm" } ,
|
|
|
|
{ NEEDS_ADDRESSING_MODE, "Needs Addressing Mode" } ,
|
|
|
|
{ 0, NULL }
|
2000-11-07 07:46:22 +00:00
|
|
|
};
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
typedef enum LocateStatusType
|
|
|
|
{
|
|
|
|
UNKNOWN_OBJECT,
|
|
|
|
OBJECT_HERE,
|
|
|
|
OBJECT_FORWARD,
|
2001-02-26 22:19:12 +00:00
|
|
|
OBJECT_FORWARD_PERM, /* new value for GIOP 1.2 */
|
|
|
|
LOC_SYSTEM_EXCEPTION, /* new value for GIOP 1.2 */
|
|
|
|
LOC_NEEDS_ADDRESSING_MODE /* new value for GIOP 1.2 */
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
LocateStatusType_t;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
typedef struct LocateReplyHeader
|
|
|
|
{
|
|
|
|
guint32 request_id;
|
|
|
|
guint32 locate_status;
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
LocateReplyHeader_t;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* DATA - complete_request_list
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
2000-07-27 17:11:44 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
static GList *giop_complete_request_list = NULL;
|
2000-07-27 17:11:44 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct comp_req_list_entry {
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 fn; /* frame number */
|
|
|
|
gchar * operation; /* echo echoString */
|
2001-06-18 05:27:18 +00:00
|
|
|
giop_sub_handle_t *subh; /* handle to sub dissector */
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 reqid; /* request id */
|
|
|
|
gchar * repoid; /* repository ID */
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
typedef struct comp_req_list_entry comp_req_list_entry_t;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DATA - complete_reply_hash
|
|
|
|
*
|
|
|
|
* Maps reply FN to request MFN
|
2000-11-07 07:46:22 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct complete_reply_hash_key {
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 fn; /* reply frame number */
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct complete_reply_hash_val {
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 mfn; /* matching frame number (request) */
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
GHashTable *giop_complete_reply_hash = NULL; /* hash */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DATA - Module Hash stuff to store data from register_giop_user_module
|
|
|
|
*
|
|
|
|
* ie: module (or interface ?) name, and ptr to sub_dissector handle
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* With this knowledge, we can call a sub dissector directly,
|
2001-06-18 05:27:18 +00:00
|
|
|
* by :
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* objkey -> repoid -> sub_dissector via registered module/interface
|
|
|
|
*
|
2000-11-07 07:46:22 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-21 20:45:09 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct giop_module_key {
|
2010-01-18 18:00:23 +00:00
|
|
|
gchar *module; /* module (interface?) name */
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct giop_module_val {
|
|
|
|
giop_sub_handle_t *subh; /* handle to sub dissector */
|
|
|
|
};
|
2000-11-15 20:10:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
GHashTable *giop_module_hash = NULL; /* hash */
|
2000-11-15 20:10:22 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* DATA - GSList to store list of function (dissector) pointers.
|
|
|
|
* for heuristic dissection.
|
|
|
|
*
|
|
|
|
*/
|
2000-11-15 20:10:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static GSList *giop_sub_list = NULL;
|
2000-11-15 20:10:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* DATA - Hash stuff to follow request/reply. This is so if we get a REPLY
|
|
|
|
* to a REQUEST (resolve), we can dump/store the RepoId and Object Key.
|
|
|
|
*
|
|
|
|
* With this knowledge, we can call a sub dissector directly later
|
|
|
|
* by :
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
* objkey -> repoid -> sub_dissector via registered module/interface
|
|
|
|
*
|
|
|
|
* rather than heuristic calls that do not provide operation context.
|
|
|
|
* (unless we pass the RepoID for a given objkey -- hmmm)
|
|
|
|
*
|
2000-11-07 07:46:22 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Interesting operation list, add more if you want to save
|
|
|
|
* interesting data.
|
2000-11-07 07:46:22 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static const char giop_op_resolve[] = "resolve";
|
2007-04-14 14:01:53 +00:00
|
|
|
static const char giop_op_bind_new_context[] _U_ = "bind_new_context";
|
|
|
|
static const char giop_op_bind[] _U_ = "bind";
|
2005-08-11 20:14:41 +00:00
|
|
|
static const char giop_op_is_a[] = "_is_a";
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Enums for interesting local operations, that we may need to monitor
|
|
|
|
* with their subsequent replies
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
enum giop_op_val {
|
2010-01-18 18:00:23 +00:00
|
|
|
request_resolve_op_val, /* REQUEST (resolve) to get RepoID etc*/
|
2001-06-18 05:27:18 +00:00
|
|
|
request_bind_new_context_op_val, /* bind_new_context */
|
2010-01-18 18:00:23 +00:00
|
|
|
request_bind_op_val, /* bind */
|
|
|
|
request_get_INIT_op_val /* finding Nameserver */
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-09 10:50:59 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* hash for mapping object keys onto object namespaces, so
|
|
|
|
* I can call the correct dissector.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Where did I get the IOR from.
|
|
|
|
*/
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
enum ior_src {
|
2010-02-01 18:16:25 +00:00
|
|
|
ior_src_req_res = 0, /* REQUEST (resolve) */
|
|
|
|
ior_src_file /* stringified IOR' in a file */
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
typedef enum ior_src ior_src_t;
|
2000-11-09 10:50:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Enums for my lists and hash's
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
enum collection_data {
|
|
|
|
cd_heuristic_users = 0,
|
|
|
|
cd_module_hash,
|
|
|
|
cd_objkey_hash,
|
|
|
|
cd_complete_request_list,
|
|
|
|
cd_complete_reply_hash
|
|
|
|
};
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
typedef enum collection_data collection_data_t;
|
2000-11-09 10:50:59 +00:00
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct giop_object_key {
|
2010-01-18 18:00:23 +00:00
|
|
|
guint8 *objkey; /* ptr to object key */
|
|
|
|
guint32 objkey_len; /* length */
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
struct giop_object_val {
|
2010-01-18 18:00:23 +00:00
|
|
|
guint8 *repo_id; /* ptr to Repository ID string */
|
|
|
|
ior_src_t src; /* where did Iget this IOR from */
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
GHashTable *giop_objkey_hash = NULL; /* hash */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2005-09-01 19:31:48 +00:00
|
|
|
gboolean giop_desegment = TRUE;
|
2006-04-18 10:04:18 +00:00
|
|
|
static const char *giop_ior_file = "IOR.txt";
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* ------------------------------------------------------------------------------------------+
|
2001-06-18 05:27:18 +00:00
|
|
|
* Private helper functions
|
|
|
|
* ------------------------------------------------------------------------------------------+
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Insert FN,reqid,operation and sub handle in list. DOES not check for duplicates yet.
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static GList *insert_in_comp_req_list(GList *list, guint32 fn, guint32 reqid, gchar * op, giop_sub_handle_t *sh ) {
|
2010-02-01 18:16:25 +00:00
|
|
|
comp_req_list_entry_t * entry;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
entry = se_alloc(sizeof(comp_req_list_entry_t));
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
entry->fn = fn;
|
2001-06-18 05:27:18 +00:00
|
|
|
entry->reqid = reqid;
|
2010-02-01 18:16:25 +00:00
|
|
|
entry->subh = sh;
|
|
|
|
entry->operation = se_strdup(op); /* duplicate operation for storage */
|
|
|
|
entry->repoid = NULL; /* dont have yet */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
return g_list_append (list, entry); /* append */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Used to find an entry with matching Frame Number FN
|
|
|
|
* in the complete_request_list list.
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static comp_req_list_entry_t * find_fn_in_list(guint32 fn) {
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
GList * element; /* entry in list */
|
2001-06-18 05:27:18 +00:00
|
|
|
comp_req_list_entry_t * entry_ptr = NULL;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
element = g_list_last(giop_complete_request_list); /* start from last */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
while(element) { /* valid list entry */
|
|
|
|
entry_ptr = element->data; /* grab data pointer */
|
|
|
|
if (entry_ptr->fn == fn) { /* similar FN */
|
2001-06-18 05:27:18 +00:00
|
|
|
return entry_ptr;
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
element = g_list_previous(element); /* try next previous */
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return NULL; /* no match so return NULL */
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add/update a sub_dissector handle and repoid to a FN entry in the complete_request_list
|
|
|
|
*
|
|
|
|
* Call this when you know a FN and matching giop_sub_handle_t and repoid
|
|
|
|
*
|
|
|
|
* This is done in say, try_explicit_dissector for example.
|
2000-11-07 07:46:22 +00:00
|
|
|
*
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static void add_sub_handle_repoid_to_comp_req_list(guint32 fn, giop_sub_handle_t *sh, gchar *repoid ) {
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
comp_req_list_entry_t * entry = NULL;
|
2010-01-18 18:00:23 +00:00
|
|
|
entry = find_fn_in_list(fn); /* grab FN data entry */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (entry) {
|
2002-08-28 21:04:11 +00:00
|
|
|
entry->subh = sh;
|
2001-06-18 05:27:18 +00:00
|
|
|
entry->repoid = g_strdup(repoid); /* copy and store */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* giop_complete_reply_hash "EQUAL" Functions */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static gint complete_reply_equal_fn(gconstpointer v, gconstpointer w) {
|
2002-12-02 23:43:30 +00:00
|
|
|
const struct complete_reply_hash_key *mk1 = (const struct complete_reply_hash_key *)v;
|
|
|
|
const struct complete_reply_hash_key *mk2 = (const struct complete_reply_hash_key *)w;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (mk1->fn == mk2->fn) {
|
2001-06-18 05:27:18 +00:00
|
|
|
return 1;
|
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return 0; /* found differences */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2000-11-09 10:50:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* giop_complete_reply_hash "HASH" Functions */
|
|
|
|
|
|
|
|
static guint32 complete_reply_hash_fn(gconstpointer v) {
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 val; /* init hash value */
|
2002-12-02 23:43:30 +00:00
|
|
|
const struct complete_reply_hash_key *key = (const struct complete_reply_hash_key *)v;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
val = key->fn; /* simple and unique */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
return val;
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Insert the FN and MFN together in our complete_reply_hash.
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static void insert_in_complete_reply_hash(guint32 fn, guint32 mfn) {
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct complete_reply_hash_key key, *new_key;
|
|
|
|
struct complete_reply_hash_val *val = NULL;
|
|
|
|
|
|
|
|
key.fn = fn;
|
|
|
|
|
|
|
|
val = (struct complete_reply_hash_val *)g_hash_table_lookup(giop_complete_reply_hash, &key);
|
|
|
|
|
|
|
|
if (val) {
|
2010-01-18 18:00:23 +00:00
|
|
|
return; /* FN collision */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2005-08-12 23:00:01 +00:00
|
|
|
new_key = se_alloc(sizeof(struct complete_reply_hash_key));
|
2010-01-18 18:00:23 +00:00
|
|
|
new_key->fn = fn; /* save FN */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2005-08-12 23:00:01 +00:00
|
|
|
val = se_alloc(sizeof(struct complete_reply_hash_val));
|
2010-01-18 18:00:23 +00:00
|
|
|
val->mfn = mfn; /* and MFN */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
g_hash_table_insert(giop_complete_reply_hash, new_key, val);
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Find the MFN values from a given FN key.
|
|
|
|
* Assumes the complete_reply_hash is already populated.
|
2000-11-07 07:46:22 +00:00
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static guint32 get_mfn_from_fn(guint32 fn) {
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct complete_reply_hash_key key;
|
|
|
|
struct complete_reply_hash_val *val = NULL;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 mfn = fn; /* save */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
key.fn = fn;
|
|
|
|
val = (struct complete_reply_hash_val *)g_hash_table_lookup(giop_complete_reply_hash, &key);
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (val) {
|
2010-01-18 18:00:23 +00:00
|
|
|
mfn = val->mfn; /* grab it */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return mfn; /* mfn or fn if not found */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Attempt to find the MFN for this FN, and return it.
|
|
|
|
* Return MFN if found, or just FN if not. This is
|
|
|
|
* only used when we are building
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static guint32 get_mfn_from_fn_and_reqid(guint32 fn, guint32 reqid) {
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
GList * element; /* last entry in list */
|
2001-06-18 05:27:18 +00:00
|
|
|
comp_req_list_entry_t * entry_ptr = NULL;
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Need Some pretty snappy code */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Loop back from current end of complete_request_list looking for */
|
|
|
|
/* a FN with the same reqid -- TODO enhance with port/address checks -- FS */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As this routine is only called during initial pass of data,
|
|
|
|
* and NOT when a user clicks, it is ok to start from Current
|
|
|
|
* end of complete_request_list when searching for a match.
|
|
|
|
* As that list is bing populated in the same order as FN's
|
|
|
|
* are being read.
|
|
|
|
*
|
|
|
|
* Also, can make check for same reqid more detailed, but I start
|
|
|
|
* with reqid. Could add say port or address checks etc later ??
|
|
|
|
*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
element = g_list_last(giop_complete_request_list); /* get last */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
while(element) { /* valid list entry */
|
|
|
|
entry_ptr = element->data; /* grab data pointer */
|
|
|
|
if (entry_ptr->reqid == reqid) { /* similar reqid */
|
|
|
|
return entry_ptr->fn; /* return MFN */
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
element = g_list_previous(element); /* try next previous */
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return fn; /* no match so return FN */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Module Hash "EQUAL" Functions */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static gint giop_hash_module_equal(gconstpointer v, gconstpointer w) {
|
2002-12-02 23:43:30 +00:00
|
|
|
const struct giop_module_key *mk1 = (const struct giop_module_key *)v;
|
|
|
|
const struct giop_module_key *mk2 = (const struct giop_module_key *)w;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-12-02 23:43:30 +00:00
|
|
|
if (strcmp(mk1->module, mk2->module) == 0) {
|
2001-06-18 05:27:18 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return 0; /* found differences */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Module Hash "HASH" Functions */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static guint32 giop_hash_module_hash(gconstpointer v) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
int i,len;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 val = 0; /* init hash value */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2002-12-02 23:43:30 +00:00
|
|
|
const struct giop_module_key *key = (const struct giop_module_key *)v;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Hmm, try this simple hashing scheme for now.
|
|
|
|
* ie: Simple summation, FIX later -- FS
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2009-03-29 12:07:30 +00:00
|
|
|
len = (int)strlen(key->module);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
val += (guint8) key->module[i];
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return val;
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* ------------------------------------------------------------------------------------------+
|
2001-06-18 05:27:18 +00:00
|
|
|
* Public Utility functions
|
|
|
|
* ------------------------------------------------------------------------------------------+
|
|
|
|
*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routine to allow giop users to register their sub dissector function, name, and
|
2001-06-29 20:49:29 +00:00
|
|
|
* IDL module/interface name. Store in giop_module_hash. Also pass along their proto_XXX
|
|
|
|
* value returned from their proto_register_protocol(), so we can enable/disbale it
|
|
|
|
* through the GUI (edit protocols).
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* This is used by try_explicit_giop_dissector() to find the
|
|
|
|
* correct sub-dissector.
|
2000-11-07 07:46:22 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-29 20:49:29 +00:00
|
|
|
void register_giop_user_module(giop_sub_dissector_t *sub, gchar *name, gchar *module, int sub_proto) {
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
struct giop_module_key module_key, *new_module_key;
|
|
|
|
struct giop_module_val *module_val = NULL;
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
module_key.module = module; /* module name */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
module_val = (struct giop_module_val *)g_hash_table_lookup(giop_module_hash, &module_key);
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (module_val) {
|
2010-01-18 18:00:23 +00:00
|
|
|
return; /* module name collision */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* So, passed module name should NOT exist in hash at this point.*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
#if DEBUG
|
2001-06-18 05:27:18 +00:00
|
|
|
printf("giop:register_module: Adding Module %s to module hash \n", module);
|
|
|
|
printf("giop:register_module: Module sub dissector name is %s \n", name);
|
|
|
|
#endif
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2005-08-14 01:48:43 +00:00
|
|
|
new_module_key = g_malloc(sizeof(struct giop_module_key));
|
2001-06-18 05:27:18 +00:00
|
|
|
new_module_key->module = module; /* save Module or interface name from IDL */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-08-14 01:48:43 +00:00
|
|
|
module_val = g_malloc(sizeof(struct giop_module_val));
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
module_val->subh = g_malloc(sizeof (giop_sub_handle_t)); /* init subh */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
module_val->subh->sub_name = name; /* save dissector name */
|
|
|
|
module_val->subh->sub_fn = sub; /* save subdissector*/
|
|
|
|
module_val->subh->sub_proto = find_protocol_by_id(sub_proto); /* save protocol_t for subdissector's protocol */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
g_hash_table_insert(giop_module_hash, new_module_key, module_val);
|
|
|
|
|
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Object Key Hash "EQUAL" Functions */
|
|
|
|
|
|
|
|
static gint giop_hash_objkey_equal(gconstpointer v, gconstpointer w) {
|
2002-12-02 23:43:30 +00:00
|
|
|
const struct giop_object_key *v1 = (const struct giop_object_key *)v;
|
|
|
|
const struct giop_object_key *v2 = (const struct giop_object_key *)w;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if (v1->objkey_len != v2->objkey_len)
|
2010-01-18 18:00:23 +00:00
|
|
|
return 0; /* no match because different length */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
/* Now do a byte comparison */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-12-02 23:43:30 +00:00
|
|
|
if (memcmp(v1->objkey,v2->objkey, v1->objkey_len) == 0) {
|
2010-01-18 18:00:23 +00:00
|
|
|
return 1; /* compares ok */
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:giop_hash_objkey_equal: Objkey's DO NOT match");
|
|
|
|
#endif
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return 0; /* found differences */
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Object Key Hash "HASH" Functions */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static guint32 giop_hash_objkey_hash(gconstpointer v) {
|
2002-12-02 23:43:30 +00:00
|
|
|
const struct giop_object_key *key = (const struct giop_object_key *)v;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-19 18:50:33 +00:00
|
|
|
guint32 i;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 val = 0; /* init hash value */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Hmm, try this simple hashing scheme for now.
|
|
|
|
* ie: Simple summation
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
#if DEBUG
|
|
|
|
printf("giop:hash_objkey: Key length = %u \n", key->objkey_len );
|
|
|
|
#endif
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
for (i=0; i< key->objkey_len; i++) {
|
|
|
|
val += (guint8) key->objkey[i];
|
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return val;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routine to take an object key octet sequence, and length, and ptr to
|
|
|
|
* a (null terminated )repository ID string, and store them in the obect key hash.
|
|
|
|
*
|
|
|
|
* Blindly Inserts even if it does exist, See TODO at top for reason.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void insert_in_objkey_hash(GHashTable *hash, gchar *obj, guint32 len, gchar *repoid, ior_src_t src) {
|
|
|
|
|
|
|
|
struct giop_object_key objkey_key, *new_objkey_key;
|
|
|
|
struct giop_object_val *objkey_val = NULL;
|
|
|
|
|
|
|
|
objkey_key.objkey_len = len; /* length */
|
2010-01-18 18:00:23 +00:00
|
|
|
objkey_key.objkey = obj; /* object key octet sequence */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* Look it up to see if it exists */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
objkey_val = (struct giop_object_val *)g_hash_table_lookup(hash, &objkey_key);
|
|
|
|
|
|
|
|
/* CHANGED -- Same reqid, so abandon old entry */
|
|
|
|
|
|
|
|
if (objkey_val) {
|
|
|
|
g_hash_table_remove(hash, &objkey_key);
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* So, passed key should NOT exist in hash at this point.*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-08-12 23:00:01 +00:00
|
|
|
new_objkey_key = se_alloc(sizeof(struct giop_object_key));
|
2001-06-18 05:27:18 +00:00
|
|
|
new_objkey_key->objkey_len = len; /* save it */
|
2010-02-01 18:16:25 +00:00
|
|
|
new_objkey_key->objkey = (guint8 *) se_memdup(obj,len); /* copy from object and allocate ptr */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-08-12 23:00:01 +00:00
|
|
|
objkey_val = se_alloc(sizeof(struct giop_object_val));
|
2010-02-01 18:16:25 +00:00
|
|
|
objkey_val->repo_id = se_strdup(repoid); /* duplicate and store Respository ID string */
|
|
|
|
objkey_val->src = src; /* where IOR came from */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
#if DEBUG
|
2001-06-18 05:27:18 +00:00
|
|
|
printf("giop: ******* Inserting Objkey with RepoID = %s and key length = %u into hash \n",
|
|
|
|
objkey_val->repo_id, new_objkey_key->objkey_len);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_hash_table_insert(hash, new_objkey_key, objkey_val);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* convert an ascii char representing a hex value,
|
|
|
|
* to a numeric value.
|
|
|
|
*
|
|
|
|
* returns value, or -1 if problem.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gint8 hex_char_to_val(guchar c){
|
|
|
|
gint8 retval ;
|
|
|
|
|
|
|
|
if (!isxdigit(c)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (isdigit(c)) {
|
2010-01-18 18:00:23 +00:00
|
|
|
retval = c - 48; /* convert digit */
|
2001-06-18 05:27:18 +00:00
|
|
|
return retval;
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
c = toupper(c); /* convert to uppercase */
|
2001-06-18 05:27:18 +00:00
|
|
|
if (c >= 'A' && c <= 'F') {
|
|
|
|
retval = c - 55;
|
|
|
|
return retval;
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
else {
|
|
|
|
return -1;
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Convert from stringified IOR of the kind IOR:af4f7e459f....
|
|
|
|
* to an IOR octet sequence.
|
|
|
|
*
|
|
|
|
* User must free buffer.
|
|
|
|
*
|
|
|
|
* Creates a new tvbuff and call decode_IOR with a NULL tree, just to
|
2002-08-28 21:04:11 +00:00
|
|
|
* grab repoid etc for our objkey hash.
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static guint32 string_to_IOR(guchar *in, guint32 in_len, guint8 **out){
|
|
|
|
gint8 tmpval_lsb;
|
|
|
|
gint8 tmpval_msb;
|
2010-01-18 18:00:23 +00:00
|
|
|
gint8 tmpval; /* complete value */
|
2001-06-19 18:50:33 +00:00
|
|
|
guint32 i;
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
*out = g_new0(guint8, in_len); /* allocate buffer */
|
|
|
|
|
|
|
|
if (*out == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip past IOR: and convert character pairs to guint8 */
|
|
|
|
|
|
|
|
for (i=4; i<in_len-1; i+=2) {
|
|
|
|
if ( isxdigit(in[i]) && isxdigit(in[i+1]) ) { /* hex ? */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if ( (tmpval_msb = hex_char_to_val(in[i])) < 0 ) {
|
2010-01-18 18:00:23 +00:00
|
|
|
g_warning("giop: Invalid value in IOR %i \n", tmpval_msb);
|
2001-06-29 20:49:29 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if ( (tmpval_lsb = hex_char_to_val(in[i+1])) < 0 ) {
|
2010-01-18 18:00:23 +00:00
|
|
|
g_warning("giop: Invalid value in IOR %i \n", tmpval_lsb);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
tmpval = tmpval_msb << 4;
|
|
|
|
tmpval += tmpval_lsb;
|
|
|
|
(*out)[(i-4)/2] = (guint8) tmpval;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-09 10:50:59 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
else {
|
|
|
|
/* hmm */
|
|
|
|
break;
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return (i-4)/2; /* length */
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2003-11-26 02:58:12 +00:00
|
|
|
* Simple "get a line" routine, copied from somewhere :)
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2003-11-26 02:58:12 +00:00
|
|
|
static int giop_getline(FILE *fp, gchar *line, int maxlen) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if (fgets(line,maxlen,fp) == NULL)
|
|
|
|
return 0;
|
|
|
|
else
|
2009-03-29 12:07:30 +00:00
|
|
|
return (int)strlen(line);
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-06-18 05:27:18 +00:00
|
|
|
* Read a list of stringified IOR's from a named file, convert to IOR's
|
|
|
|
* and store in object key hash
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2005-07-23 11:41:25 +00:00
|
|
|
static void read_IOR_strings_from_file(const gchar *name, int max_iorlen) {
|
2010-01-18 18:00:23 +00:00
|
|
|
guchar *buf; /* NOTE reused for every line */
|
2001-06-18 05:27:18 +00:00
|
|
|
int len;
|
2010-01-18 18:00:23 +00:00
|
|
|
int ior_val_len; /* length after unstringifying. */
|
2002-08-28 21:04:11 +00:00
|
|
|
FILE *fp;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint8 *out; /* ptr to unstringified IOR */
|
|
|
|
tvbuff_t *tvb; /* temp tvbuff for dissectin IORs */
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 my_offset = 0;
|
2000-11-07 07:46:22 +00:00
|
|
|
gboolean stream_is_big_endian;
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
fp = ws_fopen(name,"r"); /* open read only */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (fp == NULL) {
|
|
|
|
if (errno == EACCES)
|
2006-04-16 23:16:46 +00:00
|
|
|
fprintf(stderr, "Error opening file %s for reading: %s\n", name, strerror(errno));
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
|
|
|
}
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
buf = g_malloc0(max_iorlen+1); /* input buf */
|
2000-11-09 09:15:40 +00:00
|
|
|
|
2003-11-26 02:58:12 +00:00
|
|
|
while ((len = giop_getline(fp,buf,max_iorlen+1)) > 0) {
|
2010-01-18 18:00:23 +00:00
|
|
|
my_offset = 0; /* reset for every IOR read */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
ior_val_len = string_to_IOR(buf,len,&out); /* convert */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if(ior_val_len>0) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/* Combination of tvb_new() and tvb_set_real_data().
|
|
|
|
Can throw ReportedBoundsError.
|
|
|
|
|
|
|
|
XXX - can it throw an exception in this case? If so, we
|
|
|
|
need to catch it and clean up, but we really shouldn't allow
|
|
|
|
it - or "get_CDR_octet()", or "decode_IOR()" - to throw an
|
|
|
|
exception. */
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2002-02-18 01:08:44 +00:00
|
|
|
tvb = tvb_new_real_data(out, ior_val_len, ior_val_len);
|
2000-11-12 03:11:24 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian = !get_CDR_octet(tvb,&my_offset);
|
|
|
|
decode_IOR(tvb, NULL, NULL, &my_offset, 0, stream_is_big_endian);
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
tvb_free(tvb);
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
|
|
|
g_free(out);
|
|
|
|
|
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
|
|
|
}
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
fclose(fp); /* be nice */
|
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
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
g_free(buf);
|
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
|
|
|
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Init routine, setup our request hash stuff, or delete old ref's
|
|
|
|
*
|
|
|
|
* Cannot setup the module hash here as my init() may not be called before
|
|
|
|
* users start registering. So I will move the module_hash stuff to
|
|
|
|
* proto_register_giop, as is done with packet-rpc
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Also, setup our objectkey/repoid hash here.
|
|
|
|
*
|
|
|
|
*/
|
1998-11-18 03:04:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static void giop_init(void) {
|
1998-11-18 03:04:25 +00:00
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Create objkey/repoid hash, use my "equal" and "hash" functions.
|
2010-02-01 18:16:25 +00:00
|
|
|
* Note: keys and values are se_alloc'd so they don't need to be freed.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (giop_objkey_hash)
|
|
|
|
g_hash_table_destroy(giop_objkey_hash);
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Create hash, use my "equal" and "hash" functions.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
giop_objkey_hash = g_hash_table_new(giop_hash_objkey_hash, giop_hash_objkey_equal);
|
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Create complete_reply_hash, use my "equal" and "hash" functions.
|
2010-02-01 18:16:25 +00:00
|
|
|
* Note: keys and values are se_alloc'd so they don't need to be freed.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (giop_complete_reply_hash)
|
|
|
|
g_hash_table_destroy(giop_complete_reply_hash);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create hash, use my "equal" and "hash" functions.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
giop_complete_reply_hash = g_hash_table_new(complete_reply_hash_fn, complete_reply_equal_fn);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
/*
|
|
|
|
* Free giop_complete_request_list (if necessary)
|
|
|
|
* Note: The data elements are se_alloc'd so only the
|
|
|
|
* actual list elements need to be freed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (giop_complete_request_list) {
|
|
|
|
g_list_free(giop_complete_request_list);
|
|
|
|
giop_complete_request_list = NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-18 10:04:18 +00:00
|
|
|
read_IOR_strings_from_file(giop_ior_file, 600);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-06-29 20:49:29 +00:00
|
|
|
* Insert an entry in the GIOP Heuristic User table.
|
2001-06-18 05:27:18 +00:00
|
|
|
* Uses a GList.
|
|
|
|
* Uses giop_sub_handle_t to wrap giop user info.
|
|
|
|
*
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-07-23 11:41:25 +00:00
|
|
|
void register_giop_user(giop_sub_dissector_t *sub, const gchar *name, int sub_proto) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
giop_sub_handle_t *subh;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
subh = g_malloc(sizeof (giop_sub_handle_t));
|
|
|
|
|
|
|
|
subh->sub_name = name;
|
|
|
|
subh->sub_fn = sub;
|
2010-01-18 18:00:23 +00:00
|
|
|
subh->sub_proto = find_protocol_by_id(sub_proto); /* protocol_t for sub dissectors's proto_register_protocol() */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
giop_sub_list = g_slist_append (giop_sub_list, subh);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup an object key in our object key hash, and return the corresponding
|
|
|
|
* Repo Id.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gchar * get_repoid_from_objkey(GHashTable *hash, guint8 *obj, guint32 len) {
|
|
|
|
|
|
|
|
struct giop_object_key objkey_key;
|
|
|
|
struct giop_object_val *objkey_val = NULL;
|
|
|
|
|
|
|
|
objkey_key.objkey_len = len; /* length */
|
2010-01-18 18:00:23 +00:00
|
|
|
objkey_key.objkey = obj; /* object key octet sequence */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* Look it up to see if it exists */
|
|
|
|
|
|
|
|
objkey_val = (struct giop_object_val *)g_hash_table_lookup(hash, &objkey_key);
|
|
|
|
|
|
|
|
if (objkey_val) {
|
|
|
|
#if DEBUG
|
|
|
|
printf("Lookup of object key returns RepoId = %s \n",objkey_val->repo_id );
|
|
|
|
#endif
|
2010-01-18 18:00:23 +00:00
|
|
|
return objkey_val->repo_id; /* found */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
#if DEBUG
|
2001-06-18 05:27:18 +00:00
|
|
|
printf("FAILED Lookup of object key \n" );
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return NULL; /* not found */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Extract top level module/interface from repoid
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* eg from - "IDL:Echo/interface1:1.0"
|
|
|
|
* get "Echo"
|
|
|
|
*
|
|
|
|
* Or, from "IDL:linux.org/Penguin/Teeth:1.0" get
|
|
|
|
* get linux.org/Penguin/Teeth
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* User must free returned ptr after use.
|
|
|
|
*
|
|
|
|
* TODO -- generalize for other Repoid encodings
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gchar * get_modname_from_repoid(gchar *repoid) {
|
|
|
|
|
|
|
|
gchar *modname = NULL;
|
|
|
|
gchar c = 'a';
|
2010-01-18 18:00:23 +00:00
|
|
|
guint8 stop_mod = 0; /* Index of last character of modname in Repoid */
|
|
|
|
guint8 start_mod = 4; /* Index where Module name starts in repoid */
|
2001-06-18 05:27:18 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Must start with IDL: , otherwise I get confused */
|
|
|
|
|
2008-02-21 22:11:08 +00:00
|
|
|
if (g_ascii_strncasecmp("IDL:",repoid,4))
|
2001-06-18 05:27:18 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Looks like a RepoID to me, so get Module or interface name */
|
|
|
|
|
|
|
|
/* TODO -- put some code here to get Module name */
|
|
|
|
|
|
|
|
for(i=4; c != '\0'; i++) {
|
|
|
|
c = repoid[i];
|
2010-01-18 18:00:23 +00:00
|
|
|
stop_mod = i; /* save */
|
|
|
|
if (c == ':' ) /* delimiters */
|
2000-11-07 07:46:22 +00:00
|
|
|
break;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2000-11-07 07:46:22 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Now create a new string based on start and stop and \0 */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
modname = g_strndup(repoid+4, stop_mod - start_mod);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return modname;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-11-07 07:46:22 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* DEBUG CODE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
/*
|
|
|
|
* Display a "module" hash entry
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void display_module_hash(gpointer key, gpointer val, gpointer user_data) {
|
|
|
|
|
|
|
|
struct giop_module_val *mv = (struct giop_module_val *) val;
|
|
|
|
struct giop_module_key *mk = (struct giop_module_key *) key;
|
|
|
|
|
|
|
|
printf("giop:module: Key = (%s) , Val = (%s) \n", mk->module, mv->subh->sub_name);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
}
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Display a "complete_reply " hash entry
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void display_complete_reply_hash(gpointer key, gpointer val, gpointer user_data) {
|
|
|
|
|
|
|
|
struct complete_reply_hash_val *mv = (struct complete_reply_hash_val *) val;
|
|
|
|
struct complete_reply_hash_key *mk = (struct complete_reply_hash_key *) key;
|
|
|
|
|
|
|
|
printf("giop:complete_reply: FN (key) = %8u , MFN (val) = %8u \n", mk->fn, mv->mfn);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display an "objkey" hash entry
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void display_objkey_hash(gpointer key, gpointer val, gpointer user_data) {
|
2001-06-27 20:38:56 +00:00
|
|
|
guint32 i;
|
2001-06-18 05:27:18 +00:00
|
|
|
struct giop_object_val *mv = (struct giop_object_val *) val;
|
|
|
|
struct giop_object_key *mk = (struct giop_object_key *) key;
|
|
|
|
|
|
|
|
|
|
|
|
printf("giop:objkey: Key->objkey_len = %u, Key->objkey ", mk->objkey_len);
|
|
|
|
|
|
|
|
for (i=0; i<mk->objkey_len; i++) {
|
|
|
|
printf("%.2x ", mk->objkey[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If read from file, mark it as such..
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(mv->src == 0) {
|
|
|
|
printf(", Repo ID = %s \n", mv->repo_id);
|
|
|
|
}
|
|
|
|
else {
|
2002-08-28 21:04:11 +00:00
|
|
|
printf(", Repo ID = %s , (file) \n", mv->repo_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display all giop_sub_list (GSList) entries
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void display_heuristic_user_list() {
|
|
|
|
int i;
|
|
|
|
int len;
|
2010-01-18 18:00:23 +00:00
|
|
|
giop_sub_handle_t *subh; /* handle */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Get length of list */
|
|
|
|
len = g_slist_length(giop_sub_list); /* find length */
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
subh = ( giop_sub_handle_t *) g_slist_nth_data(giop_sub_list,i); /* grab entry */
|
|
|
|
printf("giop:heuristic_user: Element = %i, Val (user) = %s \n", i, subh->sub_name);
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display all complete_request_list (GList) entries
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void display_complete_request_list() {
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
comp_req_list_entry_t *entry;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Get length of list */
|
|
|
|
len = g_list_length(giop_complete_request_list); /* find length */
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
entry = (comp_req_list_entry_t *) g_list_nth_data(giop_complete_request_list,i); /* grab entry */
|
2002-08-28 21:04:11 +00:00
|
|
|
printf("giop:Index = %8i , FN = %8i, reqid = %8u , operation = %20s , repoid = %30s \n", i, entry->fn,
|
2010-01-18 18:00:23 +00:00
|
|
|
entry->reqid,entry->operation, entry->repoid);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Dump Hash/List contents
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* collection_type specifies the list or hash to dump
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void giop_dump_collection(collection_data_t collection_type) {
|
|
|
|
|
|
|
|
switch(collection_type) {
|
|
|
|
case cd_heuristic_users:
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Heuristic User (Begin) --------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
display_heuristic_user_list();
|
|
|
|
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Heuristic User (End) ----------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cd_complete_request_list:
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+------------- Complete Request List (Begin) --+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
display_complete_request_list();
|
|
|
|
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+------------ Complete Request List (End) -----+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cd_module_hash:
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Module (Begin) ----------------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
g_hash_table_foreach(giop_module_hash, display_module_hash, NULL);
|
|
|
|
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Module ( End) -----------------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cd_objkey_hash:
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Objkey (Begin) ----------------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
g_hash_table_foreach(giop_objkey_hash, display_objkey_hash,NULL);
|
|
|
|
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Objkey (End) ------------------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n\n");
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case cd_complete_reply_hash:
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+-------------- Complete_Reply_Hash (Begin) ---+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
g_hash_table_foreach(giop_complete_reply_hash, display_complete_reply_hash, NULL);
|
|
|
|
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
printf("+------------- Complete_Reply_Hash (End) ------+ \n");
|
|
|
|
printf("+----------------------------------------------+ \n");
|
|
|
|
|
|
|
|
break;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
default:
|
|
|
|
|
|
|
|
printf("giop: giop_dump_collection: Unknown type \n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through all subdissectors, and call them until someone
|
|
|
|
* answers (returns TRUE). This function then returns TRUE, otherwise
|
|
|
|
* it return FALSE
|
2001-06-29 20:49:29 +00:00
|
|
|
*
|
|
|
|
* But skip a subdissector if it has been disabled in GUI "edit protocols".
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-22 22:46:41 +00:00
|
|
|
static gboolean try_heuristic_giop_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
MessageHeader *header, gchar *operation ) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
int i,len;
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean res = FALSE; /* result of calling a heuristic sub dissector */
|
2002-08-28 21:04:11 +00:00
|
|
|
giop_sub_handle_t *subh = NULL;
|
2001-12-17 22:45:18 +00:00
|
|
|
const char *saved_proto;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
len = g_slist_length(giop_sub_list); /* find length */
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return FALSE;
|
2009-08-22 22:46:41 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
guint32 message_size;
|
|
|
|
gboolean stream_is_big_endian = is_big_endian (header);
|
|
|
|
|
|
|
|
if (stream_is_big_endian)
|
2009-08-23 05:20:30 +00:00
|
|
|
message_size = pntohl (&header->message_size);
|
2009-08-22 22:46:41 +00:00
|
|
|
else
|
2009-08-23 05:20:30 +00:00
|
|
|
message_size = pletohl (&header->message_size);
|
2009-08-22 22:46:41 +00:00
|
|
|
|
|
|
|
if (*offset > header->message_size)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2001-12-17 22:45:18 +00:00
|
|
|
saved_proto = pinfo->current_proto;
|
2001-06-18 05:27:18 +00:00
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
subh = (giop_sub_handle_t *) g_slist_nth_data(giop_sub_list,i); /* grab dissector handle */
|
2001-06-29 20:49:29 +00:00
|
|
|
|
|
|
|
if (proto_is_protocol_enabled(subh->sub_proto)) {
|
2001-12-17 22:45:18 +00:00
|
|
|
pinfo->current_proto =
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_get_protocol_short_name(subh->sub_proto);
|
2001-06-29 20:49:29 +00:00
|
|
|
res = (subh->sub_fn)(tvb,pinfo,tree,offset,header,operation,NULL); /* callit TODO - replace NULL */
|
|
|
|
if (res) {
|
2010-01-18 18:00:23 +00:00
|
|
|
pinfo->current_proto = saved_proto;
|
|
|
|
return TRUE; /* found one, lets return */
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-29 20:49:29 +00:00
|
|
|
} /* protocol_is_enabled */
|
|
|
|
} /* loop */
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str (pinfo->cinfo, COL_PROTOCOL, "GIOP");
|
2001-12-19 08:59:08 +00:00
|
|
|
|
2001-12-17 22:45:18 +00:00
|
|
|
pinfo->current_proto = saved_proto;
|
2010-01-18 18:00:23 +00:00
|
|
|
return res; /* result */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the matching repoid in the module hash and call
|
|
|
|
* the dissector function if offset exists.
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
|
|
|
* Repoid is eg IDL:tux.antarctic/Penguin/Teeth:1.0 but subdissectors
|
|
|
|
* will register possibly "tux.antarctic/Penguin" and "tux.antarctic/Penguin/Teeth".
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
static gboolean try_explicit_giop_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
MessageHeader *header, gchar *operation, gchar *repoid ) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
giop_sub_handle_t *subdiss = NULL; /* handle */
|
2001-06-27 20:38:56 +00:00
|
|
|
gboolean res = FALSE;
|
2001-06-18 05:27:18 +00:00
|
|
|
gchar *modname = NULL;
|
|
|
|
struct giop_module_key module_key;
|
|
|
|
struct giop_module_val *module_val = NULL;
|
2001-12-17 22:45:18 +00:00
|
|
|
const char *saved_proto;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Get top level module/interface from complete repoid
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
modname = get_modname_from_repoid(repoid);
|
2001-07-25 20:21:57 +00:00
|
|
|
if (modname == NULL) {
|
2010-01-18 18:00:23 +00:00
|
|
|
return res; /* unknown module name */
|
2001-07-25 20:21:57 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Search for Module or interface name */
|
|
|
|
|
|
|
|
module_key.module = modname; /* module name */
|
|
|
|
module_val = (struct giop_module_val *)g_hash_table_lookup(giop_module_hash, &module_key);
|
|
|
|
|
|
|
|
if (module_val == NULL) {
|
2010-01-18 18:00:23 +00:00
|
|
|
return res; /* module not registered */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
subdiss = (giop_sub_handle_t *) module_val->subh; /* grab dissector handle */
|
|
|
|
|
|
|
|
if (subdiss) {
|
|
|
|
/* Add giop_sub_handle_t and repoid into complete_request_list, so REPLY can */
|
|
|
|
/* look it up directly, later ie: FN -> MFN -> giop_sub_handle_t and repoid */
|
|
|
|
/* but only if user not clicking */
|
|
|
|
|
|
|
|
if (!pinfo->fd->flags.visited)
|
|
|
|
add_sub_handle_repoid_to_comp_req_list(pinfo->fd->num,subdiss,repoid);
|
|
|
|
|
|
|
|
|
2001-06-29 20:49:29 +00:00
|
|
|
/* Call subdissector if current offset exists , and dissector is enabled in GUI "edit protocols" */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tvb_offset_exists(tvb, *offset)) {
|
|
|
|
#if DEBUG
|
2001-06-18 05:27:18 +00:00
|
|
|
printf("giop:try_explicit_dissector calling sub = %s with module = (%s) \n", subdiss->sub_name , modname);
|
|
|
|
#endif
|
2001-06-29 20:49:29 +00:00
|
|
|
|
|
|
|
if (proto_is_protocol_enabled(subdiss->sub_proto)) {
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
saved_proto = pinfo->current_proto;
|
|
|
|
pinfo->current_proto =
|
|
|
|
proto_get_protocol_short_name(subdiss->sub_proto);
|
|
|
|
res = (subdiss->sub_fn)(tvb,pinfo,tree,offset,header,operation, modname); /* callit, TODO replace NULL with idlname */
|
|
|
|
pinfo->current_proto = saved_proto;
|
2001-06-29 20:49:29 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
} /* protocol_is_enabled */
|
2001-06-18 05:27:18 +00:00
|
|
|
} /* offset exists */
|
|
|
|
} /* subdiss */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return res; /* return result */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Take in an array of char and create a new string.
|
|
|
|
* Replace non-printable characters with periods.
|
|
|
|
*
|
|
|
|
* The array may contain \0's so dont use strdup
|
|
|
|
* The string is \0 terminated, and thus longer than
|
2002-08-28 21:04:11 +00:00
|
|
|
* the initial sequence.
|
2001-06-18 05:27:18 +00:00
|
|
|
* Caller must free the new string.
|
|
|
|
*/
|
|
|
|
|
2005-08-11 20:14:41 +00:00
|
|
|
gchar * make_printable_string (gchar *in, guint32 len) {
|
2001-06-19 18:50:33 +00:00
|
|
|
guint32 i = 0;
|
2001-06-18 05:27:18 +00:00
|
|
|
gchar *print_string = NULL;
|
|
|
|
|
|
|
|
print_string = (gchar * )g_malloc0(len + 1); /* make some space and zero it */
|
|
|
|
memcpy(print_string, in, len); /* and make a copy of input data */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
for(i=0; i < len; i++) {
|
2002-08-28 21:04:11 +00:00
|
|
|
if( !isprint( (unsigned char)print_string[i] ) )
|
2001-06-18 05:27:18 +00:00
|
|
|
print_string[i] = '.';
|
|
|
|
}
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return print_string; /* return ptr */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine the byte order from the GIOP MessageHeader */
|
|
|
|
|
|
|
|
gboolean is_big_endian (MessageHeader * header) {
|
|
|
|
gboolean big_endian = FALSE;
|
|
|
|
|
|
|
|
switch (header->GIOP_version.minor) {
|
|
|
|
case 2:
|
|
|
|
case 1:
|
2010-02-01 18:16:25 +00:00
|
|
|
if (header->flags & GIOP_MESSAGE_FLAGS_ENDIANNESS)
|
2001-06-18 05:27:18 +00:00
|
|
|
big_endian = FALSE;
|
|
|
|
else
|
|
|
|
big_endian = TRUE;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
if (header->flags)
|
|
|
|
big_endian = FALSE;
|
|
|
|
else
|
|
|
|
big_endian = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return big_endian;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
|
|
|
* Calculate new offset, based on the current offset, and user supplied
|
2001-06-18 05:27:18 +00:00
|
|
|
* "offset delta" value, and the alignment requirement.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* eg: Used for GIOP 1.2 where Request and Reply bodies are
|
2001-06-18 05:27:18 +00:00
|
|
|
* aligned on 8 byte boundaries.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void set_new_alignment(int *offset, int delta, int alignment) {
|
|
|
|
|
|
|
|
while( ( (*offset + delta) % alignment) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* ------------------------------------------------------------------------------------------+
|
2001-06-18 05:27:18 +00:00
|
|
|
* Public get_CDR_xxx functions.
|
|
|
|
* ------------------------------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets data of type any. This is encoded as a TypeCode
|
|
|
|
* followed by the encoded value.
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
void get_CDR_any(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, int boundary,
|
|
|
|
MessageHeader * header ) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 TCKind; /* TypeCode */
|
|
|
|
|
|
|
|
/* get TypeCode of any */
|
|
|
|
TCKind = get_CDR_typeCode(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
|
|
|
|
/* dissect data of type TCKind */
|
|
|
|
dissect_data_for_typecode(tvb, tree, offset, stream_is_big_endian, boundary, header, TCKind );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 1 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a boolean value, and convert
|
|
|
|
* it to a boolean value.
|
|
|
|
* Offset is then incremented by 1, to indicate the 1 octet which
|
|
|
|
* has been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean get_CDR_boolean(tvbuff_t *tvb, int *offset) {
|
|
|
|
guint8 val;
|
|
|
|
|
|
|
|
val = tvb_get_guint8(tvb, *offset); /* easy */
|
|
|
|
(*offset)++;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 1 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a char, and convert
|
|
|
|
* it to an char value.
|
|
|
|
* offset is then incremented by 1, to indicate the 1 octet which
|
|
|
|
* has been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint8 get_CDR_char(tvbuff_t *tvb, int *offset) {
|
|
|
|
guint8 val;
|
|
|
|
|
|
|
|
val = tvb_get_guint8(tvb, *offset); /* easy */
|
|
|
|
(*offset)++;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
|
|
|
* Floating Point Data Type double IEEE 754-1985
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Copy an 8 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a double value, and convert
|
|
|
|
* it to a double value, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for double values.
|
|
|
|
* offset is then incremented by 8, to indicate the 8 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gdouble get_CDR_double(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
gdouble val;
|
|
|
|
|
|
|
|
/* double values must be aligned on a 8 byte boundary */
|
|
|
|
|
|
|
|
while( ( (*offset + boundary) % 8) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-04-24 21:28:52 +00:00
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntohieee_double (tvb, *offset) :
|
|
|
|
tvb_get_letohieee_double (tvb, *offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-04-24 21:28:52 +00:00
|
|
|
*offset += 8;
|
|
|
|
return val;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 4 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents an enum value, and convert
|
|
|
|
* it to an enum value, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for an enum (4)
|
|
|
|
* offset is then incremented by 4, to indicate the 4 octets which
|
|
|
|
* have been processed.
|
|
|
|
*
|
|
|
|
* Enum values are encoded as unsigned long.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
guint32 get_CDR_enum(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
return get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-06-27 20:38:56 +00:00
|
|
|
* Copy an octet sequence from the tvbuff
|
|
|
|
* which represents a Fixed point decimal type, and create a string representing
|
|
|
|
* a Fixed point decimal type. There are no alignment restrictions.
|
|
|
|
* Size and scale of fixed decimal type is determined by IDL.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-06-27 20:38:56 +00:00
|
|
|
* digits - IDL specified number of "digits" for this fixed type
|
|
|
|
* scale - IDL specified "scale" for this fixed type
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* eg: typedef fixed <5,2> fixed_t;
|
2002-08-28 21:04:11 +00:00
|
|
|
* could represent numbers like 123.45, 789.12,
|
2001-06-27 20:38:56 +00:00
|
|
|
*
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
2001-06-27 20:38:56 +00:00
|
|
|
* As the fixed type could be any size, I will not try to fit it into our
|
|
|
|
* simple types like gdouble or glong etc. I will just create a string buffer holding
|
|
|
|
* a representation (after scale is applied), and with a decimal point or zero padding
|
|
|
|
* inserted at the right place if necessary. The string is null terminated
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* so string may look like
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
2001-06-27 20:38:56 +00:00
|
|
|
*
|
|
|
|
* "+1.234" or "-3456.78" or "1234567309475760377365465897891" or "-2789000000" etc
|
|
|
|
*
|
|
|
|
* According to spec, digits <= 31
|
|
|
|
* and scale is positive (except for constants eg: 1000 has digit=1 and implied scale = -3)
|
|
|
|
* or <4,0> ?
|
|
|
|
*
|
|
|
|
* User must remember to free the buffer
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
void get_CDR_fixed(tvbuff_t *tvb, gchar **seq, gint *offset, guint32 digits, gint32 scale) {
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint8 sign; /* 0x0c is positive, 0x0d is negative */
|
|
|
|
guint32 i ; /* loop */
|
|
|
|
guint32 slen; /* number of bytes to hold digits + extra 0's if scale <0 */
|
|
|
|
/* this does not include sign, decimal point and \0 */
|
|
|
|
guint32 sindex = 0; /* string index */
|
|
|
|
gchar *tmpbuf; /* temp buff, holds string without scaling */
|
|
|
|
guint8 tval; /* temp val storage */
|
2001-06-27 20:38:56 +00:00
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* how many bytes to hold digits and scale (if scale <0)
|
2001-06-27 20:38:56 +00:00
|
|
|
*
|
|
|
|
* eg: fixed <5,2> = 5 digits
|
|
|
|
* fixed <5,-2> = 7 digits (5 + 2 added 0's)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed() called , digits = %u, scale = %u \n", digits, scale);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (scale <0) {
|
2010-01-18 18:00:23 +00:00
|
|
|
slen = digits - scale; /* allow for digits + padding 0's for negative scal */
|
2001-06-27 20:38:56 +00:00
|
|
|
} else {
|
2010-01-18 18:00:23 +00:00
|
|
|
slen = digits; /* digits */
|
2001-06-27 20:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed(): slen = %.2x \n", slen);
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
tmpbuf = ep_alloc0(slen); /* allocate temp buffer */
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
/* If even , grab 1st dig */
|
|
|
|
|
|
|
|
if (!(digits & 0x01)) {
|
|
|
|
tval = get_CDR_octet(tvb,offset);
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed():even: octet = %.2x \n", tval);
|
|
|
|
#endif
|
|
|
|
tmpbuf[sindex] = (tval & 0x0f) + 0x30; /* convert top nibble to ascii */
|
|
|
|
sindex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Loop, but stop BEFORE we hit last digit and sign
|
|
|
|
* if digits = 1 or 2, then this part is skipped
|
2001-06-27 20:38:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (digits>2) {
|
|
|
|
for(i=0; i< ((digits-1)/2 ); i++) {
|
|
|
|
tval = get_CDR_octet(tvb,offset);
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed():odd: octet = %.2x \n", tval);
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
tmpbuf[sindex] = ((tval & 0xf0) >> 4) + 0x30; /* convert top nibble to ascii */
|
|
|
|
sindex++;
|
|
|
|
tmpbuf[sindex] = (tval & 0x0f) + 0x30; /* convert bot nibble to ascii */
|
|
|
|
sindex++;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
}
|
|
|
|
} /* digits > 3 */
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed(): before last digit \n");
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
|
|
|
|
/* Last digit and sign if digits >1, or 1st dig and sign if digits = 1 */
|
|
|
|
|
|
|
|
tval = get_CDR_octet(tvb,offset);
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed(): octet = %.2x \n", tval);
|
|
|
|
#endif
|
|
|
|
tmpbuf[sindex] = (( tval & 0xf0)>> 4) + 0x30; /* convert top nibble to ascii */
|
|
|
|
sindex++;
|
|
|
|
|
|
|
|
sign = tval & 0x0f; /* get sign */
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* So now, we have all digits in an array, and the sign byte
|
2001-06-27 20:38:56 +00:00
|
|
|
* so lets generate a printable string, taking into account the scale
|
|
|
|
* and sign values.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
sindex = 0; /* reset */
|
|
|
|
*seq = g_new0(gchar, slen + 3); /* allocate temp buffer , including space for sign, decimal point and
|
|
|
|
* \0 -- TODO check slen is reasonable first */
|
2001-06-27 20:38:56 +00:00
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed(): sign = %.2x \n", sign);
|
2002-08-28 21:04:11 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
switch(sign) {
|
|
|
|
case 0x0c:
|
2010-01-18 18:00:23 +00:00
|
|
|
(*seq)[sindex] = '+'; /* put sign in first string position */
|
2002-08-28 21:04:11 +00:00
|
|
|
break;
|
2001-06-27 20:38:56 +00:00
|
|
|
case 0x0d:
|
|
|
|
(*seq)[sindex] = '-';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning("giop: Unknown sign value in fixed type %u \n", sign);
|
2010-01-18 18:00:23 +00:00
|
|
|
(*seq)[sindex] = '*'; /* flag as sign unkown */
|
2001-06-27 20:38:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sindex++;
|
|
|
|
|
|
|
|
/* Add decimal point or padding 0's, depending if scale is positive or
|
|
|
|
* negative, respectively
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (scale>0) {
|
|
|
|
for (i=0; i<digits-scale; i++) {
|
2010-01-18 18:00:23 +00:00
|
|
|
(*seq)[sindex] = tmpbuf[i]; /* digits to the left of the decimal point */
|
|
|
|
sindex++;
|
2001-06-27 20:38:56 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
(*seq)[sindex] = '.'; /* decimal point */
|
2001-06-27 20:38:56 +00:00
|
|
|
sindex++;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
for (i=digits-scale; i<digits; i++) {
|
2010-01-18 18:00:23 +00:00
|
|
|
(*seq)[sindex] = tmpbuf[i]; /* remaining digits to the right of the decimal point */
|
|
|
|
sindex++;
|
2001-06-27 20:38:56 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
(*seq)[sindex] = '\0'; /* string terminator */
|
2001-06-27 20:38:56 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* negative scale, dump digits and pad out with 0's */
|
|
|
|
|
|
|
|
for (i=0; i<digits-scale; i++) {
|
2010-01-18 18:00:23 +00:00
|
|
|
if (i<digits) {
|
|
|
|
(*seq)[sindex] = tmpbuf[i]; /* save digits */
|
|
|
|
} else {
|
|
|
|
(*seq)[sindex] = '0'; /* all digits used up, so pad with 0's */
|
|
|
|
}
|
|
|
|
sindex++;
|
2001-06-27 20:38:56 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
(*seq)[sindex] = '\0'; /* string terminator */
|
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
printf("giop:get_CDR_fixed(): value = %s \n", *seq);
|
|
|
|
#endif
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
return;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Floating Point Data Type float IEEE 754-1985
|
|
|
|
*
|
|
|
|
* Copy an 4 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a float value, and convert
|
|
|
|
* it to a float value, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for float values.
|
|
|
|
* offset is then incremented by 4, to indicate the 4 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gfloat get_CDR_float(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
gfloat val;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* float values must be aligned on a 4 byte boundary */
|
|
|
|
|
|
|
|
while( ( (*offset + boundary) % 4) != 0)
|
|
|
|
++(*offset);
|
|
|
|
|
2002-04-24 21:28:52 +00:00
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntohieee_float (tvb, *offset) :
|
|
|
|
tvb_get_letohieee_float (tvb, *offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-04-24 21:28:52 +00:00
|
|
|
*offset += 4;
|
|
|
|
return val;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode an Interface type, and display it on the tree.
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, int boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
decode_IOR(tvb, pinfo, tree, offset, boundary, stream_is_big_endian);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 4 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a signed long value, and convert
|
|
|
|
* it to an signed long vaule, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for long values.
|
|
|
|
* offset is then incremented by 4, to indicate the 4 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gint32 get_CDR_long(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
gint32 val;
|
|
|
|
|
|
|
|
/* unsigned long values must be aligned on a 4 byte boundary */
|
|
|
|
while( ( (*offset + boundary) % 4) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntohl (tvb, *offset) :
|
|
|
|
tvb_get_letohl (tvb, *offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
*offset += 4;
|
|
|
|
return val;
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2006-04-19 18:59:29 +00:00
|
|
|
/* Copy a 8 octet sequence from the tvbuff
|
|
|
|
* which represents a signed long long value, and convert
|
|
|
|
* it to an signed long long vaule, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for long long values.
|
|
|
|
* offset is then incremented by 8, to indicate the 8 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gint64 get_CDR_long_long(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
gint64 val;
|
|
|
|
|
|
|
|
/* unsigned long long values must be aligned on a 8 byte boundary */
|
|
|
|
while( ( (*offset + boundary) % 8) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2006-04-19 18:59:29 +00:00
|
|
|
|
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntoh64 (tvb, *offset) :
|
|
|
|
tvb_get_letoh64 (tvb, *offset);
|
|
|
|
|
2007-04-22 10:29:47 +00:00
|
|
|
*offset += 8;
|
2006-04-19 18:59:29 +00:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Decode an Object type, and display it on the tree.
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean stream_is_big_endian, int boundary) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
decode_IOR(tvb, pinfo, tree, offset, boundary, stream_is_big_endian);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 1 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a octet, and convert
|
|
|
|
* it to an octet value.
|
|
|
|
* offset is then incremented by 1, to indicate the 1 octet which
|
|
|
|
* has been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint8 get_CDR_octet(tvbuff_t *tvb, int *offset) {
|
|
|
|
guint8 val;
|
|
|
|
|
|
|
|
val = tvb_get_guint8(tvb, *offset); /* easy */
|
|
|
|
(*offset)++;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Copy a sequence of octets from the tvbuff.
|
2002-08-28 21:04:11 +00:00
|
|
|
* Caller of this function must remember to free the
|
2001-06-18 05:27:18 +00:00
|
|
|
* array pointed to by seq.
|
2002-08-28 21:04:11 +00:00
|
|
|
* This function also increments offset by len.
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
2002-05-12 20:43:29 +00:00
|
|
|
void get_CDR_octet_seq(tvbuff_t *tvb, gchar **seq, int *offset, guint32 len) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-05-13 01:24:47 +00:00
|
|
|
/*
|
|
|
|
* Make sure that the entire sequence of octets is in the buffer before
|
|
|
|
* allocating the buffer, so that we don't have to worry about freeing
|
|
|
|
* the buffer, and so that we don't try to allocate a buffer bigger
|
|
|
|
* than the data we'll actually be copying, and thus don't run the risk
|
|
|
|
* of crashing if the buffer is *so* big that we fail to allocate it
|
|
|
|
* and "g_new0()" aborts.
|
|
|
|
*/
|
|
|
|
tvb_ensure_bytes_exist(tvb, *offset, len);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* XXX - should we just allocate "len" bytes, and have "get_CDR_string()"
|
|
|
|
* do what we do now, and null-terminate the string (which also means
|
|
|
|
* we don't need to zero out the entire allocation, just the last byte)?
|
|
|
|
*/
|
|
|
|
*seq = g_new0(gchar, len + 1);
|
|
|
|
tvb_memcpy( tvb, *seq, *offset, len);
|
|
|
|
*offset += len;
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 2 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a signed short value, and convert
|
|
|
|
* it to a signed short value, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for short values.
|
|
|
|
* offset is then incremented by 2, to indicate the 2 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gint16 get_CDR_short(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
gint16 val;
|
|
|
|
|
|
|
|
/* short values must be aligned on a 2 byte boundary */
|
|
|
|
while( ( (*offset + boundary) % 2) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntohs (tvb, *offset) :
|
|
|
|
tvb_get_letohs (tvb, *offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
*offset += 2;
|
|
|
|
return val;
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy an octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents a string, and convert
|
|
|
|
* it to an string value, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for string values. (begins with an unsigned long LI)
|
|
|
|
*
|
|
|
|
* String sequence is copied to a buffer "seq". This must
|
|
|
|
* be freed by the calling program.
|
|
|
|
* offset is then incremented, to indicate the octets which
|
|
|
|
* have been processed.
|
|
|
|
*
|
|
|
|
* returns number of octets in the sequence
|
|
|
|
*
|
|
|
|
* Note: This function only supports single byte encoding at the
|
|
|
|
* moment until I get a handle on multibyte encoding etc.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
guint32 get_CDR_string(tvbuff_t *tvb, gchar **seq, int *offset, gboolean stream_is_big_endian,
|
2010-01-18 18:00:23 +00:00
|
|
|
int boundary ) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 slength;
|
|
|
|
|
|
|
|
slength = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary); /* get length first */
|
|
|
|
|
|
|
|
#if 0
|
2010-01-18 18:00:23 +00:00
|
|
|
(*offset)++; /* must step past \0 delimiter */
|
2001-06-18 05:27:18 +00:00
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (slength > 0) {
|
|
|
|
get_CDR_octet_seq(tvb, seq, offset, slength);
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
} else {
|
2010-01-18 18:00:23 +00:00
|
|
|
*seq = g_strdup(""); /* zero-length string */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return slength; /* return length */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Process a sequence of octets that represent the
|
2001-06-18 05:27:18 +00:00
|
|
|
* Pseudo Object Type "TypeCode". Typecodes are used for example,
|
2002-08-28 21:04:11 +00:00
|
|
|
* by "Any values".
|
2001-06-18 05:27:18 +00:00
|
|
|
* This function also increments offset to the correct position.
|
|
|
|
*
|
|
|
|
* It will parse the TypeCode and output data to the "tree" provided
|
|
|
|
* by the user
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* It returns a guint32 representing a TCKind value.
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
guint32 get_CDR_typeCode(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, int boundary,
|
|
|
|
MessageHeader * header ) {
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 val;
|
|
|
|
|
|
|
|
gint16 s_octet2; /* signed int16 */
|
|
|
|
guint16 u_octet2; /* unsigned int16 */
|
|
|
|
guint32 u_octet4; /* unsigned int32 */
|
|
|
|
|
|
|
|
val = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary); /* get TCKind enum */
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_TCKind,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(val),4,val);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Grab the data according to Typecode Table - Corba Chapter 15 */
|
|
|
|
|
|
|
|
switch (val) {
|
|
|
|
case tk_null: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_void: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_short: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_long: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_ushort: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_ulong: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_float: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_double: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_boolean: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_char: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_octet: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_any: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_TypeCode: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_Principal: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_objref: /* complex parameter list */
|
2002-05-02 19:39:05 +00:00
|
|
|
dissect_tk_objref_params(tvb, tree, offset, stream_is_big_endian, boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
case tk_struct: /* complex parameter list */
|
|
|
|
dissect_tk_struct_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_union: /* complex parameter list */
|
|
|
|
dissect_tk_union_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_enum: /* complex parameter list */
|
2002-05-02 19:39:05 +00:00
|
|
|
dissect_tk_enum_params(tvb, tree, offset, stream_is_big_endian, boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case tk_string: /* simple parameter list */
|
|
|
|
u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary); /* get maximum length */
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_max_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case tk_sequence: /* complex parameter list */
|
|
|
|
dissect_tk_sequence_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_array: /* complex parameter list */
|
|
|
|
dissect_tk_array_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_alias: /* complex parameter list */
|
|
|
|
dissect_tk_alias_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_except: /* complex parameter list */
|
|
|
|
dissect_tk_except_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_longlong: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_ulonglong: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_longdouble: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_wchar: /* empty parameter list */
|
|
|
|
break;
|
|
|
|
case tk_wstring: /* simple parameter list */
|
|
|
|
u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary); /* get maximum length */
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_max_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case tk_fixed: /* simple parameter list */
|
|
|
|
u_octet2 = get_CDR_ushort(tvb,offset,stream_is_big_endian,boundary); /* get digits */
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_digits,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet2),2,u_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s_octet2 = get_CDR_short(tvb,offset,stream_is_big_endian,boundary); /* get scale */
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_int(tree,hf_giop_typecode_scale,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(s_octet2),2,s_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case tk_value: /* complex parameter list */
|
|
|
|
dissect_tk_value_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_value_box: /* complex parameter list */
|
|
|
|
dissect_tk_value_box_params(tvb, tree, offset, stream_is_big_endian, boundary, header );
|
|
|
|
break;
|
|
|
|
case tk_native: /* complex parameter list */
|
2002-05-02 19:39:05 +00:00
|
|
|
dissect_tk_native_params(tvb, tree, offset, stream_is_big_endian, boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
case tk_abstract_interface: /* complex parameter list */
|
2002-05-02 19:39:05 +00:00
|
|
|
dissect_tk_abstract_interface_params(tvb, tree, offset, stream_is_big_endian, boundary );
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning("giop: Unknown TCKind %u \n", val);
|
|
|
|
break;
|
|
|
|
} /* val */
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 4 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents an unsigned long value, and convert
|
|
|
|
* it to an unsigned long vaule, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for unsigned long values.
|
|
|
|
* offset is then incremented by 4, to indicate the 4 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint32 get_CDR_ulong(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
guint32 val;
|
|
|
|
|
|
|
|
/* unsigned long values must be aligned on a 4 byte boundary */
|
|
|
|
while( ( (*offset + boundary) % 4) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntohl (tvb, *offset) :
|
|
|
|
tvb_get_letohl (tvb, *offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
*offset += 4;
|
|
|
|
return val;
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2006-04-19 18:59:29 +00:00
|
|
|
/* Copy a 8 octet sequence from the tvbuff
|
|
|
|
* which represents an unsigned long long value, and convert
|
|
|
|
* it to an unsigned long long vaule, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for unsigned long long values.
|
|
|
|
* offset is then incremented by 4, to indicate the 4 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint64 get_CDR_ulong_long(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
guint64 val;
|
|
|
|
|
|
|
|
/* unsigned long long values must be aligned on a 8 byte boundary */
|
|
|
|
while( ( (*offset + boundary) % 8) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2006-04-19 18:59:29 +00:00
|
|
|
|
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntoh64 (tvb, *offset) :
|
|
|
|
tvb_get_letoh64 (tvb, *offset);
|
|
|
|
|
|
|
|
*offset += 8;
|
|
|
|
return val;
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Copy a 2 octet sequence from the tvbuff
|
2001-06-18 05:27:18 +00:00
|
|
|
* which represents an unsigned short value, and convert
|
|
|
|
* it to an unsigned short value, taking into account byte order.
|
|
|
|
* offset is first incremented so that it falls on a proper alignment
|
|
|
|
* boundary for unsigned short values.
|
|
|
|
* offset is then incremented by 2, to indicate the 2 octets which
|
|
|
|
* have been processed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint16 get_CDR_ushort(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary) {
|
|
|
|
|
|
|
|
guint16 val;
|
|
|
|
|
|
|
|
/* unsigned short values must be aligned on a 2 byte boundary */
|
|
|
|
while( ( (*offset + boundary) % 2) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
++(*offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
val = (stream_is_big_endian) ? tvb_get_ntohs (tvb, *offset) :
|
|
|
|
tvb_get_letohs (tvb, *offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
*offset += 2;
|
|
|
|
return val;
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Copy a wchar from the tvbuff.
|
2002-08-28 21:04:11 +00:00
|
|
|
* Caller of this function must remember to free the
|
2001-06-18 05:27:18 +00:00
|
|
|
* array pointed to by seq.
|
|
|
|
* This function also increments offset according to
|
|
|
|
* the wchar size.
|
|
|
|
*
|
|
|
|
* For GIOP 1.1 read 2 octets and return size -2. The
|
|
|
|
* negation means there is no size element in the packet
|
|
|
|
* and therefore no size to add to the tree.
|
|
|
|
*
|
|
|
|
* For GIOP 1.2 read size of wchar and the size
|
|
|
|
* octets. size is returned as a gint8.
|
|
|
|
*
|
|
|
|
* For both GIOP versions the wchar is returned
|
|
|
|
* as a printable string.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOTE: This is very primitive in that it just reads
|
|
|
|
* the wchar as a series of octets and returns them
|
|
|
|
* to the user. No translation is attempted based on
|
2002-08-28 21:04:11 +00:00
|
|
|
* byte orientation, nor on code set. I.e it only
|
2001-06-18 05:27:18 +00:00
|
|
|
* really reads past the wchar and sets the offset
|
|
|
|
* correctly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The "decoding" is done according to CORBA chapter 15.
|
|
|
|
* Wchar is not supported for GIOP 1.0.
|
|
|
|
*/
|
|
|
|
|
2002-05-13 01:24:47 +00:00
|
|
|
gint get_CDR_wchar(tvbuff_t *tvb, gchar **seq, int *offset, MessageHeader * header) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-05-13 01:24:47 +00:00
|
|
|
gint slength;
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *raw_wstring;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* CORBA chapter 15:
|
|
|
|
* - prior to GIOP 1.2 wchar limited to two octet fixed length.
|
|
|
|
* - GIOP 1.2 wchar is encoded as an unsigned binary octet
|
|
|
|
* followed by the elements of the octet sequence representing
|
|
|
|
* the encoded value of the wchar.
|
|
|
|
*/
|
|
|
|
|
|
|
|
*seq = NULL; /* set in case GIOP 1.2 length is 0 */
|
|
|
|
slength = 2; /* set for GIOP 1.1 length in octets */
|
|
|
|
|
|
|
|
if (header->GIOP_version.minor > 1) /* if GIOP 1.2 get length of wchar */
|
|
|
|
slength = get_CDR_octet(tvb,offset);
|
|
|
|
|
|
|
|
if (slength > 0) {
|
|
|
|
/* ??? assume alignment is ok for GIOP 1.1 ??? */
|
|
|
|
get_CDR_octet_seq(tvb, &raw_wstring, offset, slength);
|
|
|
|
|
|
|
|
/* now turn octets (wchar) into something that can be printed by the user */
|
|
|
|
*seq = make_printable_string(raw_wstring, slength);
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
|
|
|
g_free(raw_wstring);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if GIOP 1.1 negate length to indicate not an item to add to tree */
|
|
|
|
if (header->GIOP_version.minor < 2)
|
|
|
|
slength = -slength;
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return slength; /* return length */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Copy a wstring from the tvbuff.
|
2002-08-28 21:04:11 +00:00
|
|
|
* Caller of this function must remember to free the
|
2001-06-18 05:27:18 +00:00
|
|
|
* array pointed to by seq.
|
|
|
|
* This function also increments offset, according to
|
|
|
|
* wstring length. length is returned as guint32
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOTE: This is very primitive in that it just reads
|
|
|
|
* the wstring as a series of octets and returns them
|
|
|
|
* to the user. No translation is attempted based on
|
2002-08-28 21:04:11 +00:00
|
|
|
* byte orientation, nor on code set. I.e it only
|
2001-06-18 05:27:18 +00:00
|
|
|
* really reads past the wstring and sets the offset
|
|
|
|
* correctly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The "decoding" is done according to CORBA chapter 15.
|
|
|
|
* Wstring is not supported for GIOP 1.0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
guint32 get_CDR_wstring(tvbuff_t *tvb, gchar **seq, int *offset, gboolean stream_is_big_endian,
|
2010-01-18 18:00:23 +00:00
|
|
|
int boundary, MessageHeader * header) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 slength;
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *raw_wstring;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* CORBA chapter 15:
|
|
|
|
* - prior to GIOP 1.2 wstring limited to two octet fixed length.
|
|
|
|
* length and string are NUL terminated (length???).
|
|
|
|
* - GIOP 1.2 length is total number of octets. wstring is NOT NUL
|
|
|
|
* terminated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
*seq = NULL; /* set in case GIOP 1.2 length is 0 */
|
|
|
|
|
|
|
|
/* get length, same for all GIOP versions,
|
2002-08-28 21:04:11 +00:00
|
|
|
* although for 1.2 CORBA doesnt say, so assume.
|
2001-06-18 05:27:18 +00:00
|
|
|
*/
|
|
|
|
slength = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (slength>200) {
|
|
|
|
fprintf(stderr, "giop:get_CDR_wstring, length %u > 200, truncating to 5 \n", slength);
|
2010-01-18 18:00:23 +00:00
|
|
|
slength = 5; /* better than core dumping during debug */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (header->GIOP_version.minor < 2) {
|
|
|
|
#if 0
|
|
|
|
(*offset)++; /* must step past \0 delimiter */
|
|
|
|
#endif
|
|
|
|
/* assume length is number of characters and not octets, spec not clear */
|
|
|
|
slength = slength * 2; /* length in octets is 2 * wstring length */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slength > 0) {
|
|
|
|
get_CDR_octet_seq(tvb, &raw_wstring, offset, slength);
|
|
|
|
|
|
|
|
/* now turn octets (wstring) into something that can be printed by the user */
|
|
|
|
*seq = make_printable_string(raw_wstring, slength);
|
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
g_free(raw_wstring);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return slength; /* return length */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dissects a TargetAddress which is defined in (CORBA 2.4, section 15.4.2)
|
|
|
|
* GIOP 1.2
|
|
|
|
* typedef short AddressingDisposition;
|
|
|
|
* const short KeyAddr = 0;
|
|
|
|
* const short ProfileAddr = 1;
|
|
|
|
* const short ReferenceAddr = 2;
|
|
|
|
* struct IORAddressingInfo {
|
|
|
|
* unsigned long selected_profile_index;
|
|
|
|
* IOP::IOR ior;
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* union TargetAddress switch (AddressingDisposition) {
|
|
|
|
* case KeyAddr: sequence <octet> object_key;
|
|
|
|
* case ProfileAddr: IOP::TaggedProfile profile;
|
|
|
|
* case ReferenceAddr: IORAddressingInfo ior;
|
|
|
|
* };
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2002-08-28 21:04:11 +00:00
|
|
|
dissect_target_address(tvbuff_t * tvb, packet_info *pinfo, int *offset, proto_tree * tree,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 *object_key_len,
|
|
|
|
gchar **object_key_val)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
guint16 discriminant;
|
|
|
|
gchar *object_key;
|
|
|
|
gchar *p_object_key;
|
|
|
|
guint32 len = 0;
|
|
|
|
guint32 u_octet4;
|
|
|
|
const char * name;
|
|
|
|
|
|
|
|
object_key = NULL;
|
|
|
|
discriminant = get_CDR_ushort(tvb, offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
switch (discriminant)
|
|
|
|
{
|
|
|
|
case 0: name = "KeyAddr"; break;
|
|
|
|
case 1: name = "ProfileAddr"; break;
|
|
|
|
case 2: name = "ReferenceAddr"; break;
|
|
|
|
default: name = "Unknown"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_tree_add_text (tree, tvb, *offset -2, 2, "TargetAddress: %s", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (discriminant)
|
|
|
|
{
|
|
|
|
case 0: /* KeyAddr */
|
|
|
|
len = get_CDR_ulong(tvb, offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (tree, tvb, *offset -4, 4,
|
|
|
|
"KeyAddr (object key length): %u", len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > 0) {
|
|
|
|
|
|
|
|
get_CDR_octet_seq(tvb, &object_key, offset, len);
|
|
|
|
p_object_key = make_printable_string( object_key, len );
|
|
|
|
|
|
|
|
if(tree)
|
2009-08-10 19:53:12 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_text (tree, tvb, *offset -len, len,
|
|
|
|
"KeyAddr (object key): %s", p_object_key);
|
|
|
|
}
|
|
|
|
g_free( p_object_key );
|
|
|
|
if (object_key_len) {
|
|
|
|
*object_key_len = len;
|
2009-08-10 19:53:12 +00:00
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
if (object_key_val) {
|
|
|
|
*object_key_val = object_key;
|
|
|
|
} else {
|
|
|
|
g_free( object_key );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: /* ProfileAddr */
|
|
|
|
decode_TaggedProfile(tvb, pinfo, tree, offset, GIOP_HEADER_SIZE,
|
|
|
|
stream_is_big_endian, NULL);
|
|
|
|
break;
|
|
|
|
case 2: /* ReferenceAddr */
|
|
|
|
u_octet4 = get_CDR_ulong(tvb, offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2009-08-10 19:53:12 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (tree, tvb, *offset -len -4, 4,
|
|
|
|
"ReferenceAddr (selected_profile_index): %u", u_octet4);
|
|
|
|
}
|
|
|
|
|
|
|
|
decode_IOR(tvb, pinfo, tree, offset, GIOP_HEADER_SIZE, stream_is_big_endian);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-02 23:36:07 +00:00
|
|
|
dissect_reply_body (tvbuff_t *tvb, guint offset, packet_info *pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree *tree, gboolean stream_is_big_endian,
|
|
|
|
guint32 reply_status, MessageHeader *header, proto_tree *clnp_tree) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-02 23:36:07 +00:00
|
|
|
guint sequence_length;
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean exres = FALSE; /* result of trying explicit dissectors */
|
|
|
|
gchar * repoid = NULL; /* Repositor ID looked up from objkey */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* comp_req_list stuff
|
|
|
|
*/
|
|
|
|
|
|
|
|
comp_req_list_entry_t * entry = NULL; /* data element in our list */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 mfn;
|
|
|
|
|
|
|
|
switch (reply_status)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
case SYSTEM_EXCEPTION:
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
decode_SystemExceptionReplyBody (tvb, tree, &offset, stream_is_big_endian, GIOP_HEADER_SIZE);
|
|
|
|
break;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
case USER_EXCEPTION:
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
sequence_length = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text(tree, tvb, offset-4, 4,
|
|
|
|
"Exception length: %u", sequence_length);
|
|
|
|
}
|
|
|
|
if (sequence_length != 0 && sequence_length < ITEM_LABEL_LENGTH)
|
|
|
|
{
|
2001-06-18 05:27:18 +00:00
|
|
|
#if 1
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, sequence_length);
|
|
|
|
header->exception_id = g_new0(gchar,sequence_length ); /* allocate buffer */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/* read exception id from buffer and store in*/
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
tvb_get_nstringz0(tvb,offset,sequence_length, header->exception_id );
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_string(tree, hf_giop_exception_id, tvb,
|
|
|
|
offset, sequence_length, header->exception_id);
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
offset += sequence_length;
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/*
|
|
|
|
* Now just fall through to the NO_EXCEPTION part
|
|
|
|
* as this is common .
|
|
|
|
*/
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
case NO_EXCEPTION:
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/* lookup MFN in hash directly */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
mfn = get_mfn_from_fn(pinfo->fd->num);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (mfn == pinfo->fd->num)
|
|
|
|
return; /* no matching frame number, what am I */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/* get entry for this MFN */
|
|
|
|
entry = find_fn_in_list(mfn); /* get data entry in complete_request_list */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (!entry)
|
|
|
|
return; /* no matching entry */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/*
|
|
|
|
* If this packet is a REPLY to a RESOLVE(request)
|
|
|
|
* then decode IOR.
|
|
|
|
* TODO - make this lookup faster -- FS
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (!strcmp(giop_op_resolve,entry->operation)) {
|
|
|
|
decode_IOR(tvb, pinfo, tree, &offset, GIOP_HEADER_SIZE,stream_is_big_endian);
|
|
|
|
return; /* done */
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/* TODO -- Put stuff here for other "interesting operations" */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Call sub dissector.
|
|
|
|
* First try an find a explicit sub_dissector, then if that
|
|
|
|
* fails, try the heuristic method.
|
|
|
|
*/
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2001-06-27 20:38:56 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if(entry->repoid) {
|
|
|
|
exres = try_explicit_giop_dissector(tvb,pinfo,clnp_tree, &offset, header, entry->operation, entry->repoid );
|
|
|
|
}
|
2001-06-27 20:38:56 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/* Only call heuristic if no explicit dissector was found */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if(! exres) {
|
|
|
|
exres = try_heuristic_giop_dissector(tvb,pinfo,clnp_tree,&offset,header,entry->operation);
|
|
|
|
}
|
2005-08-11 20:14:41 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (!exres && !strcmp(giop_op_is_a, entry->operation) && tree) {
|
|
|
|
proto_tree_add_text(tree, tvb, offset - 1, 1, "Type Id%s matched",
|
|
|
|
get_CDR_boolean(tvb, &offset) ? "" : " not");
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if(! exres) {
|
|
|
|
gint stub_length = tvb_reported_length_remaining(tvb, offset);
|
|
|
|
if (stub_length >0)
|
|
|
|
proto_tree_add_text(tree, tvb, offset, -1,
|
|
|
|
"Stub data (%d byte%s)", stub_length,
|
|
|
|
plurality(stub_length, "", "s"));
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
break;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
case LOCATION_FORWARD:
|
|
|
|
decode_IOR(tvb, pinfo, tree, &offset, GIOP_HEADER_SIZE, stream_is_big_endian);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
break;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
case LOCATION_FORWARD_PERM:
|
|
|
|
decode_IOR(tvb, pinfo, tree, &offset, GIOP_HEADER_SIZE, stream_is_big_endian);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
break;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
case NEEDS_ADDRESSING_MODE: {
|
|
|
|
guint16 addr_disp;
|
|
|
|
addr_disp = get_CDR_ushort(tvb, &offset, stream_is_big_endian, GIOP_HEADER_SIZE);
|
|
|
|
if(tree) {
|
|
|
|
proto_tree_add_text (tree, tvb, offset -2, 2,
|
|
|
|
"AddressingDisposition: %u", addr_disp);
|
2001-12-15 20:40:19 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
default:
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_warning("giop: Unknown reply status %i request_id = %u\n",reply_status, header->req_id);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
} /* switch */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_free(repoid); /* free resource */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return; /* done */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The format of the Reply Header for GIOP 1.0 and 1.1
|
|
|
|
* is documented in Section 15.4.3.1 of the CORBA 2.4 standard.
|
|
|
|
|
|
|
|
struct ReplyHeader_1_0 {
|
|
|
|
IOP::ServiceContextList service_context;
|
|
|
|
unsigned long request_id;
|
|
|
|
ReplyStatusType_1_0 reply_status;
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void dissect_giop_reply (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
|
2010-01-18 18:00:23 +00:00
|
|
|
MessageHeader * header,
|
|
|
|
gboolean stream_is_big_endian) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 offset = 0;
|
|
|
|
guint32 request_id;
|
|
|
|
guint32 reply_status;
|
|
|
|
proto_tree *reply_tree = NULL;
|
|
|
|
proto_item *tf;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 mfn; /* matching frame number */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2002-01-24 09:20:54 +00:00
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"General Inter-ORB Protocol Reply");
|
2001-06-18 05:27:18 +00:00
|
|
|
if (reply_tree == NULL)
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
reply_tree = proto_item_add_subtree (tf, ett_giop_reply);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Decode IOP::ServiceContextList
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-05-02 19:39:05 +00:00
|
|
|
decode_ServiceContextList(tvb, reply_tree, &offset,stream_is_big_endian, GIOP_HEADER_SIZE);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
2008-02-21 20:45:09 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id );
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
2004-11-24 21:26:52 +00:00
|
|
|
proto_tree_add_uint(reply_tree, hf_giop_req_id, tvb, offset-4, 4, request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reply_status = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
|
2001-06-18 05:27:18 +00:00
|
|
|
val_to_str(reply_status, reply_status_types, "Unknown (%u)"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
2005-08-11 20:14:41 +00:00
|
|
|
proto_tree_add_uint(reply_tree, hf_giop_reply_status, tvb,
|
|
|
|
offset-4, 4, reply_status);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save FN and MFN in complete_reply_hash, only if user is NOT clicking
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (! pinfo->fd->flags.visited) {
|
2010-01-18 18:00:23 +00:00
|
|
|
mfn = get_mfn_from_fn_and_reqid(pinfo->fd->num,request_id); /* find MFN for this FN */
|
2001-06-18 05:27:18 +00:00
|
|
|
if (mfn != pinfo->fd->num) { /* if mfn is not fn, good */
|
|
|
|
insert_in_complete_reply_hash(pinfo->fd->num, mfn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
header->req_id = request_id; /* save for sub dissector */
|
2001-06-18 05:27:18 +00:00
|
|
|
header->rep_status = reply_status; /* save for sub dissector */
|
|
|
|
|
2005-09-01 19:44:26 +00:00
|
|
|
/* Do we have a body */
|
|
|
|
if (tvb_reported_length_remaining(tvb, offset))
|
2010-01-18 18:00:23 +00:00
|
|
|
dissect_reply_body(tvb, offset, pinfo, reply_tree, stream_is_big_endian,
|
|
|
|
reply_status, header,tree);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** The format of the GIOP 1.2 Reply header is very similar to the 1.0
|
|
|
|
* and 1.1 header, only the fields have been rearranged. From Section
|
|
|
|
* 15.4.3.1 of the CORBA 2.4 specification:
|
|
|
|
*
|
|
|
|
* struct ReplyHeader_1_2 {
|
|
|
|
* unsigned long request_id;
|
|
|
|
* ReplyStatusType_1_2 reply_status;
|
2002-08-28 21:04:11 +00:00
|
|
|
* IOP:ServiceContextList service_context;
|
2001-06-18 05:27:18 +00:00
|
|
|
* };
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void dissect_giop_reply_1_2 (tvbuff_t * tvb, packet_info * pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree * tree,
|
|
|
|
MessageHeader * header,
|
|
|
|
gboolean stream_is_big_endian) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-02 23:36:07 +00:00
|
|
|
guint offset = 0;
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 request_id;
|
|
|
|
guint32 reply_status;
|
|
|
|
proto_tree *reply_tree = NULL;
|
|
|
|
proto_item *tf;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 mfn; /* matching frame number */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (tree) {
|
2002-01-24 09:20:54 +00:00
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"General Inter-ORB Protocol Reply");
|
2001-06-18 05:27:18 +00:00
|
|
|
reply_tree = proto_item_add_subtree (tf, ett_giop_reply);
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
2008-02-21 20:45:09 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
2004-11-24 21:26:52 +00:00
|
|
|
proto_tree_add_uint (reply_tree, hf_giop_req_id, tvb, offset-4, 4, request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reply_status = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
|
2001-06-18 05:27:18 +00:00
|
|
|
val_to_str(reply_status, reply_status_types, "Unknown (%u)"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
2005-08-11 20:14:41 +00:00
|
|
|
proto_tree_add_uint(reply_tree, hf_giop_reply_status, tvb,
|
|
|
|
offset-4, 4, reply_status);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode IOP::ServiceContextList
|
|
|
|
*/
|
|
|
|
|
2002-05-02 19:39:05 +00:00
|
|
|
decode_ServiceContextList(tvb, reply_tree, &offset,stream_is_big_endian, GIOP_HEADER_SIZE);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GIOP 1.2 Reply body must fall on an 8 octet alignment.
|
|
|
|
*/
|
|
|
|
|
|
|
|
set_new_alignment(&offset, GIOP_HEADER_SIZE, 8);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save FN and MFN in complete_reply_hash, only if user is NOT clicking
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (! pinfo->fd->flags.visited) {
|
2010-01-18 18:00:23 +00:00
|
|
|
mfn = get_mfn_from_fn_and_reqid(pinfo->fd->num,request_id); /* find MFN for this FN */
|
2001-06-18 05:27:18 +00:00
|
|
|
if (mfn != pinfo->fd->num) { /* if mfn is not fn, good */
|
|
|
|
insert_in_complete_reply_hash(pinfo->fd->num, mfn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add header to argument list so sub dissector can get header info.
|
|
|
|
*/
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
header->req_id = request_id; /* save for sub dissector */
|
2001-06-18 05:27:18 +00:00
|
|
|
header->rep_status = reply_status; /* save for sub dissector */
|
|
|
|
|
|
|
|
dissect_reply_body(tvb, offset, pinfo, reply_tree, stream_is_big_endian,
|
2010-01-18 18:00:23 +00:00
|
|
|
reply_status,header,tree);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void dissect_giop_cancel_request (tvbuff_t * tvb, packet_info * pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree * tree,
|
|
|
|
gboolean stream_is_big_endian) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-02 23:36:07 +00:00
|
|
|
guint offset = 0;
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 request_id;
|
|
|
|
proto_tree *cancel_request_tree = NULL;
|
|
|
|
proto_item *tf;
|
|
|
|
|
|
|
|
if (tree) {
|
2002-01-24 09:20:54 +00:00
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"General Inter-ORB Protocol CancelRequest");
|
2001-06-18 05:27:18 +00:00
|
|
|
cancel_request_tree = proto_item_add_subtree (tf, ett_giop_cancel_request);
|
|
|
|
}
|
|
|
|
|
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
2008-02-21 20:45:09 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
2004-11-24 21:26:52 +00:00
|
|
|
proto_tree_add_uint (cancel_request_tree,hf_giop_req_id, tvb, offset-4, 4, request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** The formats for GIOP 1.0 and 1.1 Request messages are defined
|
|
|
|
* in section 15.4.2.1 of the CORBA 2.4 specification.
|
|
|
|
*
|
|
|
|
* struct RequestHeader{
|
|
|
|
* IOP::ServiceContextList service_context;
|
|
|
|
* unsigned long request_id;
|
|
|
|
* boolean response_expected;
|
|
|
|
* octet reserved[3]; // Only in GIOP 1.1
|
|
|
|
* sequence<octet> object_key;
|
|
|
|
* string operation;
|
|
|
|
* CORBA::OctetSeq requesting_principal;
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_giop_request_1_1 (tvbuff_t * tvb, packet_info * pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree * tree,
|
|
|
|
MessageHeader * header, gboolean stream_is_big_endian)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
|
|
|
guint32 offset = 0;
|
|
|
|
guint32 request_id;
|
|
|
|
guint32 len = 0;
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 objkey_len = 0; /* object key length */
|
|
|
|
gchar *objkey = NULL; /* object key sequence */
|
|
|
|
gboolean exres = FALSE; /* result of trying explicit dissectors */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *operation;
|
|
|
|
gchar *requesting_principal;
|
|
|
|
gchar *print_requesting_principal;
|
2001-06-18 05:27:18 +00:00
|
|
|
guint8 response_expected;
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *reserved;
|
2009-09-08 18:46:47 +00:00
|
|
|
gchar miop[4];
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree *request_tree = NULL;
|
|
|
|
proto_item *tf;
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
gchar *repoid = NULL; /* from object key lookup in objkey hash */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (tree)
|
2010-02-01 18:16:25 +00:00
|
|
|
{
|
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
|
|
|
"General Inter-ORB Protocol Request");
|
|
|
|
if (request_tree == NULL)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
request_tree = proto_item_add_subtree (tf, ett_giop_request);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
2010-02-01 18:16:25 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode IOP::ServiceContextList
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
decode_ServiceContextList(tvb, request_tree, &offset,stream_is_big_endian, 0);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2010-02-01 18:16:25 +00:00
|
|
|
{
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
if (tree)
|
2010-02-01 18:16:25 +00:00
|
|
|
{
|
|
|
|
proto_tree_add_uint (request_tree,hf_giop_req_id, tvb, offset-4, 4, request_id);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
response_expected = tvb_get_guint8( tvb, offset );
|
|
|
|
offset += 1;
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2010-02-01 18:16:25 +00:00
|
|
|
{
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)",
|
|
|
|
response_expected ? "two-way" : "one-way");
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
if (tree)
|
2010-02-01 18:16:25 +00:00
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset-1, 1,
|
|
|
|
"Response expected: %u", response_expected);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if( header->GIOP_version.minor > 0)
|
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
get_CDR_octet_seq( tvb, &reserved, &offset, 3);
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset-3, 3,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Reserved: %x %x %x", reserved[0], reserved[1], reserved[2]);
|
2010-02-01 18:16:25 +00:00
|
|
|
}
|
|
|
|
g_free(reserved);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2009-09-08 18:46:47 +00:00
|
|
|
/* Prior to GIOP 1.2, MIOP profile address prefixed with 'MIOP' */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2009-09-08 18:46:47 +00:00
|
|
|
miop[0] = get_CDR_octet (tvb, &offset);
|
|
|
|
miop[1] = get_CDR_octet (tvb, &offset);
|
|
|
|
miop[2] = get_CDR_octet (tvb, &offset);
|
|
|
|
miop[3] = get_CDR_octet (tvb, &offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2009-09-08 18:46:47 +00:00
|
|
|
if (miop[0] == 'M' && miop[1] == 'I' && miop[2] == 'O' && miop[3] == 'P')
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset - 4, 4,
|
|
|
|
"Magic number: %s", MIOP_MAGIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
decode_TaggedProfile (tvb, pinfo, request_tree, &offset, GIOP_HEADER_SIZE,
|
|
|
|
stream_is_big_endian, NULL);
|
2009-09-08 18:46:47 +00:00
|
|
|
}
|
|
|
|
else
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
/* Wind back if not MIOP profile */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
offset -= 4;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
/* Length of object_key sequence */
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
objkey_len = get_CDR_ulong (tvb, &offset, stream_is_big_endian,
|
|
|
|
GIOP_HEADER_SIZE);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset-4, 4,
|
|
|
|
"Object Key length: %u", objkey_len);
|
|
|
|
}
|
2009-09-08 18:46:47 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
if (objkey_len > 0)
|
|
|
|
{
|
|
|
|
get_CDR_octet_seq(tvb, &objkey, &offset, objkey_len);
|
2009-09-08 18:46:47 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_item (request_tree, hf_giop_objekt_key, tvb,
|
|
|
|
offset - objkey_len, objkey_len, FALSE);
|
|
|
|
}
|
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2009-09-08 18:46:47 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/*
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
* Register a cleanup function in case on of our tvbuff accesses
|
|
|
|
* throws an exception. We need to clean up objkey.
|
|
|
|
*/
|
2010-01-18 18:00:23 +00:00
|
|
|
CLEANUP_PUSH (g_free, objkey);
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
{
|
|
|
|
/* XXX: Get operation string, create a copy in ep memory and then g_free
|
|
|
|
the string returned from get_CDR_string(). This is a hack so that
|
|
|
|
a lexically nested CLEANUP_PUSH & etc is not req'd below.
|
|
|
|
[The nested CLEANUP_PUSH causes a gcc -Wshadow warning :( ] */
|
|
|
|
gchar *tmp;
|
|
|
|
/* length of operation string and string */
|
|
|
|
len = get_CDR_string(tvb, &tmp, &offset, stream_is_big_endian, GIOP_HEADER_SIZE);
|
|
|
|
operation = ep_strdup(tmp);
|
|
|
|
g_free(tmp);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
if(tree)
|
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
proto_tree_add_text (request_tree, tvb, offset - 4 - len, 4,
|
|
|
|
/**/ "Operation length: %u", len);
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if( len > 0)
|
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, ": op=%s", operation);
|
|
|
|
}
|
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_string (request_tree, hf_giop_req_operation,tvb, offset - len, len, operation);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
#if 0 /* See comment above re hack ... */
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* Register a cleanup function in case on of our tvbuff accesses
|
|
|
|
* throws an exception. We need to clean up operation.
|
|
|
|
*/
|
|
|
|
CLEANUP_PUSH(g_free, operation);
|
2010-02-01 18:16:25 +00:00
|
|
|
#endif
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* length of requesting_principal string */
|
2001-06-18 05:27:18 +00:00
|
|
|
len = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if(tree)
|
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
proto_tree_add_text (request_tree, tvb, offset-4, 4,
|
|
|
|
/**/ "Requesting Principal Length: %u", len);
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if( len > 0)
|
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
get_CDR_octet_seq(tvb, &requesting_principal, &offset, len);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
print_requesting_principal = make_printable_string(requesting_principal, len);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset - len, len,
|
|
|
|
/**/ "Requesting Principal: %s", print_requesting_principal);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
}
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
g_free( print_requesting_principal );
|
|
|
|
g_free( requesting_principal );
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save FN,reqid,and operation for later. Add sub_handle later.
|
|
|
|
* But only if user is NOT clicking.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (! pinfo->fd->flags.visited)
|
|
|
|
giop_complete_request_list = insert_in_comp_req_list(giop_complete_request_list,pinfo->fd->num,
|
2010-01-18 18:00:23 +00:00
|
|
|
request_id,operation,NULL);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Call subdissector here before freeing "operation" and "key"
|
2002-08-28 21:04:11 +00:00
|
|
|
* pass request_id also.
|
2001-06-18 05:27:18 +00:00
|
|
|
* First try an find an explicit sub_dissector, then if that
|
|
|
|
* fails, try the heuristic method.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
header->req_id = request_id; /* save for sub dissector */
|
2001-06-18 05:27:18 +00:00
|
|
|
repoid = get_repoid_from_objkey(giop_objkey_hash,objkey,objkey_len);
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if(repoid) {
|
2001-06-27 20:38:56 +00:00
|
|
|
exres = try_explicit_giop_dissector(tvb,pinfo,tree,&offset,header,operation,repoid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only call heuristic if no explicit dissector was found */
|
|
|
|
|
|
|
|
if (! exres) {
|
2005-08-11 20:14:41 +00:00
|
|
|
exres = try_heuristic_giop_dissector(tvb,pinfo,tree,&offset,header,operation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!exres && !strcmp(giop_op_is_a, operation) && request_tree) {
|
|
|
|
gchar *type_id;
|
|
|
|
len = get_CDR_string(tvb, &type_id, &offset, stream_is_big_endian, 0);
|
|
|
|
proto_tree_add_text(request_tree, tvb, offset - len - 4, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Type Id length: %d", len);
|
2005-08-11 20:14:41 +00:00
|
|
|
proto_tree_add_text(request_tree, tvb, offset - len, len,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Type Id: %s", type_id);
|
2010-02-01 18:16:25 +00:00
|
|
|
g_free(type_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-07-04 03:45:29 +00:00
|
|
|
if(! exres) {
|
|
|
|
gint stub_length = tvb_reported_length_remaining(tvb, offset);
|
2010-02-01 18:16:25 +00:00
|
|
|
if (stub_length >0)
|
|
|
|
proto_tree_add_text(request_tree, tvb, offset, -1,
|
|
|
|
"Stub data (%d byte%s)", stub_length,
|
|
|
|
plurality(stub_length, "", "s"));
|
2005-07-04 03:45:29 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
#if 0 /* See comment above re hack ... */
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* We're done with operation, so we can call the cleanup handler to free
|
|
|
|
* it, and then pop the cleanup handler.
|
|
|
|
*/
|
|
|
|
CLEANUP_CALL_AND_POP;
|
2010-02-01 18:16:25 +00:00
|
|
|
#endif
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We're done with objkey, so we can call the cleanup handler to free
|
|
|
|
* it, and then pop the cleanup handler.
|
|
|
|
*/
|
|
|
|
CLEANUP_CALL_AND_POP;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/** The format of a GIOP 1.2 RequestHeader message is
|
2001-06-18 05:27:18 +00:00
|
|
|
* (CORBA 2.4, sec. 15.4.2):
|
|
|
|
*
|
|
|
|
* struct RequestHeader_1_2 {
|
|
|
|
* unsigned long request_id;
|
|
|
|
* octet response_flags;
|
|
|
|
* octet reserved[3];
|
|
|
|
* TargetAddress target;
|
|
|
|
* string operation;
|
|
|
|
* IOP::ServiceContextList service_context;
|
|
|
|
* // requesting_principal not in GIOP 1.2
|
|
|
|
* };
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_giop_request_1_2 (tvbuff_t * tvb, packet_info * pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree * tree,
|
|
|
|
MessageHeader * header, gboolean stream_is_big_endian)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
|
|
|
guint32 offset = 0;
|
|
|
|
guint32 request_id;
|
|
|
|
guint32 len = 0;
|
|
|
|
guint8 response_flags;
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *reserved;
|
2001-06-18 05:27:18 +00:00
|
|
|
gchar *operation = NULL;
|
|
|
|
proto_tree *request_tree = NULL;
|
|
|
|
proto_item *tf;
|
2010-02-01 18:16:25 +00:00
|
|
|
gboolean exres = FALSE; /* result of trying explicit dissectors */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 objkey_len = 0; /* object key length */
|
|
|
|
gchar *objkey = NULL; /* object key sequence */
|
|
|
|
gchar *repoid = NULL; /* from object key lookup in objkey hash */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2002-01-24 09:20:54 +00:00
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"General Inter-ORB Protocol Request");
|
2001-06-18 05:27:18 +00:00
|
|
|
request_tree = proto_item_add_subtree (tf, ett_giop_reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2008-02-21 20:45:09 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
if (request_tree)
|
|
|
|
{
|
2004-11-24 21:26:52 +00:00
|
|
|
proto_tree_add_uint (request_tree, hf_giop_req_id, tvb, offset-4, 4, request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
response_flags = tvb_get_guint8( tvb, offset );
|
|
|
|
offset += 1;
|
|
|
|
if (request_tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset-1, 1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Response flags: %s (%u)",
|
|
|
|
val_to_str(response_flags, response_flags_vals, "(0x%x)"),
|
|
|
|
response_flags);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_CDR_octet_seq( tvb, &reserved, &offset, 3);
|
|
|
|
if (request_tree)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
proto_tree_add_text (request_tree, tvb, offset-3, 3,
|
|
|
|
"Reserved: %x %x %x", reserved[0], reserved[1], reserved[2]);
|
|
|
|
}
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
g_free(reserved);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2006-04-16 23:16:46 +00:00
|
|
|
dissect_target_address(tvb, pinfo, &offset, request_tree, stream_is_big_endian,
|
2010-01-18 18:00:23 +00:00
|
|
|
&objkey_len, &objkey);
|
2006-04-16 23:16:46 +00:00
|
|
|
if (objkey) {
|
|
|
|
repoid = get_repoid_from_objkey(giop_objkey_hash, objkey, objkey_len);
|
|
|
|
g_free(objkey);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* length of operation string */
|
2001-06-18 05:27:18 +00:00
|
|
|
len = get_CDR_string(tvb, &operation, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if(tree)
|
|
|
|
{
|
2010-02-01 18:16:25 +00:00
|
|
|
proto_tree_add_text (request_tree, tvb, offset - len - 4, 4,
|
|
|
|
/**/ "Operation length: %u", len);
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if( len > 0)
|
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2008-02-21 20:45:09 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, ": op=%s", operation);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
if(request_tree)
|
|
|
|
{
|
2004-11-24 21:26:52 +00:00
|
|
|
proto_tree_add_string (request_tree,hf_giop_req_operation, tvb, offset - len, len, operation);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* Register a cleanup function in case on of our tvbuff accesses
|
|
|
|
* throws an exception. We need to clean up operation.
|
|
|
|
*/
|
|
|
|
CLEANUP_PUSH(g_free, operation);
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Decode IOP::ServiceContextList
|
|
|
|
*/
|
|
|
|
|
2002-05-02 19:39:05 +00:00
|
|
|
decode_ServiceContextList(tvb, request_tree, &offset, stream_is_big_endian, GIOP_HEADER_SIZE);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GIOP 1.2 Request body must fall on an 8 octet alignment, taking into
|
|
|
|
* account we are in a new tvbuff, GIOP_HEADER_SIZE octets from the
|
|
|
|
* GIOP octet stream start.
|
|
|
|
*/
|
|
|
|
|
2006-12-22 14:48:51 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0)
|
|
|
|
{
|
|
|
|
set_new_alignment(&offset, GIOP_HEADER_SIZE, 8);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Save FN,reqid,and operation for later. Add sub_handle later.
|
|
|
|
* But only if user is NOT clicking.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (! pinfo->fd->flags.visited)
|
|
|
|
giop_complete_request_list = insert_in_comp_req_list(giop_complete_request_list,pinfo->fd->num,
|
2010-01-18 18:00:23 +00:00
|
|
|
request_id,operation,NULL);
|
2001-06-27 20:38:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Call sub dissector.
|
|
|
|
* First try an find a explicit sub_dissector, then if that
|
|
|
|
* fails, try the heuristic method.
|
|
|
|
*/
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if(repoid) {
|
2001-06-27 20:38:56 +00:00
|
|
|
exres = try_explicit_giop_dissector(tvb,pinfo,tree,&offset,header,operation,repoid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only call heuristic if no explicit dissector was found */
|
|
|
|
|
|
|
|
if (! exres) {
|
2005-08-11 20:14:41 +00:00
|
|
|
exres = try_heuristic_giop_dissector(tvb,pinfo,tree,&offset,header,operation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!exres && !strcmp(giop_op_is_a, operation) && request_tree) {
|
|
|
|
gchar *type_id;
|
|
|
|
len = get_CDR_string(tvb, &type_id, &offset, stream_is_big_endian, 0);
|
|
|
|
proto_tree_add_text(request_tree, tvb, offset - len - 4, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Type Id length: %d", len);
|
2005-08-11 20:14:41 +00:00
|
|
|
proto_tree_add_text(request_tree, tvb, offset - len, len,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Type Id: %s", type_id);
|
2010-02-01 18:16:25 +00:00
|
|
|
g_free(type_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2005-07-04 03:45:29 +00:00
|
|
|
if(! exres) {
|
|
|
|
gint stub_length = tvb_reported_length_remaining(tvb, offset);
|
2010-01-18 18:00:23 +00:00
|
|
|
if (stub_length >0)
|
|
|
|
proto_tree_add_text(request_tree, tvb, offset, -1,
|
|
|
|
"Stub data (%d byte%s)", stub_length,
|
|
|
|
plurality(stub_length, "", "s"));
|
2005-07-04 03:45:29 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* We're done with operation, so we can call the cleanup handler to free
|
|
|
|
* it, and then pop the cleanup handler.
|
|
|
|
*/
|
|
|
|
CLEANUP_CALL_AND_POP;
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_giop_locate_request( tvbuff_t * tvb, packet_info * pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree * tree, MessageHeader * header,
|
|
|
|
gboolean stream_is_big_endian)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
|
|
|
guint32 offset = 0;
|
|
|
|
guint32 request_id;
|
|
|
|
guint32 len = 0;
|
|
|
|
proto_tree *locate_request_tree = NULL;
|
|
|
|
proto_item *tf;
|
|
|
|
|
|
|
|
if (tree)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
|
|
|
"General Inter-ORB Locate Request");
|
|
|
|
if (locate_request_tree == NULL)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
locate_request_tree = proto_item_add_subtree (tf, ett_giop_locate_request);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u op=LocateRequest", request_id);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
if (locate_request_tree)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
proto_tree_add_text (locate_request_tree, tvb, offset-4, 4,
|
|
|
|
"Request id: %u", request_id);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if(header->GIOP_version.minor < 2)
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
len = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if (locate_request_tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (locate_request_tree, tvb, offset-4, 4,
|
|
|
|
"Object Key length: %u", len);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (len > 0) {
|
2007-03-24 13:46:41 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if(locate_request_tree)
|
|
|
|
{
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_item(locate_request_tree, hf_giop_objekt_key, tvb, offset-len, len, FALSE);
|
|
|
|
}
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
else /* GIOP 1.2 and higher */
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
dissect_target_address(tvb, pinfo, &offset, locate_request_tree,
|
|
|
|
stream_is_big_endian, NULL, NULL);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_giop_locate_reply( tvbuff_t * tvb, packet_info * pinfo,
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree * tree, MessageHeader * header,
|
|
|
|
gboolean stream_is_big_endian)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
|
|
|
guint32 offset = 0;
|
|
|
|
guint32 request_id;
|
|
|
|
guint32 locate_status;
|
|
|
|
guint16 addr_disp;
|
|
|
|
|
|
|
|
proto_tree *locate_reply_tree = NULL;
|
|
|
|
proto_item *tf;
|
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2002-01-24 09:20:54 +00:00
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"General Inter-ORB Locate Reply");
|
2001-06-18 05:27:18 +00:00
|
|
|
if (locate_reply_tree == NULL)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
locate_reply_tree = proto_item_add_subtree (tf, ett_giop_locate_reply);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2008-02-21 20:45:09 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
if (locate_reply_tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (locate_reply_tree, tvb, offset-4, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Request id: %u", request_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
locate_status = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if (locate_reply_tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text (locate_reply_tree, tvb, offset-4, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Locate status: %s",
|
|
|
|
val_to_str(locate_status, giop_locate_status_types, "(0x%x)")
|
|
|
|
);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Decode the LocateReply body.
|
|
|
|
*
|
|
|
|
* For GIOP 1.0 and 1.1 body immediately follows header.
|
|
|
|
* For GIOP 1.2 it is aligned on 8 octet boundary so need to
|
|
|
|
* spin up.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (header->GIOP_version.minor > 1) {
|
|
|
|
while( ( (offset + GIOP_HEADER_SIZE) % 8) != 0)
|
|
|
|
++(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(locate_status) {
|
|
|
|
case OBJECT_FORWARD: /* fall through to OBJECT_FORWARD_PERM */
|
|
|
|
case OBJECT_FORWARD_PERM:
|
|
|
|
decode_IOR(tvb, pinfo, locate_reply_tree, &offset, GIOP_HEADER_SIZE, stream_is_big_endian);
|
|
|
|
break;
|
|
|
|
case LOC_SYSTEM_EXCEPTION:
|
|
|
|
decode_SystemExceptionReplyBody (tvb, tree, &offset, stream_is_big_endian, GIOP_HEADER_SIZE);
|
|
|
|
break;
|
|
|
|
case LOC_NEEDS_ADDRESSING_MODE:
|
|
|
|
addr_disp = get_CDR_ushort(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if(locate_reply_tree) {
|
|
|
|
proto_tree_add_text (tree, tvb, offset -2, 2,
|
2010-01-18 18:00:23 +00:00
|
|
|
"AddressingDisposition: %u", addr_disp);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: /* others have no reply body */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_giop_fragment( tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
|
|
|
guint32 offset = 0;
|
2008-02-21 20:45:09 +00:00
|
|
|
guint32 request_id;
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree *fragment_tree = NULL;
|
|
|
|
proto_item *tf;
|
|
|
|
|
|
|
|
if (tree)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
tf = proto_tree_add_text (tree, tvb, offset, -1,
|
|
|
|
"General Inter-ORB Fragment");
|
|
|
|
if (fragment_tree == NULL)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
fragment_tree = proto_item_add_subtree (tf, ett_giop_fragment);
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
request_id = get_CDR_ulong(tvb, &offset, stream_is_big_endian,GIOP_HEADER_SIZE);
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " id=%u", request_id);
|
|
|
|
}
|
|
|
|
if (fragment_tree )
|
|
|
|
{
|
|
|
|
proto_tree_add_uint (fragment_tree, hf_giop_req_id, tvb, offset-4, 4,request_id);
|
|
|
|
}
|
2008-02-21 20:45:09 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Main entry point */
|
|
|
|
|
2005-09-02 08:19:15 +00:00
|
|
|
static void dissect_giop_common (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
2002-08-02 23:36:07 +00:00
|
|
|
guint offset = 0;
|
2001-06-18 05:27:18 +00:00
|
|
|
MessageHeader header;
|
|
|
|
tvbuff_t *giop_header_tvb;
|
|
|
|
tvbuff_t *payload_tvb;
|
|
|
|
|
|
|
|
proto_tree *clnp_tree = NULL;
|
|
|
|
proto_item *ti;
|
2002-08-02 23:36:07 +00:00
|
|
|
guint message_size;
|
|
|
|
guint minor_version;
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean stream_is_big_endian;
|
2008-02-21 22:11:08 +00:00
|
|
|
const char *gMessageType;
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* DEBUG */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
#if DEBUG
|
|
|
|
giop_dump_collection(cd_module_hash);
|
|
|
|
giop_dump_collection(cd_objkey_hash);
|
|
|
|
giop_dump_collection(cd_heuristic_users);
|
|
|
|
giop_dump_collection(cd_complete_reply_hash);
|
|
|
|
giop_dump_collection(cd_complete_request_list);
|
|
|
|
#endif
|
|
|
|
|
2001-08-20 09:10:27 +00:00
|
|
|
header.exception_id = NULL;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
giop_header_tvb = tvb_new_subset (tvb, 0, GIOP_HEADER_SIZE, -1);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* because I have added extra elements in MessageHeader struct
|
|
|
|
* for sub dissectors. -- FS
|
|
|
|
*/
|
|
|
|
|
|
|
|
tvb_memcpy (giop_header_tvb, (guint8 *)&header, 0, GIOP_HEADER_SIZE );
|
|
|
|
|
|
|
|
|
2009-08-09 07:59:51 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "GIOP");
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
if (header.GIOP_version.major != GIOP_MAJOR ||
|
|
|
|
((minor_version = header.GIOP_version.minor) > GIOP_MINOR))
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
/* Bad version number; should we note that and dissect the rest
|
|
|
|
as data, or should this be done outside dissect_giop_common()
|
|
|
|
(which is called as the PDU dissector for GIOP-over-TCP,
|
|
|
|
so it can't return anything), with the test returning FALSE
|
|
|
|
on the theory that it might have been some other packet that
|
|
|
|
happened to begin with "GIOP"? We do the former, for now.
|
|
|
|
If we should return FALSE, we should do so *without* setting
|
|
|
|
the "Info" column, *without* setting the "Protocol" column,
|
|
|
|
and *without* adding anything to the protocol tree. */
|
|
|
|
|
|
|
|
if (check_col (pinfo->cinfo, COL_INFO))
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "Version %u.%u",
|
|
|
|
header.GIOP_version.major, header.GIOP_version.minor);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
ti = proto_tree_add_item (tree, proto_giop, tvb, 0, -1, FALSE);
|
|
|
|
clnp_tree = proto_item_add_subtree (ti, ett_giop);
|
|
|
|
proto_tree_add_text (clnp_tree, giop_header_tvb, 0, -1,
|
|
|
|
"Version %u.%u not supported",
|
|
|
|
header.GIOP_version.major,
|
|
|
|
header.GIOP_version.minor);
|
|
|
|
}
|
2010-02-01 16:18:18 +00:00
|
|
|
payload_tvb = tvb_new_subset_remaining (tvb, GIOP_HEADER_SIZE);
|
2010-01-18 18:00:23 +00:00
|
|
|
call_dissector(data_handle,payload_tvb, pinfo, tree);
|
|
|
|
return;
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (check_col (pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "GIOP %u.%u %s",
|
|
|
|
header.GIOP_version.major, header.GIOP_version.minor,
|
|
|
|
val_to_str(header.message_type, giop_message_types,
|
|
|
|
"Unknown message type (0x%02x)"));
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stream_is_big_endian = is_big_endian (&header);
|
|
|
|
|
|
|
|
if (stream_is_big_endian)
|
|
|
|
message_size = pntohl (&header.message_size);
|
|
|
|
else
|
|
|
|
message_size = pletohl (&header.message_size);
|
|
|
|
|
2008-02-21 20:45:09 +00:00
|
|
|
if (check_col (pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
gMessageType = val_to_str(header.message_type, giop_message_types, "Unknown message type (0x%02x)");
|
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "GIOP %u.%u %s s=%u",
|
|
|
|
header.GIOP_version.major, header.GIOP_version.minor, gMessageType, message_size );
|
2008-02-21 20:45:09 +00:00
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (tree)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
ti = proto_tree_add_item (tree, proto_giop, tvb, 0, -1, FALSE);
|
|
|
|
clnp_tree = proto_item_add_subtree (ti, ett_giop);
|
|
|
|
proto_tree_add_text (clnp_tree, giop_header_tvb, offset, 4,
|
|
|
|
"Magic number: %s", GIOP_MAGIC);
|
|
|
|
proto_tree_add_text (clnp_tree, giop_header_tvb, 4, 2,
|
|
|
|
"Version: %u.%u",
|
|
|
|
header.GIOP_version.major,
|
|
|
|
header.GIOP_version.minor);
|
|
|
|
switch (minor_version)
|
2001-06-18 05:27:18 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
case 2:
|
|
|
|
case 1:
|
2010-02-01 18:16:25 +00:00
|
|
|
ti = proto_tree_add_bitmask(clnp_tree, giop_header_tvb, 6,
|
|
|
|
hf_giop_message_flags, ett_giop_message_flags,
|
|
|
|
giop_message_flags, FALSE);
|
|
|
|
if ((header.flags & GIOP_MESSAGE_FLAGS_ENDIANNESS) == 0)
|
|
|
|
proto_item_append_text(ti, ", (Big Endian)"); /* hack to show "Big Endian" when endianness flag == 0 */
|
2010-01-18 18:00:23 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
proto_tree_add_text (clnp_tree, giop_header_tvb, 6, 1,
|
|
|
|
"Byte ordering: %s-endian",
|
|
|
|
(stream_is_big_endian) ? "big" : "little");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} /* minor_version */
|
|
|
|
|
|
|
|
gMessageType = val_to_str(header.message_type, giop_message_types, "(0x%02x)" );
|
|
|
|
|
|
|
|
proto_tree_add_uint_format (clnp_tree,
|
|
|
|
hf_giop_message_type,
|
|
|
|
giop_header_tvb, 7, 1,
|
|
|
|
header.message_type,
|
|
|
|
"Message type: %s", gMessageType );
|
|
|
|
|
|
|
|
proto_tree_add_uint (clnp_tree,
|
|
|
|
hf_giop_message_size,
|
|
|
|
giop_header_tvb, 8, 4, message_size);
|
|
|
|
|
|
|
|
} /* tree */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
#if 0
|
2002-08-28 21:04:11 +00:00
|
|
|
if (check_col (pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "GIOP %u.%u %s",
|
|
|
|
header.GIOP_version.major, header.GIOP_version.minor,
|
|
|
|
val_to_str(header.message_type, giop_message_types, "(0x%x)"));
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-01 18:16:25 +00:00
|
|
|
if (header.flags & GIOP_MESSAGE_FLAGS_ZIOP_ENABLED)
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
payload_tvb = tvb_child_uncompress(tvb, tvb, GIOP_HEADER_SIZE, tvb_length_remaining(tvb, GIOP_HEADER_SIZE ) );
|
2010-02-01 16:18:18 +00:00
|
|
|
if (payload_tvb) {
|
|
|
|
add_new_data_source (pinfo, payload_tvb, "decompressed Content");
|
|
|
|
} else {
|
|
|
|
/* Decompression failed. */
|
|
|
|
/* XXX: Consider: add expert item ? do data dissection ? */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
payload_tvb = tvb_new_subset_remaining (tvb, GIOP_HEADER_SIZE);
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2008-02-21 20:45:09 +00:00
|
|
|
|
2010-02-01 16:18:18 +00:00
|
|
|
switch (header.message_type)
|
|
|
|
{
|
2009-07-13 20:12:53 +00:00
|
|
|
|
2010-02-01 16:18:18 +00:00
|
|
|
case Request:
|
|
|
|
if(header.GIOP_version.minor < 2)
|
|
|
|
{
|
|
|
|
dissect_giop_request_1_1 (payload_tvb, pinfo, tree,
|
|
|
|
&header, stream_is_big_endian);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dissect_giop_request_1_2 (payload_tvb, pinfo, tree,
|
|
|
|
&header, stream_is_big_endian);
|
|
|
|
}
|
2009-07-13 20:12:53 +00:00
|
|
|
|
2010-02-01 16:18:18 +00:00
|
|
|
break;
|
2009-07-13 20:12:53 +00:00
|
|
|
|
|
|
|
|
2010-02-01 16:18:18 +00:00
|
|
|
case Reply:
|
|
|
|
if(header.GIOP_version.minor < 2)
|
|
|
|
{
|
|
|
|
dissect_giop_reply (payload_tvb, pinfo, tree, &header,
|
|
|
|
stream_is_big_endian);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dissect_giop_reply_1_2 (payload_tvb, pinfo, tree,
|
|
|
|
&header, stream_is_big_endian);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CancelRequest:
|
|
|
|
dissect_giop_cancel_request(payload_tvb, pinfo, tree,
|
2010-01-18 18:00:23 +00:00
|
|
|
stream_is_big_endian);
|
2010-02-01 16:18:18 +00:00
|
|
|
break;
|
|
|
|
case LocateRequest:
|
|
|
|
dissect_giop_locate_request(payload_tvb, pinfo, tree, &header,
|
|
|
|
stream_is_big_endian);
|
|
|
|
break;
|
|
|
|
case LocateReply:
|
|
|
|
dissect_giop_locate_reply(payload_tvb, pinfo, tree, &header,
|
|
|
|
stream_is_big_endian);
|
|
|
|
break;
|
|
|
|
case Fragment:
|
|
|
|
dissect_giop_fragment(payload_tvb, pinfo, tree,
|
|
|
|
stream_is_big_endian);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-07-13 20:12:53 +00:00
|
|
|
|
2010-02-01 16:18:18 +00:00
|
|
|
} /* switch message_type */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
2001-08-20 09:16:08 +00:00
|
|
|
/*
|
|
|
|
* XXX - we should catch exceptions here, so that we can free
|
|
|
|
* this if an exception is thrown.
|
|
|
|
* We'd then have to forward the exception.
|
|
|
|
*/
|
|
|
|
if (header.exception_id != NULL)
|
|
|
|
g_free(header.exception_id);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2005-09-01 19:31:48 +00:00
|
|
|
static guint
|
2006-10-31 09:29:07 +00:00
|
|
|
get_giop_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
|
2005-09-01 19:31:48 +00:00
|
|
|
{
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
MessageHeader header;
|
|
|
|
guint message_size;
|
|
|
|
gboolean stream_is_big_endian;
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if ( tvb_memeql(tvb, 0, GIOP_MAGIC ,4) != 0)
|
|
|
|
return 0;
|
2008-02-21 20:45:09 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
tvb_memcpy (tvb, (guint8 *)&header, offset, GIOP_HEADER_SIZE );
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
stream_is_big_endian = is_big_endian (&header);
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (stream_is_big_endian)
|
|
|
|
message_size = pntohl (&header.message_size);
|
|
|
|
else
|
|
|
|
message_size = pletohl (&header.message_size);
|
2005-09-01 19:31:48 +00:00
|
|
|
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return message_size + GIOP_HEADER_SIZE;
|
2005-09-01 19:31:48 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 19:51:08 +00:00
|
|
|
static gboolean
|
|
|
|
dissect_giop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
|
|
|
|
|
|
|
|
|
|
|
|
gboolean dissect_giop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|
|
|
return dissect_giop_heur(tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-24 13:46:41 +00:00
|
|
|
static void
|
2005-09-02 08:19:15 +00:00
|
|
|
dissect_giop_tcp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if ( tvb_memeql(tvb, 0, GIOP_MAGIC ,4) != 0) {
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if ( tvb_memeql(tvb, 0, ZIOP_MAGIC ,4) == 0)
|
|
|
|
dissect_ziop_heur(tvb, pinfo, tree);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
tcp_dissect_pdus(tvb, pinfo, tree, giop_desegment, GIOP_HEADER_SIZE,
|
|
|
|
get_giop_pdu_len, dissect_giop_common);
|
2005-09-01 19:31:48 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 12:51:14 +00:00
|
|
|
static gboolean
|
|
|
|
dissect_giop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
2005-09-01 19:31:48 +00:00
|
|
|
|
|
|
|
guint tot_len;
|
|
|
|
|
|
|
|
conversation_t *conversation;
|
|
|
|
/* check magic number and version */
|
|
|
|
|
|
|
|
|
|
|
|
/*define END_OF_GIOP_MESSAGE (offset - first_offset - GIOP_HEADER_SIZE) */
|
|
|
|
|
2007-10-23 05:50:00 +00:00
|
|
|
tot_len = tvb_length(tvb);
|
2007-03-24 13:46:41 +00:00
|
|
|
|
2005-09-01 19:31:48 +00:00
|
|
|
if (tot_len < GIOP_HEADER_SIZE) /* tot_len < 12 */
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
/* Not enough data captured to hold the GIOP header; don't try
|
|
|
|
to interpret it as GIOP. */
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-09-01 19:31:48 +00:00
|
|
|
if ( tvb_memeql(tvb, 0, GIOP_MAGIC ,4) != 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
return FALSE;
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2005-09-02 08:19:15 +00:00
|
|
|
if ( pinfo->ptype == PT_TCP )
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Make the GIOP dissector the dissector for this conversation.
|
|
|
|
*
|
|
|
|
* If this isn't the first time this packet has been processed,
|
|
|
|
* we've already done this work, so we don't need to do it
|
|
|
|
* again.
|
|
|
|
*/
|
|
|
|
if (!pinfo->fd->flags.visited)
|
2005-09-02 08:19:15 +00:00
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
conversation = find_conversation(pinfo->fd->num, &pinfo->src,
|
|
|
|
&pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
|
|
|
|
if (conversation == NULL)
|
|
|
|
{
|
|
|
|
conversation = conversation_new(pinfo->fd->num, &pinfo->src,
|
|
|
|
&pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
|
|
|
|
}
|
|
|
|
/* Set dissector */
|
|
|
|
conversation_set_dissector(conversation, giop_tcp_handle);
|
2005-09-02 08:19:15 +00:00
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
dissect_giop_tcp (tvb, pinfo, tree);
|
|
|
|
}
|
2005-09-02 08:19:15 +00:00
|
|
|
else
|
2010-01-18 18:00:23 +00:00
|
|
|
{
|
|
|
|
dissect_giop_common (tvb, pinfo, tree);
|
|
|
|
}
|
2005-09-01 19:31:48 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
void
|
|
|
|
proto_register_giop (void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2010-02-01 18:16:25 +00:00
|
|
|
{ &hf_giop_message_flags,
|
|
|
|
{ "Message Flags", "giop.flags",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_message_flags_ziop_enabled,
|
|
|
|
{ "ZIOP Enabled", "giop.flags.ziop_enabled",
|
|
|
|
FT_BOOLEAN, 8, NULL, GIOP_MESSAGE_FLAGS_ZIOP_ENABLED, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_message_flags_ziop_supported,
|
|
|
|
{ "ZIOP Supported", "giop.flags.ziop_supported",
|
|
|
|
FT_BOOLEAN, 8, NULL, GIOP_MESSAGE_FLAGS_ZIOP_SUPPORTED, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_message_flags_fragment,
|
|
|
|
{ "Fragment", "giop.flags.fragment",
|
|
|
|
FT_BOOLEAN, 8, NULL, GIOP_MESSAGE_FLAGS_FRAGMENT, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_message_flags_little_endian,
|
|
|
|
{ "Little Endian", "giop.flags.little_endian",
|
|
|
|
FT_BOOLEAN, 8, NULL, GIOP_MESSAGE_FLAGS_ENDIANNESS, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
{ &hf_giop_message_type,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Message type", "giop.type",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
{ &hf_giop_message_size,
|
|
|
|
{ "Message size", "giop.len",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_repoid,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Repository ID", "giop.repoid",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_string_length,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "String Length", "giop.strlen",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_sequence_length,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Sequence Length", "giop.seqlen",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_profile_id,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Profile ID", "giop.profid",
|
|
|
|
FT_UINT32, BASE_DEC, VALS(profile_id_vals), 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{ &hf_giop_type_id,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IOR::type_id", "giop.typeid",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_iiop_v_maj,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IIOP Major Version", "giop.iiop_vmaj",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
,
|
|
|
|
{ &hf_giop_iiop_v_min,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IIOP Minor Version", "giop.iiop_vmin",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
2008-02-21 20:45:09 +00:00
|
|
|
{ &hf_giop_compressed,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "ZIOP", "giop.compressed",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2008-02-21 20:45:09 +00:00
|
|
|
},
|
|
|
|
|
2008-12-17 17:23:37 +00:00
|
|
|
{ &hf_giop_endianness,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Endianness", "giop.endianness",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(giop_endianness_vals), 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_IIOP_tag,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IIOP Component TAG", "giop.iioptag",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_IOR_tag,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IOR Profile TAG", "giop.iortag",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_TCKind,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode enum", "giop.TCKind",
|
|
|
|
FT_UINT32, BASE_DEC, VALS(tckind_vals), 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_count,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode count", "giop.tccount",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_default_used,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "default_used", "giop.tcdefault_used",
|
|
|
|
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_digits,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Digits", "giop.tcdigits",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_length,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Length", "giop.tclength",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_max_length,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Maximum length", "giop.tcmaxlen",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_member_name,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode member name", "giop.tcmemname",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_name,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode name", "giop.tcname",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_scale,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Scale", "giop.tcscale",
|
|
|
|
FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_ValueModifier,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "ValueModifier", "giop.tcValueModifier",
|
|
|
|
FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_typecode_Visibility,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "Visibility", "giop.tcVisibility",
|
|
|
|
FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ &hf_giop_type_boolean,
|
|
|
|
{ "TypeCode boolean data", "giop.tcboolean",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_char,
|
|
|
|
{ "TypeCode char data", "giop.tcchar",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_double,
|
|
|
|
{ "TypeCode double data", "giop.tcdouble",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_enum,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode enum data", "giop.tcenumdata",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* float as double ?? -- FIX
|
|
|
|
*/
|
|
|
|
|
|
|
|
{ &hf_giop_type_float,
|
|
|
|
{ "TypeCode float data", "giop.tcfloat",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_long,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode long data", "giop.tclongdata",
|
|
|
|
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_octet,
|
|
|
|
{ "TypeCode octet data", "giop.tcoctet",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_short,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode short data", "giop.tcshortdata",
|
|
|
|
FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_string,
|
|
|
|
{ "TypeCode string data", "giop.tcstring",
|
2010-01-18 18:00:23 +00:00
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_ulong,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode ulong data", "giop.tculongdata",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_type_ushort,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "TypeCode ushort data", "giop.tcushortdata",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
2001-06-18 05:27:18 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IIOP Module - Chapter 15.10.2
|
|
|
|
*/
|
|
|
|
|
|
|
|
{ &hf_giop_iiop_host,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IIOP::Profile_host", "giop.iiop.host",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
|
|
|
},
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
{ &hf_giop_iiop_port,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "IIOP::Profile_port", "giop.iiop.port",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
|
|
|
|
},
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IIOP ServiceContext
|
|
|
|
*/
|
|
|
|
|
|
|
|
{ &hf_giop_iop_vscid,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "VSCID", "giop.iiop.vscid",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0xffffff00, NULL, HFILL }
|
|
|
|
},
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
{ &hf_giop_iop_scid,
|
2010-01-18 18:00:23 +00:00
|
|
|
{ "SCID", "giop.iiop.scid",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x000000ff, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_req_id,
|
|
|
|
{ "Request id", "giop.request_id",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_req_operation,
|
|
|
|
{ "Request operation", "giop.request_op",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_reply_status,
|
|
|
|
{ "Reply status", "giop.replystatus",
|
|
|
|
FT_UINT32, BASE_DEC, VALS(reply_status_types), 0x0, NULL, HFILL }
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_giop_exception_id,
|
|
|
|
{ "Exception id", "giop.exceptionid",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
|
|
|
},
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
{ &hf_giop_objekt_key,
|
|
|
|
{ "Object Key", "giop.objektkey",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
|
|
|
|
},
|
2005-09-04 08:53:04 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2007-03-24 13:46:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_giop,
|
2010-02-01 18:16:25 +00:00
|
|
|
&ett_giop_message_flags,
|
2001-06-18 05:27:18 +00:00
|
|
|
&ett_giop_reply,
|
|
|
|
&ett_giop_request,
|
|
|
|
&ett_giop_cancel_request,
|
|
|
|
&ett_giop_locate_request,
|
|
|
|
&ett_giop_locate_reply,
|
2001-07-03 23:30:01 +00:00
|
|
|
&ett_giop_fragment,
|
|
|
|
&ett_giop_scl,
|
2003-02-13 01:23:37 +00:00
|
|
|
&ett_giop_scl_st1,
|
2001-07-03 23:30:01 +00:00
|
|
|
&ett_giop_ior
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
};
|
2005-09-01 19:31:48 +00:00
|
|
|
module_t *giop_module;
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_giop = proto_register_protocol("General Inter-ORB Protocol", "GIOP",
|
2010-01-18 18:00:23 +00:00
|
|
|
"giop");
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_register_field_array (proto_giop, hf, array_length (hf));
|
|
|
|
proto_register_subtree_array (ett, array_length (ett));
|
|
|
|
|
|
|
|
|
|
|
|
/* register init routine */
|
|
|
|
|
|
|
|
register_init_routine( &giop_init); /* any init stuff */
|
|
|
|
|
2005-09-01 19:31:48 +00:00
|
|
|
/* register preferences */
|
|
|
|
giop_module = prefs_register_protocol(proto_giop, NULL);
|
|
|
|
prefs_register_bool_preference(giop_module, "desegment_giop_messages",
|
|
|
|
"Reassemble GIOP messages spanning multiple TCP segments",
|
|
|
|
"Whether the GIOP 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.",
|
|
|
|
&giop_desegment);
|
2006-04-18 10:04:18 +00:00
|
|
|
prefs_register_string_preference(giop_module, "ior_txt", "Stringified IORs",
|
|
|
|
"File containing stringified IORs, one per line.", &giop_ior_file);
|
2005-09-01 19:31:48 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Init the giop user module hash tables here, as giop users
|
|
|
|
* will populate it via register_giop_user_module BEFORE my
|
|
|
|
* own giop_init() is called.
|
|
|
|
*/
|
|
|
|
|
|
|
|
giop_module_hash = g_hash_table_new(giop_hash_module_hash, giop_hash_module_equal);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void proto_reg_handoff_giop (void) {
|
2001-11-26 04:52:51 +00:00
|
|
|
data_handle = find_dissector("data");
|
2005-09-01 19:31:48 +00:00
|
|
|
giop_tcp_handle = create_dissector_handle(dissect_giop_tcp, proto_giop);
|
|
|
|
heur_dissector_add("tcp", dissect_giop_heur, proto_giop);
|
2002-02-27 00:30:22 +00:00
|
|
|
/* Support DIOP (GIOP/UDP) */
|
2005-09-01 19:31:48 +00:00
|
|
|
heur_dissector_add("udp", dissect_giop_heur, proto_giop);
|
2008-11-13 01:31:57 +00:00
|
|
|
dissector_add_handle("tcp.port", giop_tcp_handle); /* for "decode-as" */
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode IOR
|
|
|
|
*
|
|
|
|
* Ref Corba v2.4.2 Chapter 13
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
module IOP{
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
typedef unsigned long ProfileId;
|
|
|
|
|
|
|
|
const ProfileId TAG_INTERNET_IOP = 0;
|
|
|
|
const ProfileId TAG_MULTIPLE_COMPONENTS = 1;
|
|
|
|
|
|
|
|
struct TaggedProfile {
|
|
|
|
ProfileId tag;
|
|
|
|
sequence <octet> profile_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IOR {
|
|
|
|
string type_id;
|
|
|
|
sequence <TaggedProfile> profiles;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef unsigned long ComponentId;
|
|
|
|
|
|
|
|
struct TaggedComponent {
|
|
|
|
ComponentId tag;
|
|
|
|
sequence <octet> component_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef sequence <TaggedComponent> MultipleComponentProfile;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2001-07-03 23:30:01 +00:00
|
|
|
void decode_IOR(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 boundary, gboolean stream_is_big_endian) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 seqlen_p; /* sequence length of profiles */
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 u_octet4;
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree *tree = NULL; /* IOR tree */
|
2001-07-03 23:30:01 +00:00
|
|
|
proto_item *tf;
|
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
gchar *repobuf; /* for repository ID */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2001-06-19 18:50:33 +00:00
|
|
|
guint32 i;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2001-07-03 23:30:01 +00:00
|
|
|
/* create a subtree */
|
|
|
|
|
|
|
|
if (ptree) {
|
2002-01-24 09:20:54 +00:00
|
|
|
tf = proto_tree_add_text (ptree, tvb, *offset, -1, "IOR");
|
2001-07-03 23:30:01 +00:00
|
|
|
tree = proto_item_add_subtree (tf, ett_giop_ior);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Get type_id == Repository ID */
|
|
|
|
|
|
|
|
u_octet4 = get_CDR_string(tvb,&repobuf,offset,stream_is_big_endian,boundary);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tree) {
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_string_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
if (u_octet4 > 0) {
|
|
|
|
proto_tree_add_string(tree,hf_giop_type_id,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4,u_octet4,repobuf);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* Register a cleanup function in case on of our tvbuff accesses
|
|
|
|
* throws an exception. We need to clean up repobuf.
|
|
|
|
* We can't free it yet, as we must wait until we have the object
|
|
|
|
* key, as we have to add both to the hash table.
|
|
|
|
*/
|
|
|
|
CLEANUP_PUSH(g_free, repobuf);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* Now get a sequence of profiles */
|
|
|
|
/* Get sequence length (number of elements) */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
seqlen_p = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_sequence_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(seqlen_p),4,seqlen_p);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* fetch all TaggedProfiles in this sequence */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
for (i=0; i< seqlen_p; i++) { /* for every TaggedProfile */
|
|
|
|
decode_TaggedProfile(tvb, pinfo, tree, offset, boundary, stream_is_big_endian, repobuf);
|
|
|
|
}
|
2001-07-26 16:59:28 +00:00
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* We're done with repobuf, so we can call the cleanup handler to free
|
|
|
|
* it, and then pop the cleanup handler.
|
|
|
|
*/
|
|
|
|
CLEANUP_CALL_AND_POP;
|
2001-07-26 16:59:28 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void decode_TaggedProfile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 boundary, gboolean stream_is_big_endian, gchar *repobuf) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 seqlen_pd; /* sequence length of profile data */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 pidtag; /* profile ID TAG */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
gchar *profile_data; /* profile_data pointer */
|
|
|
|
gchar *p_profile_data; /* printable profile_data pointer */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 new_boundary; /* for encapsulations encountered */
|
|
|
|
gboolean new_big_endianness; /* for encapsulations encountered */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* Get ProfileId tag */
|
|
|
|
|
|
|
|
pidtag = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_profile_id,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(pidtag),4,pidtag);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
seqlen_pd = get_CDR_encap_info(tvb, tree, offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_big_endianness, &new_boundary);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* return if zero length sequence */
|
|
|
|
|
|
|
|
if(seqlen_pd == 0)
|
|
|
|
return;
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Lets see what kind of TAG it is. If TAG_INTERNET_IOP then
|
|
|
|
* decode it, otherwise just dump the octet sequence
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* also, store IOR in our objectkey hash
|
|
|
|
*
|
|
|
|
* TODO - handle other TAGS
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch(pidtag) {
|
|
|
|
case IOP_TAG_INTERNET_IOP:
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2008-12-17 17:23:37 +00:00
|
|
|
decode_IIOP_IOR_profile(tvb, pinfo, tree, offset, new_boundary, new_big_endianness, repobuf, TRUE);
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2008-12-17 17:23:37 +00:00
|
|
|
/* fetch all octets in this sequence , but skip endianness */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-07-27 18:31:56 +00:00
|
|
|
get_CDR_octet_seq(tvb, &profile_data, offset, seqlen_pd -1);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Make a printable string */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-07-27 18:31:56 +00:00
|
|
|
p_profile_data = make_printable_string( profile_data, seqlen_pd -1);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if(tree) {
|
2001-07-27 18:31:56 +00:00
|
|
|
proto_tree_add_text (tree, tvb, *offset -seqlen_pd + 1, seqlen_pd - 1,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Profile Data: %s", p_profile_data);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
g_free(p_profile_data);
|
|
|
|
|
|
|
|
g_free(profile_data);
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode IIOP IOR Profile
|
|
|
|
* Ref Chap 15.7.2 in Corba Spec
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static void decode_IIOP_IOR_profile(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 boundary, gboolean stream_is_big_endian, gchar *repo_id_buf,
|
|
|
|
gboolean store_flag) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 i; /* loop index */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint8 v_major,v_minor; /* IIOP version */
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *buf;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 u_octet4; /* u long */
|
|
|
|
guint16 u_octet2; /* u short */
|
|
|
|
guint32 seqlen; /* generic sequence length */
|
|
|
|
guint32 seqlen1; /* generic sequence length */
|
|
|
|
gchar *objkey; /* object key pointer */
|
|
|
|
gchar *p_chars; /* printable characters pointer */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Get major/minor version */
|
|
|
|
|
|
|
|
v_major = get_CDR_octet(tvb,offset);
|
|
|
|
v_minor = get_CDR_octet(tvb,offset);
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tree) {
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_iiop_v_maj,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(v_minor)-sizeof(v_major),1,v_major );
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_iiop_v_min,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(v_minor),1,v_minor );
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* host */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
u_octet4 = get_CDR_string(tvb,&buf,offset,stream_is_big_endian,boundary);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_string_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
if (u_octet4 > 0) {
|
|
|
|
proto_tree_add_string(tree,hf_giop_iiop_host,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4,u_octet4,buf);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_free(buf); /* dont forget */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Port */
|
|
|
|
|
|
|
|
u_octet2 = get_CDR_ushort(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tree) {
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_iiop_port,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet2),2,u_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Object Key - sequence<octet> object_key */
|
|
|
|
|
|
|
|
seqlen = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_sequence_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(seqlen),4,seqlen);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (seqlen > 0) {
|
2002-08-28 21:04:11 +00:00
|
|
|
/* fetch all octets in this sequence */
|
2001-06-18 05:27:18 +00:00
|
|
|
get_CDR_octet_seq(tvb, &objkey, offset, seqlen);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we may have the Repository ID from earlier, as well
|
|
|
|
* as the object key sequence and lengh. So lets store them in
|
|
|
|
* our objectkey hash and free buffers.
|
|
|
|
*
|
|
|
|
* But only insert if user is not clicking and repo id not NULL.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (repo_id_buf) {
|
|
|
|
if (pinfo) {
|
2010-01-18 18:00:23 +00:00
|
|
|
if(!pinfo->fd->flags.visited)
|
2010-02-01 18:16:25 +00:00
|
|
|
insert_in_objkey_hash(giop_objkey_hash,objkey,seqlen,repo_id_buf,ior_src_req_res);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/*
|
|
|
|
* No pinfo, but store anyway if flag set. eg: IOR read from file
|
|
|
|
*/
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (store_flag)
|
2010-02-01 18:16:25 +00:00
|
|
|
insert_in_objkey_hash(giop_objkey_hash,objkey,seqlen,repo_id_buf,ior_src_file);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tree) {
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_item(tree, hf_giop_objekt_key, tvb, *offset -seqlen, seqlen, FALSE);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
g_free(objkey);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Now see if if its v1.1 or 1.2, as they can contain
|
|
|
|
* extra sequence of IOP::TaggedComponents
|
|
|
|
*
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
switch(v_minor) {
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
/* nothing extra */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
/* sequence of IOP::TaggedComponents */
|
|
|
|
/* Ref Chap 13 in Corba Spec */
|
|
|
|
|
|
|
|
/* get sequence length */
|
|
|
|
seqlen = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_sequence_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(seqlen),4,seqlen);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i< seqlen; i++) {
|
|
|
|
/* get tag */
|
|
|
|
u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_IIOP_tag,tvb,
|
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get component_data */
|
|
|
|
seqlen1 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_sequence_length,tvb,
|
|
|
|
*offset-sizeof(seqlen1),4,seqlen1);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (seqlen1 > 0) {
|
2010-01-18 18:00:23 +00:00
|
|
|
get_CDR_octet_seq(tvb, &buf, offset, seqlen1);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
if (tree) {
|
|
|
|
/* Make a printable string of data */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
p_chars = make_printable_string(buf, seqlen1);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_text (tree, tvb, *offset -seqlen1, seqlen1,
|
|
|
|
"component_data: %s", p_chars);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_free(p_chars);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_free(buf);
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_warning("giop:Invalid v_minor value = %u ", v_minor);
|
|
|
|
break;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2003-02-18 02:03:29 +00:00
|
|
|
/*
|
2003-03-05 15:33:12 +00:00
|
|
|
* From Section 13.10.2.5 of the CORBA 3.0 spec.
|
|
|
|
*
|
|
|
|
* module CONV_FRAME {
|
|
|
|
* typedef unsigned long CodeSetId;
|
|
|
|
* struct CodeSetContext {
|
|
|
|
* CodeSetId char_data;
|
|
|
|
* CodeSetId wchar_data;
|
|
|
|
* };
|
2007-03-24 13:46:41 +00:00
|
|
|
* };
|
|
|
|
*
|
2003-03-05 15:33:12 +00:00
|
|
|
* Code sets are identified by a 32-bit integer id from OSF.
|
|
|
|
* See: ftp://ftp.opengroup.org/pub/code_set_registry
|
2003-02-18 02:03:29 +00:00
|
|
|
*/
|
2008-02-21 20:45:09 +00:00
|
|
|
static const value_string giop_code_set_vals[] = {
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x00010001, "ISO_8859_1" },
|
|
|
|
{ 0x00010002, "ISO_8859_2" },
|
|
|
|
{ 0x00010003, "ISO_8859_3" },
|
|
|
|
{ 0x00010004, "ISO_8859_4" },
|
|
|
|
{ 0x00010005, "ISO_8859_5" },
|
|
|
|
{ 0x00010006, "ISO_8859_6" },
|
|
|
|
{ 0x00010007, "ISO_8859_7" },
|
|
|
|
{ 0x00010008, "ISO_8859_8" },
|
|
|
|
{ 0x00010009, "ISO_8859_9" },
|
|
|
|
{ 0x0001000A, "ISO_8859_10" },
|
|
|
|
{ 0x0001000F, "ISO_8859_15" },
|
|
|
|
{ 0x00010020, "ISO_646" },
|
2008-02-21 20:45:09 +00:00
|
|
|
{ 0x00010100, "ISO_UCS_2_LEVEL_1" },
|
2010-01-18 18:00:23 +00:00
|
|
|
{ 0x00010101, "ISO_UCS_2_LEVEL_2" },
|
|
|
|
{ 0x00010102, "ISO_UCS_2_LEVEL_3" },
|
|
|
|
{ 0x00010104, "ISO_UCS_4_LEVEL_1" },
|
|
|
|
{ 0x00010105, "ISO_UCS_4_LEVEL_2" },
|
|
|
|
{ 0x00010106, "ISO_UCS_4_LEVEL_3" },
|
2008-02-21 22:11:08 +00:00
|
|
|
{ 0x00010108, "ISO_UTF_8" },
|
|
|
|
{ 0x00010109, "ISO_UTF_16" },
|
|
|
|
{ 0x00030001, "JIS_X0201" },
|
|
|
|
{ 0x00030004, "JIS_X0208_1978" },
|
|
|
|
{ 0x00030005, "JIS_X0208_1983" },
|
|
|
|
{ 0x00030006, "JIS_X0208_1990" },
|
|
|
|
{ 0x0003000A, "JIS_X0212" },
|
|
|
|
{ 0x00030010, "JIS_EUCJP" },
|
|
|
|
{ 0x00040001, "KS_C5601" },
|
|
|
|
{ 0x00040002, "KS_C5657" },
|
|
|
|
{ 0x0004000A, "KS_EUCKR" },
|
|
|
|
{ 0x00050001, "CNS_11643_1986" },
|
|
|
|
{ 0x00050002, "CNS_11643_1992" },
|
|
|
|
{ 0x0005000A, "CNS_EUCTW_1991" },
|
|
|
|
{ 0x00050010, "CNS_EUCTW_1993" },
|
|
|
|
{ 0x000B0001, "TIS_620_2529" },
|
|
|
|
{ 0x000D0001, "TTB_CCDC" },
|
|
|
|
{ 0x05000010, "OSF_JAPANESE_UJIS" },
|
|
|
|
{ 0x05000011, "OSF_JAPANESE_SJIS_1" },
|
|
|
|
{ 0x05000012, "OSF_JAPANESE_SJIS_2" },
|
|
|
|
{ 0x05010001, "XOPEN_UTF_8" },
|
|
|
|
{ 0x05020001, "JVC_EUCJP" },
|
|
|
|
{ 0x05020002, "JVC_SJIS" },
|
|
|
|
{ 0x10000001, "DEC_KANJI" },
|
|
|
|
{ 0x10000002, "SUPER_DEC_KANJI" },
|
|
|
|
{ 0x10000003, "DEC_SHIFT_JIS" },
|
|
|
|
{ 0x10010001, "HP_ROMAN8" },
|
|
|
|
{ 0x10010002, "HP_KANA8" },
|
|
|
|
{ 0x10010003, "HP_ARABIC8" },
|
|
|
|
{ 0x10010004, "HP_GREEK8" },
|
|
|
|
{ 0x10010005, "HP_HEBREW8" },
|
|
|
|
{ 0x10010006, "HP_TURKISH8" },
|
|
|
|
{ 0x10010007, "HP15CN" },
|
|
|
|
{ 0x10010008, "HP_BIG5" },
|
|
|
|
{ 0x10010009, "HP_JAPANESE15__SJIS_" },
|
|
|
|
{ 0x1001000A, "HP_SJISHI" },
|
|
|
|
{ 0x1001000B, "HP_SJISPC" },
|
|
|
|
{ 0x1001000C, "HP_UJIS" },
|
|
|
|
{ 0x10020025, "IBM_037" },
|
|
|
|
{ 0x10020111, "IBM_273" },
|
|
|
|
{ 0x10020115, "IBM_277" },
|
|
|
|
{ 0x10020116, "IBM_278" },
|
|
|
|
{ 0x10020118, "IBM_280" },
|
|
|
|
{ 0x1002011A, "IBM_282" },
|
|
|
|
{ 0x1002011C, "IBM_284" },
|
|
|
|
{ 0x1002011D, "IBM_285" },
|
|
|
|
{ 0x10020122, "IBM_290" },
|
|
|
|
{ 0x10020129, "IBM_297" },
|
|
|
|
{ 0x1002012C, "IBM_300" },
|
|
|
|
{ 0x1002012D, "IBM_301" },
|
|
|
|
{ 0x100201A4, "IBM_420" },
|
|
|
|
{ 0x100201A8, "IBM_424" },
|
|
|
|
{ 0x100201B5, "IBM_437" },
|
|
|
|
{ 0x100201F4, "IBM_500" },
|
|
|
|
{ 0x10020341, "IBM_833" },
|
|
|
|
{ 0x10020342, "IBM_834" },
|
|
|
|
{ 0x10020343, "IBM_835" },
|
|
|
|
{ 0x10020344, "IBM_836" },
|
|
|
|
{ 0x10020345, "IBM_837" },
|
|
|
|
{ 0x10020346, "IBM_838" },
|
|
|
|
{ 0x10020347, "IBM_839" },
|
|
|
|
{ 0x10020352, "IBM_850" },
|
|
|
|
{ 0x10020354, "IBM_852" },
|
|
|
|
{ 0x10020357, "IBM_855" },
|
|
|
|
{ 0x10020358, "IBM_856" },
|
|
|
|
{ 0x10020359, "IBM_857" },
|
|
|
|
{ 0x1002035D, "IBM_861" },
|
|
|
|
{ 0x1002035E, "IBM_862" },
|
|
|
|
{ 0x1002035F, "IBM_863" },
|
|
|
|
{ 0x10020360, "IBM_864" },
|
|
|
|
{ 0x10020362, "IBM_866" },
|
|
|
|
{ 0x10020364, "IBM_868" },
|
|
|
|
{ 0x10020365, "IBM_869" },
|
|
|
|
{ 0x10020366, "IBM_870" },
|
|
|
|
{ 0x10020367, "IBM_871" },
|
|
|
|
{ 0x1002036A, "IBM_874" },
|
|
|
|
{ 0x1002036B, "IBM_875" },
|
|
|
|
{ 0x10020370, "IBM_880" },
|
|
|
|
{ 0x1002037B, "IBM_891" },
|
|
|
|
{ 0x10020380, "IBM_896" },
|
|
|
|
{ 0x10020381, "IBM_897" },
|
|
|
|
{ 0x10020387, "IBM_903" },
|
|
|
|
{ 0x10020388, "IBM_904" },
|
|
|
|
{ 0x10020396, "IBM_918" },
|
|
|
|
{ 0x10020399, "IBM_921" },
|
|
|
|
{ 0x1002039A, "IBM_922" },
|
|
|
|
{ 0x1002039E, "IBM_926" },
|
|
|
|
{ 0x1002039F, "IBM_927" },
|
|
|
|
{ 0x100203A0, "IBM_928" },
|
|
|
|
{ 0x100203A1, "IBM_929" },
|
|
|
|
{ 0x100203A2, "IBM_930" },
|
|
|
|
{ 0x100203A4, "IBM_932" },
|
|
|
|
{ 0x100203A5, "IBM_933" },
|
|
|
|
{ 0x100203A6, "IBM_934" },
|
|
|
|
{ 0x100203A7, "IBM_935" },
|
|
|
|
{ 0x100203A8, "IBM_936" },
|
|
|
|
{ 0x100203A9, "IBM_937" },
|
|
|
|
{ 0x100203AA, "IBM_938" },
|
|
|
|
{ 0x100203AB, "IBM_939" },
|
|
|
|
{ 0x100203AD, "IBM_941" },
|
|
|
|
{ 0x100203AE, "IBM_942" },
|
|
|
|
{ 0x100203AF, "IBM_943" },
|
|
|
|
{ 0x100203B2, "IBM_946" },
|
|
|
|
{ 0x100203B3, "IBM_947" },
|
|
|
|
{ 0x100203B4, "IBM_948" },
|
|
|
|
{ 0x100203B5, "IBM_949" },
|
|
|
|
{ 0x100203B6, "IBM_950" },
|
|
|
|
{ 0x100203B7, "IBM_951" },
|
|
|
|
{ 0x100203BB, "IBM_955" },
|
|
|
|
{ 0x100203C4, "IBM_964" },
|
|
|
|
{ 0x100203CA, "IBM_970" },
|
|
|
|
{ 0x100203EE, "IBM_1006" },
|
|
|
|
{ 0x10020401, "IBM_1025" },
|
|
|
|
{ 0x10020402, "IBM_1026" },
|
|
|
|
{ 0x10020403, "IBM_1027" },
|
|
|
|
{ 0x10020410, "IBM_1040" },
|
|
|
|
{ 0x10020411, "IBM_1041" },
|
|
|
|
{ 0x10020413, "IBM_1043" },
|
|
|
|
{ 0x10020416, "IBM_1046" },
|
|
|
|
{ 0x10020417, "IBM_1047" },
|
|
|
|
{ 0x10020440, "IBM_1088" },
|
|
|
|
{ 0x10020449, "IBM_1097" },
|
|
|
|
{ 0x1002044A, "IBM_1098" },
|
|
|
|
{ 0x10020458, "IBM_1112" },
|
|
|
|
{ 0x1002045A, "IBM_1114" },
|
|
|
|
{ 0x1002045B, "IBM_1115" },
|
|
|
|
{ 0x10020462, "IBM_1122" },
|
|
|
|
{ 0x100204E2, "IBM_1250" },
|
|
|
|
{ 0x100204E3, "IBM_1251" },
|
|
|
|
{ 0x100204E4, "IBM_1252" },
|
|
|
|
{ 0x100204E5, "IBM_1253" },
|
|
|
|
{ 0x100204E6, "IBM_1254" },
|
|
|
|
{ 0x100204E7, "IBM_1255" },
|
|
|
|
{ 0x100204E8, "IBM_1256" },
|
|
|
|
{ 0x100204E9, "IBM_1257" },
|
|
|
|
{ 0x10020564, "IBM_1380" },
|
|
|
|
{ 0x10020565, "IBM_1381" },
|
|
|
|
{ 0x10020567, "IBM_1383" },
|
|
|
|
{ 0x1002112C, "IBM_4396" },
|
|
|
|
{ 0x10021352, "IBM_4946" },
|
|
|
|
{ 0x10021354, "IBM_4948" },
|
|
|
|
{ 0x10021357, "IBM_4951" },
|
|
|
|
{ 0x10021358, "IBM_4952" },
|
|
|
|
{ 0x10021359, "IBM_4953" },
|
|
|
|
{ 0x10021360, "IBM_4960" },
|
|
|
|
{ 0x10021364, "IBM_4964" },
|
|
|
|
{ 0x10021365, "IBM_4965" },
|
|
|
|
{ 0x100213A2, "IBM_5026" },
|
|
|
|
{ 0x100213A7, "IBM_5031" },
|
|
|
|
{ 0x100213AB, "IBM_5035" },
|
|
|
|
{ 0x100213B8, "IBM_5048" },
|
|
|
|
{ 0x100213B9, "IBM_5049" },
|
|
|
|
{ 0x100213CB, "IBM_5067" },
|
|
|
|
{ 0x100221A4, "IBM_8612" },
|
|
|
|
{ 0x10022341, "IBM_9025" },
|
|
|
|
{ 0x10022342, "IBM_9026" },
|
|
|
|
{ 0x10022346, "IBM_9030" },
|
|
|
|
{ 0x10022360, "IBM_9056" },
|
|
|
|
{ 0x1002236A, "IBM_9066" },
|
|
|
|
{ 0x100223A5, "IBM_9125" },
|
|
|
|
{ 0x10026352, "IBM_25426" },
|
|
|
|
{ 0x10026358, "IBM_25432" },
|
|
|
|
{ 0x10026412, "IBM_1042" },
|
|
|
|
{ 0x10027025, "IBM_28709" },
|
|
|
|
{ 0x10028358, "IBM_33624" },
|
|
|
|
{ 0x100283BA, "IBM_33722" },
|
|
|
|
{ 0x10030001, "HTCSJIS" },
|
|
|
|
{ 0x10030002, "HTCUJIS" },
|
|
|
|
{ 0x10040001, "FUJITSU_U90" },
|
|
|
|
{ 0x10040002, "FUJITSU_S90" },
|
|
|
|
{ 0x10040003, "FUJITSU_R90" },
|
|
|
|
{ 0x10040004, "EBCDIC_ASCII_AND_JEF" },
|
|
|
|
{ 0x10040005, "EBCDIC_KATAKANA_AND_JEF" },
|
|
|
|
{ 0x10040006, "EBCDIC_JAPANESE_ENGLISH_AND_JEF" },
|
|
|
|
{ 0, NULL }
|
2008-02-21 20:45:09 +00:00
|
|
|
};
|
|
|
|
|
2003-02-18 02:03:29 +00:00
|
|
|
static void decode_CodeSets(tvbuff_t *tvb, proto_tree *tree, int *offset,
|
2003-03-05 15:33:12 +00:00
|
|
|
gboolean stream_is_be, guint32 boundary) {
|
2003-02-18 02:03:29 +00:00
|
|
|
|
2007-03-24 13:46:41 +00:00
|
|
|
/* The boundary being passed in is the offset where the context_data
|
2003-03-05 15:33:12 +00:00
|
|
|
* sequence begins. */
|
2007-03-24 13:46:41 +00:00
|
|
|
|
2003-02-18 02:03:29 +00:00
|
|
|
guint32 code_set_id;
|
|
|
|
if(tree) {
|
2003-03-05 15:33:12 +00:00
|
|
|
/* We pass in -boundary, because the alignment is calculated relative to
|
|
|
|
the beginning of the context_data sequence.
|
2007-03-24 13:46:41 +00:00
|
|
|
Inside get_CDR_ulong(), the calculation will be (offset +(- boundary)) % 4
|
2003-03-05 15:33:12 +00:00
|
|
|
to determine the correct alignment of the short. */
|
2003-12-28 12:43:40 +00:00
|
|
|
code_set_id = get_CDR_ulong(tvb, offset, stream_is_be, -((gint32) boundary) );
|
2003-02-18 02:03:29 +00:00
|
|
|
|
|
|
|
proto_tree_add_text (tree, tvb, *offset - 4, 4,
|
2008-02-21 20:45:09 +00:00
|
|
|
"char_data: 0x%08x %s", code_set_id, val_to_str(code_set_id, giop_code_set_vals, "Unknown (%u)") );
|
2003-02-18 02:03:29 +00:00
|
|
|
|
2003-12-28 12:43:40 +00:00
|
|
|
code_set_id = get_CDR_ulong(tvb, offset, stream_is_be, -((gint32) boundary) );
|
2003-02-18 02:03:29 +00:00
|
|
|
|
|
|
|
proto_tree_add_text (tree, tvb, *offset - 4, 4,
|
2008-02-21 22:11:08 +00:00
|
|
|
"wchar_data: 0x%08x %s", code_set_id, val_to_str(code_set_id, giop_code_set_vals, "Unknown (%u)") );
|
2008-02-21 20:45:09 +00:00
|
|
|
|
2003-02-18 02:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2003-02-13 01:23:37 +00:00
|
|
|
* From Section 2.7.3 of the Real-time CORBA 1.1 Standard, the CORBA priority
|
|
|
|
* is represented in the GIOP service request as:
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
2003-02-13 01:23:37 +00:00
|
|
|
* module IOP {
|
|
|
|
* typedef short ServiceId;
|
|
|
|
* const ServiceId RTCorbaPriority = 10;
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* The RT-CORBA priority is a CDR encoded short value in a sequence<octet>
|
|
|
|
* buffer.
|
2007-03-24 13:46:41 +00:00
|
|
|
*/
|
|
|
|
static void decode_RTCorbaPriority(tvbuff_t *tvb, proto_tree *tree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_be, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2007-03-24 13:46:41 +00:00
|
|
|
/* The boundary being passed in is the offset where the context_data
|
2003-03-05 15:33:12 +00:00
|
|
|
* sequence begins. */
|
2007-03-24 13:46:41 +00:00
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
gint16 rtpriority;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
/* RTCorbaPriority is stored as a CDR encoded short */
|
2003-03-05 15:33:12 +00:00
|
|
|
/* We pass in -boundary, because the alignment is calculated relative to
|
|
|
|
the beginning of the context_data sequence.
|
|
|
|
Inside get_CDR_short(), the calculation will be (offset + (- boundary)) % 2
|
|
|
|
to determine the correct alignment of the short. */
|
2003-12-28 12:43:40 +00:00
|
|
|
rtpriority = get_CDR_short(tvb, offset, stream_is_be, -((gint32) boundary) );
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
if(tree) {
|
2007-03-24 13:46:41 +00:00
|
|
|
/* Highlight all of context_data except for the first endian byte */
|
2003-03-05 15:33:12 +00:00
|
|
|
proto_tree_add_text (tree, tvb, *offset - 2, 2,
|
2003-02-13 01:23:37 +00:00
|
|
|
"RTCorbaPriority: %d", rtpriority);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
static void decode_UnknownServiceContext(tvbuff_t *tvb, proto_tree *tree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_be, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
guint32 context_data_len;
|
2003-02-13 01:23:37 +00:00
|
|
|
gchar *p_context_data;
|
|
|
|
gchar *context_data;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
/* get sequence length, and NO encapsulation */
|
2003-03-05 15:33:12 +00:00
|
|
|
context_data_len = get_CDR_ulong(tvb, offset, stream_is_be,boundary);
|
2003-02-13 01:23:37 +00:00
|
|
|
|
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
/* return if zero length sequence */
|
|
|
|
if(context_data_len == 0)
|
|
|
|
return;
|
2003-02-18 02:24:51 +00:00
|
|
|
|
|
|
|
/*
|
2003-03-05 15:33:12 +00:00
|
|
|
* Now decode sequence according to vendor ServiceId, but I dont
|
2003-02-18 02:24:51 +00:00
|
|
|
* have that yet, so just dump it as data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* fetch all octets in this sequence */
|
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
get_CDR_octet_seq(tvb, &context_data, offset, context_data_len);
|
2003-02-18 02:24:51 +00:00
|
|
|
|
|
|
|
/* Make a printable string */
|
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
p_context_data = make_printable_string( context_data, context_data_len );
|
2003-02-18 02:24:51 +00:00
|
|
|
|
|
|
|
if(tree) {
|
2003-03-05 15:33:12 +00:00
|
|
|
proto_tree_add_text (tree, tvb, *offset - context_data_len , context_data_len,
|
2010-01-18 18:00:23 +00:00
|
|
|
"context_data: %s", p_context_data);
|
2003-02-18 02:24:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free(context_data);
|
|
|
|
g_free(p_context_data);
|
|
|
|
}
|
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/*
|
|
|
|
* Corba , chp 13.7
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* typedef unsigned long ServiceID;
|
|
|
|
*
|
|
|
|
* struct ServiceContext {
|
|
|
|
* ServiceID context_id;
|
|
|
|
* sequence <octet> context_data;
|
|
|
|
* };
|
|
|
|
* typedef sequence <ServiceContext> ServiceContextList;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Note: Spec says context_data is an encapsulation.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-05-02 19:39:05 +00:00
|
|
|
void decode_ServiceContextList(tvbuff_t *tvb, proto_tree *ptree, int *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_be, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
guint32 context_data_len; /* context data sequence length */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree *tree = NULL; /* ServiceContext tree */
|
2003-02-13 01:23:37 +00:00
|
|
|
proto_tree *sub_tree1 = NULL;
|
2003-03-05 15:33:12 +00:00
|
|
|
proto_item *tf = NULL, *tf_st1;
|
2001-07-03 23:30:01 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 context_id;
|
|
|
|
|
2001-06-19 18:50:33 +00:00
|
|
|
guint32 i;
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 vscid; /* Vendor Service context id */
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 scid;
|
2003-02-13 01:23:37 +00:00
|
|
|
const gchar *service_context_name;
|
|
|
|
gboolean encapsulation_is_be;
|
|
|
|
guint32 encapsulation_boundary;
|
2003-03-05 15:33:12 +00:00
|
|
|
int temp_offset, temp_offset1;
|
2003-02-13 23:18:59 +00:00
|
|
|
int start_offset = *offset;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2001-07-03 23:30:01 +00:00
|
|
|
/* create a subtree */
|
|
|
|
|
|
|
|
if (ptree) {
|
2003-02-13 23:18:59 +00:00
|
|
|
/* set length to 0 now and correct with proto_item_set_len() later */
|
|
|
|
tf = proto_tree_add_text (ptree, tvb, *offset, 0, "ServiceContextList");
|
|
|
|
|
2001-07-03 23:30:01 +00:00
|
|
|
tree = proto_item_add_subtree (tf, ett_giop_scl);
|
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* Get sequence length (number of elements) */
|
|
|
|
seqlen = get_CDR_ulong(tvb,offset,stream_is_be,boundary);
|
2003-02-13 23:18:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_sequence_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(seqlen),4,seqlen);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return if zero length sequence */
|
|
|
|
|
2003-02-13 23:18:59 +00:00
|
|
|
if (seqlen == 0) {
|
2005-04-17 18:28:50 +00:00
|
|
|
if (tf) {
|
|
|
|
if (*offset - start_offset <= 0)
|
|
|
|
THROW(ReportedBoundsError);
|
2003-02-13 23:18:59 +00:00
|
|
|
proto_item_set_len(tf, *offset - start_offset);
|
2005-04-17 18:28:50 +00:00
|
|
|
}
|
2003-02-13 23:18:59 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
return;
|
2003-02-13 23:18:59 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
/* Loop for all ServiceContext's */
|
|
|
|
|
|
|
|
for (i=0; i<seqlen; i++) {
|
|
|
|
|
|
|
|
context_id = get_CDR_ulong(tvb,offset,stream_is_be,boundary);
|
2003-02-13 23:18:59 +00:00
|
|
|
vscid = (context_id & 0xffffff00) >> 8; /* vendor info, top 24 bits */
|
2003-02-13 01:23:37 +00:00
|
|
|
scid = context_id & 0x000000ff; /* standard service info, lower 8 bits */
|
2003-03-05 15:33:12 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_iop_vscid,tvb,
|
|
|
|
*offset-sizeof(guint32),4,vscid);
|
2003-03-05 15:33:12 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_iop_scid,tvb,
|
|
|
|
*offset-sizeof(guint32),4,scid);
|
2003-03-05 15:33:12 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
}
|
2003-03-05 15:33:12 +00:00
|
|
|
|
|
|
|
if( vscid == 0) { /* OMG specified */
|
2010-01-18 18:00:23 +00:00
|
|
|
service_context_name = val_to_str(scid, service_context_ids, "(0x%x)");
|
2003-03-05 15:33:12 +00:00
|
|
|
} else { /* Proprietary vscid */
|
2010-01-18 18:00:23 +00:00
|
|
|
service_context_name = "Unknown";
|
2007-03-24 13:46:41 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2003-02-13 01:23:37 +00:00
|
|
|
if(tree) {
|
2003-03-05 15:33:12 +00:00
|
|
|
proto_tree_add_text (tree, tvb, *offset -sizeof(context_id), 4,
|
2007-03-24 13:46:41 +00:00
|
|
|
"Service Context ID: %s (%u)", service_context_name,
|
2010-01-18 18:00:23 +00:00
|
|
|
context_id);
|
2003-03-05 15:33:12 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
temp_offset1 = *offset;
|
|
|
|
/* The OMG has vscid of 0 reserved */
|
|
|
|
if( vscid != 0 || scid > max_service_context_id ) {
|
2010-01-18 18:00:23 +00:00
|
|
|
decode_UnknownServiceContext(tvb, tree, offset, stream_is_be, boundary);
|
|
|
|
continue;
|
2003-02-13 01:23:37 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
temp_offset = *offset;
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
|
|
|
context_data_len = get_CDR_encap_info(tvb, sub_tree1, offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
stream_is_be, boundary,
|
|
|
|
&encapsulation_is_be , &encapsulation_boundary);
|
2003-03-05 15:33:12 +00:00
|
|
|
|
2003-02-13 23:18:59 +00:00
|
|
|
if (tree) {
|
2008-10-31 15:11:57 +00:00
|
|
|
tf_st1 = proto_tree_add_text (tree, tvb, temp_offset, sizeof(context_data_len) + context_data_len , "%s", service_context_name);
|
2003-02-13 23:18:59 +00:00
|
|
|
sub_tree1 = proto_item_add_subtree (tf_st1, ett_giop_scl_st1);
|
|
|
|
}
|
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
if (context_data_len == 0)
|
2010-01-18 18:00:23 +00:00
|
|
|
continue;
|
2003-02-18 02:24:51 +00:00
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
/* See CORBA 3.0.2 standard, section Section 15.3.3 "Encapsulation",
|
|
|
|
* for how CDR types can be marshalled into a sequence<octet>.
|
|
|
|
* The first octet in the sequence determines endian order,
|
|
|
|
* 0 == big-endian, 1 == little-endian
|
|
|
|
*/
|
2003-02-14 07:14:18 +00:00
|
|
|
|
2003-03-05 15:33:12 +00:00
|
|
|
switch(scid)
|
|
|
|
{
|
2010-01-18 18:00:23 +00:00
|
|
|
case 0x01: /* Codesets */
|
|
|
|
decode_CodeSets(tvb, sub_tree1, offset,
|
|
|
|
encapsulation_is_be, encapsulation_boundary);
|
|
|
|
break;
|
|
|
|
case 0x0a: /* RTCorbaPriority */
|
|
|
|
decode_RTCorbaPriority(tvb, sub_tree1, offset,
|
|
|
|
encapsulation_is_be, encapsulation_boundary);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Need to fill these in as we learn them */
|
|
|
|
*offset = temp_offset1;
|
|
|
|
decode_UnknownServiceContext(tvb, sub_tree1, offset, stream_is_be,
|
|
|
|
boundary);
|
|
|
|
break;
|
2003-02-18 02:24:51 +00:00
|
|
|
}
|
2003-03-05 15:33:12 +00:00
|
|
|
/* Set the offset to the end of the context_data sequence */
|
2007-03-24 13:46:41 +00:00
|
|
|
*offset = temp_offset1 + sizeof(context_data_len) + context_data_len;
|
2003-02-14 07:14:18 +00:00
|
|
|
|
2003-02-13 23:18:59 +00:00
|
|
|
} /* for seqlen */
|
|
|
|
|
2005-04-17 18:28:50 +00:00
|
|
|
if (tf) {
|
|
|
|
if (*offset - start_offset <= 0)
|
|
|
|
THROW(ReportedBoundsError);
|
2003-02-13 23:18:59 +00:00
|
|
|
proto_item_set_len(tf, *offset - start_offset);
|
2005-04-17 18:28:50 +00:00
|
|
|
}
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Decode SystemExceptionReplyBody as defined in the CORBA spec chapter 15.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void decode_SystemExceptionReplyBody (tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian,
|
|
|
|
guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 length; /* string length */
|
|
|
|
guint32 minor_code_value;
|
|
|
|
guint32 completion_status;
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
gchar *buf; /* pointer to string buffer */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
length = get_CDR_string(tvb, &buf, offset, stream_is_big_endian, boundary);
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_text(tree, tvb, *offset-4, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Exception length: %u", length);
|
2001-06-18 05:27:18 +00:00
|
|
|
if (length > 0) {
|
|
|
|
proto_tree_add_text(tree, tvb, *offset - length, length,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Exception id: %s", buf );
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
g_free(buf);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
minor_code_value = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
|
|
|
|
completion_status = get_CDR_ulong(tvb, offset, stream_is_big_endian, boundary);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_text(tree, tvb, *offset-8, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Minor code value: %u", minor_code_value);
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_text(tree, tvb, *offset-4, 4,
|
2010-01-18 18:00:23 +00:00
|
|
|
"Completion Status: %u", completion_status);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Helper functions for dissecting TypeCodes
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* These functions decode the complex parameter lists
|
|
|
|
* of TypeCodes as defined in the CORBA spec chapter 15.
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_objref_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_struct_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header ) {
|
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 count; /* parameter count (of tuples) */
|
|
|
|
guint32 seqlen; /* sequence length */
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 i; /* loop index */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* get sequence lengt,h new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get count of tuples */
|
|
|
|
count = get_CDR_ulong(tvb,offset,new_stream_is_big_endian,new_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_count,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(count),4,count);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get all tuples */
|
|
|
|
for (i=0; i< count; i++) {
|
|
|
|
/* get member name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_member_name);
|
|
|
|
|
|
|
|
/* get member type */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_union_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 TCKind; /* TypeCode */
|
|
|
|
gint32 s_octet4; /* signed int32 */
|
|
|
|
|
|
|
|
guint32 count; /* parameter count (of tuples) */
|
|
|
|
guint32 seqlen; /* sequence length */
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 i; /* loop index */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* get sequence legnth, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get discriminant type */
|
|
|
|
TCKind = get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
|
|
|
|
/* get default used */
|
|
|
|
s_octet4 = get_CDR_long(tvb,offset,new_stream_is_big_endian,new_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_int(tree,hf_giop_typecode_default_used,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(s_octet4),4,s_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
/* get count of tuples */
|
|
|
|
count = get_CDR_ulong(tvb,offset,new_stream_is_big_endian,new_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_count,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(count),4,count);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get all tuples */
|
|
|
|
for (i=0; i< count; i++) {
|
|
|
|
/* get label value, based on TCKind above */
|
|
|
|
dissect_data_for_typecode(tvb, tree, offset, new_stream_is_big_endian, new_boundary, header, TCKind );
|
|
|
|
|
|
|
|
/* get member name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_member_name);
|
|
|
|
|
|
|
|
/* get member type */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_enum_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 count; /* parameter count (of tuples) */
|
|
|
|
guint32 seqlen; /* sequence length */
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 i; /* loop index */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get count of tuples */
|
|
|
|
count = get_CDR_ulong(tvb,offset,new_stream_is_big_endian,new_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_count,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(count),4,count);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get all tuples */
|
|
|
|
for (i=0; i< count; i++) {
|
|
|
|
/* get member name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_member_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_sequence_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 u_octet4; /* unsigned int32 */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get element type */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
|
|
|
|
/* get max length */
|
|
|
|
u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_max_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_array_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 u_octet4; /* unsigned int32 */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get element type */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
|
|
|
|
/* get length */
|
|
|
|
u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_alias_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence legnth, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get ??? (noname) TypeCode */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_except_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 count; /* parameter count (of tuples) */
|
|
|
|
guint32 seqlen; /* sequence length */
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 i; /* loop index */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get count of tuples */
|
|
|
|
count = get_CDR_ulong(tvb,offset,new_stream_is_big_endian,new_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_count,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(count),4,count);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get all tuples */
|
|
|
|
for (i=0; i< count; i++) {
|
|
|
|
/* get member name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_member_name);
|
|
|
|
|
|
|
|
/* get member type */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_value_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
gint16 s_octet2; /* signed int16 */
|
|
|
|
|
|
|
|
guint32 count; /* parameter count (of tuples) */
|
|
|
|
guint32 seqlen; /* sequence length */
|
2010-01-18 18:00:23 +00:00
|
|
|
guint32 i; /* loop index */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get ValueModifier */
|
|
|
|
s_octet2 = get_CDR_short(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_int(tree,hf_giop_typecode_ValueModifier,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(s_octet2),2,s_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get conrete base */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
|
|
|
|
/* get count of tuples */
|
|
|
|
count = get_CDR_ulong(tvb,offset,new_stream_is_big_endian,new_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_typecode_count,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(count),4,count);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get all tuples */
|
|
|
|
for (i=0; i< count; i++) {
|
|
|
|
/* get member name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_member_name);
|
|
|
|
|
|
|
|
/* get member type */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
|
|
|
|
/* get Visibility */
|
|
|
|
s_octet2 = get_CDR_short(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_int(tree,hf_giop_typecode_Visibility,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(s_octet2),2,s_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_value_box_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
/* get ??? (noname) TypeCode */
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,new_stream_is_big_endian,new_boundary,header);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_native_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_tk_abstract_interface_params(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 new_boundary; /* new boundary for encapsulation */
|
|
|
|
gboolean new_stream_is_big_endian; /* new endianness for encapsulation */
|
|
|
|
|
|
|
|
guint32 seqlen; /* sequence length */
|
|
|
|
|
|
|
|
/* get sequence length, new endianness and boundary for encapsulation */
|
2002-08-28 21:04:11 +00:00
|
|
|
seqlen = get_CDR_encap_info(tvb, tree, offset,
|
2001-06-18 05:27:18 +00:00
|
|
|
stream_is_big_endian, boundary,
|
|
|
|
&new_stream_is_big_endian, &new_boundary);
|
|
|
|
|
|
|
|
/* get repository ID */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_repoid);
|
|
|
|
|
|
|
|
/* get name */
|
|
|
|
dissect_typecode_string_param(tvb, tree, offset, new_stream_is_big_endian, new_boundary,
|
|
|
|
hf_giop_typecode_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Typecode parameter lists are encoded as encapsulations and
|
|
|
|
* this function gets the encapsulation information; see
|
2002-08-28 21:04:11 +00:00
|
|
|
* CORBA spec chapter 15
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
* Renamed to get_CDR_encap_info() for any encapsulation
|
|
|
|
* we come across, useful helper function
|
2001-06-18 05:27:18 +00:00
|
|
|
*
|
|
|
|
* Also, should return immediately if seqlen == 0.
|
2008-12-17 17:23:37 +00:00
|
|
|
* ie: Forget about trying to grab endianness for
|
2001-06-18 05:27:18 +00:00
|
|
|
* zero length sequence.
|
|
|
|
*
|
|
|
|
* Caller must always check seqlen == 0, and not assume its value
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Note: there seemed to be considerable confusion in corba
|
|
|
|
* circles as to the correct interpretation of encapsulations,
|
2002-08-28 21:04:11 +00:00
|
|
|
* and zero length sequences etc, but this is our best bet at the
|
2001-06-18 05:27:18 +00:00
|
|
|
* moment.
|
|
|
|
*
|
|
|
|
* -- FS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
guint32 get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean old_stream_is_big_endian, guint32 old_boundary,
|
|
|
|
gboolean *new_stream_is_big_endian_ptr, guint32 *new_boundary_ptr ) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
guint32 seqlen; /* sequence length */
|
2008-12-17 17:23:37 +00:00
|
|
|
guint8 giop_endianness;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* Get sequence length of parameter list */
|
|
|
|
seqlen = get_CDR_ulong(tvb,offset,old_stream_is_big_endian,old_boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_sequence_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(seqlen),4,seqlen);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
2008-12-17 17:23:37 +00:00
|
|
|
* seqlen == 0, implies no endianness and no data
|
2001-06-18 05:27:18 +00:00
|
|
|
* so just return. Populate new_boundary_ptr and
|
|
|
|
* new_stream_is_big_endian_ptr with current (old)
|
|
|
|
* values, just to keep everyone happy. -- FS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (seqlen == 0) {
|
|
|
|
|
|
|
|
*new_boundary_ptr = old_boundary;
|
|
|
|
*new_stream_is_big_endian_ptr = old_stream_is_big_endian;
|
|
|
|
|
|
|
|
return seqlen;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start of encapsulation of parameter list */
|
2010-01-18 18:00:23 +00:00
|
|
|
*new_boundary_ptr = *offset; /* remember */
|
2008-12-17 17:23:37 +00:00
|
|
|
giop_endianness = get_CDR_octet(tvb,offset);
|
2001-06-18 05:27:18 +00:00
|
|
|
|
2008-12-17 17:23:37 +00:00
|
|
|
*new_stream_is_big_endian_ptr = ! giop_endianness;
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Glib: typedef gint gboolean;
|
|
|
|
* ie: It is not a guint8, so cannot use sizeof to correctly
|
|
|
|
* highlight octet.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if (tree) {
|
2008-12-17 17:23:37 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_endianness,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-1,1,giop_endianness);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return seqlen;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2001-06-18 05:27:18 +00:00
|
|
|
* gets a TypeCode complex string parameter and
|
|
|
|
* displays it in the relevant tree.
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_typecode_string_param(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean new_stream_is_big_endian, guint32 new_boundary, int hf_id ) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
guint32 u_octet4; /* unsigned int32 */
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
gchar *buf; /* ptr to string buffer */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
/* get string */
|
|
|
|
u_octet4 = get_CDR_string(tvb,&buf,offset,new_stream_is_big_endian,new_boundary);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_string_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
if (u_octet4 > 0) {
|
|
|
|
proto_tree_add_string(tree,hf_id,tvb,*offset-u_octet4,u_octet4,buf);
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_free(buf); /* dont forget */
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For a given data type, given by a TypeCode gets the associated data
|
|
|
|
* and displays it in the relevant tree.
|
|
|
|
*/
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void dissect_data_for_typecode(tvbuff_t *tvb, proto_tree *tree, gint *offset,
|
2010-01-18 18:00:23 +00:00
|
|
|
gboolean stream_is_big_endian, guint32 boundary,
|
|
|
|
MessageHeader * header, guint32 data_type ) {
|
2001-06-18 05:27:18 +00:00
|
|
|
|
|
|
|
gboolean my_boolean; /* boolean */
|
|
|
|
|
|
|
|
gint8 s_octet1; /* signed int8 */
|
|
|
|
guint8 u_octet1; /* unsigned int8 */
|
|
|
|
|
|
|
|
gint16 s_octet2; /* signed int16 */
|
|
|
|
guint16 u_octet2; /* unsigned int16 */
|
|
|
|
|
|
|
|
gint32 s_octet4; /* signed int32 */
|
|
|
|
guint32 u_octet4; /* unsigned int32 */
|
|
|
|
|
|
|
|
gdouble my_double; /* double */
|
|
|
|
gfloat my_float; /* float */
|
|
|
|
|
|
|
|
gchar *buf = NULL; /* ptr to string buffer */
|
|
|
|
|
|
|
|
/* Grab the data according to data type */
|
|
|
|
|
|
|
|
switch (data_type) {
|
|
|
|
case tk_null:
|
|
|
|
/* nothing to decode */
|
|
|
|
break;
|
|
|
|
case tk_void:
|
|
|
|
/* nothing to decode */
|
|
|
|
break;
|
|
|
|
case tk_short:
|
|
|
|
s_octet2 = get_CDR_short(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_int(tree,hf_giop_type_short,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(s_octet2),2,s_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_long:
|
|
|
|
s_octet4 = get_CDR_long(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_int(tree,hf_giop_type_long,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(s_octet4),4,s_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_ushort:
|
|
|
|
u_octet2 = get_CDR_ushort(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_type_ushort,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet2),2,u_octet2);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_ulong:
|
|
|
|
u_octet4 = get_CDR_ulong(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_type_ulong,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_float:
|
|
|
|
my_float = get_CDR_float(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_double(tree,hf_giop_type_float,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(my_float),4,my_float);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_double:
|
|
|
|
my_double = get_CDR_double(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_double(tree,hf_giop_type_double,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(my_double),8,my_double);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_boolean:
|
|
|
|
my_boolean = get_CDR_boolean(tvb,offset);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_boolean(tree,hf_giop_type_boolean,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-1,1,my_boolean);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_char:
|
|
|
|
u_octet1 = get_CDR_char(tvb,offset);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_type_char,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet1),1,u_octet1);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_octet:
|
|
|
|
u_octet1 = get_CDR_octet(tvb,offset);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_type_octet,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet1),1,u_octet1);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_any:
|
|
|
|
get_CDR_any(tvb,tree,offset,stream_is_big_endian,boundary,header);
|
|
|
|
break;
|
|
|
|
case tk_TypeCode:
|
|
|
|
get_CDR_typeCode(tvb,tree,offset,stream_is_big_endian,boundary,header);
|
|
|
|
break;
|
|
|
|
case tk_Principal:
|
|
|
|
break;
|
|
|
|
case tk_objref:
|
|
|
|
break;
|
|
|
|
case tk_struct:
|
|
|
|
break;
|
|
|
|
case tk_union:
|
|
|
|
break;
|
|
|
|
case tk_enum:
|
|
|
|
u_octet4 = get_CDR_enum(tvb,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_type_enum,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case tk_string:
|
|
|
|
u_octet4 = get_CDR_string(tvb,&buf,offset,stream_is_big_endian,boundary);
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_uint(tree,hf_giop_string_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
if (u_octet4 > 0) {
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_string(tree,hf_giop_type_string,tvb,
|
|
|
|
*offset-u_octet4,u_octet4,buf);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2010-01-18 18:00:23 +00:00
|
|
|
g_free(buf); /* dont forget */
|
2001-06-18 05:27:18 +00:00
|
|
|
break;
|
|
|
|
case tk_sequence:
|
|
|
|
break;
|
|
|
|
case tk_array:
|
|
|
|
break;
|
|
|
|
case tk_alias:
|
|
|
|
break;
|
|
|
|
case tk_except:
|
|
|
|
break;
|
|
|
|
case tk_longlong:
|
|
|
|
break;
|
|
|
|
case tk_ulonglong:
|
|
|
|
break;
|
|
|
|
case tk_longdouble:
|
|
|
|
break;
|
|
|
|
case tk_wchar:
|
|
|
|
s_octet1 = get_CDR_wchar(tvb,&buf,offset,header);
|
|
|
|
if (tree) {
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* XXX - can any of these throw an exception?
|
|
|
|
* If so, we need to catch the exception and free "buf".
|
|
|
|
*/
|
2001-06-18 05:27:18 +00:00
|
|
|
if (s_octet1 < 0) { /* no size to add to tree */
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_string(tree,hf_giop_type_string,tvb,
|
|
|
|
*offset+s_octet1,(-s_octet1),buf);
|
2001-06-18 05:27:18 +00:00
|
|
|
} else {
|
2010-01-18 18:00:23 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_string_length,tvb,
|
|
|
|
*offset-s_octet1-sizeof(s_octet1),1,s_octet1);
|
|
|
|
proto_tree_add_string(tree,hf_giop_type_string,tvb,
|
|
|
|
*offset-s_octet1,s_octet1,buf);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(buf); /* dont forget */
|
|
|
|
break;
|
|
|
|
case tk_wstring:
|
|
|
|
u_octet4 = get_CDR_wstring(tvb,&buf,offset,stream_is_big_endian,boundary,header);
|
|
|
|
if (tree) {
|
Free allocated memory as soon as we're done with it. In many cases,
this obviates the need to add cleanup handlers for exceptions, if we
move a free call so that there are no tvbuff references between the
allocation and the free. Checking for that also found some cases where
frees were missing, and one loop where a call was made to allocate stuff
but the free was only done after the exit from the loop.
In cases where we can't move the free up above tvbuff references,
register cleanup handlers, and replace the free with
CLEANUP_CALL_AND_POP.
Eliminate some initializations of pointers to null - the initializations
aren't necessary (or ceased to be necessary after the frees were moved
up).
In the "force an exception" code in "get_CDR_octet_seq()", touch the
first byte after the string, to make it more likely that we'll throw the
correct exception (e.g., throw a "past end of captured data" exception
rather than a "past end of data" exception).
There's no need for "get_CDR_string()" to force an exception, as it just
calls "get_CDR_octet_seq()", which will do it for us.
However, as the result of "get_CDR_string()" is often processed as a
string, if the length is 0 it should just "g_strdup()" a null string,
rather than not doing anything (and relying on the pointer variable
being initialized to null). It's not always safe to treat a null
pointer as if it pointed to a string (in fact, it is often most
definitely unsafe).
svn path=/trunk/; revision=3878
2001-08-28 07:19:47 +00:00
|
|
|
/*
|
|
|
|
* XXX - can any of these throw an exception?
|
|
|
|
* If so, we need to catch the exception and free "buf".
|
|
|
|
*/
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_uint(tree,hf_giop_string_length,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4-sizeof(u_octet4),4,u_octet4);
|
2001-06-18 05:27:18 +00:00
|
|
|
proto_tree_add_string(tree,hf_giop_type_string,tvb,
|
2010-01-18 18:00:23 +00:00
|
|
|
*offset-u_octet4,u_octet4,buf);
|
2001-06-18 05:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free(buf); /* dont forget */
|
|
|
|
break;
|
|
|
|
case tk_fixed:
|
|
|
|
break;
|
|
|
|
case tk_value:
|
|
|
|
break;
|
|
|
|
case tk_value_box:
|
|
|
|
break;
|
|
|
|
case tk_native:
|
|
|
|
break;
|
|
|
|
case tk_abstract_interface:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning("giop: Unknown typecode data type %u \n", data_type);
|
|
|
|
break;
|
|
|
|
} /* data_type */
|
|
|
|
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
}
|
2010-01-18 18:00:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=2 tabstop=8 expandtab
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|