📄 tcpconnectiontable.c
字号:
/* * Note: this file originally auto-generated by mib2c using * version : 1.48 $ of : mfd-top.m2c,v $ * * $Id: tcpConnectionTable.c 14169 2006-01-25 16:28:12Z dts12 $ *//** \page MFD helper for tcpConnectionTable * * \section intro Introduction * Introductory text. * *//* * standard Net-SNMP includes */#include <net-snmp/net-snmp-config.h>#include <net-snmp/net-snmp-includes.h>#include <net-snmp/agent/net-snmp-agent-includes.h>/* * include our parent header */#include "tcpConnectionTable.h"#include <net-snmp/agent/mib_modules.h>#include "tcpConnectionTable_interface.h"oid tcpConnectionTable_oid[] = { TCPCONNECTIONTABLE_OID };int tcpConnectionTable_oid_size =OID_LENGTH(tcpConnectionTable_oid);tcpConnectionTable_registration tcpConnectionTable_user_context;void initialize_table_tcpConnectionTable(void);void shutdown_table_tcpConnectionTable(void);/** * Initializes the tcpConnectionTable module */voidinit_tcpConnectionTable(void){ DEBUGMSGTL(("verbose:tcpConnectionTable:init_tcpConnectionTable", "called\n")); /* * TODO:300:o: Perform tcpConnectionTable one-time module initialization. */ /* * here we initialize all the tables we're planning on supporting */ if (should_init("tcpConnectionTable")) initialize_table_tcpConnectionTable();} /* init_tcpConnectionTable *//** * Shut-down the tcpConnectionTable module (agent is exiting) */voidshutdown_tcpConnectionTable(void){ if (should_init("tcpConnectionTable")) shutdown_table_tcpConnectionTable();}/** * Initialize the table tcpConnectionTable * (Define its contents and how it's structured) */voidinitialize_table_tcpConnectionTable(void){ tcpConnectionTable_registration *user_context; u_long flags; DEBUGMSGTL(("verbose:tcpConnectionTable:initialize_table_tcpConnectionTable", "called\n")); /* * TODO:301:o: Perform tcpConnectionTable one-time table initialization. */ /* * TODO:302:o: |->Initialize tcpConnectionTable user context * if you'd like to pass in a pointer to some data for this * table, allocate or set it up here. */ user_context = &tcpConnectionTable_user_context; /* * No support for any flags yet, but in the future you would * set any flags here. */ flags = 0; /* * call interface initialization code */ _tcpConnectionTable_initialize_interface(user_context, flags);} /* initialize_table_tcpConnectionTable *//** * Shutdown the table tcpConnectionTable */voidshutdown_table_tcpConnectionTable(void){ /* * call interface shutdown code */ _tcpConnectionTable_shutdown_interface (&tcpConnectionTable_user_context);}/** * extra context initialization (eg default values) * * @param rowreq_ctx : row request context * @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) * * @retval MFD_SUCCESS : no errors * @retval MFD_ERROR : error (context allocate will fail) */inttcpConnectionTable_rowreq_ctx_init(tcpConnectionTable_rowreq_ctx * rowreq_ctx, void *user_init_ctx){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_rowreq_ctx_init", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:210:o: |-> Perform extra tcpConnectionTable rowreq initialization. (eg DEFVALS) */ return MFD_SUCCESS;} /* tcpConnectionTable_rowreq_ctx_init *//** * extra context cleanup * */voidtcpConnectionTable_rowreq_ctx_cleanup(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_rowreq_ctx_cleanup", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:211:o: |-> Perform extra tcpConnectionTable rowreq cleanup. */} /* tcpConnectionTable_rowreq_ctx_cleanup *//** * pre-request callback * * @param user_context * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error */inttcpConnectionTable_pre_request(tcpConnectionTable_registration * user_context){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_pre_request", "called\n")); /* * TODO:510:o: Perform tcpConnectionTable pre-request actions. */ return MFD_SUCCESS;} /* tcpConnectionTable_pre_request *//** * post-request callback * * Note: * New rows have been inserted into the container, and * deleted rows have been removed from the container and * released. * @param user_context * @param rc : MFD_SUCCESS if all requests succeeded * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error (ignored) */inttcpConnectionTable_post_request(tcpConnectionTable_registration * user_context, int rc){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_post_request", "called\n")); /* * TODO:511:o: Perform tcpConnectionTable post-request actions. */ /* * check to set if any rows were changed. */ if (tcpConnectionTable_dirty_get()) { /* * check if request was successful. If so, this would be * a good place to save data to its persistent store. */ if (MFD_SUCCESS == rc) { /* * save changed rows, if you haven't already */ } tcpConnectionTable_dirty_set(0); /* clear table dirty flag */ } return MFD_SUCCESS;} /* tcpConnectionTable_post_request *//********************************************************************** ********************************************************************** *** *** Table tcpConnectionTable *** ********************************************************************** **********************************************************************//* * TCP-MIB::tcpConnectionTable is subid 19 of tcp. * Its status is Current. * OID: .1.3.6.1.2.1.6.19, length: 8 *//* * --------------------------------------------------------------------- * * TODO:200:r: Implement tcpConnectionTable data context functions. *//* * tcpConnectionTable_allocate_data * * Purpose: create new tcpConnectionTable_data. */tcpConnectionTable_data *tcpConnectionTable_allocate_data(void){ /* * TODO:201:r: |-> allocate memory for the tcpConnectionTable data context. */ tcpConnectionTable_data *rtn = SNMP_MALLOC_TYPEDEF(tcpConnectionTable_data); DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_allocate_data", "called\n")); if (NULL == rtn) { snmp_log(LOG_ERR, "unable to malloc memory for new " "tcpConnectionTable_data.\n"); } return rtn;} /* tcpConnectionTable_allocate_data *//* * tcpConnectionTable_release_data * * Purpose: release tcpConnectionTable data. */voidtcpConnectionTable_release_data(tcpConnectionTable_data * data){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_release_data", "called\n")); /* * TODO:202:r: |-> release memory for the tcpConnectionTable data context. */ free(data);} /* tcpConnectionTable_release_data *//** * set mib index(es) * * @param tbl_idx mib index structure * @param tcpConnectionLocalAddressType_val * @param tcpConnectionLocalAddress_val_ptr * @param tcpConnectionLocalAddress_val_ptr_len * @param tcpConnectionLocalPort_val * @param tcpConnectionRemAddressType_val * @param tcpConnectionRemAddress_val_ptr * @param tcpConnectionRemAddress_val_ptr_len * @param tcpConnectionRemPort_val * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error. * * @remark * This convenience function is useful for setting all the MIB index * components with a single function call. It is assume that the C values * have already been mapped from their native/rawformat to the MIB format. */inttcpConnectionTable_indexes_set_tbl_idx(tcpConnectionTable_mib_index * tbl_idx, u_long tcpConnectionLocalAddressType_val, char *tcpConnectionLocalAddress_val_ptr, size_t tcpConnectionLocalAddress_val_ptr_len, u_long tcpConnectionLocalPort_val, u_long tcpConnectionRemAddressType_val, char *tcpConnectionRemAddress_val_ptr, size_t tcpConnectionRemAddress_val_ptr_len, u_long tcpConnectionRemPort_val){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_indexes_set_tbl_idx", "called\n")); /* * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /** WARNING: this code might not work for netsnmp_tcpconn_entry */ /** are cross protocol connections allowed? */ netsnmp_assert(tbl_idx->tcpConnectionRemAddressType == tbl_idx->tcpConnectionLocalAddressType); if (4 == tcpConnectionLocalAddressType_val) tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_IPV4; else if (16 == tcpConnectionLocalAddressType_val) tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_IPV6; else tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_UNKNOWN; /* * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ tbl_idx->tcpConnectionLocalAddress_len = sizeof(tbl_idx->tcpConnectionLocalAddress) / sizeof(tbl_idx->tcpConnectionLocalAddress[0]); /* max length */ /** WARNING: this code might not work for netsnmp_tcpconn_entry */ /* * make sure there is enough space for tcpConnectionLocalAddress data */ if ((NULL == tbl_idx->tcpConnectionLocalAddress) || (tbl_idx->tcpConnectionLocalAddress_len < (tcpConnectionLocalAddress_val_ptr_len))) { snmp_log(LOG_ERR, "not enough space for value\n"); return MFD_ERROR; } tbl_idx->tcpConnectionLocalAddress_len = tcpConnectionLocalAddress_val_ptr_len; memcpy(tbl_idx->tcpConnectionLocalAddress, tcpConnectionLocalAddress_val_ptr, tcpConnectionLocalAddress_val_ptr_len * sizeof(tcpConnectionLocalAddress_val_ptr[0])); /* * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ /** WARNING: this code might not work for netsnmp_tcpconn_entry */ tbl_idx->tcpConnectionLocalPort = tcpConnectionLocalPort_val; /* * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /** WARNING: this code might not work for netsnmp_tcpconn_entry */ tbl_idx->tcpConnectionRemAddressType = tbl_idx->tcpConnectionLocalAddressType; /* * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ tbl_idx->tcpConnectionRemAddress_len = sizeof(tbl_idx->tcpConnectionRemAddress) / sizeof(tbl_idx->tcpConnectionRemAddress[0]); /* max length */ /** WARNING: this code might not work for netsnmp_tcpconn_entry */ /* * make sure there is enough space for tcpConnectionRemAddress data */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -