📄 iftable.c
字号:
For character-oriented or fixed-length interfaces, the number of outbound transmission units that could not be transmitted because of errors. Discontinuities in the value of this counter can occur at re-initialization of the management system, and at other times as indicated by the value of ifCounterDiscontinuityTime. * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 0 * * * Its syntax is COUNTER (based on perltype COUNTER) * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) *//** * Extract the current value of the ifOutErrors data. * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param ifOutErrors_val_ptr * Pointer to storage for a u_long variable * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error */intifOutErrors_get(ifTable_rowreq_ctx * rowreq_ctx, u_long * ifOutErrors_val_ptr){ /** we should have a non-NULL pointer */ netsnmp_assert(NULL != ifOutErrors_val_ptr); DEBUGMSGTL(("verbose:ifTable:ifOutErrors_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the ifOutErrors data. * set (* ifOutErrors_val_ptr ) from rowreq_ctx->data */ (*ifOutErrors_val_ptr) = rowreq_ctx->data.ifOutErrors; return MFD_SUCCESS;} /* ifOutErrors_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifOutQLen * ifOutQLen is subid 21 of ifEntry. * Its status is Deprecated, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.21 * Description:The length of the output packet queue (in packets). * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 0 * * * Its syntax is GAUGE (based on perltype GAUGE) * The net-snmp type is ASN_GAUGE. The C type decl is u_long (u_long) *//** * Extract the current value of the ifOutQLen data. * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param ifOutQLen_val_ptr * Pointer to storage for a u_long variable * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error */intifOutQLen_get(ifTable_rowreq_ctx * rowreq_ctx, u_long * ifOutQLen_val_ptr){ /** we should have a non-NULL pointer */ netsnmp_assert(NULL != ifOutQLen_val_ptr); DEBUGMSGTL(("verbose:ifTable:ifOutQLen_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the ifOutQLen data. * set (* ifOutQLen_val_ptr ) from rowreq_ctx->data */ (*ifOutQLen_val_ptr) = rowreq_ctx->data.ifOutQLen; return MFD_SUCCESS;} /* ifOutQLen_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifSpecific * ifSpecific is subid 22 of ifEntry. * Its status is Deprecated, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.22 * Description:A reference to MIB definitions specific to the particular media being used to realize the interface. It is recommended that this value point to an instance of a MIB object in the media-specific MIB, i.e., that this object have the semantics associated with the InstancePointer textual convention defined in RFC 2579. In fact, it is recommended that the media-specific MIB specify what value ifSpecific should/can take for values of ifType. If no MIB definitions specific to the particular media are available, the value should be set to the OBJECT IDENTIFIER { 0 0 }. * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 0 * * * Its syntax is OBJECTID (based on perltype OBJECTID) * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) * This data type requires a length. (Max 255) *//** * Extract the current value of the ifSpecific data. * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param ifSpecific_val_ptr_ptr * Pointer to storage for a oid variable * @param ifSpecific_val_ptr_len_ptr * Pointer to a size_t. On entry, it will contain the size (in bytes) * pointed to by ifSpecific. * 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 (*ifSpecific_val_ptr_len_ptr) bytes of memory, * allocate it using malloc() and update ifSpecific_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.) */intifSpecific_get(ifTable_rowreq_ctx * rowreq_ctx, oid ** ifSpecific_val_ptr_ptr, size_t *ifSpecific_val_ptr_len_ptr){ /** we should have a non-NULL pointer and enough storage */ netsnmp_assert((NULL != ifSpecific_val_ptr_ptr) && (NULL != *ifSpecific_val_ptr_ptr)); netsnmp_assert(NULL != ifSpecific_val_ptr_len_ptr); DEBUGMSGTL(("verbose:ifTable:ifSpecific_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the ifSpecific data. * set (* ifSpecific_val_ptr_ptr ) and (* ifSpecific_val_ptr_len_ptr ) from rowreq_ctx->data */#ifdef IFTABLE_HAS_IFSPECIFIC /* * make sure there is enough space for ifSpecific data */ if ((NULL == (*ifSpecific_val_ptr_ptr)) || ((*ifSpecific_val_ptr_len_ptr) < rowreq_ctx->data.ifSpecific_len)) { /* * allocate space for ifSpecific data */ (*ifSpecific_val_ptr_ptr) = malloc(rowreq_ctx->data.ifSpecific_len * sizeof((*ifSpecific_val_ptr_ptr)[0])); if (NULL == (*ifSpecific_val_ptr_ptr)) { snmp_log(LOG_ERR, "could not allocate memory\n"); return MFD_ERROR; } } (*ifSpecific_val_ptr_len_ptr) = rowreq_ctx->data.ifSpecific_len; memcpy((*ifSpecific_val_ptr_ptr), rowreq_ctx->data.ifSpecific, (*ifSpecific_val_ptr_len_ptr) * sizeof((*ifSpecific_val_ptr_ptr)[0]));#else /* * hard coded */ netsnmp_assert((*ifSpecific_val_ptr_len_ptr) > nullOidLen); (*ifSpecific_val_ptr_len_ptr) = nullOidLen; memcpy(*ifSpecific_val_ptr_ptr, &nullOid, nullOidLen);#endif return MFD_SUCCESS;} /* ifSpecific_get *//** @} *//********************************************************************** ********************************************************************** *** *** Table ifTable *** ********************************************************************** **********************************************************************//* * ifTable is subid 2 of interfaces. * Its status is Current. * OID: .1.3.6.1.2.1.2.2, length: 8 */ /* * NOTE: if you update this chart, please update the versions in * local/mib2c-conf.d/parent-set.m2i * agent/mibgroup/helpers/baby_steps.c * while you're at it. */ /* *********************************************************************** * Baby Steps Flow Chart (2004.06.05) * * * * +--------------+ +================+ U = unconditional path * * |optional state| ||required state|| S = path for success * * +--------------+ +================+ E = path for error * *********************************************************************** * * +--------------+ * | pre | * | request | * +--------------+ * | U * +==============+ * +----------------|| object || * | E || lookup || * | +==============+ * | | S * | +==============+ * | E || check || * |<---------------|| values || * | +==============+ * | | S * | +==============+ * | +<-------|| undo || * | | E || setup || * | | +==============+ * | | | S * | | +==============+ * | | || set ||-------------------------->+ * | | || value || E | * | | +==============+ | * | | | S | * | | +--------------+ | * | | | check |-------------------------->| * | | | consistency | E | * | | +--------------+ | * | | | S | * | | +==============+ +==============+ | * | | || commit ||-------->|| undo || | * | | || || E || commit || | * | | +==============+ +==============+ | * | | | S U |<--------+ * | | +--------------+ +==============+ * | | | irreversible | || undo || * | | | commit | || set || * | | +--------------+ +==============+ * | | | U U | * | +-------------->|<------------------------+ * | +==============+ * | || undo || * | || cleanup || * | +==============+ * +---------------------->| U * +--------------+ * | post | * | request | * +--------------+ * *//** * Setup up context with information needed to undo a set request. * * This function will be called before the individual node undo setup * functions are called. If you need to do any undo setup that is not * related to a specific column, you can do it here. * * Note that the undo context has been allocated with * ifTable_allocate_data(), but may need extra * initialization similar to what you may have done in * ifTable_rowreq_ctx_init(). * Note that an individual node's undo_setup function will only be called * if that node is being set to a new value. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in the node's undo_setup * function, so it won't be done unless it is necessary. * * @param rowreq_ctx * Pointer to the table context (ifTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. */intifTable_undo_setup(ifTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:ifTable:ifTable_undo_setup", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:451:M: |-> Setup ifTable undo. * set up ifTable undo information, in preparation for a set. */ rowreq_ctx->undo->ifentry = netsnmp_access_interface_entry_create(rowreq_ctx->data.ifentry-> name, rowreq_ctx->data.ifentry->index); if (NULL == rowreq_ctx->undo->ifentry) rc = MFD_ERROR; else netsnmp_access_interface_entry_copy(rowreq_ctx->undo->ifentry, rowreq_ctx->data.ifentry); return rc;} /* ifTable_undo_setup *//** * Cleanup up context undo information. * * This function will be called after set/commit processing. If you * allocated any resources in undo_setup, this is the place to release * those resources. * * This function is called regardless of the success or failure of the set * request. If you need to perform different steps for cleanup depending * on success or failure, you can add a flag to the rowreq_ctx. * * @param rowreq_ctx * Pointer to the table context (ifTable_rowre
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -