Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: support for nasl snmp getnext (#1047)
* Add prototypes and make the functions available * Add comments and update docstrings * Rework nasl_snmpv3_get(). Now is called nasl_snmpv3_get_action() and receives the new parameter "action" to specify if it will be called the "get" or "getnext" action. Add wrappers for this function which call nasl_snmpv3_get_action() with the requiered action. * Modify nasl_snmpv1v2c_get () function signature. Now receives a new parameter "action". Pass the new action parameter set with NASL_SNMP_GET in the existing nasl_snmpv*_get() wrapper functions Add the new wrapper functions nasl_snmpv1_getnext() and nasl_snmpv2c_getnext() * Add log domain * Define snmp versions * Add request struct for snmp v1 and v2c * Add request struct for snmp v3 * Use snmpv3_request struct in nasl_snmpv3_get_action. Also uses the action var * Use snmpv3_request struct in snmpv3_get(). * Use snmpv3_request struct in snmpv3_get() (cmd wrap-up). * Add definition for action. Depends on the method, cmd wrapper or library * Use snmpv1v2_request struct in nasl_snmpv1v2c_get(). Also uses the action var * Use snmpv1v2_request struct in snmpv1v2c_get() (cmd wrap-up). * Use snmpv1v2_request struct in snmpv1v2c_get() (libnet-snmp) * Receive and use the action param in snmp_get() * Add struct snmp_result * Change array_from_smmp_result() to use the new struct snmp_result * Add array_from_snmp_error() * Use snmp_result struct where necessary * Adjust format * Define new type snmp_result_t for snmp_result* * Use the new type for results, and allocate memory for results This fixes a segmentation fault in the original PR, because result didn't have allocated memory. * Define new type snmpv1v2_request_t for struct snmpv1v2_request* * Use the new type and allocate memory for the request struct * Define new type snmpv3_request_t for struct snmpv3_request* * Use snmpv3_request_t and allocate memory for the request struct * Adjust format again * Make the oid optional for "snmp getnext" (lib version) The first time the oid is requiered. The next time, the oid is optional for getnext While snmpgetnext support mib descriptions instead of oids (like iso.3.6....), the older version snmp v1 doesn't. Therfore the iso. is formated in the right place, so the oid can be saved once it is in the result. * Get the oid also in the result for the snmp cmd wrapper Now, also the oid is get with name. * Parse the result (snmp cmd wrapper), and stores the oid and name in the result struct. The oid can be used now for getnext. (See some commits above.) * Adjust format one more time * Free memory allocated for request Co-authored-by: Juan Jose Nicola <juan.nicola@greenbone.net>
- Loading branch information