A new SNMP library supporting v2c/v3 + Traps

Hi!

Here is libSNMP, a SNMP library made for Arduino. I have developed this for a client and now I am publishing my work with his consent.

Features:

  • It supports only SNMP GET and GETNEXT. Although SNMP SET is also partially implemented, it is not actually supported -because it was getting too complicated.
  • It supports single community string for v2c.
  • It supports multiple users and custom access rights for v3.
  • Traps are supported both for v2c and v3. However, some features might be missing.
  • Switching between v2c and v3 is possible during runtime.

You can download it here: GitHub - semihiseri/libSNMP: SNMP v2c/v3 Agent Library for Arduino
Documentation: Home · semihiseri/libSNMP Wiki · GitHub

I am not sure about the quality of documentation. So, feel free to post here for your questions!

Which board is this intended to compile for? You use these u_char and u_int types in auth.cpp and auth.h that make it not compile for me. Why don't you use standard types?

I tested it only on Arduino Due.

And I use uint32_t etc. because it is not platform dependent. I mean, I can be sure that it is always 32 bits. Which board do you intend to use?

semihiseri:
I tested it only on Arduino Due.

OK, that does work for me.

semihiseri:
And I use uint32_t etc. because it is not platform dependent.

But see, that's the problem. You used these non-standard types u_char and u_int, which ARE platform dependent. From libSNMP/libSNMP-example/auth.h at master · semihiseri/libSNMP · GitHub

void password_to_key_sha(
      u_char *password,    /* IN */
      u_int   passwordlen, /* IN */
      u_char *engineID,    /* IN  - pointer to snmpEngineID  */
      u_int   engineLength,/* IN  - length of snmpEngineID */
      u_char *key);         /* OUT - pointer to caller 20-octet buffer */

void password_to_key_md5(
      u_char *password,    /* IN */
      u_int   passwordlen, /* IN */
      u_char *engineID,    /* IN  - pointer to snmpEngineID  */
      u_int   engineLength,/* IN  - length of snmpEngineID */
u_char *key); /* OUT - pointer to caller 16-octet buffer */

semihiseri:
Which board do you intend to use?

I don't have a need for the library. I was going to submit a pull request but wanted to compile it after making my changes. I usually default to compiling for Uno or Mega 2560 since those are the most common Arduino boards. Of course I can compile for any board but there is no documentation that says this library only works for certain boards so I had not way to know I needed to compile for Due. Now I can proceed with the pull request.

My recommendation is that if the library will only work for certain boards to document that. Otherwise change the non-standard types to standard types so that it will compile for any board.