netsnmp_tdata_row * expObject_createRow( char *expOwner, char *expName, long expIndex, int fixed) { struct expObject *entry; netsnmp_tdata_row *row; size_t expOwner_len = (expOwner) ? strlen(expOwner) : 0; size_t expName_len = (expName) ? strlen(expName) : 0; /* * Create the expObject entry, and the * (table-independent) row wrapper structure... */ entry = SNMP_MALLOC_TYPEDEF(struct expObject); if (!entry) return NULL; row = netsnmp_tdata_create_row(); if (!row) { SNMP_FREE(entry); return NULL; } row->data = entry; /* * ... initialize this row with the indexes supplied * and the default values for the row... */ if (expOwner) memcpy(entry->expOwner, expOwner, expOwner_len); netsnmp_tdata_row_add_index(row, ASN_OCTET_STR, entry->expOwner, expOwner_len); if (expName) memcpy(entry->expName, expName, expName_len); netsnmp_tdata_row_add_index(row, ASN_OCTET_STR, entry->expName, expName_len); entry->expObjectIndex = expIndex; netsnmp_tdata_row_add_index(row, ASN_INTEGER, &entry->expObjectIndex, sizeof(long)); entry->expObjectSampleType = 1; /* absoluteValue */ entry->expObjDiscontinuityType = 1; /* timeTicks */ if (fixed) entry->flags |= EXP_OBJ_FLAG_FIXED; /* * ... and insert the row into the table container. */ netsnmp_tdata_add_row(expObject_table_data, row); return row; }
netsnmp_tdata_row * expExpression_createRow(char *expOwner, char *expName, int fixed) { struct expExpression *entry; netsnmp_tdata_row *row; size_t expOwner_len = (expOwner) ? strlen(expOwner) : 0; size_t expName_len = (expName) ? strlen(expName) : 0; /* * Create the expExpression entry, and the * (table-independent) row wrapper structure... */ entry = SNMP_MALLOC_TYPEDEF(struct expExpression); if (!entry) return NULL; row = netsnmp_tdata_create_row(); if (!row) { SNMP_FREE(entry); return NULL; } row->data = entry; /* * ... initialize this row with the indexes supplied * and the default values for the row... */ if (expOwner) memcpy(entry->expOwner, expOwner, expOwner_len); netsnmp_tdata_row_add_index(row, ASN_OCTET_STR, entry->expOwner, expOwner_len); if (expName) memcpy(entry->expName, expName, expName_len); netsnmp_tdata_row_add_index(row, ASN_OCTET_STR, entry->expName, expName_len); entry->expValueType = EXPVALTYPE_COUNTER; entry->expErrorCount = 0; if (fixed) entry->flags |= EXP_FLAG_FIXED; /* * ... and insert the row into the table container. */ netsnmp_tdata_add_row(expr_table_data, row); DEBUGMSGTL(("disman:expr:table", "Expression entry created (%s, %s)\n", expOwner, expName)); return row; }
static int channelList_callback(void *pArg, int argc, char **argv, char **columnNames) { chan_entry_t *entry; netsnmp_tdata_row *row; switch_zmalloc(entry, sizeof(chan_entry_t)); row = netsnmp_tdata_create_row(); if (!row) { switch_safe_free(entry); return 0; } row->data = entry; entry->idx = idx++; strncpy(entry->uuid, switch_str_nil(argv[0]), sizeof(entry->uuid)); strncpy(entry->direction, switch_str_nil(argv[1]), sizeof(entry->direction)); entry->created_epoch = atoi(argv[3]); strncpy(entry->name, switch_str_nil(argv[4]), sizeof(entry->name)); strncpy(entry->state, switch_str_nil(argv[5]), sizeof(entry->state)); strncpy(entry->cid_name, switch_str_nil(argv[6]), sizeof(entry->cid_name)); strncpy(entry->cid_num, switch_str_nil(argv[7]), sizeof(entry->cid_num)); strncpy(entry->dest, switch_str_nil(argv[9]), sizeof(entry->dest)); strncpy(entry->application, switch_str_nil(argv[10]), sizeof(entry->application)); strncpy(entry->application_data, switch_str_nil(argv[11]), sizeof(entry->application_data)); strncpy(entry->dialplan, switch_str_nil(argv[12]), sizeof(entry->dialplan)); strncpy(entry->context, switch_str_nil(argv[13]), sizeof(entry->context)); strncpy(entry->read_codec, switch_str_nil(argv[14]), sizeof(entry->read_codec)); entry->read_rate = atoi(switch_str_nil(argv[15])); entry->read_bitrate = atoi(switch_str_nil(argv[16])); strncpy(entry->write_codec, switch_str_nil(argv[17]), sizeof(entry->write_codec)); entry->write_rate = atoi(switch_str_nil(argv[18])); entry->write_bitrate = atoi(switch_str_nil(argv[19])); memset(&entry->ip_addr, 0, sizeof(entry->ip_addr)); if (strchr(switch_str_nil(argv[8]), ':')) { switch_inet_pton(AF_INET6, switch_str_nil(argv[8]), &entry->ip_addr); entry->addr_family = AF_INET6; } else { switch_inet_pton(AF_INET, switch_str_nil(argv[8]), &entry->ip_addr); entry->addr_family = AF_INET; } netsnmp_tdata_row_add_index(row, ASN_INTEGER, &entry->idx, sizeof(entry->idx)); netsnmp_tdata_add_row(ch_table, row); return 0; }
/* * create a new row in the table */ netsnmp_tdata_row * tlstmCertToTSNTable_createEntry(netsnmp_tdata * table, u_long tlstmCertToTSNID) { certToTSN_entry *entry; netsnmp_tdata_row *row; entry = SNMP_MALLOC_TYPEDEF(certToTSN_entry); if (!entry) return NULL; row = netsnmp_tdata_create_row(); if (!row) { SNMP_FREE(entry); return NULL; } row->data = entry; DEBUGMSGT(("tlstmCertToSN:entry:create", "entry %p / row %p\n", entry, row)); /* * populate index */ entry->tlstmCertToTSNID = tlstmCertToTSNID; netsnmp_tdata_row_add_index(row, ASN_UNSIGNED, &(entry->tlstmCertToTSNID), sizeof(entry->tlstmCertToTSNID)); /* * assign default column values */ entry->mapType = TSNM_tlstmCertSpecified; entry->storageType = ST_NONVOLATILE; entry->rowStatus = RS_NOTREADY; if (table) { DEBUGMSGTL(("tlstmCertToTSN:row:insert", "row %p\n", row)); netsnmp_tdata_add_row(table, row); } return row; }