Introduce cap_file_add_fdata() and start using it
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Tue, 22 Sep 2009 16:39:48 +0000 (16:39 -0000)
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Tue, 22 Sep 2009 16:39:48 +0000 (16:39 -0000)
svn path=/trunk/; revision=30071

cfile.c
cfile.h
file.c

diff --git a/cfile.c b/cfile.c
index e9f1f08332444bd4176ca4917eb59a4e9db18608..00498281e2bef230bbc3ec31e5eb89e125cb01d3 100644 (file)
--- a/cfile.c
+++ b/cfile.c
@@ -51,3 +51,15 @@ init_cap_file(capture_file *cf)
   cf->redissecting  = FALSE;
 }
 
+void
+cap_file_add_fdata(capture_file *cf, frame_data *fdata)
+{
+  frame_data *plist_end = cf->plist_end;
+  fdata->prev = plist_end;
+  if (plist_end != NULL)
+    plist_end->next = fdata;
+  else
+    cf->plist_start = fdata;
+  cf->plist_end = fdata;
+}
+
diff --git a/cfile.h b/cfile.h
index 9608d70001967c608421bd6701e78080e812dd05..613bc47cb4bda976a118e8241d2e7ae7711a7611 100644 (file)
--- a/cfile.h
+++ b/cfile.h
@@ -95,4 +95,6 @@ typedef struct _capture_file {
 
 void init_cap_file(capture_file *cf);
 
+void cap_file_add_fdata(capture_file *cf, frame_data *fdata);
+
 #endif /* cfile.h */
diff --git a/file.c b/file.c
index ad8af0e8dddcfc1209e207bac9c005d589b54b4c..ee8a9bf94971838046a9f20f3f5783bbaa974e7b 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1327,8 +1327,7 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
   const guchar *buf = wtap_buf_ptr(cf->wth);
   frame_data   *fdata;
   int           passed;
-  frame_data   *plist_end;
-  int row = -1;
+  int           row = -1;
 
   cf->count++;
 
@@ -1360,15 +1359,9 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
   }
 
   if (passed) {
-    plist_end = cf->plist_end;
-    fdata->prev = plist_end;
-    if (plist_end != NULL)
-      plist_end->next = fdata;
-    else
-      cf->plist_start = fdata;
-    cf->plist_end = fdata;
+    cap_file_add_fdata(cf, fdata);
 
-    cf->f_datalen = offset + phdr->caplen;
+    cf->f_datalen = offset + fdata->cap_len;
 
     if (!cf->redissecting) {
       row = add_packet_to_packet_list(fdata, cf, dfcode,