📄 ipcidrroutetable_interface.c
字号:
break; /* * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IPCIDRROUTESTATUS: rc = netsnmp_check_vb_rowstatus_value(var); if (SNMPERR_SUCCESS == rc) { rc = ipCidrRouteStatus_check_value(rowreq_ctx, *((u_long *) var->val. string)); if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from ipCidrRouteStatus_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column %d in _ipCidrRouteTable_check_column\n", column); } return rc;} /* _ipCidrRouteTable_check_column */int_mfd_ipCidrRouteTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ ipCidrRouteTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc; DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_check_objects", "called\n")); netsnmp_assert(NULL != rowreq_ctx); for (; requests; requests = requests->next) { /* * get column number from table request info, and check that column */ netsnmp_table_request_info *tri; tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _ipCidrRouteTable_check_column(rowreq_ctx, requests->requestvb, tri->colnum); if (rc) { netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); break; } } /* for results */ return SNMP_ERR_NOERROR;} /* _mfd_ipCidrRouteTable_check_objects */NETSNMP_STATIC_INLINE int_ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc; DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_indexes", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h */ rc = ipCidrRouteDest_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h */ rc = ipCidrRouteMask_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h */ rc = ipCidrRouteTos_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h */ rc = ipCidrRouteNextHop_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * if individual parts look ok, check them as a whole */ return ipCidrRouteTable_validate_index(rowreq_ctx-> ipCidrRouteTable_reg, rowreq_ctx);} /* _ipCidrRouteTable_check_indexes *//*---------------------------------------------------------------------- * * SET: Undo setup * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ipCidrRouteTable_undo_setup_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_setup_column", "called\n")); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEIFINDEX: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEIFINDEX; rc = ipCidrRouteIfIndex_undo_setup(rowreq_ctx); break; /* * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IPCIDRROUTETYPE: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTETYPE; rc = ipCidrRouteType_undo_setup(rowreq_ctx); break; /* * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h */ case COLUMN_IPCIDRROUTEINFO: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEINFO; rc = ipCidrRouteInfo_undo_setup(rowreq_ctx); break; /* * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTENEXTHOPAS: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTENEXTHOPAS; rc = ipCidrRouteNextHopAS_undo_setup(rowreq_ctx); break; /* * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEMETRIC1: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC1; rc = ipCidrRouteMetric1_undo_setup(rowreq_ctx); break; /* * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEMETRIC2: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC2; rc = ipCidrRouteMetric2_undo_setup(rowreq_ctx); break; /* * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEMETRIC3: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC3; rc = ipCidrRouteMetric3_undo_setup(rowreq_ctx); break; /* * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEMETRIC4: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC4; rc = ipCidrRouteMetric4_undo_setup(rowreq_ctx); break; /* * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEMETRIC5: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC5; rc = ipCidrRouteMetric5_undo_setup(rowreq_ctx); break; /* * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IPCIDRROUTESTATUS: rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTESTATUS; rc = ipCidrRouteStatus_undo_setup(rowreq_ctx); break; default: snmp_log(LOG_ERR, "unknown column %d in _ipCidrRouteTable_undo_setup_column\n", column); break; } return rc;} /* _ipCidrRouteTable_undo_setup_column *//** * @internal * undo setup */int_mfd_ipCidrRouteTable_undo_setup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc; ipCidrRouteTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_setup", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * allocate undo context */ rowreq_ctx->undo = ipCidrRouteTable_allocate_data(); if (NULL == rowreq_ctx->undo) { /** msg already logged */ netsnmp_request_set_error_all(requests, SNMP_ERR_RESOURCEUNAVAILABLE); return SNMP_ERR_NOERROR; } /* * row undo setup */ rowreq_ctx->column_set_flags = 0; rc = ipCidrRouteTable_undo_setup(rowreq_ctx); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from " "ipCidrRouteTable_undo_setup\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } else { /* * column undo setup */ netsnmp_table_request_info *tri; for (; requests; requests = requests->next) { /* * set column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _ipCidrRouteTable_undo_setup_column(rowreq_ctx, tri->colnum); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from " "ipCidrRouteTable_undo_setup_column\n", rc)); netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); } } /* for results */ } return SNMP_ERR_NOERROR;} /* _mfd_ipCidrRouteTable_undo_setup *//** * @internal * undo setup */int_mfd_ipCidrRouteTable_undo_cleanup(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ ipCidrRouteTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc; DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_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 = ipCidrRouteTable_undo_cleanup(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from " "ipCidrRouteTable_undo_cleanup\n", rc)); } /* * release undo context, if needed */ if (rowreq_ctx->undo) { ipCidrRouteTable_release_data(rowreq_ctx->undo); rowreq_ctx->undo = NULL; } /* * clear set flags */ rowreq_ctx->column_set_flags = 0; return SNMP_ERR_NOERROR;} /* _mfd_ipCidrRouteTable_undo_cleanup *//*---------------------------------------------------------------------- * * SET: Set values * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ipCidrRouteTable_set_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_set_column", "called\n")); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_IPCIDRROUTEIFINDEX: if (var->val_len != sizeof(long)) { rc = SNMP_ERR_WRONGLENGTH; snmp_log(LOG_ERR, "varbind size of %d does not match expected size %d\n", var->val_len, sizeof(long)); break; } rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEIFINDEX; rc = ipCidrRouteIfIndex_set(rowreq_ctx, *((long *) var->val.string)); break; /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -