Skip to content

Commit 6c430ad

Browse files
committed
refactor
1 parent b8cf2e1 commit 6c430ad

36 files changed

+74
-91
lines changed

PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public LivePacketDeviceTests()
3232
#endif
3333

3434
[Fact]
35-
public void SendAndReceievePacketTest()
35+
public void SendAndReceivePacketTest()
3636
{
3737
const string SourceMac = "11:22:33:44:55:66";
3838
const string DestinationMac = "77:88:99:AA:BB:CC";

PcapDotNet/src/PcapDotNet.Core.Test/OfflinePacketDeviceTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public void SetSamplingMethodOneEveryNTest()
310310
public void SetSamplingMethodFirstAfterIntervalTest()
311311
{
312312
const int NumPackets = 10;
313-
313+
314314
Packet expectedPacket = _random.NextEthernetPacket(100);
315315
using (PacketCommunicator communicator = OpenOfflineDevice(NumPackets, expectedPacket, TimeSpan.FromSeconds(1)))
316316
{
@@ -338,7 +338,7 @@ public void DumpToBadFileTest()
338338
{
339339
Assert.Throws<InvalidOperationException>(() => OpenOfflineDevice(10, _random.NextEthernetPacket(100), TimeSpan.Zero, "??"));
340340
}
341-
341+
342342
[Fact]
343343
public void EmptyNameTest()
344344
{
@@ -404,7 +404,6 @@ public void ReadUnicodeFilenameTest()
404404
Assert.True(File.Exists(ReadUnicodeFilename), string.Format("File {0} doesn't exist", ReadUnicodeFilename));
405405
}
406406

407-
408407
[Fact]
409408
public void ReadNonExistingUnicodeFilenameTest()
410409
{

PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ private static void ComparePacketsToWireshark(IEnumerable<Packet> packets)
452452
{
453453
// Wireshark's preferences file is %APPDATA%\Wireshark\preferences
454454
FileName = Path.Combine(wiresharkDirectory, WiresharkTshark),
455-
Arguments = "-o ip.check_checksum:TRUE " +
455+
Arguments = "-o ip.check_checksum:TRUE " +
456456
"-o ipv6.use_geoip:FALSE " +
457457
"-o udp.check_checksum:TRUE " +
458458
"-o tcp.relative_sequence_numbers:FALSE " +

PcapDotNet/src/PcapDotNet.Core/BerkeleyPacketFilter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Dispose()
7272

7373
/// <summary>
7474
/// Returns if a given filter applies to an offline packet.
75-
/// This method is used to apply a filter to a packet that is currently in memory.
75+
/// This method is used to apply a filter to a packet that is currently in memory.
7676
/// This process does not need to open an adapter; we need just to create the proper filter (by settings parameters like the snapshot length, or the link-layer type) by means of the Pcap.
7777
/// The current API of libpcap does not allow to receive a packet and to filter the packet after it has been received. However, this can be useful in case you want to filter packets in the application, instead of into the receiving process. This function allows you to do the job.
7878
/// </summary>

PcapDotNet/src/PcapDotNet.Core/Native/PcapUnixPal.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ internal extern static int pcap_getnonblock(
699699
internal extern static int pcap_minor_version(PcapHandle /* pcap_t* */ p);
700700

701701
/// <summary>
702-
/// pcap_activate() is used to activate a packet capture handle to look at packets on the network, with the options that were set on the handle being in effect.
702+
/// pcap_activate() is used to activate a packet capture handle to look at packets on the network, with the options that were set on the handle being in effect.
703703
/// </summary>
704704
/// <returns>Returns 0 on success without warnings, a non-zero positive value on success with warnings, and a negative value on error. A non-zero return value indicates what warning or error condition occurred.</returns>
705705
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]

PcapDotNet/src/PcapDotNet.Core/PacketCommunicator/PacketCommunicator.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace PcapDotNet.Core
2020
public delegate void HandleStatistics(PacketSampleStatistics statistics);
2121

2222
/// <summary>
23-
/// Used to receive and send packets accross the network or to read and write packets to a pcap file.
23+
/// Used to receive and send packets across the network or to read and write packets to a pcap file.
2424
/// </summary>
2525
public abstract class PacketCommunicator : IDisposable
2626
{
@@ -34,13 +34,13 @@ protected PacketCommunicator(SocketAddress netmask)
3434
}
3535

3636
/// <summary>
37-
/// Close the files associated with the capture and deallocates resources.
37+
/// Close the files associated with the capture and deallocates resources.
3838
/// </summary>
3939
protected virtual void Dispose(bool disposing)
4040
{
4141
PcapDescriptor.Dispose();
4242
}
43-
43+
4444
/// <inheritdoc/>
4545
public void Dispose()
4646
{
@@ -110,7 +110,7 @@ public ReadOnlyCollection<PcapDataLink> SupportedDataLinks
110110
}
111111

112112
/// <summary>
113-
/// The dimension of the packet portion (in bytes) that is delivered to the application.
113+
/// The dimension of the packet portion (in bytes) that is delivered to the application.
114114
/// </summary>
115115
public int SnapshotLength { get => Interop.Pcap.pcap_snapshot(PcapDescriptor); }
116116

@@ -230,12 +230,12 @@ public void SetKernelMinimumBytesToCopy(int size)
230230

231231
/// <summary>
232232
/// Define a sampling method for packet capture.
233-
/// This function allows applying a sampling method to the packet capture process.
233+
/// This function allows applying a sampling method to the packet capture process.
234234
/// The method will be applied as soon as the capture starts.
235235
/// </summary>
236236
/// <remarks>
237237
/// Warning: Sampling parameters cannot be changed when a capture is active. These parameters must be applied before starting the capture. If they are applied when the capture is in progress, the new settings are ignored.
238-
/// Warning: Sampling works only when capturing data on Win32 or reading from a file. It has not been implemented on other platforms. Sampling works on remote machines provided that the probe (i.e. the capturing device) is a Win32 workstation.
238+
/// Warning: Sampling works only when capturing data on Win32 or reading from a file. It has not been implemented on other platforms. Sampling works on remote machines provided that the probe (i.e. the capturing device) is a Win32 workstation.
239239
/// </remarks>
240240
/// <param name="method">The sampling method to be applied</param>
241241
public void SetSamplingMethod(SamplingMethod method)
@@ -290,7 +290,7 @@ public PacketCommunicatorReceiveResult ReceivePacket(out Packet packet)
290290

291291
/// <summary>
292292
/// Collect a group of packets.
293-
/// Used to collect and process packets.
293+
/// Used to collect and process packets.
294294
/// <seealso cref="ReceivePacket"/>
295295
/// <seealso cref="ReceivePackets"/>
296296
/// <seealso cref="Break"/>

PcapDotNet/src/PcapDotNet.Core/PacketCommunicator/SamplingMethod.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22

33
namespace PcapDotNet.Core
44
{
@@ -31,7 +31,7 @@ public abstract class SamplingMethod
3131
public const int PCAP_SAMP_FIRST_AFTER_N_MS = 2;
3232

3333
internal abstract int Method { get; }
34-
34+
3535
internal abstract int Value { get; }
3636
}
3737

@@ -40,7 +40,7 @@ public abstract class SamplingMethod
4040
/// In other words, if the interval is set to 10 milliseconds, the first packet is returned to the caller; the next returned one will be the first packet that arrives when 10ms have elapsed.
4141
/// </summary>
4242
public sealed class SamplingMethodFirstAfterInterval : SamplingMethod
43-
{
43+
{
4444
private readonly int _intervalInMilliseconds;
4545

4646
/// <summary>
@@ -82,7 +82,7 @@ public SamplingMethodFirstAfterInterval(TimeSpan interval)
8282

8383
/// <summary>
8484
/// No sampling has to be done on the current capture.
85-
/// In this case, no sampling algorithms are applied to the current capture.
85+
/// In this case, no sampling algorithms are applied to the current capture.
8686
/// </summary>
8787
public sealed class SamplingMethodNone : SamplingMethod
8888
{

PcapDotNet/src/PcapDotNet.Core/PacketDevice/LivePacketDevice.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class LivePacketDevice : PacketDevice
2222
/// </returns>
2323
/// <exception cref="InvalidOperationException">
2424
/// Thrown if some errors occurred.
25-
/// An error could be due to several reasons:
25+
/// An error could be due to several reasons:
2626
/// <list type="bullet">
2727
/// <item>libpcap/WinPcap was not installed on the local/remote host.</item>
2828
/// <item>The user does not have enough privileges to list the devices.</item>

PcapDotNet/src/PcapDotNet.Core/PacketDevice/OfflinePacketDevice.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace PcapDotNet.Core
1111
public sealed class OfflinePacketDevice : PacketDevice
1212
{
1313
private readonly string _fileName;
14-
14+
1515
/// <summary>
1616
/// Creates a device object from a pcap file.
1717
/// The device can opened to read packets from.
@@ -39,7 +39,7 @@ public override string Description
3939
}
4040

4141
/// <summary>
42-
/// Interface flags. Currently the only possible flag is Loopback, that is set if the interface is a loopback interface.
42+
/// Interface flags. Currently the only possible flag is Loopback, that is set if the interface is a loopback interface.
4343
/// </summary>
4444
public override DeviceAttributes Attributes
4545
{
@@ -55,7 +55,7 @@ public override ReadOnlyCollection<DeviceAddress> Addresses
5555
}
5656

5757
/// <summary>
58-
/// Open a generic source in order to capture / send (WinPcap only) traffic.
58+
/// Open a generic source in order to capture / send (WinPcap only) traffic.
5959
/// </summary>
6060
/// <param name="snapshotLength">length of the packet that has to be retained. For each packet received by the filter, only the first 'snapshotLength' bytes are stored in the buffer and passed to the user application. For instance, snaplen equal to 100 means that only the first 100 bytes of each packet are stored.</param>
6161
/// <param name="attributes">Keeps several flags that can be needed for capturing packets.</param>
@@ -65,5 +65,5 @@ public override PacketCommunicator Open(int snapshotLength, PacketDeviceOpenAttr
6565
{
6666
return new OfflinePacketCommunicator(_fileName);
6767
}
68-
};
68+
}
6969
}

PcapDotNet/src/PcapDotNet.Core/PacketDevice/PacketDevice.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected PacketDevice() { }
1313
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
1414

1515
/// <summary>
16-
/// This snapshort length value should be sufficient, on most if not all networks, to capture all the data available from the packet.
16+
/// This snapshot length value should be sufficient, on most if not all networks, to capture all the data available from the packet.
1717
/// </summary>
1818
public const int DefaultSnapshotLength = 65536;
1919

@@ -28,7 +28,7 @@ protected PacketDevice() { }
2828
public abstract string Description { get; }
2929

3030
/// <summary>
31-
/// Interface flags. Currently the only possible flag is Loopback, that is set if the interface is a loopback interface.
31+
/// Interface flags. Currently the only possible flag is Loopback, that is set if the interface is a loopback interface.
3232
/// </summary>
3333
public abstract DeviceAttributes Attributes { get; }
3434

@@ -47,8 +47,8 @@ protected PacketDevice() { }
4747
public abstract PacketCommunicator Open(int snapshotLength, PacketDeviceOpenAttributes attributes, int readTimeout);
4848

4949
/// <summary>
50-
/// Open a generic source in order to capture / send (WinPcap only) traffic.
51-
/// Uses maxmimum snapshotLength (65536), promiscuous mode and 1 second read timeout.
50+
/// Open a generic source in order to capture / send (WinPcap only) traffic.
51+
/// Uses maximum snapshotLength (65536), promiscuous mode and 1 second read timeout.
5252
/// </summary>
5353
public virtual PacketCommunicator Open()
5454
{

PcapDotNet/src/PcapDotNet.Core/PacketSendBuffer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void Enqueue(Packet packet)
4444
{
4545
throw new ArgumentNullException(nameof(packet));
4646
}
47-
47+
4848
var hdrSize = Interop.Pcap.PcapHeaderSize;
4949
if (hdrSize + packet.Length > _buffer.Length - _currentBufferPosition)
5050
{

PcapDotNet/src/PcapDotNet.Core/PacketTotalStatistics.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace PcapDotNet.Core
77
{
88
/// <summary>
9-
/// Statistics on capture from the start of the run.
9+
/// Statistics on capture from the start of the run.
1010
/// </summary>
1111
public sealed class PacketTotalStatistics : IEquatable<PacketTotalStatistics>
1212
{

PcapDotNet/src/PcapDotNet.Core/PcapDataLink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public override string ToString()
140140
{
141141
return Name + " (" + Description + ")";
142142
}
143-
143+
144144
/// <inheritdoc/>
145145
public bool Equals(PcapDataLink other)
146146
{

PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void DnsDomainNameCompressionTest()
8686
{
8787
DnsLayer dnsLayer = new DnsLayer();
8888
TestDomainNameCompression(0, dnsLayer);
89-
89+
9090
dnsLayer.Queries = new List<DnsQueryResourceRecord>();
9191
dnsLayer.Answers = new List<DnsDataResourceRecord>();
9292
dnsLayer.Authorities = new List<DnsDataResourceRecord>();
@@ -181,7 +181,7 @@ public void DnsOptResourceRecordTest()
181181
DnsResourceDataOptions data = (DnsResourceDataOptions)random.NextDnsResourceData(DnsType.Opt);
182182

183183
DnsOptResourceRecord record = new DnsOptResourceRecord(domainName, sendersUdpPayloadSize, extendedRcode, version, flags, data);
184-
184+
185185
Assert.Equal(domainName, record.DomainName);
186186
Assert.Equal(sendersUdpPayloadSize, record.SendersUdpPayloadSize);
187187
Assert.Equal(extendedRcode, record.ExtendedReturnCode);
@@ -723,7 +723,7 @@ public void DnsResourceDataDelegationSignerConstructorNullDigestTest()
723723
{
724724
Assert.Throws<ArgumentNullException>(() => new DnsResourceDataDelegationSigner(1, DnsAlgorithm.PrivateDns, DnsDigestType.Sha1, null));
725725
}
726-
726+
727727
[Fact]
728728
public void DnsResourceDataDomainNameParseWrongLengthTest()
729729
{

PcapDotNet/src/PcapDotNet.Packets/ByteArrayExtensions.cs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4-
using System.Linq;
54
using System.Net;
65
using System.Numerics;
76
using System.Text;
@@ -141,7 +140,7 @@ public static void BlockCopy(this byte[] source, int sourceOffset, byte[] destin
141140
/// <returns>The value read from the buffer.</returns>
142141
public static byte ReadByte(this byte[] buffer, int offset)
143142
{
144-
if (buffer == null)
143+
if (buffer == null)
145144
throw new ArgumentNullException("buffer");
146145
return buffer[offset];
147146
}
@@ -387,7 +386,7 @@ public static UInt128 ReadUInt128(this byte[] buffer, int offset, Endianity endi
387386
/// <returns>The value converted from the read bytes according to the endianity.</returns>
388387
public static BigInteger ReadUnsignedBigInteger(this byte[] buffer, int offset, int length, Endianity endianity)
389388
{
390-
if (buffer == null)
389+
if (buffer == null)
391390
throw new ArgumentNullException("buffer");
392391

393392
BigInteger value = BigInteger.Zero;
@@ -494,7 +493,7 @@ public static IpV6Address ReadIpV6Address(this byte[] buffer, int offset, Endian
494493
/// <param name="value">The value to write.</param>
495494
public static void Write(this byte[] buffer, int offset, byte value)
496495
{
497-
if (buffer == null)
496+
if (buffer == null)
498497
throw new ArgumentNullException("buffer");
499498

500499
buffer[offset] = value;
@@ -520,9 +519,9 @@ public static void Write(this byte[] buffer, ref int offset, byte value)
520519
/// <param name="value">The value to write.</param>
521520
public static void Write(this byte[] buffer, ref int offset, IEnumerable<byte> value)
522521
{
523-
if (buffer == null)
522+
if (buffer == null)
524523
throw new ArgumentNullException("buffer");
525-
if (value == null)
524+
if (value == null)
526525
throw new ArgumentNullException("value");
527526

528527
foreach (byte b in value)
@@ -751,9 +750,9 @@ public static void Write(this byte[] buffer, ref int offset, UInt128 value, Endi
751750
/// <param name="endianity">The endianity to use when converting the value to bytes.</param>
752751
public static void WriteUnsigned(this byte[] buffer, int offset, BigInteger value, int length, Endianity endianity)
753752
{
754-
if (buffer == null)
753+
if (buffer == null)
755754
throw new ArgumentNullException("buffer");
756-
755+
757756
if (value.Sign < 0)
758757
throw new ArgumentOutOfRangeException("value", value, "Must be non-negative.");
759758
for (int i = 0; i != length && value != BigInteger.Zero; ++i, value >>= 8)
@@ -801,7 +800,7 @@ public static void Write(this byte[] buffer, int offset, DataSegment value)
801800
/// <param name="value">The value to write.</param>
802801
public static void Write(this byte[] buffer, ref int offset, DataSegment value)
803802
{
804-
if (value == null)
803+
if (value == null)
805804
throw new ArgumentNullException("value");
806805

807806
value.Write(buffer, offset);
@@ -967,7 +966,7 @@ private static UInt48 HostToNetworkOrder(UInt48 value)
967966
{
968967
UInt48* resultPtr = &result;
969968
byte* resultBytePtr = (byte*)resultPtr;
970-
969+
971970
UInt48* valuePtr = &value;
972971
byte* valueBytePtr = (byte*)valuePtr;
973972

@@ -1088,7 +1087,7 @@ private static void Write(byte[] buffer, int offset, UInt24 value)
10881087
}
10891088
}
10901089
}
1091-
1090+
10921091
private static void Write(byte[] buffer, int offset, int value)
10931092
{
10941093
unsafe

PcapDotNet/src/PcapDotNet.Packets/DataSegment.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Generic;
44
using System.Globalization;
55
using System.IO;
6-
using System.Linq;
76
using System.Numerics;
87
using System.Text;
98
using PcapDotNet.Base;

PcapDotNet/src/PcapDotNet.Packets/Dns/ResourceData/DnsResourceData.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Numerics;
65
using System.Reflection;
7-
using PcapDotNet.Base;
86

97
namespace PcapDotNet.Packets.Dns
108
{
@@ -14,7 +12,7 @@ namespace PcapDotNet.Packets.Dns
1412
/// </summary>
1513
public abstract class DnsResourceData
1614
{
17-
internal const int StringMinimumLength = sizeof(byte);
15+
internal const int StringMinimumLength = sizeof(byte);
1816

1917
/// <summary>
2018
/// Returns the DnsResourceData concrete type that should be created for the given DnsType.

0 commit comments

Comments
 (0)