📄 inetnettomediatable.c
字号:
/* * Note: this file originally auto-generated by mib2c using * version : 1.32 $ of : mfd-top.m2c,v $ * * $Id: inetNetToMediaTable.c,v 1.4 2004/10/16 00:21:20 rstory Exp $ *//** \mainpage MFD helper for inetNetToMediaTable * * \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 "inetNetToMediaTable.h"#include <net-snmp/agent/mib_modules.h>#include "inetNetToMediaTable_interface.h"oid inetNetToMediaTable_oid[] = { INETNETTOMEDIATABLE_OID };int inetNetToMediaTable_oid_size =OID_LENGTH(inetNetToMediaTable_oid);void initialize_table_inetNetToMediaTable(void);/** * Initializes the inetNetToMediaTable module */voidinit_inetNetToMediaTable(void){ DEBUGMSGTL(("verbose:inetNetToMediaTable:init_inetNetToMediaTable", "called\n")); /* * TODO:300:o: Perform inetNetToMediaTable one-time module initialization. */ /* * here we initialize all the tables we're planning on supporting */ if (should_init("inetNetToMediaTable")) initialize_table_inetNetToMediaTable();} /* init_inetNetToMediaTable *//** * Initialize the table inetNetToMediaTable * (Define its contents and how it's structured) */voidinitialize_table_inetNetToMediaTable(void){ inetNetToMediaTable_registration_ptr user_context; u_long flags; DEBUGMSGTL(("verbose:inetNetToMediaTable:initialize_table_inetNetToMediaTable", "called\n")); /* * TODO:301:o: Perform inetNetToMediaTable one-time table initialization. */ /* * TODO:302:o: |->Initialize inetNetToMediaTable user context * if you'd like to pass in a pointer to some data for this * table, allocate or set it up here. */ /* * a netsnmp_data_list is a simple way to store void pointers. A simple * string token is used to add, find or remove pointers. */ user_context = netsnmp_create_data_list("inetNetToMediaTable", NULL, NULL); /* * No support for any flags yet, but in the future you would * set any flags here. */ flags = 0; /* * call interface initialization code */ _inetNetToMediaTable_initialize_interface(user_context, flags);} /* initialize_table_inetNetToMediaTable *//** * pre-request callback * * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error */intinetNetToMediaTable_pre_request(inetNetToMediaTable_registration_ptr user_context){ DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_pre_request", "called\n")); /* * TODO:510:o: Perform inetNetToMediaTable pre-request actions. */ return MFD_SUCCESS;} /* inetNetToMediaTable_pre_request *//** * post-request callback * * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error (ignored) */intinetNetToMediaTable_post_request(inetNetToMediaTable_registration_ptr user_context){ DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_post_request", "called\n")); /* * TODO:511:o: Perform inetNetToMediaTable pos-request actions. */ return MFD_SUCCESS;} /* inetNetToMediaTable_post_request *//********************************************************************** ********************************************************************** *** *** Table inetNetToMediaTable *** ********************************************************************** **********************************************************************//* * inetNetToMediaTable is subid 35 of ip. * Its status is Current. * OID: .1.3.6.1.2.1.4.35, length: 8 *//* * --------------------------------------------------------------------- * * TODO:200:r: Implement inetNetToMediaTable data context functions. *//* * inetNetToMediaTable_allocate_data * * Purpose: create new inetNetToMediaTable_data. */inetNetToMediaTable_data *inetNetToMediaTable_allocate_data(void){ /* * TODO:201:r: |-> allocate memory for the inetNetToMediaTable data context. */ /** this might not be right for netsnmp_inetmedia_entry */ inetNetToMediaTable_data *rtn = netsnmp_access_arp_entry_create(); DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_allocate_data", "called\n")); if (NULL == rtn) { snmp_log(LOG_ERR, "unable to malloc memory for new " "inetNetToMediaTable_data.\n"); } return rtn;} /* inetNetToMediaTable_allocate_data *//* * inetNetToMediaTable_release_data * * Purpose: release inetNetToMediaTable data. */voidinetNetToMediaTable_release_data(inetNetToMediaTable_data * data){ DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_release_data", "called\n")); /* * TODO:202:r: |-> release memory for the inetNetToMediaTable data context. */ netsnmp_access_arp_entry_free(data);} /* inetNetToMediaTable_release_data *//** * set mib index(es) * * @param tbl_idx mib index structure * * @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. */intinetNetToMediaTable_indexes_set_tbl_idx(inetNetToMediaTable_mib_index * tbl_idx, long inetNetToMediaIfIndex_val, u_long inetNetToMediaNetAddressType_val, char *inetNetToMediaNetAddress_val_ptr, size_t inetNetToMediaNetAddress_val_ptr_len){ DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_indexes_set_tbl_idx", "called\n")); /* * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H */ /** WARNING: this code might not work for netsnmp_arp_entry */ tbl_idx->inetNetToMediaIfIndex = inetNetToMediaIfIndex_val; /* * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /** WARNING: this code might not work for netsnmp_arp_entry */ tbl_idx->inetNetToMediaNetAddressType = inetNetToMediaNetAddressType_val; /* * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ tbl_idx->inetNetToMediaNetAddress_len = sizeof(tbl_idx->inetNetToMediaNetAddress); /** WARNING: this code might not work for netsnmp_arp_entry */ /* * make sure there is enough space for inetNetToMediaNetAddress data */ if (tbl_idx->inetNetToMediaNetAddress_len < inetNetToMediaNetAddress_val_ptr_len) { snmp_log(LOG_ERR, "not enough space for value\n"); return MFD_ERROR; } tbl_idx->inetNetToMediaNetAddress_len = inetNetToMediaNetAddress_val_ptr_len; memcpy(tbl_idx->inetNetToMediaNetAddress, inetNetToMediaNetAddress_val_ptr, tbl_idx->inetNetToMediaNetAddress_len * sizeof(tbl_idx->inetNetToMediaNetAddress[0])); return MFD_SUCCESS;} /* inetNetToMediaTable_indexes_set_tbl_idx *//** * @internal * set row context indexes * * @param reqreq_ctx the row context that needs updated indexes * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error. * * @remark * This function sets the mib indexs, then updates the oid indexs * from the mib index. */intinetNetToMediaTable_indexes_set(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, long inetNetToMediaIfIndex_val, u_long inetNetToMediaNetAddressType_val, char *inetNetToMediaNetAddress_val_ptr, size_t inetNetToMediaNetAddress_val_ptr_len){ DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_indexes_set", "called\n")); if (MFD_SUCCESS != inetNetToMediaTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, inetNetToMediaIfIndex_val, inetNetToMediaNetAddressType_val, inetNetToMediaNetAddress_val_ptr, inetNetToMediaNetAddress_val_ptr_len)) return MFD_ERROR; /* * convert mib index to oid index */ rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); if (0 != inetNetToMediaTable_index_to_oid(&rowreq_ctx->oid_idx, &rowreq_ctx->tbl_idx)) { return MFD_ERROR; } return MFD_SUCCESS;} /* inetNetToMediaTable_indexes_set *//*--------------------------------------------------------------------- * IP-MIB::inetNetToMediaEntry.inetNetToMediaPhysAddress * inetNetToMediaPhysAddress is subid 4 of inetNetToMediaEntry. * Its status is Current, and its access level is Create. * OID: .1.3.6.1.2.1.4.35.1.4 * Description:The media-dependent `physical' address. As the entries in this table are typically not persistent when this object is written the entity SHOULD NOT save the change to non-volatile storage. * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 1 hashint 1 * settable 1 * hint: 1x: * * Ranges: 0 - 65535; * * Its syntax is PhysAddress (based on perltype OCTETSTR) * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) * This data type requires a length. (Max 65535) *//** * Extract the current value of the inetNetToMediaPhysAddress data. * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param inetNetToMediaPhysAddress_val_ptr_ptr * Pointer to storage for a char variable * @param inetNetToMediaPhysAddress_val_ptr_len_ptr * Pointer to a size_t. On entry, it will contain the size (in bytes) * pointed to by inetNetToMediaPhysAddress. * On exit, this value should contain the data size (in bytes). * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error* * @note If you need more than (*inetNetToMediaPhysAddress_val_ptr_len_ptr) bytes of memory, * allocate it using malloc() and update inetNetToMediaPhysAddress_val_ptr_ptr. * <b>DO NOT</b> free the previous pointer. * The MFD helper will release the memory you allocate. * * @remark If you call this function yourself, you are responsible * for checking if the pointer changed, and freeing any * previously allocated memory. (Not necessary if you pass * in a pointer to static memory, obviously.) */intinetNetToMediaPhysAddress_get(inetNetToMediaTable_rowreq_ctx * rowreq_ctx, char **inetNetToMediaPhysAddress_val_ptr_ptr, size_t *inetNetToMediaPhysAddress_val_ptr_len_ptr){ /** we should have a non-NULL pointer and enough storage */ netsnmp_assert((NULL != inetNetToMediaPhysAddress_val_ptr_ptr) && (NULL != *inetNetToMediaPhysAddress_val_ptr_ptr)); netsnmp_assert(NULL != inetNetToMediaPhysAddress_val_ptr_len_ptr); DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaPhysAddress_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -