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

C++ CONTAINER_SIZE函数代码示例

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

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



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

示例1: _cache_load

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;
}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:54,代码来源:snmpTlstmCertToTSNTable.c


示例2: _load6

/**
 *
 * @retval  0 no errors
 * @retval !0 errors
 */
static int
_load6(netsnmp_container *container, u_int load_flags)
{
    netsnmp_file              *fp;
    netsnmp_line_process_info  lpi;

    if (NULL == container)
        return -1;

    /*
     * allocate file resources
     */
    fp = netsnmp_file_fill(NULL, "/proc/net/udp6" , O_RDONLY, 0, 0);
    if (NULL == fp) /** msg already logged */
        return -2;
    
    memset(&lpi, 0x0, sizeof(lpi));
    lpi.mem_size = sizeof(netsnmp_udp_endpoint_entry);
    lpi.process = _process_line_udp_ep;
    lpi.user_context = (void*)CONTAINER_SIZE(container);

    container = netsnmp_file_text_parse(fp, container, PM_USER_FUNCTION,
                                        0, &lpi);
    netsnmp_file_release(fp);
    return (NULL == container);
}
开发者ID:duniansampa,项目名称:SigLog,代码行数:31,代码来源:udp_endpoint_linux.cpp


示例3: netsnmp_mysql_cleanup

/*
 * sql cleanup function, called at exit
 */
static void
netsnmp_mysql_cleanup(void)
{
    DEBUGMSGTL(("sql:cleanup"," called\n"));

    /** unregister alarm */
    if (_sql.alarm_id)
        snmp_alarm_unregister(_sql.alarm_id);

    /** save any queued traps */
    if (CONTAINER_SIZE(_sql.queue))
        _sql_process_queue(0,NULL);

    CONTAINER_FREE(_sql.queue);
    _sql.queue = NULL;

    if (_sql.trap_stmt) {
        mysql_stmt_close(_sql.trap_stmt);
        _sql.trap_stmt = NULL;
    }
    if (_sql.vb_stmt) {
        mysql_stmt_close(_sql.vb_stmt);
        _sql.vb_stmt = NULL;
    }
    
    /** disconnect from server */
    netsnmp_sql_disconnected();

    if (_sql.conn) {
        mysql_close(_sql.conn);
        _sql.conn = NULL;
    }

    mysql_library_end();
}
开发者ID:b1nary-chen,项目名称:net-snmp,代码行数:38,代码来源:snmptrapd_sql.c


示例4: _count_handler

static int
_count_handler(netsnmp_mib_handler *handler,
               netsnmp_handler_registration *reginfo,
               netsnmp_agent_request_info *reqinfo,
               netsnmp_request_info *requests)
{
    int                val;

    if (MODE_GET != reqinfo->mode) {
        snmp_log(LOG_ERR, "bad mode in RO handler");
        return SNMP_ERR_GENERR;
    }

    if (NULL == _table->container)
        val = 0;
    else
        val = CONTAINER_SIZE(_table->container);

    snmp_set_var_typed_value(requests->requestvb, ASN_GAUGE,
                             (u_char *) &val, sizeof(val));
   
    if (handler->next && handler->next->access_method)
        return netsnmp_call_next_handler(handler, reginfo, reqinfo,
                                         requests);
    
    return SNMP_ERR_NOERROR;
}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:27,代码来源:snmpTlstmCertToTSNTable.c


示例5: netsnmp_tdata_row_count

int
netsnmp_tdata_row_count(netsnmp_tdata *table)
{
    if (!table)
        return 0;
    return CONTAINER_SIZE( table->container );
}
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:7,代码来源:table_tdata.c


示例6: delete_watchdog_row

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


示例7: handle_saHpiDomainEventEntryCount

 /**
 * 
 * @handler:
 * @reginfo:
 * @reqinfo:
 * @requests:
 * 
 * @return:
 */
int
handle_saHpiDomainEventEntryCount(netsnmp_mib_handler *handler,
                          netsnmp_handler_registration *reginfo,
                          netsnmp_agent_request_info   *reqinfo,
                          netsnmp_request_info         *requests)
{
        /* We are never called for a GETNEXT if it's registered as a
           "instance", as it's "magically" handled for us.  */
        /* a instance handler also only hands us one request at a time, so
           we don't need to loop over a list of requests; we'll only get one. */

        DEBUGMSGTL ((AGENT, "handle_saHpiDomainEventEntryCount, called\n"));

	domain_event_entry_count = CONTAINER_SIZE (cb.container);
        
        switch(reqinfo->mode) {

        case MODE_GET:
                snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
        			        (u_char *) &domain_event_entry_count,
        			        sizeof(domain_event_entry_count));
                break;


        default:
                /* we should never get here, so this is a really bad error */
                return SNMP_ERR_GENERR;
        }

        return SNMP_ERR_NOERROR;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:40,代码来源:saHpiDomainEventTable.c


示例8: tcpListenerTable_container_load

/**
 * load initial data
 *
 * TODO:350:M: Implement tcpListenerTable data load
 * This function will also be called by the cache helper to load
 * the container again (after the container free function has been
 * called to free the previous contents).
 *
 * @param container container to which items should be inserted
 *
 * @retval MFD_SUCCESS              : success.
 * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
 * @retval MFD_ERROR                : other error.
 *
 *  This function is called to load the index(es) (and data, optionally)
 *  for the every row in the data set.
 *
 * @remark
 *  While loading the data, the only important thing is the indexes.
 *  If access to your data is cheap/fast (e.g. you have a pointer to a
 *  structure in memory), it would make sense to update the data here.
 *  If, however, the accessing the data invovles more work (e.g. parsing
 *  some other existing data, or peforming calculations to derive the data),
 *  then you can limit yourself to setting the indexes and saving any
 *  information you will need later. Then use the saved information in
 *  tcpListenerTable_row_prep() for populating data.
 *
 * @note
 *  If you need consistency between rows (like you want statistics
 *  for each row to be from the same time frame), you should set all
 *  data here.
 *
 */
int
tcpListenerTable_container_load(netsnmp_container *container)
{
    netsnmp_container *raw_data =
        netsnmp_access_tcpconn_container_load(NULL,
                                              NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN);

    DEBUGMSGTL(("verbose:tcpListenerTable:tcpListenerTable_container_load",
                "called\n"));

    if (NULL == raw_data)
        return MFD_RESOURCE_UNAVAILABLE;        /* msg already logged */

    /*
     * got all the connections. pull out the active ones.
     */
    CONTAINER_FOR_EACH(raw_data, (netsnmp_container_obj_func *)
                       _add_connection, container);

    /*
     * free the container. we've either claimed each entry, or released it,
     * so the dal function doesn't need to clear the container.
     */
    netsnmp_access_tcpconn_container_free(raw_data, 0);

    DEBUGMSGT(("verbose:tcpListenerTable:tcpListenerTable_cache_load",
               "%d records\n", (int)CONTAINER_SIZE(container)));

    return MFD_SUCCESS;
}                               /* tcpListenerTable_container_load */
开发者ID:millken,项目名称:zhuxianB30,代码行数:63,代码来源:tcpListenerTable_data_access.c


示例9: clear_domain_info_entry

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


示例10: netsnmp_swinst_arch_load

/* ---------------------------------------------------------------------
 */
int
netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
{
    /* Nothing to do */
    DEBUGMSGTL(("swinst:load:arch"," loaded %" NETSNMP_PRIz "d entries\n",
                CONTAINER_SIZE(container)));

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


示例11: _load_udp_endpoint_table_v6

static int 
_load_udp_endpoint_table_v6(netsnmp_container *container, int flag) 
{
    netsnmp_udp_endpoint_entry *ep;
    mib2_udp6Entry_t ue6;
    req_e            req = GET_FIRST;

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

    while (getMibstat(MIB_UDP6_ENDPOINT, &ue6, sizeof(ue6), req, 
                      &Get_everything, 0)==0) {
        req = GET_NEXT;
        ep = netsnmp_access_udp_endpoint_entry_create();
        if (ep == NULL)
            return (-1);
        DEBUGMSGT(("access:udp_endpoint:container", "add entry\n"));

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

        ep->loc_port = ue6.udp6LocalPort;

        /* remote address/port */
        if (IN6_IS_ADDR_UNSPECIFIED(&ue6.udp6EntryInfo.ue_RemoteAddress)) {
            ep->rmt_addr_len = 0;
        } else {
            ep->rmt_addr_len = sizeof(ue6.udp6EntryInfo.ue_RemoteAddress);
            (void)memcpy(&ep->rmt_addr, &ue6.udp6EntryInfo.ue_RemoteAddress,
                         ep->rmt_addr_len);
        }
        ep->rmt_port = ue6.udp6EntryInfo.ue_RemotePort;

        /* instance */
#ifdef SOLARIS_HAVE_RFC4293_SUPPORT  
        ep->instance = ue6.udp6Instance; 
#else
        ep->instance = 0;
#endif
        /* state */
        ep->state = 0; 

        /* index */
        ep->index = CONTAINER_SIZE(container) + 1;        
        ep->oid_index.oids = &ep->index;
        ep->oid_index.len = 1;

        CONTAINER_INSERT(container, (void *)ep);
    }
    return (0);
}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:57,代码来源:udp_endpoint_solaris2.c


示例12: _kvmload

/**
 *
 * @retval  0 no errors
 * @retval !0 errors
 */
static int
_kvmload(netsnmp_container *container, u_int load_flags)
{
    netsnmp_udp_endpoint_entry  *entry;
    struct   kinfo_file *kf;
    int      count;
    int      rc = 0;

    kf = kvm_getfiles(kd, KERN_FILE_BYFILE, DTYPE_SOCKET, sizeof(struct kinfo_file), &count);

    while (count--) {
	if (kf->so_protocol != IPPROTO_UDP)
	    goto skip;
#if !defined(NETSNMP_ENABLE_IPV6)
        if (kf->so_family == AF_INET6)
	    goto skip;
#endif

        entry = netsnmp_access_udp_endpoint_entry_create();
        if(NULL == entry) {
            rc = -3;
            break;
        }

        /** oddly enough, these appear to already be in network order */
        entry->loc_port = ntohs(kf->inp_lport);
        entry->rmt_port = ntohs(kf->inp_fport);
        entry->pid = kf->p_pid;
        
        /** the addr string may need work */
	if (kf->so_family == AF_INET6) {
	    entry->loc_addr_len = entry->rmt_addr_len = 16;
	    memcpy(entry->loc_addr, &kf->inp_laddru, 16);
	    memcpy(entry->rmt_addr, &kf->inp_faddru, 16);
	}
	else {
	    entry->loc_addr_len = entry->rmt_addr_len = 4;
	    memcpy(entry->loc_addr, &kf->inp_laddru[0], 4);
	    memcpy(entry->rmt_addr, &kf->inp_faddru[0], 4);
	}
	DEBUGMSGTL(("udp-mib/data_access", "udp %d %d %d\n",
	    entry->loc_addr_len, entry->loc_port, entry->rmt_port));

        /*
         * add entry to container
         */
        entry->index = CONTAINER_SIZE(container) + 1;
        CONTAINER_INSERT(container, entry);
skip:
	kf++;
    }

    if (rc < 0)
    return rc;
    return 0;
}
开发者ID:fenner,项目名称:net-snmp,代码行数:61,代码来源:udp_endpoint_openbsd.c


示例13: inetCidrRouteTable_container_load

/**
 * load initial data
 *
 * TODO:350:M: Implement inetCidrRouteTable data load
 * This function will also be called by the cache helper to load
 * the container again (after the container free function has been
 * called to free the previous contents).
 *
 * @param container container to which items should be inserted
 *
 * @retval MFD_SUCCESS              : success.
 * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
 * @retval MFD_ERROR                : other error.
 *
 *  This function is called to load the index(es) (and data, optionally)
 *  for the every row in the data set.
 *
 * @remark
 *  While loading the data, the only important thing is the indexes.
 *  If access to your data is cheap/fast (e.g. you have a pointer to a
 *  structure in memory), it would make sense to update the data here.
 *  If, however, the accessing the data invovles more work (e.g. parsing
 *  some other existing data, or peforming calculations to derive the data),
 *  then you can limit yourself to setting the indexes and saving any
 *  information you will need later. Then use the saved information in
 *  inetCidrRouteTable_row_prep() for populating data.
 *
 * @note
 *  If you need consistency between rows (like you want statistics
 *  for each row to be from the same time frame), you should set all
 *  data here.
 *
 */
int
inetCidrRouteTable_container_load(netsnmp_container *container)
{
    netsnmp_container *route_container;

    DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_load", "called\n"));

    /*
     * TODO:351:M: |-> Load/update data in the inetCidrRouteTable container.
     * loop over your inetCidrRouteTable data, allocate a rowreq context,
     * set the index(es) [and data, optionally] and insert into
     * the container.
     *
     * we use the netsnmp data access api to get the data
     */
    route_container =
        netsnmp_access_route_container_load(NULL,
                                            NETSNMP_ACCESS_ROUTE_LOAD_NOFLAGS);
    DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load",
               "%d records\n", (int)CONTAINER_SIZE(route_container)));

    if (NULL == route_container)
        return MFD_RESOURCE_UNAVAILABLE;        /* msg already logged */

    /*
     * we just got a fresh copy of route data. snarf data
     */
    CONTAINER_FOR_EACH(route_container,
                       (netsnmp_container_obj_func *) _snarf_route_entry,
                       container);

    /*
     * free the container. we've either claimed each ifentry, or released it,
     * so the dal function doesn't need to clear the container.
     */
    netsnmp_access_route_container_free(route_container,
                                        NETSNMP_ACCESS_ROUTE_FREE_DONT_CLEAR);

    DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load",
               "%d records\n", (int)CONTAINER_SIZE(container)));

    return MFD_SUCCESS;
}                               /* inetCidrRouteTable_container_load */
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:76,代码来源:inetCidrRouteTable_data_access.c


示例14: _load_tcpconn_table_v4

static int 
_load_tcpconn_table_v4(netsnmp_container *container, int flag) 
{
    mib2_tcpConnEntry_t   tc;
    netsnmp_tcpconn_entry *ep;
    req_e                  req = GET_FIRST;

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

    while (getMibstat(MIB_TCP_CONN, &tc, sizeof(tc), req, 
                          &Get_everything, 0)==0) {
        req = GET_NEXT;
        if ((flag & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN && 
             tc.tcpConnState != MIB2_TCP_listen) ||
            (flag & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN &&
             tc.tcpConnState == 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(tc.tcpConnLocalAddress);
        if (sizeof(ep->loc_addr) < ep->loc_addr_len) {
            netsnmp_access_tcpconn_entry_free(ep);
            return (-1);
        }
        (void)memcpy(&ep->loc_addr, &tc.tcpConnLocalAddress, ep->loc_addr_len);

        ep->loc_port = tc.tcpConnLocalPort;

        /* 
         * remote address/port. The address length is the same as the
         * local address, so no check needed.
         */
        ep->rmt_addr_len = sizeof(tc.tcpConnRemAddress);
        (void)memcpy(&ep->rmt_addr, &tc.tcpConnRemAddress, ep->rmt_addr_len);

        ep->rmt_port = tc.tcpConnRemPort;
        
        /* state/pid */
        ep->tcpConnState = tc.tcpConnState;
        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,代码行数:55,代码来源:tcpConn_solaris2.cpp


示例15: ifTable_container_load

/**
 * load initial data
 *
 * TODO:350:M: Implement ifTable data load
 * This function will also be called by the cache helper to load
 * the container again (after the container free function has been
 * called to free the previous contents).
 *
 * @param container container to which items should be inserted
 *
 * @retval MFD_SUCCESS              : success.
 * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
 * @retval MFD_ERROR                : other error.
 *
 *  This function is called to load the index(es) (and data, optionally)
 *  for the every row in the data set.
 *
 * @remark
 *  While loading the data, the only important thing is the indexes.
 *  If access to your data is cheap/fast (e.g. you have a pointer to a
 *  structure in memory), it would make sense to update the data here.
 *  If, however, the accessing the data invovles more work (e.g. parsing
 *  some other existing data, or peforming calculations to derive the data),
 *  then you can limit yourself to setting the indexes and saving any
 *  information you will need later. Then use the saved information in
 *  ifTable_row_prep() for populating data.
 *
 * @note
 *  If you need consistency between rows (like you want statistics
 *  for each row to be from the same time frame), you should set all
 *  data here.
 *
 */
int
ifTable_container_load(netsnmp_container *container)
{
    netsnmp_container *ifcontainer;

    DEBUGMSGTL(("verbose:ifTable:ifTable_container_load", "called\n"));

    /*
     * TODO:351:M: |-> Load/update data in the ifTable container.
     * loop over your ifTable data, allocate a rowreq context,
     * set the index(es) [and data, optionally] and insert into
     * the container.
     */
    /*
     * ifTable gets its data from the netsnmp_interface API.
     */
    ifcontainer =
        netsnmp_access_interface_container_load(NULL,
                                                NETSNMP_ACCESS_INTERFACE_INIT_NOFLAGS);
    if (NULL == ifcontainer)
        return MFD_RESOURCE_UNAVAILABLE;        /* msg already logged */

    /*
     * we just got a fresh copy of interface data. compare it to
     * what we've already got, and make any adjustements...
     */
    CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *)
                       _check_interface_entry_for_updates, ifcontainer);

    /*
     * now add any new interfaces
     */
    CONTAINER_FOR_EACH(ifcontainer,
                       (netsnmp_container_obj_func *) _add_new_interface,
                       container);

    /*
     * free the container. we've either claimed each ifentry, or released it,
     * so the dal function doesn't need to clear the container.
     */
    netsnmp_access_interface_container_free(ifcontainer,
                                            NETSNMP_ACCESS_INTERFACE_FREE_DONT_CLEAR);

    DEBUGMSGT(("verbose:ifTable:ifTable_cache_load",
               "%d records\n", CONTAINER_SIZE(container)));

    if (_first_load)
        _first_load = 0;

    return MFD_SUCCESS;
}                               /* ifTable_container_load */
开发者ID:grantc,项目名称:ingres-snmp-agent,代码行数:84,代码来源:ifTable_data_access.c


示例16: _cache_free

static void
_cache_free(netsnmp_cache *cache, netsnmp_tdata *table)
{
    netsnmp_tdata_row *row;
    netsnmp_iterator   *tbl_itr;
    certToTSN_entry   *entry;

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

    /** insert rows for active maps into tbl container */
    tbl_itr = CONTAINER_ITERATOR(table->container);
    if (NULL == tbl_itr) {
        DEBUGMSGTL(("tlstmCertToTSNTable:cache:free",
                    "cant get map iterator\n"));
        return;
    }

    row = ITERATOR_FIRST(tbl_itr);
    for( ; row; row = ITERATOR_NEXT(tbl_itr)) {
        entry = row->data;

        /*
         * remove all active rows (they are in the maps container kept
         * by the library). Keep inactive ones for next time.
         */
        if (entry->rowStatus == RS_ACTIVE) {
            tlstmCertToTSNTable_removeEntry(NULL, row);
            ITERATOR_REMOVE(tbl_itr);
            continue;
        }
    }
    ITERATOR_RELEASE(tbl_itr);

    DEBUGMSGTL(("tlstmCertToTSNTable:cache:free", "done, %" NETSNMP_PRIz "d rows\n",
                CONTAINER_SIZE(table->container)));
}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:37,代码来源:snmpTlstmCertToTSNTable.c


示例17: _sql_process_queue

/*
 * process (save) queued items to sql database.
 *
 * dontcare & meeither are dummy params so this function can be used
 * as a netsnmp_alarm callback function.
 */
static void
_sql_process_queue(u_int dontcare, void *meeither)
{
    int        rc;

    /** bail if the queue is empty */
    if( 0 == CONTAINER_SIZE(_sql.queue))
        return;

    DEBUGMSGT(("sql:process", "processing %d queued traps\n",
               (int)CONTAINER_SIZE(_sql.queue)));

    /*
     * if we don't have a database connection, try to reconnect. We
     * don't care if we fail - traps will be logged in that case.
     */
    if (0 == _sql.connected) {
        DEBUGMSGT(("sql:process", "no sql connection; reconnecting\n"));
        (void) netsnmp_mysql_connect();
    }

    CONTAINER_FOR_EACH(_sql.queue, (netsnmp_container_obj_func*)_sql_save,
                       NULL);

    if (_sql.connected) {
        rc = mysql_commit(_sql.conn);
        if (rc) { /* nuts... now what? */
            netsnmp_sql_error("commit failed");
            CONTAINER_FOR_EACH(_sql.queue,
                               (netsnmp_container_obj_func*)_sql_log,
                               NULL);
        }
    }

    CONTAINER_CLEAR(_sql.queue, (netsnmp_container_obj_func*)_sql_buf_free,
                    NULL);
}
开发者ID:b1nary-chen,项目名称:net-snmp,代码行数:43,代码来源:snmptrapd_sql.c


示例18: sctpAssocRemAddrTable_delete_invalid

/*
 * Remove all entries from sctpAssocRemAddrTable, which are not marked as valid.
 * All valid entries are then marked as invalid (to delete them in next cache
 * load, if the entry is not updated). 
 */
void
sctpAssocRemAddrTable_delete_invalid(netsnmp_container *remAddrTable)
{
    netsnmp_container *to_delete = netsnmp_container_find("lifo");

    CONTAINER_FOR_EACH(remAddrTable, sctpAssocRemAddrTable_collect_invalid,
                       to_delete);

    while (CONTAINER_SIZE(to_delete)) {
        sctpAssocRemAddrTable_entry *entry = CONTAINER_FIRST(to_delete);
        CONTAINER_REMOVE(remAddrTable, entry);
        sctpAssocRemAddrTable_entry_free(entry);
        CONTAINER_REMOVE(to_delete, NULL);
    }
    CONTAINER_FREE(to_delete);
}
开发者ID:a5216652166,项目名称:rcp100,代码行数:21,代码来源:sctpTables_common.c


示例19: 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


示例20: ipIfStatsTable_container_load

/**
 * load initial data
 *
 * TODO:350:M: Implement ipIfStatsTable data load
 * This function will also be called by the cache helper to load
 * the container again (after the container free function has been
 * called to free the previous contents).
 *
 * @param container container to which items should be inserted
 *
 * @retval MFD_SUCCESS              : success.
 * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
 * @retval MFD_ERROR                : other error.
 *
 *  This function is called to load the index(es) (and data, optionally)
 *  for the every row in the data set.
 *
 * @remark
 *  While loading the data, the only important thing is the indexes.
 *  If access to your data is cheap/fast (e.g. you have a pointer to a
 *  structure in memory), it would make sense to update the data here.
 *  If, however, the accessing the data invovles more work (e.g. parsing
 *  some other existing data, or peforming calculations to derive the data),
 *  then you can limit yourself to setting the indexes and saving any
 *  information you will need later. Then use the saved information in
 *  ipIfStatsTable_row_prep() for populating data.
 *
 * @note
 *  If you need consistency between rows (like you want statistics
 *  for each row to be from the same time frame), you should set all
 *  data here.
 *
 */
int
ipIfStatsTable_container_load(netsnmp_container * container)
{
    netsnmp_container *stats;

    DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_container_load",
                "called\n"));

    netsnmp_assert(NULL != container);

    stats = netsnmp_access_systemstats_container_load(NULL, NETSNMP_ACCESS_SYSTEMSTATS_LOAD_IFTABLE);
    if (NULL == stats)
        return MFD_RESOURCE_UNAVAILABLE;        /* msg already logged */

    /*
     * TODO:351:M: |-> Load/update data in the ipIfStatsTable container.
     * loop over your ipIfStatsTable data, allocate a rowreq context,
     * set the index(es) [and data, optionally] and insert into
     * the container.
     */

    /*
     * we just got a fresh copy of data. compare it to
     * what we've already got, and make any adjustements...
     */
    CONTAINER_FOR_EACH(container, (netsnmp_container_obj_func *)
                       _check_for_updates, stats);

    /*
     * now add any new entries
     */
    CONTAINER_FOR_EACH(stats, (netsnmp_container_obj_func *)
                       _add_new, container);


    /*
      * free the container. we've either claimed each ifentry, or released it,
     * so the dal function doesn't need to clear the container.
     */
    netsnmp_access_systemstats_container_free(stats,
            NETSNMP_ACCESS_SYSTEMSTATS_FREE_DONT_CLEAR);

    DEBUGMSGT(("verbose:ipIfStatsTable:ipIfStatsTable_container_load",
               "%lu records\n", (unsigned long)CONTAINER_SIZE(container)));

    return MFD_SUCCESS;
}                               /* ipIfStatsTable_container_load */
开发者ID:liquidradio,项目名称:net-snmp,代码行数:80,代码来源:ipIfStatsTable_data_access.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ CONTAINS函数代码示例发布时间:2022-05-30
下一篇:
C++ CONTAINER_REMOVE函数代码示例发布时间: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