- ERROR ("snmp plugin: csnmp_instance_list_add failed.");
- status = -1;
- break;
- }
-
- /* The instance OID is added to the list of OIDs to GET from the
- * snmp agent last, so set vb on the last variable returned and copy
- * that OID. */
- for (vb = res->variables;
- (vb != NULL) && (vb->next_variable != NULL);
- vb = vb->next_variable)
- /* do nothing */;
- assert (vb != NULL);
-
- /* Copy the OID of the instance value to oid_list[data->values_len].
- * "oid_list" is used for the next GETNEXT request. */
- memcpy (oid_list[data->values_len].oid, vb->name,
- sizeof (oid) * vb->name_length);
- oid_list[data->values_len].oid_len = vb->name_length;
- }
-
- /* Iterate over all the (non-instance) values returned by the agent. The
- * (i < value_len) check will make sure we're not handling the instance OID
- * twice. */
- for (vb = res->variables, i = 0;
- (vb != NULL) && (i < data->values_len);
- vb = vb->next_variable, i++)
- {
- csnmp_table_values_t *vt;
- oid_t vb_name;
- oid_t suffix;
-
- csnmp_oid_init (&vb_name, vb->name, vb->name_length);
-
- /* Calculate the current suffix. This is later used to check that the
- * suffix is increasing. This also checks if we left the subtree */
- status = csnmp_oid_suffix (&suffix, &vb_name, data->values + i);
- if (status != 0)
- {
- DEBUG ("snmp plugin: host = %s; data = %s; Value %i failed. "
- "It probably left its subtree.",
- host->name, data->name, i);
- continue;
- }
-
- /* Make sure the OIDs returned by the agent are increasing. Otherwise our
- * table matching algorithm will get confused. */
- if ((value_list_tail[i] != NULL)
- && (csnmp_oid_compare (&suffix, &value_list_tail[i]->suffix) <= 0))
- {
- DEBUG ("snmp plugin: host = %s; data = %s; i = %i; "
- "Suffix is not increasing.",
- host->name, data->name, i);
- continue;
+ if ((vb->type == SNMP_ENDOFMIBVIEW)
+ || (snmp_oid_ncompare (data->instance.oid.oid,
+ data->instance.oid.oid_len,
+ vb->name, vb->name_length,
+ data->instance.oid.oid_len) != 0))
+ {
+ DEBUG ("snmp plugin: host = %s; data = %s; Instance left its subtree.",
+ host->name, data->name);
+ oid_list_todo[i] = 0;
+ continue;
+ }
+
+ /* Allocate a new `csnmp_list_instances_t', insert the instance name and
+ * add it to the list */
+ if (csnmp_instance_list_add (&instance_list_head, &instance_list_tail,
+ res, host, data) != 0)
+ {
+ ERROR ("snmp plugin: csnmp_instance_list_add failed.");
+ status = -1;
+ break;
+ }