AGENT++  4.0.3
snmp_request.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## AGENT++ 4.0 - snmp_request.h
4  _##
5  _## Copyright (C) 2000-2013 Frank Fock and Jochen Katz (agentpp.com)
6  _##
7  _## Licensed under the Apache License, Version 2.0 (the "License");
8  _## you may not use this file except in compliance with the License.
9  _## You may obtain a copy of the License at
10  _##
11  _## http://www.apache.org/licenses/LICENSE-2.0
12  _##
13  _## Unless required by applicable law or agreed to in writing, software
14  _## distributed under the License is distributed on an "AS IS" BASIS,
15  _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  _## See the License for the specific language governing permissions and
17  _## limitations under the License.
18  _##
19  _##########################################################################*/
20 
21 
22 #ifndef snmp_request_h_
23 #define snmp_request_h_
24 
25 #include <snmp_pp/snmperrs.h>
26 #include <snmp_pp/address.h>
27 #include <snmp_pp/target.h>
28 #include <agent_pp/snmp_pp_ext.h>
29 #include <snmp_pp/snmp_pp.h>
30 
31 #define MIN_REQUEST_ID 10000
32 #define DEFAULT_RETRIES 1
33 #define DEFAULT_TIMEOUT 900
34 
35 #ifdef AGENTPP_NAMESPACE
36 namespace Agentpp {
37 #endif
38 
39 
41 
42  public:
43  InformInfo(NS_SNMP CTarget&, Vbx*, int, const Oidx&);
44  ~InformInfo();
45 
46  NS_SNMP CTarget target;
47  Vbx* vbs;
48  int sz;
50 };
51 
52 
54  friend class SnmpRequestV3;
55 public:
56  static int process(int, const NS_SNMP UdpAddress&, Vbx*, int& sz, Vbx*, int&,
57  const NS_SNMP OctetStr&, const int=0, const int=0);
58  static int process_trap(NS_SNMP SnmpTarget&, Vbx*, int sz,
59  const Oidx&, const Oidx&, bool = FALSE);
60 
61  static int get (const NS_SNMP UdpAddress&, Vbx*, int sz, int&);
62  static int next(const NS_SNMP UdpAddress&, Vbx*, int sz, int&);
63  static int getbulk(const NS_SNMP UdpAddress&, Vbx*, int& sz, Vbx*, int&,
64  const int, const int);
65  static int set (const NS_SNMP UdpAddress&, Vbx*, int sz, int&);
66 
67  static int get (const NS_SNMP UdpAddress&, Vbx*, int sz, int&, const NS_SNMP OctetStr&);
68  static int next(const NS_SNMP UdpAddress&, Vbx*, int sz, int&, const NS_SNMP OctetStr&);
69  static int getbulk(const NS_SNMP UdpAddress&, Vbx*, int& sz, Vbx*, int&,
70  const NS_SNMP OctetStr&, const int, const int);
71  static int gettable(const NS_SNMP UdpAddress&, Vbx*, int sz, Vbx*, int&,
72  const NS_SNMP OctetStr&, const int);
73  static int set (const NS_SNMP UdpAddress&, Vbx*, int sz, int&, const NS_SNMP OctetStr&);
74 
75  static int trap(NS_SNMP SnmpTarget&, Vbx*, int sz, const Oidx&, const Oidx&);
76  static void inform(NS_SNMP CTarget&, Vbx*, int sz, const Oidx&);
77 
78  protected:
79  static Snmpx *get_new_snmp(int &status);
80 };
81 
82 #ifdef _SNMPv3
83 
92 class AGENTPP_DECL SnmpRequestV3 {
93 
94  public:
102  SnmpRequestV3();
106  ~SnmpRequestV3();
107 
120  static int send(NS_SNMP UTarget&, Pdux&);
121 
136  int send_request(NS_SNMP UTarget&, Pdux&,
137  const int non_repeaters = 0, const int repetitions = 0);
138 
139  protected:
140 
141  Snmpx* snmp;
142 };
143 #endif
144 #ifdef AGENTPP_NAMESPACE
145 }
146 #endif
147 #endif