/
Example1.IfList.cs
43 lines (36 loc) · 1.21 KB
/
Example1.IfList.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: MIT
using System;
using SharpPcap;
namespace Example1
{
/// <summary>
/// Obtaining the device list
/// </summary>
public class Program
{
/// <summary>
/// Obtaining the device list
/// </summary>
public static void Main(string[] args)
{
// Print SharpPcap version
var ver = Pcap.SharpPcapVersion;
Console.WriteLine("SharpPcap {0}, Example1.IfList.cs", ver);
// Retrieve the device list
var devices = CaptureDeviceList.Instance;
// If no devices were found print an error
if (devices.Count < 1)
{
Console.WriteLine("No devices were found on this machine");
return;
}
Console.WriteLine("\nThe following devices are available on this machine:");
Console.WriteLine("----------------------------------------------------\n");
/* Scan the list printing every entry */
foreach (var dev in devices)
Console.WriteLine("{0}\n", dev.ToString());
Console.Write("Hit 'Enter' to exit...");
Console.ReadLine();
}
}
}