📄 ifxtable_interface.c
字号:
* set column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _ifXTable_undo_setup_column(rowreq_ctx, tri->colnum); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from " "ifXTable_undo_setup_column\n", rc)); netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); } } /* for results */ } return SNMP_ERR_NOERROR;} /* _mfd_ifXTable_undo_setup *//** * @internal * undo setup */int_mfd_ifXTable_undo_cleanup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ ifXTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc; DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_cleanup", "called\n")); /* * failed row create in early stages has no rowreq_ctx */ if (NULL == rowreq_ctx) return MFD_SUCCESS; /* * call user cleanup */ rc = ifXTable_undo_cleanup(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from " "ifXTable_undo_cleanup\n", rc)); } /* * release undo context, if needed */ if (rowreq_ctx->undo) { ifXTable_release_data(rowreq_ctx->undo); rowreq_ctx->undo = NULL; } /* * clear set flags */ rowreq_ctx->column_set_flags = 0; return SNMP_ERR_NOERROR;} /* _mfd_ifXTable_undo_cleanup *//*---------------------------------------------------------------------- * * SET: Set values * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ifXTable_set_column(ifXTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:ifXTable:_ifXTable_set_column", "called\n")); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IFLINKUPDOWNTRAPENABLE: if (var->val_len != sizeof(u_long)) { rc = SNMP_ERR_WRONGLENGTH; snmp_log(LOG_ERR, "varbind size of %d does not match expected size %d\n", var->val_len, sizeof(u_long)); break; } rowreq_ctx->column_set_flags |= FLAG_IFLINKUPDOWNTRAPENABLE; rc = ifLinkUpDownTrapEnable_set(rowreq_ctx, *((u_long *) var->val.string)); break; /* * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IFPROMISCUOUSMODE: if (var->val_len != sizeof(u_long)) { rc = SNMP_ERR_WRONGLENGTH; snmp_log(LOG_ERR, "varbind size of %d does not match expected size %d\n", var->val_len, sizeof(u_long)); break; } rowreq_ctx->column_set_flags |= FLAG_IFPROMISCUOUSMODE; rc = ifPromiscuousMode_set(rowreq_ctx, *((u_long *) var->val.string)); break; /* * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ case COLUMN_IFALIAS: rowreq_ctx->column_set_flags |= FLAG_IFALIAS; rc = ifAlias_set(rowreq_ctx, (char *) var->val.string, var->val_len); break; default: snmp_log(LOG_ERR, "unknown column %d in _ifXTable_set_column\n", column); break; } return rc;} /* _ifXTable_set_column */int_mfd_ifXTable_set_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ ifXTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info *tri; int rc = SNMP_ERR_NOERROR; DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_set_values", "called\n")); netsnmp_assert(NULL != rowreq_ctx); rowreq_ctx->column_set_flags = 0; for (; requests; requests = requests->next) { /* * set column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _ifXTable_set_column(rowreq_ctx, requests->requestvb, tri->colnum); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from " "ifXTable_set_column\n", rc)); netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); } } /* for results */ return SNMP_ERR_NOERROR;} /* _mfd_ifXTable_set_values *//*---------------------------------------------------------------------- * * SET: commit * *---------------------------------------------------------------------*//** * @internal * commit the values */int_mfd_ifXTable_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc; ifXTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_commit", "called\n")); netsnmp_assert(NULL != rowreq_ctx); rc = ifXTable_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from " "ifXTable_commit\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } return SNMP_ERR_NOERROR;}int_mfd_ifXTable_undo_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc; ifXTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_commit", "called\n")); netsnmp_assert(NULL != rowreq_ctx); rc = ifXTable_undo_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from " "ifXTable_undo_commit\n", rc)); } return SNMP_ERR_NOERROR;} /* _mfd_ifXTable_commit *//*---------------------------------------------------------------------- * * SET: Undo * *---------------------------------------------------------------------*//** * @internal * undo the value for a particular column */NETSNMP_STATIC_INLINE int_ifXTable_undo_column(ifXTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:ifXTable:_ifXTable_undo_column", "called\n")); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IFLINKUPDOWNTRAPENABLE: rc = ifLinkUpDownTrapEnable_undo(rowreq_ctx); break; /* * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IFPROMISCUOUSMODE: rc = ifPromiscuousMode_undo(rowreq_ctx); break; /* * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ case COLUMN_IFALIAS: rc = ifAlias_undo(rowreq_ctx); break; default: snmp_log(LOG_ERR, "unknown column %d in _ifXTable_undo_column\n", column); break; } return rc;} /* _ifXTable_undo_column */int_mfd_ifXTable_undo_values(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc; ifXTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); netsnmp_table_request_info *tri; DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_values", "called\n")); netsnmp_assert(NULL != rowreq_ctx); for (; requests; requests = requests->next) { /* * set column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _ifXTable_undo_column(rowreq_ctx, requests->requestvb, tri->colnum); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from " "ifXTable_undo_column\n", rc)); } } /* for results */ return SNMP_ERR_NOERROR;} /* _mfd_ifXTable_undo_values *//*********************************************************************** * * DATA ACCESS * ***********************************************************************//** * @internal * initialize the iterator container with functions or wrappers */void_ifXTable_container_init(ifXTable_interface_ctx * if_ctx){ DEBUGMSGTL(("internal:ifXTable:_ifXTable_container_init", "called\n")); /* * set up the cache * * special case: sharing a cache */ if_ctx->cache = netsnmp_cache_find_by_oid(ifTable_oid, ifTable_oid_size); if (NULL != if_ctx->cache) { if_ctx->container = (netsnmp_container *) if_ctx->cache->magic; return; } else { snmp_log(LOG_ERR, "error finding ifTable cache\n"); }}/* * allow direct access to container. */netsnmp_container *_ifXTable_container_get(void){ return ifXTable_if_ctx.container;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -