/** swaps out origrow with newrow.  This does *not* delete/free anything! */
void
netsnmp_tdata_replace_row(netsnmp_tdata *table,
                               netsnmp_tdata_row *origrow,
                               netsnmp_tdata_row *newrow)
{
    netsnmp_tdata_remove_row(table, origrow);
    netsnmp_tdata_add_row(table, newrow);
}
static int
_cache_load(netsnmp_cache *cache, netsnmp_tdata *table)
{
    netsnmp_container *maps;
    netsnmp_iterator  *map_itr;
    netsnmp_cert_map  *map;
    netsnmp_tdata_row *row;
    certToTSN_entry   *entry;
    int                rc = 0;

    DEBUGMSGTL(("tlstmCertToTSNTable:cache:load", "called, %" NETSNMP_PRIz "d rows\n",
                CONTAINER_SIZE(table->container)));

    /** get current active maps */
    maps = netsnmp_cert_map_container();
    if (NULL == maps)
        return 0;
    DEBUGMSGTL(("tlstmCertToTSNTable:cache:load", "maps %" NETSNMP_PRIz "d rows\n",
                CONTAINER_SIZE(maps)));

    map_itr = CONTAINER_ITERATOR(maps);
    if (NULL == map_itr) {
        DEBUGMSGTL(("tlstmCertToTSNTable:cache:load",
                    "cant get map iterator\n"));
        return -1;
    }

    /*
     * insert rows for active maps into tbl container
     */
    map = ITERATOR_FIRST(map_itr);
    for( ; map; map = ITERATOR_NEXT(map_itr)) {

        row = _entry_from_map(map);
        if (NULL == row) {
            rc =-1;
            break;
        }
        entry = (certToTSN_entry*)row->data;
        entry->rowStatus = RS_ACTIVE;

        if (netsnmp_tdata_add_row(table, row) != SNMPERR_SUCCESS) {
            tlstmCertToTSNTable_removeEntry(NULL, row);
            rc = -1;
            break;
        }
    }
    ITERATOR_RELEASE(map_itr);

    DEBUGMSGTL(("tlstmCertToTSNTable:cache:load", "done, %" NETSNMP_PRIz "d rows\n",
                CONTAINER_SIZE(table->container)));

    return rc;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
/*
 * Create a new row in the event table 
 */
netsnmp_tdata_row *mteEvent_createEntry (const char *mteOwner, const char *mteEName, int fixed)
{
    struct mteEvent *entry;

    netsnmp_tdata_row *row;

    size_t mteOwner_len = (mteOwner) ? strlen (mteOwner) : 0;

    size_t mteEName_len = (mteEName) ? strlen (mteEName) : 0;

    DEBUGMSGTL (("disman:event:table", "Create event entry (%s, %s)\n", mteOwner, mteEName));
    /*
     * Create the mteEvent entry, and the
     * (table-independent) row wrapper structure...
     */
    entry = SNMP_MALLOC_TYPEDEF (struct mteEvent);

    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 (mteOwner)
        memcpy (entry->mteOwner, mteOwner, mteOwner_len);
    netsnmp_table_row_add_index (row, ASN_OCTET_STR, entry->mteOwner, mteOwner_len);
    if (mteEName)
        memcpy (entry->mteEName, mteEName, mteEName_len);
    netsnmp_table_row_add_index (row, ASN_PRIV_IMPLIED_OCTET_STR, entry->mteEName, mteEName_len);

    entry->mteNotification_len = 2;    /* .0.0 */
    if (fixed)
        entry->flags |= MTE_EVENT_FLAG_FIXED;

    /*
     * ... and insert the row into the (common) table container
     */
    netsnmp_tdata_add_row (event_table_data, row);
    DEBUGMSGTL (("disman:event:table", "Event entry created\n"));
    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;
}
Exemplo n.º 6
0
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;
}
static void
_parse_mib_maps(const char *token, char *line)
{
    netsnmp_tdata_row *row;
    certToTSN_entry   *entry;
    netsnmp_cert_map *map = netsnmp_certToTSN_parse_common(&line);

    if (NULL == line) {
        netsnmp_config_error("incomplete line");
        netsnmp_cert_map_free(map);
        return;
    }

    map->flags = NSCM_FROM_MIB | NSCM_NONVOLATILE;
    row = _entry_from_map(map);
    if (NULL == row) {
        netsnmp_cert_map_free(map);
        return;
    }
    
    entry = (certToTSN_entry*)row->data;
    entry->rowStatus = atoi(line);
    entry->storageType = ST_NONVOLATILE;

    /*
     * if row is active, add it to the maps container so it is available
     * for use. Do not add it to the table, since it will be added
     * during cache_load.
     */
    if (RS_ACTIVE == entry->rowStatus) {
        if (netsnmp_cert_map_add(map) != 0)
            netsnmp_cert_map_free(map);
    }
    else {
        netsnmp_cert_map_free(map);
        if (netsnmp_tdata_add_row(_table, row) != SNMPERR_SUCCESS)
            tlstmCertToTSNTable_removeEntry(NULL, row);
    }
}
Exemplo n.º 9
0
/*
 * Create a new row in the trigger table
 */
netsnmp_tdata_row *
mteTrigger_createEntry(const char *mteOwner, char *mteTName, int fixed)
{
    struct mteTrigger *entry;
    netsnmp_tdata_row *row;
    size_t mteOwner_len = (mteOwner) ? strlen(mteOwner) : 0;
    size_t mteTName_len = (mteTName) ? strlen(mteTName) : 0;

    DEBUGMSGTL(("disman:event:table", "Create trigger entry (%s, %s)\n",
                mteOwner, mteTName));
    /*
     * Create the mteTrigger entry, and the
     * (table-independent) row wrapper structure...
     */
    entry = SNMP_MALLOC_TYPEDEF(struct mteTrigger);
    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 (mteOwner)
        memcpy(entry->mteOwner, mteOwner, mteOwner_len);
    netsnmp_table_row_add_index(row, ASN_OCTET_STR,
                                entry->mteOwner, mteOwner_len);
    if (mteTName)
        memcpy(entry->mteTName, mteTName, mteTName_len);
    netsnmp_table_row_add_index(row, ASN_PRIV_IMPLIED_OCTET_STR,
                                entry->mteTName, mteTName_len);

    /* entry->mteTriggerTest         = MTE_TRIGGER_BOOLEAN; */
    entry->mteTriggerValueID_len  = 2;  /* .0.0 */
    entry->mteTriggerFrequency    = 600;
    memcpy(entry->mteDeltaDiscontID, _sysUpTime_instance,
           sizeof(_sysUpTime_instance));
    entry->mteDeltaDiscontID_len  =  _sysUpTime_inst_len;
    entry->mteDeltaDiscontIDType  = MTE_DELTAD_TTICKS;
    entry->flags                 |= MTE_TRIGGER_FLAG_SYSUPT;
    entry->mteTExTest             = (MTE_EXIST_PRESENT | MTE_EXIST_ABSENT);
    entry->mteTExStartup          = (MTE_EXIST_PRESENT | MTE_EXIST_ABSENT);
    entry->mteTBoolComparison     = MTE_BOOL_UNEQUAL;
    entry->flags                 |= MTE_TRIGGER_FLAG_BSTART;
    entry->mteTThStartup          = MTE_THRESH_START_RISEFALL;

    if (fixed)
        entry->flags |= MTE_TRIGGER_FLAG_FIXED;

    /*
     * ... and insert the row into the (common) table container
     */
    netsnmp_tdata_add_row(trigger_table_data, row);
    DEBUGMSGTL(("disman:event:table", "Trigger entry created\n"));
    return row;
}