• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CONTAINER_INSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CONTAINER_INSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ CONTAINER_INSERT函数的具体用法?C++ CONTAINER_INSERT怎么用?C++ CONTAINER_INSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CONTAINER_INSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sctpAssocTable_collect_invalid

static void
sctpAssocTable_collect_invalid(void *what, void *magic)
{
    sctpAssocTable_entry *entry = what;
    netsnmp_container *to_delete = magic;

    if (entry->valid)
        entry->valid = 0;
    else
        CONTAINER_INSERT(to_delete, entry);
}
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:11,代码来源:sctpTables_common.c


示例2: createRegUserRow

/* Creates a row and inserts it.  
 *
 * Returns: The rows userIndex on success, and 0 otherwise. */
int createRegUserRow(char *stringToRegister) 
{
	int static index = 0;
	
	index++;

	openserSIPRegUserTable_context *theRow;

	oid  *OIDIndex;
	int  stringLength;

	theRow = SNMP_MALLOC_TYPEDEF(openserSIPRegUserTable_context);

	if (theRow == NULL) {
		LM_ERR("failed to create a row for openserSIPRegUserTable\n");
		return 0;
	}

	OIDIndex = pkg_malloc(sizeof(oid));

	if (OIDIndex == NULL) {
		free(theRow);
		LM_ERR("failed to create a row for openserSIPRegUserTable\n");
		return 0;
	}

	stringLength = strlen(stringToRegister);

	OIDIndex[0] = index;

	theRow->index.len  = 1;
	theRow->index.oids = OIDIndex;
	theRow->openserSIPUserIndex = index;

	theRow->openserSIPUserUri     = (unsigned char*)pkg_malloc(stringLength* sizeof(char));
    if(theRow->openserSIPUserUri== NULL)
    {
        pkg_free(OIDIndex);
		free(theRow);
		LM_ERR("failed to create a row for openserSIPRegUserTable\n");
		return 0;

    }
    memcpy(theRow->openserSIPUserUri, stringToRegister, stringLength);
	
    theRow->openserSIPUserUri_len = stringLength;

	theRow->openserSIPUserAuthenticationFailures = 0;

	CONTAINER_INSERT(cb.container, theRow);

	return index;
}
开发者ID:iamroger,项目名称:voip,代码行数:56,代码来源:openserSIPRegUserTable.c


示例3: populate_hotswap

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;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:53,代码来源:saHpiHotSwapTable.c


示例4: _load_tcpconn_table_v6

static int 
_load_tcpconn_table_v6(netsnmp_container *container, int flag) 
{
    mib2_tcp6ConnEntry_t  tc6;
    netsnmp_tcpconn_entry *ep;
    req_e                 req = GET_FIRST;

    DEBUGMSGT(("access:tcpconn:container", "load v6\n"));

    while (getMibstat(MIB_TCP6_CONN, &tc6, sizeof(tc6), req, 
                      &Get_everything, 0)==0) {
        req = GET_NEXT;
        if ((flag & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN && 
             tc6.tcp6ConnState != MIB2_TCP_listen) ||
            (flag & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN &&
             tc6.tcp6ConnState == MIB2_TCP_listen)) {
            continue;
        }
        ep = netsnmp_access_tcpconn_entry_create();
        if (ep == NULL)
            return (-1);
        DEBUGMSGT(("access:tcpconn:container", "add entry\n"));

        /* 
         * local address/port. 
         */
        ep->loc_addr_len = sizeof(tc6.tcp6ConnLocalAddress);
        if (sizeof(ep->loc_addr) < ep->loc_addr_len) {
            netsnmp_access_tcpconn_entry_free(ep);
            return (-1);
        }
        (void)memcpy(&ep->loc_addr, &tc6.tcp6ConnLocalAddress,
                     ep->loc_addr_len);

        ep->loc_port = tc6.tcp6ConnLocalPort;

        /* remote address/port */
        ep->rmt_addr_len = sizeof(tc6.tcp6ConnRemAddress);
        (void)memcpy(&ep->rmt_addr, &tc6.tcp6ConnRemAddress, ep->rmt_addr_len);

        ep->rmt_port = tc6.tcp6ConnRemPort;
        
        /* state/pid */
        ep->tcpConnState = tc6.tcp6ConnState;
        ep->pid = 0;
        ep->arch_data = NULL;

        /* index */
        ep->arbitrary_index = CONTAINER_SIZE(container) + 1;        
        CONTAINER_INSERT(container, (void *)ep);
    }
    return (0);
}
开发者ID:duniansampa,项目名称:SigLog,代码行数:53,代码来源:tcpConn_solaris2.cpp


示例5: createIndex

/* 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;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:58,代码来源:openserSIPPortTable.c


示例6: register_foreach

/** create a new row in the table */
static void
register_foreach(const struct sysORTable* data, void* dummy)
{
    sysORTable_entry *entry;

    sysORLastChange = data->OR_uptime;

    entry = SNMP_MALLOC_TYPEDEF(sysORTable_entry);
    if (!entry) {
	snmp_log(LOG_ERR,
		 "could not allocate storage, sysORTable is inconsistent\n");
    } else {
	const oid firstNext = sysORNextIndex;
	netsnmp_iterator* it = CONTAINER_ITERATOR(table);

	do {
	    const sysORTable_entry* value;
	    const oid cur = sysORNextIndex;

	    if (sysORNextIndex == SNMP_MIN(MAX_SUBID, 2147483647UL))
		sysORNextIndex = 1;
	    else
		++sysORNextIndex;

	    for (value = (sysORTable_entry*)it->curr(it);
		 value && value->sysORIndex < cur;
		 value = (sysORTable_entry*)ITERATOR_NEXT(it)) {
	    }

	    if (value && value->sysORIndex == cur) {
		if (sysORNextIndex < cur)
		    it->reset(it);
	    } else {
		entry->sysORIndex = cur;
		break;
	    }
	} while (firstNext != sysORNextIndex);

	ITERATOR_RELEASE(it);

	if(firstNext == sysORNextIndex) {
            snmp_log(LOG_ERR, "Failed to locate a free index in sysORTable\n");
            free(entry);
	} else {
	    entry->data = data;
	    entry->oid_index.len = 1;
	    entry->oid_index.oids = &entry->sysORIndex;

	    CONTAINER_INSERT(table, entry);
	}
    }
}
开发者ID:duniansampa,项目名称:SigLog,代码行数:53,代码来源:sysORTable.cpp


示例7: _pm_save_index_string_string

/**
 * @internal
 * parse mode: 
 */
void
_pm_save_index_string_string(FILE *f, netsnmp_container *cin,
                             int flags)
{
    char                        line[STRINGMAX], *ptr;
    netsnmp_token_value_index  *tvi;
    size_t                      count = 0, len;

    netsnmp_assert(NULL != f);
    netsnmp_assert(NULL != cin);

    while (fgets(line, sizeof(line), f) != NULL) {

        ++count;
        ptr = line;
        len = strlen(line) - 1;
        if (line[len] == '\n')
            line[len] = 0;

        /*
         * save blank line or comment?
         */
        if (flags & PM_FLAG_SKIP_WHITESPACE) {
            if (NULL == (ptr = skip_white(ptr)))
                continue;
        }

        tvi = SNMP_MALLOC_TYPEDEF(netsnmp_token_value_index);
        if (NULL == tvi) {
            snmp_log(LOG_ERR,"malloc failed\n");
            break;
        }
            
        /*
         * copy whole line, then set second pointer to
         * after token. One malloc, 2 strings!
         */
        tvi->index = count;
        tvi->token = strdup(line);
        if (NULL == tvi->token) {
            snmp_log(LOG_ERR,"malloc failed\n");
            free(tvi);
            break;
        }
        tvi->value.cp = skip_not_white(tvi->token);
        if (NULL != tvi->value.cp) {
            *(tvi->value.cp) = 0;
            ++(tvi->value.cp);
        }
        CONTAINER_INSERT(cin, tvi);
    }
}
开发者ID:ColdStart,项目名称:SNMPD,代码行数:56,代码来源:text_utils.c


示例8: _snarf_arp_entry

/**
 * check entry for update
 *
 */
static void
_snarf_arp_entry(netsnmp_arp_entry *arp_entry,
                 netsnmp_container *container)
{
    inetNetToMediaTable_rowreq_ctx *rowreq_ctx;
    int             inetAddressType;

    DEBUGTRACE;

    netsnmp_assert(NULL != arp_entry);
    netsnmp_assert(NULL != container);

    /*
     * convert the addr len to an inetAddressType
     */
    switch (arp_entry->arp_ipaddress_len) {
    case 4:
        inetAddressType = INETADDRESSTYPE_IPV4;
        break;

    case 6:
        inetAddressType = INETADDRESSTYPE_IPV6;
        break;

    default:
        netsnmp_access_arp_entry_free(arp_entry);
        snmp_log(LOG_ERR, "unsupported address type\n");
        return;
    }

    /*
     * allocate an row context and set the index(es), then add it to
     * the container
     */
    rowreq_ctx = inetNetToMediaTable_allocate_rowreq_ctx(arp_entry, NULL);
    if ((NULL != rowreq_ctx) &&
        (MFD_SUCCESS == inetNetToMediaTable_indexes_set
         (rowreq_ctx, rowreq_ctx->data->if_index, inetAddressType,
          rowreq_ctx->data->arp_ipaddress,
          rowreq_ctx->data->arp_ipaddress_len))) {
        rowreq_ctx->inetNetToMediaRowStatus = ROWSTATUS_ACTIVE;
        CONTAINER_INSERT(container, rowreq_ctx);
    } else {
        if (rowreq_ctx) {
            snmp_log(LOG_ERR, "error setting index while loading "
                     "inetNetToMediaTable cache.\n");
            inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx);
        } else
            netsnmp_access_arp_entry_free(arp_entry);
    }
}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:55,代码来源:inetNetToMediaTable_data_access.c


示例9: sensor_by_name

/*
 * Retrieve a sensor entry by name,
 *  or (optionally) insert a new one into the container
 */
netsnmp_sensor_info *
sensor_by_name( char *name, int create_type )
{
    netsnmp_sensor_info *sp;

    DEBUGMSGTL(("sensors:name", "Get sensor entry (%s)\n", name));

    /*
     *  Look through the list for a matching entry
     */
        /* .. or use a secondary index container ?? */
    for (sp = CONTAINER_FIRST( _sensor_container );
         sp;
         sp = CONTAINER_NEXT(  _sensor_container, sp )) {

        if ( !strcmp( name, sp->name ))
            return sp;
    }

    /*
     * Not found...
     */
    if ( create_type == NETSNMP_SENSOR_FIND_EXIST ) {
        DEBUGMSGTL(("sensors:name", "No such sensor entry\n"));
        return NULL;
    }

    /*
     * ... so let's create a new one, using the type supplied
     */
    sp = SNMP_MALLOC_TYPEDEF( netsnmp_sensor_info );
    if ( sp ) {
        strcpy( sp->name, name );
        sp->type = create_type;
        /*
         * Set up the index value.
         *  
         * All this trouble, just for a simple integer.
         * Surely there must be a better way?
         */
        sp->idx.len  = 1;
        sp->idx.oids = SNMP_MALLOC_TYPEDEF( oid );
        sp->idx.oids[0] = ++_sensor_idx;
    }

    DEBUGMSGTL(("sensors:name", "Create sensor entry (type = %d, index = %d\n",
                                 create_type, _sensor_idx));
    CONTAINER_INSERT( _sensor_container, sp );
    return sp;
}
开发者ID:gittestusername,项目名称:uClinux,代码行数:54,代码来源:hw_sensors.c


示例10: alarmModelTable_insert_defs

/************************************************************
 *
 * Retreives all the alarm definitions
 */
void alarmModelTable_insert_defs(AlarmTableDefs& defs)
{
  for (AlarmTableDefsIterator it = defs.begin(); it != defs.end(); it++)
  {
    alarmModelTable_context* ctx = alarmModelTable_create_row_context((char*) "", 
                                                                      it->alarm_index(), 
                                                                      it->state());
    if (ctx)
    {
      ctx->_alarm_table_def = &(*it);
      CONTAINER_INSERT(cb.container, ctx);
    }
  }
}
开发者ID:LoveleshPandya,项目名称:clearwater-snmp-handlers,代码行数:18,代码来源:alarm_model_table.cpp


示例11: _add_new_interface

/**
 * add new entry
 */
static void
_add_new_interface(netsnmp_interface_entry *ifentry,
                   netsnmp_container *container)
{
    ifTable_rowreq_ctx *rowreq_ctx;

    DEBUGMSGTL(("ifTable:access", "creating new entry\n"));

    /*
     * allocate an row context and set the index(es), then add it to
     * the container and set ifTableLastChanged.
     */
    rowreq_ctx = ifTable_allocate_rowreq_ctx(ifentry);
    if ((NULL != rowreq_ctx) &&
        (MFD_SUCCESS == ifTable_indexes_set(rowreq_ctx, ifentry->index))) {
        CONTAINER_INSERT(container, rowreq_ctx);
        /*
         * fix this when we hit an arch that reports its own last change
         */
        netsnmp_assert(0 == (ifentry->ns_flags &
                             NETSNMP_INTERFACE_FLAGS_HAS_LASTCHANGE));
        if (0 == _first_load) {
            rowreq_ctx->data.ifLastChange = netsnmp_get_agent_uptime();
            ifTable_lastChange_set(rowreq_ctx->data.ifLastChange);
        }
#ifdef USING_IP_MIB_IPV4INTERFACETABLE_IPV4INTERFACETABLE_MODULE
        /*
         * give ipv4If table a crack at the entry
         */
        ipv4InterfaceTable_check_entry_for_updates(rowreq_ctx, ifentry);
#endif
#ifdef USING_IP_MIB_IPV6INTERFACETABLE_IPV6INTERFACETABLE_MODULE
        /*
         * give ipv6If table a crack at the entry
         */
        ipv6InterfaceTable_check_entry_for_updates(rowreq_ctx, ifentry);
#endif
    } else {
        if (rowreq_ctx) {
            snmp_log(LOG_ERR, "error setting index while loading "
                     "ifTable cache.\n");
            ifTable_release_rowreq_ctx(rowreq_ctx);
        } else {
            snmp_log(LOG_ERR, "memory allocation failed while loading "
                     "ifTable cache.\n");
            netsnmp_access_interface_entry_free(ifentry);
        }
    }
}
开发者ID:grantc,项目名称:ingres-snmp-agent,代码行数:52,代码来源:ifTable_data_access.c


示例12: netsnmp_swinst_arch_load

/* ---------------------------------------------------------------------
 */
int
netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
{
    FILE *p = popen("dpkg-query --show --showformat '${Package}#${Version}#${Section}#${Priority}#${Essential}#${Status}\n'", "r");
    char package[SNMP_MAXBUF];
    char version[SNMP_MAXBUF];
    char section[SNMP_MAXBUF];
    char priority[SNMP_MAXBUF];
    char essential[SNMP_MAXBUF];
    char status[SNMP_MAXBUF];
    char buf[BUFSIZ];
    netsnmp_swinst_entry *entry;
    int i = 0;

    if (p == NULL) {
	snmp_perror("dpkg-list");
	return 1;
    }

    while (fgets(buf, BUFSIZ, p)) {
	DEBUGMSG(("swinst_apt", "entry: %s\n", buf));
        entry = netsnmp_swinst_entry_create( i++ );
        if (NULL == entry)
            continue;   /* error already logged by function */
        CONTAINER_INSERT(container, entry);

	sscanf(buf, apt_fmt, package, version, section, priority, essential, status);
	if (strstr(status, "not-installed"))
	    continue;

        entry->swName_len = snprintf( entry->swName, sizeof(entry->swName),
                                      "%s-%s", package, version);
	if (entry->swName_len >= sizeof(entry->swName))
	    entry->swName_len = sizeof(entry->swName)-1;
        entry->swType = (strcmp(essential, "yes") == 0)
                        ? 2      /* operatingSystem */
                        : 4;     /*  application    */

        entry->swDate_len = 8;
	memcpy(entry->swDate, "\0\0\1\1\0\0\0\0", 8);
    }
    pclose(p);
    DEBUGMSGTL(("swinst:load:arch"," loaded %d entries\n",
                (int) CONTAINER_SIZE(container)));

    return 0;
}
开发者ID:duniansampa,项目名称:SigLog,代码行数:49,代码来源:swinst_apt.cpp


示例13: _add_new_entry

/**
 * add new entry
 */
static void
_add_new_entry(netsnmp_ipaddress_entry *ipaddress_entry,
               netsnmp_container *container)
{
    ipAddressTable_rowreq_ctx *rowreq_ctx;

    DEBUGMSGTL(("ipAddressTable:access", "creating new entry\n"));

    netsnmp_assert(NULL != ipaddress_entry);
    netsnmp_assert(NULL != container);

    /*
     * allocate an row context and set the index(es)
     */
    rowreq_ctx = ipAddressTable_allocate_rowreq_ctx(ipaddress_entry, NULL);
    if ((NULL != rowreq_ctx) &&
        (MFD_SUCCESS ==
         ipAddressTable_indexes_set(rowreq_ctx,
                                    ipaddress_entry->ia_address_len,
                                    ipaddress_entry->ia_address,
                                    ipaddress_entry->ia_address_len))) {
        if (CONTAINER_INSERT(container, rowreq_ctx) < 0) {
            DEBUGMSGTL (("ipAddressTable:access","container insert failed for new entry\n"));
            ipAddressTable_release_rowreq_ctx(rowreq_ctx);
            return;
        }
        rowreq_ctx->ipAddressLastChanged =
            rowreq_ctx->ipAddressCreated = netsnmp_get_agent_uptime();
    } else {
        if (NULL != rowreq_ctx) {
            snmp_log(LOG_ERR, "error setting index while loading "
                     "ipAddressTable cache.\n");
            ipAddressTable_release_rowreq_ctx(rowreq_ctx);
        } else {
            snmp_log(LOG_ERR, "memory allocation failed while loading "
                     "ipAddressTable cache.\n");
            netsnmp_access_ipaddress_entry_free(ipaddress_entry);
        }

        return;
    }

    /*-------------------------------------------------------------------
     * handle data that isn't part of the data_access ipaddress structure
     */
    rowreq_ctx->ipAddressRowStatus = ROWSTATUS_ACTIVE;
}
开发者ID:prak5192,项目名称:C_Project,代码行数:50,代码来源:ipAddressTable_data_access.c


示例14: mysql_handler

/*
 * sql trap handler
 */
int
mysql_handler(netsnmp_pdu           *pdu,
              netsnmp_transport     *transport,
              netsnmp_trapd_handler *handler)
{
    sql_buf     *sqlb;
    int          old_format, rc;

    DEBUGMSGTL(("sql:handler", "called\n"));

    /** allocate a buffer to save data */
    sqlb = _sql_buf_get();
    if (NULL == sqlb) {
        snmp_log(LOG_ERR, "Could not allocate trap sql buffer\n");
        return syslog_handler( pdu, transport, handler );
    }

    /** save OID output format and change to numeric */
    old_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID,
                                    NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT,
                       NETSNMP_OID_OUTPUT_NUMERIC);


    rc = _sql_save_trap_info(sqlb, pdu, transport);
    rc = _sql_save_varbind_info(sqlb, pdu);

    /** restore previous OID output format */
    netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT,
                       old_format);

    /** insert into queue */
    rc = CONTAINER_INSERT(_sql.queue, sqlb);
    if(rc) {
        snmp_log(LOG_ERR, "Could not log queue sql trap buffer\n");
        _sql_log(sqlb, NULL);
        _sql_buf_free(sqlb, 0);
        return -1;
    }

    /** save queue if size is > max */
    if (CONTAINER_SIZE(_sql.queue) >= _sql.queue_max)
        _sql_process_queue(0,NULL);

    return 0;
}
开发者ID:b1nary-chen,项目名称:net-snmp,代码行数:49,代码来源:snmptrapd_sql.c


示例15: createRow

/* Create a row at the given index, containing stringToRegister, and insert it
 * into the table.  Note that stringToRegister will be copied, so it is not
 * necessary to pre-allocate this string anywhere. */
void createRow(int index, char *stringToRegister) {

	openserSIPMethodSupportedTable_context *theRow;

	oid  *OIDIndex;
	char *copiedString;
	int  stringLength;

	theRow = SNMP_MALLOC_TYPEDEF(openserSIPMethodSupportedTable_context);

	if (theRow == NULL) {
		LM_ERR("failed to create a row for openserSIPMethodSupportedTable\n");
		return;
	}

	OIDIndex = pkg_malloc(sizeof(oid));

	if (OIDIndex == NULL) {
		free(theRow);
		LM_ERR("failed to create a row for openserSIPMethodSupportedTable\n");
		return;
	}

	stringLength = strlen(stringToRegister);

	copiedString = pkg_malloc((stringLength + 1) * sizeof(char));

	if (copiedString == NULL) {
		SNMP_FREE(theRow);
		LM_ERR("failed to create a row for openserSIPMethodSupportedTable\n");
		return;
	}

	strcpy(copiedString, stringToRegister);

	OIDIndex[0] = index;

	theRow->index.len  = 1;
	theRow->index.oids = OIDIndex;
	theRow->openserSIPMethodSupportedIndex = index;

	theRow->openserSIPMethodName     = (unsigned char*) copiedString;
	theRow->openserSIPMethodName_len = stringLength;

	CONTAINER_INSERT(cb.container, theRow);
}
开发者ID:NormB,项目名称:opensips,代码行数:49,代码来源:openserSIPMethodSupportedTable.c


示例16: _snarf_route_entry

/**
 * check entry for update
 */
static void
_snarf_route_entry(netsnmp_route_entry *route_entry,
                   netsnmp_container *container)
{
    inetCidrRouteTable_rowreq_ctx *rowreq_ctx;

    netsnmp_assert(NULL != route_entry);
    netsnmp_assert(NULL != container);

    /*
     * per  inetCidrRouteType:
     *
     * Routes which do not result in traffic forwarding or 
     * rejection should not be displayed even if the  
     * implementation keeps them stored internally.
     */
    if (route_entry->rt_type == 0) {    /* set when route not up */
        DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load", "skipping route\n"));
        netsnmp_access_route_entry_free(route_entry);
        return;
    }

    /*
     * allocate an row context and set the index(es), then add it to
     * the container
     */
    rowreq_ctx = inetCidrRouteTable_allocate_rowreq_ctx(route_entry, NULL);
    if ((NULL != rowreq_ctx) &&
        (MFD_SUCCESS == inetCidrRouteTable_indexes_set
         (rowreq_ctx, route_entry->rt_dest_type,
          (char *) route_entry->rt_dest, route_entry->rt_dest_len,
          route_entry->rt_pfx_len,
          route_entry->rt_policy, route_entry->rt_policy_len,
          route_entry->rt_nexthop_type,
          (char *) route_entry->rt_nexthop, route_entry->rt_nexthop_len))) {
        CONTAINER_INSERT(container, rowreq_ctx);
        rowreq_ctx->row_status = ROWSTATUS_ACTIVE;
    } else {
        if (rowreq_ctx) {
            snmp_log(LOG_ERR, "error setting index while loading "
                     "inetCidrRoute cache.\n");
            inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
        } else
            netsnmp_access_route_entry_free(route_entry);
    }
}
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:49,代码来源:inetCidrRouteTable_data_access.c


示例17: _add_new_entry

/**
 * add new entry
 */
static void
_add_new_entry(netsnmp_defaultrouter_entry *defaultrouter_entry,
               netsnmp_container *container)
{
    ipDefaultRouterTable_rowreq_ctx *rowreq_ctx;

    DEBUGMSGTL(("ipDefaultRouterTable:access", "creating new entry\n"));

    netsnmp_assert(NULL != defaultrouter_entry);
    netsnmp_assert(NULL != container);

    /*
     * allocate an row context and set the index(es)
     */
    rowreq_ctx = ipDefaultRouterTable_allocate_rowreq_ctx(defaultrouter_entry,
                                                          NULL);
    if ((NULL != rowreq_ctx) &&
            (MFD_SUCCESS ==
             ipDefaultRouterTable_indexes_set(rowreq_ctx,
                 defaultrouter_entry->dr_addresstype,
                 defaultrouter_entry->dr_address,
                 defaultrouter_entry->dr_address_len,
                 defaultrouter_entry->dr_if_index))) {
        if (CONTAINER_INSERT(container, rowreq_ctx) < 0) {
            DEBUGMSGTL(("ipAddressTable:access",
                         "container insert failed for new entry\n"));
            ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx);
            return;
        }
    } else {
        if (NULL != rowreq_ctx) {
            snmp_log(LOG_ERR, "error setting index while loading "
                    "ipDefaultRouterTable cache.\n");
            ipDefaultRouterTable_release_rowreq_ctx(rowreq_ctx);
        } else {
            snmp_log(LOG_ERR, "memory allocation failed while loading "
                     "ipDefaultRouterTable cache.\n");
            netsnmp_access_defaultrouter_entry_free(defaultrouter_entry);
        }

        return;
    }
}
开发者ID:duniansampa,项目名称:SigLog,代码行数:46,代码来源:ipDefaultRouterTable_data_access.cpp


示例18: sctpTables_add_rem_port

static void
sctpTables_add_rem_port(sctpAssocTable_entry * assoc,
                        sctpTables_containers * containers)
{
    sctpLookupRemPortTable_entry *entry;

    entry = sctpLookupRemPortTable_entry_create();
    if (entry == NULL) {
        DEBUGMSGTL(("sctp:tables:fill_lookup",
                    "cannot create sctpLookupRemPortTable_entry"));
        return;
    }

    entry->sctpAssocId = assoc->sctpAssocId;
    entry->sctpAssocRemPort = assoc->sctpAssocRemPort;
    entry->sctpLookupRemPortStartTime = assoc->sctpAssocStartTime;
    sctpLookupRemPortTable_entry_update_index(entry);
    CONTAINER_INSERT(containers->sctpLookupRemPortTable, entry);
}
开发者ID:a5216652166,项目名称:rcp100,代码行数:19,代码来源:sctpTables_common.c


示例19: sctpAssocTable_add_or_update

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;
}
开发者ID:a5216652166,项目名称:rcp100,代码行数:42,代码来源:sctpTables_common.c


示例20: init_ituAlarmTable

/************************************************************
 *
 *  Initializes the ituAlarmTable module
 */
void init_ituAlarmTable(void)
{
  AlarmTableDefs& defs = AlarmTableDefs::get_instance();

  if (initialize_table_ituAlarmTable() == SNMP_ERR_NOERROR)
  {
    for (AlarmTableDefsIterator it = defs.begin(); it != defs.end(); it++)
    {
      ituAlarmTable_context* ctx = ituAlarmTable_create_row_context((char*) "", 
                                                                    it->index(), 
                                                                    it->severity());
      if (ctx)
      {
        ctx->_alarm_table_def = &(*it);

        CONTAINER_INSERT(cb.container, ctx);
      }
    }
  }
}
开发者ID:AiprNick,项目名称:clearwater-snmp-handlers,代码行数:24,代码来源:itu_alarm_table.cpp



注:本文中的CONTAINER_INSERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CONTAINER_REMOVE函数代码示例发布时间:2022-05-30
下一篇:
C++ CONTAINER_FIND函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap