summaryrefslogtreecommitdiff
path: root/pcapio.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2012-12-19 20:27:12 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2012-12-19 20:27:12 +0000
commit10dbe80c650b03026e99acd65aab95ffc56c7d91 (patch)
tree3421f667ddff8a449717141044a4c7595fd5c4e6 /pcapio.c
parent1208041a4a5a476cccd8a7ac4492899cc5893e12 (diff)
downloadwireshark-10dbe80c650b03026e99acd65aab95ffc56c7d91.tar.gz
Add support for writing the flags option in the enhanced
packet block (pcapng). svn path=/trunk/; revision=46619
Diffstat (limited to 'pcapio.c')
-rw-r--r--pcapio.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pcapio.c b/pcapio.c
index 01d1eb5cdd..b45a0e7284 100644
--- a/pcapio.c
+++ b/pcapio.c
@@ -157,6 +157,7 @@ struct option {
};
#define OPT_ENDOFOPT 0
#define OPT_COMMENT 1
+#define EPB_FLAGS 2
#define SHB_HARDWARE 2 /* currently not used */
#define SHB_OS 3
#define SHB_USERAPPL 4
@@ -554,10 +555,12 @@ libpcap_write_enhanced_packet_block(FILE *fp,
guint32 interface_id,
guint ts_mul,
const u_char *pd,
+ guint32 flags,
long *bytes_written,
int *err)
{
struct epb epb;
+ struct option option;
guint32 block_total_length;
guint64 timestamp;
const guint32 padding = 0;
@@ -565,6 +568,9 @@ libpcap_write_enhanced_packet_block(FILE *fp,
block_total_length = sizeof(struct epb) +
ADD_PADDING(phdr->caplen) +
sizeof(guint32);
+ if (flags != 0) {
+ block_total_length += 2 * sizeof(struct option) + sizeof(guint32);
+ }
timestamp = (guint64)(phdr->ts.tv_sec) * ts_mul +
(guint64)(phdr->ts.tv_usec);
epb.block_type = ENHANCED_PACKET_BLOCK_TYPE;
@@ -579,6 +585,15 @@ libpcap_write_enhanced_packet_block(FILE *fp,
if (phdr->caplen % 4) {
WRITE_DATA(fp, &padding, 4 - phdr->caplen % 4, *bytes_written, err);
}
+ if (flags != 0) {
+ option.type = EPB_FLAGS;
+ option.value_length = sizeof(guint32);
+ WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+ WRITE_DATA(fp, &flags, sizeof(guint32), *bytes_written, err);
+ option.type = OPT_ENDOFOPT;
+ option.value_length = 0;
+ WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
+ }
WRITE_DATA(fp, &block_total_length, sizeof(guint32), *bytes_written, err);
return TRUE;
}