// TODO: Add this test once Dumping to files with Unicode filenames is supported. See http://www.winpcap.org/pipermail/winpcap-users/2011-February/004273.html
pcap_t*pcapDescriptor=pcap_open(source,// name of the device
snapshotLength,// portion of the packet to capture
// 65536 guarantees that the whole packet will be captured on all the link layers
safe_cast<int>(attributes),
readTimeout,// read timeout
auth,// authentication on the remote machine
errorBuffer);// error buffer
if(pcapDescriptor==NULL)
throwgcnewInvalidOperationException(String::Format(CultureInfo::InvariantCulture,"Unable to open the adapter. Adapter name: {0}. Error: {1}",gcnewString(source),gcnewString(errorBuffer)));
// Create the source string according to the new WinPcap syntax
charsource[PCAP_BUF_SIZE];
charerrorBuffer[PCAP_ERRBUF_SIZE];
if(pcap_createsrcstr(source,// variable that will keep the source string
PCAP_SRC_FILE,// we want to open a file
NULL,// remote host
NULL,// port on the remote host
unamangedFilename.c_str(),// name of the file we want to open
errorBuffer// error buffer
)!=0)
{
throwgcnewInvalidOperationException(String::Format(CultureInfo::InvariantCulture,"Error creating a source string from filename {0}. Error: {1}",_fileName,gcnewString(errorBuffer)));
pcap_t*pcapDescriptor=pcap_open(source,// name of the device
snapshotLength,// portion of the packet to capture
// 65536 guarantees that the whole packet will be captured on all the link layers
safe_cast<int>(attributes),
readTimeout,// read timeout
auth,// authentication on the remote machine
errorBuffer);// error buffer
if(pcapDescriptor==NULL)
throwgcnewInvalidOperationException(String::Format(CultureInfo::InvariantCulture,"Unable to open the adapter. Adapter name: {0}. Error: {1}",gcnewString(source),gcnewString(errorBuffer)));
// TODO: Use pcap_dump_fopen() to support Unicode filenames once it's available. See http://www.winpcap.org/pipermail/winpcap-users/2011-February/004273.html