# Unit snmpsend

Description | uses | Classes, Interfaces and Objects | Functions and Procedures | Types | Constants | Variables

## Description

SNMP client

Supports SNMPv1 include traps, SNMPv2c and SNMPv3 include authorization (encryption not yet supported!)

Used RFC: RFC-1157, RFC-1901, RFC-3412, RFC-3414, RFC-3416

## Classes, Interfaces and Objects

Name | Description
--- | ---
Class `TSNMPMib` | Data object with one record of MIB OID and corresponding values.
record `TV3Sync` | It holding all information for SNMPv3 agent synchronization
Class `TSNMPRec` | Data object abstracts SNMP data packet
Class `TSNMPSend` | Implementation of SNMP protocol.

## Functions and Procedures

### Overview

`function SNMPGet(const OID, Community, SNMPHost: AnsiString; var Value: AnsiString): Boolean;`
`function SNMPSet(const OID, Community, SNMPHost, Value: AnsiString; ValueType: Integer): Boolean;`
`function SNMPGetNext(var OID: AnsiString; const Community, SNMPHost: AnsiString; var Value: AnsiString): Boolean;`
`function SNMPGetTable(const BaseOID, Community, SNMPHost: AnsiString; const Value: TStrings): Boolean;`
`function SNMPGetTableElement(const BaseOID, RowID, ColID, Community, SNMPHost: AnsiString; var Value: AnsiString): Boolean;`
`function SendTrap(const Dest, Source, Enterprise, Community: AnsiString; Generic, Specific, Seconds: Integer; const MIBName, MIBValue: AnsiString; MIBtype: Integer): Integer;`
`function RecvTrap(var Dest, Source, Enterprise, Community: AnsiString; var Generic, Specific, Seconds: Integer; const MIBName, MIBValue: TStringList): Integer;`

### Description

`function RecvTrap(var Dest, Source, Enterprise, Community: AnsiString; var Generic, Specific, Seconds: Integer; const MIBName, MIBValue: TStringList): Integer;`

A very useful function and example of its use would be found in the TSNMPSend object. It receives a TRAPv1 and returns all the data that comes with it.

`function SendTrap(const Dest, Source, Enterprise, Community: AnsiString; Generic, Specific, Seconds: Integer; const MIBName, MIBValue: AnsiString; MIBtype: Integer): Integer;`

A very useful function and example of its use would be found in the TSNMPSend object. It implements a TRAPv1 to send with all data in the parameters.

`function SNMPGet(const OID, Community, SNMPHost: AnsiString; var Value: AnsiString): Boolean;`

A very useful function and example of its use would be found in the TSNMPSend object. It implements basic GET method of the SNMP protocol. The MIB value is located in the "OID" variable, and is sent to the requested "SNMPHost" with the proper "Community" access identifier. Upon a successful retrieval, "Value" will contain the information requested. If the SNMP operation is successful, the result returns `True`.

`function SNMPGetNext(var OID: AnsiString; const Community, SNMPHost: AnsiString; var Value: AnsiString): Boolean;`

A very useful function and example of its use would be found in the TSNMPSend object. It implements basic GETNEXT method of the SNMP protocol. The MIB value is located in the "OID" variable, and is sent to the requested "SNMPHost" with the proper "Community" access identifier. Upon a successful retrieval, "Value" will contain the information requested. If the SNMP operation is successful, the result returns `True`.

`function SNMPGetTable(const BaseOID, Community, SNMPHost: AnsiString; const Value: TStrings): Boolean;`

A very useful function and example of its use would be found in the TSNMPSend object. It implements basic read of SNMP MIB tables. As BaseOID you must specify basic MIB OID of requested table (base IOD is OID without row and column specificator!) Table is readed into stringlist, where each string is comma delimited string.

Warning: this function is not have best performance. For better performance you must write your own function. best performace you can get by knowledge of structuture of table and by more then one MIB on one query.

`function SNMPGetTableElement(const BaseOID, RowID, ColID, Community, SNMPHost: AnsiString; var Value: AnsiString): Boolean;`

A very useful function and example of its use would be found in the TSNMPSend object. It implements basic read of SNMP MIB table element. As BaseOID you must specify basic MIB OID of requested table (base IOD is OID without row and column specificator!) As next you must specify identificator of row and column for specify of needed field of table.

`function SNMPSet(const OID, Community, SNMPHost, Value: AnsiString; ValueType: Integer): Boolean;`

This is useful function and example of use TSNMPSend object. It implements the basic SET method of the SNMP protocol. If the SNMP operation is successful, the result is `True`. "Value" is value of MIB Oid for "SNMPHost" with "Community" access identifier. You must specify "ValueType" too.

## Types

Name | Description
--- | ---
TV3Flags`` | Possible values for SNMPv3 flags. This flags specify level of authorization and encryption. NoAuthNoPriv: AuthNoPriv: AuthPriv:
TV3Auth`` | Type of SNMPv3 authorization AuthMD5: AuthSHA1:

## Constants

Name | Description
--- | ---
cSnmpProtocol`= '161';` |
cSnmpTrapProtocol`= '162';` |
SNMP_V1`= 0;` |
SNMP_V2C`= 1;` |
SNMP_V3`= 3;` |
PDUGetRequest`= $A0;` |
PDUGetNextRequest`= $A1;` |
PDUGetResponse`= $A2;` |
PDUSetRequest`= $A3;` |
PDUTrap`= $A4;` |
PDUGetBulkRequest`= $A5;` |
PDUInformRequest`= $A6;` |
PDUTrapV2`= $A7;` |
PDUReport`= $A8;` |
ENoError`= 0;` |
ETooBig`= 1;` |
ENoSuchName`= 2;` |
EBadValue`= 3;` |
EReadOnly`= 4;` |
EGenErr`= 5;` |
ENoAccess`= 6;` |
EWrongType`= 7;` |
EWrongLength`= 8;` |
EWrongEncoding`= 9;` |
EWrongValue`= 10;` |
ENoCreation`= 11;` |
EInconsistentValue`= 12;` |
EResourceUnavailable`= 13;` |
ECommitFailed`= 14;` |
EUndoFailed`= 15;` |
EAuthorizationError`= 16;` |
ENotWritable`= 17;` |
EInconsistentName`= 18;` |

Generated by PasDoc 0.8.8.2 on 2005-01-19 20:01:19