/usr/include/ptclib/psnmp.h is in libpt-1.10.10-dev 1.10.10-3.1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | /*
* psnmp.h
*
* Simple Network Management Protocol classes.
*
* Portable Windows Library
*
* Copyright (c) 1993-2002 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Log: psnmp.h,v $
* Revision 1.9 2002/11/06 22:47:24 robertj
* Fixed header comment (copyright etc)
*
* Revision 1.8 2002/09/16 01:08:59 robertj
* Added #define so can select if #pragma interface/implementation is used on
* platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
*
* Revision 1.7 1999/03/09 08:01:46 robertj
* Changed comments for doc++ support (more to come).
*
* Revision 1.6 1999/02/16 08:07:10 robertj
* MSVC 6.0 compatibility changes.
*
* Revision 1.5 1998/11/30 02:50:55 robertj
* New directory structure
*
* Revision 1.4 1998/09/23 06:27:38 robertj
* Added open source copyright license.
*
* Revision 1.3 1996/11/04 03:56:16 robertj
* Added selectable read buffer size.
*
* Revision 1.2 1996/09/20 12:19:36 robertj
* Used read timeout instead of member variable.
*
* Revision 1.1 1996/09/14 12:58:57 robertj
* Initial revision
*
* Revision 1.6 1996/05/09 13:23:49 craigs
* Added trap functions
*
* Revision 1.5 1996/04/23 12:12:46 craigs
* Changed to use GetErrorText function
*
* Revision 1.4 1996/04/16 13:20:43 craigs
* Final version prior to beta1 release
*
* Revision 1.3 1996/04/15 09:05:30 craigs
* Latest version prior to integration with Robert's changes
*
* Revision 1.2 1996/04/01 12:36:12 craigs
* Fixed RCS header, added IPAddress functions
*
* Revision 1.1 1996/03/02 06:49:51 craigs
* Initial revision
*
*/
#ifndef _PSNMP_H
#define _PSNMP_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptlib/sockets.h>
#include <ptclib/pasn.h>
//////////////////////////////////////////////////////////////////////////
/** A list of object IDs and their values
*/
class PSNMPVarBindingList : public PObject
{
PCLASSINFO(PSNMPVarBindingList, PObject)
public:
void Append(const PString & objectID);
void Append(const PString & objectID, PASNObject * obj);
void AppendString(const PString & objectID, const PString & str);
void RemoveAll();
PINDEX GetSize() const;
PString GetObjectID(PINDEX idx) const;
PASNObject & operator[](PINDEX idx) const;
void PrintOn(ostream & strm) const;
protected:
PStringList objectIds;
PASNObjectList values;
};
//////////////////////////////////////////////////////////////////////////
/** A descendant of PUDPSocket which can perform SNMP calls
*/
class PSNMP : public PIndirectChannel
{
PCLASSINFO(PSNMP, PIndirectChannel)
public:
enum ErrorType {
// Standard RFC1157 errors
NoError = 0,
TooBig = 1,
NoSuchName = 2,
BadValue = 3,
ReadOnly = 4,
GenErr = 5,
// Additional errors
NoResponse,
MalformedResponse,
SendFailed,
RxBufferTooSmall,
TxDataTooBig,
NumErrors
};
enum RequestType {
GetRequest = 0,
GetNextRequest = 1,
GetResponse = 2,
SetRequest = 3,
Trap = 4,
};
enum { TrapPort = 162 };
enum TrapType {
ColdStart = 0,
WarmStart = 1,
LinkDown = 2,
LinkUp = 3,
AuthenticationFailure = 4,
EGPNeighbourLoss = 5,
EnterpriseSpecific = 6,
NumTrapTypes
};
static PString GetErrorText(ErrorType err);
static PString GetTrapTypeText(PINDEX code);
static void SendEnterpriseTrap (
const PIPSocket::Address & addr,
const PString & community,
const PString & enterprise,
PINDEX specificTrap,
PASNUnsigned timeTicks,
WORD sendPort = TrapPort);
static void SendEnterpriseTrap (
const PIPSocket::Address & addr,
const PString & community,
const PString & enterprise,
PINDEX specificTrap,
PASNUnsigned timeTicks,
const PSNMPVarBindingList & vars,
WORD sendPort = TrapPort);
static void SendTrap (
const PIPSocket::Address & addr,
PSNMP::TrapType trapType,
const PString & community,
const PString & enterprise,
PINDEX specificTrap,
PASNUnsigned timeTicks,
const PSNMPVarBindingList & vars,
WORD sendPort = TrapPort);
static void SendTrap (
const PIPSocket::Address & addr,
PSNMP::TrapType trapType,
const PString & community,
const PString & enterprise,
PINDEX specificTrap,
PASNUnsigned timeTicks,
const PSNMPVarBindingList & vars,
const PIPSocket::Address & agentAddress,
WORD sendPort = TrapPort);
static void WriteTrap ( PChannel & channel,
PSNMP::TrapType trapType,
const PString & community,
const PString & enterprise,
PINDEX specificTrap,
PASNUnsigned timeTicks,
const PSNMPVarBindingList & vars,
const PIPSocket::Address & agentAddress);
static BOOL DecodeTrap(const PBYTEArray & readBuffer,
PINDEX & version,
PString & community,
PString & enterprise,
PIPSocket::Address & address,
PINDEX & genericTrapType,
PINDEX & specificTrapType,
PASNUnsigned & timeTicks,
PSNMPVarBindingList & varsOut);
};
//////////////////////////////////////////////////////////////////////////
/** Class which gets SNMP data
*/
class PSNMPClient : public PSNMP
{
PCLASSINFO(PSNMPClient, PSNMP)
public:
PSNMPClient(const PString & host,
PINDEX retryMax = 5,
PINDEX timeoutMax = 5,
PINDEX rxBufferSize = 1500,
PINDEX txSize = 484);
PSNMPClient(PINDEX retryMax = 5,
PINDEX timeoutMax = 5,
PINDEX rxBufferSize = 1500,
PINDEX txSize = 484);
void SetVersion(PASNInt version);
PASNInt GetVersion() const;
void SetCommunity(const PString & str);
PString GetCommunity() const;
void SetRequestID(PASNInt requestID);
PASNInt GetRequestID() const;
BOOL WriteGetRequest (PSNMPVarBindingList & varsIn,
PSNMPVarBindingList & varsOut);
BOOL WriteGetNextRequest (PSNMPVarBindingList & varsIn,
PSNMPVarBindingList & varsOut);
BOOL WriteSetRequest (PSNMPVarBindingList & varsIn,
PSNMPVarBindingList & varsOut);
ErrorType GetLastErrorCode() const;
PINDEX GetLastErrorIndex() const;
PString GetLastErrorText() const;
protected:
BOOL WriteRequest (PASNInt requestCode,
PSNMPVarBindingList & varsIn,
PSNMPVarBindingList & varsOut);
BOOL ReadRequest(PBYTEArray & readBuffer);
PString hostName;
PString community;
PASNInt requestId;
PASNInt version;
PINDEX retryMax;
PINDEX lastErrorIndex;
ErrorType lastErrorCode;
PBYTEArray readBuffer;
PINDEX maxRxSize;
PINDEX maxTxSize;
};
//////////////////////////////////////////////////////////////////////////
/** Class which supplies SNMP data
*/
class PSNMPServer : public PSNMP
{
PCLASSINFO(PSNMPServer, PSNMP)
public:
virtual void OnGetRequest (PSNMPVarBindingList & vars);
virtual void OnGetNextRequest (PSNMPVarBindingList & vars);
virtual void OnSetRequest (PSNMPVarBindingList & vars);
BOOL SendGetResponse (PSNMPVarBindingList & vars);
};
#endif
// End of File.
|