📄 inetcidrroutetable_interface.c
字号:
/* * save old pointer, so we can free it if replaced */ old_string = requests->requestvb->val.string; dataFreeHook = requests->requestvb->dataFreeHook; if (NULL == requests->requestvb->val.string) { requests->requestvb->val.string = requests->requestvb->buf; requests->requestvb->val_len = sizeof(requests->requestvb->buf); } else if (requests->requestvb->buf == requests->requestvb->val.string) { if (requests->requestvb->val_len != sizeof(requests->requestvb->buf)) requests->requestvb->val_len = sizeof(requests->requestvb->buf); } /* * get column data */ tri = netsnmp_extract_table_info(requests); if (NULL == tri) continue; rc = _inetCidrRouteTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); if (rc) { if (MFD_SKIP == rc) { requests->requestvb->type = SNMP_NOSUCHINSTANCE; rc = SNMP_ERR_NOERROR; } } else if (NULL == requests->requestvb->val.string) { snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); rc = SNMP_ERR_GENERR; } if (rc) netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); /* * if the buffer wasn't used previously for the old data (i.e. it * was allcoated memory) and the get routine replaced the pointer, * we need to free the previous pointer. */ if (old_string && (old_string != requests->requestvb->buf) && (requests->requestvb->val.string != old_string)) { if (dataFreeHook) (*dataFreeHook) (old_string); else free(old_string); } } /* for results */ return SNMP_ERR_NOERROR;} /* _mfd_inetCidrRouteTable_get_values */NETSNMP_STATIC_INLINE int_inetCidrRouteTable_check_indexes(inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_check_indexes", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * (INDEX) inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /* * check that the value is one of defined enums */ if ((SNMPERR_SUCCESS == rc) && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != INETADDRESSTYPE_UNKNOWN) && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != INETADDRESSTYPE_IPV4) && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != INETADDRESSTYPE_IPV6) && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != INETADDRESSTYPE_IPV4Z) && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != INETADDRESSTYPE_IPV6Z) && (rowreq_ctx->tbl_idx.inetCidrRouteDestType != INETADDRESSTYPE_DNS) ) { rc = SNMP_ERR_WRONGVALUE; } if (MFD_SUCCESS != rc) return rc; rc = inetCidrRouteDestType_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ /* * check defined range(s). */ if ((SNMPERR_SUCCESS == rc) && ((rowreq_ctx->tbl_idx.inetCidrRouteDest_len < 0) || (rowreq_ctx->tbl_idx.inetCidrRouteDest_len > 255)) ) { rc = SNMP_ERR_WRONGLENGTH; } if (MFD_SUCCESS != rc) return rc; rc = inetCidrRouteDest_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ /* * check defined range(s). */ if ((SNMPERR_SUCCESS == rc) && ((rowreq_ctx->tbl_idx.inetCidrRoutePfxLen < 0) || (rowreq_ctx->tbl_idx.inetCidrRoutePfxLen > 2040)) ) { rc = SNMP_ERR_WRONGVALUE; } if (MFD_SUCCESS != rc) return rc; rc = inetCidrRoutePfxLen_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h */ if (MFD_SUCCESS != rc) return rc; rc = inetCidrRoutePolicy_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /* * check that the value is one of defined enums */ if ((SNMPERR_SUCCESS == rc) && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != INETADDRESSTYPE_UNKNOWN) && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != INETADDRESSTYPE_IPV4) && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != INETADDRESSTYPE_IPV6) && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != INETADDRESSTYPE_IPV4Z) && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != INETADDRESSTYPE_IPV6Z) && (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != INETADDRESSTYPE_DNS) ) { rc = SNMP_ERR_WRONGVALUE; } if (MFD_SUCCESS != rc) return rc; rc = inetCidrRouteNextHopType_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * (INDEX) inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ /* * check defined range(s). */ if ((SNMPERR_SUCCESS == rc) && ((rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len < 0) || (rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len > 255)) ) { rc = SNMP_ERR_WRONGLENGTH; } if (MFD_SUCCESS != rc) return rc; rc = inetCidrRouteNextHop_check_index(rowreq_ctx); if (MFD_SUCCESS != rc) return SNMP_ERR_NOCREATION; /* * if individual parts look ok, check them as a whole */ return inetCidrRouteTable_validate_index(inetCidrRouteTable_if_ctx. user_ctx, rowreq_ctx);} /* _inetCidrRouteTable_check_indexes *//*********************************************************************** * * SET processing * ***********************************************************************//*---------------------------------------------------------------------- * * SET: Syntax checks * *---------------------------------------------------------------------*//* * @internal * Check the syntax for a particular column */NETSNMP_STATIC_INLINE int_inetCidrRouteTable_check_column(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column){ int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_check_column", "called for %d\n", column)); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * (INDEX) inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ case COLUMN_INETCIDRROUTEDESTTYPE: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ case COLUMN_INETCIDRROUTEDEST: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ case COLUMN_INETCIDRROUTEPFXLEN: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h */ case COLUMN_INETCIDRROUTEPOLICY: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ case COLUMN_INETCIDRROUTENEXTHOPTYPE: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * (INDEX) inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ case COLUMN_INETCIDRROUTENEXTHOP: rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ break; /* * inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H */ case COLUMN_INETCIDRROUTEIFINDEX: rc = netsnmp_check_vb_type(var, ASN_INTEGER); /* * check defined range(s). */ if ((SNMPERR_SUCCESS == rc) && ((*var->val.integer < 0) || (*var->val.integer > 2147483647)) ) { rc = SNMP_ERR_WRONGVALUE; } if (SNMPERR_SUCCESS != rc) { DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteIfIndex", "varbind validation failed (eg bad type or size)\n")); } else { rc = inetCidrRouteIfIndex_check_value(rowreq_ctx, *((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 inetCidrRouteIfIndex_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; /* * inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_INETCIDRROUTETYPE: rc = netsnmp_check_vb_type(var, ASN_INTEGER); /* * check that the value is one of defined enums */ if ((SNMPERR_SUCCESS == rc) && (*var->val.integer != INETCIDRROUTETYPE_OTHER) && (*var->val.integer != INETCIDRROUTETYPE_REJECT) && (*var->val.integer != INETCIDRROUTETYPE_LOCAL) && (*var->val.integer != INETCIDRROUTETYPE_REMOTE) && (*var->val.integer != INETCIDRROUTETYPE_BLACKHOLE) ) { rc = SNMP_ERR_WRONGVALUE; } if (SNMPERR_SUCCESS != rc) { DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteType", "varbind validation failed (eg bad type or size)\n")); } else { rc = inetCidrRouteType_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 inetCidrRouteType_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; /* * inetCidrRouteProto(9)/IANAipRouteProtocol/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ case COLUMN_INETCIDRROUTEPROTO: rc = SNMP_ERR_NOTWRITABLE; break; /* * inetCidrRouteAge(10)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h */ case COLUMN_INETCIDRROUTEAGE: rc = SNMP_ERR_NOTWRITABLE; break; /* * inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H */ case COLUMN_INETCIDRROUTENEXTHOPAS: rc = netsnmp_check_vb_type(var, ASN_UNSIGNED); if (SNMPERR_SUCCESS != rc) { DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteNextHopAS", "varbind validation failed (eg bad type or size)\n")); } else { rc = inetCidrRouteNextHopAS_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 inetCidrRouteNextHopAS_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; /* * inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h */ case COLUMN_INETCIDRROUTEMETRIC1: rc = netsnmp_check_vb_type(var, ASN_INTEGER); if (SNMPERR_SUCCESS != rc) { DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric1", "varbind validation failed (eg bad type or size)\n")); } else { rc = inetCidrRouteMetric1_check_value(rowreq_ctx, *((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 inetCidrRouteMetric1_check_value\n",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -