Skip to content

Commit

Permalink
Print a hint when the input file has no packet capture (#35)
Browse files Browse the repository at this point in the history
* fix header comment

* Print a hint when user runs on ETL file with no packet capture

* fix compile warning for printf format string

Co-authored-by: Matt Olson <[email protected]>
  • Loading branch information
maolson-msft and Matt Olson authored Feb 10, 2021
1 parent 1f0572c commit fd059e4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ in Windows that produces packet capture events) to pcapng format
-ndiscap supports packet truncation and so does pcapng, but ndiscap doesn't
currently log metadata about truncation in its events, so we try to infer
the original fragment length from IP headers and it currently works for
RAW and Eithernet frames. For LSO v2 packets since length field is not
filled, we can't infer the original length for them and we use the
truncated length as their original length.
the original fragment length from IP headers. This currently works for
RAW and Ethernet frames. For LSOv2 packets, since the length field is not
filled, we can't infer the original length, so we use the truncated length
as the original length.
*/

Expand Down Expand Up @@ -301,7 +301,7 @@ void WINAPI EventCallback(PEVENT_RECORD ev)
}

if (MetadataLength != sizeof(PacketMetadata)) {
printf("Unknown Metadata length. Expected %llu, got %u\n", sizeof(DOT11_EXTSTA_RECV_CONTEXT), MetadataLength);
printf("Unknown Metadata length. Expected %lu, got %u\n", (unsigned long)sizeof(DOT11_EXTSTA_RECV_CONTEXT), MetadataLength);
return;
}

Expand Down Expand Up @@ -531,7 +531,11 @@ int __cdecl wmain(int argc, wchar_t** argv)
goto Done;
}

printf("Converted %llu frames\n", NumFramesConverted);
if (NumFramesConverted == 0) {
printf("Input ETL file does not contain a packet capture.\n");
} else {
printf("Converted %llu frames\n", NumFramesConverted);
}

Done:
if (OutFile != INVALID_HANDLE_VALUE) {
Expand Down

0 comments on commit fd059e4

Please sign in to comment.