SNMP 2.0.0
Loading...
Searching...
No Matches
BER.cpp
Go to the documentation of this file.
1#include "BER.h"
2
7namespace SNMP {
8
15BER* BER::create(const Type &type) {
16 switch (type) {
17 case Type::Boolean:
18 return new BooleanBER(false);
19 case Type::Integer:
20 return new IntegerBER(0);
22 return new OctetStringBER(nullptr, 0);
23 case Type::Null:
27 return new NullBER(type);
29 return new ObjectIdentifierBER(nullptr);
30 case Type::IPAddress:
31 return new IPAddressBER(IPAddress());
32 case Type::Counter32:
33 return new Counter32BER(0);
34 case Type::Gauge32:
35 return new Gauge32BER(0);
36 case Type::TimeTicks:
37 return new TimeTicksBER(0);
38 case Type::Opaque:
39 return new OpaqueBER(nullptr);
40 case Type::Counter64:
41 return new Counter64BER(0);
42 case Type::Float:
43 return new FloatBER(0);
45 return new OpaqueFloatBER(0);
46 case Type::Sequence:
51 case Type::Trap:
55 case Type::Report:
56 return new SequenceBER(type);
57 }
58 return nullptr;
59}
60
72OctetStringBER::OctetStringBER(const char *value, const uint32_t length) :
73 OctetStringBER() {
74 setValue(value, length);
75}
76
82OpaqueBER::OpaqueBER(BER *ber) :
83 BER(Type::Opaque) {
84 _ber = ber;
85 if (ber) {
86 _length = _ber->getSize();
87 }
88}
89
90} // namespace SNMP
BER * create(const Type &type)
Creates a BER of given type.
OctetStringBER(const char *value)
Creates an OctetStringBER object.
Definition BER.h:1300
@ Trap
Definition BER.h:313
@ NoSuchObject
Definition BER.h:305
@ OpaqueFloat
Definition BER.h:321
@ GetNextRequest
Definition BER.h:310
@ Gauge32
Definition BER.h:299
@ EndOfMIBView
Definition BER.h:307
@ Boolean
Definition BER.h:289
@ Sequence
Definition BER.h:295
@ GetResponse
Definition BER.h:311
@ NoSuchInstance
Definition BER.h:306
@ TimeTicks
Definition BER.h:300
@ Integer
Definition BER.h:290
@ InformRequest
Definition BER.h:316
@ SNMPv2Trap
Definition BER.h:317
@ Counter64
Definition BER.h:302
@ ObjectIdentifier
Definition BER.h:294
@ Counter32
Definition BER.h:298
@ GetRequest
Definition BER.h:309
@ GetBulkRequest
Definition BER.h:315
@ Float
Definition BER.h:303
@ Report
Definition BER.h:319
@ SetRequest
Definition BER.h:312
@ IPAddress
Definition BER.h:297
@ Null
Definition BER.h:293
@ Opaque
Definition BER.h:301
@ OctetString
Definition BER.h:292
SNMP library namespace.