Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / ASNMP / asnmp / wpdu.h
blobbfa35adebe03c6ae0e3a8f00f94f41b6aa5fda72
1 /* -*-C++-*- */
2 #ifndef WPDU_H_
3 #define WPDU_H_
4 //=============================================================================
5 /**
6 * @file wpdu.h
8 * Adapter class. Converts a Pdu and GenTarget into a format
9 * that can be stuffed out a I/O port
11 * @author Michael R. MacFaden re-worked api
12 * @author use ACE APIPeter E Mellquist wrote original class snmpmsg
14 //=============================================================================
17 #include "ace/config-all.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "asnmp/asn1.h"
24 #include "asnmp/pdu.h"
25 #include "asnmp/target.h"
27 struct snmp_pdu;
28 /**
29 * @class wpdu
31 * @brief Implement an Adapter pattern between CMU SNMP and HP SNMP++
33 * this is an adapter class, it peforms the following transformations
34 * PDU / Target -> iovec buffer
35 * iovec buffer -> PDU / Target
37 class ASNMP_Export wpdu
39 public:
40 /// construct CMU data from HP SNMP++ objects
41 /// construct HP SNMP++ objects from raw buffer via CMU SNMP datatypes
42 wpdu(const Pdu& pdu, const UdpTarget& target);
43 wpdu(const iovec& buffer);
44 wpdu(); // same as using iovec?
46 ~wpdu();
48 /// constructor completed ok? rc = 1 else 0
49 int valid() const;
51 /// return raw data stream via CMU code
52 const iovec& get_buffer() const;
54 /// return HP SNMP++ pdu
55 int get_pdu(Pdu& pdu, snmp_version& version);
57 /// return community strptr
58 const unsigned char *get_community() const;
60 private:
61 int convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival );
62 int load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu);
63 int restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const;
64 void free_smival_descriptor( SmiVALUE *smival );
65 static void copy_iovec(iovec& dest, const iovec& src);
66 int set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const;
68 /// raw format
69 iovec iovec_;
71 /// object construction state
72 int valid_flag_;
74 /// snmp version
75 snmp_version version_;
77 unsigned char community_name[MAX_COMM_STR_LEN];
78 unsigned long comm_len; // = MAX_COMM_STR_LEN;
81 #endif // WPDU_H_