/* * Copyright 2007 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. */ /* ip4293_mth.c - method routines for the ip tree in RFC 4293 */ /* modification history -------------------- 01c,29jan08,msa Fix defect 111403 01b,18jul07,msa Add missing #ifdefs 01a,28jun07,msa Add RFC4293 support */ #include #include #include #include #include #include #include #include #include "ipicmp4293_mibleaf.h" #include /************************************************************************** * Defines **************************************************************************/ #define ipVersion_ipv4 1 #define ipVersion_ipv6 2 #define ipVersion_ipv4z 3 #define ipVersion_ipv6z 4 /************************************************************************** * Local structures **************************************************************************/ typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_Ipv4InterfaceEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipv4InterfaceEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_Ipv6InterfaceEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipv6InterfaceEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_IpSystemStatsEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipSystemStatsEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_IpIfStatsEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipIfStatsEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_IpAddressPrefixEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipAddressPrefixEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_IpAddressEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipAddressEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_IpNetToPhysicalEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipNetToPhysicalEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_Ipv6ScopeZoneIndexEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipv6ScopeZoneIndexEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_IpDefaultRouterEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipDefaultRouterEntry_cookie_t; typedef struct { int tcount; OIDC_T * tlist; Ipcom_mib2_Ipv6RouterAdvertEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } ipv6RouterAdvertEntry_cookie_t; typedef struct { #ifdef IPCOM_USE_INET Ipcom_mib2_ip_general_group ipv4Group; Ipcom_mib2_TimeStamp ipv4InterfaceTableLastChange; #endif /* IPCOM_USE_INET */ #ifdef IPCOM_USE_INET6 Ipcom_mib2_ipv6_general_group ipv6Group; Ipcom_mib2_TimeStamp ipv6InterfaceTableLastChange; Ipcom_mib2_TestAndIncr ipv6RouterAdvertSpinLock; #endif /* IPCOM_USE_INET6 */ Ipcom_mib2_TestAndIncr ipAddressSpinLock; } ip_data_t; /************************************************************************** * Local Helper Routines **************************************************************************/ /* Wrapper to allow a pointer back for freeing VB priv data */ static void localFree (PTR_T memP) { VB_T * vbp = (VB_T *)memP; SNMP_memory_free (vbp->vb_priv); } /* * Method routines for the ipv4InterfaceTable: * * ipv4InterfaceIfIndex -- not-accessible * The index value that uniquely identifies the interface to * which this entry is applicable. The interface identified by * a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipv4InterfaceReasmMaxSize -- read-only * The size of the largest IPv4 datagram that this entity can * re-assemble from incoming IPv4 fragmented datagrams received * on this interface. * * ipv4InterfaceEnableStatus -- read-write * The indication of whether IPv4 is enabled (up) or disabled * (down) on this interface. This object does not affect the * state of the interface itself, only its connection to an * IPv4 stack. The IF-MIB should be used to control the state * of the interface. * * ipv4InterfaceRetransmitTime -- read-only * The time between retransmissions of ARP requests to a * neighbor when resolving the address or when probing the * reachability of a neighbor. */ static int ipv4InterfaceEntry_get_value (OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_Ipv4InterfaceEntry *data) { switch (lastmatch) { case LEAF_ipv4InterfaceReasmMaxSize: getproc_got_int32 (pktp, vbp, data->ipv4InterfaceReasmMaxSize); break; case LEAF_ipv4InterfaceEnableStatus: /* Values: * up (1) = VAL_ipv4InterfaceEnableStatus_up * down (2) = VAL_ipv4InterfaceEnableStatus_down */ getproc_got_int32 (pktp, vbp, data->ipv4InterfaceEnableStatus); break; case LEAF_ipv4InterfaceRetransmitTime: getproc_got_uint32 (pktp, vbp, data->ipv4InterfaceRetransmitTime, VT_GAUGE); break; default: return GEN_ERR; } return NO_ERROR; } #define ipv4InterfaceEntry_INSTANCE_LEN 1 static unsigned ipv4InterfaceEntry_build_instance (Ipcom_mib2_Ipv4InterfaceEntry *data, OIDC_T *instance) { instance [0] = data->ipv4InterfaceIfIndex; return (ipv4InterfaceEntry_INSTANCE_LEN); } #ifdef IPCOM_USE_INET static int ipv4InterfaceEntry_callback (Ipcom_mib2_Ipv4InterfaceEntry *entry, void *user) { ipv4InterfaceEntry_cookie_t * cookie = (ipv4InterfaceEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipv4InterfaceEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipv4InterfaceEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipv4InterfaceEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipv4InterfaceEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_Ipv4InterfaceEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_Ipv4InterfaceEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } #endif /* IPCOM_USE_INET */ static Ipcom_mib2_Ipv4InterfaceEntry * ipv4InterfaceEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { #ifdef IPCOM_USE_INET ipv4InterfaceEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ if (!getnext && (tcount != ipv4InterfaceEntry_INSTANCE_LEN)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipv4InterfaceTable (ipv4InterfaceEntry_callback, (void *)&cookie); return (cookie.dataPtr); #else return (NULL); #endif } void ipv4InterfaceEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv4InterfaceEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv4InterfaceEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipv4InterfaceEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipv4InterfaceEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv4InterfaceEntry * data; OIDC_T best_inst [ipv4InterfaceEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv4InterfaceEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipv4InterfaceEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipv4InterfaceEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } void ipv4InterfaceEntry_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv4InterfaceEntry *data; VB_T *group_vbp; if ((data = ipv4InterfaceEntry_lookup (tcount, tlist, FALSE)) == NULL) { testproc_error (pktp, vbp, NO_SUCH_NAME); return; } /* stash the looked up information here for the setproc */ vbp->vb_priv = (PTR_T *)data; vbp->vb_free_priv = (VBPRIVPROC_T *)localFree; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* now check each varbind */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { #ifdef IPCOM_USE_INET case LEAF_ipv4InterfaceEnableStatus: switch (VB_GET_INT32 (group_vbp)) { case VAL_ipv4InterfaceEnableStatus_up: case VAL_ipv4InterfaceEnableStatus_down: break; default: testproc_error (pktp, group_vbp, WRONG_VALUE); continue; } testproc_good (pktp, group_vbp); break; #endif default: testproc_error (pktp, group_vbp, GEN_ERR); return; } } } void ipv4InterfaceEntry_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { #ifdef IPCOM_USE_INET /* Stashed here by the testproc */ Ipcom_mib2_Ipv4InterfaceEntry * data = vbp->vb_priv; for ( ; vbp; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { case LEAF_ipv4InterfaceEnableStatus: data->ipv4InterfaceEnableStatus = VB_GET_INT32 (vbp); setproc_good (pktp, vbp); break; default: setproc_error (pktp, vbp, COMMIT_FAILED); return; } } /* Actual setting of the data. */ ipcom_mib2_set_ipv4InterfaceEnableStatus (data->ipv4InterfaceIfIndex, data->ipv4InterfaceEnableStatus); #else setproc_error (pktp, vbp, COMMIT_FAILED); #endif } /* * Method routines for the ipv6InterfaceTable: * * ipv6InterfaceIfIndex -- not-accessible * The index value that uniquely identifies the interface to * which this entry is applicable. The interface identified by * a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipv6InterfaceReasmMaxSize -- read-only * The size of the largest IPv6 datagram that this entity can * re-assemble from incoming IPv6 fragmented datagrams received * on this interface. * * ipv6InterfaceIdentifier -- read-only * The Interface Identifier for this interface. The Interface * Identifier is combined with an address prefix to form an * interface address. * * By default, the Interface Identifier is auto-configured * according to the rules of the link type to which this * interface is attached. * * A zero length identifier may be used where appropriate. One * possible example is a loopback interface. * * ipv6InterfaceEnableStatus -- read-write * The indication of whether IPv6 is enabled (up) or disabled * (down) on this interface. This object does not affect the * state of the interface itself, only its connection to an * IPv6 stack. The IF-MIB should be used to control the state * of the interface. * * When this object is written, the entity SHOULD save the * change to non-volatile storage and restore the object from * non-volatile storage upon re-initialization of the system. * * ipv6InterfaceReachableTime -- read-only * The time a neighbor is considered reachable after receiving * a reachability confirmation. * * ipv6InterfaceRetransmitTime -- read-only * The time between retransmissions of Neighbor Solicitation * messages to a neighbor when resolving the address or when * probing the reachability of a neighbor. * * ipv6InterfaceForwarding -- read-write * The indication of whether this entity is acting as an IPv6 * router on this interface with respect to the forwarding of * datagrams received by, but not addressed to, this entity. * IPv6 routers forward datagrams. IPv6 hosts do not (except * those source-routed via the host). * * This object is constrained by ipv6IpForwarding and is * ignored if ipv6IpForwarding is set to notForwarding. Those * systems that do not provide per-interface control of the * forwarding function should set this object to forwarding for * all interfaces and allow the ipv6IpForwarding object to * control the forwarding capability. * * When this object is written, the entity SHOULD save the * change to non-volatile storage and restore the object from * non-volatile storage upon re-initialization of the system. */ static int ipv6InterfaceEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_Ipv6InterfaceEntry *data) { /* IPNet stores OCTET STRING lengths as a 32-bit values */ ALENGTH_T * ipv6InterfaceIdentifierLengthP = (ALENGTH_T *)&(data->ipv6InterfaceIdentifier [0]); switch(lastmatch) { case LEAF_ipv6InterfaceReasmMaxSize: getproc_got_uint32(pktp, vbp, data->ipv6InterfaceReasmMaxSize, VT_GAUGE); break; case LEAF_ipv6InterfaceIdentifier: getproc_got_octet_string(pktp, vbp, *ipv6InterfaceIdentifierLengthP, &(data->ipv6InterfaceIdentifier [4]), VT_STRING); break; case LEAF_ipv6InterfaceEnableStatus: /* Values: * up(1) = VAL_ipv6InterfaceEnableStatus_up * down(2) = VAL_ipv6InterfaceEnableStatus_down */ getproc_got_int32(pktp, vbp, data->ipv6InterfaceEnableStatus); break; case LEAF_ipv6InterfaceReachableTime: getproc_got_uint32(pktp, vbp, data->ipv6InterfaceReachableTime, VT_GAUGE); break; case LEAF_ipv6InterfaceRetransmitTime: getproc_got_uint32(pktp, vbp, data->ipv6InterfaceRetransmitTime, VT_GAUGE); break; case LEAF_ipv6InterfaceForwarding: /* Values: * forwarding(1) = VAL_ipv6InterfaceForwarding_forwarding * notForwarding(2) = VAL_ipv6InterfaceForwarding_notForwarding */ getproc_got_int32(pktp, vbp, data->ipv6InterfaceForwarding); break; default: return GEN_ERR; } return NO_ERROR; } #define ipv6InterfaceEntry_INSTANCE_LEN 1 static unsigned ipv6InterfaceEntry_build_instance (Ipcom_mib2_Ipv6InterfaceEntry *data, OIDC_T *instance) { instance [0] = data->ipv6InterfaceIfIndex; return (ipv6InterfaceEntry_INSTANCE_LEN); } #ifdef IPCOM_USE_INET6 static int ipv6InterfaceEntry_callback (Ipcom_mib2_Ipv6InterfaceEntry *entry, void *user) { ipv6InterfaceEntry_cookie_t * cookie = (ipv6InterfaceEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipv6InterfaceEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipv6InterfaceEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipv6InterfaceEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipv6InterfaceEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_Ipv6InterfaceEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_Ipv6InterfaceEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } #endif /* IPCOM_USE_INET6 */ static Ipcom_mib2_Ipv6InterfaceEntry * ipv6InterfaceEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { #ifdef IPCOM_USE_INET6 ipv6InterfaceEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ if (!getnext && (tcount != ipv6InterfaceEntry_INSTANCE_LEN)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipv6InterfaceTable (ipv6InterfaceEntry_callback, (void *)&cookie); return (cookie.dataPtr); #else return (NULL); #endif /* IPCOM_USE_INET6 */ } void ipv6InterfaceEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6InterfaceEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv6InterfaceEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipv6InterfaceEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipv6InterfaceEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6InterfaceEntry * data; OIDC_T best_inst [ipv6InterfaceEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv6InterfaceEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipv6InterfaceEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipv6InterfaceEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } void ipv6InterfaceEntry_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6InterfaceEntry *data; VB_T *group_vbp; if ((data = ipv6InterfaceEntry_lookup (tcount, tlist, FALSE)) == NULL) { testproc_error (pktp, vbp, NO_SUCH_NAME); return; } /* stash the looked up information here for the setproc */ vbp->vb_priv = (PTR_T *)data; vbp->vb_free_priv = (VBPRIVPROC_T *)localFree; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* now check each varbind */ /* coverity[unreachable] */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { #ifdef IPCOM_USE_INET6 case LEAF_ipv6InterfaceEnableStatus: switch (VB_GET_INT32 (group_vbp)) { case VAL_ipv6InterfaceEnableStatus_up: case VAL_ipv6InterfaceEnableStatus_down: break; default: testproc_error (pktp, group_vbp, WRONG_VALUE); continue; } testproc_good (pktp, group_vbp); break; case LEAF_ipv6InterfaceForwarding: switch (VB_GET_INT32 (group_vbp)) { case VAL_ipv6InterfaceForwarding_forwarding: case VAL_ipv6InterfaceForwarding_notForwarding: break; default: testproc_error (pktp, group_vbp, WRONG_VALUE); continue; } testproc_good (pktp, group_vbp); break; #endif default: testproc_error(pktp, group_vbp, GEN_ERR); return; } } } void ipv6InterfaceEntry_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { #ifdef IPCOM_USE_INET6 boolean_t enableStatusChanged = FALSE; boolean_t forwardingChanged = FALSE; /* Stashed here by the testproc */ Ipcom_mib2_Ipv6InterfaceEntry * data = vbp->vb_priv; for ( ; vbp; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { case LEAF_ipv6InterfaceEnableStatus: data->ipv6InterfaceEnableStatus = VB_GET_INT32 (vbp); setproc_good (pktp, vbp); enableStatusChanged = TRUE; break; case LEAF_ipv6InterfaceForwarding: data->ipv6InterfaceForwarding = VB_GET_INT32 (vbp); setproc_good (pktp, vbp); forwardingChanged = TRUE; break; default: setproc_error (pktp, vbp, COMMIT_FAILED); return; } } /* Actual setting of the data. */ if (enableStatusChanged) ipcom_mib2_set_ipv6InterfaceEnableStatus (data->ipv6InterfaceIfIndex, data->ipv6InterfaceEnableStatus); if (forwardingChanged) ipcom_mib2_set_ipv6InterfaceForwarding (data->ipv6InterfaceIfIndex, data->ipv6InterfaceForwarding); #else setproc_error (pktp, vbp, COMMIT_FAILED); #endif } /* * Method routines for the ipSystemStatsTable: * * ipSystemStatsIPVersion -- not-accessible * The IP version of this row. * * ipSystemStatsInReceives -- read-only * The total number of input IP datagrams received, including * those received in error. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInReceives -- read-only * The total number of input IP datagrams received, including * those received in error. This object counts the same * datagrams as ipSystemStatsInReceives, but allows for larger * values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInOctets -- read-only * The total number of octets received in input IP datagrams, * including those received in error. Octets from datagrams * counted in ipSystemStatsInReceives MUST be counted here. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInOctets -- read-only * The total number of octets received in input IP datagrams, * including those received in error. This object counts the * same octets as ipSystemStatsInOctets, but allows for larger * values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInHdrErrors -- read-only * The number of input IP datagrams discarded due to errors in * their IP headers, including version number mismatch, other * format errors, hop count exceeded, errors discovered in * processing their IP options, etc. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInNoRoutes -- read-only * The number of input IP datagrams discarded because no route * could be found to transmit them to their destination. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInAddrErrors -- read-only * The number of input IP datagrams discarded because the IP * address in their IP header's destination field was not a * valid address to be received at this entity. This count * includes invalid addresses (e.g., ::0). For entities * that are not IP routers and therefore do not forward * datagrams, this counter includes datagrams discarded * because the destination address was not a local address. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInUnknownProtos -- read-only * The number of locally-addressed IP datagrams received * successfully but discarded because of an unknown or * unsupported protocol. * * When tracking interface statistics, the counter of the * interface to which these datagrams were addressed is * incremented. This interface might not be the same as the * input interface for some of the datagrams. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInTruncatedPkts -- read-only * The number of input IP datagrams discarded because the * datagram frame didn't carry enough data. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInForwDatagrams -- read-only * The number of input datagrams for which this entity was not * their final IP destination and for which this entity * attempted to find a route to forward them to that final * destination. In entities that do not act as IP routers, * this counter will include only those datagrams that were * Source-Routed via this entity, and the Source-Route * processing was successful. * * When tracking interface statistics, the counter of the * incoming interface is incremented for each datagram. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInForwDatagrams -- read-only * The number of input datagrams for which this entity was not * their final IP destination and for which this entity * attempted to find a route to forward them to that final * destination. This object counts the same packets as * ipSystemStatsInForwDatagrams, but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsReasmReqds -- read-only * The number of IP fragments received that needed to be * reassembled at this interface. * * When tracking interface statistics, the counter of the * interface to which these fragments were addressed is * incremented. This interface might not be the same as the * input interface for some of the fragments. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsReasmOKs -- read-only * The number of IP datagrams successfully reassembled. * * When tracking interface statistics, the counter of the * interface to which these datagrams were addressed is * incremented. This interface might not be the same as the * input interface for some of the datagrams. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsReasmFails -- read-only * The number of failures detected by the IP re-assembly * algorithm (for whatever reason: timed out, errors, etc.). * Note that this is not necessarily a count of discarded IP * fragments since some algorithms (notably the algorithm in * RFC 815) can lose track of the number of fragments by * combining them as they are received. * * When tracking interface statistics, the counter of the * interface to which these fragments were addressed is * incremented. This interface might not be the same as the * input interface for some of the fragments. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInDiscards -- read-only * The number of input IP datagrams for which no problems were * encountered to prevent their continued processing, but * were discarded (e.g., for lack of buffer space). Note that * this counter does not include any datagrams discarded while * awaiting re-assembly. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInDelivers -- read-only * The total number of datagrams successfully delivered to IP * user-protocols (including ICMP). * * When tracking interface statistics, the counter of the * interface to which these datagrams were addressed is * incremented. This interface might not be the same as the * input interface for some of the datagrams. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInDelivers -- read-only * The total number of datagrams successfully delivered to IP * user-protocols (including ICMP). This object counts the * same packets as ipSystemStatsInDelivers, but allows for * larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutRequests -- read-only * The total number of IP datagrams that local IP user- * protocols (including ICMP) supplied to IP in requests for * transmission. Note that this counter does not include any * datagrams counted in ipSystemStatsOutForwDatagrams. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutRequests -- read-only * The total number of IP datagrams that local IP user- * protocols (including ICMP) supplied to IP in requests for * transmission. This object counts the same packets as * ipSystemStatsOutRequests, but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutNoRoutes -- read-only * The number of locally generated IP datagrams discarded * because no route could be found to transmit them to their * destination. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutForwDatagrams -- read-only * The number of datagrams for which this entity was not their * final IP destination and for which it was successful in * finding a path to their final destination. In entities * that do not act as IP routers, this counter will include * only those datagrams that were Source-Routed via this * entity, and the Source-Route processing was successful. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * forwarded datagram. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutForwDatagrams -- read-only * The number of datagrams for which this entity was not their * final IP destination and for which it was successful in * finding a path to their final destination. This object * counts the same packets as ipSystemStatsOutForwDatagrams, * but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutDiscards -- read-only * The number of output IP datagrams for which no problem was * encountered to prevent their transmission to their * destination, but were discarded (e.g., for lack of * buffer space). Note that this counter would include * datagrams counted in ipSystemStatsOutForwDatagrams if any * such datagrams met this (discretionary) discard criterion. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutFragReqds -- read-only * The number of IP datagrams that would require fragmentation * in order to be transmitted. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * fragmented datagram. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutFragOKs -- read-only * The number of IP datagrams that have been successfully * fragmented. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * fragmented datagram. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutFragFails -- read-only * The number of IP datagrams that have been discarded because * they needed to be fragmented but could not be. This * includes IPv4 packets that have the DF bit set and IPv6 * packets that are being forwarded and exceed the outgoing * link MTU. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for an unsuccessfully * fragmented datagram. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutFragCreates -- read-only * The number of output datagram fragments that have been * generated as a result of IP fragmentation. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * fragmented datagram. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutTransmits -- read-only * The total number of IP datagrams that this entity supplied * to the lower layers for transmission. This includes * datagrams generated locally and those forwarded by this * entity. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutTransmits -- read-only * The total number of IP datagrams that this entity supplied * to the lower layers for transmission. This object counts * the same datagrams as ipSystemStatsOutTransmits, but allows * for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutOctets -- read-only * The total number of octets in IP datagrams delivered to the * lower layers for transmission. Octets from datagrams * counted in ipSystemStatsOutTransmits MUST be counted here. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutOctets -- read-only * The total number of octets in IP datagrams delivered to the * lower layers for transmission. This objects counts the same * octets as ipSystemStatsOutOctets, but allows for larger * values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInMcastPkts -- read-only * The number of IP multicast datagrams received. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInMcastPkts -- read-only * The number of IP multicast datagrams received. This object * counts the same datagrams as ipSystemStatsInMcastPkts but * allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInMcastOctets -- read-only * The total number of octets received in IP multicast * datagrams. Octets from datagrams counted in * ipSystemStatsInMcastPkts MUST be counted here. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInMcastOctets -- read-only * The total number of octets received in IP multicast * datagrams. This object counts the same octets as * ipSystemStatsInMcastOctets, but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutMcastPkts -- read-only * The number of IP multicast datagrams transmitted. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutMcastPkts -- read-only * The number of IP multicast datagrams transmitted. This * object counts the same datagrams as * ipSystemStatsOutMcastPkts, but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutMcastOctets -- read-only * The total number of octets transmitted in IP multicast * datagrams. Octets from datagrams counted in * ipSystemStatsOutMcastPkts MUST be counted here. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutMcastOctets -- read-only * The total number of octets transmitted in IP multicast * datagrams. This object counts the same octets as * ipSystemStatsOutMcastOctets, but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsInBcastPkts -- read-only * The number of IP broadcast datagrams received. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCInBcastPkts -- read-only * The number of IP broadcast datagrams received. This object * counts the same datagrams as ipSystemStatsInBcastPkts but * allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsOutBcastPkts -- read-only * The number of IP broadcast datagrams transmitted. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsHCOutBcastPkts -- read-only * The number of IP broadcast datagrams transmitted. This * object counts the same datagrams as * ipSystemStatsOutBcastPkts, but allows for larger values. * * 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 * ipSystemStatsDiscontinuityTime. * * ipSystemStatsDiscontinuityTime -- read-only * The value of sysUpTime on the most recent occasion at which * any one or more of this entry's counters suffered a * discontinuity. * * If no such discontinuities have occurred since the last re- * initialization of the local management subsystem, then this * object contains a zero value. * * ipSystemStatsRefreshRate -- read-only * The minimum reasonable polling interval for this entry. * This object provides an indication of the minimum amount of * time required to update the counters in this entry. */ static int ipSystemStatsEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_IpSystemStatsEntry *data) { switch(lastmatch) { case LEAF_ipSystemStatsInReceives: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInReceives, VT_COUNTER); break; case LEAF_ipSystemStatsHCInReceives: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInReceives)); break; case LEAF_ipSystemStatsInOctets: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInOctets, VT_COUNTER); break; case LEAF_ipSystemStatsHCInOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInOctets)); break; case LEAF_ipSystemStatsInHdrErrors: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInHdrErrors, VT_COUNTER); break; case LEAF_ipSystemStatsInNoRoutes: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInNoRoutes, VT_COUNTER); break; case LEAF_ipSystemStatsInAddrErrors: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInAddrErrors, VT_COUNTER); break; case LEAF_ipSystemStatsInUnknownProtos: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInUnknownProtos, VT_COUNTER); break; case LEAF_ipSystemStatsInTruncatedPkts: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInTruncatedPkts, VT_COUNTER); break; case LEAF_ipSystemStatsInForwDatagrams: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInForwDatagrams, VT_COUNTER); break; case LEAF_ipSystemStatsHCInForwDatagrams: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInForwDatagrams)); break; case LEAF_ipSystemStatsReasmReqds: getproc_got_uint32(pktp, vbp, data->ipSystemStatsReasmReqds, VT_COUNTER); break; case LEAF_ipSystemStatsReasmOKs: getproc_got_uint32(pktp, vbp, data->ipSystemStatsReasmOKs, VT_COUNTER); break; case LEAF_ipSystemStatsReasmFails: getproc_got_uint32(pktp, vbp, data->ipSystemStatsReasmFails, VT_COUNTER); break; case LEAF_ipSystemStatsInDiscards: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInDiscards, VT_COUNTER); break; case LEAF_ipSystemStatsInDelivers: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInDelivers, VT_COUNTER); break; case LEAF_ipSystemStatsHCInDelivers: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInDelivers)); break; case LEAF_ipSystemStatsOutRequests: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutRequests, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutRequests: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutRequests)); break; case LEAF_ipSystemStatsOutNoRoutes: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutNoRoutes, VT_COUNTER); break; case LEAF_ipSystemStatsOutForwDatagrams: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutForwDatagrams, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutForwDatagrams: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutForwDatagrams)); break; case LEAF_ipSystemStatsOutDiscards: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutDiscards, VT_COUNTER); break; case LEAF_ipSystemStatsOutFragReqds: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutFragReqds, VT_COUNTER); break; case LEAF_ipSystemStatsOutFragOKs: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutFragOKs, VT_COUNTER); break; case LEAF_ipSystemStatsOutFragFails: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutFragFails, VT_COUNTER); break; case LEAF_ipSystemStatsOutFragCreates: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutFragCreates, VT_COUNTER); break; case LEAF_ipSystemStatsOutTransmits: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutTransmits, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutTransmits: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutTransmits)); break; case LEAF_ipSystemStatsOutOctets: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutOctets, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutOctets)); break; case LEAF_ipSystemStatsInMcastPkts: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInMcastPkts, VT_COUNTER); break; case LEAF_ipSystemStatsHCInMcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInMcastPkts)); break; case LEAF_ipSystemStatsInMcastOctets: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInMcastOctets, VT_COUNTER); break; case LEAF_ipSystemStatsHCInMcastOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInMcastOctets)); break; case LEAF_ipSystemStatsOutMcastPkts: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutMcastPkts, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutMcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutMcastPkts)); break; case LEAF_ipSystemStatsOutMcastOctets: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutMcastOctets, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutMcastOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutMcastOctets)); break; case LEAF_ipSystemStatsInBcastPkts: getproc_got_uint32(pktp, vbp, data->ipSystemStatsInBcastPkts, VT_COUNTER); break; case LEAF_ipSystemStatsHCInBcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCInBcastPkts)); break; case LEAF_ipSystemStatsOutBcastPkts: getproc_got_uint32(pktp, vbp, data->ipSystemStatsOutBcastPkts, VT_COUNTER); break; case LEAF_ipSystemStatsHCOutBcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipSystemStatsHCOutBcastPkts)); break; case LEAF_ipSystemStatsDiscontinuityTime: getproc_got_uint32(pktp, vbp, data->ipSystemStatsDiscontinuityTime, VT_TIMETICKS); break; case LEAF_ipSystemStatsRefreshRate: getproc_got_uint32(pktp, vbp, data->ipSystemStatsRefreshRate, VT_GAUGE); break; default: return GEN_ERR; } return NO_ERROR; } #define ipSystemStatsEntry_INSTANCE_LEN 1 static unsigned ipSystemStatsEntry_build_instance (Ipcom_mib2_IpSystemStatsEntry *data, OIDC_T *instance) { instance [0] = data->ipSystemStatsIPVersion; return (ipSystemStatsEntry_INSTANCE_LEN); } static int ipSystemStatsEntry_callback (Ipcom_mib2_IpSystemStatsEntry *entry, void *user) { ipSystemStatsEntry_cookie_t * cookie = (ipSystemStatsEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipSystemStatsEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipSystemStatsEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipSystemStatsEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipSystemStatsEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_IpSystemStatsEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_IpSystemStatsEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } static Ipcom_mib2_IpSystemStatsEntry * ipSystemStatsEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { ipSystemStatsEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ if (!getnext && (tcount != ipSystemStatsEntry_INSTANCE_LEN)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipSystemStatsTable (ipSystemStatsEntry_callback, (void *)&cookie); return (cookie.dataPtr); } void ipSystemStatsEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpSystemStatsEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipSystemStatsEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipSystemStatsEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipSystemStatsEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpSystemStatsEntry * data; OIDC_T best_inst [ipSystemStatsEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipSystemStatsEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipSystemStatsEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipSystemStatsEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } /* * Method routines for the ipIfStatsTable: * * ipIfStatsIPVersion -- not-accessible * The IP version of this row. * * ipIfStatsIfIndex -- not-accessible * The index value that uniquely identifies the interface to * which this entry is applicable. The interface identified by * a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipIfStatsInReceives -- read-only * The total number of input IP datagrams received, including * those received in error. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInReceives -- read-only * The total number of input IP datagrams received, including * those received in error. This object counts the same * datagrams as ipIfStatsInReceives, but allows for larger * values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInOctets -- read-only * The total number of octets received in input IP datagrams, * including those received in error. Octets from datagrams * counted in ipIfStatsInReceives MUST be counted here. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInOctets -- read-only * The total number of octets received in input IP datagrams, * including those received in error. This object counts the * same octets as ipIfStatsInOctets, but allows for larger * values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInHdrErrors -- read-only * The number of input IP datagrams discarded due to errors in * their IP headers, including version number mismatch, other * format errors, hop count exceeded, errors discovered in * processing their IP options, etc. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInNoRoutes -- read-only * The number of input IP datagrams discarded because no route * could be found to transmit them to their destination. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInAddrErrors -- read-only * The number of input IP datagrams discarded because the IP * address in their IP header's destination field was not a * valid address to be received at this entity. This count * includes invalid addresses (e.g., ::0). For entities that * are not IP routers and therefore do not forward datagrams, * this counter includes datagrams discarded because the * destination address was not a local address. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInUnknownProtos -- read-only * The number of locally-addressed IP datagrams received * successfully but discarded because of an unknown or * unsupported protocol. * * When tracking interface statistics, the counter of the * interface to which these datagrams were addressed is * incremented. This interface might not be the same as the * input interface for some of the datagrams. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInTruncatedPkts -- read-only * The number of input IP datagrams discarded because the * datagram frame didn't carry enough data. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInForwDatagrams -- read-only * The number of input datagrams for which this entity was not * their final IP destination and for which this entity * attempted to find a route to forward them to that final * destination. In entities that do not act as IP routers, * this counter will include only those datagrams that were * Source-Routed via this entity, and the Source-Route * processing was successful. * * When tracking interface statistics, the counter of the * incoming interface is incremented for each datagram. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInForwDatagrams -- read-only * The number of input datagrams for which this entity was not * their final IP destination and for which this entity * attempted to find a route to forward them to that final * destination. This object counts the same packets as * ipIfStatsInForwDatagrams, but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsReasmReqds -- read-only * The number of IP fragments received that needed to be * reassembled at this interface. * * When tracking interface statistics, the counter of the * interface to which these fragments were addressed is * incremented. This interface might not be the same as the * input interface for some of the fragments. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsReasmOKs -- read-only * The number of IP datagrams successfully reassembled. * * When tracking interface statistics, the counter of the * interface to which these datagrams were addressed is * incremented. This interface might not be the same as the * input interface for some of the datagrams. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsReasmFails -- read-only * The number of failures detected by the IP re-assembly * algorithm (for whatever reason: timed out, errors, etc.). * Note that this is not necessarily a count of discarded IP * fragments since some algorithms (notably the algorithm in * RFC 815) can lose track of the number of fragments by * combining them as they are received. * * When tracking interface statistics, the counter of the * interface to which these fragments were addressed is * incremented. This interface might not be the same as the * input interface for some of the fragments. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInDiscards -- read-only * The number of input IP datagrams for which no problems were * encountered to prevent their continued processing, but * were discarded (e.g., for lack of buffer space). Note that * this counter does not include any datagrams discarded while * awaiting re-assembly. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInDelivers -- read-only * The total number of datagrams successfully delivered to IP * user-protocols (including ICMP). * * When tracking interface statistics, the counter of the * interface to which these datagrams were addressed is * incremented. This interface might not be the same as the * input interface for some of the datagrams. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInDelivers -- read-only * The total number of datagrams successfully delivered to IP * user-protocols (including ICMP). This object counts the * same packets as ipIfStatsInDelivers, but allows for larger * values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutRequests -- read-only * The total number of IP datagrams that local IP user- * protocols (including ICMP) supplied to IP in requests for * transmission. Note that this counter does not include any * datagrams counted in ipIfStatsOutForwDatagrams. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutRequests -- read-only * The total number of IP datagrams that local IP user- * protocols (including ICMP) supplied to IP in requests for * transmission. This object counts the same packets as * ipIfStatsOutRequests, but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutForwDatagrams -- read-only * The number of datagrams for which this entity was not their * final IP destination and for which it was successful in * finding a path to their final destination. In entities * that do not act as IP routers, this counter will include * only those datagrams that were Source-Routed via this * entity, and the Source-Route processing was successful. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * forwarded datagram. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutForwDatagrams -- read-only * The number of datagrams for which this entity was not their * final IP destination and for which it was successful in * finding a path to their final destination. This object * counts the same packets as ipIfStatsOutForwDatagrams, but * allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutDiscards -- read-only * The number of output IP datagrams for which no problem was * encountered to prevent their transmission to their * destination, but were discarded (e.g., for lack of * buffer space). Note that this counter would include * datagrams counted in ipIfStatsOutForwDatagrams if any such * datagrams met this (discretionary) discard criterion. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutFragReqds -- read-only * The number of IP datagrams that would require fragmentation * in order to be transmitted. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * fragmented datagram. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutFragOKs -- read-only * The number of IP datagrams that have been successfully * fragmented. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * fragmented datagram. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutFragFails -- read-only * The number of IP datagrams that have been discarded because * they needed to be fragmented but could not be. This * includes IPv4 packets that have the DF bit set and IPv6 * packets that are being forwarded and exceed the outgoing * link MTU. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for an unsuccessfully * fragmented datagram. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutFragCreates -- read-only * The number of output datagram fragments that have been * generated as a result of IP fragmentation. * * When tracking interface statistics, the counter of the * outgoing interface is incremented for a successfully * fragmented datagram. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutTransmits -- read-only * The total number of IP datagrams that this entity supplied * to the lower layers for transmission. This includes * datagrams generated locally and those forwarded by this * entity. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutTransmits -- read-only * The total number of IP datagrams that this entity supplied * to the lower layers for transmission. This object counts * the same datagrams as ipIfStatsOutTransmits, but allows for * larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutOctets -- read-only * The total number of octets in IP datagrams delivered to the * lower layers for transmission. Octets from datagrams * counted in ipIfStatsOutTransmits MUST be counted here. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutOctets -- read-only * The total number of octets in IP datagrams delivered to the * lower layers for transmission. This objects counts the same * octets as ipIfStatsOutOctets, but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInMcastPkts -- read-only * The number of IP multicast datagrams received. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInMcastPkts -- read-only * The number of IP multicast datagrams received. This object * counts the same datagrams as ipIfStatsInMcastPkts, but * allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInMcastOctets -- read-only * The total number of octets received in IP multicast * datagrams. Octets from datagrams counted in * ipIfStatsInMcastPkts MUST be counted here. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInMcastOctets -- read-only * The total number of octets received in IP multicast * datagrams. This object counts the same octets as * ipIfStatsInMcastOctets, but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutMcastPkts -- read-only * The number of IP multicast datagrams transmitted. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutMcastPkts -- read-only * The number of IP multicast datagrams transmitted. This * object counts the same datagrams as ipIfStatsOutMcastPkts, * but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutMcastOctets -- read-only * The total number of octets transmitted in IP multicast * datagrams. Octets from datagrams counted in * ipIfStatsOutMcastPkts MUST be counted here. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutMcastOctets -- read-only * The total number of octets transmitted in IP multicast * datagrams. This object counts the same octets as * ipIfStatsOutMcastOctets, but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsInBcastPkts -- read-only * The number of IP broadcast datagrams received. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCInBcastPkts -- read-only * The number of IP broadcast datagrams received. This object * counts the same datagrams as ipIfStatsInBcastPkts, but * allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsOutBcastPkts -- read-only * The number of IP broadcast datagrams transmitted. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsHCOutBcastPkts -- read-only * The number of IP broadcast datagrams transmitted. This * object counts the same datagrams as ipIfStatsOutBcastPkts, * but allows for larger values. * * 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 * ipIfStatsDiscontinuityTime. * * ipIfStatsDiscontinuityTime -- read-only * The value of sysUpTime on the most recent occasion at which * any one or more of this entry's counters suffered a * discontinuity. * * If no such discontinuities have occurred since the last re- * initialization of the local management subsystem, then this * object contains a zero value. * * ipIfStatsRefreshRate -- read-only * The minimum reasonable polling interval for this entry. * This object provides an indication of the minimum amount of * time required to update the counters in this entry. */ static int ipIfStatsEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_IpIfStatsEntry *data) { switch(lastmatch) { case LEAF_ipIfStatsInReceives: getproc_got_uint32(pktp, vbp, data->ipIfStatsInReceives, VT_COUNTER); break; case LEAF_ipIfStatsHCInReceives: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInReceives)); break; case LEAF_ipIfStatsInOctets: getproc_got_uint32(pktp, vbp, data->ipIfStatsInOctets, VT_COUNTER); break; case LEAF_ipIfStatsHCInOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInOctets)); break; case LEAF_ipIfStatsInHdrErrors: getproc_got_uint32(pktp, vbp, data->ipIfStatsInHdrErrors, VT_COUNTER); break; case LEAF_ipIfStatsInNoRoutes: getproc_got_uint32(pktp, vbp, data->ipIfStatsInNoRoutes, VT_COUNTER); break; case LEAF_ipIfStatsInAddrErrors: getproc_got_uint32(pktp, vbp, data->ipIfStatsInAddrErrors, VT_COUNTER); break; case LEAF_ipIfStatsInUnknownProtos: getproc_got_uint32(pktp, vbp, data->ipIfStatsInUnknownProtos, VT_COUNTER); break; case LEAF_ipIfStatsInTruncatedPkts: getproc_got_uint32(pktp, vbp, data->ipIfStatsInTruncatedPkts, VT_COUNTER); break; case LEAF_ipIfStatsInForwDatagrams: getproc_got_uint32(pktp, vbp, data->ipIfStatsInForwDatagrams, VT_COUNTER); break; case LEAF_ipIfStatsHCInForwDatagrams: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInForwDatagrams)); break; case LEAF_ipIfStatsReasmReqds: getproc_got_uint32(pktp, vbp, data->ipIfStatsReasmReqds, VT_COUNTER); break; case LEAF_ipIfStatsReasmOKs: getproc_got_uint32(pktp, vbp, data->ipIfStatsReasmOKs, VT_COUNTER); break; case LEAF_ipIfStatsReasmFails: getproc_got_uint32(pktp, vbp, data->ipIfStatsReasmFails, VT_COUNTER); break; case LEAF_ipIfStatsInDiscards: getproc_got_uint32(pktp, vbp, data->ipIfStatsInDiscards, VT_COUNTER); break; case LEAF_ipIfStatsInDelivers: getproc_got_uint32(pktp, vbp, data->ipIfStatsInDelivers, VT_COUNTER); break; case LEAF_ipIfStatsHCInDelivers: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInDelivers)); break; case LEAF_ipIfStatsOutRequests: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutRequests, VT_COUNTER); break; case LEAF_ipIfStatsHCOutRequests: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutRequests)); break; case LEAF_ipIfStatsOutForwDatagrams: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutForwDatagrams, VT_COUNTER); break; case LEAF_ipIfStatsHCOutForwDatagrams: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutForwDatagrams)); break; case LEAF_ipIfStatsOutDiscards: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutDiscards, VT_COUNTER); break; case LEAF_ipIfStatsOutFragReqds: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutFragReqds, VT_COUNTER); break; case LEAF_ipIfStatsOutFragOKs: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutFragOKs, VT_COUNTER); break; case LEAF_ipIfStatsOutFragFails: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutFragFails, VT_COUNTER); break; case LEAF_ipIfStatsOutFragCreates: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutFragCreates, VT_COUNTER); break; case LEAF_ipIfStatsOutTransmits: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutTransmits, VT_COUNTER); break; case LEAF_ipIfStatsHCOutTransmits: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutTransmits)); break; case LEAF_ipIfStatsOutOctets: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutOctets, VT_COUNTER); break; case LEAF_ipIfStatsHCOutOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutOctets)); break; case LEAF_ipIfStatsInMcastPkts: getproc_got_uint32(pktp, vbp, data->ipIfStatsInMcastPkts, VT_COUNTER); break; case LEAF_ipIfStatsHCInMcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInMcastPkts)); break; case LEAF_ipIfStatsInMcastOctets: getproc_got_uint32(pktp, vbp, data->ipIfStatsInMcastOctets, VT_COUNTER); break; case LEAF_ipIfStatsHCInMcastOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInMcastOctets)); break; case LEAF_ipIfStatsOutMcastPkts: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutMcastPkts, VT_COUNTER); break; case LEAF_ipIfStatsHCOutMcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutMcastPkts)); break; case LEAF_ipIfStatsOutMcastOctets: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutMcastOctets, VT_COUNTER); break; case LEAF_ipIfStatsHCOutMcastOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutMcastOctets)); break; case LEAF_ipIfStatsInBcastPkts: getproc_got_uint32(pktp, vbp, data->ipIfStatsInBcastPkts, VT_COUNTER); break; case LEAF_ipIfStatsHCInBcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCInBcastPkts)); break; case LEAF_ipIfStatsOutBcastPkts: getproc_got_uint32(pktp, vbp, data->ipIfStatsOutBcastPkts, VT_COUNTER); break; case LEAF_ipIfStatsHCOutBcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(data->ipIfStatsHCOutBcastPkts)); break; case LEAF_ipIfStatsDiscontinuityTime: getproc_got_uint32(pktp, vbp, data->ipIfStatsDiscontinuityTime, VT_TIMETICKS); break; case LEAF_ipIfStatsRefreshRate: getproc_got_uint32(pktp, vbp, data->ipIfStatsRefreshRate, VT_GAUGE); break; default: return GEN_ERR; } return NO_ERROR; } #define ipIfStatsEntry_INSTANCE_LEN 2 static unsigned ipIfStatsEntry_build_instance (Ipcom_mib2_IpIfStatsEntry *data, OIDC_T *instance) { instance [0] = data->ipIfStatsIPVersion; instance [1] = data->ipIfStatsIfIndex; return (ipIfStatsEntry_INSTANCE_LEN); } static int ipIfStatsEntry_callback (Ipcom_mib2_IpIfStatsEntry *entry, void *user) { ipIfStatsEntry_cookie_t * cookie = (ipIfStatsEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipIfStatsEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipIfStatsEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipIfStatsEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipIfStatsEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_IpIfStatsEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_IpIfStatsEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } static Ipcom_mib2_IpIfStatsEntry * ipIfStatsEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { ipIfStatsEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ if (!getnext && (tcount != ipIfStatsEntry_INSTANCE_LEN)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipIfStatsTable (ipIfStatsEntry_callback, (void *)&cookie); return (cookie.dataPtr); } void ipIfStatsEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpIfStatsEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipIfStatsEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipIfStatsEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipIfStatsEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpIfStatsEntry * data; OIDC_T best_inst [ipIfStatsEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipIfStatsEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipIfStatsEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipIfStatsEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } /* * Method routines for the ipTrafficStats variables: * * ipIfStatsTableLastChange -- read-only * The value of sysUpTime on the most recent occasion at which * a row in the ipIfStatsTable was added or deleted. * * If new objects are added to the ipIfStatsTable that require * the ipIfStatsTableLastChange to be updated when they are * modified, they must specify that requirement in their * description clause. */ static int ipTrafficStats_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_TimeStamp *data) { switch(lastmatch) { case LEAF_ipIfStatsTableLastChange: getproc_got_uint32(pktp, vbp, *data, VT_TIMETICKS); break; default: return GEN_ERR; } return NO_ERROR; } void ipTrafficStats_get(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_TimeStamp data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance(pktp, vbp, tcount, tlist); /* check that the instance is exactly .0 */ if (!((tcount == 1) && (*tlist == 0))) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else if (ipcom_mib2_get_ipIfStatsTableLastChange (&data) != 0) { for ( ; vbp; vbp = vbp->vb_link) getproc_error (pktp, vbp, GEN_ERR); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipTrafficStats_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, &data)) != NO_ERROR) getproc_error(pktp, vbp, error); } } } void ipTrafficStats_next(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_TimeStamp data; OIDC_T instance = 0; /* the only time there's a next for a scalar is if we're given * no instance at all. */ if (tcount != 0) nextproc_no_next (pktp, vbp); else if (ipcom_mib2_get_ipIfStatsTableLastChange (&data) != 0) getproc_error (pktp, vbp, GEN_ERR); else { /* find all the varbinds in this group and retrieve their * values from the same data structure */ for (group_by_getproc_and_instance (pktp, vbp, tcount, tlist); vbp; vbp = vbp->vb_link) { nextproc_next_instance (pktp, vbp, 1, &instance); (void)ipTrafficStats_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, &data); } } } /* * Method routines for the ipAddressPrefixTable: * * ipAddressPrefixIfIndex -- not-accessible * The index value that uniquely identifies the interface on * which this prefix is configured. The interface identified * by a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipAddressPrefixType -- not-accessible * The address type of ipAddressPrefix. * * ipAddressPrefixPrefix -- not-accessible * The address prefix. The address type of this object is * specified in ipAddressPrefixType. The length of this object * is the standard length for objects of that type (4 or 16 * bytes). Any bits after ipAddressPrefixLength must be zero. * * Implementors need to be aware that, if the size of * ipAddressPrefixPrefix exceeds 114 octets, then OIDS of * instances of columns in this row will have more than 128 * sub-identifiers and cannot be accessed using SNMPv1, * SNMPv2c, or SNMPv3. * * ipAddressPrefixLength -- not-accessible * The prefix length associated with this prefix. * * The value 0 has no special meaning for this object. It * simply refers to address '::/0'. * * ipAddressPrefixOrigin -- read-only * The origin of this prefix. * * ipAddressPrefixOnLinkFlag -- read-only * This object has the value 'true(1)', if this prefix can be * used for on-link determination; otherwise, the value is * 'false(2)'. * * The default for IPv4 prefixes is 'true(1)'. * * ipAddressPrefixAutonomousFlag -- read-only * Autonomous address configuration flag. When true(1), * indicates that this prefix can be used for autonomous * address configuration (i.e., can be used to form a local * interface address). If false(2), it is not used to auto- * configure a local interface address. * * The default for IPv4 prefixes is 'false(2)'. * * ipAddressPrefixAdvPreferredLifetime -- read-only * The remaining length of time, in seconds, that this prefix * will continue to be preferred, i.e., time until deprecation. * * A value of 4,294,967,295 represents infinity. * * The address generated from a deprecated prefix should no * longer be used as a source address in new communications, * but packets received on such an interface are processed as * expected. * * The default for IPv4 prefixes is 4,294,967,295 (infinity). * * ipAddressPrefixAdvValidLifetime -- read-only * The remaining length of time, in seconds, that this prefix * will continue to be valid, i.e., time until invalidation. A * value of 4,294,967,295 represents infinity. * * The address generated from an invalidated prefix should not * appear as the destination or source address of a packet. * * The default for IPv4 prefixes is 4,294,967,295 (infinity). */ static int ipAddressPrefixEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_IpAddressPrefixEntry *data) { switch(lastmatch) { case LEAF_ipAddressPrefixOrigin: /* Values: * other(1) = VAL_ipAddressPrefixOrigin_other * manual(2) = VAL_ipAddressPrefixOrigin_manual * wellknown(3) = VAL_ipAddressPrefixOrigin_wellknown * dhcp(4) = VAL_ipAddressPrefixOrigin_dhcp * routeradv(5) = VAL_ipAddressPrefixOrigin_routeradv */ getproc_got_int32(pktp, vbp, data->ipAddressPrefixOrigin); break; case LEAF_ipAddressPrefixOnLinkFlag: /* Values: * true(1) = VAL_ipAddressPrefixOnLinkFlag_true * false(2) = VAL_ipAddressPrefixOnLinkFlag_false */ getproc_got_int32(pktp, vbp, data->ipAddressPrefixOnLinkFlag); break; case LEAF_ipAddressPrefixAutonomousFlag: /* Values: * true(1) = VAL_ipAddressPrefixAutonomousFlag_true * false(2) = VAL_ipAddressPrefixAutonomousFlag_false */ getproc_got_int32(pktp, vbp, data->ipAddressPrefixAutonomousFlag); break; case LEAF_ipAddressPrefixAdvPreferredLifetime: getproc_got_uint32(pktp, vbp, data->ipAddressPrefixAdvPreferredLifetime, VT_GAUGE); break; case LEAF_ipAddressPrefixAdvValidLifetime: getproc_got_uint32(pktp, vbp, data->ipAddressPrefixAdvValidLifetime, VT_GAUGE); break; default: return GEN_ERR; } return NO_ERROR; } #define ipAddressPrefixEntry_INSTANCE_LEN 20 static unsigned ipAddressPrefixEntry_build_instance (Ipcom_mib2_IpAddressPrefixEntry *data, OIDC_T *instance) { int i = 0; instance [0] = data->ipAddressPrefixIfIndex; instance [1] = data->ipAddressPrefixType; switch (instance [1]) { case ipVersion_ipv4: case ipVersion_ipv4z: instance [2] = 4; break; case ipVersion_ipv6: case ipVersion_ipv6z: instance [2] = 16; break; default: instance [2] = 0; break; } for (i = 0; i < instance [2]; i++) instance [3 + i] = data->ipAddressPrefixPrefix [i]; instance [instance [2] + 3] = data->ipAddressPrefixLength; return (instance [2] + 4); } static int ipAddressPrefixEntry_callback (Ipcom_mib2_IpAddressPrefixEntry *entry, void *user) { ipAddressPrefixEntry_cookie_t * cookie = (ipAddressPrefixEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipAddressPrefixEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipAddressPrefixEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipAddressPrefixEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipAddressPrefixEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_IpAddressPrefixEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_IpAddressPrefixEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } static Ipcom_mib2_IpAddressPrefixEntry * ipAddressPrefixEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { ipAddressPrefixEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ /* v4 length = 4 + 4, v6 length = 4 + 16 */ if (!getnext && (tcount != 4) && (tcount != 8) && (tcount != 20)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipAddressPrefixTable (ipAddressPrefixEntry_callback, (void *)&cookie); return (cookie.dataPtr); } void ipAddressPrefixEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpAddressPrefixEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipAddressPrefixEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipAddressPrefixEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipAddressPrefixEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpAddressPrefixEntry * data; OIDC_T best_inst [ipAddressPrefixEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipAddressPrefixEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipAddressPrefixEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipAddressPrefixEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } /* * Method routines for the ipAddressTable: * * ipAddressAddrType -- not-accessible * The address type of ipAddressAddr. * * ipAddressAddr -- not-accessible * The IP address to which this entry's addressing information * pertains. The address type of this object is specified in * ipAddressAddrType. * * Implementors need to be aware that if the size of * ipAddressAddr exceeds 116 octets, then OIDS of instances of * columns in this row will have more than 128 sub-identifiers * and cannot be accessed using SNMPv1, SNMPv2c, or SNMPv3. * * ipAddressIfIndex -- read-create * The index value that uniquely identifies the interface to * which this entry is applicable. The interface identified by * a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipAddressType -- read-create * The type of address. broadcast(3) is not a valid value for * IPv6 addresses (RFC 3513). * * ipAddressPrefix -- read-only * A pointer to the row in the prefix table to which this * address belongs. May be { 0 0 } if there is no such row. * * ipAddressOrigin -- read-only * The origin of the address. * * ipAddressStatus -- read-create * The status of the address, describing if the address can be * used for communication. * * In the absence of other information, an IPv4 address is * always preferred(1). * * ipAddressCreated -- read-only * The value of sysUpTime at the time this entry was created. * If this entry was created prior to the last re- * initialization of the local network management subsystem, * then this object contains a zero value. * * ipAddressLastChanged -- read-only * The value of sysUpTime at the time this entry was last * updated. If this entry was updated prior to the last re- * initialization of the local network management subsystem, * then this object contains a zero value. * * ipAddressRowStatus -- read-create * The status of this conceptual row. * * The RowStatus TC requires that this DESCRIPTION clause * states under which circumstances other objects in this row * can be modified. The value of this object has no effect on * whether other objects in this conceptual row can be * modified. * * A conceptual row can not be made active until the * ipAddressIfIndex has been set to a valid index. * * ipAddressStorageType -- read-create * The storage type for this conceptual row. If this object * has a value of 'permanent', then no other objects are * required to be able to be modified. */ static int ipAddressEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_IpAddressEntry *data) { switch(lastmatch) { case LEAF_ipAddressIfIndex: getproc_got_int32(pktp, vbp, data->ipAddressIfIndex); break; case LEAF_ipAddressType: /* Values: * unicast(1) = VAL_ipAddressType_unicast * anycast(2) = VAL_ipAddressType_anycast * broadcast(3) = VAL_ipAddressType_broadcast */ getproc_got_int32(pktp, vbp, data->ipAddressType); break; case LEAF_ipAddressPrefix: { /* Convert from data structure array elements to OID-sized elements. */ OIDC_T * oidp = SNMP_memory_alloc (data->ipAddressPrefix [0] * sizeof (OIDC_T)); int i = 0; if (oidp == NULL) return GEN_ERR; for (i = 0; i < data->ipAddressPrefix [0]; i++) oidp [i] = data->ipAddressPrefix [i + 1]; getproc_got_object_id(pktp, vbp, data->ipAddressPrefix [0], oidp, 1); } break; case LEAF_ipAddressOrigin: /* Values: * other(1) = VAL_ipAddressOrigin_other * manual(2) = VAL_ipAddressOrigin_manual * dhcp(4) = VAL_ipAddressOrigin_dhcp * linklayer(5) = VAL_ipAddressOrigin_linklayer * random(6) = VAL_ipAddressOrigin_random */ getproc_got_int32(pktp, vbp, data->ipAddressOrigin); break; case LEAF_ipAddressStatus: /* Values: * preferred(1) = VAL_ipAddressStatus_preferred * deprecated(2) = VAL_ipAddressStatus_deprecated * invalid(3) = VAL_ipAddressStatus_invalid * inaccessible(4) = VAL_ipAddressStatus_inaccessible * unknown(5) = VAL_ipAddressStatus_unknown * tentative(6) = VAL_ipAddressStatus_tentative * duplicate(7) = VAL_ipAddressStatus_duplicate * optimistic(8) = VAL_ipAddressStatus_optimistic */ getproc_got_int32(pktp, vbp, data->ipAddressStatus); break; case LEAF_ipAddressCreated: getproc_got_uint32(pktp, vbp, data->ipAddressCreated, VT_TIMETICKS); break; case LEAF_ipAddressLastChanged: getproc_got_uint32(pktp, vbp, data->ipAddressLastChanged, VT_TIMETICKS); break; case LEAF_ipAddressRowStatus: /* Values: * active(1) = VAL_ipAddressRowStatus_active * notInService(2) = VAL_ipAddressRowStatus_notInService * notReady(3) = VAL_ipAddressRowStatus_notReady * createAndGo(4) = VAL_ipAddressRowStatus_createAndGo * createAndWait(5) = VAL_ipAddressRowStatus_createAndWait * destroy(6) = VAL_ipAddressRowStatus_destroy */ getproc_got_int32(pktp, vbp, data->ipAddressRowStatus); break; case LEAF_ipAddressStorageType: /* Values: * other(1) = VAL_ipAddressStorageType_other * volatile(2) = VAL_ipAddressStorageType_volatile * nonVolatile(3) = VAL_ipAddressStorageType_nonVolatile * permanent(4) = VAL_ipAddressStorageType_permanent * readOnly(5) = VAL_ipAddressStorageType_readOnly */ getproc_got_int32(pktp, vbp, data->ipAddressStorageType); break; default: return GEN_ERR; } return NO_ERROR; } #define ipAddressEntry_INSTANCE_LEN 22 static unsigned ipAddressEntry_build_instance (Ipcom_mib2_IpAddressEntry *data, OIDC_T *instance) { int i = 0; instance [0] = data->ipAddressAddrType; switch (instance [0]) { case ipVersion_ipv4: instance [1] = 4; break; case ipVersion_ipv4z: instance [1] = 8; break; case ipVersion_ipv6: instance [1] = 16; break; case ipVersion_ipv6z: instance [1] = 20; break; default: instance [1] = 0; break; } for (i = 0; i < instance [1]; i++) instance [2 + i] = data->ipAddressAddr [i]; return (instance [1] + 2); } static int ipAddressEntry_callback (Ipcom_mib2_IpAddressEntry *entry, void *user) { ipAddressEntry_cookie_t * cookie = (ipAddressEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipAddressEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipAddressEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipAddressEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipAddressEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_IpAddressEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_IpAddressEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } static Ipcom_mib2_IpAddressEntry * ipAddressEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { ipAddressEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ /* v4 length = 2 + 4, v6 length = 2 + 16 */ if (!getnext && (tcount != 2) && (tcount != 6) && (tcount != 18)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipAddressTable (ipAddressEntry_callback, (void *)&cookie); return (cookie.dataPtr); } void ipAddressEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpAddressEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipAddressEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipAddressEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipAddressEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpAddressEntry * data; OIDC_T best_inst [ipAddressEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipAddressEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipAddressEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipAddressEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } void ipAddressEntry_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpAddressEntry *data; VB_T *group_vbp; if ((data = ipAddressEntry_lookup (tcount, tlist, FALSE)) == NULL) { testproc_error (pktp, vbp, NO_SUCH_NAME); return; } /* stash the looked up information here for the setproc */ vbp->vb_priv = (PTR_T *)data; vbp->vb_free_priv = (VBPRIVPROC_T *)localFree; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* now check each varbind */ /* coverity[unreachable] */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { case LEAF_ipAddressIfIndex: { bits32_t value = VB_GET_INT32(group_vbp); if (!((value >= MIN_ipAddressIfIndex) && (value <= MAX_ipAddressIfIndex))) { testproc_error(pktp, group_vbp, WRONG_VALUE); return; } /* SET is not supported for this object. */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; } case LEAF_ipAddressType: switch (VB_GET_INT32(group_vbp)) { case VAL_ipAddressType_unicast: case VAL_ipAddressType_anycast: case VAL_ipAddressType_broadcast: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipAddressStatus: switch (VB_GET_INT32(group_vbp)) { case VAL_ipAddressStatus_preferred: case VAL_ipAddressStatus_deprecated: case VAL_ipAddressStatus_invalid: case VAL_ipAddressStatus_inaccessible: case VAL_ipAddressStatus_unknown: case VAL_ipAddressStatus_tentative: case VAL_ipAddressStatus_duplicate: case VAL_ipAddressStatus_optimistic: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipAddressRowStatus: switch (VB_GET_INT32(group_vbp)) { case VAL_ipAddressRowStatus_active: case VAL_ipAddressRowStatus_notInService: case VAL_ipAddressRowStatus_notReady: case VAL_ipAddressRowStatus_createAndGo: case VAL_ipAddressRowStatus_createAndWait: case VAL_ipAddressRowStatus_destroy: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipAddressStorageType: switch (VB_GET_INT32(group_vbp)) { case VAL_ipAddressStorageType_other: case VAL_ipAddressStorageType_volatile: case VAL_ipAddressStorageType_nonVolatile: case VAL_ipAddressStorageType_permanent: case VAL_ipAddressStorageType_readOnly: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } default: testproc_error(pktp, group_vbp, GEN_ERR); return; } } } void ipAddressEntry_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { /* IPNet does not currently support SET for this object. */ } /* * Method routines for the ipNetToPhysicalTable: * * ipNetToPhysicalIfIndex -- not-accessible * The index value that uniquely identifies the interface to * which this entry is applicable. The interface identified by * a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipNetToPhysicalNetAddressType -- not-accessible * The type of ipNetToPhysicalNetAddress. * * ipNetToPhysicalNetAddress -- not-accessible * The IP Address corresponding to the media-dependent * `physical' address. The address type of this object is * specified in ipNetToPhysicalAddressType. * * Implementors need to be aware that if the size of * ipNetToPhysicalNetAddress exceeds 115 octets, then OIDS of * instances of columns in this row will have more than 128 * sub-identifiers and cannot be accessed using SNMPv1, * SNMPv2c, or SNMPv3. * * ipNetToPhysicalPhysAddress -- read-create * The media-dependent `physical' address. * * As the entries in this table are typically not persistent * when this object is written the entity SHOULD NOT save the * change to non-volatile storage. * * ipNetToPhysicalLastUpdated -- read-only * The value of sysUpTime at the time this entry was last * updated. If this entry was updated prior to the last re- * initialization of the local network management subsystem, * then this object contains a zero value. * * ipNetToPhysicalType -- read-create * The type of mapping. * * Setting this object to the value invalid(2) has the effect * of invalidating the corresponding entry in the * ipNetToPhysicalTable. That is, it effectively dis- * associates the interface identified with said entry from the * mapping identified with said entry. It is an * implementation-specific matter as to whether the agent * removes an invalidated entry from the table. Accordingly, * management stations must be prepared to receive tabular * information from agents that corresponds to entries not * currently in use. Proper interpretation of such entries * requires examination of the relevant ipNetToPhysicalType * object. * * The 'dynamic(3)' type indicates that the IP address to * physical addresses mapping has been dynamically resolved * using e.g., IPv4 ARP or the IPv6 Neighbor Discovery * protocol. * * The 'static(4)' type indicates that the mapping has been * statically configured. Both of these refer to entries that * provide mappings for other entities addresses. * * The 'local(5)' type indicates that the mapping is provided * for an entity's own interface address. * * As the entries in this table are typically not persistent * when this object is written the entity SHOULD NOT save the * change to non-volatile storage. * * ipNetToPhysicalState -- read-only * The Neighbor Unreachability Detection state for the * interface when the address mapping in this entry is used. * If Neighbor Unreachability Detection is not in use (e.g. for * IPv4), this object is always unknown(6). * * ipNetToPhysicalRowStatus -- read-create * The status of this conceptual row. * * The RowStatus TC requires that this DESCRIPTION clause * states under which circumstances other objects in this row * can be modified. The value of this object has no effect on * whether other objects in this conceptual row can be * modified. * * A conceptual row can not be made active until the * ipNetToPhysicalPhysAddress object has been set. * * Note that if the ipNetToPhysicalType is set to 'invalid', * the managed node may delete the entry independent of the * state of this object. */ static int ipNetToPhysicalEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_IpNetToPhysicalEntry *data) { /* IPNet stores OCTET STRING lengths as a 32-bit values */ ALENGTH_T * ipNetToPhysicalPhysAddressLengthP = (ALENGTH_T *)&(data->ipNetToPhysicalPhysAddress [0]); switch(lastmatch) { case LEAF_ipNetToPhysicalPhysAddress: getproc_got_octet_string(pktp, vbp, *ipNetToPhysicalPhysAddressLengthP, &(data->ipNetToPhysicalPhysAddress [4]), VT_STRING); break; case LEAF_ipNetToPhysicalLastUpdated: getproc_got_uint32(pktp, vbp, data->ipNetToPhysicalLastUpdated, VT_TIMETICKS); break; case LEAF_ipNetToPhysicalType: /* Values: * other(1) = VAL_ipNetToPhysicalType_other * invalid(2) = VAL_ipNetToPhysicalType_invalid * dynamic(3) = VAL_ipNetToPhysicalType_dynamic * static(4) = VAL_ipNetToPhysicalType_static * local(5) = VAL_ipNetToPhysicalType_local */ getproc_got_int32(pktp, vbp, data->ipNetToPhysicalType); break; case LEAF_ipNetToPhysicalState: /* Values: * reachable(1) = VAL_ipNetToPhysicalState_reachable * stale(2) = VAL_ipNetToPhysicalState_stale * delay(3) = VAL_ipNetToPhysicalState_delay * probe(4) = VAL_ipNetToPhysicalState_probe * invalid(5) = VAL_ipNetToPhysicalState_invalid * unknown(6) = VAL_ipNetToPhysicalState_unknown * incomplete(7) = VAL_ipNetToPhysicalState_incomplete */ getproc_got_int32(pktp, vbp, data->ipNetToPhysicalState); break; case LEAF_ipNetToPhysicalRowStatus: /* Values: * active(1) = VAL_ipNetToPhysicalRowStatus_active * notInService(2) = VAL_ipNetToPhysicalRowStatus_notInService * notReady(3) = VAL_ipNetToPhysicalRowStatus_notReady * createAndGo(4) = VAL_ipNetToPhysicalRowStatus_createAndGo * createAndWait(5) = VAL_ipNetToPhysicalRowStatus_createAndWait * destroy(6) = VAL_ipNetToPhysicalRowStatus_destroy */ getproc_got_int32(pktp, vbp, data->ipNetToPhysicalRowStatus); break; default: return GEN_ERR; } return NO_ERROR; } #define ipNetToPhysicalEntry_INSTANCE_LEN 19 static unsigned ipNetToPhysicalEntry_build_instance (Ipcom_mib2_IpNetToPhysicalEntry *data, OIDC_T *instance) { int i = 0; instance [0] = data->ipNetToPhysicalIfIndex; instance [1] = data->ipNetToPhysicalNetAddressType; switch (instance [1]) { case ipVersion_ipv4: case ipVersion_ipv4z: instance [2] = 4; break; case ipVersion_ipv6: case ipVersion_ipv6z: instance [2] = 16; break; default: instance [2] = 0; break; } for (i = 0; i < instance [2]; i++) instance [3 + i] = data->ipNetToPhysicalNetAddress [i]; return (instance [2] + 3); } static int ipNetToPhysicalEntry_callback (Ipcom_mib2_IpNetToPhysicalEntry *entry, void *user) { ipNetToPhysicalEntry_cookie_t * cookie = (ipNetToPhysicalEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipNetToPhysicalEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipNetToPhysicalEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipNetToPhysicalEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipNetToPhysicalEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_IpNetToPhysicalEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_IpNetToPhysicalEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } static Ipcom_mib2_IpNetToPhysicalEntry * ipNetToPhysicalEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { ipNetToPhysicalEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ /* v4 length = 3 + 4, v6 length = 3 + 16 */ if (!getnext && (tcount != 3) && (tcount != 7) && (tcount != 19)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipNetToPhysicalTable (ipNetToPhysicalEntry_callback, (void *)&cookie); return (cookie.dataPtr); } void ipNetToPhysicalEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpNetToPhysicalEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipNetToPhysicalEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipNetToPhysicalEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipNetToPhysicalEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpNetToPhysicalEntry * data; OIDC_T best_inst [ipNetToPhysicalEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipNetToPhysicalEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipNetToPhysicalEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipNetToPhysicalEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } void ipNetToPhysicalEntry_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpNetToPhysicalEntry *data; VB_T *group_vbp; if ((data = ipNetToPhysicalEntry_lookup (tcount, tlist, FALSE)) == NULL) { testproc_error (pktp, vbp, NO_SUCH_NAME); return; } /* stash the looked up information here for the setproc */ vbp->vb_priv = (PTR_T *)data; vbp->vb_free_priv = (VBPRIVPROC_T *)localFree; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* now check each varbind */ /* coverity[unreachable] */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { case LEAF_ipNetToPhysicalPhysAddress: { ALENGTH_T length = EBufferUsed(VB_GET_STRING(group_vbp)); if ((length != 4) && (length != 16)) { testproc_error (pktp, group_vbp, WRONG_LENGTH); return; } } /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipNetToPhysicalType: switch (VB_GET_INT32(group_vbp)) { case VAL_ipNetToPhysicalType_other: case VAL_ipNetToPhysicalType_invalid: case VAL_ipNetToPhysicalType_dynamic: case VAL_ipNetToPhysicalType_static: case VAL_ipNetToPhysicalType_local: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipNetToPhysicalRowStatus: switch (VB_GET_INT32(group_vbp)) { case VAL_ipNetToPhysicalRowStatus_active: case VAL_ipNetToPhysicalRowStatus_notInService: case VAL_ipNetToPhysicalRowStatus_notReady: case VAL_ipNetToPhysicalRowStatus_createAndGo: case VAL_ipNetToPhysicalRowStatus_createAndWait: case VAL_ipNetToPhysicalRowStatus_destroy: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } default: testproc_error(pktp, group_vbp, GEN_ERR); return; } } } void ipNetToPhysicalEntry_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { /* IPNet does not currently support SET for this object. */ } /* * Method routines for the ipv6ScopeZoneIndexTable: * * ipv6ScopeZoneIndexIfIndex -- not-accessible * The index value that uniquely identifies the interface to * which these scopes belong. The interface identified by a * particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipv6ScopeZoneIndexLinkLocal -- read-only * The zone index for the link-local scope on this interface. * * ipv6ScopeZoneIndex3 -- read-only * The zone index for scope 3 on this interface. * * ipv6ScopeZoneIndexAdminLocal -- read-only * The zone index for the admin-local scope on this interface. * * ipv6ScopeZoneIndexSiteLocal -- read-only * The zone index for the site-local scope on this interface. * * ipv6ScopeZoneIndex6 -- read-only * The zone index for scope 6 on this interface. * * ipv6ScopeZoneIndex7 -- read-only * The zone index for scope 7 on this interface. * * ipv6ScopeZoneIndexOrganizationLocal -- read-only * The zone index for the organization-local scope on this * interface. * * ipv6ScopeZoneIndex9 -- read-only * The zone index for scope 9 on this interface. * * ipv6ScopeZoneIndexA -- read-only * The zone index for scope A on this interface. * * ipv6ScopeZoneIndexB -- read-only * The zone index for scope B on this interface. * * ipv6ScopeZoneIndexC -- read-only * The zone index for scope C on this interface. * * ipv6ScopeZoneIndexD -- read-only * The zone index for scope D on this interface. */ static int ipv6ScopeZoneIndexEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_Ipv6ScopeZoneIndexEntry *data) { switch(lastmatch) { case LEAF_ipv6ScopeZoneIndexLinkLocal: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexLinkLocal, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndex3: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndex3, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexAdminLocal: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexAdminLocal, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexSiteLocal: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexSiteLocal, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndex6: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndex6, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndex7: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndex7, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexOrganizationLocal: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexOrganizationLocal, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndex9: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndex9, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexA: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexA, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexB: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexB, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexC: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexC, VT_GAUGE); break; case LEAF_ipv6ScopeZoneIndexD: getproc_got_uint32(pktp, vbp, data->ipv6ScopeZoneIndexD, VT_GAUGE); break; default: return GEN_ERR; } return NO_ERROR; } #define ipv6ScopeZoneIndexEntry_INSTANCE_LEN 1 static unsigned ipv6ScopeZoneIndexEntry_build_instance (Ipcom_mib2_Ipv6ScopeZoneIndexEntry *data, OIDC_T *instance) { instance [0] = data->ipv6ScopeZoneIndexIfIndex; return (ipv6ScopeZoneIndexEntry_INSTANCE_LEN); } #ifdef IPCOM_USE_INET6 static int ipv6ScopeZoneIndexEntry_callback (Ipcom_mib2_Ipv6ScopeZoneIndexEntry *entry, void *user) { ipv6ScopeZoneIndexEntry_cookie_t * cookie = (ipv6ScopeZoneIndexEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipv6ScopeZoneIndexEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipv6ScopeZoneIndexEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipv6ScopeZoneIndexEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipv6ScopeZoneIndexEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_Ipv6ScopeZoneIndexEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_Ipv6ScopeZoneIndexEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } #endif /* IPCOM_USE_INET6 */ static Ipcom_mib2_Ipv6ScopeZoneIndexEntry * ipv6ScopeZoneIndexEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { #ifdef IPCOM_USE_INET6 ipv6ScopeZoneIndexEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ if (!getnext && (tcount != ipv6ScopeZoneIndexEntry_INSTANCE_LEN)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipv6ScopeZoneIndexTable (ipv6ScopeZoneIndexEntry_callback, (void *)&cookie); return (cookie.dataPtr); #else return (NULL); #endif /* IPCOM_USE_INET6 */ } void ipv6ScopeZoneIndexEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6ScopeZoneIndexEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv6ScopeZoneIndexEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipv6ScopeZoneIndexEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipv6ScopeZoneIndexEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6ScopeZoneIndexEntry * data; OIDC_T best_inst [ipv6ScopeZoneIndexEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv6ScopeZoneIndexEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipv6ScopeZoneIndexEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipv6ScopeZoneIndexEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } /* * Method routines for the ipDefaultRouterTable: * * ipDefaultRouterAddressType -- not-accessible * The address type for this row. * * ipDefaultRouterAddress -- not-accessible * The IP address of the default router represented by this * row. The address type of this object is specified in * ipDefaultRouterAddressType. * * Implementers need to be aware that if the size of * ipDefaultRouterAddress exceeds 115 octets, then OIDS of * instances of columns in this row will have more than 128 * sub-identifiers and cannot be accessed using SNMPv1, * SNMPv2c, or SNMPv3. * * ipDefaultRouterIfIndex -- not-accessible * The index value that uniquely identifies the interface by * which the router can be reached. The interface identified * by a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipDefaultRouterLifetime -- read-only * The remaining length of time, in seconds, that this router * will continue to be useful as a default router. A value of * zero indicates that it is no longer useful as a default * router. It is left to the implementer of the MIB as to * whether a router with a lifetime of zero is removed from the * list. * * For IPv6, this value should be extracted from the router * advertisement messages. * * ipDefaultRouterPreference -- read-only * An indication of preference given to this router as a * default router as described in he Default Router * Preferences document. Treating the value as a * 2 bit signed integer allows for simple arithmetic * comparisons. * * For IPv4 routers or IPv6 routers that are not using the * updated router advertisement format, this object is set to * medium (0). */ static int ipDefaultRouterEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_IpDefaultRouterEntry *data) { switch(lastmatch) { case LEAF_ipDefaultRouterLifetime: getproc_got_uint32(pktp, vbp, data->ipDefaultRouterLifetime, VT_GAUGE); break; case LEAF_ipDefaultRouterPreference: /* Values: * reserved(-2) = VAL_ipDefaultRouterPreference_reserved * low(-1) = VAL_ipDefaultRouterPreference_low * medium(0) = VAL_ipDefaultRouterPreference_medium * high(1) = VAL_ipDefaultRouterPreference_high */ getproc_got_int32(pktp, vbp, data->ipDefaultRouterPreference); break; default: return GEN_ERR; } return NO_ERROR; } #define ipDefaultRouterEntry_INSTANCE_LEN 19 static unsigned ipDefaultRouterEntry_build_instance (Ipcom_mib2_IpDefaultRouterEntry *data, OIDC_T *instance) { int i = 0; instance [0] = data->ipDefaultRouterAddressType; switch (instance [0]) { case ipVersion_ipv4: case ipVersion_ipv4z: instance [1] = 4; break; case ipVersion_ipv6: case ipVersion_ipv6z: instance [1] = 16; break; default: instance [1] = 0; break; } for (i = 0; i < instance [1]; i++) instance [2 + i] = data->ipDefaultRouterAddress [i]; instance [instance [1] + 2] = data->ipDefaultRouterIfIndex; return (instance [1] + 3); } static int ipDefaultRouterEntry_callback (Ipcom_mib2_IpDefaultRouterEntry *entry, void *user) { ipDefaultRouterEntry_cookie_t * cookie = (ipDefaultRouterEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipDefaultRouterEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipDefaultRouterEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipDefaultRouterEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipDefaultRouterEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_IpDefaultRouterEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_IpDefaultRouterEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } static Ipcom_mib2_IpDefaultRouterEntry * ipDefaultRouterEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { ipDefaultRouterEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ /* v4 length = 3 + 4, v6 length = 3 + 16 */ if (!getnext && (tcount != 3) && (tcount != 7) && (tcount != 19)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipDefaultRouterTable (ipDefaultRouterEntry_callback, (void *)&cookie); return (cookie.dataPtr); } void ipDefaultRouterEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpDefaultRouterEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipDefaultRouterEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipDefaultRouterEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipDefaultRouterEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_IpDefaultRouterEntry * data; OIDC_T best_inst [ipDefaultRouterEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipDefaultRouterEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipDefaultRouterEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipDefaultRouterEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } /* * Method routines for the ipv6RouterAdvertTable: * * ipv6RouterAdvertIfIndex -- not-accessible * The index value that uniquely identifies the interface on * which router advertisements constructed with this * information will be transmitted. The interface identified * by a particular value of this index is the same interface as * identified by the same value of the IF-MIB's ifIndex. * * ipv6RouterAdvertSendAdverts -- read-create * A flag indicating whether the router sends periodic * router advertisements and responds to router solicitations * on this interface. * * ipv6RouterAdvertMaxInterval -- read-create * The maximum time allowed between sending unsolicited router * advertisements from this interface. * * ipv6RouterAdvertMinInterval -- read-create * The minimum time allowed between sending unsolicited router * advertisements from this interface. * * The default is 0.33 * ipv6RouterAdvertMaxInterval, however, * in the case of a low value for ipv6RouterAdvertMaxInterval, * the minimum value for this object is restricted to 3. * * ipv6RouterAdvertManagedFlag -- read-create * The true/false value to be placed into the 'managed address * configuration' flag field in router advertisements sent from * this interface. * * ipv6RouterAdvertOtherConfigFlag -- read-create * The true/false value to be placed into the 'other stateful * configuration' flag field in router advertisements sent from * this interface. * * ipv6RouterAdvertLinkMTU -- read-create * The value to be placed in MTU options sent by the router on * this interface. * * A value of zero indicates that no MTU options are sent. * * ipv6RouterAdvertReachableTime -- read-create * The value to be placed in the reachable time field in router * advertisement messages sent from this interface. * * A value of zero in the router advertisement indicates that * the advertisement isn't specifying a value for reachable * time. * * ipv6RouterAdvertRetransmitTime -- read-create * The value to be placed in the retransmit timer field in * router advertisements sent from this interface. * * A value of zero in the router advertisement indicates that * the advertisement isn't specifying a value for retrans * time. * * ipv6RouterAdvertCurHopLimit -- read-create * The default value to be placed in the current hop limit * field in router advertisements sent from this interface. * * The value should be set to the current diameter of the * Internet. * * A value of zero in the router advertisement indicates that * the advertisement isn't specifying a value for curHopLimit. * * The default should be set to the value specified in the IANA * web pages (www.iana.org) at the time of implementation. * * ipv6RouterAdvertDefaultLifetime -- read-create * The value to be placed in the router lifetime field of * router advertisements sent from this interface. This value * MUST be either 0 or between ipv6RouterAdvertMaxInterval and * 9000 seconds. * * A value of zero indicates that the router is not to be used * as a default router. * * The default is 3 * ipv6RouterAdvertMaxInterval. * * ipv6RouterAdvertRowStatus -- read-create * The status of this conceptual row. * * As all objects in this conceptual row have default values, a * row can be created and made active by setting this object * appropriately. * * The RowStatus TC requires that this DESCRIPTION clause * states under which circumstances other objects in this row * can be modified. The value of this object has no effect on * whether other objects in this conceptual row can be * modified. */ static int ipv6RouterAdvertEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, Ipcom_mib2_Ipv6RouterAdvertEntry *data) { switch(lastmatch) { case LEAF_ipv6RouterAdvertSendAdverts: /* Values: * true(1) = VAL_ipv6RouterAdvertSendAdverts_true * false(2) = VAL_ipv6RouterAdvertSendAdverts_false */ getproc_got_int32(pktp, vbp, data->ipv6RouterAdvertSendAdverts); break; case LEAF_ipv6RouterAdvertMaxInterval: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertMaxInterval, VT_GAUGE); break; case LEAF_ipv6RouterAdvertMinInterval: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertMinInterval, VT_GAUGE); break; case LEAF_ipv6RouterAdvertManagedFlag: /* Values: * true(1) = VAL_ipv6RouterAdvertManagedFlag_true * false(2) = VAL_ipv6RouterAdvertManagedFlag_false */ getproc_got_int32(pktp, vbp, data->ipv6RouterAdvertManagedFlag); break; case LEAF_ipv6RouterAdvertOtherConfigFlag: /* Values: * true(1) = VAL_ipv6RouterAdvertOtherConfigFlag_true * false(2) = VAL_ipv6RouterAdvertOtherConfigFlag_false */ getproc_got_int32(pktp, vbp, data->ipv6RouterAdvertOtherConfigFlag); break; case LEAF_ipv6RouterAdvertLinkMTU: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertLinkMTU, VT_GAUGE); break; case LEAF_ipv6RouterAdvertReachableTime: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertReachableTime, VT_GAUGE); break; case LEAF_ipv6RouterAdvertRetransmitTime: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertRetransmitTime, VT_GAUGE); break; case LEAF_ipv6RouterAdvertCurHopLimit: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertCurHopLimit, VT_GAUGE); break; case LEAF_ipv6RouterAdvertDefaultLifetime: getproc_got_uint32(pktp, vbp, data->ipv6RouterAdvertDefaultLifetime, VT_GAUGE); break; case LEAF_ipv6RouterAdvertRowStatus: /* Values: * active(1) = VAL_ipv6RouterAdvertRowStatus_active * notInService(2) = VAL_ipv6RouterAdvertRowStatus_notInService * notReady(3) = VAL_ipv6RouterAdvertRowStatus_notReady * createAndGo(4) = VAL_ipv6RouterAdvertRowStatus_createAndGo * createAndWait(5) = VAL_ipv6RouterAdvertRowStatus_createAndWait * destroy(6) = VAL_ipv6RouterAdvertRowStatus_destroy */ getproc_got_int32(pktp, vbp, data->ipv6RouterAdvertRowStatus); break; default: return GEN_ERR; } return NO_ERROR; } #define ipv6RouterAdvertEntry_INSTANCE_LEN 1 static unsigned ipv6RouterAdvertEntry_build_instance (Ipcom_mib2_Ipv6RouterAdvertEntry *data, OIDC_T *instance) { instance [0] = data->ipv6RouterAdvertIfIndex; return (ipv6RouterAdvertEntry_INSTANCE_LEN); } #ifdef IPCOM_USE_INET6 static int ipv6RouterAdvertEntry_callback (Ipcom_mib2_Ipv6RouterAdvertEntry *entry, void *user) { ipv6RouterAdvertEntry_cookie_t * cookie = (ipv6RouterAdvertEntry_cookie_t *)user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; OIDC_T instance [ipv6RouterAdvertEntry_INSTANCE_LEN]; unsigned instanceLen = 0; int cmpval = 0; instanceLen = ipv6RouterAdvertEntry_build_instance (entry, instance); cmpval = oidcmp2 (instanceLen, instance, cookie->tcount, cookie->tlist); if (cookie->getnext) { if (cmpval > 0) { if (cookie->dataPtr == NULL) saveData = TRUE; else { OIDC_T prevInstance [ipv6RouterAdvertEntry_INSTANCE_LEN]; unsigned prevInstanceLen = 0; prevInstanceLen = ipv6RouterAdvertEntry_build_instance (cookie->dataPtr, prevInstance); if (oidcmp2 (instanceLen, instance, prevInstanceLen, prevInstance) < 0) saveData = TRUE; } } } else /* Get exact */ { if (cmpval == 0) { saveData = TRUE; stopIterating = TRUE; } } if (saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = SNMP_memory_alloc (sizeof (Ipcom_mib2_Ipv6RouterAdvertEntry)); if (cookie->dataPtr != NULL) memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_Ipv6RouterAdvertEntry)); } /* Return values defined are part of callback API. */ return (stopIterating? 1: 0); } #endif /* IPCOM_USE_INET6 */ static Ipcom_mib2_Ipv6RouterAdvertEntry * ipv6RouterAdvertEntry_lookup (int tcount, OIDC_T * tlist, boolean_t getnext) { #ifdef IPCOM_USE_INET6 ipv6RouterAdvertEntry_cookie_t cookie; /* Make sure the instance length is correct if we need an exact match. */ if (!getnext && (tcount != ipv6RouterAdvertEntry_INSTANCE_LEN)) return (NULL); cookie.tcount = tcount; cookie.tlist = tlist; cookie.dataPtr = NULL; cookie.getnext = getnext; ipcom_mib2_iterate_ipv6RouterAdvertTable (ipv6RouterAdvertEntry_callback, (void *)&cookie); return (cookie.dataPtr); #else return (NULL); #endif /* IPCOM_USE_INET6 */ } void ipv6RouterAdvertEntry_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6RouterAdvertEntry *data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv6RouterAdvertEntry_lookup (tcount, tlist, FALSE)) == NULL) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins (pktp, vbp); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ipv6RouterAdvertEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR) getproc_error (pktp, vbp, error); } SNMP_memory_free (data); } } void ipv6RouterAdvertEntry_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6RouterAdvertEntry * data; OIDC_T best_inst [ipv6RouterAdvertEntry_INSTANCE_LEN]; int error; unsigned best_inst_len; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); if ((data = ipv6RouterAdvertEntry_lookup (tcount, tlist, TRUE)) != NULL) { best_inst_len = ipv6RouterAdvertEntry_build_instance (data, best_inst); /* we found a next so get the values and set the instance for all * the varbinds for this row of this table. */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = ipv6RouterAdvertEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, data)) == NO_ERROR) nextproc_next_instance (pktp, vbp, best_inst_len, best_inst); else nextproc_error (pktp, vbp, error); } SNMP_memory_free (data); } else /* there's no more in this table */ { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next (pktp, vbp); } } void ipv6RouterAdvertEntry_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { Ipcom_mib2_Ipv6RouterAdvertEntry *data; VB_T *group_vbp; if ((data = ipv6RouterAdvertEntry_lookup (tcount, tlist, FALSE)) == NULL) { testproc_error (pktp, vbp, NO_SUCH_NAME); return; } /* stash the looked up information here for the setproc */ vbp->vb_priv = (PTR_T *)data; vbp->vb_free_priv = (VBPRIVPROC_T *)localFree; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* now check each varbind */ /* coverity[unreachable] */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { case LEAF_ipv6RouterAdvertSendAdverts: switch (VB_GET_INT32(group_vbp)) { case VAL_ipv6RouterAdvertSendAdverts_true: case VAL_ipv6RouterAdvertSendAdverts_false: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipv6RouterAdvertMaxInterval: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertMinInterval: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertManagedFlag: switch (VB_GET_INT32(group_vbp)) { case VAL_ipv6RouterAdvertManagedFlag_true: case VAL_ipv6RouterAdvertManagedFlag_false: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipv6RouterAdvertOtherConfigFlag: switch (VB_GET_INT32(group_vbp)) { case VAL_ipv6RouterAdvertOtherConfigFlag_true: case VAL_ipv6RouterAdvertOtherConfigFlag_false: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } case LEAF_ipv6RouterAdvertLinkMTU: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertReachableTime: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertRetransmitTime: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertCurHopLimit: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertDefaultLifetime: testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; case LEAF_ipv6RouterAdvertRowStatus: switch (VB_GET_INT32(group_vbp)) { case VAL_ipv6RouterAdvertRowStatus_active: case VAL_ipv6RouterAdvertRowStatus_notInService: case VAL_ipv6RouterAdvertRowStatus_notReady: case VAL_ipv6RouterAdvertRowStatus_createAndGo: case VAL_ipv6RouterAdvertRowStatus_createAndWait: case VAL_ipv6RouterAdvertRowStatus_destroy: /* SET is not supported for this object */ testproc_error (pktp, vbp, INCONSISTENT_VALUE); return; default: testproc_error(pktp, group_vbp, WRONG_VALUE); return; } default: testproc_error(pktp, group_vbp, GEN_ERR); return; } } } void ipv6RouterAdvertEntry_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { /* IPNet does not currently support SET for this object. */ } /* * Method routines for the ip variables: * * ipForwarding -- read-write * The indication of whether this entity is acting as an IPv4 * router in respect to the forwarding of datagrams received * by, but not addressed to, this entity. IPv4 routers forward * datagrams. IPv4 hosts do not (except those source-routed * via the host). * * When this object is written, the entity should save the * change to non-volatile storage and restore the object from * non-volatile storage upon re-initialization of the system. * Note: a stronger requirement is not used because this object * was previously defined. * * ipDefaultTTL -- read-write * The default value inserted into the Time-To-Live field of * the IPv4 header of datagrams originated at this entity, * whenever a TTL value is not supplied by the transport layer * protocol. * * When this object is written, the entity should save the * change to non-volatile storage and restore the object from * non-volatile storage upon re-initialization of the system. * Note: a stronger requirement is not used because this object * was previously defined. * * ipReasmTimeout -- read-only * The maximum number of seconds that received fragments are * held while they are awaiting reassembly at this entity. * * ipv6IpForwarding -- read-write * The indication of whether this entity is acting as an IPv6 * router on any interface in respect to the forwarding of * datagrams received by, but not addressed to, this entity. * IPv6 routers forward datagrams. IPv6 hosts do not (except * those source-routed via the host). * * When this object is written, the entity SHOULD save the * change to non-volatile storage and restore the object from * non-volatile storage upon re-initialization of the system. * * ipv6IpDefaultHopLimit -- read-write * The default value inserted into the Hop Limit field of the * IPv6 header of datagrams originated at this entity whenever * a Hop Limit value is not supplied by the transport layer * protocol. * * When this object is written, the entity SHOULD save the * change to non-volatile storage and restore the object from * non-volatile storage upon re-initialization of the system. * * ipv4InterfaceTableLastChange -- read-only * The value of sysUpTime on the most recent occasion at which * a row in the ipv4InterfaceTable was added or deleted, or * when an ipv4InterfaceReasmMaxSize or an * ipv4InterfaceEnableStatus object was modified. * * If new objects are added to the ipv4InterfaceTable that * require the ipv4InterfaceTableLastChange to be updated when * they are modified, they must specify that requirement in * their description clause. * * ipv6InterfaceTableLastChange -- read-only * The value of sysUpTime on the most recent occasion at which * a row in the ipv6InterfaceTable was added or deleted or when * an ipv6InterfaceReasmMaxSize, ipv6InterfaceIdentifier, * ipv6InterfaceEnableStatus, ipv6InterfaceReachableTime, * ipv6InterfaceRetransmitTime, or ipv6InterfaceForwarding * object was modified. * * If new objects are added to the ipv6InterfaceTable that * require the ipv6InterfaceTableLastChange to be updated when * they are modified, they must specify that requirement in * their description clause. * * ipAddressSpinLock -- read-write * An advisory lock used to allow cooperating SNMP managers to * coordinate their use of the set operation in creating or * modifying rows within this table. * * In order to use this lock to coordinate the use of set * operations, managers should first retrieve * ipAddressTableSpinLock. They should then determine the * appropriate row to create or modify. Finally, they should * issue the appropriate set command, including the retrieved * value of ipAddressSpinLock. If another manager has altered * the table in the meantime, then the value of * ipAddressSpinLock will have changed, and the creation will * fail as it will be specifying an incorrect value for * ipAddressSpinLock. It is suggested, but not required, that * the ipAddressSpinLock be the first var bind for each set of * objects representing a 'row' in a PDU. * * ipv6RouterAdvertSpinLock -- read-write * An advisory lock used to allow cooperating SNMP managers to * coordinate their use of the set operation in creating or * modifying rows within this table. * * In order to use this lock to coordinate the use of set * operations, managers should first retrieve * ipv6RouterAdvertSpinLock. They should then determine the * appropriate row to create or modify. Finally, they should * issue the appropriate set command including the retrieved * value of ipv6RouterAdvertSpinLock. If another manager has * altered the table in the meantime, then the value of * ipv6RouterAdvertSpinLock will have changed and the creation * will fail as it will be specifying an incorrect value for * ipv6RouterAdvertSpinLock. It is suggested, but not * required, that the ipv6RouterAdvertSpinLock be the first var * bind for each set of objects representing a 'row' in a PDU. */ static int ip_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, ip_data_t *data) { switch(lastmatch) { #ifdef IPCOM_USE_INET case LEAF_ipForwarding: /* Values: * forwarding(1) = VAL_ipForwarding_forwarding * notForwarding(2) = VAL_ipForwarding_notForwarding */ getproc_got_int32(pktp, vbp, data->ipv4Group.ipForwarding); break; case LEAF_ipDefaultTTL: getproc_got_int32(pktp, vbp, data->ipv4Group.ipDefaultTTL); break; case LEAF_ipReasmTimeout: getproc_got_int32(pktp, vbp, data->ipv4Group.ipReasmTimeout); break; case LEAF_ipv4InterfaceTableLastChange: getproc_got_uint32(pktp, vbp, data->ipv4InterfaceTableLastChange, VT_TIMETICKS); break; #endif #ifdef IPCOM_USE_INET6 case LEAF_ipv6IpForwarding: /* Values: * forwarding(1) = VAL_ipv6IpForwarding_forwarding * notForwarding(2) = VAL_ipv6IpForwarding_notForwarding */ getproc_got_int32(pktp, vbp, data->ipv6Group.ipv6IpForwarding); break; case LEAF_ipv6IpDefaultHopLimit: getproc_got_int32(pktp, vbp, data->ipv6Group.ipv6IpDefaultHopLimit); break; case LEAF_ipv6InterfaceTableLastChange: getproc_got_uint32(pktp, vbp, data->ipv6InterfaceTableLastChange, VT_TIMETICKS); break; case LEAF_ipv6RouterAdvertSpinLock: getproc_got_int32(pktp, vbp, data->ipv6RouterAdvertSpinLock); break; #endif case LEAF_ipAddressSpinLock: getproc_got_int32(pktp, vbp, data->ipAddressSpinLock); break; default: return GEN_ERR; } return NO_ERROR; } static int ip_lookup (ip_data_t * dataP) { int retVal = 0; #ifdef IPCOM_USE_INET retVal |= ipcom_mib2_get_ip_general_group (&(dataP->ipv4Group)); retVal |= ipcom_mib2_get_ipv4InterfaceTableLastChange (&(dataP->ipv4InterfaceTableLastChange)); #endif /* IPCOM_USE_INET */ #ifdef IPCOM_USE_INET6 retVal |= ipcom_mib2_get_ipv6_general_group (&(dataP->ipv6Group)); retVal |= ipcom_mib2_get_ipv6InterfaceTableLastChange (&(dataP->ipv6InterfaceTableLastChange)); retVal |= ipcom_mib2_get_ipv6RouterAdvertSpinLock (&(dataP->ipv6RouterAdvertSpinLock)); #endif /* IPCOM_USE_INET6 */ retVal |= ipcom_mib2_get_ipAddressSpinLock (&(dataP->ipAddressSpinLock)); return (retVal); } static boolean_t ip_instanceExists (OIDC_T lastmatch) { switch (lastmatch) { #ifdef IPCOM_USE_INET case LEAF_ipForwarding: case LEAF_ipDefaultTTL: case LEAF_ipReasmTimeout: case LEAF_ipv4InterfaceTableLastChange: #endif #ifdef IPCOM_USE_INET6 case LEAF_ipv6IpForwarding: case LEAF_ipv6IpDefaultHopLimit: case LEAF_ipv6InterfaceTableLastChange: case LEAF_ipv6RouterAdvertSpinLock: #endif case LEAF_ipAddressSpinLock: return TRUE; default: return FALSE; } } void ip_get (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { ip_data_t data; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); /* check that the instance is exactly .0 */ if (!((tcount == 1) && (*tlist == 0))) { for ( ; vbp; vbp = vbp->vb_link) getproc_nosuchins(pktp, vbp); } else if (ip_lookup(&data) != 0) { for ( ; vbp; vbp = vbp->vb_link) getproc_error(pktp, vbp, GEN_ERR); } else { /* retrieve all the values from the same data structure */ for ( ; vbp; vbp = vbp->vb_link) { if ((error = ip_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, &data)) != NO_ERROR) getproc_error(pktp, vbp, error); } } } void ip_next (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { ip_data_t data; OIDC_T instance = 0; /* the only time there's a next for a scalar is if we're given * no instance at all. */ if (tcount != 0) nextproc_no_next (pktp, vbp); else if (ip_lookup(&data)) getproc_error (pktp, vbp, GEN_ERR); else { /* find all the varbinds in this group and retrieve their * values from the same data structure */ for (group_by_getproc_and_instance (pktp, vbp, tcount, tlist); vbp; vbp = vbp->vb_link) { if (ip_instanceExists (vbp->vb_ml.ml_last_match)) { nextproc_next_instance (pktp, vbp, 1, &instance); (void)ip_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, &data); } else nextproc_no_next (pktp, vbp); } } } void ip_test (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { VB_T *group_vbp; /* Only scalar variables here, check for .0 */ if (!((tcount == 1) && (*tlist == 0))) { testproc_error (pktp, vbp, NO_SUCH_NAME); return; } /* find all the varbinds that share the same getproc and instance and * group them together. */ group_by_getproc_and_instance(pktp, vbp, tcount, tlist); /* now check each varbind */ for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { #ifdef IPCOM_USE_INET case LEAF_ipForwarding: switch (VB_GET_INT32 (group_vbp)) { case VAL_ipForwarding_forwarding: case VAL_ipForwarding_notForwarding: break; default: testproc_error (pktp, group_vbp, WRONG_VALUE); continue; } testproc_good (pktp, group_vbp); break; case LEAF_ipDefaultTTL: { bits32_t value = VB_GET_INT32 (group_vbp); if (!((value >= MIN_ipDefaultTTL) && (value <= MAX_ipDefaultTTL))) { testproc_error (pktp, group_vbp, WRONG_VALUE); break; } } testproc_good (pktp, group_vbp); break; #endif #ifdef IPCOM_USE_INET6 case LEAF_ipv6IpForwarding: switch (VB_GET_INT32 (group_vbp)) { case VAL_ipv6IpForwarding_forwarding: case VAL_ipv6IpForwarding_notForwarding: break; default: testproc_error (pktp, group_vbp, WRONG_VALUE); continue; } testproc_good (pktp, group_vbp); break; case LEAF_ipv6IpDefaultHopLimit: { bits32_t value = VB_GET_INT32 (group_vbp); if (!((value >= MIN_ipv6IpDefaultHopLimit) && (value <= MAX_ipv6IpDefaultHopLimit))) { testproc_error (pktp, group_vbp, WRONG_VALUE); break; } } testproc_good (pktp, group_vbp); break; case LEAF_ipv6RouterAdvertSpinLock: { Ipcom_mib2_TestAndIncr spinLockValue; bits32_t value = VB_GET_INT32 (group_vbp); int error = NO_ERROR; if (ipcom_mib2_get_ipv6RouterAdvertSpinLock (&spinLockValue)) error = GEN_ERR; else if (spinLockValue != value) error = INCONSISTENT_VALUE; else if (!((value >= MIN_ipv6RouterAdvertSpinLock) && (value <= MAX_ipv6RouterAdvertSpinLock))) error = WRONG_VALUE; if (error == NO_ERROR) testproc_good (pktp, group_vbp); else { testproc_error (pktp, group_vbp, error); return; } } break; #endif case LEAF_ipAddressSpinLock: { Ipcom_mib2_TestAndIncr spinLockValue; bits32_t value = VB_GET_INT32 (group_vbp); int error = NO_ERROR; if (ipcom_mib2_get_ipAddressSpinLock (&spinLockValue)) error = GEN_ERR; else if (spinLockValue != value) error = INCONSISTENT_VALUE; /* The macro value may be changed to non-zero. */ /* coverity[unsigned_compare] */ else if (!((value >= MIN_ipAddressSpinLock) && (value <= MAX_ipAddressSpinLock))) error = WRONG_VALUE; if (error == NO_ERROR) testproc_good (pktp, group_vbp); else { testproc_error (pktp, group_vbp, error); return; } } break; default: testproc_error (pktp, group_vbp, GEN_ERR); return; } } } void ip_set (OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp) { for ( ; vbp; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { #ifdef IPCOM_USE_INET case LEAF_ipForwarding: if (ipcom_mib2_set_ipForwarding (VB_GET_INT32 (vbp)) == 0) setproc_good (pktp, vbp); else { setproc_error (pktp, vbp, COMMIT_FAILED); return; } break; case LEAF_ipDefaultTTL: if (ipcom_mib2_set_ipDefaultTTL (VB_GET_INT32 (vbp)) == 0) setproc_good (pktp, vbp); else { setproc_error (pktp, vbp, COMMIT_FAILED); return; } break; #endif #ifdef IPCOM_USE_INET6 case LEAF_ipv6IpForwarding: if (ipcom_mib2_set_ipv6IpForwarding (VB_GET_INT32 (vbp)) == 0) setproc_good (pktp, vbp); else { setproc_error (pktp, vbp, COMMIT_FAILED); return; } break; case LEAF_ipv6IpDefaultHopLimit: if (ipcom_mib2_set_ipv6IpDefaultHopLimit (VB_GET_INT32 (vbp)) == 0) setproc_good (pktp, vbp); else { setproc_error (pktp, vbp, COMMIT_FAILED); return; } break; case LEAF_ipv6RouterAdvertSpinLock: { bits32_t value = VB_GET_INT32 (vbp); /* Increment so the next caller knows things have changed. */ value = ((value + 1) % (MAX_ipv6RouterAdvertSpinLock)) + MIN_ipv6RouterAdvertSpinLock; if (ipcom_mib2_set_ipv6RouterAdvertSpinLock (value) == 0) setproc_good (pktp, vbp); else { setproc_error (pktp, vbp, COMMIT_FAILED); return; } } break; #endif case LEAF_ipAddressSpinLock: { bits32_t value = VB_GET_INT32 (vbp); /* Increment so the next caller knows things have changed. */ value = ((value + 1) % (MAX_ipAddressSpinLock)) + MIN_ipAddressSpinLock; if (ipcom_mib2_set_ipAddressSpinLock (value) == 0) setproc_good (pktp, vbp); else { setproc_error (pktp, vbp, COMMIT_FAILED); return; } } break; default: setproc_error (pktp, vbp, COMMIT_FAILED); return; } } }