change all file offsets from long to gint64 so we can - theoretically - handle files...
[metze/wireshark/wip.git] / wiretap / csids.c
index 09b9455fb6937e171473e329d46757682645a923..fc078c212905ad3a6c6ed782bbcbeacd52077e18 100644 (file)
@@ -1,6 +1,6 @@
 /* csids.c
  *
- * $Id: csids.c,v 1.15 2002/08/28 20:30:44 jmayer Exp $
+ * $Id$
  *
  * Copyright (c) 2000 by Mike Hall <mlh@io.com>
  * Copyright (c) 2000 by Cisco Systems
  *
  * For a time there was an error in iplogging and the ip length, flags, and id
  * were byteswapped. We will check for this and handle it before handing to
- * ethereal.
+ * wireshark.
  */
 
-static gboolean csids_read(wtap *wth, int *err, long *data_offset);
-static gboolean csids_seek_read(wtap *wth, long seek_off,
-       union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err);
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
+       gint64 *data_offset);
+static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
+       union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+       int *err, gchar **err_info);
 static void csids_close(wtap *wth);
 
 struct csids_header {
@@ -56,7 +58,7 @@ struct csids_header {
 };
 
 /* XXX - return -1 on I/O error and actually do something with 'err'. */
-int csids_open(wtap *wth, int *err)
+int csids_open(wtap *wth, int *err, gchar **err_info _U_)
 {
   /* There is no file header. There is only a header for each packet
    * so we read a packet header and compare the caplen with iplen. They
@@ -136,12 +138,14 @@ int csids_open(wtap *wth, int *err)
   wth->subtype_read = csids_read;
   wth->subtype_seek_read = csids_seek_read;
   wth->subtype_close = csids_close;
+  wth->tsprecision = WTAP_FILE_TSPREC_SEC;
 
   return 1;
 }
 
-/* Find the next packet and parse it; called from wtap_loop(). */
-static gboolean csids_read(wtap *wth, int *err, long *data_offset)
+/* Find the next packet and parse it; called from wtap_read(). */
+static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
+    gint64 *data_offset)
 {
   guint8 *buf;
   int bytesRead = 0;
@@ -177,9 +181,8 @@ static gboolean csids_read(wtap *wth, int *err, long *data_offset)
 
   wth->phdr.len = hdr.caplen;
   wth->phdr.caplen = hdr.caplen;
-  wth->phdr.ts.tv_sec = hdr.seconds;
-  wth->phdr.ts.tv_usec = 0;
-  wth->phdr.pkt_encap = WTAP_ENCAP_RAW_IP;
+  wth->phdr.ts.secs = hdr.seconds;
+  wth->phdr.ts.nsecs = 0;
 
   if( wth->capture.csids->byteswapped == TRUE ) {
     guint16* swap = (guint16*)buf;
@@ -197,11 +200,12 @@ static gboolean csids_read(wtap *wth, int *err, long *data_offset)
 /* Used to read packets in random-access fashion */
 static gboolean
 csids_seek_read (wtap *wth,
-                long seek_off,
+                gint64 seek_off,
                 union wtap_pseudo_header *pseudo_header _U_,
                 guint8 *pd,
                 int len,
-                int *err)
+                int *err,
+                gchar **err_info)
 {
   int bytesRead;
   struct csids_header hdr;
@@ -222,6 +226,8 @@ csids_seek_read (wtap *wth,
 
   if( len != hdr.caplen ) {
     *err = WTAP_ERR_BAD_RECORD;
+    *err_info = g_strdup_printf("csids: record length %u doesn't match requested length %d",
+                                 hdr.caplen, len);
     return FALSE;
   }