Using the SNMP Class mentioned previously in a blog, you can also find out the available MAC Addresses on the switch. Be sure to reference the assembly in the beginning.
public void ConnectCiscoSwitch(string arg0, string arg1)
{
int commlength, miblength, datastart, datalength;
string nextmib, value;
SNMP conn = new SNMP();
string mib = "1.3.6.1.2.1.17.4.3.1.1";
int orgmiblength = mib.Length;
byte[] response = new byte[1024];
nextmib = mib;
Label1.ForeColor = Color.Black;
this.Label1.Style["text-align"] = "left";
Label1.Text = "<br />Switch <b>" + arg0 +
"</b> Usage information: <br />";
Label1.Text +=
"----------------------------------------------<br />";
try
{
while (true)
{
response = conn.get("getnext", arg0, arg1, nextmib);
commlength = Convert.ToInt16(response[6]);
miblength = Convert.ToInt16(response[23 + commlength]);
datalength = Convert.ToInt16(response[25 + commlength + miblength]);
datastart = 26 + commlength + miblength;
value = BitConverter.ToString(response, datastart, datalength);
nextmib = conn.getnextMIB(response);
if (!(nextmib.Substring(0, orgmiblength) == mib))
break;
Console.WriteLine("{0} = {1}", nextmib, value);
Label1.Text += nextmib + " = " + value + "<br />";
}
}
catch (Exception ex)
{
Label1.ForeColor = Color.Maroon;
Label1.Text = "Sorry! Switch could not be found for <b>" +
txtServer.Text + "</b>. " + ex.Message;
}
}
Various Scripts and Application Code Segments for .NET, VB, C#, C++, C, Java, JavaScript, HTML, Python, Perl, AutoIT, Batch, ASP Classic, Objective-C, Swift, Unreal Engine 4, Unity3D & others. Also contains numerous IT tidbits, procedures, and tricks including Technology Hacks on various platforms.
Subscribe to:
Post Comments (Atom)
Generating "Always On Top" NSWindow in macOS across all detected displays
Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift Langues, you m...
-
In Unreal Engine 4 you will eventually need Linear Interpolation between two values to do something like ping pong between two float val...
-
Recently Possess () has been deprecated from UE4 , and when writing classes based on AAIController you have to use the function OnPossess ...
-
Often we intermingle C++ and Blueprints, and need for the two to communicate. With Behavior Trees, using ENUMs is an everyday occurrence an...
No comments:
Post a Comment