2017 © Pedro Peláez
 

library snmp-packet

SNMP packets encoder/decoder

image

dface/snmp-packet

SNMP packets encoder/decoder

  • Wednesday, January 3, 2018
  • by 3DFace
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

SnmpPacket

Note: This is an early development version., (*2)

A PHP library to encode/decode SNMP packets., (*3)

This library does not aim to implement SNMP protocol processing. It's just for decoding SNMP messages from binary strings into PHP-objects and vice versa., (*4)

Supports SNMP messages v1, v2c and v3., (*5)

Installation

composer require dface/snmp-packet, (*6)

Usage

Example of naive snmpget command can be found in ./examples/NaiveSnmpGet.php. Take a look at prepareRequest() to see how to construct/encode messages. And processResponse() to see how to decode/process them., (*7)

Simple example of message encoding:, (*8)

// construct pdu:
$bindings = new VarBindList(
   new VarBind(new Oid('1.3.6.1.2.1.1.3.0'), new NullValue())
); 
$pdu = new GetRequestPDU(1, 0, 0, $bindings);

// pack into the message:
$message = new MessageV1(1, $this->community, $pdu);

// take a binary to send it somewhere:
$bin = $message->toBinary();

Simple example of message decoding:, (*9)

// decode message from binary:
$message = MessageV1::fromBinary($bin);

// take pdu:
$pdu = $message->getPdu();

//check on errors:
$err = $pdu->getErrorStatus();

// iterate over bindings:
$bindings = $pdu->getVariableBindings()->getList();
foreach ($bindings as $var_bind) {
    printf("%s: %s\n", $var_bind->getOid(), $var_bind->getValue());
}

The Versions

03/01 2018

dev-master

9999999-dev

SNMP packets encoder/decoder

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Ponomarev

message encoder decoder snmp packet