/* Used to read packets in random-access fashion */ static gboolean dbs_etherwatch_seek_read (wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, guint8 *pd, int len, int *err, gchar **err_info) { union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; int pkt_len; if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; pkt_len = parse_dbs_etherwatch_packet(NULL, wth->random_fh, pd, err, err_info); if (pkt_len != len) { if (pkt_len != -1) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dbs_etherwatch: packet length %d doesn't match requested length %d", pkt_len, len); } return FALSE; } /* * We don't have an FCS in this frame. */ pseudo_header->eth.fcs_len = 0; return TRUE; }
/* Find the next packet and parse it; called from wtap_read(). */ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; guint8 *buf; int pkt_len; /* Find the next packet */ offset = dbs_etherwatch_seek_next_packet(wth, err, err_info); if (offset < 1) return FALSE; /* Make sure we have enough room for the packet */ buffer_assure_space(wth->frame_buffer, DBS_ETHERWATCH_MAX_PACKET_LEN); buf = buffer_start_ptr(wth->frame_buffer); /* Parse the packet */ pkt_len = parse_dbs_etherwatch_packet(wth, wth->fh, buf, err, err_info); if (pkt_len == -1) return FALSE; /* * We don't have an FCS in this frame. */ wth->phdr.pseudo_header.eth.fcs_len = 0; *data_offset = offset; return TRUE; }
/* Used to read packets in random-access fashion */ static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) return FALSE; return parse_dbs_etherwatch_packet(rec, wth->random_fh, buf, err, err_info); }
/* Find the next packet and parse it; called from wtap_read(). */ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; /* Find the next packet */ offset = dbs_etherwatch_seek_next_packet(wth, err, err_info); if (offset < 1) return FALSE; *data_offset = offset; /* Parse the packet */ return parse_dbs_etherwatch_packet(&wth->rec, wth->fh, wth->rec_data, err, err_info); }