aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-03-06 02:46:20 -0800
committerGuy Harris <guy@alum.mit.edu>2019-03-06 10:47:06 +0000
commitd7a376447558a671376800c0c910d0afb90918d1 (patch)
treeb1315b64de0e9acd99bf4c85115853329d44ff58 /text2pcap.c
parent8f15ebed65ceea5c856fce055b5d83fb0c4b597b (diff)
Some cleanups.
hdr_ethernet is a flag indicating whether we should add a fake Ethernet header or not; make it a Boolean. Move number_of_padding_bytes() closer to where it is in ui/text_import.c, and make it more like the version there. Shift the direction flag to put it in the right bit position - or, at least, throw in the shift constant to clarify that we're trying to put it there, even if it's already in the right position (i.e., the shift constant happens to be 0, as it happens to be in the low-order bits). Fix a comment. Change-Id: Ia643d9ab2188951a682bf773239d0175c0d578c2 Reviewed-on: https://code.wireshark.org/review/32337 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/text2pcap.c b/text2pcap.c
index 30cc579f1d..762370a3bb 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -146,7 +146,7 @@ static int debug = 0;
static gboolean quiet = FALSE;
/* Dummy Ethernet header */
-static int hdr_ethernet = FALSE;
+static gboolean hdr_ethernet = FALSE;
static guint8 hdr_eth_dest_addr[6] = {0x0a, 0x02, 0x02, 0x02, 0x02, 0x02};
static guint8 hdr_eth_src_addr[6] = {0x0a, 0x02, 0x02, 0x02, 0x02, 0x01};
static guint32 hdr_ethernet_proto = 0;
@@ -202,7 +202,7 @@ static guint32 direction = PACK_FLAGS_DIRECTION_UNKNOWN;
static guint8 packet_buf[WTAP_MAX_PACKET_SIZE_STANDARD];
static guint32 header_length;
static guint32 ip_offset;
-static guint32 curr_offset;
+static guint32 curr_offset = 0;
static guint32 max_offset = WTAP_MAX_PACKET_SIZE_STANDARD;
static guint32 packet_start = 0;
@@ -462,6 +462,22 @@ unwrite_bytes (guint32 nbytes)
}
/*----------------------------------------------------------------------
+ * Determine SCTP chunk padding length
+ */
+static guint32
+number_of_padding_bytes (guint32 length)
+{
+ guint32 remainder;
+
+ remainder = length % 4;
+
+ if (remainder == 0)
+ return 0;
+ else
+ return 4 - remainder;
+}
+
+/*----------------------------------------------------------------------
* Compute one's complement checksum (from RFC1071)
*/
static guint16
@@ -590,19 +606,6 @@ finalize_crc32c (guint32 crc)
return result;
}
-static guint16
-number_of_padding_bytes (guint32 length)
-{
- guint16 remainder;
-
- remainder = length % 4;
-
- if (remainder == 0)
- return 0;
- else
- return 4 - remainder;
-}
-
/*----------------------------------------------------------------------
* Write current packet out
*/
@@ -834,7 +837,8 @@ write_current_packet (gboolean cont)
length, length,
0,
1000000000,
- packet_buf, direction,
+ packet_buf,
+ (direction << PACK_FLAGS_DIRECTION_SHIFT),
&bytes_written, &err);
} else {
success = libpcap_write_packet(output_file,
@@ -1048,7 +1052,7 @@ parse_preamble (void)
} else {
/*
* Convert that number to a number
- * of microseconds; if it's N digits
+ * of nanoseconds; if it's N digits
* long, it's in units of 10^(-N) seconds,
* so, to convert it to units of
* 10^-9 seconds, we multiply by