Skip to content

OID encoding / decoding issues #63

@N1IOX

Description

@N1IOX

I had noticed issues with Observium discovery, where certain requests were failing. My local copy of the library has some additional logging added to help track it down. Specifically, it was requests for LLDP-MIB, which are all under OID .1.0.8802.1.1.2

Additionally, as reported in #33, a null OID (.0.0) is needed as a response in certain cases.
It is the same underlying issue: the current code is written to reject OIDs that are not under .1.3

After studying specs and other implementations, I implemented a rewrite of the OID encoding and decoding to address this. I have also enhanced the unit tests to demonstrate / validate.

TEST_CASE( "Test OID Encoding / Decoding ", "[snmp]") {

    std::list<std::string> testOIDs {
        ".1.3.6.1.4.1.52420",
        ".1.0.8802.1.1.2.1.3.7",
        ".2.999.3",
        ".0.0",
        ".0.1.2.3",
        ".1.2.3.4",
        ".2.3.4.5"};

    std::string oidOut;
    std::vector<uint8_t> oidEncoded;

    for (auto oidIn : testOIDs) {
        REQUIRE( tryEncodeOID(oidIn, oidEncoded, leadingDotRequired) );
        REQUIRE( tryDecodeOID(oidEncoded, oidOut, leadingDotRequired) );
        REQUIRE( oidIn == oidOut );

        oidOut.clear();
        oidEncoded.clear();
    }
}

And of course, I've been running the changes on an ESP32 that's being polled by Observium every 5 minutes - all looking good. Observium is a lot happier now that it doesn't hang on LLDP discovery, and responds accordingly when I need to return ".0.0" for queries like mib2 / system / sysObjectID, etc.

Before I submit a PR for this, I kindly ask that you review the outstanding PR #62 - I'd like to see that in there, and I will then sync up my fork before creating a branch to commit the OID fix.

Please let me know if you have any questions or concerns.
Thanks!

73 de N1IOX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions