summaryrefslogtreecommitdiff
path: root/text2pcap.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2012-12-25 14:34:24 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2012-12-25 14:34:24 +0000
commitdcd2b0614b4d97a079d69f7d44b8d2f6f06b783a (patch)
treeeb3c316b6e01223edb23051c108393d163dc6392 /text2pcap.c
parent4aa19ce98fc4b641b151d2d4a981a88c30ebe570 (diff)
downloadwireshark-dcd2b0614b4d97a079d69f7d44b8d2f6f06b783a.tar.gz
Fix SCTP packet generation if DATA chunk headers need
to be generated. svn path=/trunk/; revision=46736
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/text2pcap.c b/text2pcap.c
index 3acc6dedae..99868b1f90 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -589,7 +589,11 @@ write_current_packet (void)
/* Compute packet length */
length = curr_offset;
-
+ if (hdr_sctp) {
+ padding_length = number_of_padding_bytes(length - header_length );
+ } else {
+ padding_length = 0;
+ }
/* Reset curr_offset, since we now write the headers */
curr_offset = 0;
@@ -601,7 +605,7 @@ write_current_packet (void)
/* Write IP header */
if (hdr_ip) {
- HDR_IP.packet_length = g_htons(length - ip_offset);
+ HDR_IP.packet_length = g_htons(length - ip_offset + padding_length);
HDR_IP.protocol = (guint8) hdr_ip_proto;
HDR_IP.hdr_checksum = 0;
HDR_IP.hdr_checksum = in_checksum(&HDR_IP, sizeof(HDR_IP));
@@ -671,11 +675,21 @@ write_current_packet (void)
HDR_TCP.seq_num = g_htonl(HDR_TCP.seq_num);
}
+ /* Compute DATA chunk header */
+ if (hdr_data_chunk) {
+ HDR_DATA_CHUNK.type = hdr_data_chunk_type;
+ HDR_DATA_CHUNK.bits = hdr_data_chunk_bits;
+ HDR_DATA_CHUNK.length = g_htons(length - header_length + sizeof(HDR_DATA_CHUNK));
+ HDR_DATA_CHUNK.tsn = g_htonl(hdr_data_chunk_tsn);
+ HDR_DATA_CHUNK.sid = g_htons(hdr_data_chunk_sid);
+ HDR_DATA_CHUNK.ssn = g_htons(hdr_data_chunk_ssn);
+ HDR_DATA_CHUNK.ppid = g_htonl(hdr_data_chunk_ppid);
+ }
+
/* Write SCTP common header */
if (hdr_sctp) {
guint32 zero = 0;
- padding_length = number_of_padding_bytes(length - header_length);
HDR_SCTP.src_port = g_htons(hdr_sctp_src);
HDR_SCTP.dest_port = g_htons(hdr_sctp_dest);
HDR_SCTP.tag = g_htonl(hdr_sctp_tag);
@@ -693,15 +707,8 @@ write_current_packet (void)
write_bytes((const char *)&HDR_SCTP, sizeof(HDR_SCTP));
}
- /* Compute DATA chunk header and append padding */
+ /* Write DATA chunk header */
if (hdr_data_chunk) {
- HDR_DATA_CHUNK.type = hdr_data_chunk_type;
- HDR_DATA_CHUNK.bits = hdr_data_chunk_bits;
- HDR_DATA_CHUNK.length = g_htons(length - header_length + sizeof(HDR_DATA_CHUNK));
- HDR_DATA_CHUNK.tsn = g_htonl(hdr_data_chunk_tsn);
- HDR_DATA_CHUNK.sid = g_htons(hdr_data_chunk_sid);
- HDR_DATA_CHUNK.ssn = g_htons(hdr_data_chunk_ssn);
- HDR_DATA_CHUNK.ppid = g_htonl(hdr_data_chunk_ppid);
write_bytes((const char *)&HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK));
}