AGENT++  4.0.3
mib_proxy.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## AGENT++ 4.0 - mib_proxy.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 #ifndef mib_proxy_h_
22 #define mib_proxy_h_
23 
24 #include <agent_pp/agent++.h>
25 #include <agent_pp/mib.h>
26 #ifdef _SNMPv3
29 #endif
30 
31 #ifndef _PROXY_FORWARDER
32 
33 #ifdef AGENTPP_NAMESPACE
34 namespace Agentpp {
35 #endif
36 
37 /*--------------------------- class MibProxy -----------------------------*/
38 
57 
58 public:
62  MibProxy();
63 
70  MibProxy(const MibProxy& other);
71 
83  MibProxy(const Oidx&, mib_access, const NS_SNMP UdpAddress&);
84 
102  MibProxy(const Oidx&, mib_access, const Oidx&, const NS_SNMP UdpAddress&);
103 
107  virtual ~MibProxy() { }
108 
115  virtual mib_type type() const { return AGENTPP_PROXY; }
116 
123  virtual MibEntry* clone() { return new MibProxy(*this); }
124 
133  virtual OidxPtr max_key();
134 
150  virtual Oidx find_succ(const Oidx&, Request* r = 0);
151 
158  virtual bool is_empty()
159  { return ((find_succ(*key()).len() == 0) ||
160  (lastNext.get_oid() >= *max_key()));}
161 
162  virtual void get_request(Request*, int);
163  virtual int commit_set_request(Request*, int);
164  virtual int prepare_set_request(Request*, int&);
165  virtual void get_next_request(Request*, int);
166 
177  void set_community(access_types a,
178  const NS_SNMP OctetStr& c)
179  { community[a] = c; }
180 
181 protected:
182  virtual Oidx translate(const Oidx&);
183  virtual Oidx backward_translate(const Oidx&);
184 
185  void determineDefaultRange(const Oidx&);
186 
187  NS_SNMP UdpAddress source;
190 
191  NS_SNMP OctetStr community[WRITING+1];
192 
194 
197 };
198 
199 #ifdef _SNMPv3
200 
201 /*--------------------------- class MibProxyV3 -----------------------------*/
202 
220 class AGENTPP_DECL MibProxyV3: public MibEntry {
221 
222 public:
226  MibProxyV3(const Oidx&, mib_access);
227 
234  MibProxyV3(const MibProxyV3& other);
235 
247  MibProxyV3(snmpProxyEntry*, const Oidx&, mib_access);
248 
256  MibProxyV3(const NS_SNMP OctetStr&);
257 
261  virtual ~MibProxyV3() { }
262 
269  virtual mib_type type() const { return AGENTPP_PROXY; }
270 
277  virtual MibEntry* clone() { return new MibProxyV3(*this); }
278 
287  virtual OidxPtr max_key();
288 
304  virtual Oidx find_succ(const Oidx&, Request* r = 0);
305 
306  virtual void get_request(Request*, int);
307  virtual int commit_set_request(Request*, int);
308  virtual int prepare_set_request(Request*, int&);
309  virtual void get_next_request(Request*, int);
310 
311 
312 protected:
313 
314  OidList<MibTableRow>* get_matches(Request*);
315  bool match_target_params(Request*, const NS_SNMP OctetStr&);
316  int process_single(Pdux&, Request*);
317 
318  void check_references();
319  void determineDefaultRange(const Oidx&);
320 
321  snmpProxyEntry* myProxyInfo;
322 
323  Oidx range;
324 
325  Vbx lastNext;
326  int lastNextStatus;
327 };
328 
329 #ifdef AGENTPP_NAMESPACE
330 }
331 #endif
332 
333 #endif
334 
335 #endif
336 #endif