📄 ipaddresstable.c
字号:
/* * Note: this file originally auto-generated by mib2c using * version : 1.48 $ of : mfd-top.m2c,v $ * * $Id: ipAddressTable.c 15640 2006-12-06 15:10:40Z rstory $ *//** \page MFD helper for ipAddressTable * * \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 <net-snmp/data_access/interface.h>/* * include our parent header */#include "ipAddressTable.h"#include <net-snmp/agent/mib_modules.h>#include "ipAddressTable_interface.h"oid ipAddressTable_oid[] = { IPADDRESSTABLE_OID };int ipAddressTable_oid_size = OID_LENGTH(ipAddressTable_oid);ipAddressTable_registration ipAddressTable_user_context;void initialize_table_ipAddressTable(void);void shutdown_table_ipAddressTable(void);/** * Initializes the ipAddressTable module */voidinit_ipAddressTable(void){ DEBUGMSGTL(("verbose:ipAddressTable:init_ipAddressTable", "called\n")); /* * TODO:300:o: Perform ipAddressTable one-time module initialization. */ /* * here we initialize all the tables we're planning on supporting */ if (should_init("ipAddressTable")) initialize_table_ipAddressTable();} /* init_ipAddressTable *//** * Shut-down the ipAddressTable module (agent is exiting) */voidshutdown_ipAddressTable(void){ if (should_init("ipAddressTable")) shutdown_table_ipAddressTable();}/** * Initialize the table ipAddressTable * (Define its contents and how it's structured) */voidinitialize_table_ipAddressTable(void){ ipAddressTable_registration *user_context; u_long flags; DEBUGMSGTL(("verbose:ipAddressTable:initialize_table_ipAddressTable", "called\n")); /* * TODO:301:o: Perform ipAddressTable one-time table initialization. */ /* * TODO:302:o: |->Initialize ipAddressTable 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 = NULL; /* * No support for any flags yet, but in the future you would * set any flags here. */ flags = 0; /* * call interface initialization code */ _ipAddressTable_initialize_interface(user_context, flags);} /* initialize_table_ipAddressTable *//** * Shutdown the table ipAddressTable */voidshutdown_table_ipAddressTable(void){ /* * call interface shutdown code */ _ipAddressTable_shutdown_interface(&ipAddressTable_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) */intipAddressTable_rowreq_ctx_init(ipAddressTable_rowreq_ctx * rowreq_ctx, void *user_init_ctx){ DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_rowreq_ctx_init", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:210:o: |-> Perform extra ipAddressTable rowreq initialization. (eg DEFVALS) */ return MFD_SUCCESS;} /* ipAddressTable_rowreq_ctx_init *//** * extra context cleanup * */voidipAddressTable_rowreq_ctx_cleanup(ipAddressTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_rowreq_ctx_cleanup", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:211:o: |-> Perform extra ipAddressTable rowreq cleanup. */ if (NULL != rowreq_ctx->data) { ipAddressTable_release_data(rowreq_ctx->data); rowreq_ctx->data = NULL; }} /* ipAddressTable_rowreq_ctx_cleanup *//** * pre-request callback * * @param user_context * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error */intipAddressTable_pre_request(ipAddressTable_registration * user_context){ DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_pre_request", "called\n")); /* * TODO:510:o: Perform ipAddressTable pre-request actions. */ return MFD_SUCCESS;} /* ipAddressTable_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) */intipAddressTable_post_request(ipAddressTable_registration * user_context, int rc){ DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_post_request", "called\n")); /* * TODO:511:o: Perform ipAddressTable post-request actions. */ /* * check to set if any rows were changed. */ if (ipAddressTable_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 */ } ipAddressTable_dirty_set(0); /* clear table dirty flag */ } return MFD_SUCCESS;} /* ipAddressTable_post_request *//********************************************************************** ********************************************************************** *** *** Table ipAddressTable *** ********************************************************************** **********************************************************************//* * IP-MIB::ipAddressTable is subid 34 of ip. * Its status is Current. * OID: .1.3.6.1.2.1.4.34, length: 8 *//* * --------------------------------------------------------------------- * * TODO:200:r: Implement ipAddressTable data context functions. *//* * ipAddressTable_allocate_data * * Purpose: create new ipAddressTable_data. */ipAddressTable_data *ipAddressTable_allocate_data(void){ /* * TODO:201:r: |-> allocate memory for the ipAddressTable data context. */ ipAddressTable_data *rtn = netsnmp_access_ipaddress_entry_create(); DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_allocate_data", "called\n")); if (NULL == rtn) { snmp_log(LOG_ERR, "unable to malloc memory for new " "ipAddressTable_data.\n"); } return rtn;} /* ipAddressTable_allocate_data *//* * ipAddressTable_release_data * * Purpose: release ipAddressTable data. */voidipAddressTable_release_data(ipAddressTable_data * data){ DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_release_data", "called\n")); /* * TODO:202:r: |-> release memory for the ipAddressTable data context. */ netsnmp_access_ipaddress_entry_free(data);} /* ipAddressTable_release_data *//*--------------------------------------------------------------------- * IP-MIB::ipAddressEntry.ipAddressAddrType * ipAddressAddrType is subid 1 of ipAddressEntry. * Its status is Current, and its access level is NoAccess. * OID: .1.3.6.1.2.1.4.34.1.1 * Description:The address type of ipAddressAddr. * * Attributes: * accessible 0 isscalar 0 enums 1 hasdefval 0 * readable 0 iscolumn 1 ranges 0 hashint 0 * settable 0 * * Enum range: 5/8. Values: unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) * * Its syntax is InetAddressType (based on perltype INTEGER) * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) * * * * NOTE: NODE ipAddressAddrType IS NOT ACCESSIBLE * * *//** * map a value from its original native format to the MIB format. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : Any other error * * @note parameters follow the memset convention (dest, src). * * @note generation and use of this function can be turned off by re-running * mib2c after adding the following line to the file * default-node-ipAddressAddrType.m2d : * @verbatim $m2c_node_skip_mapping = 1@endverbatim * * @remark * If the values for your data type don't exactly match the * possible values defined by the mib, you should map them here. * Otherwise, just do a direct copy. */intipAddressAddrType_map(u_long * mib_ipAddressAddrType_val_ptr, u_long raw_ipAddressAddrType_val){ netsnmp_assert(NULL != mib_ipAddressAddrType_val_ptr); DEBUGMSGTL(("verbose:ipAddressTable:ipAddressAddrType_map", "called\n")); /* * TODO:241:o: |-> Implement ipAddressAddrType enum mapping. * uses INTERNAL_* macros defined in the header files */ switch (raw_ipAddressAddrType_val) { case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4: *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4; break; case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6: *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6; break; default: snmp_log(LOG_ERR, "couldn't map value %ld for ipAddressAddrType\n", raw_ipAddressAddrType_val); *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_UNKNOWN; } return MFD_SUCCESS;} /* ipAddressAddrType_map *//** * set mib index(es) * * @param tbl_idx mib index structure * @param ipAddressAddrType_val * @param ipAddressAddr_val_ptr * @param ipAddressAddr_val_ptr_len * * @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. */intipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * tbl_idx, u_long ipAddressAddrType_val, char *ipAddressAddr_val_ptr, size_t ipAddressAddr_val_ptr_len){ DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set_tbl_idx", "called\n")); /* * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /** WARNING: this code might not work for netsnmp_ipaddress_entry */ ipAddressAddrType_map(&tbl_idx->ipAddressAddrType, ipAddressAddrType_val); /* * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ tbl_idx->ipAddressAddr_len = sizeof(tbl_idx->ipAddressAddr) / sizeof(tbl_idx->ipAddressAddr[0]); /* max length */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -