summaryrefslogtreecommitdiff
path: root/ASNMP/asnmp/smival.h
blob: 6e7c8c4c1b97d6a9ab86356e2738c571929f53ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* -*-C++-*- */
// $Id$
#ifndef SMIVALUE_
#define SMIVALUE_
// ============================================================================
//
// = LIBRARY
//    tests
//
// = FILENAME
//    smival.h
//
// = DESCRIPTION
// SMIValue class definition. Superclass for the various types
// of SNMP values (Address, Oid, Octet, etc.).  Provides
// only a few functions, most info is in subclass.
//
// = AUTHOR
// Jeff Meyer
//
// ============================================================================
/*===================================================================
  Copyright (c) 1996
  Hewlett-Packard Company

  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.
=====================================================================*/

//----[ includes ]-----------------------------------------------------
#include "asnmp/smi.h"

//----[ macros ]-------------------------------------------------------

//======================================================================
// SMI value structure conforming with SMI RFC
//
typedef struct {                /* smiVALUE portion of VarBind */
          SmiUINT32 syntax;     /* Insert SNMP_SYNTAX_<type> */
        union   {
          SmiINT    sNumber;    /* SNMP_SYNTAX_INT
                                   SNMP_SYNTAX_INT32 */
          SmiUINT32 uNumber;    /* SNMP_SYNTAX_UINT32
                                   SNMP_SYNTAX_CNTR32
                                   SNMP_SYNTAX_GAUGE32
                                   SNMP_SYNTAX_TIMETICKS */
          SmiCNTR64 hNumber;    /* SNMP_SYNTAX_CNTR64 */
          SmiOCTETS string;     /* SNMP_SYNTAX_OCTETS
                                   SNMP_SYNTAX_BITS
                                   SNMP_SYNTAX_OPAQUE
                                   SNMP_SYNTAX_IPADDR
                                   SNMP_SYNTAX_NSAPADDR */
          SmiOID    oid;        /* SNMP_SYNTAX_OID */
          SmiBYTE   empty;      /* SNMP_SYNTAX_NULL
                                   SNMP_SYNTAX_NOSUCHOBJECT
                                   SNMP_SYNTAX_NOSUCHINSTANCE
                                   SNMP_SYNTAX_ENDOFMIBVIEW */
                  }   value;
}    SmiVALUE, *SmiLPVALUE;

// An "abstract" (pure virtual) class that serves as the base class
// for all specific SNMP syntax types.
//
class ACE_Export SnmpSyntax {

public:
  virtual char * to_string() = 0;
  // virtual function for getting a printable ASCII value for any SNMP Value

  virtual SmiUINT32 get_syntax() = 0;
  // return the current syntax

  virtual  SnmpSyntax * clone() const = 0;
  // virtual clone operation for creating a new Value from an existing
  // value.  The caller MUST use the delete operation on the return
  // value when done.

  virtual ~SnmpSyntax() {};
  // virtual destructor to ensure deletion of derived classes...

  virtual SnmpSyntax& operator=( SnmpSyntax &/*val*/)
  {
      return *this;
  }
  // overloaded assignment operator
  // This should be pure virtual, but WinNT compiler
  // complains about unresolved reference at link time.

  virtual int valid() const = 0;
  // return validity of value object.

protected:
  SmiVALUE smival;
};

#endif  // SMIVALUE_