Added IsSupportingRTP function to simplify detecting when STUN supports RTP
[pwlib.git] / src / ptclib / psnmp.cxx
blobecff4f4a6ca626e35dea476a6cb8b88000c46f4f
1 /*
2 * psnmp.cxx
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
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
26 * $Log$
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
40 * GNU Support
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
52 * Initial revision
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
76 * Added RCS header
81 #ifdef __GNUC__
82 #pragma implementation "psnmp.h"
83 #endif
85 #include <ptlib.h>
86 #include <ptclib/psnmp.h>
88 #define new PNEW
91 static char const * const SnmpErrorCodeTable[] =
93 "no error",
94 "too big",
95 "no such name",
96 "bad value",
97 "read only",
98 "gen err",
100 "no response",
101 "malformed response",
102 "send failed",
103 "rx buff too small",
104 "tx data too big"
107 static char const * const TrapCodeToText[PSNMP::NumTrapTypes] = {
108 "Cold Start",
109 "Warm Start",
110 "Link Down",
111 "Link Up",
112 "Auth Fail",
113 "EGP Loss",
114 "Enterprise"
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);
133 values.Append(obj);
137 void PSNMPVarBindingList::AppendString(const PString & objectID, const PString & str)
139 Append(objectID, new PASNString(str));
143 void PSNMPVarBindingList::RemoveAll()
145 objectIds.RemoveAll();
146 values.RemoveAll();
150 PINDEX PSNMPVarBindingList::GetSize() const
152 return objectIds.GetSize();
156 PASNObject & PSNMPVarBindingList::operator[](PINDEX idx) const
158 return values[idx];
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++)
171 strm << objectIds[i]
172 << " = "
173 << values[i];
177 PString PSNMP::GetTrapTypeText(PINDEX code)
179 PString str;
180 if (code >= NumTrapTypes)
181 return "Unknown";
182 else
183 return TrapCodeToText[code];
187 PString PSNMP::GetErrorText(ErrorType err)
189 if (err >= NumErrors)
190 return "unknown error";
191 else
192 return SnmpErrorCodeTable[err];
196 // End Of File ///////////////////////////////////////////////////////////////