本文整理汇总了C++中CONTAINER_SIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ CONTAINER_SIZE函数的具体用法?C++ CONTAINER_SIZE怎么用?C++ CONTAINER_SIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CONTAINER_SIZE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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();
}
示例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;
}
示例5: netsnmp_tdata_row_count
int
netsnmp_tdata_row_count(netsnmp_tdata *table)
{
if (!table)
return 0;
return CONTAINER_SIZE( table->container );
}
示例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;
}
示例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;
}
示例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 */
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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 */
示例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);
}
示例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 */