FreeDSx / SNMP

A Pure PHP SNMP Library.
MIT License
57 stars 13 forks source link

Counter64 Values Can Exceed the PHP Max Int Value #1

Closed ChadSikorra closed 5 years ago

ChadSikorra commented 5 years ago

The PHP max int is limited to the 64 bit signed integer value of 9,223,372,036,854,775,807. However, the Counter64 value of SNMP can be the maximum value of a 64 bit unsigned integer, which is 18,446,744,073,709,551,615.

This presents a real issue with integer type hinting across FreeDSx libraries. This will need to be solved in the ASN.1 library than decide how to handle it elsewhere.

ChadSikorra commented 5 years ago

Added support for arbitrary-precision in the Integer/Enumerated ASN.1 types with this commit: https://github.com/FreeDSx/ASN1/commit/eb1d0c3e3696b12162f3498f2354057cddfa63f7. I will need to tag a new release there, modify the BigCounter class here, and adjust the composer requirements / suggests.

BigCounters were introduced with SNMPv2, so GMP should only be suggested here and not required. An encoding exception will be thrown explaining the need for GMP if a bigint is encountered.

ChadSikorra commented 5 years ago

Resolved. The composer file has been adjusted and a note marked on the README regarding this.