/** * 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 */
int main(int argc, char** argv) { netsnmp_container *container; netsnmp_config("debugTokens access:tcp,verbose:access:tcp,tcp,verbose:tcp"); netsnmp_container_init_list(); dodebug = 1; container = netsnmp_access_tcpconn_container_load(NULL, 0); netsnmp_access_tcpconn_container_free(container, 0); }