Skip to content

Commit e990c14

Browse files
committed
refactor
1 parent 63b31c0 commit e990c14

38 files changed

+98
-115
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/IPcapPal.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,42 +155,42 @@ public interface IPcapPal
155155
/// <summary>
156156
/// Is used to get a list of the supported link-layer header types of the interface associated with the pcap descriptor. pcap_list_datalinks() allocates an array to hold the list and sets *dataLinkList to point to that array.
157157
/// The caller is responsible for freeing the array with pcap_free_datalinks(), which frees the list of link-layer header types pointed to by dataLinkList.
158-
/// It must not be called on a pcap descriptor created by pcap_create(3PCAP) that has not yet been activated by pcap_activate(3PCAP).
158+
/// It must not be called on a pcap descriptor created by pcap_create(3PCAP) that has not yet been activated by pcap_activate(3PCAP).
159159
/// </summary>
160160
/// <param name="dataLinkList">list of link-layer header types supported by a capture device</param>
161161
/// <returns>The number of link-layer header types in the array on success, PCAP_ERROR_NOT_ACTIVATED if called on a capture handle that has been created but not activated, and PCAP_ERROR on other errors. If PCAP_ERROR is returned, pcap_geterr(3PCAP) or pcap_perror(3PCAP) may be called with p as an argument to fetch or display the error text.</returns>
162162
int pcap_list_datalinks(PcapHandle /* pcap_t* */ adaptHandle, ref IntPtr /* int** */ dataLinkList);
163163

164164
/// <summary>
165-
/// Frees the list of link-layer header types pointed to by dataLinkList.
165+
/// Frees the list of link-layer header types pointed to by dataLinkList.
166166
/// </summary>
167167
void pcap_free_datalinks(IntPtr /* int* */ dataLinkList);
168168

169169
/// <summary>
170170
/// Get the link-layer header type value corresponding to a header type name.
171-
/// Translates a link-layer header type name, which is a DLT_ name with the DLT_ removed,
171+
/// Translates a link-layer header type name, which is a DLT_ name with the DLT_ removed,
172172
/// to the corresponding link-layer header type value.The translation is case-insensitive.
173173
/// </summary>
174174
/// <returns>Returns the type value on success and PCAP_ERROR if the name is not a known type name.</returns>
175175
int pcap_datalink_name_to_val(string /*const char* */ name);
176176

177177
/// <summary>
178-
/// Translates a link-layer header type value to the corresponding link-layer header type name,
179-
/// which is the DLT_ name for the link-layer header type value with the DLT_ removed.
180-
/// NULL is returned if the type value does not correspond to a known DLT_ value.
178+
/// Translates a link-layer header type value to the corresponding link-layer header type name,
179+
/// which is the DLT_ name for the link-layer header type value with the DLT_ removed.
180+
/// NULL is returned if the type value does not correspond to a known DLT_ value.
181181
/// </summary>
182182
string /* const char* */ pcap_datalink_val_to_name(int dlt);
183183

184184
/// <summary>
185-
/// Translates a link-layer header type value to a short description of that link-layer header type.
186-
/// NULL is returned if the type value does not correspond to a known DLT_ value.
185+
/// Translates a link-layer header type value to a short description of that link-layer header type.
186+
/// NULL is returned if the type value does not correspond to a known DLT_ value.
187187
/// </summary>
188188
string /* const char* */ pcap_datalink_val_to_description(int dlt);
189189

190190
/// <summary>
191191
/// Translates a link-layer header type value to a short description of that link-layer header type
192-
/// just like pcap_datalink_val_to_description. If the type value does not correspond to a known DLT_ value,
193-
/// the string "DLT n" is returned, where n is the value of the dlt argument.
192+
/// just like pcap_datalink_val_to_description. If the type value does not correspond to a known DLT_ value,
193+
/// the string "DLT n" is returned, where n is the value of the dlt argument.
194194
/// </summary>
195195
string /* const char* */ pcap_datalink_val_to_description_or_dlt(int dlt);
196196

@@ -238,15 +238,15 @@ public interface IPcapPal
238238
int pcap_snapshot(PcapHandle /* pcap_t* */ adapter);
239239

240240
/// <summary>
241-
/// find out whether a 'savefile' has the native byte order
241+
/// find out whether a 'savefile' has the native byte order
242242
/// </summary>
243243
/// <returns>
244244
/// returns true (1) if p refers to a 'savefile' that uses a different byte order than the current system. For a live capture, it always returns false (0). Returns PCAP_ERROR_NOT_ACTIVATED if called on a capture handle that has been created but not activated.
245245
/// </returns>
246246
int pcap_is_swapped(PcapHandle /* pcap_t* */ adapter);
247247

248248
/// <summary>
249-
/// The version number of a 'savefile'
249+
/// The version number of a 'savefile'
250250
/// </summary>
251251
/// <returns>The major number of the file format of the 'savefile'</returns>
252252
/// <remarks>
@@ -256,7 +256,7 @@ public interface IPcapPal
256256
int pcap_major_version(PcapHandle /* pcap_t* */ adapter);
257257

258258
/// <summary>
259-
/// The version number of a 'savefile'
259+
/// The version number of a 'savefile'
260260
/// </summary>
261261
/// <returns>The minor number of the file format of the 'savefile'</returns>
262262
/// <remarks>

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ internal extern static int pcap_findalldevs(
461461
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PcapStringMarshaler))] string /*const char * */fname);
462462

463463
/// <summary>
464-
/// Save a packet to disk.
464+
/// Save a packet to disk.
465465
/// </summary>
466466
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
467467
internal extern static void pcap_dump(IntPtr /*u_char * */user, IntPtr /*const struct pcap_pkthdr * */h, IntPtr /*const u_char * */sp);
@@ -478,7 +478,7 @@ internal extern static int pcap_findalldevs(
478478

479479
/// <summary>
480480
/// Send a raw packet.<br/>
481-
/// This function allows to send a raw packet to the network.
481+
/// This function allows to send a raw packet to the network.
482482
/// The MAC CRC doesn't need to be included, because it is transparently calculated
483483
/// and added by the network interface driver.
484484
/// </summary>
@@ -490,7 +490,7 @@ internal extern static int pcap_findalldevs(
490490
internal extern static int pcap_sendpacket(PcapHandle /* pcap_t* */ adaptHandle, IntPtr data, int size);
491491

492492
/// <summary>
493-
/// Compile a packet filter, converting an high level filtering expression (see Filtering expression syntax) in a program that can be interpreted by the kernel-level filtering engine.
493+
/// Compile a packet filter, converting an high level filtering expression (see Filtering expression syntax) in a program that can be interpreted by the kernel-level filtering engine.
494494
/// </summary>
495495
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
496496
internal extern static int pcap_compile(
@@ -504,7 +504,7 @@ internal extern static int pcap_compile(
504504
internal extern static int pcap_setfilter(PcapHandle /* pcap_t* */ adaptHandle, IntPtr /*bpf_program **/fp);
505505

506506
/// <summary>
507-
/// Returns if a given filter applies to an offline packet.
507+
/// Returns if a given filter applies to an offline packet.
508508
/// </summary>
509509
/// <returns></returns>
510510
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
@@ -532,8 +532,8 @@ internal extern static int pcap_compile(
532532
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
533533
internal extern static IntPtr /*FILE **/ pcap_dump_file(IntPtr /*pcap_dumper_t **/p);
534534

535-
/// <summary>Flushes the output buffer to the 'savefile', so that any packets
536-
/// written with pcap_dump() but not yet written to the 'savefile' will be written.
535+
/// <summary>Flushes the output buffer to the 'savefile', so that any packets
536+
/// written with pcap_dump() but not yet written to the 'savefile' will be written.
537537
/// -1 is returned on error, 0 on success. </summary>
538538
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
539539
internal extern static int pcap_dump_flush(IntPtr /*pcap_dumper_t **/p);
@@ -609,22 +609,22 @@ internal extern static int pcap_getnonblock(
609609

610610
/// <summary>
611611
/// pcap_set_rfmon() sets whether monitor mode should be set on a capture handle when the handle is activated.
612-
/// If rfmon is non-zero, monitor mode will be set, otherwise it will not be set.
612+
/// If rfmon is non-zero, monitor mode will be set, otherwise it will not be set.
613613
/// </summary>
614614
/// <returns>Returns 0 on success or PCAP_ERROR_ACTIVATED if called on a capture handle that has been activated.</returns>
615615
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
616616
internal extern static int pcap_set_rfmon(PcapHandle /* pcap_t* */ p, int rfmon);
617617

618618
/// <summary>
619-
/// pcap_set_snaplen() sets the snapshot length to be used on a capture handle when the handle is activated to snaplen.
619+
/// pcap_set_snaplen() sets the snapshot length to be used on a capture handle when the handle is activated to snaplen.
620620
/// </summary>
621621
/// <returns>Returns 0 on success or PCAP_ERROR_ACTIVATED if called on a capture handle that has been activated.</returns>
622622
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
623623
internal extern static int pcap_set_snaplen(PcapHandle /* pcap_t* */ p, int snaplen);
624624

625625
/// <summary>
626-
/// pcap_set_promisc() sets whether promiscuous mode should be set on a capture handle when the handle is activated.
627-
/// If promisc is non-zero, promiscuous mode will be set, otherwise it will not be set.
626+
/// pcap_set_promisc() sets whether promiscuous mode should be set on a capture handle when the handle is activated.
627+
/// If promisc is non-zero, promiscuous mode will be set, otherwise it will not be set.
628628
/// </summary>
629629
/// <returns>Returns 0 on success or PCAP_ERROR_ACTIVATED if called on a capture handle that has been activated.</returns>
630630
[DllImport(PCAP_DLL, CallingConvention = CallingConvention.Cdecl)]
@@ -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/Native/PcapWindowsPal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public int pcap_sendqueue_transmit(PcapHandle p, ref pcap_send_queue queue, int
435435
}
436436

437437
/// <summary>
438-
/// Per http://msdn.microsoft.com/en-us/ms182161.aspx
438+
/// Per http://msdn.microsoft.com/en-us/ms182161.aspx
439439
/// </summary>
440440
[SuppressUnmanagedCodeSecurity]
441441
private static class SafeNativeMethods

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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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>

0 commit comments

Comments
 (0)