Uncommented beaudio code
[pwlib.git] / src / ptclib / snmpserv.cxx
blob4af3a4b70f3898fe1ead0e7ce4a049bf590db2f8
1 /*
2 * snmpserv.cxx
4 * SNMP Server (agent) class
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.4 2002/11/06 22:47:25 robertj
28 * Fixed header comment (copyright etc)
30 * Revision 1.3 1998/11/30 04:52:09 robertj
31 * New directory structure
33 * Revision 1.2 1998/09/23 06:22:42 robertj
34 * Added open source copyright license.
36 * Revision 1.1 1996/09/14 13:02:18 robertj
37 * Initial revision
41 #include <ptlib.h>
42 #include <ptclib/psnmp.h>
45 BOOL PSNMPServer::SendGetResponse (PSNMPVarBindingList &)
47 PAssertAlways("SendGetResponse not yet implemented");
48 return GenErr;
52 void PSNMPServer::OnGetRequest (PSNMPVarBindingList &)
57 void PSNMPServer::OnGetNextRequest (PSNMPVarBindingList &)
62 void PSNMPServer::OnSetRequest (PSNMPVarBindingList &)
67 BOOL PSNMP::DecodeTrap(const PBYTEArray & readBuffer,
68 PINDEX & version,
69 PString & community,
70 PString & enterprise,
71 PIPSocket::Address & address,
72 PINDEX & genericTrapType,
73 PINDEX & specificTrapType,
74 PASNUnsigned & timeTicks,
75 PSNMPVarBindingList & varsOut)
77 // parse the response
78 PASNSequence response(readBuffer);
79 PINDEX seqLen = response.GetSize();
81 // check PDU
82 if (seqLen != 3 ||
83 response[0].GetType() != PASNObject::Integer ||
84 response[1].GetType() != PASNObject::String ||
85 response[2].GetType() != PASNObject::Choice)
86 return FALSE;
88 // check the PDU data
89 const PASNSequence & rPduData = response[2].GetSequence();
90 seqLen = rPduData.GetSize();
91 if (seqLen != 6 ||
92 rPduData.GetChoice() != Trap ||
93 rPduData[0].GetType() != PASNObject::ObjectID ||
94 rPduData[1].GetType() != PASNObject::IPAddress ||
95 rPduData[2].GetType() != PASNObject::Integer ||
96 rPduData[3].GetType() != PASNObject::Integer ||
97 rPduData[4].GetType() != PASNObject::TimeTicks ||
98 rPduData[5].GetType() != PASNObject::Sequence)
99 return FALSE;
101 version = response[0].GetInteger();
102 community = response[1].GetString();
103 enterprise = rPduData[0].GetString();
104 address = rPduData[1].GetIPAddress();
105 genericTrapType = rPduData[2].GetInteger();
106 specificTrapType = rPduData[3].GetInteger();
107 timeTicks = rPduData[4].GetUnsigned();
109 // check the variable bindings
110 const PASNSequence & rBindings = rPduData[5].GetSequence();
111 PINDEX bindingCount = rBindings.GetSize();
113 // create the return list
114 for (PINDEX i = 0; i < bindingCount; i++) {
115 if (rBindings[i].GetType() != PASNObject::Sequence)
116 return TRUE;
118 const PASNSequence & rVar = rBindings[i].GetSequence();
119 if (rVar.GetSize() != 2 ||
120 rVar[0].GetType() != PASNObject::ObjectID)
121 return TRUE;
123 varsOut.Append(rVar[0].GetString(), (PASNObject *)rVar[1].Clone());
126 return TRUE;
130 // End Of File ///////////////////////////////////////////////////////////////