forked from dotpcap/sharppcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARCHITECTURE
67 lines (52 loc) · 2.64 KB
/
ARCHITECTURE
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
SharpPcap Architecture
Chris Morgan <[email protected]>
Questions or comments about this or any other document, code file etc
can be directed to the SharpPcap project website, http://sharppcap.sf.net or to
This document is intended to describe the high level architecture of
the SharpPcap assembly to provide some insight into the namespaces and
class layout of the project and how to use the various classes.
There are four major namespaces in SharpPcap:
SharpPcap
SharpPcap.LibPcap
SharpPcap.WinPcap
SharpPcap.AirPcap
These correspond to the directories:
SharpPcap/
LibPcap/
WinPcap/
AirPcap/
While at the same level, these directories are a hierarchy of functionality
SharpPcap/ - Base level defines, interfaces to capture devices (ICaptureDevie)
and high level classes for retrieving a list of ICaptureDevice entries
LibPcap/ - libpcap functionality, background capture code etc
WinPcap/ - WinPcap functionality. WinPcap adds several extension methods
that aren't present in libpcap. WinPcap adapters are inherited
from LibPcap adapters to add this functionality.
AirPcap/ - AirPcap functionality. AirPcap adapters are inherited from
WinPcap adapters and have additional methods for retrieving
channel frequency, strength, etc that aren't present in
WinPcap or LibPcap adapters
Two usage cases.
1. You want to retrieve a list of all capture devices and maybe for specific
types of capture devices you want to do something custom with them like
adjusting the capture channel for AirPcap adapters
- You should use the CaptureDeviceList and in your code do something like:
var captureDevices = SharpPcap.CaptureDeviceList.Instance;
foreach(var dev in captureDevices)
{
if(dev is SharpPcap.AirPcap.AirPcapDevice)
{
var airPcapDevice = (SharpPcap.AirPcap.AirPcapDevice)dev;
// Now you can use the AirPcap specific additions here
}
...
2. You know you want to get a list of specific devices, say AirPcap adapters, and
you don't want to see the other kinds of adapters
- You can use the technique in #1 and simply ignore the ones that aren't the type you want
or
- You can use the type specific lists such as SharpPcap.AirPcap.AirPcapDeviceList or
SharpPcap.WinPcap.WinPcapDeviceList or SharpPcap.LibPcap.LibPcapDeviceList. These
classes will return adapters of a specific type. Note that because
AirPcap adapters are WinPcap adapters which are LibPcap adapters that LibPcapDeviceList
WILL contain the available AirPcap adapters as those show up as pcap capture devices.