Corrected the MS/TP capture to limit data to the input buffer. (again)
This commit is contained in:
@@ -199,7 +199,8 @@ static void write_received_packet(
|
|||||||
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
||||||
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
incl_len = orig_len = 8 + mstp_port->DataLength + 2;
|
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
||||||
|
incl_len = orig_len = 8 + max_data + 2;
|
||||||
} else {
|
} else {
|
||||||
incl_len = orig_len = 8;
|
incl_len = orig_len = 8;
|
||||||
}
|
}
|
||||||
@@ -215,7 +216,6 @@ static void write_received_packet(
|
|||||||
header[7] = mstp_port->HeaderCRCActual;
|
header[7] = mstp_port->HeaderCRCActual;
|
||||||
fwrite(header, sizeof(header), 1, pFile);
|
fwrite(header, sizeof(header), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
|
||||||
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
|
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
|
||||||
fwrite((char *) &mstp_port->DataCRCActualMSB, 1, 1, pFile);
|
fwrite((char *) &mstp_port->DataCRCActualMSB, 1, 1, pFile);
|
||||||
fwrite((char *) &mstp_port->DataCRCActualLSB, 1, 1, pFile);
|
fwrite((char *) &mstp_port->DataCRCActualLSB, 1, 1, pFile);
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ static void snap_received_packet(
|
|||||||
uint16_t mtu_len = 0; /* number of octets of packet saved in file */
|
uint16_t mtu_len = 0; /* number of octets of packet saved in file */
|
||||||
unsigned i = 0; /* counter */
|
unsigned i = 0; /* counter */
|
||||||
static uint8_t mtu[1500] = { 0 };
|
static uint8_t mtu[1500] = { 0 };
|
||||||
size_t max_data = 0;
|
uint16_t max_data = 0;
|
||||||
|
|
||||||
mtu[0] = 0;
|
mtu[0] = 0;
|
||||||
mtu[1] = 0;
|
mtu[1] = 0;
|
||||||
@@ -200,7 +200,7 @@ static void snap_received_packet(
|
|||||||
mtu[30] = mstp_port->HeaderCRCActual;
|
mtu[30] = mstp_port->HeaderCRCActual;
|
||||||
mtu_len = 31;
|
mtu_len = 31;
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
||||||
for (i = 0; i < max_data; i++) {
|
for (i = 0; i < max_data; i++) {
|
||||||
mtu[31 + i] = mstp_port->InputBuffer[i];
|
mtu[31 + i] = mstp_port->InputBuffer[i];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,8 @@ static void write_received_packet(
|
|||||||
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
||||||
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
incl_len = orig_len = 8 + mstp_port->DataLength + 2;
|
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
||||||
|
incl_len = orig_len = 8 + max_data + 2;
|
||||||
} else {
|
} else {
|
||||||
incl_len = orig_len = 8;
|
incl_len = orig_len = 8;
|
||||||
}
|
}
|
||||||
@@ -209,7 +210,6 @@ static void write_received_packet(
|
|||||||
header[7] = mstp_port->HeaderCRCActual;
|
header[7] = mstp_port->HeaderCRCActual;
|
||||||
fwrite(header, sizeof(header), 1, pFile);
|
fwrite(header, sizeof(header), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
|
||||||
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
|
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
|
||||||
fwrite(&(mstp_port->DataCRCActualMSB), 1, 1, pFile);
|
fwrite(&(mstp_port->DataCRCActualMSB), 1, 1, pFile);
|
||||||
fwrite(&(mstp_port->DataCRCActualLSB), 1, 1, pFile);
|
fwrite(&(mstp_port->DataCRCActualLSB), 1, 1, pFile);
|
||||||
|
|||||||
@@ -240,7 +240,8 @@ static void write_received_packet(
|
|||||||
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
||||||
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
incl_len = orig_len = 8 + mstp_port->DataLength + 2;
|
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
||||||
|
incl_len = orig_len = 8 + max_data + 2;
|
||||||
} else {
|
} else {
|
||||||
incl_len = orig_len = 8;
|
incl_len = orig_len = 8;
|
||||||
}
|
}
|
||||||
@@ -256,7 +257,6 @@ static void write_received_packet(
|
|||||||
header[7] = mstp_port->HeaderCRCActual;
|
header[7] = mstp_port->HeaderCRCActual;
|
||||||
fwrite(header, sizeof(header), 1, pFile);
|
fwrite(header, sizeof(header), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
fwrite(mstp_port->InputBuffer, mstp_port->DataLength, 1, pFile);
|
|
||||||
fwrite(&(mstp_port->DataCRCActualMSB), 1, 1, pFile);
|
fwrite(&(mstp_port->DataCRCActualMSB), 1, 1, pFile);
|
||||||
fwrite(&(mstp_port->DataCRCActualLSB), 1, 1, pFile);
|
fwrite(&(mstp_port->DataCRCActualLSB), 1, 1, pFile);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user