On Tue, Apr 15, 2003 at 12:36:42PM +0300, Shaul Eizikovich wrote:
> I have been writing a new dissector where adjacent packets are grouped
> according to some accumulative data.
> To do so, I employed the p_add_proto_data() and p_get_proto_data() function
> pair.
>
> In short:
> Crash when redissecting.
> Important data: I do not pass pinfo->fd, rather I pass pinfo->fd->prev as
> first parameter of p_get_proto_data()
>
> More detailed explanation:
> Every time the dissector is called it checks if a previous packet exists,
> if it does then it gets my data structure that I have previously added.
As Ronnie Sahlberg noted, that's *NOT* the case if the previous packet
wasn't a packet for your new dissector's protocol.
> Then, my dissector data structure is malloc'd, filled-in with data and
> stored using p_add_proto_data().
Presumably that's what's done if the attempt to get the data structure
returns a null pointer, meaning that the data structure *wasn't*
previously added.
> When I re-dissect an input file (e.g. Decode As ...) I usually get a crash
> that results from the following condition:
> pinfo->fd is OK,
> if (pinfo->fd->next)
> next_packet = (my_packet *)p_get_proto_data(pinfo->fd->next,
> proto_myproto);
pinfo->fd->next, or pinfo->fd->prev? You said pinfo->fd->prev earlier.