aboutsummaryrefslogtreecommitdiffstats
path: root/randpkt_core
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-02-08 16:19:12 -0800
committerGuy Harris <guy@alum.mit.edu>2018-02-09 00:29:51 +0000
commit1f5f63f8ef98bfe9c4d734674cee0df64855555d (patch)
tree133dd3563cc8d2d29dd85d4d43cd9a4636283192 /randpkt_core
parente4c5efafb7da2d25b7d47fe2dac3b1556c0b67b0 (diff)
Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'randpkt_core')
-rw-r--r--randpkt_core/randpkt_core.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c
index 7e73c7678b..bb0d6a650c 100644
--- a/randpkt_core/randpkt_core.c
+++ b/randpkt_core/randpkt_core.c
@@ -563,16 +563,16 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
gchar* err_info;
union wtap_pseudo_header* ps_header;
guint8* buffer;
- struct wtap_pkthdr* pkthdr;
+ wtap_rec* rec;
- pkthdr = g_new0(struct wtap_pkthdr, 1);
+ rec = g_new0(wtap_rec, 1);
buffer = (guint8*)g_malloc0(65536);
- pkthdr->rec_type = REC_TYPE_PACKET;
- pkthdr->presence_flags = WTAP_HAS_TS;
- pkthdr->pkt_encap = example->sample_wtap_encap;
+ rec->rec_type = REC_TYPE_PACKET;
+ rec->presence_flags = WTAP_HAS_TS;
+ rec->rec_header.packet_header.pkt_encap = example->sample_wtap_encap;
- ps_header = &pkthdr->pseudo_header;
+ ps_header = &rec->rec_header.packet_header.pseudo_header;
/* Load the sample pseudoheader into our pseudoheader buffer */
if (example->pseudo_buffer)
@@ -593,9 +593,9 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
len_this_pkt = example->sample_length + len_random;
- pkthdr->caplen = len_this_pkt;
- pkthdr->len = len_this_pkt;
- pkthdr->ts.secs = i; /* just for variety */
+ rec->rec_header.packet_header.caplen = len_this_pkt;
+ rec->rec_header.packet_header.len = len_this_pkt;
+ rec->ts.secs = i; /* just for variety */
for (j = example->pseudo_length; j < (int) sizeof(*ps_header); j++) {
((guint8*)ps_header)[j] = g_rand_int_range(pkt_rand, 0, 0x100);
@@ -611,14 +611,14 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
}
}
- if (!wtap_dump(example->dump, pkthdr, buffer, &err, &err_info)) {
+ if (!wtap_dump(example->dump, rec, buffer, &err, &err_info)) {
cfile_write_failure_message("randpkt", NULL,
example->filename, err, err_info, 0,
WTAP_FILE_TYPE_SUBTYPE_PCAP);
}
}
- g_free(pkthdr);
+ g_free(rec);
g_free(buffer);
}