📄 inetcidrroutetable.c
字号:
size_t inetCidrRouteNextHop_val_ptr_len){ DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_indexes_set_tbl_idx", "called\n")); /* * inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /** WARNING: this code might not work for netsnmp_route_entry */ tbl_idx->inetCidrRouteDestType = inetCidrRouteDestType_val; /* * inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ tbl_idx->inetCidrRouteDest_len = sizeof(tbl_idx->inetCidrRouteDest) / sizeof(tbl_idx->inetCidrRouteDest[0]); /* max length */ /** WARNING: this code might not work for netsnmp_route_entry */ /* * make sure there is enough space for inetCidrRouteDest data */ if ((NULL == tbl_idx->inetCidrRouteDest) || (tbl_idx->inetCidrRouteDest_len < (inetCidrRouteDest_val_ptr_len))) { snmp_log(LOG_ERR, "not enough space for value\n"); return MFD_ERROR; } tbl_idx->inetCidrRouteDest_len = inetCidrRouteDest_val_ptr_len; memcpy(tbl_idx->inetCidrRouteDest, inetCidrRouteDest_val_ptr, inetCidrRouteDest_val_ptr_len * sizeof(inetCidrRouteDest_val_ptr[0])); /* * inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H */ /** WARNING: this code might not work for netsnmp_route_entry */ tbl_idx->inetCidrRoutePfxLen = inetCidrRoutePfxLen_val; /* * inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h */ tbl_idx->inetCidrRoutePolicy_len = sizeof(tbl_idx->inetCidrRoutePolicy) / sizeof(tbl_idx->inetCidrRoutePolicy[0]); /* max length */ /** WARNING: this code might not work for netsnmp_route_entry */ /* * make sure there is enough space for inetCidrRoutePolicy data */ if ((NULL == tbl_idx->inetCidrRoutePolicy) || (tbl_idx->inetCidrRoutePolicy_len < (inetCidrRoutePolicy_val_ptr_len))) { snmp_log(LOG_ERR, "not enough space for value\n"); return MFD_ERROR; } if (0 == inetCidrRoutePolicy_val_ptr_len) { inetCidrRoutePolicy_val_ptr_len = nullOidLen / sizeof(oid); inetCidrRoutePolicy_val_ptr = nullOid; } tbl_idx->inetCidrRoutePolicy_len = inetCidrRoutePolicy_val_ptr_len; memcpy(tbl_idx->inetCidrRoutePolicy, inetCidrRoutePolicy_val_ptr, inetCidrRoutePolicy_val_ptr_len * sizeof(inetCidrRoutePolicy_val_ptr[0])); /* * inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ /** WARNING: this code might not work for netsnmp_route_entry */ tbl_idx->inetCidrRouteNextHopType = inetCidrRouteNextHopType_val; /* * inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ tbl_idx->inetCidrRouteNextHop_len = sizeof(tbl_idx->inetCidrRouteNextHop) / sizeof(tbl_idx->inetCidrRouteNextHop[0]); /* max length */ /** WARNING: this code might not work for netsnmp_route_entry */ /* * make sure there is enough space for inetCidrRouteNextHop data */ if ((NULL == tbl_idx->inetCidrRouteNextHop) || (tbl_idx->inetCidrRouteNextHop_len < (inetCidrRouteNextHop_val_ptr_len))) { snmp_log(LOG_ERR, "not enough space for value\n"); return MFD_ERROR; } tbl_idx->inetCidrRouteNextHop_len = inetCidrRouteNextHop_val_ptr_len; memcpy(tbl_idx->inetCidrRouteNextHop, inetCidrRouteNextHop_val_ptr, inetCidrRouteNextHop_val_ptr_len * sizeof(inetCidrRouteNextHop_val_ptr[0])); return MFD_SUCCESS;} /* inetCidrRouteTable_indexes_set_tbl_idx *//** * @internal * set row context indexes * * @param rowreq_ctx the row context that needs updated indexes * @param inetCidrRouteDestType_val * @param inetCidrRouteDest_val_ptr * @param inetCidrRouteDest_val_ptr_len * @param inetCidrRoutePfxLen_val * @param inetCidrRoutePolicy_val_ptr * @param inetCidrRoutePolicy_val_ptr_len * @param inetCidrRouteNextHopType_val * @param inetCidrRouteNextHop_val_ptr * @param inetCidrRouteNextHop_val_ptr_len * * @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. */intinetCidrRouteTable_indexes_set(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, u_long inetCidrRouteDestType_val, char *inetCidrRouteDest_val_ptr, size_t inetCidrRouteDest_val_ptr_len, u_long inetCidrRoutePfxLen_val, oid * inetCidrRoutePolicy_val_ptr, size_t inetCidrRoutePolicy_val_ptr_len, u_long inetCidrRouteNextHopType_val, char *inetCidrRouteNextHop_val_ptr, size_t inetCidrRouteNextHop_val_ptr_len){ DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_indexes_set", "called\n")); if (MFD_SUCCESS != inetCidrRouteTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx, inetCidrRouteDestType_val, inetCidrRouteDest_val_ptr, inetCidrRouteDest_val_ptr_len, inetCidrRoutePfxLen_val, inetCidrRoutePolicy_val_ptr, inetCidrRoutePolicy_val_ptr_len, inetCidrRouteNextHopType_val, inetCidrRouteNextHop_val_ptr, inetCidrRouteNextHop_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 != inetCidrRouteTable_index_to_oid(&rowreq_ctx->oid_idx, &rowreq_ctx->tbl_idx)) { return MFD_ERROR; } return MFD_SUCCESS;} /* inetCidrRouteTable_indexes_set *//*--------------------------------------------------------------------- * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteIfIndex * inetCidrRouteIfIndex is subid 7 of inetCidrRouteEntry. * Its status is Current, and its access level is Create. * OID: .1.3.6.1.2.1.4.24.7.1.7 * Description:The ifIndex value which identifies the local interface through which the next hop of this route should be reached. A value of 0 is valid and represents the scenario where no interface is specified. * * Attributes: * accessible 1 isscalar 0 enums 0 hasdefval 0 * readable 1 iscolumn 1 ranges 1 hashint 1 * settable 1 * hint: d * * Ranges: 0 - 2147483647; * * Its syntax is InterfaceIndexOrZero (based on perltype INTEGER32) * The net-snmp type is ASN_INTEGER. The C type decl is long (long) *//** * Extract the current value of the inetCidrRouteIfIndex data-> * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param inetCidrRouteIfIndex_val_ptr * Pointer to storage for a long variable * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error */intinetCidrRouteIfIndex_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, long *inetCidrRouteIfIndex_val_ptr){ /** we should have a non-NULL pointer */ netsnmp_assert(NULL != inetCidrRouteIfIndex_val_ptr); DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteIfIndex_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the inetCidrRouteIfIndex data-> * copy (* inetCidrRouteIfIndex_val_ptr ) from rowreq_ctx->data */ /* * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteIfIndex data */ (*inetCidrRouteIfIndex_val_ptr) = rowreq_ctx->data->if_index; return MFD_SUCCESS;} /* inetCidrRouteIfIndex_get *//*--------------------------------------------------------------------- * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteType * inetCidrRouteType is subid 8 of inetCidrRouteEntry. * Its status is Current, and its access level is Create. * OID: .1.3.6.1.2.1.4.24.7.1.8 * Description:The type of route. Note that local(3) refers to a route for which the next hop is the final destination; remote(4)refers to a route for which the next hop is not the final destination. Routes which do not result in traffic forwarding or rejection should not be displayed even if the implementation keeps them stored internally. reject(2) refers to a route which, if matched, discards the message as unreachable and returns a notification (e.g. ICMP error) to the message sender. This is used in some protocols as a means of correctly aggregating routes. blackhole(5) refers to a route which, if matched, discards the message silently. * * Attributes: * accessible 1 isscalar 0 enums 1 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 1 * * Enum range: 3/8. Values: other(1), reject(2), local(3), remote(4), blackhole(5) * * Its syntax is INTEGER (based on perltype INTEGER) * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) *//** * Extract the current value of the inetCidrRouteType data-> * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param inetCidrRouteType_val_ptr * Pointer to storage for a long variable * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error */intinetCidrRouteType_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, u_long * inetCidrRouteType_val_ptr){ /** we should have a non-NULL pointer */ netsnmp_assert(NULL != inetCidrRouteType_val_ptr); DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteType_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the inetCidrRouteType data-> * copy (* inetCidrRouteType_val_ptr ) from rowreq_ctx->data */ /* * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteType data */ (*inetCidrRouteType_val_ptr) = rowreq_ctx->data->rt_type; return MFD_SUCCESS;} /* inetCidrRouteType_get *//*--------------------------------------------------------------------- * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteProto * inetCidrRouteProto is subid 9 of inetCidrRouteEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.4.24.7.1.9 * Description:The routing mechanism via which this route was learned. Inclusion of values for gateway routing protocols is not intended to imply that hosts should support those protocols. * * Attributes: * accessible 1 isscalar 0 enums 1 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 0 * * Enum range: 13/32. Values: other(1), local(2), netmgmt(3), icmp(4), egp(5), ggp(6), hello(7), rip(8), isIs(9), esIs(10), ciscoIgrp(11), bbnSpfIgp(12), ospf(13), bgp(14), idpr(15), ciscoEigrp(16), dvmrp(17) * * Its syntax is IANAipRouteProtocol (based on perltype INTEGER) * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) *//** * Extract the current value of the inetCidrRouteProto data-> * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param inetCidrRouteProto_val_ptr * Pointer to storage for a long variable * * @retval MFD_SUCCESS : success * @retval MFD_SKIP : skip this node (no value for now) * @retval MFD_ERROR : Any other error */intinetCidrRouteProto_get(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, u_long * inetCidrRouteProto_val_ptr){ /** we should have a non-NULL pointer */ netsnmp_assert(NULL != inetCidrRouteProto_val_ptr); DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteProto_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the inetCidrRouteProto data-> * copy (* inetCidrRouteProto_val_ptr ) from rowreq_ctx->data */ /* * TODO:235:M: |-> Remove log message/SKIP once you've set inetCidrRouteProto data */ (*inetCidrRouteProto_val_ptr) = rowreq_ctx->data->rt_proto; return MFD_SUCCESS;} /* inetCidrRouteProto_get *//*--------------------------------------------------------------------- * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteAge * inetCidrRouteAge is subid 10 of inetCidrRouteEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.4.24.7.1.10 * Description:The number of seconds since this route was last updated or otherwise determined to be correct. Note that no semantics of 'too old' can be implied except through knowledge of the routing protocol by which the route was learned. * * 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 inetCidrRouteAge data-> * * Set a value using the data context for the row. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -