SNMP++  3.3.11
smival.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## smival.h
4  _##
5  _## SNMP++ v3.3
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2013 Jochen Katz, Frank Fock
8  _##
9  _## This software is based on SNMP++2.6 from Hewlett Packard:
10  _##
11  _## Copyright (c) 1996
12  _## Hewlett-Packard Company
13  _##
14  _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15  _## Permission to use, copy, modify, distribute and/or sell this software
16  _## and/or its documentation is hereby granted without fee. User agrees
17  _## to display the above copyright notice and this license notice in all
18  _## copies of the software and any documentation of the software. User
19  _## agrees to assume all liability for the use of the software;
20  _## Hewlett-Packard and Jochen Katz make no representations about the
21  _## suitability of this software for any purpose. It is provided
22  _## "AS-IS" without warranty of any kind, either express or implied. User
23  _## hereby grants a royalty-free license to any and all derivatives based
24  _## upon this software code base.
25  _##
26  _##########################################################################*/
27 /*===================================================================
28 
29  Copyright (c) 1999
30  Hewlett-Packard Company
31 
32  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
33  Permission to use, copy, modify, distribute and/or sell this software
34  and/or its documentation is hereby granted without fee. User agrees
35  to display the above copyright notice and this license notice in all
36  copies of the software and any documentation of the software. User
37  agrees to assume all liability for the use of the software; Hewlett-Packard
38  makes no representations about the suitability of this software for any
39  purpose. It is provided "AS-IS without warranty of any kind,either express
40  or implied. User hereby grants a royalty-free license to any and all
41  derivatives based upon this software code base.
42 
43 
44  SNMP++ S M I V A L . H
45 
46  SMIVALUE CLASS DEFINITION
47 
48  DESIGN + AUTHOR: Jeff Meyer
49 
50  DESCRIPTION:
51  SMIValue class definition. Superclass for the various types
52  of SNMP values (Address, Oid, Octet, etc.). Provides
53  only a few functions, most info is in subclass.
54 
55 =====================================================================*/
56 // $Id$
57 
58 #ifndef _SNMP_SMIVAL_H_
59 #define _SNMP_SMIVAL_H_
60 
61 //----[ includes ]-----------------------------------------------------
62 #include <libsnmp.h>
63 #include "snmp_pp/smi.h"
64 
65 #ifdef SNMP_PP_NAMESPACE
66 namespace Snmp_pp {
67 #endif
68 
69 
70 //----[ macros ]-------------------------------------------------------
71 #if defined(USE_CPP_CASTS)
72 #define PP_CONST_CAST(___type, ___ptr) const_cast< ___type >(___ptr)
73 #else
74 #define PP_CONST_CAST(___type, ___ptr) ((___type)(___ptr))
75 #endif
76 
77 //======================================================================
78 // SMI value structure conforming with SMI RFC
79 //
80 typedef struct SmiVALUE
81 { /* smiVALUE portion of VarBind */
83  : syntax(sNMP_SYNTAX_NULL)
84  { memset( &value, 0, sizeof(value) ); }
85 
86  SmiUINT32 syntax; /* Insert SNMP_SYNTAX_<type> */
87  union {
88  SmiINT sNumber; /* SNMP_SYNTAX_INT
89  SNMP_SYNTAX_INT32 */
90  SmiUINT32 uNumber; /* SNMP_SYNTAX_UINT32
91  SNMP_SYNTAX_CNTR32
92  SNMP_SYNTAX_GAUGE32
93  SNMP_SYNTAX_TIMETICKS */
94  SmiCNTR64 hNumber; /* SNMP_SYNTAX_CNTR64 */
95  SmiOCTETS string; /* SNMP_SYNTAX_OCTETS
96  SNMP_SYNTAX_BITS
97  SNMP_SYNTAX_OPAQUE
98  SNMP_SYNTAX_IPADDR
99  SNMP_SYNTAX_NSAPADDR */
100  SmiOID oid; /* SNMP_SYNTAX_OID */
101  SmiBYTE empty; /* SNMP_SYNTAX_NULL
102  SNMP_SYNTAX_NOSUCHOBJECT
103  SNMP_SYNTAX_NOSUCHINSTANCE
104  SNMP_SYNTAX_ENDOFMIBVIEW */
105  } value;
106  } *SmiLPVALUE;
107 //=================================================================
108 
109 //--------------------------------------------------------------------
110 //----[ SnmpSyntax class ]--------------------------------------------
111 //--------------------------------------------------------------------
112 
113 /**
114  * An "abstract" (pure virtual) class that serves as the base class
115  * for all specific SNMP syntax types.
116  */
118 
119 public:
120 
121  /**
122  * Virtual function for getting a printable ASCII value for any SNMP
123  * value.
124  *
125  * @note The returned string is valid as long as the object is not
126  * modified.
127  * @note This function is NOT thread safe.
128  */
129  virtual const char *get_printable() const = 0;
130 
131  /**
132  * Return the current syntax.
133  */
134  virtual SmiUINT32 get_syntax() const = 0;
135 
136  /**
137  * Virtual clone operation for creating a new Value from an existing
138  * value.
139  *
140  * @note The caller MUST use the delete operation on the return
141  * value when done.
142  */
143  virtual SnmpSyntax * clone() const = 0;
144 
145  /**
146  * Virtual destructor to ensure deletion of derived classes...
147  */
148  virtual ~SnmpSyntax() {}
149 
150  /**
151  * Overloaded assignment operator.
152  */
153  virtual SnmpSyntax& operator = (const SnmpSyntax &val) = 0;
154 
155  /**
156  * Return validity of the object.
157  */
158  virtual bool valid() const = 0;
159 
160  /**
161  * Return the space needed for serialization.
162  */
163  virtual int get_asn1_length() const = 0;
164 
165  /**
166  * Reset the object.
167  */
168  virtual void clear() = 0;
169 
170 protected:
172  : smival()
173  {}
174 
176 };
177 
178 #ifdef SNMP_PP_NAMESPACE
179 } // end of namespace Snmp_pp
180 #endif
181 
182 #endif // _SNMP_SMIVAL_H_
SnmpSyntax()
Definition: smival.h:171
unsigned long SmiUINT32
Definition: smi.h:157
SmiVALUE smival
Definition: smival.h:175
#define sNMP_SYNTAX_NULL
Definition: smi.h:103
SmiUINT32 uNumber
Definition: smival.h:90
SmiOID oid
Definition: smival.h:100
virtual ~SnmpSyntax()
Virtual destructor to ensure deletion of derived classes...
Definition: smival.h:148
SmiCNTR64 hNumber
Definition: smival.h:94
SmiVALUE()
Definition: smival.h:82
Definition: smi.h:160
SmiBYTE empty
Definition: smival.h:101
#define DLLOPT
long SmiINT
Definition: smi.h:151
SmiUINT32 syntax
Definition: smival.h:86
SmiOCTETS string
Definition: smival.h:95
struct SmiVALUE * SmiLPVALUE
unsigned char SmiBYTE
Definition: smi.h:148
Definition: smi.h:191
SmiINT sNumber
Definition: smival.h:88
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:117
Definition: smi.h:168