summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ad9a924)
raw | patch | inline | side by side (parent: ad9a924)
author | Korynkevych, RomanX <romanx.korynkevych@intel.com> | |
Fri, 30 Dec 2016 16:45:06 +0000 (16:45 +0000) | ||
committer | Roman Korynkevych <romanx.korynkevych@intel.com> | |
Tue, 3 Jan 2017 14:55:33 +0000 (14:55 +0000) |
Additional validation and variable names changes.
Change-Id: Ic6c3c3226e2ee6586c03b64d063822b99c242af3
Signed-off-by: Korynkevych, RomanX <romanx.korynkevych@intel.com>
Change-Id: Ic6c3c3226e2ee6586c03b64d063822b99c242af3
Signed-off-by: Korynkevych, RomanX <romanx.korynkevych@intel.com>
src/snmp_agent.c | patch | blob | history |
diff --git a/src/snmp_agent.c b/src/snmp_agent.c
index c732bb68b19021591f1e38167202166cb8024b73..74c2d0b027a10f5db5faa8f15828712f1dc2d73e 100644 (file)
--- a/src/snmp_agent.c
+++ b/src/snmp_agent.c
static int snmp_agent_form_reply(struct netsnmp_request_info_s *requests,
data_definition_t *dd, char *instance,
int oid_index) {
- char buf[DATA_MAX_NAME_LEN];
- format_name(buf, sizeof(buf), hostname_g, dd->plugin,
+ char name[DATA_MAX_NAME_LEN];
+ format_name(name, sizeof(name), hostname_g, dd->plugin,
instance ? instance : dd->plugin_instance, dd->type,
dd->type_instance);
- DEBUG(PLUGIN_NAME ": Identifier '%s'", buf);
+ DEBUG(PLUGIN_NAME ": Identifier '%s'", name);
value_t *values;
size_t values_num;
const data_set_t *ds = plugin_get_ds(dd->type);
if (ds == NULL) {
- DEBUG(PLUGIN_NAME ": Data set not found for '%s' type", dd->type);
+ ERROR(PLUGIN_NAME ": Data set not found for '%s' type", dd->type);
return SNMP_NOSUCHINSTANCE;
}
- int ret = uc_get_value_by_name(buf, &values, &values_num);
+ int ret = uc_get_value_by_name(name, &values, &values_num);
if (ret != 0) {
- ERROR(PLUGIN_NAME ": Failed to get value for '%s'", buf);
+ ERROR(PLUGIN_NAME ": Failed to get value for '%s'", name);
return SNMP_NOSUCHINSTANCE;
}
sfree(values);
if (ret != 0) {
- ERROR(PLUGIN_NAME ": Failed to convert '%s' value to snmp data", buf);
+ ERROR(PLUGIN_NAME ": Failed to convert '%s' value to snmp data", name);
return SNMP_NOSUCHINSTANCE;
}
for (llentry_t *te = llist_head(g_agent->tables); te != NULL; te = te->next) {
table_definition_t *td = te->value;
+ if (!td->index_oid.oid_len) {
+ DEBUG(PLUGIN_NAME ": %s:%d NOT IMPLEMENTED", __FUNCTION__, __LINE__);
+ continue;
+ }
+
for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
data_definition_t *dd = de->value;
if (ret != 0)
continue;
- if (!td->index_oid.oid_len) {
- DEBUG(PLUGIN_NAME ": %s:%d NOT IMPLEMENTED", __FUNCTION__, __LINE__);
- continue;
- }
-
int index = oid.oid[oid.oid_len - 1];
char *instance;
}
}
+ if (td->index_oid.oid_len == 0) {
+ ERROR(PLUGIN_NAME ": Table %s Index OID is not specified", td->name);
+ snmp_agent_free_table(&td);
+ return (-1);
+ }
+
llentry_t *entry = llentry_create(td->name, td);
if (entry == NULL) {
snmp_agent_free_table(&td);