4 * SNMP base and support classes.
6 * Portable Windows Library
8 * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
27 * Revision 1.9 2002/11/06 22:47:25 robertj
28 * Fixed header comment (copyright etc)
30 * Revision 1.8 1998/11/30 04:52:06 robertj
31 * New directory structure
33 * Revision 1.7 1998/10/13 14:06:32 robertj
34 * Complete rewrite of memory leak detection code.
36 * Revision 1.6 1998/09/23 06:22:33 robertj
37 * Added open source copyright license.
39 * Revision 1.5 1998/01/26 02:50:17 robertj
42 * Revision 1.4 1997/07/20 08:50:04 craigs
43 * Changed var binding list to use ASN NULL rather than empty string
45 * Revision 1.3 1997/07/14 11:47:17 robertj
46 * Added "const" to numerous variables.
48 * Revision 1.2 1996/11/04 03:59:19 robertj
49 * Added selectable read buffer size.
51 * Revision 1.1 1996/09/14 13:02:18 robertj
54 * Revision 1.9 1996/05/29 10:44:51 craigs
55 * Latest version wil traps and discovery
57 * Revision 1.8 1996/05/09 13:23:49 craigs
58 * Added trap functions
60 * Revision 1.7 1996/04/23 12:12:46 craigs
61 * Changed to use GetErrorText function
63 * Revision 1.6 1996/04/16 13:20:43 craigs
64 * Final version prior to beta1 release
66 * Revision 1.5 1996/04/15 09:05:30 craigs
67 * Latest version prior to integration with Robert's changes
69 * Revision 1.4 1996/04/06 11:38:35 craigs
70 * Lots of changes - working version prior to discover changes
72 * Revision 1.3 1996/04/01 12:50:44 craigs
73 * CHanged for clean compile under NT
75 * Revision 1.2 1996/04/01 12:34:06 craigs
82 #pragma implementation "psnmp.h"
86 #include <ptclib/psnmp.h>
91 static char const * const SnmpErrorCodeTable
[] =
101 "malformed response",
107 static char const * const TrapCodeToText
[PSNMP::NumTrapTypes
] = {
118 ///////////////////////////////////////////////////////////////
120 // PSNMPVarBindingList
123 void PSNMPVarBindingList::Append(const PString
& objectID
)
125 objectIds
.AppendString(objectID
);
126 values
.Append(new PASNNull());
130 void PSNMPVarBindingList::Append(const PString
& objectID
, PASNObject
* obj
)
132 objectIds
.AppendString(objectID
);
137 void PSNMPVarBindingList::AppendString(const PString
& objectID
, const PString
& str
)
139 Append(objectID
, new PASNString(str
));
143 void PSNMPVarBindingList::RemoveAll()
145 objectIds
.RemoveAll();
150 PINDEX
PSNMPVarBindingList::GetSize() const
152 return objectIds
.GetSize();
156 PASNObject
& PSNMPVarBindingList::operator[](PINDEX idx
) const
162 PString
PSNMPVarBindingList::GetObjectID(PINDEX idx
) const
164 return objectIds
[idx
];
168 void PSNMPVarBindingList::PrintOn(ostream
& strm
) const
170 for (PINDEX i
= 0; i
< GetSize(); i
++)
177 PString
PSNMP::GetTrapTypeText(PINDEX code
)
180 if (code
>= NumTrapTypes
)
183 return TrapCodeToText
[code
];
187 PString
PSNMP::GetErrorText(ErrorType err
)
189 if (err
>= NumErrors
)
190 return "unknown error";
192 return SnmpErrorCodeTable
[err
];
196 // End Of File ///////////////////////////////////////////////////////////////