change all file offsets from long to gint64 so we can - theoretically - handle files...
[obnox/wireshark/wip.git] / wiretap / eyesdn.c
index 7320d8edff3840787dfe59cb7a5238ca44fe9215..a8f768b824e71c8178f2b0c091243dbc9af2374c 100644 (file)
@@ -1,6 +1,6 @@
 /* eyesdn.c
  *
- * $Id: eyesdn.c,v 1.8 2004/04/02 07:40:37 guy Exp $
+ * $Id$
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -43,7 +43,8 @@
  * Each Frame starts with the 0xff Flag byte
  * - Bytes 0-2: timestamp (long usec in network byte order)
  * - Bytes 3-7: timestamp (40bits sec since 1970 in network byte order)
- * - Byte 8: channel (0 for D channel, 1-30 for B1-B30)
+ * - Byte 8: channel (0 for D channel, 1-30 for B1-B30, 
+ *     128 ATM cells, 129 ATM layer indications)
  * - Byte 9: Sender (0 NT, 1 TE)
  * - Byte 10-11: frame size in bytes
  * - Byte 12-n: Frame Payload
@@ -94,8 +95,8 @@ static const unsigned char eyesdn_hdr_magic[]  =
 #define EYESDN_MAX_PACKET_LEN  16384
 
 static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
-       long *data_offset);
-static gboolean eyesdn_seek_read(wtap *wth, long seek_off,
+       gint64 *data_offset);
+static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
        union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
        int *err, gchar **err_info);
 static gboolean parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf,
@@ -105,10 +106,10 @@ static int parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
 
 /* Seeks to the beginning of the next packet, and returns the
    byte offset.  Returns -1 on failure, and sets "*err" to the error. */
-static long eyesdn_seek_next_packet(wtap *wth, int *err)
+static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
 {
   int byte;
-  long cur_off;
+  gint64 cur_off;
 
   while ((byte = file_getc(wth->fh)) != EOF) {
     if (byte == 0xff) {
@@ -155,15 +156,16 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_)
        wth->snapshot_length = 0; /* not known */
        wth->subtype_read = eyesdn_read;
        wth->subtype_seek_read = eyesdn_seek_read;
+       wth->tsprecision = WTAP_FILE_TSPREC_USEC;
 
        return 1;
 }
 
-/* Find the next packet and parse it; called from wtap_loop() and wtap_read(). */
+/* Find the next packet and parse it; called from wtap_read(). */
 static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
-    long *data_offset)
+    gint64 *data_offset)
 {
-       long    offset;
+       gint64  offset;
        guint8  *buf;
        int     pkt_len;
 
@@ -193,7 +195,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
 
 /* Used to read packets in random-access fashion */
 static gboolean
-eyesdn_seek_read (wtap *wth, long seek_off,
+eyesdn_seek_read (wtap *wth, gint64 seek_off,
        union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
        int *err, gchar **err_info)
 {
@@ -226,7 +228,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
        guint8          hdr[EYESDN_HDR_LENGTH];
         unsigned long   secs, usecs;
        int             pkt_len;
-       unsigned int    channel, direction;
+       guint8          channel, direction;
 
        /* Our file pointer should be at the summary information header
         * for a packet. Read in that header and extract the useful
@@ -259,7 +261,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
         pkt_len = (pkt_len << 8) | ((unsigned long) hdr[11]);
 
         /* sanity checks */
-        if(channel>30) {
+        if((channel>30)&&(channel<128)) {
            *err = WTAP_ERR_BAD_RECORD;
             *err_info = g_strdup_printf("eyesdn: bad channel number %u",
                channel);
@@ -280,8 +282,8 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
        }
 
        if (wth) {
-               wth->phdr.ts.tv_sec = secs;
-               wth->phdr.ts.tv_usec = usecs;
+               wth->phdr.ts.secs = secs;
+               wth->phdr.ts.nsecs = usecs * 1000;
                wth->phdr.caplen = pkt_len;
                wth->phdr.len = pkt_len;
        }