Ejemplo n.º 1
0
int
update_watchdog_row (SaHpiDomainIdT domain_id,
		     SaHpiResourceIdT resource_id,
		     SaHpiWatchdogNumT num, SaHpiWatchdogEventT * wdog)
{
  saHpiWatchdogTable_context *ctx;
  oid index_oid[WATCHDOG_INDEX_NR];
  netsnmp_index index;

  // Look at the MIB to find out what the indexs are
  index_oid[0] = domain_id;
  index_oid[1] = resource_id;
  index_oid[2] = num;
  // Possible more indexes?
  index.oids = (oid *) & index_oid;
  index.len = WATCHDOG_INDEX_NR;
  ctx = CONTAINER_FIND (cb.container, &index);

  if (ctx)
    {
      ctx->saHpiWatchdogTimerUse = wdog->WatchdogUse + 1;
      ctx->saHpiWatchdogTimerAction = wdog->WatchdogAction + 1;
      ctx->saHpiWatchdogPretimerInterrupt = wdog->WatchdogPreTimerAction + 1;
      return AGENT_ERR_NOERROR;
    }

  return AGENT_ERR_NOT_FOUND;

}
ipv4InterfaceTable_rowreq_ctx *
ipv4InterfaceTable_row_find_by_mib_index(ipv4InterfaceTable_mib_index *
                                         mib_idx)
{
    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx;
    oid             oid_tmp[MAX_OID_LEN];
    netsnmp_index   oid_idx;
    int             rc;

    /*
     * set up storage for OID
     */
    oid_idx.oids = oid_tmp;
    oid_idx.len = sizeof(oid_tmp) / sizeof(oid);

    /*
     * convert
     */
    rc = ifTable_index_to_oid(&oid_idx, mib_idx);
    if (MFD_SUCCESS != rc)
        return NULL;

    rowreq_ctx =
        CONTAINER_FIND(ipv4InterfaceTable_if_ctx.container, &oid_idx);

    return rowreq_ctx;
}
Ejemplo n.º 3
0
/**
 *
 * @sessionid
 *
 * @return
 */
SaErrorT clear_domain_info_entry(SaHpiDomainIdT domain_id)
{
    SaErrorT rv = SA_OK;
    netsnmp_index *row_idx;
    saHpiDomainInfoTable_context *ctx;

    DEBUGMSGTL ((AGENT, "clear_domain_info_entry, called\n"));
    DEBUGMSGTL ((AGENT, "           domainId   [%d]\n", domain_id));

    row_idx = CONTAINER_FIRST(cb.container);
    if (row_idx) //At least one entry was found.
    {
        do {
            ctx = CONTAINER_FIND(cb.container, row_idx);

            row_idx = CONTAINER_NEXT(cb.container, row_idx);

            if (ctx->index.oids[saHpiDomainId_INDEX] == domain_id) {

                /* all conditions met remove row */
                CONTAINER_REMOVE (cb.container, ctx);
                saHpiDomainInfoTable_delete_row (ctx);
                domain_info_entry_count =
                    CONTAINER_SIZE (cb.container);
                DEBUGMSGTL ((AGENT, "clear_domain_info_entry:"
                             " found row: removing\n"));
            }

        } while (row_idx);
    }

    return rv;
}
Ejemplo n.º 4
0
int
delete_hotswap_row (SaHpiDomainIdT domain_id, SaHpiResourceIdT resource_id)
{

  saHpiHotSwapTable_context *ctx;
  oid hotswap_oid[HOTSWAP_INDEX_NR];
  netsnmp_index hotswap_index;
  int rc = AGENT_ERR_NOT_FOUND;

  DEBUGMSGTL ((AGENT, "delete_hotswap_row (%d, %d). Entry\n",
	       domain_id, resource_id));

  hotswap_oid[0] = domain_id;
  hotswap_oid[1] = resource_id;


  // Possible more indexs?
  hotswap_index.oids = (oid *) & hotswap_oid;
  hotswap_index.len = HOTSWAP_INDEX_NR;

  ctx = CONTAINER_FIND (cb.container, &hotswap_index);

  if (ctx)
    {
      CONTAINER_REMOVE (cb.container, ctx);
      saHpiHotSwapTable_delete_row (ctx);
      rc = AGENT_ERR_NOERROR;
    }
  DEBUGMSGTL ((AGENT, "delete_hotswap_row. Exit (rc: %d).\n", rc));
  return rc;
}
Ejemplo n.º 5
0
int
delete_watchdog_row (SaHpiDomainIdT domain_id,
		     SaHpiResourceIdT resource_id, SaHpiWatchdogNumT num)
{

  saHpiWatchdogTable_context *ctx;
  oid index_oid[WATCHDOG_INDEX_NR];
  netsnmp_index index;
  int rc = AGENT_ERR_NOT_FOUND;

  DEBUGMSGTL ((AGENT, "delete_watchdog_row (%d, %d, %d). Entry.\n",
	       domain_id, resource_id, num));

  // Look at the MIB to find out what the indexs are
  index_oid[0] = domain_id;
  index_oid[1] = resource_id;
  index_oid[2] = num;
  // Possible more indexes?
  index.oids = (oid *) & index_oid;
  index.len = WATCHDOG_INDEX_NR;
  ctx = CONTAINER_FIND (cb.container, &index);

  if (ctx)
    {
      CONTAINER_REMOVE (cb.container, ctx);
      saHpiWatchdogTable_delete_row (ctx);
      watchdog_count = CONTAINER_SIZE (cb.container);
      rc = AGENT_ERR_NOERROR;
    }
  DEBUGMSGTL ((AGENT, "delete_watchdog_row. Exit (rc: %d).\n", rc));
  return rc;
}
int
delete_ThdPosHysteresis_row (SaHpiDomainIdT domain_id,
			   SaHpiResourceIdT resource_id,
			   SaHpiSensorNumT sensor_num)
{

  saHpiSensorThdPosHysteresisTable_context *ctx;
  oid index_oid[SENSOR_THD_INDEX_NR];
  netsnmp_index sensor_reading_index;
  int rc = AGENT_ERR_NOT_FOUND;

  DEBUGMSGTL ((AGENT, "delete_ThdPosHysteresis_row (%d, %d, %d). Entry.\n",
	       domain_id, resource_id, sensor_num));

  // Look at the MIB to find out what the indexs are
  index_oid[0] = domain_id;
  index_oid[1] = resource_id;
  index_oid[2] = sensor_num;
  // Possible more indexs?
  sensor_reading_index.oids = (oid *) & index_oid;
  sensor_reading_index.len = SENSOR_THD_INDEX_NR;

  ctx = CONTAINER_FIND (cb.container, &sensor_reading_index);

  if (ctx)
    {
      CONTAINER_REMOVE (cb.container, ctx);
      saHpiSensorThdPosHysteresisTable_delete_row (ctx);
      rc = AGENT_ERR_NOERROR;
    }
  DEBUGMSGTL ((AGENT, "delete_ThdPosHysteresis_row. Exit (rc: %d).\n", rc));
  return rc;
}
Ejemplo n.º 7
0
/* 
 * Removes the row indexed by userIndex and contactIndex, and free's up the
 * memory allocated to it.  If the row could not be found, then nothing is done.
 */
void deleteContactRow(int userIndex, int contactIndex) 
{
	openserSIPContactTable_context *theRow;

	netsnmp_index indexToRemove;
	oid indexToRemoveOID[2];

	/* Form the OID Index of the row so we can search for it */
	indexToRemoveOID[0] = userIndex;
	indexToRemoveOID[1] = contactIndex;
	indexToRemove.oids  = indexToRemoveOID;
	indexToRemove.len   = 2;

	theRow = CONTAINER_FIND(cb.container, &indexToRemove);

	/* The ContactURI is shared memory, the index.oids was allocated from
	 * pkg_malloc(), and theRow was made with the NetSNMP API which uses
	 * malloc() */
	if (theRow != NULL) {
		CONTAINER_REMOVE(cb.container, &indexToRemove);
		pkg_free(theRow->openserSIPContactURI);
		pkg_free(theRow->index.oids);
		free(theRow);
	} 
}
Ejemplo n.º 8
0
int
update_hotswap_event (SaHpiDomainIdT domain_id,
		      SaHpiResourceIdT resource_id,
		      SaHpiHotSwapEventT * event)
{

  saHpiHotSwapTable_context *ctx;
  oid hotswap_oid[HOTSWAP_INDEX_NR];
  netsnmp_index hotswap_index;
  int rc = AGENT_ERR_NOT_FOUND;

  hotswap_oid[0] = domain_id;
  hotswap_oid[1] = resource_id;

  // Possible more indexs?
  hotswap_index.oids = (oid *) & hotswap_oid;
  hotswap_index.len = HOTSWAP_INDEX_NR;

  ctx = CONTAINER_FIND (cb.container, &hotswap_index);

  if (ctx)
    {
      ctx->saHpiHotSwapState = event->HotSwapState + 1;
      ctx->saHpiHotSwapPreviousState = event->PreviousHotSwapState + 1;
      rc = AGENT_ERR_NOERROR;
    }

  return rc;
}
Ejemplo n.º 9
0
void
put_memTable(int idx, char* name, int total, int avail, int used, int usage)
{
    netsnmp_index   index;
    oid             myoid;
    memTable_context* myrow;
	int 			makeit=0;

   	myoid      = idx;
    index.oids = &myoid;
    index.len  = 1;

    if(!(myrow = (memTable_context*)CONTAINER_FIND(cb.container, &index))) {
    	myrow = memTable_create_row(&index); makeit=1;
	}

   	myrow->memIndex = idx;
   	strcpy(myrow->memSystem, name);
   	myrow->memSystem_len = strlen(name);
   	myrow->memTotal = total;
   	myrow->memAvail = avail;
   	myrow->memUsed  = used;
   	myrow->memUsage = usage;

    if(makeit) CONTAINER_INSERT(cb.container,myrow);
}
static void
_cert_map_tweak_storage(certToTSN_entry *entry)
{
    netsnmp_container *maps;
    netsnmp_cert_map *map, index;

    if (NULL == entry)
        return;

    DEBUGMSGTL(("tlstmCertToTSNTable:map:tweak", "pri %ld, st %d\n",
                entry->tlstmCertToTSNID, entry->storageType));

    /** get current active maps */
    maps = netsnmp_cert_map_container();
    if (NULL == maps)
        return;

    index.priority = entry->tlstmCertToTSNID;
    map = CONTAINER_FIND(maps, &index);
    if (NULL == map) {
        DEBUGMSGTL(("tlstmCertToTSNTable:map:tweak", "couldn't find map!\n"));
        return;
    }

    if (entry->storageType == ST_NONVOLATILE)
        map->flags |= NSCM_NONVOLATILE;
    else
        map->flags &= ~NSCM_NONVOLATILE;
}
Ejemplo n.º 11
0
/* Removes an SNMP row indexed by userIndex, and frees the string and index it
 * pointed to. */
void deleteRegUserRow(int userIndex) 
{
	
	openserSIPRegUserTable_context *theRow;

	netsnmp_index indexToRemove;
	oid indexToRemoveOID;
		
	indexToRemoveOID   = userIndex;
	indexToRemove.oids = &indexToRemoveOID;
	indexToRemove.len  = 1;

	theRow = CONTAINER_FIND(cb.container, &indexToRemove);

	/* The userURI is shared memory, the index.oids was allocated from
	 * pkg_malloc(), and theRow was made with the NetSNMP API which uses
	 * malloc() */
	if (theRow != NULL) {
		CONTAINER_REMOVE(cb.container, &indexToRemove);
		pkg_free(theRow->openserSIPUserUri);
		pkg_free(theRow->index.oids);
		free(theRow);
	}

}
Ejemplo n.º 12
0
/************************************************************
 * netSnmpIETFWGTable_get_by_idx
 */
const netSnmpIETFWGTable_context *
netSnmpIETFWGTable_get_by_idx(netsnmp_index * hdr)
{
	DEBUGMSGTL((AGENT,"netSnmpIETFWGTable_get_by_idx"));
    return (const netSnmpIETFWGTable_context *)
        CONTAINER_FIND(cb.container, hdr);
}
Ejemplo n.º 13
0
/************************************************************
 * saHpiRdrTable_get_by_idx
 */
const saHpiRdrTable_context *
saHpiRdrTable_get_by_idx(netsnmp_index * hdr)
{
	DEBUGMSGTL ((AGENT, "saHpiRdrTable_get_by_idx, called\n"));

    return (const saHpiRdrTable_context *)
        CONTAINER_FIND(cb.container, hdr );
}
/************************************************************
 * saHpiSensorThdNegHysteresisTable_get_by_idx
 */
const saHpiSensorThdNegHysteresisTable_context *
saHpiSensorThdNegHysteresisTable_get_by_idx(netsnmp_index * hdr)
{
        DEBUGMSGTL ((AGENT, "saHpiSensorThdNegHysteresisTable_get_by_idx called\n"));

        return(const saHpiSensorThdNegHysteresisTable_context *)
        CONTAINER_FIND(cb.container, hdr );
}
Ejemplo n.º 15
0
/*
 * debug_is_token_registered(char *TOKEN):
 * 
 * returns SNMPERR_SUCCESS
 * or SNMPERR_GENERR
 * 
 * if TOKEN has been registered and debugging support is turned on.
 */
int
debug_is_token_registered(const char *token)
{
    int             i, rc;

    /*
     * debugging flag is on or off 
     */
    if (!dodebug)
        return SNMPERR_GENERR;

    if (debug_num_tokens == 0 || debug_print_everything) {
        /*
         * no tokens specified, print everything 
         * (unless something might be excluded)
         */
        if (debug_num_excluded) {
            rc = SNMPERR_SUCCESS; /* ! found = success */
        } else {
            return SNMPERR_SUCCESS;
        }
    }
    else
        rc = SNMPERR_GENERR; /* ! found = err */

    for (i = 0; i < debug_num_tokens; i++) {
        if (SNMP_DEBUG_DISABLED == dbg_tokens[i].enabled)
            continue;
        if (dbg_tokens[i].token_name &&
            strncmp(dbg_tokens[i].token_name, token,
                    strlen(dbg_tokens[i].token_name)) == 0) {
            if (SNMP_DEBUG_ACTIVE == dbg_tokens[i].enabled)
                return SNMPERR_SUCCESS; /* active */
            else
                return SNMPERR_GENERR; /* excluded */
        }
    }

#ifdef NETSNMP_DEBUG_STATS
    if ((SNMPERR_SUCCESS == rc) && (NULL != dbg_stats)) {
        netsnmp_token_descr td, *found;

        td.token_name = token;
        found = CONTAINER_FIND(dbg_stats, &td);
        if (NULL == found) {
            found = SNMP_MALLOC_TYPEDEF(netsnmp_token_descr);
            netsnmp_assert(NULL != found);
            found->token_name = strdup(token);
            netsnmp_assert(0 == found->enabled);
            CONTAINER_INSERT(dbg_stats, found);
        }
        ++found->enabled;
    /*  snmp_log(LOG_ERR,"tok %s, %d hits\n", token, found->enabled);  */
    }
#endif

    return rc;
}
Ejemplo n.º 16
0
/** finds a row in the 'tdata' table given the index OID */
netsnmp_tdata_row *netsnmp_tdata_row_get_byoid (netsnmp_tdata * table, oid * searchfor, size_t searchfor_len)
{
    netsnmp_index index;

    if (!table)
        return NULL;

    index.oids = searchfor;
    index.len = searchfor_len;
    return (netsnmp_tdata_row *) CONTAINER_FIND (table->container, &index);
}
Ejemplo n.º 17
0
int
populate_hotswap (SaHpiRptEntryT * rpt_entry,
		  oid * rpt_oid, size_t rpt_oid_len)
{

  SaHpiSessionIdT session_id;
  int rc = AGENT_ERR_NOERROR;

  oid index_oid[HOTSWAP_INDEX_NR];


  netsnmp_index hotswap_index;
  saHpiHotSwapTable_context *hotswap_context;

  DEBUGMSGTL ((AGENT, "\n\t--- populate_hotswap. Entry\n"));
  if ((rc = getSaHpiSession (&session_id)) == AGENT_ERR_NOERROR)
    {


      index_oid[0] = rpt_entry->DomainId;
      index_oid[1] = rpt_entry->ResourceId;

      hotswap_index.oids = (oid *) & index_oid;
      hotswap_index.len = HOTSWAP_INDEX_NR;
      hotswap_context = CONTAINER_FIND (cb.container, &hotswap_index);

      if (!hotswap_context)
	{
	  // Couldn't find it. Add new entry.
	  hotswap_context = saHpiHotSwapTable_create_row (&hotswap_index);
	}

      if (!hotswap_context)
	{
	  snmp_log (LOG_ERR, "Not enough memory for a HotSwap row!\n");
	  return AGENT_ERR_MEMORY_FAULT;
	}

      if (saHpiHotSwapTable_modify_context (rpt_entry,
					    rpt_oid,
					    rpt_oid_len,
					    hotswap_context)
	  == AGENT_NEW_ENTRY)
	{

	  CONTAINER_INSERT (cb.container, hotswap_context);
	}

    }

  DEBUGMSGTL ((AGENT, "\n\t--- populate_hotswap: Exit (rc: %d).\n", rc));
  return rc;
}
Ejemplo n.º 18
0
/* Will return an existing row indexed by the parameter list if one exists, and
 * return a new one otherwise.  If the row is new, then the provided index will be
 * assigned to the new row.
 *
 * Note: NULL will be returned on an error 
 */
openserSIPPortTable_context *getRow(int ipType, int *ipAddress) 
{
	int lengthOfOID;
	oid *currentOIDIndex = createIndex(ipType, ipAddress, &lengthOfOID);

	if (currentOIDIndex == NULL)
	{
		return NULL;
	}

	netsnmp_index theIndex;

	theIndex.oids = currentOIDIndex;
	theIndex.len  = lengthOfOID;

	openserSIPPortTable_context *rowToReturn;

	/* Lets check to see if there is an existing row. */
	rowToReturn = CONTAINER_FIND(cb.container, &theIndex);
	
	/* We found an existing row, so there is no need to create a new one.
	 * Let's return it to the caller. */
	if (rowToReturn != NULL) 
	{
		/* We don't need the index we allocated anymore, because the
		 * existing row already has its own copy, so free the memory */
		pkg_free(currentOIDIndex);

		return rowToReturn;
	}
	
	/* If we are here then the row doesn't exist yet.  So lets create it. */
	rowToReturn = SNMP_MALLOC_TYPEDEF(openserSIPPortTable_context);

	/* Not enough memory to create the new row. */
	if (rowToReturn == NULL) {
		pkg_free(currentOIDIndex);
		return NULL;
	}

	/* Assign the Container Index. */
	rowToReturn->index.len  = lengthOfOID;
	rowToReturn->index.oids = currentOIDIndex;

	memcpy(rowToReturn->openserSIPStringIndex, currentOIDIndex, NUM_IP_OCTETS + 3);
	rowToReturn->openserSIPStringIndex_len = NUM_IP_OCTETS + 3;

	/* Insert the new row into the table */
	CONTAINER_INSERT(cb.container, rowToReturn);

	return rowToReturn;
}
/**
 * check entry for update
 */
static void
_check_for_updates(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
                   netsnmp_container *stats)
{
    netsnmp_systemstats_entry *ifstats_entry;

    /*
     * check for matching entry. works because indexes are the same.
     */
    ifstats_entry = (netsnmp_systemstats_entry*)CONTAINER_FIND(stats, rowreq_ctx->data);
    if (NULL == ifstats_entry) {
        DEBUGMSGTL(("ipIfStatsTable:access",
                    "updating missing entry\n"));

        /*
         * mark row as missing, so we can set discontinuity
         * when it comes back.
         *
         * what else should we do? set refresh to 0? that's not quite right...
         */
        rowreq_ctx->known_missing = 1;
    } else {
        DEBUGMSGTL(("ipIfStatsTable:access",
                    "updating existing entry\n"));

        /*
         * Check for changes & update
         */
        netsnmp_access_systemstats_entry_update(rowreq_ctx->data,
                                                ifstats_entry);

        /*
         * set discontinuity if previously missing.
         */
        if (1 == rowreq_ctx->known_missing) {
            rowreq_ctx->known_missing = 0;
            rowreq_ctx->ipIfStatsDiscontinuityTime =
                netsnmp_get_agent_uptime();
            ipIfStatsTable_lastChange_set(netsnmp_get_agent_uptime());
        }

        /*
         * remove entry from container
         */
        CONTAINER_REMOVE(stats, ifstats_entry);
        netsnmp_access_systemstats_entry_free(ifstats_entry);
    }
}
Ejemplo n.º 20
0
netsnmp_systemstats_entry *
netsnmp_access_systemstats_entry_get_by_index(netsnmp_container *container, oid index)
{
    netsnmp_index   tmp;

    DEBUGMSGTL(("access:systemstats:entry", "by_index\n"));

    if (NULL == container) {
        snmp_log(LOG_ERR,
                 "invalid container for netsnmp_access_systemstats_entry_get_by_index\n");
        return NULL;
    }

    tmp.len = 1;
    tmp.oids = &index;

    return (netsnmp_systemstats_entry *) CONTAINER_FIND(container, &tmp);
}
/**
 * 
 * @domainId
 * @resourceId
 * 
 * @return 
 */
SaErrorT clear_sensor_normal_max(SaHpiDomainIdT domainId, 
                              SaHpiResourceIdT resourceId)

{
        SaErrorT rv = SA_OK;
        netsnmp_index *row_idx;
        saHpiSensorReadingNormalMaxTable_context *sen_norm_max_ctx;

	DEBUGMSGTL ((AGENT, "clear_sensor_normal_max, called\n"));	
	DEBUGMSGTL ((AGENT, "           domainId   [%d]\n", domainId));	
	DEBUGMSGTL ((AGENT, "           resourceId [%d]\n", resourceId));

        row_idx = CONTAINER_FIRST(cb.container);
        if (row_idx) //At least one entry was found.
        {
                do {
                        /* based on the found row_idx get the pointer   */
                        /* to its context (row data)                    */
                        sen_norm_max_ctx = CONTAINER_FIND(cb.container, row_idx);

                        /* before we delete the context we should get the  */
                        /* next row (context) if any before we delete this */ 
                        /* one.                                            */
                        row_idx = CONTAINER_NEXT(cb.container, row_idx);

                        if ((sen_norm_max_ctx->index.oids[saHpiSenNormMaxDomainId_INDEX] ==
                             domainId) &&

                            (sen_norm_max_ctx->index.oids[saHpiSenNormMaxResourceId_INDEX] ==
                             resourceId)) {

                                /* all conditions met remove row */
                                CONTAINER_REMOVE (cb.container, sen_norm_max_ctx);
                                saHpiSensorReadingNormalMaxTable_delete_row (sen_norm_max_ctx);
                                DEBUGMSGTL ((AGENT, "clear_sensor_normal_max: "
                                                    "found row: removing\n"));

                        }

                } while (row_idx);
        } 

        return rv;
}
Ejemplo n.º 22
0
netsnmp_swrun_entry *
netsnmp_swrun_entry_get_by_index(netsnmp_container *container, oid index)
{
    netsnmp_index   tmp;

    DEBUGMSGTL(("swrun:entry", "by_index\n"));
    netsnmp_assert(1 == _swrun_init);

    if (NULL == container) {
        snmp_log(LOG_ERR,
                 "invalid container for netsnmp_swrun_entry_get_by_index\n");
        return NULL;
    }

    tmp.len = 1;
    tmp.oids = &index;

    return (netsnmp_swrun_entry *) CONTAINER_FIND(container, &tmp);
}
Ejemplo n.º 23
0
int
sctpAssocTable_add_or_update(netsnmp_container *assocTable,
                             sctpAssocTable_entry * entry)
{
    /*
     * we have full sctpAssocTable entry, update or add it in the container 
     */
    sctpAssocTable_entry *old;

    entry->valid = 1;

    /*
     * try to find it in the container 
     */
    sctpAssocTable_entry_update_index(entry);
    old = CONTAINER_FIND(assocTable, entry);

    if (old != NULL) {
        /*
         * update existing entry, don't overwrite the timestamp
         */
        time_t          timestamp = old->sctpAssocStartTime;
        if (timestamp == 0 && entry->sctpAssocStartTime == 0
            && entry->sctpAssocState >= SCTPASSOCSTATE_ESTABLISHED)
            timestamp = netsnmp_get_agent_uptime();     /* set the timestamp if it was not set before and entry reaches the right state */
        sctpAssocTable_entry_copy(entry, old);
        old->sctpAssocStartTime = timestamp;
        sctpAssocTable_entry_free(entry);

    } else {
        /*
         * the entry is new, add it there 
         */
        if (entry->sctpAssocStartTime == 0
            && entry->sctpAssocState >= SCTPASSOCSTATE_ESTABLISHED) {
            entry->sctpAssocStartTime = netsnmp_get_agent_uptime();
        }
        CONTAINER_INSERT(assocTable, entry);
    }

    return SNMP_ERR_NOERROR;
}
Ejemplo n.º 24
0
/**
 * Remove a client
 */
void
del_radiusAccClientExtTable(dm_id id)
{
	netsnmp_index idx;
	oid soid[1];
	radiusAccClientExtTable_context *row;

	if (!my_handler)
		return;

	idx.len = 1;
	idx.oids = &soid[0];
	soid[0] = id;

	row = CONTAINER_FIND(cb.container, &idx);
	if (row) {
		CONTAINER_REMOVE(cb.container, row);
		free(row);
	}
}
Ejemplo n.º 25
0
/**
 * check entry for update
 */
static void _check_entry_for_updates (ipDefaultRouterTable_rowreq_ctx * rowreq_ctx, void **magic)
{
    netsnmp_container *defaultrouter_container = magic[0];

    netsnmp_container *to_delete = (netsnmp_container *) magic[1];

    /*
     * check for matching entry using secondary index.
     */
    netsnmp_defaultrouter_entry *defaultrouter_entry = CONTAINER_FIND (defaultrouter_container, rowreq_ctx->data);

    if (NULL == defaultrouter_entry)
    {
        DEBUGMSGTL (("ipDefaultRouterTable:access", "removing missing entry\n"));

        if (NULL == to_delete)
        {
            magic[1] = to_delete = netsnmp_container_find ("lifo");
            if (NULL == to_delete)
                snmp_log (LOG_ERR, "couldn't create delete container\n");
        }
        if (NULL != to_delete)
            CONTAINER_INSERT (to_delete, rowreq_ctx);
    }
    else
    {
        DEBUGMSGTL (("ipDefaultRouterTable:access", "updating existing entry\n"));

        /*
         * Check for changes & update
         */
        netsnmp_access_defaultrouter_entry_update (rowreq_ctx->data, defaultrouter_entry);

        /*
         * remove entry from ifcontainer
         */
        CONTAINER_REMOVE (defaultrouter_container, defaultrouter_entry);
        netsnmp_access_defaultrouter_entry_free (defaultrouter_entry);
    }
}
Ejemplo n.º 26
0
/**
 * check entry for update
 */
static void
_check_entry_for_updates(ipAddressTable_rowreq_ctx * rowreq_ctx,
                         void **magic)
{
    netsnmp_container *ipaddress_container = (netsnmp_container*)magic[0];
    netsnmp_container *to_delete           = (netsnmp_container*)magic[1];

    /*
     * check for matching entry using secondary index.
     */
    netsnmp_ipaddress_entry *ipaddress_entry = (netsnmp_ipaddress_entry*)
        CONTAINER_FIND(ipaddress_container, rowreq_ctx->data);
    if (NULL == ipaddress_entry) {
        DEBUGMSGTL(("ipAddressTable:access", "removing missing entry\n"));

        if (NULL == to_delete) {
            magic[1] = to_delete = netsnmp_container_find("lifo");
            if (NULL == to_delete)
                snmp_log(LOG_ERR, "couldn't create delete container\n");
        }
        if (NULL != to_delete)
            CONTAINER_INSERT(to_delete, rowreq_ctx);
    } else {
        DEBUGMSGTL(("ipAddressTable:access", "updating existing entry\n"));

        /*
         * Check for changes & update
         */
        if (netsnmp_access_ipaddress_entry_update(rowreq_ctx->data,
                                                  ipaddress_entry) > 0)
            rowreq_ctx->ipAddressLastChanged = netsnmp_get_agent_uptime();

        /*
         * remove entry from ifcontainer
         */
        CONTAINER_REMOVE(ipaddress_container, ipaddress_entry);
        netsnmp_access_ipaddress_entry_free(ipaddress_entry);
    }
}
Ejemplo n.º 27
0
void
delete_(unsigned int clientreg, void *clientarg) {

	netsnmp_index index;
	netSnmpIETFWGTable_context *x;
	netSnmpIETFWGTable_context blah;
	oid	tmp[4];

        tmp[0]=3; tmp[1]='A'; tmp[2] ='B'; tmp[3] ='C';

        index.oids = tmp;
        index.len = 4;
	
	blah.index = index;	
	DEBUGMSGTL((AGENT,"Delete first some table."));
	x = CONTAINER_FIND(cb.container, &blah);
	DEBUGMSGTL((AGENT,"Found object [%X]\n",x));
	if (x) {
		DEBUGMSGTL((AGENT,"Deleteing object\n"));
		CONTAINER_REMOVE(cb.container,x);
		DEBUGMSGTL((AGENT,"Object deleted\n"));
	}
		
}
Ejemplo n.º 28
0
int
delete_rdr_row (SaHpiDomainIdT domain_id,
		SaHpiResourceIdT resource_id,
		SaHpiEntryIdT num, SaHpiRdrTypeT type)
{

  saHpiRdrTable_context *ctx;
  oid rdr_oid[RDR_INDEX_NR];
  netsnmp_index rdr_index;
  int rc = AGENT_ERR_NOT_FOUND;

  DEBUGMSGTL ((AGENT, "delete_rdr_row (%d, %d, %d, %d). Entry.\n",
	       domain_id, resource_id, num, type));
// Look at the MIB to find out what the indexs are
  rdr_oid[0] = domain_id;
  rdr_oid[1] = resource_id;
  rdr_oid[2] = num;
  rdr_oid[3] = type;

  // Possible more indexs?
  rdr_index.oids = (oid *) & rdr_oid;
  rdr_index.len = RDR_INDEX_NR;

  ctx = CONTAINER_FIND (cb.container, &rdr_index);

  if (ctx)
    {

      CONTAINER_REMOVE (cb.container, ctx);
      saHpiRdrTable_delete_row (ctx);
      rdr_count = CONTAINER_SIZE (cb.container);
      rc = AGENT_ERR_NOERROR;
    }
  DEBUGMSGTL ((AGENT, "delete_rdr_row. Exit (rc: %d)\n", rc));
  return rc;
}
Ejemplo n.º 29
0
void
put_pwrTable(int idx, char* name, int id, int status)
{
    netsnmp_index   index;
    oid             myoid;
    pwrTable_context* myrow;
    int             makeit=0;

    myoid      = idx;
    index.oids = &myoid;
    index.len  = 1;

    if(!(myrow = (pwrTable_context*)CONTAINER_FIND(cb.container, &index))) {
        myrow = pwrTable_create_row(&index); makeit=1;
    }

    myrow->pwrIndex = idx;
    strcpy(myrow->pwrSystem, name);
    myrow->pwrSystem_len = strlen(name);
    myrow->pwrId  = id;
    myrow->pwrStatus = status;

    if(makeit) CONTAINER_INSERT(cb.container,myrow);
}
Ejemplo n.º 30
0
netsnmp_interface_entry *
netsnmp_access_interface_entry_get_by_name(netsnmp_container *container,
                                const char *name)
{
    netsnmp_interface_entry tmp;

    DEBUGMSGTL(("access:interface:entry", "by_name\n"));
    netsnmp_assert(1 == _access_interface_init);

    if (NULL == container) {
        snmp_log(LOG_ERR,
                 "invalid container for netsnmp_access_interface_entry_get_by_name\n");
        return NULL;
    }

    if (NULL == container->next) {
        snmp_log(LOG_ERR,
                 "secondary index missing for netsnmp_access_interface_entry_get_by_name\n");
        return NULL;
    }

    tmp.name = NETSNMP_REMOVE_CONST(char *, name);
    return (netsnmp_interface_entry*)CONTAINER_FIND(container->next, &tmp);
}