Move the new files to the same places as in automake.
[obnox/wireshark/wip.git] / wiretap / eyesdn.c
index 4f54467..897e32e 100644 (file)
@@ -105,8 +105,9 @@ static int parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
        union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
 
 /* Seeks to the beginning of the next packet, and returns the
-   byte offset.  Returns -1 on failure, and sets "*err" to the error. */
-static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
+   byte offset.  Returns -1 on failure, and sets "*err" to the error
+   and "*err_info" to null or an additional error string. */
+static gint64 eyesdn_seek_next_packet(wtap *wth, int *err, gchar **err_info)
 {
        int byte;
        gint64 cur_off;
@@ -116,7 +117,7 @@ static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
                        cur_off = file_tell(wth->fh);
                        if (cur_off == -1) {
                                /* Error. */
-                               *err = file_error(wth->fh);
+                               *err = file_error(wth->fh, err_info);
                                return -1;
                        }
                        return cur_off;
@@ -127,12 +128,12 @@ static gint64 eyesdn_seek_next_packet(wtap *wth, int *err)
                *err = 0;
        } else {
                /* We got an error. */
-               *err = file_error(wth->fh);
+               *err = file_error(wth->fh, err_info);
        }
        return -1;
 }
 
-int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_)
+int eyesdn_open(wtap *wth, int *err, gchar **err_info)
 {
        int     bytes_read;
        char    magic[EYESDN_HDR_MAGIC_SIZE];
@@ -141,7 +142,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_)
        errno = WTAP_ERR_CANT_READ;
        bytes_read = file_read(&magic, sizeof magic, wth->fh);
        if (bytes_read != sizeof magic) {
-               *err = file_error(wth->fh);
+               *err = file_error(wth->fh, err_info);
                if (*err != 0)
                        return -1;
                return 0;
@@ -169,7 +170,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
        int     pkt_len;
 
        /* Find the next packet */
-       offset = eyesdn_seek_next_packet(wth, err);
+       offset = eyesdn_seek_next_packet(wth, err, err_info);
        if (offset < 1)
                return FALSE;
 
@@ -208,7 +209,7 @@ eyesdn_seek_read (wtap *wth, gint64 seek_off,
 
        if (pkt_len != len) {
                if (pkt_len != -1) {
-                       *err = WTAP_ERR_BAD_RECORD;
+                       *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup_printf("eyesdn: requested length %d doesn't match length %d",
                            len, pkt_len);
                }
@@ -235,7 +236,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
         * information.
         */
        if (esc_read(hdr, EYESDN_HDR_LENGTH, fh) != EYESDN_HDR_LENGTH) {
-               *err = file_error(fh);
+               *err = file_error(fh, err_info);
                if (*err == 0)
                        *err = WTAP_ERR_SHORT_READ;
                return -1;
@@ -295,7 +296,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
                gint64 cur_off;
 
                if(pkt_len != CELL_LEN) {
-                       *err = WTAP_ERR_BAD_RECORD;
+                       *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup_printf(
                            "eyesdn: ATM cell has a length != 53 (%u)",
                            pkt_len);
@@ -304,7 +305,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
 
                cur_off = file_tell(fh);
                if (esc_read(cell, CELL_LEN, fh) != CELL_LEN) {
-                       *err = file_error(fh);
+                       *err = file_error(fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
                        return -1;
@@ -359,13 +360,14 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
        }
 
        if(pkt_len > EYESDN_MAX_PACKET_LEN) {
-               *err = WTAP_ERR_BAD_RECORD;
+               *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("eyesdn: File has %u-byte packet, bigger than maximum of %u",
                pkt_len, EYESDN_MAX_PACKET_LEN);
                return -1;
        }
 
        if (wth) {
+               wth->phdr.presence_flags = WTAP_HAS_TS;
                wth->phdr.ts.secs = secs;
                wth->phdr.ts.nsecs = usecs * 1000;
                wth->phdr.caplen = pkt_len;
@@ -386,11 +388,11 @@ parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf, int *err,
        bytes_read = esc_read(buf, pkt_len, fh);
        if (bytes_read != pkt_len) {
                if (bytes_read == -2) {
-                       *err = file_error(fh);
+                       *err = file_error(fh, err_info);
                        if (*err == 0)
                                *err = WTAP_ERR_SHORT_READ;
                } else if (bytes_read == -1) {
-                       *err = WTAP_ERR_BAD_RECORD;
+                       *err = WTAP_ERR_BAD_FILE;
                        *err_info = g_strdup("eyesdn: No flag character seen in frame");
                } else
                        *err = WTAP_ERR_SHORT_READ;
@@ -426,9 +428,9 @@ esc_write(wtap_dumper *wdh, const guint8 *buf, int len, int *err)
 static gboolean eyesdn_dump(wtap_dumper *wdh,
                            const struct wtap_pkthdr *phdr,
                            const union wtap_pseudo_header *pseudo_header _U_,
-                           const guchar *pd, int *err);
+                           const guint8 *pd, int *err);
 
-gboolean eyesdn_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
+gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err)
 {
        wdh->subtype_write=eyesdn_dump;
        wdh->subtype_close=NULL;
@@ -464,7 +466,7 @@ int eyesdn_dump_can_write_encap(int encap)
 static gboolean eyesdn_dump(wtap_dumper *wdh,
                            const struct wtap_pkthdr *phdr,
                            const union wtap_pseudo_header *pseudo_header _U_,
-                           const guchar *pd, int *err)
+                           const guint8 *pd, int *err)
 {
        static const guint8 start_flag = 0xff;
        guint8 buf[EYESDN_HDR_LENGTH];