----- Original Message ----- From: "Jason House" Sent: Wednesday, December 04, 2002 3:17 AM Subject: Re: [Ethereal-dev] [Patch] revised: tap-tcp_close
> Guy Harris wrote: > > > > On Mon, Dec 02, 2002 at 09:23:56AM -0500, Jason House wrote: > > > Per Ronnie's suggestions, I have updated packet-tcp.c and tap-tcp_close > > It's a bit ugly to have "td" be static; I suppose it's not a problem in > > most cases, but one could imagine TCP-over-IP-over-X.25-over-TCP > > captures in which there's more than one TCP header per packet. > > > > Unfortunately, as a pointer to it is passed to "tap_queue_packet()", it > > can't be local to "dissect_tcp()". > > > Proposed solution: > > * In Tapping Core: > convert register_tap to: > int register_tap(char *name, void (deallocate)(void*)) > Have dissect_tcp allocate a new copy of "td" each time it is run > Have tap_queue_packet call deallocate if data won't be used. > And have tap_push_tapped_queue call deallocate after data is used ... That would complicate the API a bit. I think a much simpler solution, which is used to solve the same/similar problem elsewhere all over the place would be to add to dissect_tcp(){ static int cur_tcp_hdr_struct=0; static struct tcp_header tcph[4], *tcp; tcp=&tcph[tcp_hdr_struct]; tcp_hdr_struct++; if(tcp_hdr_struct>=4) tcp_hdr_Struct=0; adn then from there on use tcp-> everywhere in disect_tcp()