]>
Commit | Line | Data |
---|---|---|
51ea0904 | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
51ea0904 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
51ea0904 CT |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 49 SNMP Interface */ |
10 | ||
51ea0904 CT |
11 | #ifndef SQUID_SNMPX_VAR_H |
12 | #define SQUID_SNMPX_VAR_H | |
13 | ||
21dfc374 | 14 | #include "base/Range.h" |
51ea0904 | 15 | #include "ipc/forward.h" |
51ea0904 CT |
16 | #include "snmp_vars.h" |
17 | ||
51ea0904 CT |
18 | namespace Snmp |
19 | { | |
20 | ||
21 | /// variable_list wrapper implement the feature to change | |
22 | /// the name/value of variable and to pack/unpack message | |
23 | class Var: public variable_list | |
24 | { | |
25 | public: | |
26 | Var(); | |
27 | Var(const Var& var); | |
28 | Var& operator = (const Var& var); | |
29 | ~Var(); | |
30 | ||
31 | Var& operator += (const Var& var); | |
32 | Var& operator /= (int num); | |
33 | bool operator < (const Var& var) const; | |
34 | bool operator > (const Var& var) const; | |
8fb5a96c | 35 | |
51ea0904 CT |
36 | void pack(Ipc::TypedMsgHdr& msg) const; ///< prepare for sendmsg() |
37 | void unpack(const Ipc::TypedMsgHdr& msg); ///< restore struct from the message | |
38 | ||
39 | Range<const oid*> getName() const; ///< returns variable name | |
40 | void setName(const Range<const oid*>& aName); ///< set new variable name | |
41 | void clearName(); ///< clear variable name | |
42 | ||
43 | bool isNull() const; | |
44 | ||
45 | int asInt() const; ///< returns variable value as integer | |
46 | unsigned int asGauge() const; ///< returns variable value as unsigned int | |
47 | int asCounter() const; ///< returns variable value as Counter32 | |
48 | long long int asCounter64() const; ///< returns variable value as Counter64 | |
579928b6 | 49 | unsigned int asTimeTicks() const; ///< returns variable value as time ticks |
51ea0904 CT |
50 | Range<const oid*> asObject() const; ///< returns variable value as object oid |
51 | Range<const u_char*> asString() const; ///< returns variable value as chars string | |
51ea0904 CT |
52 | |
53 | void setInt(int value); ///< assign int value to variable | |
54 | void setCounter(int value); ///< assign Counter32 value to variable | |
55 | void setGauge(unsigned int value); ///< assign unsigned int value to variable | |
56 | void setString(const Range<const u_char*>& string); ///< assign string to variable | |
57 | void setObject(const Range<const oid*>& object); ///< assign object oid to variable | |
579928b6 | 58 | void setTimeTicks(unsigned int ticks); ///<assign unsigned int (time) value to variable |
51ea0904 CT |
59 | void setCounter64(long long int counter); ///< assign Counter64 value to variable |
60 | ||
61 | void copyValue(const Var& var); ///< copy variable from another one | |
62 | void clearValue(); ///< clear .val member | |
63 | void clear(); ///< clear all internal members | |
64 | ||
65 | private: | |
66 | void init(); ///< initialize members | |
67 | void assign(const Var& var); ///< perform full assignment | |
68 | void setValue(const void* value, int length, int aType); ///< set new variable value | |
69 | }; | |
70 | ||
71 | } // namespace Snmp | |
72 | ||
73 | #endif /* SQUID_SNMPX_VAR_H */ | |
f53969cc | 74 |