00001
00002
00003
00004
00005
00006
00007 #ifdef P_SNMP
00008
00009 #ifndef __PSNMP_H
00010 #define __PSNMP_H
00011
00012 #ifdef P_USE_PRAGMA
00013 #pragma interface
00014 #endif
00015
00016 #include <ptclib/asner.h>
00017 #include <ptclib/rfc1155.h>
00018
00019
00020
00021
00022
00023
00024 class PSNMP_GetRequest_PDU;
00025 class PSNMP_GetNextRequest_PDU;
00026 class PSNMP_GetResponse_PDU;
00027 class PSNMP_SetRequest_PDU;
00028 class PSNMP_Trap_PDU;
00029
00030 class PSNMP_PDUs : public PASN_Choice
00031 {
00032 #ifndef PASN_LEANANDMEAN
00033 PCLASSINFO(PSNMP_PDUs, PASN_Choice);
00034 #endif
00035 public:
00036 PSNMP_PDUs(unsigned tag = 0, TagClass tagClass = UniversalTagClass);
00037
00038 enum Choices {
00039 e_get_request,
00040 e_get_next_request,
00041 e_get_response,
00042 e_set_request,
00043 e_trap
00044 };
00045
00046 #if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9
00047 operator PSNMP_GetRequest_PDU &() const;
00048 #else
00049 operator PSNMP_GetRequest_PDU &();
00050 operator const PSNMP_GetRequest_PDU &() const;
00051 #endif
00052 #if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9
00053 operator PSNMP_GetNextRequest_PDU &() const;
00054 #else
00055 operator PSNMP_GetNextRequest_PDU &();
00056 operator const PSNMP_GetNextRequest_PDU &() const;
00057 #endif
00058 #if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9
00059 operator PSNMP_GetResponse_PDU &() const;
00060 #else
00061 operator PSNMP_GetResponse_PDU &();
00062 operator const PSNMP_GetResponse_PDU &() const;
00063 #endif
00064 #if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9
00065 operator PSNMP_SetRequest_PDU &() const;
00066 #else
00067 operator PSNMP_SetRequest_PDU &();
00068 operator const PSNMP_SetRequest_PDU &() const;
00069 #endif
00070 #if defined(__GNUC__) && __GNUC__ <= 2 && __GNUC_MINOR__ < 9
00071 operator PSNMP_Trap_PDU &() const;
00072 #else
00073 operator PSNMP_Trap_PDU &();
00074 operator const PSNMP_Trap_PDU &() const;
00075 #endif
00076
00077 virtual PBoolean Decode(PASN_Stream & strm);
00078 virtual void Encode(PASN_Stream & strm) const;
00079
00080 PBoolean CreateObject();
00081 PObject * Clone() const;
00082 };
00083
00084
00085
00086
00087
00088
00089 class PSNMP_VarBind : public PASN_Sequence
00090 {
00091 #ifndef PASN_LEANANDMEAN
00092 PCLASSINFO(PSNMP_VarBind, PASN_Sequence);
00093 #endif
00094 public:
00095 PSNMP_VarBind(unsigned tag = UniversalSequence, TagClass tagClass = UniversalTagClass);
00096
00097 PRFC1155_ObjectName m_name;
00098 PRFC1155_ObjectSyntax m_value;
00099
00100 PINDEX GetDataLength() const;
00101 PBoolean Decode(PASN_Stream & strm);
00102 void Encode(PASN_Stream & strm) const;
00103 #ifndef PASN_NOPRINTON
00104 void PrintOn(ostream & strm) const;
00105 #endif
00106 Comparison Compare(const PObject & obj) const;
00107 PObject * Clone() const;
00108 };
00109
00110
00111
00112
00113
00114
00115 class PSNMP_VarBind;
00116
00117 class PSNMP_VarBindList : public PASN_Array
00118 {
00119 #ifndef PASN_LEANANDMEAN
00120 PCLASSINFO(PSNMP_VarBindList, PASN_Array);
00121 #endif
00122 public:
00123 PSNMP_VarBindList(unsigned tag = UniversalSequence, TagClass tagClass = UniversalTagClass);
00124
00125 PASN_Object * CreateObject() const;
00126 PSNMP_VarBind & operator[](PINDEX i) const;
00127 PObject * Clone() const;
00128 };
00129
00130
00131
00132
00133
00134
00135 class PSNMP_PDU : public PASN_Sequence
00136 {
00137 #ifndef PASN_LEANANDMEAN
00138 PCLASSINFO(PSNMP_PDU, PASN_Sequence);
00139 #endif
00140 public:
00141 PSNMP_PDU(unsigned tag = UniversalSequence, TagClass tagClass = UniversalTagClass);
00142
00143 PASN_Integer m_request_id;
00144 PASN_Integer m_error_status;
00145 PASN_Integer m_error_index;
00146 PSNMP_VarBindList m_variable_bindings;
00147
00148 PINDEX GetDataLength() const;
00149 PBoolean Decode(PASN_Stream & strm);
00150 void Encode(PASN_Stream & strm) const;
00151 #ifndef PASN_NOPRINTON
00152 void PrintOn(ostream & strm) const;
00153 #endif
00154 Comparison Compare(const PObject & obj) const;
00155 PObject * Clone() const;
00156 };
00157
00158
00159
00160
00161
00162
00163 class PSNMP_Trap_PDU : public PASN_Sequence
00164 {
00165 #ifndef PASN_LEANANDMEAN
00166 PCLASSINFO(PSNMP_Trap_PDU, PASN_Sequence);
00167 #endif
00168 public:
00169 PSNMP_Trap_PDU(unsigned tag = 4, TagClass tagClass = ContextSpecificTagClass);
00170
00171 PASN_ObjectId m_enterprise;
00172 PRFC1155_NetworkAddress m_agent_addr;
00173 PASN_Integer m_generic_trap;
00174 PASN_Integer m_specific_trap;
00175 PRFC1155_TimeTicks m_time_stamp;
00176 PSNMP_VarBindList m_variable_bindings;
00177
00178 PINDEX GetDataLength() const;
00179 PBoolean Decode(PASN_Stream & strm);
00180 void Encode(PASN_Stream & strm) const;
00181 #ifndef PASN_NOPRINTON
00182 void PrintOn(ostream & strm) const;
00183 #endif
00184 Comparison Compare(const PObject & obj) const;
00185 PObject * Clone() const;
00186 };
00187
00188
00189
00190
00191
00192
00193 class PSNMP_GetRequest_PDU : public PSNMP_PDU
00194 {
00195 #ifndef PASN_LEANANDMEAN
00196 PCLASSINFO(PSNMP_GetRequest_PDU, PSNMP_PDU);
00197 #endif
00198 public:
00199 PSNMP_GetRequest_PDU(unsigned tag = 0, TagClass tagClass = ContextSpecificTagClass);
00200
00201 PObject * Clone() const;
00202 };
00203
00204
00205
00206
00207
00208
00209 class PSNMP_GetNextRequest_PDU : public PSNMP_PDU
00210 {
00211 #ifndef PASN_LEANANDMEAN
00212 PCLASSINFO(PSNMP_GetNextRequest_PDU, PSNMP_PDU);
00213 #endif
00214 public:
00215 PSNMP_GetNextRequest_PDU(unsigned tag = 1, TagClass tagClass = ContextSpecificTagClass);
00216
00217 PObject * Clone() const;
00218 };
00219
00220
00221
00222
00223
00224
00225 class PSNMP_GetResponse_PDU : public PSNMP_PDU
00226 {
00227 #ifndef PASN_LEANANDMEAN
00228 PCLASSINFO(PSNMP_GetResponse_PDU, PSNMP_PDU);
00229 #endif
00230 public:
00231 PSNMP_GetResponse_PDU(unsigned tag = 2, TagClass tagClass = ContextSpecificTagClass);
00232
00233 PObject * Clone() const;
00234 };
00235
00236
00237
00238
00239
00240
00241 class PSNMP_SetRequest_PDU : public PSNMP_PDU
00242 {
00243 #ifndef PASN_LEANANDMEAN
00244 PCLASSINFO(PSNMP_SetRequest_PDU, PSNMP_PDU);
00245 #endif
00246 public:
00247 PSNMP_SetRequest_PDU(unsigned tag = 3, TagClass tagClass = ContextSpecificTagClass);
00248
00249 PObject * Clone() const;
00250 };
00251
00252
00253
00254
00255
00256
00257 class PSNMP_Message : public PASN_Sequence
00258 {
00259 #ifndef PASN_LEANANDMEAN
00260 PCLASSINFO(PSNMP_Message, PASN_Sequence);
00261 #endif
00262 public:
00263 PSNMP_Message(unsigned tag = UniversalSequence, TagClass tagClass = UniversalTagClass);
00264
00265 PASN_Integer m_version;
00266 PASN_OctetString m_community;
00267 PSNMP_PDUs m_pdu;
00268 PASN_OctetString m_data;
00269
00270 PINDEX GetDataLength() const;
00271 PBoolean Decode(PASN_Stream & strm);
00272 void Encode(PASN_Stream & strm) const;
00273 #ifndef PASN_NOPRINTON
00274 void PrintOn(ostream & strm) const;
00275 #endif
00276 Comparison Compare(const PObject & obj) const;
00277 PObject * Clone() const;
00278 };
00279
00280
00281 #endif // __PSNMP_H
00282
00283 #endif // if ! H323_DISABLE_PSNMP
00284
00285
00286