Represents an SNMP object identifier (OID) More...
#include <oid.hpp>
Public Member Functions | |
| oid (uint32_t c1=0, uint32_t c2=0, uint32_t c3=0, uint32_t c4=0, uint32_t c5=0, uint32_t c6=0, uint32_t c7=0, uint32_t c8=0, uint32_t c9=0, uint32_t c10=0, uint32_t c11=0, uint32_t c12=0, uint32_t c13=0, uint32_t c14=0, uint32_t c15=0, uint32_t c16=0, uint32_t c17=0, uint32_t c18=0, uint32_t c19=0, uint32_t c20=0) | |
| Initialize an oid object with a sequence of up to 20 subidentifiers. | |
| oid (const oid &o, uint32_t c1=0, uint32_t c2=0, uint32_t c3=0, uint32_t c4=0, uint32_t c5=0, uint32_t c6=0, uint32_t c7=0, uint32_t c8=0, uint32_t c9=0, uint32_t c10=0, uint32_t c11=0, uint32_t c12=0, uint32_t c13=0, uint32_t c14=0, uint32_t c15=0, uint32_t c16=0, uint32_t c17=0, uint32_t c18=0, uint32_t c19=0) | |
| Initialize an oid object with another oid plus a sequence of up to 19 subidentifiers. | |
| oid & | operator= (const oid &oid) |
| Assignment operator. | |
| bool | get_include () |
| get the current include value | |
| void | set_include (bool i) |
| set the include value | |
| data_t | serialize () const |
| Encode an OID object as described in RFC 2741, section 5.1. | |
| oid (data_t::const_iterator &pos, const data_t::const_iterator &end, bool big_endian=true) | |
| Construct the object from input stream. | |
| bool | operator< (const oid &o) const |
| The less-than operator. | |
| bool | operator== (const oid &o) const |
| The equal-operator. | |
| bool | operator!= (const oid &o) const |
| The not-equal-operator for oids. | |
| bool | operator> (const oid &o) const |
| The greater-than operator. | |
Private Attributes | |
| bool | include |
| the 'include' field. | |
Friends | |
| std::ostream & | operator<< (std::ostream &, const agentxcpp::oid &) |
| The output operator for the oid class. | |
Represents an SNMP object identifier (OID)
This class represents an OID. OID's are sequences of integers. This class inherits from std:vector<>, which means that an oid object can be manipulated much the same way as a std::vector<> can be manipulated.
In addition, the OID class provides constructors taking a number of integers to ease creatng such objects. For example, this works:
Also a constructor is provided which takes an oid and a number of integers, so this works also:
In addition, some common oid's are provided as constants, e.g. 'enterprises', so the following will also work:
| oid::oid | ( | uint32_t | c1 = 0, |
| uint32_t | c2 = 0, |
||
| uint32_t | c3 = 0, |
||
| uint32_t | c4 = 0, |
||
| uint32_t | c5 = 0, |
||
| uint32_t | c6 = 0, |
||
| uint32_t | c7 = 0, |
||
| uint32_t | c8 = 0, |
||
| uint32_t | c9 = 0, |
||
| uint32_t | c10 = 0, |
||
| uint32_t | c11 = 0, |
||
| uint32_t | c12 = 0, |
||
| uint32_t | c13 = 0, |
||
| uint32_t | c14 = 0, |
||
| uint32_t | c15 = 0, |
||
| uint32_t | c16 = 0, |
||
| uint32_t | c17 = 0, |
||
| uint32_t | c18 = 0, |
||
| uint32_t | c19 = 0, |
||
| uint32_t | c20 = 0 |
||
| ) |
Initialize an oid object with a sequence of up to 20 subidentifiers.
This constructor takes up to 20 subidentifiers which forms up the object identifier. More subidentifiers can be added using functions from the vector<> class.
The 'include' field is initialized to 'false'.
This is also the default constructor.
Definition at line 28 of file oid.cpp.
References include.
| oid::oid | ( | const oid & | o, |
| uint32_t | c1 = 0, |
||
| uint32_t | c2 = 0, |
||
| uint32_t | c3 = 0, |
||
| uint32_t | c4 = 0, |
||
| uint32_t | c5 = 0, |
||
| uint32_t | c6 = 0, |
||
| uint32_t | c7 = 0, |
||
| uint32_t | c8 = 0, |
||
| uint32_t | c9 = 0, |
||
| uint32_t | c10 = 0, |
||
| uint32_t | c11 = 0, |
||
| uint32_t | c12 = 0, |
||
| uint32_t | c13 = 0, |
||
| uint32_t | c14 = 0, |
||
| uint32_t | c15 = 0, |
||
| uint32_t | c16 = 0, |
||
| uint32_t | c17 = 0, |
||
| uint32_t | c18 = 0, |
||
| uint32_t | c19 = 0 |
||
| ) |
Initialize an oid object with another oid plus a sequence of up to 19 subidentifiers.
The 'include' field is copied from o.
This is also the copy constructor.
| oid::oid | ( | data_t::const_iterator & | pos, |
| const data_t::const_iterator & | end, | ||
| bool | big_endian = true |
||
| ) |
Construct the object from input stream.
This constructor parses the serialized form of the object. It takes an iterator, starts parsing at the position of the iterator and advances the iterator to the position right behind the object.
The constructor expects valid data from the stream; if parsing fails, parse_error is thrown. In this case, the iterator is left at an undefined position.
| pos | Iterator pointing to the current stream position. The iterator is advanced while reading the header. |
| end | Iterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer. |
| big_endian | Whether the input stream is in big endian format |
| parse_error | If parsing fails. In this case, the iterator is left at an undefined position. |
Definition at line 197 of file oid.cpp.
References include.
| bool agentxcpp::oid::get_include | ( | ) | [inline] |
| bool agentxcpp::oid::operator!= | ( | const oid & | o | ) | const [inline] |
The not-equal-operator for oids.
See operator<() for a more detailed description about comparing OIDs.
| bool oid::operator< | ( | const oid & | o | ) | const |
The less-than operator.
An OID is less than another OID if either the first not-identical part is lesser or if all parts are identical and it has lesser parts.
Example:
1.3.6.1.4.1.42.3.3.1
is less than
1.3.6.1.4.1.42.3.4.1
Note the next to last number.
Also,
1.3.6.1.4.1.42.3.3.1
is less than
1.3.6.1.4.1.42.3.3.1.1
because it is shorter.
However,
1.3.6.1.4.1.42.3.3.1
is greater than
1.3.6.1.4.1.42.3.2.1.1
because the 9th number is greater (although the first OID has less numbers than the second).
| bool oid::operator== | ( | const oid & | o | ) | const |
The equal-operator.
See operator<() for a more detailed description about comparing OIDs.
| bool agentxcpp::oid::operator> | ( | const oid & | o | ) | const [inline] |
The greater-than operator.
See operator<() for a more detailed description about comparing OIDs.
| data_t oid::serialize | ( | ) | const [virtual] |
Encode an OID object as described in RFC 2741, section 5.1.
Implements variable.
Definition at line 126 of file oid.cpp.
References include.
Referenced by agentxcpp::UnregisterPDU::serialize(), agentxcpp::varbind::serialize(), and agentxcpp::RegisterPDU::serialize().
| void agentxcpp::oid::set_include | ( | bool | i | ) | [inline] |
| std::ostream& operator<< | ( | std::ostream & | , |
| const agentxcpp::oid & | |||
| ) | [friend] |
The output operator for the oid class.
Object identifiers (oid objects) can be output as follows:
oid led_state(enterprise,1,3,3,1); cout << "LED state OID: " << led_state << endl;
The last line will output "LED state OID: .1.3.6.1.4.1.3.3.1".
bool agentxcpp::oid::include [private] |
the 'include' field.
Definition at line 65 of file oid.hpp.
Referenced by get_include(), oid(), operator=(), serialize(), and set_include().