dotpcap / sharppcap

Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
1.33k stars 268 forks source link

unit for multiplying micro/nano-seconds wrong #369

Closed Bart-Baekelandt closed 2 years ago

Bart-Baekelandt commented 2 years ago

In PcapHeader.cs -> public IntPtr MarshalToIntPtr(TimestampResolution resolution)

Contains a unit for resizing the micro- or nansecond value : var unit = resolution == TimestampResolution.Nanosecond ? 1e-9M : 1e-6M;

This results in a zero tv_usec var tv_usec = (ulong)((Timeval.Value % 1) * unit);

Instead the unit should be 1000000000 or 1000000 var unit = resolution == TimestampResolution.Nanosecond ? 1e9M : 1e6M;

slight miscalculation in order :-)

kayoub5 commented 2 years ago

@Bart-Baekelandt could you make a PR?