Commit 2bb8f28e authored by Brickner_cp's avatar Brickner_cp

Upgrade to WinPcap 4.1.2.

Added support for PacketCommunicator.SupportedDataLinks property.
Added DOCSIS to DataLinkKind enum.
parent b455dfb5
...@@ -869,10 +869,11 @@ namespace PcapDotNet.Core.Test ...@@ -869,10 +869,11 @@ namespace PcapDotNet.Core.Test
address.ToString()); address.ToString());
} }
} }
PacketCommunicator communicator = device.Open(); PacketCommunicator communicator = device.Open();
try try
{ {
MoreAssert.AreSequenceEqual(new[] {DataLinkKind.Ethernet, DataLinkKind.Docsis}.Select(kind => new PcapDataLink(kind)), communicator.SupportedDataLinks);
PacketTotalStatistics totalStatistics = communicator.TotalStatistics; PacketTotalStatistics totalStatistics = communicator.TotalStatistics;
Assert.AreEqual<object>(totalStatistics, totalStatistics); Assert.AreEqual<object>(totalStatistics, totalStatistics);
Assert.AreNotEqual(null, totalStatistics); Assert.AreNotEqual(null, totalStatistics);
......
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Threading; using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -356,6 +357,7 @@ namespace PcapDotNet.Core.Test ...@@ -356,6 +357,7 @@ namespace PcapDotNet.Core.Test
communicator = device.Open(); communicator = device.Open();
try try
{ {
MoreAssert.AreSequenceEqual(new[] {DataLinkKind.Ethernet}.Select(kind => new PcapDataLink(kind)), communicator.SupportedDataLinks);
Assert.AreEqual(DataLinkKind.Ethernet, communicator.DataLink.Kind); Assert.AreEqual(DataLinkKind.Ethernet, communicator.DataLink.Kind);
Assert.AreEqual("EN10MB (Ethernet)", communicator.DataLink.ToString()); Assert.AreEqual("EN10MB (Ethernet)", communicator.DataLink.ToString());
Assert.AreEqual(communicator.DataLink, new PcapDataLink(communicator.DataLink.Name)); Assert.AreEqual(communicator.DataLink, new PcapDataLink(communicator.DataLink.Name));
......
...@@ -27,9 +27,6 @@ void PacketCommunicator::DataLink::set(PcapDataLink value) ...@@ -27,9 +27,6 @@ void PacketCommunicator::DataLink::set(PcapDataLink value)
ReadOnlyCollection<PcapDataLink>^ PacketCommunicator::SupportedDataLinks::get() ReadOnlyCollection<PcapDataLink>^ PacketCommunicator::SupportedDataLinks::get()
{ {
throw gcnew NotSupportedException("Unsupported property to avoid memory leak");
// pcap_free_datalinks(NULL);
/*
int* dataLinks; int* dataLinks;
int numDatalinks = pcap_list_datalinks(_pcapDescriptor, &dataLinks); int numDatalinks = pcap_list_datalinks(_pcapDescriptor, &dataLinks);
if (numDatalinks == -1) if (numDatalinks == -1)
...@@ -44,11 +41,8 @@ ReadOnlyCollection<PcapDataLink>^ PacketCommunicator::SupportedDataLinks::get() ...@@ -44,11 +41,8 @@ ReadOnlyCollection<PcapDataLink>^ PacketCommunicator::SupportedDataLinks::get()
} }
finally finally
{ {
// This doesn't work because of a bug. See http://www.winpcap.org/pipermail/winpcap-users/2008-May/002500.html pcap_free_datalinks(dataLinks);
// todo look for pcap_free_datalinks()
// free(dataLinks);
} }
*/
} }
int PacketCommunicator::SnapshotLength::get() int PacketCommunicator::SnapshotLength::get()
......
...@@ -36,7 +36,11 @@ DataLinkKind PcapDataLink::Kind::get() ...@@ -36,7 +36,11 @@ DataLinkKind PcapDataLink::Kind::get()
{ {
case 1: case 1:
return DataLinkKind::Ethernet; return DataLinkKind::Ethernet;
default:
case 143:
return DataLinkKind::Docsis;
default:
throw gcnew NotSupportedException(PcapDataLink::typeid->Name + " " + Value.ToString(CultureInfo::InvariantCulture) + " - " + ToString() + " is unsupported"); throw gcnew NotSupportedException(PcapDataLink::typeid->Name + " " + Value.ToString(CultureInfo::InvariantCulture) + " - " + ToString() + " is unsupported");
} }
} }
...@@ -109,7 +113,11 @@ int PcapDataLink::KindToValue(DataLinkKind kind) ...@@ -109,7 +113,11 @@ int PcapDataLink::KindToValue(DataLinkKind kind)
{ {
case DataLinkKind::Ethernet: case DataLinkKind::Ethernet:
return 1; return 1;
default:
case DataLinkKind::Docsis:
return 143;
default:
throw gcnew NotSupportedException(PcapDataLink::typeid->Name + " kind " + kind.ToString() + " is unsupported"); throw gcnew NotSupportedException(PcapDataLink::typeid->Name + " kind " + kind.ToString() + " is unsupported");
} }
} }
...@@ -8,6 +8,11 @@ namespace PcapDotNet.Packets ...@@ -8,6 +8,11 @@ namespace PcapDotNet.Packets
/// <summary> /// <summary>
/// Ethernet data link kind. /// Ethernet data link kind.
/// </summary> /// </summary>
Ethernet Ethernet,
/// <summary>
/// Data Over Cable Service Interface Specification.
/// </summary>
Docsis,
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment