clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
216 stars 71 forks source link

SNMP bits support #491

Closed mico-micic closed 6 months ago

mico-micic commented 8 months ago

Add support for SNMP "bits" data type (Feature Request #411)

@olofhagsand: May I ask you to take a look at this pull request and give me some hints on how to improve it? Currently there are no unit tests, I will write them later. So my intention is not to merge this request now, but to get feedback on whether I am "on the right track".

Note: I need to define the mapping between YANG data type "bits" and ASN_OCTET_STR, even if there is an ASN_BITS data type. The reason is that I get the error message "Expected type:4, got: 3" in https://github.com/clicon/clixon/blob/master/apps/snmp/snmp_handler.c#L747 when I use the ASN_BITS type. As far as I understand, the expected type is specified by the nets-snmp library in netsnmp_request_info, so maybe there is a bug? (I have not checked it.)

Note 2: In all functions (like type_xml2snmp_pre), the data read or written to/from snmp is treated as a string. This does not work for bits as there can be multiple 0x00 bytes. For this reason I had to implement it directly in type_xml2snmp.

Thanks, Mico

olofhagsand commented 7 months ago

Please resolve the test_snmp_get.sh conflict

olofhagsand commented 7 months ago

Can you please split this PR into two? One for the new bit-manipulating functions in clixon-lib And one for SNMP bit support? Also, there are multiple commits that null each other, a squashing of multiple commits would be in order. Style: I see some extra empty lines and occasional spaces before \n.

mico-micic commented 6 months ago

PR was splittet in two. This one here contains the snmp support: https://github.com/clicon/clixon/pull/501. (Closing this PR here..)