2 * Routines for packet disassembly
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
43 #include "timestamp.h"
45 #include "atalk-utils.h"
46 #include "sna-utils.h"
47 #include "osi-utils.h"
50 #include "addr_resolv.h"
53 #include "epan_dissect.h"
57 #include <epan/reassemble.h>
58 #include <epan/stream.h>
59 #include <epan/expert.h>
61 static gint proto_malformed = -1;
62 static dissector_handle_t frame_handle = NULL;
63 static dissector_handle_t data_handle = NULL;
68 frame_handle = find_dissector("frame");
69 data_handle = find_dissector("data");
70 proto_malformed = proto_get_id_by_filter_name("malformed");
80 * Given a tvbuff, and a length from a packet header, adjust the length
81 * of the tvbuff to reflect the specified length.
84 set_actual_length(tvbuff_t *tvb, guint specified_len)
86 if (specified_len < tvb_reported_length(tvb)) {
87 /* Adjust the length of this tvbuff to include only the specified
90 The dissector above the one calling us (the dissector above is
91 probably us) may use that to determine how much of its packet
93 tvb_set_reported_length(tvb, specified_len);
97 /* Allow protocols to register "init" routines, which are called before
98 we make a pass through a capture file and dissect all its packets
99 (e.g., when we read in a new capture file, or run a "filter packets"
100 or "colorize packets" pass over the current capture file). */
101 static GSList *init_routines;
104 register_init_routine(void (*func)(void))
106 init_routines = g_slist_append(init_routines, (gpointer)func);
109 typedef void (*void_func_t)(void);
111 /* Initialize all data structures used for dissection. */
113 call_init_routine(gpointer routine, gpointer dummy _U_)
115 void_func_t func = (void_func_t)routine;
120 * XXX - for now, these are the same; the "init" routines free whatever
121 * stuff is left over from any previous dissection, and then initialize
124 * We should probably split that into "init" and "cleanup" routines, for
128 init_dissection(void)
130 /* Reclaim and reinitialize all memory of seasonal scope */
133 /* Initialize the table of conversations. */
134 epan_conversation_init();
136 /* Initialize the table of circuits. */
139 /* Initialize protocol-specific variables. */
140 g_slist_foreach(init_routines, &call_init_routine, NULL);
142 /* Initialize the common data structures for fragment reassembly.
143 Must be done *after* calling init routines, as those routines
144 may free up space for fragments, which they find by using the
145 data structures that "reassemble_init()" frees. */
148 /* Initialize the stream-handling tables */
151 /* Initialize the expert infos */
156 cleanup_dissection(void)
161 /* Allow protocols to register a "cleanup" routine to be
162 * run after the initial sequential run through the packets.
163 * Note that the file can still be open after this; this is not
164 * the final cleanup. */
165 static GSList *postseq_cleanup_routines;
168 register_postseq_cleanup_routine(void_func_t func)
170 postseq_cleanup_routines = g_slist_append(postseq_cleanup_routines,
174 /* Call all the registered "postseq_cleanup" routines. */
176 call_postseq_cleanup_routine(gpointer routine, gpointer dummy _U_)
178 void_func_t func = (void_func_t)routine;
183 postseq_cleanup_all_protocols(void)
185 g_slist_foreach(postseq_cleanup_routines,
186 &call_postseq_cleanup_routine, NULL);
190 * Add a new data source to the list of data sources for a frame, given
191 * the tvbuff for the data source and its name.
194 add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
198 src = ep_alloc(sizeof (data_source));
201 * XXX - if we require this argument to be a string constant,
202 * we don't need to allocate a buffer for a copy and make a
203 * copy, and wouldn't need to free the buffer, either.
205 src->name = ep_strdup_printf("%s (%u bytes)", name, tvb_length(tvb));
206 pinfo->data_src = g_slist_append(pinfo->data_src, src);
210 * Free up a frame's list of data sources.
213 free_data_sources(packet_info *pinfo)
215 g_slist_free(pinfo->data_src);
216 pinfo->data_src = NULL;
219 /* Allow dissectors to register a "final_registration" routine
220 * that is run like the proto_register_XXX() routine, but at the
221 * end of the epan_init() function; that is, *after* all other
222 * subsystems, like dfilters, have finished initializing. This is
223 * useful for dissector registration routines which need to compile
224 * display filters. dfilters can't initialize itself until all protocols
225 * have registered themselves. */
226 static GSList *final_registration_routines;
229 register_final_registration_routine(void (*func)(void))
231 final_registration_routines = g_slist_append(final_registration_routines,
235 /* Call all the registered "final_registration" routines. */
237 call_final_registration_routine(gpointer routine, gpointer dummy _U_)
239 void_func_t func = (void_func_t)routine;
245 final_registration_all_protocols(void)
247 g_slist_foreach(final_registration_routines,
248 &call_final_registration_routine, NULL);
252 /* Creates the top-most tvbuff and calls dissect_frame() */
254 dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header,
255 const guchar *pd, frame_data *fd, column_info *cinfo)
259 edt->pi.current_proto = "<Missing Protocol Name>";
260 edt->pi.cinfo = cinfo;
262 edt->pi.pseudo_header = pseudo_header;
263 edt->pi.data_src = NULL;
264 edt->pi.dl_src.type = AT_NONE;
265 edt->pi.dl_src.len = 0;
266 edt->pi.dl_src.data = NULL;
267 edt->pi.dl_dst.type = AT_NONE;
268 edt->pi.dl_dst.len = 0;
269 edt->pi.dl_dst.data = NULL;
270 edt->pi.net_src.type = AT_NONE;
271 edt->pi.net_src.len = 0;
272 edt->pi.net_src.data = NULL;
273 edt->pi.net_dst.type = AT_NONE;
274 edt->pi.net_dst.len = 0;
275 edt->pi.net_dst.data = NULL;
276 edt->pi.src.type = AT_NONE;
278 edt->pi.src.data = NULL;
279 edt->pi.dst.type = AT_NONE;
281 edt->pi.dst.data = NULL;
282 edt->pi.ethertype = 0;
283 edt->pi.mpls_label = 0;
285 edt->pi.ipxptype = 0;
286 edt->pi.ctype = CT_NONE;
287 edt->pi.circuit_id = 0;
288 edt->pi.noreassembly_reason = "";
289 edt->pi.fragmented = FALSE;
290 edt->pi.in_error_pkt = FALSE;
291 edt->pi.ptype = PT_NONE;
293 edt->pi.destport = 0;
294 edt->pi.match_port = 0;
295 edt->pi.match_string = NULL;
296 edt->pi.can_desegment = 0;
297 edt->pi.want_pdu_tracking = 0;
298 edt->pi.p2p_dir = P2P_DIR_UNKNOWN;
299 edt->pi.private_data = NULL;
306 edt->pi.dcectxid = 0;
307 edt->pi.dcetransporttype = -1;
308 edt->pi.decrypt_gssapi_tvb = 0;
309 edt->pi.gssapi_wrap_tvb = NULL;
310 edt->pi.gssapi_encrypted_tvb = NULL;
311 edt->pi.gssapi_decrypted_tvb = NULL;
312 edt->pi.layer_names = NULL;
313 edt->pi.link_number = 0;
314 edt->pi.annex_a_used = MTP2_ANNEX_A_USED_UNKNOWN;
315 edt->pi.profinet_conv = NULL;
316 edt->pi.profinet_type = 0;
317 edt->pi.usb_conv_info = NULL;
318 edt->pi.tcp_tree = NULL;
319 edt->pi.dcerpc_procedure_name="";
320 edt->pi.sccp_info = NULL;
321 edt->pi.clnp_srcref = 0;
322 edt->pi.clnp_dstref = 0;
324 EP_CHECK_CANARY(("before dissecting frame %d",fd->num));
327 edt->tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
328 /* Add this tvbuffer into the data_src list */
329 add_new_data_source(&edt->pi, edt->tvb, "Frame");
331 /* Even though dissect_frame() catches all the exceptions a
332 * sub-dissector can throw, dissect_frame() itself may throw
333 * a ReportedBoundsError in bizarre cases. Thus, we catch the exception
334 * in this function. */
335 if(frame_handle != NULL)
336 call_dissector(frame_handle, edt->tvb, &edt->pi, edt->tree);
340 g_assert_not_reached();
342 CATCH(ReportedBoundsError) {
343 if(proto_malformed != -1){
344 proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0,
345 "[Malformed Frame: Packet Length]" );
347 g_assert_not_reached();
350 CATCH(OutOfMemoryError) {
355 EP_CHECK_CANARY(("after dissecting frame %d",fd->num));
357 fd->flags.visited = 1;
360 /*********************** code added for sub-dissector lookup *********************/
363 * An dissector handle.
365 struct dissector_handle {
366 const char *name; /* dissector name */
367 gboolean is_new; /* TRUE if new-style dissector */
372 protocol_t *protocol;
375 /* This function will return
376 * old style dissector :
377 * length of the payload or 1 of the payload is empty
379 * >0 this protocol was successfully dissected and this was this protocol.
380 * 0 this packet did not match this protocol.
382 * The only time this function will return 0 is if it is a new style dissector
383 * and if the dissector rejected the packet.
386 call_dissector_through_handle(dissector_handle_t handle, tvbuff_t *tvb,
387 packet_info *pinfo, proto_tree *tree)
389 const char *saved_proto;
392 saved_proto = pinfo->current_proto;
394 if (handle->protocol != NULL) {
395 pinfo->current_proto =
396 proto_get_protocol_short_name(handle->protocol);
399 if (handle->is_new) {
400 EP_CHECK_CANARY(("before calling handle->dissector.new for %s",handle->name));
401 ret = (*handle->dissector.new)(tvb, pinfo, tree);
402 EP_CHECK_CANARY(("after calling handle->dissector.new for %s",handle->name));
404 EP_CHECK_CANARY(("before calling handle->dissector.old for %s",handle->name));
405 (*handle->dissector.old)(tvb, pinfo, tree);
406 EP_CHECK_CANARY(("after calling handle->dissector.old for %s",handle->name));
407 ret = tvb_length(tvb);
410 * XXX - a tvbuff can have 0 bytes of data in
411 * it, so we have to make sure we don't return
418 pinfo->current_proto = saved_proto;
424 * Call a dissector through a handle.
425 * If the protocol for that handle isn't enabled, return 0 without
426 * calling the dissector.
427 * Otherwise, if the handle refers to a new-style dissector, call the
428 * dissector and return its return value, otherwise call it and return
429 * the length of the tvbuff pointed to by the argument.
433 call_dissector_work_error(dissector_handle_t handle, tvbuff_t *tvb,
434 packet_info *pinfo_arg, proto_tree *tree);
437 call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb,
438 packet_info *pinfo_arg, proto_tree *tree)
440 packet_info *pinfo = pinfo_arg;
441 const char *saved_proto;
442 guint16 saved_can_desegment;
444 gint saved_layer_names_len = 0;
446 if (handle->protocol != NULL &&
447 !proto_is_protocol_enabled(handle->protocol)) {
449 * The protocol isn't enabled.
454 saved_proto = pinfo->current_proto;
455 saved_can_desegment = pinfo->can_desegment;
457 if (pinfo->layer_names != NULL)
458 saved_layer_names_len = pinfo->layer_names->len;
461 * can_desegment is set to 2 by anyone which offers the
462 * desegmentation api/service.
463 * Then everytime a subdissector is called it is decremented
465 * Thus only the subdissector immediately on top of whoever
466 * offers this service can use it.
467 * We save the current value of "can_desegment" for the
468 * benefit of TCP proxying dissectors such as SOCKS, so they
469 * can restore it and allow the dissectors they call to use
470 * the desegmentation service.
472 pinfo->saved_can_desegment = saved_can_desegment;
473 pinfo->can_desegment = saved_can_desegment-(saved_can_desegment>0);
474 if (handle->protocol != NULL) {
475 pinfo->current_proto =
476 proto_get_protocol_short_name(handle->protocol);
479 * Add the protocol name to the layers
481 if (pinfo->layer_names) {
482 if (pinfo->layer_names->len > 0)
483 g_string_append(pinfo->layer_names, ":");
484 g_string_append(pinfo->layer_names,
485 proto_get_protocol_filter_name(proto_get_id(handle->protocol)));
489 if (pinfo->in_error_pkt) {
490 ret = call_dissector_work_error(handle, tvb, pinfo, tree);
493 * Just call the subdissector.
495 ret = call_dissector_through_handle(handle, tvb, pinfo, tree);
499 * That dissector didn't accept the packet, so
500 * remove its protocol's name from the list
503 if (pinfo->layer_names != NULL) {
504 g_string_truncate(pinfo->layer_names,
505 saved_layer_names_len);
508 pinfo->current_proto = saved_proto;
509 pinfo->can_desegment = saved_can_desegment;
515 call_dissector_work_error(dissector_handle_t handle, tvbuff_t *tvb,
516 packet_info *pinfo_arg, proto_tree *tree)
518 packet_info *pinfo = pinfo_arg;
519 const char *saved_proto;
520 guint16 saved_can_desegment;
521 volatile int ret = 0;
522 gboolean save_writable;
525 address save_net_src;
526 address save_net_dst;
531 * This isn't a packet being transported inside
532 * the protocol whose dissector is calling us,
533 * it's a copy of a packet that caused an error
534 * in some protocol included in a packet that
535 * reports the error (e.g., an ICMP Unreachable
540 * Save the current state of the writability of
541 * the columns, and restore them after the
542 * dissector returns, so that the columns
543 * don't reflect the packet that got the error,
544 * they reflect the packet that reported the
547 saved_proto = pinfo->current_proto;
548 saved_can_desegment = pinfo->can_desegment;
550 save_writable = col_get_writable(pinfo->cinfo);
551 col_set_writable(pinfo->cinfo, FALSE);
552 save_dl_src = pinfo->dl_src;
553 save_dl_dst = pinfo->dl_dst;
554 save_net_src = pinfo->net_src;
555 save_net_dst = pinfo->net_dst;
556 save_src = pinfo->src;
557 save_dst = pinfo->dst;
559 /* Dissect the contained packet. */
561 ret = call_dissector_through_handle(handle, tvb,pinfo, tree);
565 * Restore the column writability and addresses.
567 col_set_writable(pinfo->cinfo, save_writable);
568 pinfo->dl_src = save_dl_src;
569 pinfo->dl_dst = save_dl_dst;
570 pinfo->net_src = save_net_src;
571 pinfo->net_dst = save_net_dst;
572 pinfo->src = save_src;
573 pinfo->dst = save_dst;
576 * Restore the current protocol, so any
577 * "Short Frame" indication reflects that
578 * protocol, not the protocol for the
579 * packet that got the error.
581 pinfo->current_proto = saved_proto;
584 * Restore the desegmentability state.
586 pinfo->can_desegment = saved_can_desegment;
589 * Rethrow the exception, so this will be
590 * reported as a short frame.
594 CATCH(ReportedBoundsError) {
596 * "ret" wasn't set because an exception was thrown
597 * before "call_dissector_through_handle()" returned.
598 * As it called something, at least one dissector
599 * accepted the packet, and, as an exception was
600 * thrown, not only was all the tvbuff dissected,
601 * a dissector tried dissecting past the end of
602 * the data in some tvbuff, so we'll assume that
603 * the entire tvbuff was dissected.
605 ret = tvb_length(tvb);
607 CATCH(OutOfMemoryError) {
612 col_set_writable(pinfo->cinfo, save_writable);
613 pinfo->dl_src = save_dl_src;
614 pinfo->dl_dst = save_dl_dst;
615 pinfo->net_src = save_net_src;
616 pinfo->net_dst = save_net_dst;
617 pinfo->src = save_src;
618 pinfo->dst = save_dst;
619 pinfo->want_pdu_tracking = 0;
624 * An entry in the hash table portion of a dissector table.
627 dissector_handle_t initial;
628 dissector_handle_t current;
634 * "hash_table" is a hash table, indexed by port number, supplying
635 * a "struct dtbl_entry"; it records what dissector is assigned to
636 * that port number in that table.
638 * "dissector_handles" is a list of all dissectors that *could* be
639 * used in that table; not all of them are necessarily in the table,
640 * as they may be for protocols that don't have a fixed port number.
642 * "ui_name" is the name the dissector table has in the user interface.
644 * "type" is a field type giving the width of the port number for that
647 * "base" is the base in which to display the port number for that
650 struct dissector_table {
651 GHashTable *hash_table;
652 GSList *dissector_handles;
658 static GHashTable *dissector_tables = NULL;
660 /* Finds a dissector table by table name. */
662 find_dissector_table(const char *name)
664 g_assert(dissector_tables);
665 return g_hash_table_lookup( dissector_tables, name );
668 /* Find an entry in a uint dissector table. */
669 static dtbl_entry_t *
670 find_uint_dtbl_entry(dissector_table_t sub_dissectors, guint32 pattern)
672 switch (sub_dissectors->type) {
679 * You can do a port lookup in these tables.
685 * But you can't do a port lookup in any other types
688 g_assert_not_reached();
694 return g_hash_table_lookup(sub_dissectors->hash_table,
695 GUINT_TO_POINTER(pattern));
698 /* Add an entry to a uint dissector table. */
700 dissector_add(const char *name, guint32 pattern, dissector_handle_t handle)
702 dissector_table_t sub_dissectors;
703 dtbl_entry_t *dtbl_entry;
705 sub_dissectors = find_dissector_table(name);
707 g_assert(sub_dissectors);
708 switch (sub_dissectors->type) {
715 * You can do a port lookup in these tables.
721 * But you can't do a port lookup in any other types
724 g_assert_not_reached();
727 dtbl_entry = g_malloc(sizeof (dtbl_entry_t));
728 dtbl_entry->current = handle;
729 dtbl_entry->initial = dtbl_entry->current;
731 /* do the table insertion */
732 g_hash_table_insert( sub_dissectors->hash_table,
733 GUINT_TO_POINTER( pattern), (gpointer)dtbl_entry);
736 * Now add it to the list of handles that could be used with this
737 * table, because it *is* being used with this table.
739 dissector_add_handle(name, handle);
742 /* Delete the entry for a dissector in a uint dissector table
743 with a particular pattern. */
745 /* NOTE: this doesn't use the dissector call variable. It is included to */
746 /* be consistant with the dissector_add and more importantly to be used */
747 /* if the technique of adding a temporary dissector is implemented. */
748 /* If temporary dissectors are deleted, then the original dissector must */
751 dissector_delete(const char *name, guint32 pattern,
752 dissector_handle_t handle _U_)
754 dissector_table_t sub_dissectors = find_dissector_table( name);
755 dtbl_entry_t *dtbl_entry;
758 g_assert( sub_dissectors);
763 dtbl_entry = find_uint_dtbl_entry(sub_dissectors, pattern);
765 if (dtbl_entry != NULL) {
769 g_hash_table_remove(sub_dissectors->hash_table,
770 GUINT_TO_POINTER(pattern));
773 * Now free up the entry.
779 /* Change the entry for a dissector in a uint dissector table
780 with a particular pattern to use a new dissector handle. */
782 dissector_change(const char *name, guint32 pattern, dissector_handle_t handle)
784 dissector_table_t sub_dissectors = find_dissector_table( name);
785 dtbl_entry_t *dtbl_entry;
788 g_assert( sub_dissectors);
791 * See if the entry already exists. If so, reuse it.
793 dtbl_entry = find_uint_dtbl_entry(sub_dissectors, pattern);
794 if (dtbl_entry != NULL) {
795 dtbl_entry->current = handle;
800 * Don't create an entry if there is no dissector handle - I.E. the
801 * user said not to decode something that wasn't being decoded
802 * in the first place.
807 dtbl_entry = g_malloc(sizeof (dtbl_entry_t));
808 dtbl_entry->initial = NULL;
809 dtbl_entry->current = handle;
811 /* do the table insertion */
812 g_hash_table_insert( sub_dissectors->hash_table,
813 GUINT_TO_POINTER( pattern), (gpointer)dtbl_entry);
816 /* Reset an entry in a uint dissector table to its initial value. */
818 dissector_reset(const char *name, guint32 pattern)
820 dissector_table_t sub_dissectors = find_dissector_table( name);
821 dtbl_entry_t *dtbl_entry;
824 g_assert( sub_dissectors);
829 dtbl_entry = find_uint_dtbl_entry(sub_dissectors, pattern);
831 if (dtbl_entry == NULL)
835 * Found - is there an initial value?
837 if (dtbl_entry->initial != NULL) {
838 dtbl_entry->current = dtbl_entry->initial;
840 g_hash_table_remove(sub_dissectors->hash_table,
841 GUINT_TO_POINTER(pattern));
846 /* Look for a given value in a given uint dissector table and, if found,
847 call the dissector with the arguments supplied, and return TRUE,
848 otherwise return FALSE. */
850 dissector_try_port(dissector_table_t sub_dissectors, guint32 port,
851 tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
853 dtbl_entry_t *dtbl_entry;
854 struct dissector_handle *handle;
855 guint32 saved_match_port;
858 dtbl_entry = find_uint_dtbl_entry(sub_dissectors, port);
859 if (dtbl_entry != NULL) {
861 * Is there currently a dissector handle for this entry?
863 handle = dtbl_entry->current;
864 if (handle == NULL) {
866 * No - pretend this dissector didn't exist,
867 * so that other dissectors might have a chance
868 * to dissect this packet.
874 * Save the current value of "pinfo->match_port",
875 * set it to the port that matched, call the
876 * dissector, and restore "pinfo->match_port".
878 saved_match_port = pinfo->match_port;
879 pinfo->match_port = port;
880 ret = call_dissector_work(handle, tvb, pinfo, tree);
881 pinfo->match_port = saved_match_port;
884 * If a new-style dissector returned 0, it means that
885 * it didn't think this tvbuff represented a packet for
886 * its protocol, and didn't dissect anything.
888 * Old-style dissectors can't reject the packet.
890 * 0 is also returned if the protocol wasn't enabled.
892 * If the packet was rejected, we return FALSE, so that
893 * other dissectors might have a chance to dissect this
894 * packet, otherwise we return TRUE.
901 /* Look for a given value in a given uint dissector table and, if found,
902 return the dissector handle for that value. */
904 dissector_get_port_handle(dissector_table_t sub_dissectors, guint32 port)
906 dtbl_entry_t *dtbl_entry;
908 dtbl_entry = find_uint_dtbl_entry(sub_dissectors, port);
909 if (dtbl_entry != NULL)
910 return dtbl_entry->current;
915 /* Find an entry in a string dissector table. */
916 static dtbl_entry_t *
917 find_string_dtbl_entry(dissector_table_t sub_dissectors, const gchar *pattern)
919 switch (sub_dissectors->type) {
924 * You can do a string lookup in these tables.
930 * But you can't do a string lookup in any other types
933 g_assert_not_reached();
939 return g_hash_table_lookup(sub_dissectors->hash_table, pattern);
942 /* Add an entry to a string dissector table. */
944 dissector_add_string(const char *name, const gchar *pattern,
945 dissector_handle_t handle)
947 dissector_table_t sub_dissectors = find_dissector_table( name);
948 dtbl_entry_t *dtbl_entry;
951 g_assert( sub_dissectors);
953 switch (sub_dissectors->type) {
958 * You can do a string lookup in these tables.
964 * But you can't do a string lookup in any other types
967 g_assert_not_reached();
970 dtbl_entry = g_malloc(sizeof (dtbl_entry_t));
971 dtbl_entry->current = handle;
972 dtbl_entry->initial = dtbl_entry->current;
974 /* do the table insertion */
975 g_hash_table_insert( sub_dissectors->hash_table, (gpointer)pattern,
976 (gpointer)dtbl_entry);
979 * Now add it to the list of handles that could be used with this
980 * table, because it *is* being used with this table.
982 dissector_add_handle(name, handle);
985 /* Delete the entry for a dissector in a string dissector table
986 with a particular pattern. */
988 /* NOTE: this doesn't use the dissector call variable. It is included to */
989 /* be consistant with the dissector_add_string and more importantly to */
990 /* be used if the technique of adding a temporary dissector is */
992 /* If temporary dissectors are deleted, then the original dissector must */
995 dissector_delete_string(const char *name, const gchar *pattern,
996 dissector_handle_t handle _U_)
998 dissector_table_t sub_dissectors = find_dissector_table( name);
999 dtbl_entry_t *dtbl_entry;
1002 g_assert( sub_dissectors);
1007 dtbl_entry = find_string_dtbl_entry(sub_dissectors, pattern);
1009 if (dtbl_entry != NULL) {
1011 * Found - remove it.
1013 g_hash_table_remove(sub_dissectors->hash_table, pattern);
1016 * Now free up the entry.
1022 /* Change the entry for a dissector in a string dissector table
1023 with a particular pattern to use a new dissector handle. */
1025 dissector_change_string(const char *name, gchar *pattern,
1026 dissector_handle_t handle)
1028 dissector_table_t sub_dissectors = find_dissector_table( name);
1029 dtbl_entry_t *dtbl_entry;
1032 g_assert( sub_dissectors);
1035 * See if the entry already exists. If so, reuse it.
1037 dtbl_entry = find_string_dtbl_entry(sub_dissectors, pattern);
1038 if (dtbl_entry != NULL) {
1039 dtbl_entry->current = handle;
1044 * Don't create an entry if there is no dissector handle - I.E. the
1045 * user said not to decode something that wasn't being decoded
1046 * in the first place.
1051 dtbl_entry = g_malloc(sizeof (dtbl_entry_t));
1052 dtbl_entry->initial = NULL;
1053 dtbl_entry->current = handle;
1055 /* do the table insertion */
1056 g_hash_table_insert( sub_dissectors->hash_table, pattern,
1057 (gpointer)dtbl_entry);
1060 /* Reset an entry in a string sub-dissector table to its initial value. */
1062 dissector_reset_string(const char *name, const gchar *pattern)
1064 dissector_table_t sub_dissectors = find_dissector_table( name);
1065 dtbl_entry_t *dtbl_entry;
1068 g_assert( sub_dissectors);
1073 dtbl_entry = find_string_dtbl_entry(sub_dissectors, pattern);
1075 if (dtbl_entry == NULL)
1079 * Found - is there an initial value?
1081 if (dtbl_entry->initial != NULL) {
1082 dtbl_entry->current = dtbl_entry->initial;
1084 g_hash_table_remove(sub_dissectors->hash_table, pattern);
1089 /* Look for a given string in a given dissector table and, if found, call
1090 the dissector with the arguments supplied, and return TRUE, otherwise
1093 dissector_try_string(dissector_table_t sub_dissectors, const gchar *string,
1094 tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1096 dtbl_entry_t *dtbl_entry;
1097 struct dissector_handle *handle;
1099 const gchar *saved_match_string;
1101 /* XXX ASSERT instead ? */
1102 if (!string) return FALSE;
1103 dtbl_entry = find_string_dtbl_entry(sub_dissectors, string);
1104 if (dtbl_entry != NULL) {
1106 * Is there currently a dissector handle for this entry?
1108 handle = dtbl_entry->current;
1109 if (handle == NULL) {
1111 * No - pretend this dissector didn't exist,
1112 * so that other dissectors might have a chance
1113 * to dissect this packet.
1119 * Save the current value of "pinfo->match_string",
1120 * set it to the string that matched, call the
1121 * dissector, and restore "pinfo->match_string".
1123 saved_match_string = pinfo->match_string;
1124 pinfo->match_string = string;
1125 ret = call_dissector_work(handle, tvb, pinfo, tree);
1126 pinfo->match_string = saved_match_string;
1129 * If a new-style dissector returned 0, it means that
1130 * it didn't think this tvbuff represented a packet for
1131 * its protocol, and didn't dissect anything.
1133 * Old-style dissectors can't reject the packet.
1135 * 0 is also returned if the protocol wasn't enabled.
1137 * If the packet was rejected, we return FALSE, so that
1138 * other dissectors might have a chance to dissect this
1139 * packet, otherwise we return TRUE.
1146 /* Look for a given value in a given string dissector table and, if found,
1147 return the dissector handle for that value. */
1149 dissector_get_string_handle(dissector_table_t sub_dissectors,
1150 const gchar *string)
1152 dtbl_entry_t *dtbl_entry;
1154 dtbl_entry = find_string_dtbl_entry(sub_dissectors, string);
1155 if (dtbl_entry != NULL)
1156 return dtbl_entry->current;
1162 dtbl_entry_get_handle (dtbl_entry_t *dtbl_entry)
1164 return dtbl_entry->current;
1167 /* Add a handle to the list of handles that *could* be used with this
1168 table. That list is used by code in the UI. */
1170 dissector_add_handle(const char *name, dissector_handle_t handle)
1172 dissector_table_t sub_dissectors = find_dissector_table( name);
1176 g_assert(sub_dissectors != NULL);
1178 /* Is it already in this list? */
1179 entry = g_slist_find(sub_dissectors->dissector_handles, (gpointer)handle);
1180 if (entry != NULL) {
1182 * Yes - don't insert it again.
1187 /* Add it to the list. */
1188 sub_dissectors->dissector_handles =
1189 g_slist_append(sub_dissectors->dissector_handles, (gpointer)handle);
1193 dtbl_entry_get_initial_handle (dtbl_entry_t *dtbl_entry)
1195 return dtbl_entry->initial;
1198 /**************************************************/
1200 /* Routines to walk dissector tables */
1202 /**************************************************/
1204 typedef struct dissector_foreach_info {
1205 gpointer caller_data;
1206 DATFunc caller_func;
1208 const gchar *table_name;
1209 ftenum_t selector_type;
1210 } dissector_foreach_info_t;
1213 * Called for each entry in a dissector table.
1216 dissector_table_foreach_func (gpointer key, gpointer value, gpointer user_data)
1218 dissector_foreach_info_t *info;
1219 dtbl_entry_t *dtbl_entry;
1222 g_assert(user_data);
1225 if (dtbl_entry->current == NULL ||
1226 dtbl_entry->current->protocol == NULL) {
1228 * Either there is no dissector for this entry, or
1229 * the dissector doesn't have a protocol associated
1232 * XXX - should the latter check be done?
1238 info->caller_func(info->table_name, info->selector_type, key, value,
1243 * Called for each entry in the table of all dissector tables.
1246 dissector_all_tables_foreach_func (gpointer key, gpointer value, gpointer user_data)
1248 dissector_table_t sub_dissectors;
1249 dissector_foreach_info_t *info;
1252 g_assert(user_data);
1254 sub_dissectors = value;
1256 info->table_name = (gchar*) key;
1257 info->selector_type = get_dissector_table_selector_type(info->table_name);
1258 g_hash_table_foreach(sub_dissectors->hash_table, info->next_func, info);
1262 * Walk all dissector tables calling a user supplied function on each
1266 dissector_all_tables_foreach (DATFunc func,
1269 dissector_foreach_info_t info;
1271 info.caller_data = user_data;
1272 info.caller_func = func;
1273 info.next_func = dissector_table_foreach_func;
1274 g_hash_table_foreach(dissector_tables, dissector_all_tables_foreach_func, &info);
1278 * Walk one dissector table's hash table calling a user supplied function
1282 dissector_table_foreach (const char *name,
1286 dissector_foreach_info_t info;
1287 dissector_table_t sub_dissectors = find_dissector_table( name);
1289 info.table_name = name;
1290 info.selector_type = sub_dissectors->type;
1291 info.caller_func = func;
1292 info.caller_data = user_data;
1293 g_hash_table_foreach(sub_dissectors->hash_table, dissector_table_foreach_func, &info);
1297 * Walk one dissector table's list of handles calling a user supplied
1298 * function on each entry.
1301 dissector_table_foreach_handle(const char *name,
1302 DATFunc_handle func,
1305 dissector_table_t sub_dissectors = find_dissector_table( name);
1308 for (tmp = sub_dissectors->dissector_handles; tmp != NULL;
1309 tmp = g_slist_next(tmp))
1310 func(name, tmp->data, user_data);
1314 * Called for each entry in a dissector table.
1317 dissector_table_foreach_changed_func (gpointer key, gpointer value, gpointer user_data)
1319 dtbl_entry_t *dtbl_entry;
1320 dissector_foreach_info_t *info;
1323 g_assert(user_data);
1326 if (dtbl_entry->initial == dtbl_entry->current) {
1328 * Entry hasn't changed - don't call the function.
1334 info->caller_func(info->table_name, info->selector_type, key, value,
1339 * Walk all dissector tables calling a user supplied function only on
1340 * any entry that has been changed from its original state.
1343 dissector_all_tables_foreach_changed (DATFunc func,
1346 dissector_foreach_info_t info;
1348 info.caller_data = user_data;
1349 info.caller_func = func;
1350 info.next_func = dissector_table_foreach_changed_func;
1351 g_hash_table_foreach(dissector_tables, dissector_all_tables_foreach_func, &info);
1355 * Walk one dissector table calling a user supplied function only on
1356 * any entry that has been changed from its original state.
1359 dissector_table_foreach_changed (const char *name,
1363 dissector_foreach_info_t info;
1364 dissector_table_t sub_dissectors = find_dissector_table( name);
1366 info.table_name = name;
1367 info.selector_type = sub_dissectors->type;
1368 info.caller_func = func;
1369 info.caller_data = user_data;
1370 g_hash_table_foreach(sub_dissectors->hash_table,
1371 dissector_table_foreach_changed_func, &info);
1374 typedef struct dissector_foreach_table_info {
1375 gpointer caller_data;
1376 DATFunc_table caller_func;
1377 } dissector_foreach_table_info_t;
1380 * Called for each entry in the table of all dissector tables.
1383 dissector_all_tables_foreach_table_func (gpointer key, gpointer value, gpointer user_data)
1385 dissector_table_t table;
1386 dissector_foreach_table_info_t *info;
1390 (*info->caller_func)((gchar*)key, table->ui_name, info->caller_data);
1394 * Walk all dissector tables calling a user supplied function on each
1398 dissector_all_tables_foreach_table (DATFunc_table func,
1401 dissector_foreach_table_info_t info;
1403 info.caller_data = user_data;
1404 info.caller_func = func;
1405 g_hash_table_foreach(dissector_tables, dissector_all_tables_foreach_table_func, &info);
1409 register_dissector_table(const char *name, const char *ui_name, ftenum_t type,
1412 dissector_table_t sub_dissectors;
1414 /* Create our hash-of-hashes if it doesn't already exist */
1415 if (!dissector_tables) {
1416 dissector_tables = g_hash_table_new( g_str_hash, g_str_equal );
1417 g_assert(dissector_tables);
1420 /* Make sure the registration is unique */
1421 if(g_hash_table_lookup( dissector_tables, name )) {
1422 g_error("The filter name %s (%s) is already registered - do you use a buggy plugin?", name, ui_name);
1425 /* Create and register the dissector table for this name; returns */
1426 /* a pointer to the dissector table. */
1427 sub_dissectors = g_malloc(sizeof (struct dissector_table));
1435 * XXX - there's no "g_uint_hash()" or "g_uint_equal()",
1436 * so we use "g_direct_hash()" and "g_direct_equal()".
1438 sub_dissectors->hash_table = g_hash_table_new( g_direct_hash,
1444 sub_dissectors->hash_table = g_hash_table_new( g_str_hash,
1449 g_assert_not_reached();
1451 sub_dissectors->dissector_handles = NULL;
1452 sub_dissectors->ui_name = ui_name;
1453 sub_dissectors->type = type;
1454 sub_dissectors->base = base;
1455 g_hash_table_insert( dissector_tables, (gpointer)name, (gpointer) sub_dissectors );
1456 return sub_dissectors;
1460 get_dissector_table_ui_name(const char *name)
1462 dissector_table_t sub_dissectors = find_dissector_table( name);
1464 return sub_dissectors->ui_name;
1468 get_dissector_table_selector_type(const char *name)
1470 dissector_table_t sub_dissectors = find_dissector_table( name);
1472 return sub_dissectors->type;
1476 get_dissector_table_base(const char *name)
1478 dissector_table_t sub_dissectors = find_dissector_table( name);
1480 return sub_dissectors->base;
1483 static GHashTable *heur_dissector_lists = NULL;
1486 heur_dissector_t dissector;
1487 protocol_t *protocol;
1488 } heur_dtbl_entry_t;
1490 /* Finds a heuristic dissector table by field name. */
1491 static heur_dissector_list_t *
1492 find_heur_dissector_list(const char *name)
1494 g_assert(heur_dissector_lists != NULL);
1495 return g_hash_table_lookup(heur_dissector_lists, name);
1499 heur_dissector_add(const char *name, heur_dissector_t dissector, int proto)
1501 heur_dissector_list_t *sub_dissectors = find_heur_dissector_list(name);
1502 heur_dtbl_entry_t *dtbl_entry;
1505 g_assert(sub_dissectors != NULL);
1507 dtbl_entry = g_malloc(sizeof (heur_dtbl_entry_t));
1508 dtbl_entry->dissector = dissector;
1509 dtbl_entry->protocol = find_protocol_by_id(proto);
1511 /* do the table insertion */
1512 *sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
1517 static int find_matching_heur_dissector( gconstpointer a, gconstpointer b) {
1518 const heur_dtbl_entry_t *dtbl_entry_a = (const heur_dtbl_entry_t *) a;
1519 const heur_dtbl_entry_t *dtbl_entry_b = (const heur_dtbl_entry_t *) b;
1520 return (dtbl_entry_a->dissector == dtbl_entry_b->dissector) &&
1521 (dtbl_entry_a->protocol == dtbl_entry_b->protocol) ? 0 : 1;
1524 void heur_dissector_delete(const char *name, heur_dissector_t dissector, int proto) {
1525 heur_dissector_list_t *sub_dissectors = find_heur_dissector_list(name);
1526 heur_dtbl_entry_t dtbl_entry;
1527 GSList* found_entry;
1530 g_assert(sub_dissectors != NULL);
1532 dtbl_entry.dissector = dissector;
1534 dtbl_entry.protocol = find_protocol_by_id(proto);
1536 found_entry = g_slist_find_custom(*sub_dissectors, (gpointer) &dtbl_entry, find_matching_heur_dissector);
1539 *sub_dissectors = g_slist_remove_link(*sub_dissectors, found_entry);
1540 g_free(g_slist_nth_data(found_entry, 1));
1541 g_slist_free_1(found_entry);
1547 dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
1548 tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1551 const char *saved_proto;
1553 heur_dtbl_entry_t *dtbl_entry;
1554 guint16 saved_can_desegment;
1555 gint saved_layer_names_len = 0;
1557 /* can_desegment is set to 2 by anyone which offers this api/service.
1558 then everytime a subdissector is called it is decremented by one.
1559 thus only the subdissector immediately ontop of whoever offers this
1561 We save the current value of "can_desegment" for the
1562 benefit of TCP proxying dissectors such as SOCKS, so they
1563 can restore it and allow the dissectors they call to use
1564 the desegmentation service.
1566 saved_can_desegment=pinfo->can_desegment;
1567 pinfo->saved_can_desegment = saved_can_desegment;
1568 pinfo->can_desegment = saved_can_desegment-(saved_can_desegment>0);
1571 saved_proto = pinfo->current_proto;
1573 if (pinfo->layer_names != NULL)
1574 saved_layer_names_len = pinfo->layer_names->len;
1576 for (entry = sub_dissectors; entry != NULL; entry = g_slist_next(entry)) {
1577 /* XXX - why set this now and above? */
1578 pinfo->can_desegment = saved_can_desegment-(saved_can_desegment>0);
1579 dtbl_entry = (heur_dtbl_entry_t *)entry->data;
1581 if (dtbl_entry->protocol != NULL &&
1582 !proto_is_protocol_enabled(dtbl_entry->protocol)) {
1584 * No - don't try this dissector.
1589 if (dtbl_entry->protocol != NULL) {
1590 pinfo->current_proto =
1591 proto_get_protocol_short_name(dtbl_entry->protocol);
1594 * Add the protocol name to the layers; we'll remove it
1595 * if the dissector fails.
1597 if (pinfo->layer_names) {
1598 if (pinfo->layer_names->len > 0)
1599 g_string_append(pinfo->layer_names, ":");
1600 g_string_append(pinfo->layer_names,
1601 proto_get_protocol_filter_name(proto_get_id(dtbl_entry->protocol)));
1604 EP_CHECK_CANARY(("before calling heuristic dissector for protocol: %s",
1605 proto_get_protocol_filter_name(proto_get_id(dtbl_entry->protocol))));
1606 if ((*dtbl_entry->dissector)(tvb, pinfo, tree)) {
1607 EP_CHECK_CANARY(("after heuristic dissector for protocol: %s has accepted and dissected packet",
1608 proto_get_protocol_filter_name(proto_get_id(dtbl_entry->protocol))));
1612 EP_CHECK_CANARY(("after heuristic dissector for protocol: %s has returned true",
1613 proto_get_protocol_filter_name(proto_get_id(dtbl_entry->protocol))));
1616 * That dissector didn't accept the packet, so
1617 * remove its protocol's name from the list
1620 if (pinfo->layer_names != NULL) {
1621 g_string_truncate(pinfo->layer_names,
1622 saved_layer_names_len);
1626 pinfo->current_proto = saved_proto;
1627 pinfo->can_desegment=saved_can_desegment;
1632 register_heur_dissector_list(const char *name, heur_dissector_list_t *sub_dissectors)
1634 /* Create our hash-of-lists if it doesn't already exist */
1635 if (heur_dissector_lists == NULL) {
1636 heur_dissector_lists = g_hash_table_new(g_str_hash, g_str_equal);
1637 g_assert(heur_dissector_lists != NULL);
1640 /* Make sure the registration is unique */
1641 g_assert(g_hash_table_lookup(heur_dissector_lists, name) == NULL);
1643 *sub_dissectors = NULL; /* initially empty */
1644 g_hash_table_insert(heur_dissector_lists, (gpointer)name,
1645 (gpointer) sub_dissectors);
1649 * Register dissectors by name; used if one dissector always calls a
1650 * particular dissector, or if it bases the decision of which dissector
1651 * to call on something other than a numerical value or on "try a bunch
1652 * of dissectors until one likes the packet".
1656 * List of registered dissectors.
1658 static GHashTable *registered_dissectors = NULL;
1660 /* Get the short name of the protocol for a dissector handle, if it has
1663 dissector_handle_get_short_name(dissector_handle_t handle)
1665 if (handle->protocol == NULL) {
1667 * No protocol (see, for example, the handle for
1668 * dissecting the set of protocols where the first
1669 * octet of the payload is an OSI network layer protocol
1674 return proto_get_protocol_short_name(handle->protocol);
1677 /* Get the index of the protocol for a dissector handle, if it has
1680 dissector_handle_get_protocol_index(dissector_handle_t handle)
1682 if (handle->protocol == NULL) {
1684 * No protocol (see, for example, the handle for
1685 * dissecting the set of protocols where the first
1686 * octet of the payload is an OSI network layer protocol
1691 return proto_get_id(handle->protocol);
1694 /* Find a registered dissector by name. */
1696 find_dissector(const char *name)
1698 g_assert(registered_dissectors != NULL);
1699 return g_hash_table_lookup(registered_dissectors, name);
1702 /* Create an anonymous handle for a dissector. */
1704 create_dissector_handle(dissector_t dissector, int proto)
1706 struct dissector_handle *handle;
1708 handle = g_malloc(sizeof (struct dissector_handle));
1709 handle->name = NULL;
1710 handle->is_new = FALSE;
1711 handle->dissector.old = dissector;
1712 handle->protocol = find_protocol_by_id(proto);
1718 new_create_dissector_handle(new_dissector_t dissector, int proto)
1720 struct dissector_handle *handle;
1722 handle = g_malloc(sizeof (struct dissector_handle));
1723 handle->name = NULL;
1724 handle->is_new = TRUE;
1725 handle->dissector.new = dissector;
1726 handle->protocol = find_protocol_by_id(proto);
1731 /* Register a dissector by name. */
1733 register_dissector(const char *name, dissector_t dissector, int proto)
1735 struct dissector_handle *handle;
1737 /* Create our hash table if it doesn't already exist */
1738 if (registered_dissectors == NULL) {
1739 registered_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
1740 g_assert(registered_dissectors != NULL);
1743 /* Make sure the registration is unique */
1744 g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
1746 handle = g_malloc(sizeof (struct dissector_handle));
1747 handle->name = name;
1748 handle->is_new = FALSE;
1749 handle->dissector.old = dissector;
1750 handle->protocol = find_protocol_by_id(proto);
1752 g_hash_table_insert(registered_dissectors, (gpointer)name,
1757 new_register_dissector(const char *name, new_dissector_t dissector, int proto)
1759 struct dissector_handle *handle;
1761 /* Create our hash table if it doesn't already exist */
1762 if (registered_dissectors == NULL) {
1763 registered_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
1764 g_assert(registered_dissectors != NULL);
1767 /* Make sure the registration is unique */
1768 g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
1770 handle = g_malloc(sizeof (struct dissector_handle));
1771 handle->name = name;
1772 handle->is_new = TRUE;
1773 handle->dissector.new = dissector;
1774 handle->protocol = find_protocol_by_id(proto);
1776 g_hash_table_insert(registered_dissectors, (gpointer)name,
1780 /* Call a dissector through a handle but if the dissector rejected it
1784 call_dissector_only(dissector_handle_t handle, tvbuff_t *tvb,
1785 packet_info *pinfo, proto_tree *tree)
1789 g_assert(handle != NULL);
1790 ret = call_dissector_work(handle, tvb, pinfo, tree);
1794 /* Call a dissector through a handle and if this fails call the "data"
1798 call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
1799 packet_info *pinfo, proto_tree *tree)
1803 ret = call_dissector_only(handle, tvb, pinfo, tree);
1806 * The protocol was disabled, or the dissector rejected
1807 * it. Just dissect this packet as data.
1809 g_assert(data_handle != NULL);
1810 g_assert(data_handle->protocol != NULL);
1811 call_dissector_work(data_handle, tvb, pinfo, tree);
1812 return tvb_length(tvb);
1818 * Dumps the "layer type"/"decode as" associations to stdout, similar
1819 * to the proto_registrar_dump_*() routines.
1821 * There is one record per line. The fields are tab-delimited.
1823 * Field 1 = layer type, e.g. "tcp.port"
1824 * Field 2 = selector in decimal
1825 * Field 3 = "decode as" name, e.g. "http"
1830 dissector_dump_decodes_display(const gchar *table_name,
1831 ftenum_t selector_type _U_, gpointer key, gpointer value,
1832 gpointer user_data _U_)
1834 guint32 selector = (guint32)(unsigned long) key;
1835 dissector_table_t sub_dissectors = find_dissector_table(table_name);
1836 dtbl_entry_t *dtbl_entry;
1837 dissector_handle_t handle;
1839 const gchar *decode_as;
1841 g_assert(sub_dissectors);
1842 switch (sub_dissectors->type) {
1849 g_assert(dtbl_entry);
1851 handle = dtbl_entry->current;
1854 proto_id = dissector_handle_get_protocol_index(handle);
1856 if (proto_id != -1) {
1857 decode_as = proto_get_protocol_filter_name(proto_id);
1858 g_assert(decode_as != NULL);
1859 printf("%s\t%u\t%s\n", table_name, selector, decode_as);
1869 dissector_dump_decodes()
1871 dissector_all_tables_foreach(dissector_dump_decodes_display, NULL);
1874 static GPtrArray* post_dissectors = NULL;
1875 static guint num_of_postdissectors = 0;
1878 register_postdissector(dissector_handle_t handle)
1880 if (!post_dissectors)
1881 post_dissectors = g_ptr_array_new();
1883 g_ptr_array_add(post_dissectors, handle);
1884 num_of_postdissectors++;
1888 have_postdissector()
1891 dissector_handle_t handle;
1893 for(i = 0; i < num_of_postdissectors; i++) {
1894 handle = (dissector_handle_t) g_ptr_array_index(post_dissectors,i);
1896 if (handle->protocol != NULL
1897 && proto_is_protocol_enabled(handle->protocol)) {
1898 /* We have at least one enabled postdissector */
1906 call_all_postdissectors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1910 for(i = 0; i < num_of_postdissectors; i++) {
1911 call_dissector_only((dissector_handle_t) g_ptr_array_index(post_dissectors,i),