Updated sample programs to read the configuration from c:\snf\snf_engine.xml.master
const string LicenseID = "licensid"; // SNF License ID can be passed | const string LicenseID = "licensid"; // SNF License ID can be passed | ||||
const string Authentication = "authenticationxx"; // directly or read from the | const string Authentication = "authenticationxx"; // directly or read from the | ||||
const string ConfigurationPath = "c:\\Program Files\\SNF\\snf_engine.xml"; // configuration. OEMs go direct! | |||||
const string ConfigurationPath = "c:\\SNF\\snf_engine.xml"; // configuration. OEMs go direct! | |||||
const unsigned int IPToTest = 0x0c22384e; // Same as IP 12.34.56.78 | const unsigned int IPToTest = 0x0c22384e; // Same as IP 12.34.56.78 | ||||
<p><font face="sans-serif">Introduction</font></p> | <p><font face="sans-serif">Introduction</font></p> | ||||
<li><font face="sans-serif"><a href="#Begin">Before you begin!</a></font></li> | <li><font face="sans-serif"><a href="#Begin">Before you begin!</a></font></li> | ||||
<li><font face="sans-serif"><a href="#Contents">Contents of the SDK</a></font></li> | <li><font face="sans-serif"><a href="#Contents">Contents of the SDK</a></font></li> | ||||
<li><font face="sans-serif"><a href="#SuggestedInstallation">Suggested Installation</a></font></li> | |||||
<li><font face="sans-serif"><a href="#RunningSamples">Running the Sample Programs</a></font></li> | <li><font face="sans-serif"><a href="#RunningSamples">Running the Sample Programs</a></font></li> | ||||
<li><font face="sans-serif"><a href="#Description">SNFMulti DLL Description</a></font></li> | <li><font face="sans-serif"><a href="#Description">SNFMulti DLL Description</a></font></li> | ||||
<li><font face="sans-serif"><a href="ChangeLog.txt">Change Log</a></font></li> | <li><font face="sans-serif"><a href="ChangeLog.txt">Change Log</a></font></li> | ||||
directory <b>VS2019CPPSample</b>), in C# | directory <b>VS2019CPPSample</b>), in C# | ||||
(<b>VS2019CSSample</b>), and Visual Basic | (<b>VS2019CSSample</b>), and Visual Basic | ||||
(<b>VS2019VBSample</b>).<br> | (<b>VS2019VBSample</b>).<br> | ||||
The <b>VS2019CPPSample\README</b> contains instructions for | |||||
creating the SNFMulti import libraries for use with VS 2019. | |||||
<a href="VS2019CPPSample/README">VS2019CPPSample/README</a> | |||||
contains instructions for creating the SNFMulti import | |||||
libraries for use with VS 2019. | |||||
</font></li> | </font></li> | ||||
<li><font face="sans-serif">Other applications | <li><font face="sans-serif">Other applications | ||||
(<b>curl</b>, <b>SNFClient</b>, and <b>getRulebase</b>) and | (<b>curl</b>, <b>SNFClient</b>, and <b>getRulebase</b>) and | ||||
operation.</font></li> | operation.</font></li> | ||||
</ol> | </ol> | ||||
There are also directions for building VS 2019 import and export | There are also directions for building VS 2019 import and export | ||||
libraries in <b>VS2019CPPSample\README</b>. | |||||
libraries | |||||
in <a href="VS2019CPPSample/README">VS2019CPPSample/README</a>. | |||||
</p> | </p> | ||||
<hr/> | <hr/> | ||||
<li><font face="sans-serif"> | <li><font face="sans-serif"> | ||||
<b>identity.xml</b> | <b>identity.xml</b> | ||||
</font></li> | </font></li> | ||||
<li><font face="sans-serif"> | |||||
<b>GBUdbIgnoreList.txt</b> | |||||
</font></li> | |||||
<li><font face="sans-serif"> | |||||
<b>getRulebase.cmd</b> | |||||
</font></li> | |||||
<li><font face="sans-serif"> | |||||
<b>curl.exe</b> | |||||
</font></li> | |||||
<li><font face="sans-serif"> | |||||
<b>SNF2Check.exe</b> | |||||
</font></li> | |||||
<li><font face="sans-serif"> | <li><font face="sans-serif"> | ||||
<b>testmode.snf</b> | <b>testmode.snf</b> | ||||
</font></li> | </font></li> | ||||
<p>Since the DLL contains the entire SNFServer engine, it can (and must) be configured in | <p>Since the DLL contains the entire SNFServer engine, it can (and must) be configured in | ||||
exactly the same way as SNFServer. <a href="http://www.armresearch.com/support/articles/software/snfServer/config/index.jsp"> | exactly the same way as SNFServer. <a href="http://www.armresearch.com/support/articles/software/snfServer/config/index.jsp"> | ||||
Documentation for configuring SNFServer can be found on our web site.</a></p> | Documentation for configuring SNFServer can be found on our web site.</a></p> | ||||
<p>New in snfmulti.dll V3.4!</p> | |||||
<p>The SNF engine has been updated to remove theSaccades algorithm, | |||||
and to use the SNFMulti 3.2.2 and latest CodeDweller libraries. | |||||
</p> | |||||
<p>New in snfmulti.dll V3.0!</p> | <p>New in snfmulti.dll V3.0!</p> | ||||
<p>OEM developers can now protect their licenseID and Authentication string by providing it directly to the SNF engine at run-time. When combined with an internal mechanism for downloading rule base files this makes it practical to control SNF license information entirely within the OEM's application. <a href="#startupSNFAuthenticated">See startupSNFAuthenticated() for details.</a></p> | <p>OEM developers can now protect their licenseID and Authentication string by providing it directly to the SNF engine at run-time. When combined with an internal mechanism for downloading rule base files this makes it practical to control SNF license information entirely within the OEM's application. <a href="#startupSNFAuthenticated">See startupSNFAuthenticated() for details.</a></p> | ||||
REM ----- Edit This Section -------- | REM ----- Edit This Section -------- | ||||
SET SNIFFER_PATH=c:\SNF | SET SNIFFER_PATH=c:\SNF | ||||
SET AUTHENTICATION=authenticationxx | |||||
SET LICENSE_ID=licensid | |||||
SET AUTHENTICATION=setuptestingonly | |||||
SET LICENSE_ID=testmode | |||||
REM -------------------------------- | REM -------------------------------- | ||||
2) Select "x64" (if available) or "x86" for the platform. | 2) Select "x64" (if available) or "x86" for the platform. | ||||
3) In the project, open main.cpp. Modify the initial value of | |||||
ConfigurationPath as necessary to specify the location of the | |||||
SNFServer configuration file. | |||||
3) In the project, open main.cpp. Verify that the value of | |||||
ConfigurationPath is the path for the snf_enging.xml Sniffer | |||||
configuration file. | |||||
4) Build. | 4) Build. | ||||
README file for the VS 2019 C# sample project | |||||
Copyright (c) 2010, 2020 ARM Research Laboratories | |||||
This README file gives an overview of the VS 2019 C# sample project. | |||||
This project links the sample C# file CSSample\main.cs with the | |||||
SNFMulti DLL library. | |||||
To build this application: | |||||
1) Open VS2019CSSample\VS2019CSSample.sln with VS 2019. | |||||
2) Select "Any CPU", "x64" or "x86" for the platform. | |||||
3) In the project, open main.cs. | |||||
4) Modify the value of SNFMULTI_DLL to be the path to SNFMulti.dll. | |||||
The path depends on the platform. | |||||
5) Modify the initial value of ConfigurationPath as necessary to | |||||
specify the location of the SNFServer configuration file. | |||||
6) Build. | |||||
7) Run. | |||||
README file for the VS 2019 C# sample project | |||||
Copyright (c) 2010, 2020 ARM Research Laboratories | |||||
This README file gives an overview of the VS 2019 C# sample project. | |||||
This project links the sample C# file CSSample\main.cs with the | |||||
SNFMulti DLL library. | |||||
To build this application: | |||||
1) Open VS2019CSSample\VS2019CSSample.sln with VS 2019. | |||||
2) Select "Any CPU", "x64" or "x86" for the platform. | |||||
3) In the project, open main.cs. | |||||
4) Modify the value of SNFMULTI_DLL to be the path to SNFMulti.dll. | |||||
The path depends on the platform. | |||||
5) Verify that the value of ConfigurationPath is the path for the | |||||
snf_enging.xml Sniffer configuration file. | |||||
6) Build. | |||||
7) Run. |
// main.cs SNF-SDK-WIN C# OEM Demonstration Code | |||||
// Copyright (C) 2009 ARM Research Labs, LLC | |||||
// | |||||
// This app simply exercises the API provided by snfmultidll. | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.IO; | |||||
using System.Collections; | |||||
using System.Runtime.InteropServices; | |||||
namespace SNFMultiDLLExampleCsharp | |||||
{ | |||||
class SNFMultiDLLExample | |||||
{ | |||||
#region DLL Imports | |||||
// Location of SNFMulti.dll. | |||||
//const string SNFMULTI_DLL = "..\\..\\..\\64bitDll\\SNFMulti.dll"; // Set CPU type to "Any CPU" | |||||
//const string SNFMULTI_DLL = "..\\..\\..\\..\\64bitDll\\SNFMulti.dll"; // Set CPU type to "x64 | |||||
const string SNFMULTI_DLL = "..\\..\\..\\32bitDll\\SNFMulti.dll"; // Set CPU type to "x86" | |||||
// int setThrottle(int Threads); /* Set scan thread limit. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "setThrottle", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int setThrottle(int throttle); | |||||
// int startupSNF(char* Path); /* Start SNF with configuration. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "startupSNF", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int startupSNF([MarshalAs(UnmanagedType.LPStr)] string Path); | |||||
// EXP int startupSNFAuthenticated(char* Path, char* Lic, char* Auth); /* Start SNF with conf & auth. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "startupSNFAuthenticated", | |||||
CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int startupSNFAuthenticated( | |||||
[MarshalAs(UnmanagedType.LPStr)] string Path, | |||||
[MarshalAs(UnmanagedType.LPStr)] string Lic, | |||||
[MarshalAs(UnmanagedType.LPStr)] string Auth); | |||||
// int shutdownSNF(); /* Shutdown SNF. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "shutdownSNF", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int shutdownSNF(); | |||||
// int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "testIP", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int testIP(ulong IPToCheck); | |||||
// double getIPReputation(unsigned long int IPToCheck); /* Get reputation figure for IP. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getIPReputation", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern double getIPReputation(ulong IPToCheck); | |||||
// int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup);/* Scan msgBuffer, name, setup time. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "scanBuffer", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int scanBuffer( | |||||
[MarshalAs(UnmanagedType.LPStr)] string Bfr, | |||||
int Length, | |||||
[MarshalAs(UnmanagedType.LPStr)] string Name, | |||||
int Setup); | |||||
// int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "scanFile", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int scanFile([MarshalAs(UnmanagedType.LPStr)] string Path, int Setup); | |||||
// int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result & XHeaders. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanXHeaders", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanXHeaders(int ScanHandle, | |||||
out IntPtr Bfr, | |||||
out int Length); | |||||
// int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result & XML Log. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanXMLLog", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanXMLLog(int ScanHandle, | |||||
out IntPtr Bfr, | |||||
out int Length); | |||||
// int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result & Classic Log. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanClassicLog", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanClassicLog(int ScanHandle, | |||||
out IntPtr Bfr, | |||||
out int Length); | |||||
// int getScanResult(int ScanHandle); /* Get just the scan result. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanResult", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanResult(int ScanHandle); | |||||
// int closeScan(int ScanHandle); /* Close the scan result. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "closeScan", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int closeScan(int ScanHandle); | |||||
#endregion | |||||
static void Main(string[] args) | |||||
{ | |||||
//// Setup the basics we need to run this test. | |||||
// const string LicenseID = "licensid"; // SNF License ID can be passed | |||||
// const string Authentication = "authenticationxx"; // directly or read from the | |||||
// configuration. OEMs go direct! | |||||
const string ConfigurationPath = "c:\\Program Files\\SNF\\snf_engine.xml"; | |||||
const uint IPToTest = 0x0c22384e; // Same as IP 12.34.56.78 | |||||
const string SampleMessage = | |||||
"Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n" + | |||||
" by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n" + | |||||
"From: <somebody@example.com>\r\n" + | |||||
"To: <nobody@example.com>\r\n" + | |||||
"Subject: Nothing to see here\r\n" + | |||||
"\r\n" + | |||||
"So this is the big thing that's not here to see.\r\n" + | |||||
"I thought it would be more interesting than this.\r\n" + | |||||
"\r\n" + | |||||
"_M\r\n" + | |||||
".\r\n"; | |||||
//// Here is a simple example. Startup, exercise the API, shut down. | |||||
//// Note that we're doing this in a very "C" style becuase the DLL API is C | |||||
int Result = 0; | |||||
Result = startupSNF(ConfigurationPath); | |||||
//Result = startupSNFAuthenticated( | |||||
// ConfigurationPath, | |||||
// LicenseID, | |||||
// Authentication); | |||||
System.Console.WriteLine("Started with config " + ConfigurationPath + " Result: " + Result); | |||||
// IP tests can be done asynchrounously - they do not have to be part of any particular scan. | |||||
Result = testIP(IPToTest); | |||||
System.Console.WriteLine("IP test result: " + Result); | |||||
double IPReputation = getIPReputation(IPToTest); | |||||
System.Console.WriteLine("IP Reputation: " + IPReputation); | |||||
// Messgae scans happen in a scan, read, close cycle as shown inside this loop. | |||||
const int NumberOfScans = 10; | |||||
for(int i = 0; i < NumberOfScans; i++) { | |||||
// Show how the IP reputation changes over time. | |||||
IPReputation = getIPReputation(IPToTest); | |||||
System.Console.WriteLine("IP Reputation: " + IPReputation); | |||||
// Scan a message from a buffer. | |||||
int SetupTime = 12; | |||||
int ScanHandle = 0; | |||||
ScanHandle = scanBuffer(SampleMessage, SampleMessage.Length, "TestMessage", SetupTime); | |||||
System.Console.WriteLine("Scan Handle: " + ScanHandle); | |||||
// Retrieve the X-Headers for the scan. | |||||
IntPtr XHeadersPtr = IntPtr.Zero; | |||||
int XHeadersLength = 0; | |||||
int ScanResult = 0; | |||||
ScanResult = getScanXHeaders(ScanHandle, out XHeadersPtr, out XHeadersLength); | |||||
string XHeaders; | |||||
XHeaders = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(XHeadersPtr, XHeadersLength); | |||||
// Close the scan. | |||||
Result = closeScan(ScanHandle); | |||||
System.Console.WriteLine("Scan Close Result: " + Result); | |||||
// X- headers were captured in a string BEFORE closing the scan so we can | |||||
// use them here. | |||||
System.Console.WriteLine("Scan result code: " + ScanResult); | |||||
System.Console.WriteLine("Scan X- headers: " + XHeaders); | |||||
} | |||||
// Now that all scanning is done we shut down. | |||||
Result = shutdownSNF(); | |||||
} | |||||
} | |||||
} | |||||
// main.cs SNF-SDK-WIN C# OEM Demonstration Code | |||||
// Copyright (C) 2009 ARM Research Labs, LLC | |||||
// | |||||
// This app simply exercises the API provided by snfmultidll. | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.IO; | |||||
using System.Collections; | |||||
using System.Runtime.InteropServices; | |||||
namespace SNFMultiDLLExampleCsharp | |||||
{ | |||||
class SNFMultiDLLExample | |||||
{ | |||||
#region DLL Imports | |||||
// Location of SNFMulti.dll. | |||||
//const string SNFMULTI_DLL = "..\\..\\..\\64bitDll\\SNFMulti.dll"; // Set CPU type to "Any CPU" | |||||
//const string SNFMULTI_DLL = "..\\..\\..\\..\\64bitDll\\SNFMulti.dll"; // Set CPU type to "x64 | |||||
const string SNFMULTI_DLL = "..\\..\\..\\32bitDll\\SNFMulti.dll"; // Set CPU type to "x86" | |||||
// int setThrottle(int Threads); /* Set scan thread limit. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "setThrottle", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int setThrottle(int throttle); | |||||
// int startupSNF(char* Path); /* Start SNF with configuration. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "startupSNF", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int startupSNF([MarshalAs(UnmanagedType.LPStr)] string Path); | |||||
// EXP int startupSNFAuthenticated(char* Path, char* Lic, char* Auth); /* Start SNF with conf & auth. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "startupSNFAuthenticated", | |||||
CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int startupSNFAuthenticated( | |||||
[MarshalAs(UnmanagedType.LPStr)] string Path, | |||||
[MarshalAs(UnmanagedType.LPStr)] string Lic, | |||||
[MarshalAs(UnmanagedType.LPStr)] string Auth); | |||||
// int shutdownSNF(); /* Shutdown SNF. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "shutdownSNF", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int shutdownSNF(); | |||||
// int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "testIP", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int testIP(ulong IPToCheck); | |||||
// double getIPReputation(unsigned long int IPToCheck); /* Get reputation figure for IP. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getIPReputation", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern double getIPReputation(ulong IPToCheck); | |||||
// int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup);/* Scan msgBuffer, name, setup time. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "scanBuffer", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int scanBuffer( | |||||
[MarshalAs(UnmanagedType.LPStr)] string Bfr, | |||||
int Length, | |||||
[MarshalAs(UnmanagedType.LPStr)] string Name, | |||||
int Setup); | |||||
// int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "scanFile", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int scanFile([MarshalAs(UnmanagedType.LPStr)] string Path, int Setup); | |||||
// int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result & XHeaders. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanXHeaders", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanXHeaders(int ScanHandle, | |||||
out IntPtr Bfr, | |||||
out int Length); | |||||
// int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result & XML Log. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanXMLLog", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanXMLLog(int ScanHandle, | |||||
out IntPtr Bfr, | |||||
out int Length); | |||||
// int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result & Classic Log. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanClassicLog", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanClassicLog(int ScanHandle, | |||||
out IntPtr Bfr, | |||||
out int Length); | |||||
// int getScanResult(int ScanHandle); /* Get just the scan result. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "getScanResult", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int getScanResult(int ScanHandle); | |||||
// int closeScan(int ScanHandle); /* Close the scan result. */ | |||||
[DllImport(SNFMULTI_DLL, CharSet = CharSet.Auto, EntryPoint = "closeScan", CallingConvention = CallingConvention.Winapi)] | |||||
public static extern int closeScan(int ScanHandle); | |||||
#endregion | |||||
static void Main(string[] args) | |||||
{ | |||||
//// Setup the basics we need to run this test. | |||||
// const string LicenseID = "licensid"; // SNF License ID can be passed | |||||
// const string Authentication = "authenticationxx"; // directly or read from the | |||||
// configuration. OEMs go direct! | |||||
const string ConfigurationPath = "c:\\SNF\\snf_engine.xml"; | |||||
const uint IPToTest = 0x0c22384e; // Same as IP 12.34.56.78 | |||||
const string SampleMessage = | |||||
"Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n" + | |||||
" by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n" + | |||||
"From: <somebody@example.com>\r\n" + | |||||
"To: <nobody@example.com>\r\n" + | |||||
"Subject: Nothing to see here\r\n" + | |||||
"\r\n" + | |||||
"So this is the big thing that's not here to see.\r\n" + | |||||
"I thought it would be more interesting than this.\r\n" + | |||||
"\r\n" + | |||||
"_M\r\n" + | |||||
".\r\n"; | |||||
//// Here is a simple example. Startup, exercise the API, shut down. | |||||
//// Note that we're doing this in a very "C" style becuase the DLL API is C | |||||
int Result = 0; | |||||
Result = startupSNF(ConfigurationPath); | |||||
//Result = startupSNFAuthenticated( | |||||
// ConfigurationPath, | |||||
// LicenseID, | |||||
// Authentication); | |||||
System.Console.WriteLine("Started with config " + ConfigurationPath + " Result: " + Result); | |||||
// IP tests can be done asynchrounously - they do not have to be part of any particular scan. | |||||
Result = testIP(IPToTest); | |||||
System.Console.WriteLine("IP test result: " + Result); | |||||
double IPReputation = getIPReputation(IPToTest); | |||||
System.Console.WriteLine("IP Reputation: " + IPReputation); | |||||
// Messgae scans happen in a scan, read, close cycle as shown inside this loop. | |||||
const int NumberOfScans = 10; | |||||
for(int i = 0; i < NumberOfScans; i++) { | |||||
// Show how the IP reputation changes over time. | |||||
IPReputation = getIPReputation(IPToTest); | |||||
System.Console.WriteLine("IP Reputation: " + IPReputation); | |||||
// Scan a message from a buffer. | |||||
int SetupTime = 12; | |||||
int ScanHandle = 0; | |||||
ScanHandle = scanBuffer(SampleMessage, SampleMessage.Length, "TestMessage", SetupTime); | |||||
System.Console.WriteLine("Scan Handle: " + ScanHandle); | |||||
// Retrieve the X-Headers for the scan. | |||||
IntPtr XHeadersPtr = IntPtr.Zero; | |||||
int XHeadersLength = 0; | |||||
int ScanResult = 0; | |||||
ScanResult = getScanXHeaders(ScanHandle, out XHeadersPtr, out XHeadersLength); | |||||
string XHeaders; | |||||
XHeaders = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(XHeadersPtr, XHeadersLength); | |||||
// Close the scan. | |||||
Result = closeScan(ScanHandle); | |||||
System.Console.WriteLine("Scan Close Result: " + Result); | |||||
// X- headers were captured in a string BEFORE closing the scan so we can | |||||
// use them here. | |||||
System.Console.WriteLine("Scan result code: " + ScanResult); | |||||
System.Console.WriteLine("Scan X- headers: " + XHeaders); | |||||
} | |||||
// Now that all scanning is done we shut down. | |||||
Result = shutdownSNF(); | |||||
} | |||||
} | |||||
} |
README file for the VS 2019 VB sample project | |||||
Copyright (c) 2009, 2020 ARM Research Laboratories | |||||
This README file gives an overview of the VS 2019 VB sample project. | |||||
This project links the sample VB file VBSample\main.cpp with the | |||||
SNFMulti DLL library. | |||||
To build this application: | |||||
1) Open VS2019VBSample\VS2019VBSample.sln with VS 2019. | |||||
2) Select "Any CPU", "x64" or "x86" for the platform. | |||||
3) In the project, open main.vb. | |||||
4) Modify the initial value of ConfigurationPath as necessary to | |||||
specify the location of the SNFServer configuration file. The | |||||
defaults assume that the configuration file name is | |||||
"snf_engine.xml", and is located in the same directory as the | |||||
VS2019VBSample.sln. | |||||
5) Modify the initial value of SNFMULTI_DLL as necessary to specify | |||||
the location of the SNFMulti.dll file. | |||||
6) Build. | |||||
7) Run. | |||||
README file for the VS 2019 VB sample project | |||||
Copyright (c) 2009, 2020 ARM Research Laboratories | |||||
This README file gives an overview of the VS 2019 VB sample project. | |||||
This project links the sample VB file VBSample\main.cpp with the | |||||
SNFMulti DLL library. | |||||
To build this application: | |||||
1) Open VS2019VBSample\VS2019VBSample.sln with VS 2019. | |||||
2) Select "Any CPU", "x64" or "x86" for the platform. | |||||
3) In the project, open main.vb. | |||||
4) Verify that the value of ConfigurationPath is the path for the | |||||
snf_enging.xml Sniffer configuration file. | |||||
5) Modify the initial value of SNFMULTI_DLL as necessary to specify | |||||
the location of the SNFMulti.dll file. | |||||
6) Build. | |||||
7) Run. |
' main.vb SNF-SDK-WIN CPP OEM Demonstration Code | |||||
' Copyright (C) 2009 ARM Research Labs, LLC | |||||
' | |||||
' This app simply exercises the API provided by snfmultidll. | |||||
Imports System.Runtime.InteropServices | |||||
Imports System.Text | |||||
Module SNFMultiDLLExample | |||||
#Region "DLL Imports" | |||||
' Location of SNFMulti.dll. | |||||
Const SNFMULTI_DLL As String = "..\..\..\64bitDll\SNFMulti.dll" ' Set CPU type to "Any CPU" | |||||
'Const SNFMULTI_DLL As String = "..\..\..\..\64bitDll\SNFMulti.dll" ' Set CPU type to "x64" | |||||
'Const SNFMULTI_DLL As String = "..\..\..\32bitDll\SNFMulti.dll" ' Set CPU type to "x86" | |||||
'int setThrottle(int Threads); /* Set scan thread limit. */ | |||||
'int startupSNF(char* Path); /* Start SNF with configuration. */ | |||||
'int startupSNFAuthenticated(char* Path, char* Lic, char* Auth); /* Start SNF with conf & auth. */ | |||||
'int shutdownSNF(); /* Shutdown SNF. */ | |||||
'int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */ | |||||
'double getIPReputation(unsigned long int IPToCheck); /* Get reputation figure for IP. */ | |||||
'int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup); /* Scan msgBuffer, name, setup time. */ | |||||
'int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */ | |||||
'int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result & XHeaders. */ | |||||
'int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result & XML Log. */ | |||||
'int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result & Classic Log. */ | |||||
'int getScanResult(int ScanHandle); /* Get just the scan result. */ | |||||
'int closeScan(int ScanHandle); /* Close the scan result. */ | |||||
'Set scan thread limit | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="setThrottle", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function setThrottle(ByVal Threads As Int32) As Int32 | |||||
End Function | |||||
'Startup | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="startupSNF", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function startupSNF(ByVal PathToConfigurationFile As String) As Int32 | |||||
End Function | |||||
'Start SNF with conf & auth. | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="startupSNFAuthenticated", CharSet:=CharSet.Ansi, _ | |||||
CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function startupSNFAuthenticated( _ | |||||
ByVal Path As String, _ | |||||
ByVal Lic As String, _ | |||||
ByVal Auth As String) As Int32 | |||||
End Function | |||||
'Shutdown | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="shutdownSNF", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function shutdownSNF() As Int32 | |||||
End Function | |||||
'Test IP | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="testIP", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function testIP(ByVal IPToCheck As UInt32) As Int32 | |||||
End Function | |||||
'getIPReputation | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getIPReputation", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getIPReputation(ByVal IPToCheck As UInt32) As Double | |||||
End Function | |||||
'ScanBuffer - returns scannerhandle | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="scanBuffer", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function scanBuffer(ByVal MsgBfr As StringBuilder, ByVal MsgBfrLen As Int32, ByVal MsgID As String, ByVal SetupTime As Int32) As Int32 | |||||
End Function | |||||
'ScanFile | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="scanFile", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function scanFile(ByVal FilePath As String, ByVal Setup As Int32) As Int32 | |||||
End Function | |||||
'GetScanXHeaders - use scannerhandle returned from previous - returns ScanResult Code | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanXHeaders", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanXHeaders(ByVal ScannerHandle As Int32, ByRef HeadersPtr As IntPtr, ByRef HeadersLength As Int32) As Int32 | |||||
End Function | |||||
'GetScanXMLLog - Get result & XML Log | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanXMLLog", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanXMLLog(ByVal ScannerHandle As Int32, ByRef LogPtr As IntPtr, ByRef LogLength As Int32) As Int32 | |||||
End Function | |||||
'GetScanClassicLog - Get result & Classic Log | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanClassicLog", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanClassicLog(ByVal ScannerHandle As Int32, ByRef LogPtr As IntPtr, ByRef LogLength As Int32) As Int32 | |||||
End Function | |||||
'GetScanResult - Get just the scan result | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanResult", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanResult(ByVal ScannerHandle As Int32) As Int32 | |||||
End Function | |||||
'Close Scan | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="closeScan", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function closeScan(ByVal ScannerHandle As Int32) As Int32 | |||||
End Function | |||||
#End Region | |||||
Sub Main() | |||||
' Setup the basics we need to run this test. | |||||
'Const LicenseID As String = "licensid" ' SNF License ID can be passed | |||||
'Const Authentication As String = "authentication" ' directly or read from the | |||||
' configuration. OEMs go direct! | |||||
Const ConfigurationPath As String = "c:\Program Files\snf\snf_engine.xml" | |||||
Const IPToTest As UInt32 = &HC22384E ' Same as IP 12.34.56.78 | |||||
Const SampleMessage As String = _ | |||||
"Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n" + _ | |||||
" by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n" + _ | |||||
"From: <somebody@example.com>\r\n" + _ | |||||
"To: <nobody@example.com>\r\n" + _ | |||||
"Subject: Nothing to see here\r\n" + _ | |||||
"\r\n" + _ | |||||
"So this is the big thing that's not here to see.\r\n" + _ | |||||
"I thought it would be more interesting than this.\r\n" + _ | |||||
"\r\n" + _ | |||||
"_M\r\n" + _ | |||||
".\r\n" | |||||
'' Here is a simple example. Startup, exercise the API, shut down. | |||||
'' Note that we're doing this in a very "C" style becuase the DLL API is C | |||||
Dim Result As Integer = 0 | |||||
Result = startupSNF(ConfigurationPath) | |||||
'Result = startupSNFAuthenticated( _ | |||||
' ConfigurationPath, _ | |||||
' LicenseID, _ | |||||
' Authentication) | |||||
Console.WriteLine("Started with config " + ConfigurationPath + " Result: " + Result.ToString("D")) | |||||
' IP tests can be done asynchrounously - they do not have to be part of any particular scan. | |||||
Result = testIP(IPToTest) | |||||
Console.WriteLine("IP test result: " + Result.ToString("D")) | |||||
Dim IPReputation As Double = getIPReputation(IPToTest) | |||||
Console.WriteLine("IP Reputation: " + IPReputation.ToString()) | |||||
' Messgae scans happen in a scan, read, close cycle as shown inside this loop. | |||||
Const NumberOfScans As Integer = 10 | |||||
For i As Integer = 0 To NumberOfScans | |||||
' Show how the IP reputation changes over time. | |||||
IPReputation = getIPReputation(IPToTest) | |||||
Console.WriteLine("IP Reputation: " + IPReputation.ToString()) | |||||
' Scan a message from a buffer. | |||||
Dim SetupTime As Integer = 12 | |||||
Dim ScanHandle As Integer = 0 | |||||
Dim MsgBuffer As New StringBuilder | |||||
MsgBuffer.Append(SampleMessage) | |||||
ScanHandle = scanBuffer(MsgBuffer, MsgBuffer.Length(), "TestMessage", SetupTime) | |||||
Console.WriteLine("Scan Handle: " + ScanHandle.ToString("D")) | |||||
' Retrieve the X-Headers for the scan. | |||||
Dim XHeadersBuffer As IntPtr = IntPtr.Zero | |||||
Dim XHeadersLength As Int32 | |||||
Dim XHeaders As String | |||||
Dim ScanResult As Integer = 0 | |||||
ScanResult = getScanXHeaders(ScanHandle, XHeadersBuffer, XHeadersLength) | |||||
XHeaders = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(XHeadersBuffer, XHeadersLength) | |||||
' Close the scan. | |||||
Result = closeScan(ScanHandle) | |||||
Console.WriteLine("Scan Close Result: " + Result.ToString("D")) | |||||
' X- headers were captured in a string BEFORE closing the scan so we can | |||||
' use them here. | |||||
Console.WriteLine("Scan result code: " + ScanResult.ToString("D")) | |||||
Console.WriteLine("Scan X- headers: " + XHeaders) | |||||
Next i | |||||
' Now that all scanning is done we shut down. | |||||
Result = shutdownSNF() | |||||
End Sub | |||||
End Module | |||||
' main.vb SNF-SDK-WIN CPP OEM Demonstration Code | |||||
' Copyright (C) 2009 ARM Research Labs, LLC | |||||
' | |||||
' This app simply exercises the API provided by snfmultidll. | |||||
Imports System.Runtime.InteropServices | |||||
Imports System.Text | |||||
Module SNFMultiDLLExample | |||||
#Region "DLL Imports" | |||||
' Location of SNFMulti.dll. | |||||
Const SNFMULTI_DLL As String = "..\..\..\64bitDll\SNFMulti.dll" ' Set CPU type to "Any CPU" | |||||
'Const SNFMULTI_DLL As String = "..\..\..\..\64bitDll\SNFMulti.dll" ' Set CPU type to "x64" | |||||
'Const SNFMULTI_DLL As String = "..\..\..\32bitDll\SNFMulti.dll" ' Set CPU type to "x86" | |||||
'int setThrottle(int Threads); /* Set scan thread limit. */ | |||||
'int startupSNF(char* Path); /* Start SNF with configuration. */ | |||||
'int startupSNFAuthenticated(char* Path, char* Lic, char* Auth); /* Start SNF with conf & auth. */ | |||||
'int shutdownSNF(); /* Shutdown SNF. */ | |||||
'int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */ | |||||
'double getIPReputation(unsigned long int IPToCheck); /* Get reputation figure for IP. */ | |||||
'int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup); /* Scan msgBuffer, name, setup time. */ | |||||
'int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */ | |||||
'int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result & XHeaders. */ | |||||
'int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result & XML Log. */ | |||||
'int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result & Classic Log. */ | |||||
'int getScanResult(int ScanHandle); /* Get just the scan result. */ | |||||
'int closeScan(int ScanHandle); /* Close the scan result. */ | |||||
'Set scan thread limit | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="setThrottle", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function setThrottle(ByVal Threads As Int32) As Int32 | |||||
End Function | |||||
'Startup | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="startupSNF", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function startupSNF(ByVal PathToConfigurationFile As String) As Int32 | |||||
End Function | |||||
'Start SNF with conf & auth. | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="startupSNFAuthenticated", CharSet:=CharSet.Ansi, _ | |||||
CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function startupSNFAuthenticated( _ | |||||
ByVal Path As String, _ | |||||
ByVal Lic As String, _ | |||||
ByVal Auth As String) As Int32 | |||||
End Function | |||||
'Shutdown | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="shutdownSNF", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function shutdownSNF() As Int32 | |||||
End Function | |||||
'Test IP | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="testIP", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function testIP(ByVal IPToCheck As UInt32) As Int32 | |||||
End Function | |||||
'getIPReputation | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getIPReputation", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getIPReputation(ByVal IPToCheck As UInt32) As Double | |||||
End Function | |||||
'ScanBuffer - returns scannerhandle | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="scanBuffer", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function scanBuffer(ByVal MsgBfr As StringBuilder, ByVal MsgBfrLen As Int32, ByVal MsgID As String, ByVal SetupTime As Int32) As Int32 | |||||
End Function | |||||
'ScanFile | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="scanFile", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function scanFile(ByVal FilePath As String, ByVal Setup As Int32) As Int32 | |||||
End Function | |||||
'GetScanXHeaders - use scannerhandle returned from previous - returns ScanResult Code | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanXHeaders", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanXHeaders(ByVal ScannerHandle As Int32, ByRef HeadersPtr As IntPtr, ByRef HeadersLength As Int32) As Int32 | |||||
End Function | |||||
'GetScanXMLLog - Get result & XML Log | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanXMLLog", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanXMLLog(ByVal ScannerHandle As Int32, ByRef LogPtr As IntPtr, ByRef LogLength As Int32) As Int32 | |||||
End Function | |||||
'GetScanClassicLog - Get result & Classic Log | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanClassicLog", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanClassicLog(ByVal ScannerHandle As Int32, ByRef LogPtr As IntPtr, ByRef LogLength As Int32) As Int32 | |||||
End Function | |||||
'GetScanResult - Get just the scan result | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="getScanResult", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function getScanResult(ByVal ScannerHandle As Int32) As Int32 | |||||
End Function | |||||
'Close Scan | |||||
<DllImport(SNFMULTI_DLL, EntryPoint:="closeScan", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _ | |||||
Public Function closeScan(ByVal ScannerHandle As Int32) As Int32 | |||||
End Function | |||||
#End Region | |||||
Sub Main() | |||||
' Setup the basics we need to run this test. | |||||
'Const LicenseID As String = "licensid" ' SNF License ID can be passed | |||||
'Const Authentication As String = "authentication" ' directly or read from the | |||||
' configuration. OEMs go direct! | |||||
Const ConfigurationPath As String = "c:\snf\snf_engine.xml" | |||||
Const IPToTest As UInt32 = &HC22384E ' Same as IP 12.34.56.78 | |||||
Const SampleMessage As String = _ | |||||
"Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n" + _ | |||||
" by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n" + _ | |||||
"From: <somebody@example.com>\r\n" + _ | |||||
"To: <nobody@example.com>\r\n" + _ | |||||
"Subject: Nothing to see here\r\n" + _ | |||||
"\r\n" + _ | |||||
"So this is the big thing that's not here to see.\r\n" + _ | |||||
"I thought it would be more interesting than this.\r\n" + _ | |||||
"\r\n" + _ | |||||
"_M\r\n" + _ | |||||
".\r\n" | |||||
'' Here is a simple example. Startup, exercise the API, shut down. | |||||
'' Note that we're doing this in a very "C" style becuase the DLL API is C | |||||
Dim Result As Integer = 0 | |||||
Result = startupSNF(ConfigurationPath) | |||||
'Result = startupSNFAuthenticated( _ | |||||
' ConfigurationPath, _ | |||||
' LicenseID, _ | |||||
' Authentication) | |||||
Console.WriteLine("Started with config " + ConfigurationPath + " Result: " + Result.ToString("D")) | |||||
' IP tests can be done asynchrounously - they do not have to be part of any particular scan. | |||||
Result = testIP(IPToTest) | |||||
Console.WriteLine("IP test result: " + Result.ToString("D")) | |||||
Dim IPReputation As Double = getIPReputation(IPToTest) | |||||
Console.WriteLine("IP Reputation: " + IPReputation.ToString()) | |||||
' Messgae scans happen in a scan, read, close cycle as shown inside this loop. | |||||
Const NumberOfScans As Integer = 10 | |||||
For i As Integer = 0 To NumberOfScans | |||||
' Show how the IP reputation changes over time. | |||||
IPReputation = getIPReputation(IPToTest) | |||||
Console.WriteLine("IP Reputation: " + IPReputation.ToString()) | |||||
' Scan a message from a buffer. | |||||
Dim SetupTime As Integer = 12 | |||||
Dim ScanHandle As Integer = 0 | |||||
Dim MsgBuffer As New StringBuilder | |||||
MsgBuffer.Append(SampleMessage) | |||||
ScanHandle = scanBuffer(MsgBuffer, MsgBuffer.Length(), "TestMessage", SetupTime) | |||||
Console.WriteLine("Scan Handle: " + ScanHandle.ToString("D")) | |||||
' Retrieve the X-Headers for the scan. | |||||
Dim XHeadersBuffer As IntPtr = IntPtr.Zero | |||||
Dim XHeadersLength As Int32 | |||||
Dim XHeaders As String | |||||
Dim ScanResult As Integer = 0 | |||||
ScanResult = getScanXHeaders(ScanHandle, XHeadersBuffer, XHeadersLength) | |||||
XHeaders = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(XHeadersBuffer, XHeadersLength) | |||||
' Close the scan. | |||||
Result = closeScan(ScanHandle) | |||||
Console.WriteLine("Scan Close Result: " + Result.ToString("D")) | |||||
' X- headers were captured in a string BEFORE closing the scan so we can | |||||
' use them here. | |||||
Console.WriteLine("Scan result code: " + ScanResult.ToString("D")) | |||||
Console.WriteLine("Scan X- headers: " + XHeaders) | |||||
Next i | |||||
' Now that all scanning is done we shut down. | |||||
Result = shutdownSNF() | |||||
End Sub | |||||
End Module |