4 #include "exception.hpp"
5 #include "numericoid.hpp"
8 #include <condition_variable>
14 namespace dangerous {
namespace snmp {
66 typedef std::function<bool(const NumericOid& oid, Variant& value)>
GetFunction;
76 typedef std::function<bool(const NumericOid& oid, NumericOid& nextOid, Variant& value)>
GetNextFunction;
309 std::map< uint32_t, std::unique_ptr<AgentxPacket> >
inbox;
365 void rawRead( AgentxPacket& packet );
372 void rawWrite( AgentxPacket& packet );
This registration is for an instance of a table-based OID.
Definition: agentx.hpp:85
void uri(const std::string &uri)
This sets the URI for the client.
GetFunction getFunction
This function will be called when the value of the OID is requested.
Definition: agentx.hpp:105
OidRegistrationEntry()
Constructor.
Definition: agentx.hpp:93
void removeAgentCapabilities(const NumericOid &oid)
This removes a previously registered capability.
std::thread mailboxThread
This is the thread that runs the main loop for handling the mailbox.
Definition: agentx.hpp:315
static const uint8_t DEFAULT_PRIORITY
This is the default value for the "priority" of an OID registered with the "Register" PDU...
Definition: agentx.hpp:41
A Variant defines an arbitrary value (within the scope of SNMP).
Definition: variant.hpp:78
An AgentX represents an AgentX sub-agent.
Definition: agentx.hpp:37
uint32_t sessionId
This is the session ID, as given by the master agent.
Definition: agentx.hpp:290
void registerOid(const NumericOid &oid, const OidRegistrationEntry &entry)
This registers a new OID.
The Transport class represents an abstraction of the transport mechanism behind SNMP.
Definition: transport.hpp:24
void raw_removeAgentCapabilities(const NumericOid &oid)
This sends a "RemoveAgentCaps" PDU to the master agent.
A Dangerous SNMP "Context" is the backing for the rest of the Dangerous SNMP libraries.
Definition: context.hpp:18
std::map< NumericOid, OidRegistrationEntry > OidRegistrationMap
An OidRegistrationMap maps an OID to its registration entry.
Definition: agentx.hpp:337
void addAgentCapabilities(const NumericOid &oid, const std::string &description)
This adds a new capability for the agent.
void mailboxMain()
This is the main loop for the mailbox thread.
GetNextFunction getNextFunction
This function will be called when the next OID is requested.
Definition: agentx.hpp:108
OidRegistrationMap oidRegistrationMap
This is the mapping of an OID to its registration entry.
Definition: agentx.hpp:343
void open()
This connects the agent to the master agent.
std::string description() const
This returns the description for the agent.
Definition: agentx.hpp:171
std::unique_ptr< Transport > transport
This is a pointer to the "Transport" instance that will be used to communicate with the AgentX "maste...
Definition: agentx.hpp:283
void raw_addAgentCapabilities(const NumericOid &oid, const std::string &description)
This sends an "AddAgentCaps" PDU to the master agent.
A NumericOid represents an "true" OID; that is, one identified by a series of integers (as opposed to...
Definition: numericoid.hpp:22
AgentX(const Context &context)
Constructor.
std::function< bool(const NumericOid &oid, NumericOid &nextOid, Variant &value)> GetNextFunction
The GetNextFunction is called when the next OID is requested.
Definition: agentx.hpp:76
uint32_t id
TODO: THIS IS NOT REALLY USED ANYWHERE.
Definition: agentx.hpp:266
void startMailboxThread()
This starts the mailbox thread, if it has not already been started.
uint8_t priority
This is the priority of the OID.
Definition: agentx.hpp:93
void rawRead(AgentxPacket &packet)
This reads an AgentxPacket from the transport.
void identifier(const NumericOid &oid)
This sets the identifier OID for the agent.
Definition: agentx.hpp:151
std::mutex readMutex
This is the read mutex used for guaranteeing that only a single thread is working with the inbox for ...
Definition: agentx.hpp:298
NumericOid _identifier
This is the OID that identifies the Agent; each Agent should have a unique identifying OID...
Definition: agentx.hpp:276
void raw_registerTree(const NumericOid &oid, uint8_t priority=DEFAULT_PRIORITY)
This sends a "Register" PDU to the master agent.
virtual ~AgentX()
Destructor.
std::function< bool(const NumericOid &oid, Variant &value)> GetFunction
The GetFunction is called when the value of an OID is requested.
Definition: agentx.hpp:66
Type
This represents the kind of OID that is being registered.
Definition: agentx.hpp:81
std::string _description
This is the description of the Agent.
Definition: agentx.hpp:278
This defines the base exception class for Dangerous SNMP.
Definition: exception.hpp:10
std::condition_variable readConditionVariable
This is used to notify any waiting threads when a new packet is available from the inbox...
Definition: agentx.hpp:301
Type type
This is the type of registration TODO TODO TODO.
Definition: agentx.hpp:102
std::map< uint32_t, std::unique_ptr< AgentxPacket > > inbox
This represents an "inbox" of packets received from the master agent.
Definition: agentx.hpp:309
NumericOid identifier() const
This returns the identifier OID for the agent.
Definition: agentx.hpp:157
This registration is for an individual OID.
Definition: agentx.hpp:83
std::weak_ptr< Context::PrivateData > context
This is a weak pointer to the Context.
Definition: agentx.hpp:271
void rawWrite(AgentxPacket &packet)
This writes an AgentxPacket to the transport.
uint32_t packetNumber
This is a counter that is incremented for each packet sent by this agent.
Definition: agentx.hpp:287
This represents a parse-error event.
Definition: exception.hpp:135
std::mutex writeMutex
This is the write mutex used for guaranteeing that only a single thread is speaking for this agent at...
Definition: agentx.hpp:305
void stopMailboxThread()
This stops the mailbox thread, if it has not already been stopped.
This represents an unknown transport event.
Definition: exception.hpp:173
An OidRegistrationEntry represents an OID that has been registered.
Definition: agentx.hpp:57
void close()
This disconnects the agent from the master agent.
void description(const std::string &text)
This sets the description for the agent.
Definition: agentx.hpp:164
This registration is for a tree; it will handle all OIDs under the given one.
Definition: agentx.hpp:87
CapabilityMap capabilityMap
This is the mapping of capability OID to its description; these are created by adding a new "capabili...
Definition: agentx.hpp:328
bool isStopped
This is whether or not the mailbox thread is "stopped"; if the thread has not been started...
Definition: agentx.hpp:313
void raw_registerOid(const NumericOid &oid, uint8_t priority=DEFAULT_PRIORITY)
This sends a "Register" PDU to the master agent with a flag signifying "instance" registration...
OidRegistrationMap::const_iterator registrationThatCovers(const NumericOid &oid)
This returns the "oidRegistrationMap" iterator whose entry would be responsible for the OID given...
std::map< NumericOid, std::string > CapabilityMap
A CapabilityMap maps an OID to a string.
Definition: agentx.hpp:324
void mailboxRead(AgentxPacket &packet, uint32_t packetId)
This attempts to obtain the packet, with the specified ID, from the mailbox.
A ValueEntry represents an OID's value.
Definition: agentx.hpp:260
Variant value
This is the value of the OID.
Definition: agentx.hpp:263