The Structure of the Sample Visual C Program


The Structure of the Sample Visual C++ Program

The sample program is not complex; it has a main() structure made up of just the following two lines:

 startupRoutine (argumentCount, argumentVector); dispatchOperation(programMode, argumentVector); 

The first function validates the command-line parameters and determines the program mode ( GET , SET , etc.). The second function executes the required operation. The full source code listing is included in Appendix A, "Terminal Server Serial Ports."

The Supported Operations

Five operations are allowed with this manager:

  • GET

  • GETNEXT

  • SET

  • WALK

  • TRAP

The required operation is specified on the program command line. Overall, the external API provided by this program is a single function called:

[View full width]
 
[View full width]
int doSnmpOperation(enum Operations reqOperation, LPSTR agentName, LPSTR community, char graphics/ccc.gif *objectIdentifier, char *objectValue)

The program is invoked for a GET operation on the ipInReceives object value as follows , with a three-line response (commands typed by the user are shown in bold; system responses are delimited by angle brackets):

[View full width]
 
[View full width]
Debug\snmpmgr.exe GET myHostPC public .iso.org.dod.internet.mgmt.mib-2.ip.ipInReceives.0 graphics/ccc.gif NULL < ***** THE SYSTEM RESPONSE NOW FOLLOWS ***** > < SNMP Operation Type GET > < MIB Object Instance = ip.ipInReceives.0 > < Value = Counter32 4929873 >

The parameters for this are as follows:

  • snmpmgr.exe : the program name

  • GET : the required SNMP operation type

  • myHostPC : the target IP address or DNS name of the remote SNMP agent host

  • public : the SNMP community name

  • .iso.org.dod.internet.mgmt.mib-2.ip.ipInReceives.0 : the required MIB object instance

  • NULL : value for SET ; not required for GET , hence the value is NULL

The remote (or local) agent responds to the message and the data sent back to snmpmgr.exe is presented as:

 < SNMP Operation Type GET > < MIB Object Instance = ip.ipInReceives.0 > < Type and Value =  Counter32 4929873 > 

The last two lines indicate the required MIB object instance and its value (in this case, the object is our old friend ipInReceives.0 and has the value 4929873). The supplied DOS batch files automate the process of running the program, freeing the user from having to type complex command lines. The batch files and their use are described in the following sections.



Network Management, MIBs and MPLS
Network Management, MIBs and MPLS: Principles, Design and Implementation
ISBN: 0131011138
EAN: 2147483647
Year: 2003
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net