/* Read the next packet */ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { int bytes_read; char fcs[2]; *data_offset = file_tell(wth->fh); /* Read record header. */ if (!radcom_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) { /* Read error or EOF */ return FALSE; } if (wth->file_encap == WTAP_ENCAP_LAPB) { /* Read the FCS. XXX - should we have some way of indicating the presence and size of an FCS to our caller? That'd let us handle other file types as well. */ errno = WTAP_ERR_CANT_READ; bytes_read = file_read(&fcs, sizeof fcs, wth->fh); if (bytes_read != sizeof fcs) { *err = file_error(wth->fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; } } return TRUE; }
static gboolean radcom_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int length _U_, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read record. */ if (!radcom_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) { /* Read error or EOF */ if (*err == 0) { /* EOF means "short read" in random-access mode */ *err = WTAP_ERR_SHORT_READ; } return FALSE; } return TRUE; }
/* Read the next packet */ static gboolean radcom_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info, gint64 *data_offset) { char fcs[2]; *data_offset = file_tell(wth->fh); /* Read record. */ if (!radcom_read_rec(wth, wth->fh, rec, buf, err, err_info)) { /* Read error or EOF */ return FALSE; } if (wth->file_encap == WTAP_ENCAP_LAPB) { /* Read the FCS. XXX - should we have some way of indicating the presence and size of an FCS to our caller? That'd let us handle other file types as well. */ if (!wtap_read_bytes(wth->fh, &fcs, sizeof fcs, err, err_info)) return FALSE; } return TRUE; }