/** @internal */ void netsnmp_config_parse_add_row(const char *token, char *line) { char buf[SNMP_MAXBUF_MEDIUM]; char tname[SNMP_MAXBUF_MEDIUM]; size_t buf_size; int rc; data_set_tables *tables; netsnmp_variable_list *vb; /* containing only types */ netsnmp_table_row *row; netsnmp_table_data_set_storage *dr; line = copy_nword(line, tname, SNMP_MAXBUF_MEDIUM); tables = (data_set_tables *) netsnmp_get_list_data(auto_tables, tname); if (!tables) { config_pwarn("Unknown table trying to add a row"); return; } /* * do the indexes first */ row = netsnmp_create_table_data_row(); for (vb = tables->table_set->table->indexes_template; vb; vb = vb->next_variable) { if (!line) { config_pwarn("missing an index value"); return; } DEBUGMSGTL(("table_set_add_row", "adding index of type %d\n", vb->type)); buf_size = SNMP_MAXBUF_MEDIUM; line = read_config_read_memory(vb->type, line, buf, &buf_size); netsnmp_table_row_add_index(row, vb->type, buf, buf_size); } /* * then do the data */ for (dr = tables->table_set->default_row; dr; dr = dr->next) { if (!line) { config_pwarn("missing a data value. " "All columns must be specified."); snmp_log(LOG_WARNING," can't find value for column %d\n", dr->column - 1); return; } buf_size = SNMP_MAXBUF_MEDIUM; line = read_config_read_memory(dr->type, line, buf, &buf_size); DEBUGMSGTL(("table_set_add_row", "adding data at column %d of type %d\n", dr->column, dr->type)); netsnmp_set_row_column(row, dr->column, dr->type, buf, buf_size); if (dr->writable) netsnmp_mark_row_column_writable(row, dr->column, 1); /* make writable */ } rc = netsnmp_table_data_add_row(tables->table_set->table, row); if (SNMPERR_SUCCESS != rc) { config_pwarn("error adding table row"); } }
/* * parse values from configuration file */ static void _snmpNotifyFilter_parse(const char *token, char *buf) { snmpNotifyFilter_data_storage data, *row; size_t len, tmp_len; char type_buf[9]; /* include/excluded */ if (strcmp(token, "notificationFilter") != 0) { snmp_log(LOG_ERR, "unknown token in _snmpNotifyFilter_parse\n"); return; } DEBUGMSGTL(("internal:snmpNotifyFilter:parse", "line '%s'\n", buf)); if (NULL == buf) goto bail; /* * profile name */ data.snmpNotifyFilterProfileName_len = sizeof(data.snmpNotifyFilterProfileName); buf = read_config_read_memory(ASN_OCTET_STR, buf, (char *) &data.snmpNotifyFilterProfileName, (size_t *) &data.snmpNotifyFilterProfileName_len); if (NULL == buf) goto bail; /* * subtree */ tmp_len = sizeof(data.snmpNotifyFilterSubtree); buf = read_config_read_memory(ASN_OBJECT_ID, buf, (char *) &data.snmpNotifyFilterSubtree, (size_t *) &tmp_len); if (NULL == buf) goto bail; data.snmpNotifyFilterSubtree_len = tmp_len / sizeof(oid); /* * mask */ data.snmpNotifyFilterMask_len = sizeof(data.snmpNotifyFilterMask); buf = read_config_read_memory(ASN_OCTET_STR, buf, (char *) &data.snmpNotifyFilterMask, (size_t *) &data.snmpNotifyFilterMask_len); if (buf == NULL) goto bail; /* * type */ type_buf[0] = 0; /* empty string, in case read_config_read_memory fails */ len = sizeof(type_buf); buf = read_config_read_memory(ASN_OCTET_STR, buf, type_buf, (size_t *) &len); if (strcasecmp(type_buf, "included") == 0) data.snmpNotifyFilterType = 1; else if (strcasecmp(type_buf, "excluded") == 0) data.snmpNotifyFilterType = 2; else { config_perror("type must be 'excluded' or 'included'"); goto bail; } /** ignore any other data */ if (NULL != buf) snmp_log(LOG_WARNING, "ignoring data after notificationFilter\n"); row = snmpNotifyFilter_storage_add(data.snmpNotifyFilterProfileName, data.snmpNotifyFilterProfileName_len, data.snmpNotifyFilterSubtree, data.snmpNotifyFilterSubtree_len, data.snmpNotifyFilterMask, data.snmpNotifyFilterMask_len, data.snmpNotifyFilterType); if (NULL == row) snmp_log(LOG_ERR,"couldn't add notification filter\n"); return; bail: config_perror("error parsing notificationFilter\n"); return; }