Ethereal-dev: [Ethereal-dev] [Fwd: [patches] tap]
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Jason House <jhouse@xxxxxxxxx>
Date: Thu, 17 Oct 2002 11:23:07 -0400
--- Begin Message ---From: "Pia Sahlberg" <piabar@xxxxxxxxxxx>Date: Wed, 16 Oct 2002 23:26:21 +0000Hi Jason, can i ask you a favor?Since Im travelling and dont get access to my internet for quite some time, it is a delay for all my posts to appear on the list.(my hotmail account is not member of the list and thus the posts have to be manually scanned and approved before they appear. I think Gerald that does this may be busy).I have two patche that I want the list to get and check in (since I cant do it myslef right now)\could you just forward them to the list so they get checked in? thanks --- Hi list, Attached are two patchestap.diff will change the interface between file.c/tethereal.c and the tap system so that we get dissect-at-most-once for packets. No more dissect the packet first in file.c and then in tap.c killing performance. It also gets rid of those ugly extra parameters such as pseudoheader and such between file.c and tap.ctcp.diff this fixes the bug recently discussed on the list with TCP-Desegmentation interaction with TCP-Relative-Sequence-Numbers.best regards ronnie sahlberg _________________________________________________________________Get a speedy connection with MSN Broadband. Join now! http://resourcecenter.msn.com/access/plans/freeactivation.aspdiff -u -r -x *.[^ch]|nmake|am ethereal-orig/file.c ethereal/file.c --- ethereal-orig/file.c Wed Oct 16 20:26:58 2002 +++ ethereal/file.c Wed Oct 16 19:49:17 2002 @@ -657,18 +657,21 @@ firstusec = fdata->abs_usecs; } - tap_queue_init(pseudo_header, buf, fdata); /* If either we have a display filter and are re-applying it; we have a list of color filters; + we have tap listeners; + allocate a protocol tree root node, so that we'll construct a protocol tree against which a filter expression can be evaluated. */ if ((cf->dfcode != NULL && refilter) || filter_list != NULL) create_proto_tree = TRUE; + if ( num_tap_filters ) + create_proto_tree = TRUE; /* Dissect the frame. */ edt = epan_dissect_new(create_proto_tree, FALSE); @@ -679,8 +682,9 @@ if (filter_list) { filter_list_prime_edt(edt); } + tap_queue_init(edt); epan_dissect_run(edt, pseudo_header, buf, fdata, &cf->cinfo); - tap_push_tapped_queue(); + tap_push_tapped_queue(edt); /* If we have a display filter, apply it if we're refiltering, otherwise leave the "passed_dfilter" flag alone. diff -u -r -x *.[^ch]|nmake|am ethereal-orig/tap.c ethereal/tap.c --- ethereal-orig/tap.c Wed Oct 16 20:26:58 2002 +++ ethereal/tap.c Wed Oct 16 20:28:11 2002 @@ -41,7 +41,8 @@ #include "epan/dfilter/dfilter.h" #include "tap.h" -int tapping_is_active=0; +static int tapping_is_active=0; +int num_tap_filters=0; typedef struct _tap_dissector_t { struct _tap_dissector_t *next; @@ -79,10 +80,6 @@ } tap_listener_t; static volatile tap_listener_t *tap_listener_queue=NULL; -static union wtap_pseudo_header *l_pseudo_header=NULL; -static const u_char *l_buf=NULL; -static frame_data *l_fdata; - /* ********************************************************************** * Init routine only called from epan at application startup* ********************************************************************** */@@ -201,52 +198,56 @@This is very cheap since we just prepend the used queue to the free queue.*/ void-tap_queue_init(union wtap_pseudo_header *pseudo_header, const u_char *buf, frame_data *fdata)+tap_queue_init(epan_dissect_t *edt) { tap_packet_t *tpt; + tap_listener_t *tl; - l_pseudo_header=pseudo_header; - l_buf=buf; - l_fdata=fdata; + /* nothing to do, just return */ + if(!tap_listener_queue){ + return; + } tapping_is_active=1; - tpt=tap_packet_list_queue; - if(!tpt){ - return; - } - - for(;tpt->next;tpt=tpt->next) + if(tpt){ + for(;tpt->next;tpt=tpt->next) ; - tpt->next=tap_packet_list_free; - tap_packet_list_free=tap_packet_list_queue; - tap_packet_list_queue=NULL; + tpt->next=tap_packet_list_free; + tap_packet_list_free=tap_packet_list_queue; + tap_packet_list_queue=NULL; + } + /* loop over all tap listeners and build the list of all + interesting hf_fields */ + for(tl=(tap_listener_t *)tap_listener_queue;tl;tl=tl->next){ + if(tl->code){ + epan_dissect_prime_dfilter(edt, tl->code); + } + } }/* this function is called after a packet has been fully dissected to push the tappeddata to all extensions that has callbacks registered. */ void -tap_push_tapped_queue(void) +tap_push_tapped_queue(epan_dissect_t *edt) { tap_packet_t *tp; tap_listener_t *tl; - epan_dissect_t *edt; - - tapping_is_active=0; - edt=epan_dissect_new(TRUE, FALSE); - /* loop over all tap listeners and build the list of all - interesting hf_fields */ - for(tl=(tap_listener_t *)tap_listener_queue;tl;tl=tl->next){ - if(tl->code){ - epan_dissect_prime_dfilter(edt, tl->code); - } + /* nothing to do, just return */ + if(!tapping_is_active){ + return; } - epan_dissect_run(edt, l_pseudo_header, l_buf, l_fdata, NULL); + tapping_is_active=0; + + /* nothing to do, just return */ + if(!tap_packet_list_queue){ + return; + } /* loop over all tap listeners and call the listener callback for all packets that match the filter. */ @@ -263,8 +264,6 @@ } } } - - epan_dissect_free(edt); }/* This function is called when we need to reset all tap listeners, for example@@ -310,7 +309,7 @@ /* ********************************************************************** - * Functions used by the RS (Really Simple api) extension to + * Functions used by tap to * 1, register that a really simple extension is available for use by * ethereal. * 2, start tapping from a subdissector @@ -358,6 +357,8 @@ g_free(tl); fprintf(stderr,"register_tap_listener(): %s\n", dfilter_error_msg); return 1; + } else { + num_tap_filters++; } } @@ -401,6 +402,7 @@ if(tl){ if(tl->code){ dfilter_free(tl->code); + num_tap_filters--; } g_free(tl); } diff -u -r -x *.[^ch]|nmake|am ethereal-orig/tap.h ethereal/tap.h --- ethereal-orig/tap.h Wed Oct 16 20:26:59 2002 +++ ethereal/tap.h Wed Oct 16 19:55:15 2002 @@ -22,14 +22,16 @@* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ -#include "wiretap/wtap.h" +#include "epan/epan.h" + +extern int num_tap_filters; void tap_init(void); int register_tap(char *name); int find_tap_id(char *name);void tap_queue_packet(int tap_id, packet_info *pinfo, void *tap_specific_data); -void tap_queue_init(union wtap_pseudo_header *pseudo_header, const u_char *buf, frame_data *fdata);-void tap_push_tapped_queue(void); +void tap_queue_init(epan_dissect_t *edt); +void tap_push_tapped_queue(epan_dissect_t *edt); extern int tapping_is_active; void reset_tap_listeners(void); void draw_tap_listeners(gboolean draw_all);diff -u -r -x *.[^ch]|nmake|am ethereal-orig/tethereal.c ethereal/tethereal.c--- ethereal-orig/tethereal.c Wed Oct 16 20:27:00 2002 +++ ethereal/tethereal.c Wed Oct 16 19:55:45 2002 @@ -1675,9 +1675,9 @@ epan_dissect_prime_dfilter(edt, cf->rfcode); } - tap_queue_init(pseudo_header, buf, &fdata); + tap_queue_init(edt);epan_dissect_run(edt, pseudo_header, buf, &fdata, verbose ? NULL : &cf->cinfo);- tap_push_tapped_queue(); + tap_push_tapped_queue(edt); if (cf->rfcode) { passed = dfilter_apply_edt(cf->rfcode, edt);diff -u -r -x *.[^ch]|nmake|am ethereal-orig/packet-tcp.c ethereal/packet-tcp.c--- ethereal-orig/packet-tcp.c Thu Oct 17 06:49:00 2002 +++ ethereal/packet-tcp.c Thu Oct 17 06:51:09 2002 @@ -743,6 +743,8 @@ address *dst; guint32 seq; /* xxx */ + guint16 sport; + guint16 dport; guint32 start_seq; guint32 tot_len; guint32 first_frame; @@ -771,7 +773,7 @@ { tcp_segment_key *key = (tcp_segment_key *)k; - return key->seq; + return key->seq+key->sport; } static gint @@ -783,6 +785,8 @@ return ( ( (key1->seq==key2->seq) &&(ADDRESSES_EQUAL(key1->src, key2->src)) &&(ADDRESSES_EQUAL(key1->dst, key2->dst)) + &&(key1->sport==key2->sport) + &&(key1->dport==key2->dport) ) ? TRUE:FALSE); } @@ -837,7 +841,7 @@ proto_tree *tree, proto_tree *tcp_tree) { struct tcpinfo *tcpinfo = pinfo->private_data; - fragment_data *ipfd_head; + fragment_data *ipfd_head=NULL; tcp_segment_key old_tsk, *tsk; gboolean must_desegment = FALSE; gboolean called_dissector = FALSE; @@ -868,6 +872,8 @@ */ old_tsk.src = &pinfo->src; old_tsk.dst = &pinfo->dst; + old_tsk.sport = sport; + old_tsk.dport = dport; old_tsk.seq = seq; tsk = g_hash_table_lookup(tcp_segment_table, &old_tsk); @@ -876,7 +882,7 @@ a higher-level PDU. This means we must desegment it. Add it to the defragmentation lists. */ - ipfd_head = fragment_add(tvb, offset, pinfo, tsk->start_seq, + ipfd_head = fragment_add(tvb, offset, pinfo, tsk->first_frame, tcp_fragment_table, seq - tsk->start_seq, nxtseq - seq, @@ -1001,7 +1007,7 @@ * being a new higher-level PDU that also * needs desegmentation). */ - fragment_set_partial_reassembly(pinfo,tsk->start_seq,tcp_fragment_table); + fragment_set_partial_reassembly(pinfo,tsk->first_frame,tcp_fragment_table); tsk->tot_len = tvb_reported_length(next_tvb) + pinfo->desegment_len; /* @@ -1148,11 +1154,13 @@ tsk->start_seq = tsk->seq; tsk->tot_len = nxtseq - tsk->start_seq + pinfo->desegment_len; tsk->first_frame = pinfo->fd->num; + tsk->sport=sport; + tsk->dport=dport; g_hash_table_insert(tcp_segment_table, tsk, tsk); /* Add portion of segment unprocessed by the subdissector to defragmentation lists */ - fragment_add(tvb, deseg_offset, pinfo, tsk->start_seq, + fragment_add(tvb, deseg_offset, pinfo, tsk->first_frame, tcp_fragment_table, tsk->seq - tsk->start_seq, nxtseq - tsk->start_seq,
--- End Message ---
- Follow-Ups:
- Re: [Ethereal-dev] [Fwd: [patches] tap]
- From: Guy Harris
- Re: [Ethereal-dev] [Fwd: [patches] tap]
- Prev by Date: [Ethereal-dev] patches for arcnet support
- Next by Date: Re: [Ethereal-dev] RSVP-TE decode problem
- Previous by thread: Re: [Ethereal-dev] Re: patches for arcnet support
- Next by thread: Re: [Ethereal-dev] [Fwd: [patches] tap]
- Index(es):