Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PingmanTools/MacAddressVendorLookup
C# MAC address vendor/OUI lookup library
https://github.com/PingmanTools/MacAddressVendorLookup
Last synced: 5 days ago
JSON representation
C# MAC address vendor/OUI lookup library
- Host: GitHub
- URL: https://github.com/PingmanTools/MacAddressVendorLookup
- Owner: PingmanTools
- License: gpl-3.0
- Created: 2016-11-11T00:54:43.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-14T00:02:50.000Z (about 2 months ago)
- Last Synced: 2024-09-16T15:41:38.959Z (about 2 months ago)
- Language: C#
- Homepage:
- Size: 3.79 MB
- Stars: 14
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MAC Address Vendor Lookup
Fast MAC address vendor lookup library. Uses [Wireshark's manufactures database of OUIs](https://www.wireshark.org/tools/oui-lookup.html) (Organizationally Unique Identifier).
Takes a MAC address in the form of .NET's [`System.Net.NetworkInformation.PhysicalAddress`](https://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress(v=vs.110).aspx) and returns a matching `MacVendorInfo` if found.
The `MacAddressVendorLookup` lib has the parsing and matching logic, and the `MacAddressVendorLookup.Vendors` lib contains a compressed form of Wireshark's manuf file (about 565KB) as an embedded resource.
The `VendorFileGenerator` project checks [Wireshark's Github repo](https://github.com/wireshark/wireshark) for udpates to the [manuf file](https://github.com/wireshark/wireshark/blob/master/manuf) and generates the `manuf_bin.zip` file used as the embedded resource in `MacAddressVendorLookup.Vendors`.
# Example
```C#
// Get vendor information for current machine's network interfacesvar vendorInfoProvider = new MacAddressVendorLookup.MacVendorBinaryReader();
using (var resourceStream = MacAddressVendorLookup.Vendors.ManufBinResource.GetStream().Result)
{
vendorInfoProvider.Init(resourceStream).Wait();
}
var addressMatcher = new MacAddressVendorLookup.AddressMatcher(vendorInfoProvider);foreach (var ni in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
{
var vendorInfo = addressMatcher.FindInfo(ni.GetPhysicalAddress());
Console.WriteLine("\nAdapter: " + ni.Description);
var macAddr = BitConverter.ToString(ni.GetPhysicalAddress().GetAddressBytes()).Replace('-', ':');
Console.WriteLine($"\tMAC Address: {macAddr}");
}/* Output on Windows (in Parallels VM):
Adapter: Intel(R) 82574L Gigabit Network Connection
[MacVendorInfo: IdentiferString=00:1C:42, Organization=Parallels, Inc.]
MAC Address: 00:1C:42:B2:84:35
*//* Output on MacOS:
Adapter: en0
[MacVendorInfo: IdentiferString=78:31:C1, Organization=Apple, Inc.]
MAC Address: 78:31:C1:B7:C2:8EAdapter: vnic0
[MacVendorInfo: IdentiferString=00:1C:42, Organization=Parallels, Inc.]
MAC Address: 00:1C:42:00:00:08Adapter: en8
[MacVendorInfo: IdentiferString=48:D7:05, Organization=Apple, Inc.]
MAC Address: 48:D7:05:EA:15:A3
*/```