Wireshark-dev: Re: [Wireshark-dev] Dissector global variable
From: Jeff Morriss <[email protected]>
Date: Mon, 30 Jun 2008 11:49:58 -0400

Hans Glück wrote:
Hello, I´m writing a dissector and I want to implement "error recovery mode"/"flow control", therefor I need two gloabl variables where I can store some values (-> "next_expected_frame_to_be_recieved" and "next_expected_frame_to_be_send"). I declared them at the beginning of my c-file: static guint8 next_expected_frame_to_be_recieved = 0; static guint8 next_expected_frame_to_be_send = 0; And I set value of this variables in my dissector code: static void dissect_mux27010(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ ... if (received_successful()) { next_expected_frame_to_be_recieved++; } ... } My problem is: Every time I click in Wireshark at packet the value is increased e.g. click first packet -> next_expected_frame_to_be_recieved == 1 click second packet -> next_expected_frame_to_be_recieved == 2 click first packet -> next_expected_frame_to_be_recieved == 3 click second packet -> next_expected_frame_to_be_recieved == 4 But what I want is that the variables are increased step-by-step/ ordered (if packet n is an ACK -> increase; if packet n+1 is an ACK -> increase...) How can I realize this?
You might want to look at the variable pinfo->fd->flags.visited .  My 
(limited) understanding is it is set to 0 only the first time a 
particular frame is given to your dissector (after a file load/reload).