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
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.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
42 #include <ptclib/psnmp.h>
45 BOOL
PSNMPServer::SendGetResponse (PSNMPVarBindingList
&)
47 PAssertAlways("SendGetResponse not yet implemented");
52 void PSNMPServer::OnGetRequest (PSNMPVarBindingList
&)
57 void PSNMPServer::OnGetNextRequest (PSNMPVarBindingList
&)
62 void PSNMPServer::OnSetRequest (PSNMPVarBindingList
&)
67 BOOL
PSNMP::DecodeTrap(const PBYTEArray
& readBuffer
,
71 PIPSocket::Address
& address
,
72 PINDEX
& genericTrapType
,
73 PINDEX
& specificTrapType
,
74 PASNUnsigned
& timeTicks
,
75 PSNMPVarBindingList
& varsOut
)
78 PASNSequence
response(readBuffer
);
79 PINDEX seqLen
= response
.GetSize();
83 response
[0].GetType() != PASNObject::Integer
||
84 response
[1].GetType() != PASNObject::String
||
85 response
[2].GetType() != PASNObject::Choice
)
89 const PASNSequence
& rPduData
= response
[2].GetSequence();
90 seqLen
= rPduData
.GetSize();
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
)
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
)
118 const PASNSequence
& rVar
= rBindings
[i
].GetSequence();
119 if (rVar
.GetSize() != 2 ||
120 rVar
[0].GetType() != PASNObject::ObjectID
)
123 varsOut
.Append(rVar
[0].GetString(), (PASNObject
*)rVar
[1].Clone());
130 // End Of File ///////////////////////////////////////////////////////////////