SNMP++

C++ Based Application Programmers Interface for the Simple Network Management Protocol

 

 

 

 

 


This document describes SNMP++, an open specification for object oriented network management development using SNMP and C++. This document describes the various portable classes which make up the API and goes through a number of examples.

 

 

 

 

 

 

 

 

 

 

 

Visit the SNMP++Web site for source code, real working examples and other related documents @

http://rosegarden.external.hp.com/snmp++

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Peter Erik Mellquist

Hewlett-Packard Company

Workgroup Networks Division

Network Management Section

Roseville, CA

 

 


Hewlett-Packard Company version 2.61 11 July, 1997

Copyright © 1994-1996 Hewlett Packard Company

All Rights Reserved

Hewlett Packard

Peter Erik Mellquist

 

This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included.

 

ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.

Permission to use, copy, modify, distribute and/or sell this software and/or its documentation is hereby granted without fee. User agrees to display the above copyright notice and this license notice in all  copies of the software and any documentation of the software. User agrees to assume all liability for the use of the software; Hewlett-Packard makes no representations about the suitability of this software for any purpose. It is provided "AS-IS without warranty of any kind,either express or implied. User hereby grants a royalty-free license to any and all derivatives based upon this software code base.

 

Authors Contact Information:

Comments,  suggestions and inquiries regarding SNMP++ may be submitted via electronic mail to peter_mellquist@hp.com.

 

Acknowledgments:

I would especially like thank five people for their generous assistance. For revision 2.6 and all of its changes, credit is given to Brian OKeefe of HP Network Management Systems Division, for his many suggestions and SNMP version 2 knowledge. The SNMP++ project would not have been possible if not for Kim Bankers , HP Roseville Networks Division, continual support and effort. Bob Natale of American Computers and Electronics Corp.,  provided valuable access the WinSNMP working group where many comments and suggestions have originated.  Lastly Jeff Meyer and Tom Murray, of HP Network Computing Division, provided significant contributions to the classes and the UNIX implementation of the code base.

 

Where this document and code can be found:

This document is freely available in both Microsoft Word for Windows and Postscript formats on the following WWW  server.

 

  http://rosegarden.external.hp.com/snmp++

      

 

Technical Contributors:

Kim Banker , HP Roseville Networks Division                   

Gary Berard , HP Roseville Networks Division

Chuck Black ,HP Roseville Networks Division

Bruce Falzarano ,HP Roseville Networks Division

Greg Fichtenholtz  , HP OpenView Operations

Harry Kellog,  HP Roseville Networks Division

Moises Medina , HP Roseville Networks Division

Jeff Meyer, HP Network Computing Division

Tom Milner,  HP Roseville Networks Division

Tom Murray, HP Network Computing Division

Mark Pearson, HP Roseville Networks Division

Bob Natale, American Computers and Electronics Corporation

Brian OKeefe, HP Network Systems Management Division

Frank Wang, Purdue University

Table Of Contents

1.    Whats New in Revision 2.61. 7

2.    Products Now Using SNMP++. 8

3.    Introduction.. 9

3.1.      What Is SNMP++?. 9

3.2.      Objectives of SNMP++. 10

3.2.1.      Ease of Use and SNMP++.. 10

3.2.2.      Programming Safety and SNMP++.. 10

3.2.3.      Portability and SNMP++.. 11

3.2.4.      Extensibility and SNMP++.. 11

4.    An Introductory Example. 12

4.1.      A Simple SNMP++ Example. 12

5.    SNMP++ Features.. 13

5.1.      Full Set of C++ based SNMP classes. 13

5.2.      Automatic SNMP Memory Management.. 13

5.3.      Ease Of  Use. 13

5.4.      Power and Flexibility.. 13

5.5.      Portable Objects. 13

5.6.      Automatic Time-out And Retries. 13

5.7.      Blocked Mode Requests. 14

5.8.      Non-Blocking Asynchronous Mode Requests. 14

5.9.     Notifications, Trap Reception and Sending.. 14

5.10.        Support For SNMP Version 1 and 2 Through a Bilingual API 14

5.11.        SNMP Get, Get Next, Get Bulk, Set, Inform and Trap Supported.. 14

5.12.        Redefinition Through Inheritance. 14

6.    SNMP++ for the Microsoft Windows Family of Operating Systems.. 15

6.1.      Utilization of WinSNMP Version  1.1. 15

6.2.      IP and IPX Support.. 15

6.3.     Notifications, Trap Receive and Send Support.. 15

6.4.     Compatibility with HP OpenView for Windows. 15

7.    SNMP++ for UNIX.. 16

7.1.      Identical Class Interface. 16

7.2.     Portable to Windows-to-UNIX Emulators. 16

7.3.      Compatibility with HP OpenView for UNIX.. 16

8.    SNMP Syntax Classes.. 17

9.    Object Id Class.. 18

9.1.      The Object Identifier Class. 18

9.2.      Overview of Oid Class Member Functions. 18

9.3.      Overview of Oid Class Member Functions Continued.. 19

9.4.      Some Oid Class Examples. 20

10.      OctetStr Class.. 22

10.1.        The OctetStr Class. 22

10.2.        Overview of OctetStr Class Member Functions. 22

10.3.        Overview of OctetStr Class Member Functions Continued.. 23

10.4.        Special features. 23

10.5.        Some OctetStr Class Examples. 24

11.      TimeTicks Class.. 25

11.1.        The TimeTicks Class. 25

11.2.        Overview of TimeTicks Class Member Functions. 25

11.3.        Special Features. 25

11.4.       Some TimeTicks Class Examples. 26

12.      Counter32 Class.. 27

12.1.        The Counter32 Class. 27

12.2.        Overview of Counter32 Class Member Functions. 27

12.3.        Some Counter32 Class Examples. 28

13.      Gauge32 Class.. 29

13.1.        The Gauge32 Class. 29

13.2.        Overview of Gauge32 Class Member Functions. 29

13.3.        Some Gauge32 Examples. 30

14.      Counter64 Class.. 31

14.1.        The Counter64 Class. 31

14.2.        Overview of Counter64 Class Member Functions. 31

14.3.        Overview of Counter64Class Member Functions Continued.. 32

14.4.        Some Counter64 Class Examples. 33

15.      Address Class.. 34

15.1.       What is the Network Address Class?. 34

15.2.        Why use the Network Address Class?. 34

15.3.        Address Classes. 34

15.4.        Address Classes and Interfaces. 35

15.5.        IpAddress Class Special Features. 35

15.6.        GenAddress. 36

15.7.        Address Class Validation.. 36

15.8.        UdpAddresses and IpxSockAddresses. 37

15.8.1.    Using UdpAddresses for Making Requests. 37

15.8.2.    Using IpxSockAddresses for Making Requests. 37

15.8.3.    Using UdpAddress and IpxSockAddress for Notification Reception. 37

15.9.        Valid Address Formats. 37

15.10.      Address Class Examples. 39

16.      The Variable Binding Class.. 42

16.1.        Variable Binding Class Member Functions Overview... 43

16.2.        Vb Class Public Member Functions. 44

16.2.1.    Vb Class Constructors & Destructors. 44

16.2.2.    Vb Class Get Oid / Set Oid Member Functions. 44

16.2.3.    Vb Class Get Value / Set Value Member Functions. 45

16.2.4.    Set the value to a GenAdress object. 47

16.2.5.    Set the value to a UdpAdress object. 47

16.2.6.    Set the value to a IpxSockAdress object. 47

16.2.7.    Set the value portion of a Vb to an Octet object. 47

16.2.8.    Vb Class Get Value Member Functions. 47

16.2.9.    Vb Object Get Syntax Member Function. 50

16.2.10.      Vb Object Validation Check. 51

16.2.11.      Vb Object Assignment to Other Vb Objects. 51

16.2.12.      Vb Object Errors. 51

16.3.        Vb Class Examples. 52

17.      Pdu Class.. 54

17.1.        Pdu Class Member Functions Overview... 55

17.2.        Pdu Class Constructors and Destructors. 56

17.3.       Pdu Access Member Functions. 57

17.4.       Pdu Class Overloaded Operators. 58

17.5.        Pdu Class Member Functions for Traps and Informs. 58

17.6.       Loading Pdu Objects. 59

17.7.        Unloading Pdu Objects. 60

18.      SnmpMessage Class.. 61

19.      Target Class.. 62

19.1.        Abstract Targets. 62

19.2.        Target Addresses. 62

19.3.        Retransmission Policies. 62

19.4.        Target Class Interface. 63

19.5.        CTarget Class ( Community Based Targets) 64

19.5.1.    Constructing CTargets. 64

19.5.2.    Modifying CTargets. 64

19.5.3.    Accessing CTargets. 65

19.5.4.    CTarget Examples. 66

20.      Snmp Class.. 67

20.1.        Snmp Class Member Functions Overview... 68

20.2.        Bilingual API 69

20.3.        Snmp Class Public Member Functions. 69

20.3.1.    Snmp Class Constructors and Destructors. 69

20.3.2.    Snmp Class Constructor. 69

20.3.3.    Snmp Class Destructor. 69

20.3.4.    Snmp Class Request Member Functions. 69

20.3.5.    Snmp Class Blocked Get Member Function. 70

20.3.6.    Snmp Class Blocked Get Next Member Function. 70

20.3.7.    Snmp Class Blocked Set Member Function. 70

20.3.8.    Snmp Class Blocked Get Bulk Member Function. 70

20.3.9.    SNMP Class Blocked Inform Member Function. 71

20.4.        Snmp Class Asynchronous Member Functions. 71

20.4.1.    SNMP++ Asynchronous Callback Function Type Definition. 71

20.4.2.    Canceling an Asynchronous Request 73

20.4.3.    Snmp Class Asynchronous Get Member Function. 73

20.4.4.    Snmp Class Asynchronous Set Member Function. 73

20.4.5.    Snmp Class Asynchronous  Get Next Member Function. 74

20.4.6.    Snmp Class Asynchronous  Get Bulk Member Function. 74

20.4.7.    Snmp Class Asynchronous Inform Member Function. 74

20.5.        SNMP++ Notification Methods. 75

20.5.1.    Sending Traps. 75

20.5.2.    Receiving Notifications. 76

20.5.3.    Filtering Using OidCollection, TargetCollection and AddressCollections. 78

20.6.        SNMP+ Class Error Return Codes. 81

20.6.1.    Snmp Class Error Message Member Function. 81

21.      Operational Modes.. 82

21.1.1.    Microsoft Windows Event System Operation. 82

21.1.2.    Open Systems Foundation (OSF) X11 Motif Operation. 82

21.1.3.    Non GUI Based Application Operation. 83

22.      Status and Error Codes.. 84

23.      Error Status Values.. 85

24.      Snmp Class Examples.. 86

In addition to the examples in this section, please refer to the files in the table below for complete programs which can be used as useful command line utilities. 86

24.1.        Getting a Single MIB Variable Example. 87

24.2.        Getting Multiple MIB Variables Example. 88

24.3.        Setting a Single MIB Variable Example. 90

24.4.        Setting Multiple MIB Variables Example. 91

24.5.        Walking a MIB using Get-Next Example. 92

24.6.        Sending a Trap Example. 93

24.7.        Receiving Traps Example. 94

25.      References.. 96