/* Used to read packets in random-access fashion */ static gboolean dct3trace_seek_read (wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guint8 *pd, int len, int *err, gchar **err_info) { int buf_len; unsigned char buf[MAX_PACKET_LEN]; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { return FALSE; } if( !dct3trace_get_packet(wth->random_fh, pseudo_header, buf, &buf_len, err, err_info) ) { return FALSE; } if( len != buf_len && len != -1 ) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dct3trace: requested length %d doesn't match record length %d", len, buf_len); return FALSE; } if( buf_len > MAX_PACKET_LEN) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("dct3trace: record length %d too long", buf_len); return FALSE; } memcpy( pd, buf, buf_len ); return TRUE; }
/* Find the next packet and parse it; called from wtap_read(). */ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { guint64 offset = file_tell(wth->fh); int buf_len; unsigned char buf[MAX_PACKET_LEN]; if( !dct3trace_get_packet(wth->fh, &wth->pseudo_header, buf, &buf_len, err, err_info) ) { return FALSE; } /* We've got a full packet! */ wth->phdr.presence_flags = 0; /* no time stamp, no separate "on the wire" length */ wth->phdr.ts.secs = 0; wth->phdr.ts.nsecs = 0; wth->phdr.caplen = buf_len; wth->phdr.len = buf_len; /* Make sure we have enough room for the packet */ buffer_assure_space(wth->frame_buffer, buf_len); memcpy( buffer_start_ptr(wth->frame_buffer), buf, buf_len ); *data_offset = offset; return TRUE; }
/* Find the next packet and parse it; called from wtap_read(). */ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); return dct3trace_get_packet(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); }
/* Used to read packets in random-access fashion */ static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) { return FALSE; } return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info); }