368731: FEAT: RHEL 5.3 support MIB for SCTP Author: Jan Safranek <jsafrane@redhat.com> Accepted upstream, SVN rev. 17153 Add SCTP-MIB implementation. Requires kernel with sctp stats support (bug #435110) Index: mibs/Makefile.in =================================================================== --- mibs/Makefile.in (revision 17152) +++ mibs/Makefile.in (revision 17153) @@ -39,7 +39,8 @@ IPV6-UDP-MIB.txt \ DISMAN-EVENT-MIB.txt DISMAN-SCRIPT-MIB.txt DISMAN-SCHEDULE-MIB.txt \ NOTIFICATION-LOG-MIB.txt SNMP-USM-AES-MIB.txt \ - SNMP-USM-DH-OBJECTS-MIB.txt + SNMP-USM-DH-OBJECTS-MIB.txt \ + SCTP-MIB.txt NETSNMPMIBS = NET-SNMP-TC.txt NET-SNMP-MIB.txt NET-SNMP-AGENT-MIB.txt \ NET-SNMP-EXAMPLES-MIB.txt NET-SNMP-EXTEND-MIB.txt Index: mibs/Makefile.mib =================================================================== --- mibs/Makefile.mib (revision 17152) +++ mibs/Makefile.mib (revision 17153) @@ -25,7 +25,8 @@ HOST-RESOURCES-MIB.txt HOST-RESOURCES-TYPES.txt \ NETWORK-SERVICES-MIB.txt MTA-MIB.txt \ RMON-MIB.txt \ - RFC1155-SMI.txt RFC1213-MIB.txt + RFC1155-SMI.txt RFC1213-MIB.txt \ + SCTP-MIB.txt MIBDEPS = Makefile.mib mibfetch smistrip @@ -193,6 +194,9 @@ RFC1213-MIB.txt: $(MIBDEPS) ./mibfetch $(RFCHOST) $(RFCDIR) 1213 +SCTP-MIB.txt: $(MIBDEPS) + ./mibfetch $(RFCHOST) $(RFCDIR) 3873 + ianamibs: ianalist [ -d $(ALLDIR) ] || mkdir $(ALLDIR) cat ianalist | while read file mibs; \ Index: mibs/SCTP-MIB.txt =================================================================== --- mibs/SCTP-MIB.txt (revision 0) +++ mibs/SCTP-MIB.txt (revision 17153) @@ -0,0 +1,1342 @@ +SCTP-MIB DEFINITIONS ::= BEGIN + +IMPORTS + MODULE-IDENTITY, OBJECT-TYPE, Integer32, Unsigned32, Gauge32, + Counter32, Counter64, mib-2 + FROM SNMPv2-SMI -- [RFC2578] + TimeStamp, TruthValue + FROM SNMPv2-TC -- [RFC2579] + MODULE-COMPLIANCE, OBJECT-GROUP + FROM SNMPv2-CONF -- [RFC2580] + InetAddressType, InetAddress, InetPortNumber + FROM INET-ADDRESS-MIB; -- [RFC3291] + +sctpMIB MODULE-IDENTITY + LAST-UPDATED "200409020000Z" -- 2nd September 2004 + ORGANIZATION "IETF SIGTRAN Working Group" + CONTACT-INFO + " + WG EMail: sigtran@ietf.org + + Web Page: + http://www.ietf.org/html.charters/sigtran-charter.html + + Chair: Lyndon Ong + Ciena Corporation + 0480 Ridgeview Drive + Cupertino, CA 95014 + USA + Tel: + Email: lyong@ciena.com + + Editors: Maria-Carmen Belinchon + R&D Department + Ericsson Espana S. A. + Via de los Poblados, 13 + 28033 Madrid + Spain + Tel: +34 91 339 3535 + Email: Maria.C.Belinchon@ericsson.com + + Jose-Javier Pastor-Balbas + R&D Department + Ericsson Espana S. A. + Via de los Poblados, 13 + 28033 Madrid + Spain + Tel: +34 91 339 1397 + Email: J.Javier.Pastor@ericsson.com + " + DESCRIPTION + "The MIB module for managing SCTP implementations. + + Copyright (C) The Internet Society (2004). This version of + this MIB module is part of RFC 3873; see the RFC itself for + full legal notices. " + + REVISION "200409020000Z" -- 2nd September 2004 + DESCRIPTION " Initial version, published as RFC 3873" + ::= { mib-2 104 } + +-- the SCTP base variables group + +sctpObjects OBJECT IDENTIFIER ::= { sctpMIB 1 } + +sctpStats OBJECT IDENTIFIER ::= { sctpObjects 1 } +sctpParams OBJECT IDENTIFIER ::= { sctpObjects 2 } + +-- STATISTICS +-- ********** + +-- STATE-RELATED STATISTICS + +sctpCurrEstab OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of associations for which the current state is + either ESTABLISHED, SHUTDOWN-RECEIVED or SHUTDOWN-PENDING." + REFERENCE + "Section 4 in RFC2960 covers the SCTP Association state + diagram." + ::= { sctpStats 1 } + +sctpActiveEstabs OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of times that associations have made a direct + transition to the ESTABLISHED state from the COOKIE-ECHOED + state: COOKIE-ECHOED -> ESTABLISHED. The upper layer initiated + the association attempt." + REFERENCE + "Section 4 in RFC2960 covers the SCTP Association state + diagram." + ::= { sctpStats 2 } + +sctpPassiveEstabs OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of times that associations have made a direct + transition to the ESTABLISHED state from the CLOSED state: + CLOSED -> ESTABLISHED. The remote endpoint initiated the + association attempt." + REFERENCE + "Section 4 in RFC2960 covers the SCTP Association state + diagram." + ::= { sctpStats 3 } + +sctpAborteds OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of times that associations have made a direct + transition to the CLOSED state from any state using the + primitive 'ABORT': AnyState --Abort--> CLOSED. Ungraceful + termination of the association." + REFERENCE + "Section 4 in RFC2960 covers the SCTP Association state + diagram." + ::= { sctpStats 4 } + +sctpShutdowns OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of times that associations have made a direct + transition to the CLOSED state from either the SHUTDOWN-SENT + state or the SHUTDOWN-ACK-SENT state. Graceful termination of + the association." + REFERENCE + "Section 4 in RFC2960 covers the SCTP Association state + diagram." + ::= { sctpStats 5 } + +-- OTHER LAYER STATISTICS + +sctpOutOfBlues OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of out of the blue packets received by the host. + An out of the blue packet is an SCTP packet correctly formed, + including the proper checksum, but for which the receiver was + unable to identify an appropriate association." + REFERENCE + "Section 8.4 in RFC2960 deals with the Out-Of-The-Blue + (OOTB) packet definition and procedures." + ::= { sctpStats 6 } + +sctpChecksumErrors OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP packets received with an invalid + checksum." + REFERENCE + "The checksum is located at the end of the SCTP packet as per + Section 3.1 in RFC2960. RFC3309 updates SCTP to use a 32 bit + CRC checksum." +::= { sctpStats 7 } + +sctpOutCtrlChunks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP control chunks sent (retransmissions are + not included). Control chunks are those chunks different from + DATA." + REFERENCE + "Sections 1.3.5 and 1.4 in RFC2960 refer to control chunk as + those chunks different from those that contain user + information, i.e., DATA chunks." + ::= { sctpStats 8 } + +sctpOutOrderChunks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP ordered data chunks sent (retransmissions + are not included)." + REFERENCE + "Section 3.3.1 in RFC2960 defines the ordered data chunk." + ::= { sctpStats 9 } + +sctpOutUnorderChunks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP unordered chunks (data chunks in which the + U bit is set to 1) sent (retransmissions are not included)." + REFERENCE + "Section 3.3.1 in RFC2960 defines the unordered data chunk." + ::= { sctpStats 10 } + +sctpInCtrlChunks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP control chunks received (no duplicate + chunks included)." + REFERENCE + "Sections 1.3.5 and 1.4 in RFC2960 refer to control chunk as + those chunks different from those that contain user + information, i.e., DATA chunks." + ::= { sctpStats 11 } + +sctpInOrderChunks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP ordered data chunks received (no duplicate + chunks included)." + REFERENCE + "Section 3.3.1 in RFC2960 defines the ordered data chunk." + ::= { sctpStats 12 } + +sctpInUnorderChunks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP unordered chunks (data chunks in which the + U bit is set to 1) received (no duplicate chunks included)." + REFERENCE + "Section 3.3.1 in RFC2960 defines the unordered data chunk." + ::= { sctpStats 13 } + +sctpFragUsrMsgs OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of user messages that have to be fragmented + because of the MTU." + ::= { sctpStats 14 } + +sctpReasmUsrMsgs OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of user messages reassembled, after conversion + into DATA chunks." + REFERENCE + "Section 6.9 in RFC2960 includes a description of the + reassembly process." + ::= { sctpStats 15 } + +sctpOutSCTPPacks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP packets sent. Retransmitted DATA chunks + are included." + ::= { sctpStats 16 } + +sctpInSCTPPacks OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of SCTP packets received. Duplicates are + included." + ::= { sctpStats 17 } + +sctpDiscontinuityTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime on the most recent occasion at which + any one or more of this general statistics counters suffered a + discontinuity. The relevant counters are the specific + instances associated with this interface of any Counter32 or + Counter64 object contained in the SCTP layer statistics + (defined below sctpStats branch). If no such discontinuities + have occurred since the last re-initialization of the local + management subsystem, then this object contains a zero value." + REFERENCE + "The inclusion of this object is recommended by RFC2578." + ::= { sctpStats 18 } + +-- PROTOCOL GENERAL VARIABLES +-- ************************** + +sctpRtoAlgorithm OBJECT-TYPE + SYNTAX INTEGER { + other(1), -- Other new one. Future use + vanj(2) -- Van Jacobson's algorithm + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The algorithm used to determine the timeout value (T3-rtx) + used for re-transmitting unacknowledged chunks." + REFERENCE + "Section 6.3.1 and 6.3.2 in RFC2960 cover the RTO calculation + and retransmission timer rules." + DEFVAL {vanj} -- vanj(2) + ::= { sctpParams 1 } + +sctpRtoMin OBJECT-TYPE + SYNTAX Unsigned32 + UNITS "milliseconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The minimum value permitted by a SCTP implementation for the + retransmission timeout value, measured in milliseconds. More + refined semantics for objects of this type depend upon the + algorithm used to determine the retransmission timeout value. + + A retransmission time value of zero means immediate + retransmission. + + The value of this object has to be lower than or equal to + stcpRtoMax's value." + DEFVAL {1000} -- milliseconds + ::= { sctpParams 2 } + +sctpRtoMax OBJECT-TYPE + SYNTAX Unsigned32 + UNITS "milliseconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The maximum value permitted by a SCTP implementation for the + retransmission timeout value, measured in milliseconds. More + refined semantics for objects of this type depend upon the + algorithm used to determine the retransmission timeout value. + + A retransmission time value of zero means immediate re- + transmission. + + The value of this object has to be greater than or equal to + stcpRtoMin's value." + DEFVAL {60000} -- milliseconds + ::= { sctpParams 3 } + +sctpRtoInitial OBJECT-TYPE + SYNTAX Unsigned32 + UNITS "milliseconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The initial value for the retransmission timer. + + A retransmission time value of zero means immediate re- + transmission." + DEFVAL {3000} -- milliseconds + ::= { sctpParams 4 } + +sctpMaxAssocs OBJECT-TYPE + SYNTAX Integer32 (-1 | 0..2147483647) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The limit on the total number of associations the entity can + support. In entities where the maximum number of associations + is dynamic, this object should contain the value -1." + ::= { sctpParams 5 } + +sctpValCookieLife OBJECT-TYPE + SYNTAX Unsigned32 + UNITS "milliseconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Valid cookie life in the 4-way start-up handshake procedure." + REFERENCE + "Section 5.1.3 in RFC2960 explains the cookie generation + process. Recommended value is per section 14 in RFC2960." + DEFVAL {60000} -- milliseconds + ::= { sctpParams 6 } + +sctpMaxInitRetr OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The maximum number of retransmissions at the start-up phase + (INIT and COOKIE ECHO chunks). " + REFERENCE + "Section 5.1.4, 5.1.6 in RFC2960 refers to Max.Init.Retransmit + parameter. Recommended value is per section 14 in RFC2960." + DEFVAL {8} -- number of attempts + ::= { sctpParams 7 } + +-- TABLES +-- ****** + +-- the SCTP Association TABLE + +-- The SCTP association table contains information about each +-- association in which the local endpoint is involved. + +sctpAssocTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpAssocEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "A table containing SCTP association-specific information." + ::= { sctpObjects 3 } + +sctpAssocEntry OBJECT-TYPE + SYNTAX SctpAssocEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "General common variables and statistics for the whole + association." + INDEX { sctpAssocId } + ::= { sctpAssocTable 1 } + +SctpAssocEntry ::= SEQUENCE { + sctpAssocId Unsigned32, + sctpAssocRemHostName OCTET STRING, + sctpAssocLocalPort InetPortNumber, + sctpAssocRemPort InetPortNumber, + sctpAssocRemPrimAddrType InetAddressType, + sctpAssocRemPrimAddr InetAddress, + sctpAssocHeartBeatInterval Unsigned32, + sctpAssocState INTEGER, + sctpAssocInStreams Unsigned32, + sctpAssocOutStreams Unsigned32, + sctpAssocMaxRetr Unsigned32, + sctpAssocPrimProcess Unsigned32, + sctpAssocT1expireds Counter32, -- Statistic + sctpAssocT2expireds Counter32, -- Statistic + sctpAssocRtxChunks Counter32, -- Statistic + sctpAssocStartTime TimeStamp, + sctpAssocDiscontinuityTime TimeStamp + } + +sctpAssocId OBJECT-TYPE + SYNTAX Unsigned32 (1..4294967295) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Association Identification. Value identifying the + association. " + ::= { sctpAssocEntry 1 } + +sctpAssocRemHostName OBJECT-TYPE + SYNTAX OCTET STRING (SIZE(0..255)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The peer's DNS name. This object needs to have the same + format as the encoding in the DNS protocol. This implies that + the domain name can be up to 255 octets long, each octet being + 0<=x<=255 as value with US-ASCII A-Z having a case insensitive + matching. + + If no DNS domain name was received from the peer at init time + (embedded in the INIT or INIT-ACK chunk), this object is + meaningless. In such cases the object MUST contain a zero- + length string value. Otherwise, it contains the remote host + name received at init time." + ::= { sctpAssocEntry 2 } + +sctpAssocLocalPort OBJECT-TYPE + SYNTAX InetPortNumber (1..65535) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The local SCTP port number used for this association." + ::= { sctpAssocEntry 3 } + +sctpAssocRemPort OBJECT-TYPE + SYNTAX InetPortNumber (1..65535) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The remote SCTP port number used for this association." + ::= { sctpAssocEntry 4 } + +sctpAssocRemPrimAddrType OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The internet type of primary remote IP address. " + ::= { sctpAssocEntry 5 } + +sctpAssocRemPrimAddr OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The primary remote IP address. The type of this address is + determined by the value of sctpAssocRemPrimAddrType. + + The client side will know this value after INIT_ACK message + reception, the server side will know this value when sending + INIT_ACK message. However, values will be filled in at + established(4) state." + ::= { sctpAssocEntry 6 } + +sctpAssocHeartBeatInterval OBJECT-TYPE + SYNTAX Unsigned32 + UNITS "milliseconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The current heartbeat interval.. + + Zero value means no HeartBeat, even when the concerned + sctpAssocRemAddrHBFlag object is true." + DEFVAL {30000} -- milliseconds + ::= { sctpAssocEntry 7 } + +sctpAssocState OBJECT-TYPE + SYNTAX INTEGER { + closed(1), + cookieWait(2), + cookieEchoed(3), + established(4), + shutdownPending(5), + shutdownSent(6), + shutdownReceived(7), + shutdownAckSent(8), + deleteTCB(9) + } + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The state of this SCTP association. + + As in TCP, deleteTCB(9) is the only value that may be set by a + management station. If any other value is received, then the + agent must return a wrongValue error. + + If a management station sets this object to the value + deleteTCB(9), then this has the effect of deleting the TCB (as + defined in SCTP) of the corresponding association on the + managed node, resulting in immediate termination of the + association. + + As an implementation-specific option, an ABORT chunk may be + sent from the managed node to the other SCTP endpoint as a + result of setting the deleteTCB(9) value. The ABORT chunk + implies an ungraceful association shutdown." + REFERENCE + "Section 4 in RFC2960 covers the SCTP Association state + diagram." + ::= { sctpAssocEntry 8 } + +sctpAssocInStreams OBJECT-TYPE + SYNTAX Unsigned32 (1..65535) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Inbound Streams according to the negotiation at association + start up." + REFERENCE + "Section 1.3 in RFC2960 includes a definition of stream. + Section 5.1.1 in RFC2960 covers the streams negotiation + process." + ::= { sctpAssocEntry 9 } + +sctpAssocOutStreams OBJECT-TYPE + SYNTAX Unsigned32 (1..65535) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Outbound Streams according to the negotiation at association + start up. " + REFERENCE + "Section 1.3 in RFC2960 includes a definition of stream. + Section 5.1.1 in RFC2960 covers the streams negotiation + process." + ::= { sctpAssocEntry 10 } + +sctpAssocMaxRetr OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The maximum number of data retransmissions in the association + context. This value is specific for each association and the + upper layer can change it by calling the appropriate + primitives. This value has to be smaller than the addition of + all the maximum number for all the paths + (sctpAssocRemAddrMaxPathRtx). + + A value of zero value means no retransmissions." + DEFVAL {10} -- number of attempts + ::= { sctpAssocEntry 11 } + +sctpAssocPrimProcess OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This object identifies the system level process which holds + primary responsibility for the SCTP association. + Wherever possible, this should be the system's native unique + identification number. The special value 0 can be used to + indicate that no primary process is known. + + Note that the value of this object can be used as a pointer + into the swRunTable of the HOST-RESOURCES-MIB(if the value is + smaller than 2147483647) or into the sysApplElmtRunTable of + the SYSAPPL-MIB." + ::= { sctpAssocEntry 12 } + +-- Association Statistics + +sctpAssocT1expireds OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The T1 timer determines how long to wait for an + acknowledgement after sending an INIT or COOKIE-ECHO chunk. + This object reflects the number of times the T1 timer expires + without having received the acknowledgement. + + 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 sctpAssocDiscontinuityTime." + REFERENCE + "Section 5 in RFC2960." + ::= { sctpAssocEntry 13 } + +sctpAssocT2expireds OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The T2 timer determines how long to wait for an + acknowledgement after sending a SHUTDOWN or SHUTDOWN-ACK + chunk. This object reflects the number of times that T2- timer + expired. + + 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 sctpAssocDiscontinuityTime." +REFERENCE + "Section 9.2 in RFC2960." + ::= { sctpAssocEntry 14 } + +sctpAssocRtxChunks OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "When T3-rtx expires, the DATA chunks that triggered the T3 + timer will be re-sent according with the retransmissions + rules. Every DATA chunk that was included in the SCTP packet + that triggered the T3-rtx timer must be added to the value of + this counter. + + 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 sctpAssocDiscontinuityTime." + REFERENCE + "Section 6 in RFC2960 covers the retransmission process and + rules." + ::= { sctpAssocEntry 15 } + +sctpAssocStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time that the association + represented by this row enters the ESTABLISHED state, i.e., + the sctpAssocState object is set to established(4). The + value of this object will be zero: + - before the association enters the established(4) + state, or + + - if the established(4) state was entered prior to + the last re-initialization of the local network management + subsystem." + ::= { sctpAssocEntry 16 } + +sctpAssocDiscontinuityTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime on the most recent occasion at which + any one or more of this SCTP association counters suffered a + discontinuity. The relevant counters are the specific + instances associated with this interface of any Counter32 or + Counter64 object contained in the sctpAssocTable or + sctpLocalAddrTable or sctpRemAddrTable. If no such + discontinuities have occurred since the last re-initialization + of the local management subsystem, then this object contains a + zero value. " + REFERENCE + "The inclusion of this object is recommended by RFC2578." + ::= { sctpAssocEntry 17 } + +-- Expanded tables: Including Multi-home feature + +-- Local Address TABLE +-- ******************* + +sctpAssocLocalAddrTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpAssocLocalAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Expanded table of sctpAssocTable based on the AssocId index. + This table shows data related to each local IP address which + is used by this association." + ::= { sctpObjects 4 } + +sctpAssocLocalAddrEntry OBJECT-TYPE + SYNTAX SctpAssocLocalAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Local information about the available addresses. There will + be an entry for every local IP address defined for this + + association. + Implementors need to be aware that if the size of + sctpAssocLocalAddr exceeds 114 octets then OIDs of column + instances in this table will have more than 128 sub- + identifiers and cannot be accessed using SNMPv1, SNMPv2c, or + SNMPv3." + INDEX { sctpAssocId, -- shared index + sctpAssocLocalAddrType, + sctpAssocLocalAddr } + ::= { sctpAssocLocalAddrTable 1 } + +SctpAssocLocalAddrEntry ::= SEQUENCE { + sctpAssocLocalAddrType InetAddressType, + sctpAssocLocalAddr InetAddress, + sctpAssocLocalAddrStartTime TimeStamp + } + +sctpAssocLocalAddrType OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Internet type of local IP address used for this association." + ::= { sctpAssocLocalAddrEntry 1 } + +sctpAssocLocalAddr OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The value of a local IP address available for this + association. The type of this address is determined by the + value of sctpAssocLocalAddrType." + ::= { sctpAssocLocalAddrEntry 2 } + +sctpAssocLocalAddrStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time that this row was + created." + ::= { sctpAssocLocalAddrEntry 3 } + +-- Remote Addresses TABLE +-- ********************** + +sctpAssocRemAddrTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpAssocRemAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Expanded table of sctpAssocTable based on the AssocId index. + This table shows data related to each remote peer IP address + which is used by this association." + ::= { sctpObjects 5 } + +sctpAssocRemAddrEntry OBJECT-TYPE + SYNTAX SctpAssocRemAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Information about the most important variables for every + remote IP address. There will be an entry for every remote IP + address defined for this association. + + Implementors need to be aware that if the size of + sctpAssocRemAddr exceeds 114 octets then OIDs of column + instances in this table will have more than 128 sub- + identifiers and cannot be accessed using SNMPv1, SNMPv2c, or + SNMPv3." + INDEX { sctpAssocId, -- shared index + sctpAssocRemAddrType, + sctpAssocRemAddr } + ::= { sctpAssocRemAddrTable 1 } + +SctpAssocRemAddrEntry ::= SEQUENCE { + sctpAssocRemAddrType InetAddressType, + sctpAssocRemAddr InetAddress, + sctpAssocRemAddrActive TruthValue, + sctpAssocRemAddrHBActive TruthValue, + sctpAssocRemAddrRTO Unsigned32, + sctpAssocRemAddrMaxPathRtx Unsigned32, + sctpAssocRemAddrRtx Counter32, -- Statistic + sctpAssocRemAddrStartTime TimeStamp + } + +sctpAssocRemAddrType OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Internet type of a remote IP address available for this + association." + ::= { sctpAssocRemAddrEntry 1 } + +sctpAssocRemAddr OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The value of a remote IP address available for this + association. The type of this address is determined by the + value of sctpAssocLocalAddrType." + ::= { sctpAssocRemAddrEntry 2 } + +sctpAssocRemAddrActive OBJECT-TYPE + SYNTAX TruthValue + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This object gives information about the reachability of this + specific remote IP address. + + When the object is set to 'true' (1), the remote IP address is + understood as Active. Active means that the threshold of no + answers received from this IP address has not been reached. + + When the object is set to 'false' (2), the remote IP address + is understood as Inactive. Inactive means that either no + heartbeat or any other message was received from this address, + reaching the threshold defined by the protocol." + REFERENCE + "The remote transport states are defined as Active and + Inactive in the SCTP, RFC2960." + ::= { sctpAssocRemAddrEntry 3 } + +sctpAssocRemAddrHBActive OBJECT-TYPE + SYNTAX TruthValue + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This object indicates whether the optional Heartbeat check + associated to one destination transport address is activated + or not (value equal to true or false, respectively). " + ::= { sctpAssocRemAddrEntry 4 } + +sctpAssocRemAddrRTO OBJECT-TYPE -- T3-rtx- Timer + SYNTAX Unsigned32 + UNITS "milliseconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The current Retransmission Timeout. T3-rtx timer as defined + in the protocol SCTP." + REFERENCE + "Section 6.3 in RFC2960 deals with the Retransmission Timer + Management." + ::= { sctpAssocRemAddrEntry 5 } + +sctpAssocRemAddrMaxPathRtx OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Maximum number of DATA chunks retransmissions allowed to a + remote IP address before it is considered inactive, as defined + in RFC2960." + REFERENCE + "Section 8.2, 8.3 and 14 in RFC2960." + DEFVAL {5} -- number of attempts + ::= { sctpAssocRemAddrEntry 6 } + +-- Remote Address Statistic + +sctpAssocRemAddrRtx OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Number of DATA chunks retransmissions to this specific IP + address. When T3-rtx expires, the DATA chunk that triggered + the T3 timer will be re-sent according to the retransmissions + rules. Every DATA chunk that is included in a SCTP packet and + was transmitted to this specific IP address before, will be + included in this counter. + + 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 sctpAssocDiscontinuityTime." + ::= { sctpAssocRemAddrEntry 7 } + +sctpAssocRemAddrStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time that this row was + created." + ::= { sctpAssocRemAddrEntry 8 } + +-- ASSOCIATION INVERSE TABLE +-- ************************* + +-- BY LOCAL PORT + +sctpLookupLocalPortTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpLookupLocalPortEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "With the use of this table, a list of associations which are + + using the specified local port can be retrieved." + ::= { sctpObjects 6 } + +sctpLookupLocalPortEntry OBJECT-TYPE + SYNTAX SctpLookupLocalPortEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table is indexed by local port and association ID. + Specifying a local port, we would get a list of the + associations whose local port is the one specified." + INDEX { sctpAssocLocalPort, + sctpAssocId } + ::= { sctpLookupLocalPortTable 1 } + +SctpLookupLocalPortEntry::= SEQUENCE { + sctpLookupLocalPortStartTime TimeStamp + } + +sctpLookupLocalPortStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time that this row was created. + + As the table will be created after the sctpAssocTable + creation, this value could be equal to the sctpAssocStartTime + object from the main table." + ::= { sctpLookupLocalPortEntry 1 } + +-- BY REMOTE PORT + +sctpLookupRemPortTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpLookupRemPortEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "With the use of this table, a list of associations which are + using the specified remote port can be got" + ::= { sctpObjects 7 } + +sctpLookupRemPortEntry OBJECT-TYPE + SYNTAX SctpLookupRemPortEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table is indexed by remote port and association ID. + Specifying a remote port we would get a list of the + associations whose local port is the one specified " + INDEX { sctpAssocRemPort, + sctpAssocId } + ::= { sctpLookupRemPortTable 1 } + +SctpLookupRemPortEntry::= SEQUENCE { + sctpLookupRemPortStartTime TimeStamp + } + +sctpLookupRemPortStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time that this row was created. + + As the table will be created after the sctpAssocTable + creation, this value could be equal to the sctpAssocStartTime + object from the main table." + ::= { sctpLookupRemPortEntry 1 } + +-- BY REMOTE HOST NAME + +sctpLookupRemHostNameTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpLookupRemHostNameEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "With the use of this table, a list of associations with that + particular host can be retrieved." + ::= { sctpObjects 8 } + +sctpLookupRemHostNameEntry OBJECT-TYPE + SYNTAX SctpLookupRemHostNameEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table is indexed by remote host name and association ID. + Specifying a host name we would get a list of the associations + specifying that host name as the remote one. + + Implementors need to be aware that if the size of + sctpAssocRemHostName exceeds 115 octets then OIDs of column + instances in this table will have more than 128 sub- + identifiers and cannot be accessed using SNMPv1, SNMPv2c, or + SNMPv3." + INDEX { sctpAssocRemHostName, + sctpAssocId } + ::= { sctpLookupRemHostNameTable 1 } + +SctpLookupRemHostNameEntry::= SEQUENCE { + sctpLookupRemHostNameStartTime TimeStamp + } + +sctpLookupRemHostNameStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time that this row was created. + + As the table will be created after the sctpAssocTable + creation, this value could be equal to the sctpAssocStartTime + object from the main table." + ::= { sctpLookupRemHostNameEntry 1 } + +-- BY REMOTE PRIMARY IP ADDRESS + +sctpLookupRemPrimIPAddrTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpLookupRemPrimIPAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "With the use of this table, a list of associations that have + the specified IP address as primary within the remote set of + active addresses can be retrieved." + ::= { sctpObjects 9 } + +sctpLookupRemPrimIPAddrEntry OBJECT-TYPE + SYNTAX SctpLookupRemPrimIPAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table is indexed by primary address and association ID. + Specifying a primary address, we would get a list of the + associations that have the specified remote IP address marked + as primary. + Implementors need to be aware that if the size of + sctpAssocRemPrimAddr exceeds 114 octets then OIDs of column + instances in this table will have more than 128 sub- + identifiers and cannot be accessed using SNMPv1, SNMPv2c, or + SNMPv3." + INDEX { sctpAssocRemPrimAddrType, + sctpAssocRemPrimAddr, + sctpAssocId } + ::= { sctpLookupRemPrimIPAddrTable 1 } + +SctpLookupRemPrimIPAddrEntry::= SEQUENCE { + sctpLookupRemPrimIPAddrStartTime TimeStamp + } + +sctpLookupRemPrimIPAddrStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of SysUpTime at the time that this row was created. + + As the table will be created after the sctpAssocTable + creation, this value could be equal to the sctpAssocStartTime + object from the main table." + ::= { sctpLookupRemPrimIPAddrEntry 1 } + +-- BY REMOTE IP ADDRESS + +sctpLookupRemIPAddrTable OBJECT-TYPE + SYNTAX SEQUENCE OF SctpLookupRemIPAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "With the use of this table, a list of associations that have + the specified IP address as one of the remote ones can be + retrieved. " + ::= { sctpObjects 10 } + +sctpLookupRemIPAddrEntry OBJECT-TYPE + SYNTAX SctpLookupRemIPAddrEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table is indexed by a remote IP address and association + ID. Specifying an IP address we would get a list of the + associations that have the specified IP address included + within the set of remote IP addresses." + INDEX { sctpAssocRemAddrType, + sctpAssocRemAddr, + sctpAssocId } + ::= { sctpLookupRemIPAddrTable 1 } + +SctpLookupRemIPAddrEntry::= SEQUENCE { + + sctpLookupRemIPAddrStartTime TimeStamp + } + +sctpLookupRemIPAddrStartTime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of SysUpTime at the time that this row was created. + + As the table will be created after the sctpAssocTable + creation, this value could be equal to the sctpAssocStartTime + object from the main table." + ::= { sctpLookupRemIPAddrEntry 1 } + +-- 4.1 Conformance Information + +sctpMibConformance OBJECT IDENTIFIER ::= { sctpMIB 2 } +sctpMibCompliances OBJECT IDENTIFIER ::= { sctpMibConformance 1 } +sctpMibGroups OBJECT IDENTIFIER ::= { sctpMibConformance 2 } + +-- 4.1.1 Units of conformance + +-- +-- MODULE GROUPS +-- + +sctpLayerParamsGroup OBJECT-GROUP + OBJECTS { sctpRtoAlgorithm, + sctpRtoMin, + sctpRtoMax, + sctpRtoInitial, + sctpMaxAssocs, + sctpValCookieLife, + sctpMaxInitRetr + } + STATUS current + DESCRIPTION + "Common parameters for the SCTP layer, i.e., for all the + associations. They can usually be referred to as configuration + parameters." + ::= { sctpMibGroups 1 } + +sctpStatsGroup OBJECT-GROUP + OBJECTS { sctpCurrEstab, + sctpActiveEstabs, + sctpPassiveEstabs, + sctpAborteds, + sctpShutdowns, + sctpOutOfBlues, + sctpChecksumErrors, + sctpOutCtrlChunks, + sctpOutOrderChunks, + sctpOutUnorderChunks, + sctpInCtrlChunks, + sctpInOrderChunks, + sctpInUnorderChunks, + sctpFragUsrMsgs, + sctpReasmUsrMsgs, + sctpOutSCTPPacks, + sctpInSCTPPacks, + sctpDiscontinuityTime, + sctpAssocT1expireds, + sctpAssocT2expireds, + sctpAssocRtxChunks, + sctpAssocRemAddrRtx + } + STATUS current + DESCRIPTION + "Statistics group. It includes the objects to collect state + changes in the SCTP protocol local layer and flow control + statistics." + ::= { sctpMibGroups 2 } + +sctpPerAssocParamsGroup OBJECT-GROUP + OBJECTS { sctpAssocRemHostName, + sctpAssocLocalPort, + sctpAssocRemPort, + sctpAssocRemPrimAddrType, + sctpAssocRemPrimAddr, + sctpAssocHeartBeatInterval, + sctpAssocState, + sctpAssocInStreams, + sctpAssocOutStreams, + sctpAssocMaxRetr, + sctpAssocPrimProcess, + sctpAssocStartTime, + sctpAssocDiscontinuityTime, + sctpAssocLocalAddrStartTime, + sctpAssocRemAddrActive, + sctpAssocRemAddrHBActive, + sctpAssocRemAddrRTO, + sctpAssocRemAddrMaxPathRtx, + sctpAssocRemAddrStartTime + } + STATUS current + DESCRIPTION + "The SCTP group of objects to manage per-association + parameters. These variables include all the SCTP basic + features." + ::= { sctpMibGroups 3 } + +sctpPerAssocStatsGroup OBJECT-GROUP + OBJECTS + { sctpAssocT1expireds, + sctpAssocT2expireds, + sctpAssocRtxChunks, + sctpAssocRemAddrRtx + } + STATUS current + DESCRIPTION + "Per Association Statistics group. It includes the objects to + collect flow control statistics per association." + ::= { sctpMibGroups 4 } + +sctpInverseGroup OBJECT-GROUP + OBJECTS { sctpLookupLocalPortStartTime, + sctpLookupRemPortStartTime, + sctpLookupRemHostNameStartTime, + sctpLookupRemPrimIPAddrStartTime, + sctpLookupRemIPAddrStartTime + } + STATUS current + DESCRIPTION + "Objects used in the inverse lookup tables." + ::= { sctpMibGroups 5 } + +-- 4.1.2 Compliance Statements + +-- +-- MODULE COMPLIANCES +-- + +sctpMibCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for SNMP entities which implement + this SCTP MIB Module. + + There are a number of INDEX objects that cannot be represented + in the form of OBJECT clauses in SMIv2, but for which we have + the following compliance requirements, expressed in OBJECT + clause form in this description clause: + +-- OBJECT sctpAssocLocalAddrType +-- SYNTAX InetAddressType {ipv4(1), ipv6(2)} +-- DESCRIPTION +-- It is only required to have IPv4 and IPv6 addresses without +-- zone indices. +-- The address with zone indices is required if an +-- implementation can connect multiple zones. +-- +-- OBJECT sctpAssocLocalAddr +-- SYNTAX InetAddress (SIZE(4|16)) +-- DESCRIPTION +-- An implementation is only required to support globally +-- unique IPv4 and IPv6 addresses. +-- +-- OBJECT sctpAssocRemAddrType +-- SYNTAX InetAddressType {ipv4(1), ipv6(2)} +-- DESCRIPTION +-- It is only required to have IPv4 and IPv6 addresses without +-- zone indices. +-- The address with zone indices is required if an +-- implementation can connect multiple zones. +-- +-- OBJECT sctpAssocRemAddr +-- SYNTAX InetAddress (SIZE(4|16)) +-- DESCRIPTION +-- An implementation is only required to support globally +-- unique IPv4 and IPv6 addresses. +-- + " -- closes DESCRIPTION clause of MODULE-COMPLIANCE + + MODULE -- this module + + MANDATORY-GROUPS { sctpLayerParamsGroup, + sctpPerAssocParamsGroup, + sctpStatsGroup, + sctpPerAssocStatsGroup + } + + OBJECT sctpAssocRemPrimAddrType + SYNTAX InetAddressType { ipv4(1), + ipv6(2) + } + DESCRIPTION + "It is only required to have IPv4 and IPv6 addresses + without zone indices. + + The address with zone indices is required if an + implementation can connect multiple zones." + + OBJECT sctpAssocRemPrimAddr + SYNTAX InetAddress (SIZE(4|16)) + DESCRIPTION + "An implementation is only required to support globally + unique IPv4 and globally unique IPv6 addresses." + + OBJECT sctpAssocState + WRITE-SYNTAX INTEGER { deleteTCB(9) } + MIN-ACCESS read-only + DESCRIPTION + "Only the deleteTCB(9) value MAY be set by a management + station at most. A read-only option is also considered to + be compliant with this MIB module description." + + GROUP sctpInverseGroup + DESCRIPTION + "Objects used in inverse lookup tables. This should be + implemented, at the discretion of the implementers, for + easier lookups in the association tables" + ::= { sctpMibCompliances 1 } + +END Index: agent/mibgroup/sctp-mib/sctpScalars_common.h =================================================================== --- agent/mibgroup/sctp-mib/sctpScalars_common.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpScalars_common.h (revision 17153) @@ -0,0 +1,148 @@ +#ifndef SCTP_SCALARS_COMMON_H +#define SCTP_SCALARS_COMMON_H + +/* + * Define OIDs + */ +#define SCTP_CURRESTAB 1 +#define SCTP_ACTIVEESTABS 2 +#define SCTP_PASSIVEESTABS 3 +#define SCTP_ABORTEDS 4 +#define SCTP_SHUTDOWNS 5 +#define SCTP_OUTOFBLUES 6 +#define SCTP_CHECKSUMERRORS 7 +#define SCTP_OUTCTRLCHUNKS 8 +#define SCTP_OUTORDERCHUNKS 9 +#define SCTP_OUTUNORDERCHUNKS 10 +#define SCTP_INCTRLCHUNKS 11 +#define SCTP_INORDERCHUNKS 12 +#define SCTP_INUNORDERCHUNKS 13 +#define SCTP_FRAGUSRMSGS 14 +#define SCTP_REASMUSRMSGS 15 +#define SCTP_OUTSCTPPACKS 16 +#define SCTP_INSCTPPACKS 17 +#define SCTP_DISCONTINUITYTIME 18 + +#define SCTP_RTOALGORITHM 1 +#define SCTP_RTOMIN 2 +#define SCTP_RTOMAX 3 +#define SCTP_RTOINITIAL 4 +#define SCTP_MAXASSOCS 5 +#define SCTP_VALCOOKIELIFE 6 +#define SCTP_MAXINITRETR 7 + +/* + * Define cache timeouts + */ +#define SCTP_STATS_CACHE_TIMEOUT 30 +#define SCTP_PARAMS_CACHE_TIMEOUT 30 + +/* + * Structure to hold sctpStats + */ +typedef struct netsnmp_sctp_stats_s { + u_int curr_estab; + u_int active_estabs; + u_int passive_estabs; + u_int aborteds; + u_int shutdowns; + u_int out_of_blues; + u_int checksum_errors; + struct counter64 out_ctrl_chunks; + struct counter64 out_order_chunks; + struct counter64 out_unorder_chunks; + struct counter64 in_ctrl_chunks; + struct counter64 in_order_chunks; + struct counter64 in_unorder_chunks; + struct counter64 frag_usr_msgs; + struct counter64 reasm_usr_msgs; + struct counter64 out_sctp_packs; + struct counter64 in_sctp_packs; + u_long discontinuity_time; +} netsnmp_sctp_stats; + +/* + * Enums for sctpParams + */ +#define NETSNMP_SCTP_ALGORITHM_OTHER 1 +#define NETSNMP_SCTP_ALGORITHM_VANJ 2 + +/* + * Structure to hold sctpParams + */ +typedef struct netsnmp_sctp_params_s { + u_int rto_algorithm; + u_int rto_min; + u_int rto_max; + u_int rto_initial; + int max_assocs; + u_int val_cookie_life; + u_int max_init_retr; +} netsnmp_sctp_params; + + +/* + * sctpStats cached values. + * Will be used to reconstruct 64-bit counters when the underlying platform + * provides only 32-bit ones. + */ +extern netsnmp_sctp_stats sctp_stats; + +/* + * sctpParams cached values. + */ +extern netsnmp_sctp_params sctp_params; + +Netsnmp_Node_Handler sctp_stats_handler; +Netsnmp_Node_Handler sctp_params_handler; + +/* + * function declarations + */ + + +/* + * ======================================================= + * Platform independent functions. + * Mostly just wrappers around the platform dependent ones. + * ======================================================= + */ +extern void netsnmp_access_sctp_stats_init(void); +extern NetsnmpCacheLoad netsnmp_access_sctp_stats_load; +extern NetsnmpCacheFree netsnmp_access_sctp_stats_free; + +extern void netsnmp_access_sctp_params_init(void); +extern NetsnmpCacheLoad netsnmp_access_sctp_params_load; +extern NetsnmpCacheFree netsnmp_access_sctp_params_free; + +/* + * ======================================================= + * Platform dependent functions. + * These do the real work. + * ======================================================= + */ + +/* + * Initialize patform dependent part of sctpStats. + */ +extern void netsnmp_access_sctp_stats_arch_init(void); + +/* + * Load the sctpStats from underlying platform. The caller will reconstruct + * 64-bit counters if the platform provided 32-bit ones only. + */ +extern int netsnmp_access_sctp_stats_arch_load(netsnmp_sctp_stats * + sctp_stats); + +/* + * Initialize patform dependent part of sctpParams. + */ +extern void netsnmp_access_sctp_params_arch_init(void); + +/* + * Load the sctpParams. + */ +extern int netsnmp_access_sctp_params_arch_load(netsnmp_sctp_params * + sctp_params); + +#endif /* SCTP_SCALARS_COMMON_H */ Index: agent/mibgroup/sctp-mib/sctpLookupLocalPortTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupLocalPortTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupLocalPortTable.h (revision 17153) @@ -0,0 +1,59 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPLOOKUPLOCALPORTTABLE_H +#define SCTPLOOKUPLOCALPORTTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpLookupLocalPortTable(void); +void shutdown_sctpLookupLocalPortTable(void); +void initialize_table_sctpLookupLocalPortTable(void); +Netsnmp_Node_Handler sctpLookupLocalPortTable_handler; + +/* + * column number definitions for table sctpLookupLocalPortTable + */ +#define COLUMN_SCTPLOOKUPLOCALPORTSTARTTIME 1 + +/** Typical data structure for a row entry */ +#define SCTP_LOOKUP_LOCAL_PORT_TABLE_INDEX_SIZE 100 +struct sctpLookupLocalPortTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_LOOKUP_LOCAL_PORT_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocLocalPort; + u_long sctpAssocId; + + /* + * Column values + */ + u_long sctpLookupLocalPortStartTime; + + int valid; +}; + +sctpLookupLocalPortTable_entry* +sctpLookupLocalPortTable_entry_create(void); + +int +sctpLookupLocalPortTable_entry_update_index(sctpLookupLocalPortTable_entry + * entry); +void +sctpLookupLocalPortTable_entry_copy(sctpLookupLocalPortTable_entry * from, + sctpLookupLocalPortTable_entry * to); +void +sctpLookupLocalPortTable_entry_free(sctpLookupLocalPortTable_entry * + entry); + +void +sctpLookupLocalPortTable_container_clear(netsnmp_container *container); + +#endif /* SCTPLOOKUPLOCALPORTTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.h (revision 17153) @@ -0,0 +1,65 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPLOOKUPREMPRIMIPADDRTABLE_H +#define SCTPLOOKUPREMPRIMIPADDRTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpLookupRemPrimIPAddrTable(void); +void shutdown_sctpLookupRemPrimIPAddrTable(void); +void initialize_table_sctpLookupRemPrimIPAddrTable(void); +Netsnmp_Node_Handler sctpLookupRemPrimIPAddrTable_handler; + +/* + * column number definitions for table sctpLookupRemPrimIPAddrTable + */ +#define COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME 1 + +/** Typical data structure for a row entry */ +#define SCTP_LOOKUP_REM_PRIM_IP_ADDR_TABLE_INDEX_SIZE 100 +struct sctpLookupRemPrimIPAddrTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_LOOKUP_REM_PRIM_IP_ADDR_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocRemPrimAddrType; + char sctpAssocRemPrimAddr[SCTP_IPADDRESS_SIZE]; + u_long sctpAssocRemPrimAddr_len; + u_long sctpAssocId; + + /* + * Column values + */ + u_long sctpLookupRemPrimIPAddrStartTime; + + int valid; +}; + +sctpLookupRemPrimIPAddrTable_entry * +sctpLookupRemPrimIPAddrTable_entry_create(void); + +int +sctpLookupRemPrimIPAddrTable_entry_update_index (sctpLookupRemPrimIPAddrTable_entry + * entry); + +void +sctpLookupRemPrimIPAddrTable_entry_copy(sctpLookupRemPrimIPAddrTable_entry + * from, + sctpLookupRemPrimIPAddrTable_entry + * to); + +void +sctpLookupRemPrimIPAddrTable_entry_free(sctpLookupRemPrimIPAddrTable_entry + * entry); + +void +sctpLookupRemPrimIPAddrTable_container_clear(netsnmp_container *container); + +#endif /* SCTPLOOKUPREMPRIMIPADDRTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpScalars_linux.c =================================================================== --- agent/mibgroup/sctp-mib/sctpScalars_linux.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpScalars_linux.c (revision 17153) @@ -0,0 +1,185 @@ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +#include "sctpScalars_common.h" + +#include <stdio.h> +#include <errno.h> + +#define PROC_PREFIX "/proc" +#define PROC_RTO_MIN PROC_PREFIX "/sys/net/sctp/rto_min" +#define PROC_RTO_MAX PROC_PREFIX "/sys/net/sctp/rto_max" +#define PROC_RTO_INITIAL PROC_PREFIX "/sys/net/sctp/rto_initial" +#define PROC_VAL_COOKIE_LIFE PROC_PREFIX "/sys/net/sctp/valid_cookie_life" +#define PROC_MAX_INIT_RETR PROC_PREFIX "/sys/net/sctp/max_init_retransmits" +#define PROC_STATS PROC_PREFIX "/net/sctp/snmp" + +/** + * Reads one integer value from a file. + */ +static int +load_uint_file(const char *filename, u_int * value) +{ + FILE *f; + int ret; + + f = fopen(filename, "r"); + if (f == NULL) { + DEBUGMSGTL(("sctp:scalars:arch:load", "Cannot read file %s\n", + filename)); + return -1; + } + + ret = fscanf(f, "%u", value); + if (ret != 1) { + DEBUGMSGTL(("sctp:scalars:arch:load", "Malformed file %s\n", + filename)); + return -2; + } + + fclose(f); + return 0; +} + +void +netsnmp_access_sctp_stats_arch_init() +{ +} + +int +netsnmp_access_sctp_stats_arch_load(netsnmp_sctp_stats * sctp_stats) +{ + FILE *f; + char line[100]; + unsigned long long value; + char *delimiter; + int ret = 0; + + DEBUGMSGTL(("sctp:scalars:stats:arch_load", + "netsnmp_access_sctp_stats_arch_load called")); + + memset(sctp_stats, 0, sizeof(netsnmp_sctp_stats)); + f = fopen(PROC_STATS, "r"); + if (f == NULL) + return -1; + + while (fgets(line, sizeof(line), f) != NULL) { + DEBUGMSGTL(("sctp:scalars:stats:arch_load", "read: %s", line)); + + delimiter = strchr(line, '\t'); + if (delimiter == NULL) { + DEBUGMSGTL(("sctp:scalars:stats:arch_load", + "Malformed line, cannot find '\\t'!\n")); + return -1; + } + errno = 0; + value = strtoull(delimiter + 1, NULL, 10); + if (errno != 0) { + DEBUGMSGTL(("sctp:scalars:stats:arch_load", + "Malformed value!'\n")); + return -1; + } + + if (line[6] == 'r') + sctp_stats->curr_estab = value; + else if (line[5] == 'c') + sctp_stats->active_estabs = value; + else if (line[4] == 'P') + sctp_stats->passive_estabs = value; + else if (line[5] == 'b') + sctp_stats->aborteds = value; + else if (line[4] == 'S') + sctp_stats->shutdowns = value; + else if (line[8] == 'f') + sctp_stats->out_of_blues = value; + else if (line[6] == 'e') + sctp_stats->checksum_errors = value; + else if (line[4] == 'O') { + if (line[7] == 'C') { + sctp_stats->out_ctrl_chunks.low = value & 0xffffffff; + sctp_stats->out_ctrl_chunks.high = value >> 32; + } else if (line[7] == 'O') { + sctp_stats->out_order_chunks.low = value & 0xffffffff; + sctp_stats->out_order_chunks.high = value >> 32; + } else if (line[7] == 'U') { + sctp_stats->out_unorder_chunks.low = value & 0xffffffff; + sctp_stats->out_unorder_chunks.high = value >> 32; + } else if (line[7] == 'S') { + sctp_stats->out_sctp_packs.low = value & 0xffffffff; + sctp_stats->out_sctp_packs.high = value >> 32; + } else + ret = -1; + } else { + if (line[6] == 'C') { + sctp_stats->in_ctrl_chunks.low = value & 0xffffffff; + sctp_stats->in_ctrl_chunks.high = value >> 32; + } else if (line[6] == 'O') { + sctp_stats->in_order_chunks.low = value & 0xffffffff; + sctp_stats->in_order_chunks.high = value >> 32; + } else if (line[6] == 'U') { + sctp_stats->in_unorder_chunks.low = value & 0xffffffff; + sctp_stats->in_unorder_chunks.high = value >> 32; + } else if (line[4] == 'F') { + sctp_stats->frag_usr_msgs.low = value & 0xffffffff; + sctp_stats->frag_usr_msgs.high = value >> 32; + } else if (line[4] == 'R') { + sctp_stats->reasm_usr_msgs.low = value & 0xffffffff; + sctp_stats->reasm_usr_msgs.high = value >> 32; + } else if (line[6] == 'S') { + sctp_stats->in_sctp_packs.low = value & 0xffffffff; + sctp_stats->in_sctp_packs.high = value >> 32; + } else + ret = -1; + } + + if (ret < 0) { + DEBUGMSGTL(("sctp:scalars:stats:arch_load", + "Unknown entry!'\n")); + return ret; + } + } + + sctp_stats->discontinuity_time = 0; + return 0; +} + +void +netsnmp_access_sctp_params_arch_init() +{ +} + +int +netsnmp_access_sctp_params_arch_load(netsnmp_sctp_params * sctp_params) +{ + int ret; + DEBUGMSGTL(("sctp:scalars:params:arch_load", + "netsnmp_access_sctp_params_arch_load called")); + + sctp_params->rto_algorithm = NETSNMP_SCTP_ALGORITHM_OTHER; + + ret = load_uint_file(PROC_RTO_MIN, &sctp_params->rto_min); + if (ret < 0) + return ret; + + ret = load_uint_file(PROC_RTO_MAX, &sctp_params->rto_max); + if (ret < 0) + return ret; + + ret = load_uint_file(PROC_RTO_INITIAL, &sctp_params->rto_initial); + if (ret < 0) + return ret; + + sctp_params->max_assocs = -1; /* dynamic allocation of associations */ + + ret = load_uint_file(PROC_VAL_COOKIE_LIFE, + &sctp_params->val_cookie_life); + if (ret < 0) + return ret; + + ret = load_uint_file(PROC_MAX_INIT_RETR, &sctp_params->max_init_retr); + if (ret < 0) + return ret; + + return 0; +} Index: agent/mibgroup/sctp-mib/sctpLookupRemIPAddrTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemIPAddrTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemIPAddrTable.c (revision 17153) @@ -0,0 +1,277 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpLookupRemIPAddrTable.h" + +static netsnmp_container *sctpLookupRemIPAddrTable_container; + +/** Initializes the sctpLookupRemIPAddrTable module */ +void +init_sctpLookupRemIPAddrTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpLookupRemIPAddrTable(); +} + +void +shutdown_sctpLookupRemIPAddrTable(void) +{ + sctpLookupRemIPAddrTable_container_clear + (sctpLookupRemIPAddrTable_container); +} + +/** Initialize the sctpLookupRemIPAddrTable table by defining its contents and how it's structured */ +void +initialize_table_sctpLookupRemIPAddrTable(void) +{ + static oid sctpLookupRemIPAddrTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 10 }; + size_t sctpLookupRemIPAddrTable_oid_len = + OID_LENGTH(sctpLookupRemIPAddrTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpLookupRemIPAddrTable", + sctpLookupRemIPAddrTable_handler, + sctpLookupRemIPAddrTable_oid, + sctpLookupRemIPAddrTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpLookupRemIPAddrTable\n"); + goto bail; + } + + container = + netsnmp_container_find("sctpLookupRemIPAddrTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpLookupRemIPAddrTable\n"); + goto bail; + } + sctpLookupRemIPAddrTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemIPAddrTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: sctpLookupRemIPAddrType */ + ASN_OCTET_STR, /* index: sctpLookupRemIPAddr */ + ASN_UNSIGNED, /* index: sctpAssocId */ + 0); + table_info->min_column = COLUMN_SCTPLOOKUPREMIPADDRSTARTTIME; + table_info->max_column = COLUMN_SCTPLOOKUPREMIPADDRSTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemIPAddrTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpLookupRemIPAddrTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpLookupRemIPAddrTable\n"); + goto bail; + } + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + +/** handles requests for the sctpLookupRemIPAddrTable table */ +int +sctpLookupRemIPAddrTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpLookupRemIPAddrTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpLookupRemIPAddrTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpLookupRemIPAddrTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPLOOKUPREMIPADDRSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpLookupRemIPAddrStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpLookupRemIPAddrTable_entry * +sctpLookupRemIPAddrTable_entry_create(void) +{ + sctpLookupRemIPAddrTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpLookupRemIPAddrTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_LOOKUP_REM_IP_ADDR_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpLookupRemIPAddrTable_entry_update_index(sctpLookupRemIPAddrTable_entry + * entry) +{ + netsnmp_variable_list var_sctpAssocRemIPAddrType; + netsnmp_variable_list var_sctpAssocRemIPAddr; + netsnmp_variable_list var_sctpAssocId; + int err = 0; + + /* + * prepare the value to be converted + */ + memset(&var_sctpAssocRemIPAddrType, 0, + sizeof(var_sctpAssocRemIPAddrType)); + var_sctpAssocRemIPAddrType.type = ASN_UNSIGNED; + var_sctpAssocRemIPAddrType.next_variable = &var_sctpAssocRemIPAddr; + snmp_set_var_value(&var_sctpAssocRemIPAddrType, + (u_char *) & entry->sctpAssocRemAddrType, + sizeof(entry->sctpAssocRemAddrType)); + + memset(&var_sctpAssocRemIPAddr, 0, sizeof(var_sctpAssocRemIPAddr)); + var_sctpAssocRemIPAddr.type = ASN_OCTET_STR; + var_sctpAssocRemIPAddr.next_variable = &var_sctpAssocId; + snmp_set_var_value(&var_sctpAssocRemIPAddr, + (u_char *) & entry->sctpAssocRemAddr, + entry->sctpAssocRemAddr_len); + + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + var_sctpAssocId.next_variable = NULL; + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocRemIPAddrType); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocRemIPAddrType); + + return err; +} + +void +sctpLookupRemIPAddrTable_entry_copy(sctpLookupRemIPAddrTable_entry * from, + sctpLookupRemIPAddrTable_entry * to) +{ + memcpy(to, from, sizeof(sctpLookupRemIPAddrTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + + +void +sctpLookupRemIPAddrTable_entry_free(sctpLookupRemIPAddrTable_entry * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpLookupRemIPAddrTable_get_container(void) +{ + return sctpLookupRemIPAddrTable_container; +} + + +static void +sctpLookupRemIPAddrTable_entry_clear(void *what, void *magic) +{ + sctpLookupRemIPAddrTable_entry_free(what); +} + +void +sctpLookupRemIPAddrTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpLookupRemIPAddrTable_entry_clear, NULL); +} Index: agent/mibgroup/sctp-mib/sctpLookupRemIPAddrTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemIPAddrTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemIPAddrTable.h (revision 17153) @@ -0,0 +1,63 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPLOOKUPREMIPADDRTABLE_H +#define SCTPLOOKUPREMIPADDRTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpLookupRemIPAddrTable(void); +void shutdown_sctpLookupRemIPAddrTable(void); +void initialize_table_sctpLookupRemIPAddrTable(void); +Netsnmp_Node_Handler sctpLookupRemIPAddrTable_handler; + +/* + * column number definitions for table sctpLookupRemIPAddrTable + */ +#define COLUMN_SCTPLOOKUPREMIPADDRSTARTTIME 1 + +/** Typical data structure for a row entry */ +#define SCTP_LOOKUP_REM_IP_ADDR_TABLE_INDEX_SIZE 100 +struct sctpLookupRemIPAddrTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_LOOKUP_REM_IP_ADDR_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocRemAddrType; + char sctpAssocRemAddr[SCTP_IPADDRESS_SIZE]; + u_long sctpAssocRemAddr_len; + u_long sctpAssocId; + + /* + * Column values + */ + u_long sctpLookupRemIPAddrStartTime; + + int valid; +}; + +sctpLookupRemIPAddrTable_entry * +sctpLookupRemIPAddrTable_entry_create(void); + +int +sctpLookupRemIPAddrTable_entry_update_index(sctpLookupRemIPAddrTable_entry + * entry); + +void +sctpLookupRemIPAddrTable_entry_copy(sctpLookupRemIPAddrTable_entry * from, + sctpLookupRemIPAddrTable_entry * to); + +void +sctpLookupRemIPAddrTable_entry_free(sctpLookupRemIPAddrTable_entry * + entry); + +void +sctpLookupRemIPAddrTable_container_clear(netsnmp_container *container); + +#endif /* SCTPLOOKUPREMIPADDRTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpTables.h =================================================================== --- agent/mibgroup/sctp-mib/sctpTables.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpTables.h (revision 17153) @@ -0,0 +1,24 @@ +#ifndef SCTP_TABLES_H +#define SCTP_TABLES_H +config_require(sctp-mib/sctpTables_common) +config_require(sctp-mib/sctpAssocRemAddrTable) +config_require(sctp-mib/sctpAssocLocalAddrTable) +config_require(sctp-mib/sctpLookupLocalPortTable) +config_require(sctp-mib/sctpLookupRemPortTable) +config_require(sctp-mib/sctpLookupRemHostNameTable) +config_require(sctp-mib/sctpLookupRemPrimIPAddrTable) +config_require(sctp-mib/sctpLookupRemIPAddrTable) +/* + * this one must be last to ensure proper initialization ordering + */ +config_require(sctp-mib/sctpAssocTable) +#if defined( linux ) +config_require(sctp-mib/sctpTables_linux) +#else +/* +* couldn't determine the correct file! +* require a bogus file to generate an error. +*/ +config_require(sctp-mib/tables-unknown-arch) +#endif +#endif /* SCTP_TABLES_H */ Index: agent/mibgroup/sctp-mib/sctpAssocRemAddrTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpAssocRemAddrTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpAssocRemAddrTable.c (revision 17153) @@ -0,0 +1,333 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpAssocRemAddrTable.h" + +/* + * content of the sctpAssocRemAddrTable + */ +static netsnmp_container *sctpAssocRemAddrTable_container; + +/** Initializes the sctpAssocRemAddrTable module */ +void +init_sctpAssocRemAddrTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpAssocRemAddrTable(); +} + +void +shutdown_sctpAssocRemAddrTable(void) +{ + sctpAssocRemAddrTable_container_clear(sctpAssocRemAddrTable_container); +} + +/** Initialize the sctpAssocRemAddrTable table by defining its contents and how it's structured */ +void +initialize_table_sctpAssocRemAddrTable(void) +{ + static oid sctpAssocRemAddrTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 5 }; + size_t sctpAssocRemAddrTable_oid_len = + OID_LENGTH(sctpAssocRemAddrTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpAssocRemAddrTable", + sctpAssocRemAddrTable_handler, + sctpAssocRemAddrTable_oid, + sctpAssocRemAddrTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpAssocRemAddrTable\n"); + goto bail; + } + + container = + netsnmp_container_find("sctpAssocRemAddrTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpAssocRemAddrTable\n"); + goto bail; + } + sctpAssocRemAddrTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpAssocRemAddrTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index: sctpAssocId */ + ASN_INTEGER, /* index: sctpAssocRemAddrType */ + ASN_OCTET_STR, /* index: sctpAssocRemAddr */ + 0); + table_info->min_column = COLUMN_SCTPASSOCREMADDRACTIVE; + table_info->max_column = COLUMN_SCTPASSOCREMADDRSTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpAssocRemAddrTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpAssocRemAddrTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpAssocRemAddrTable\n"); + goto bail; + } + + /* + * Initialise the contents of the table here + */ + + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + + +/** handles requests for the sctpAssocRemAddrTable table */ +int +sctpAssocRemAddrTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpAssocRemAddrTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpAssocRemAddrTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpAssocRemAddrTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPASSOCREMADDRACTIVE: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, + table_entry->sctpAssocRemAddrActive); + break; + case COLUMN_SCTPASSOCREMADDRHBACTIVE: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, + table_entry->sctpAssocRemAddrHBActive); + break; + case COLUMN_SCTPASSOCREMADDRRTO: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocRemAddrRTO); + break; + case COLUMN_SCTPASSOCREMADDRMAXPATHRTX: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocRemAddrMaxPathRtx); + break; + case COLUMN_SCTPASSOCREMADDRRTX: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER, + table_entry->sctpAssocRemAddrRtx); + break; + case COLUMN_SCTPASSOCREMADDRSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpAssocRemAddrStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpAssocRemAddrTable_entry * +sctpAssocRemAddrTable_entry_create(void) +{ + sctpAssocRemAddrTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpAssocRemAddrTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_ASSOC_REM_ADDR_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpAssocRemAddrTable_entry_update_index(sctpAssocRemAddrTable_entry * + entry) +{ + int err = 0; + + netsnmp_variable_list var_sctpAssocId; + netsnmp_variable_list var_sctpAssocRemAddrType; + netsnmp_variable_list var_sctpAssocRemAddr; + + /* + * prepare the values to be converted + */ + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + memset(&var_sctpAssocRemAddrType, 0, sizeof(var_sctpAssocRemAddrType)); + var_sctpAssocRemAddrType.type = ASN_INTEGER; + memset(&var_sctpAssocRemAddr, 0, sizeof(var_sctpAssocRemAddr)); + var_sctpAssocRemAddr.type = ASN_OCTET_STR; + + var_sctpAssocId.next_variable = &var_sctpAssocRemAddrType; + var_sctpAssocRemAddrType.next_variable = &var_sctpAssocRemAddr; + var_sctpAssocRemAddr.next_variable = NULL; + + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + snmp_set_var_value(&var_sctpAssocRemAddrType, + (u_char *) & entry->sctpAssocRemAddrType, + sizeof(entry->sctpAssocRemAddrType)); + snmp_set_var_value(&var_sctpAssocRemAddr, + (u_char *) & entry->sctpAssocRemAddr, + entry->sctpAssocRemAddr_len * + sizeof(entry->sctpAssocRemAddr[0])); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocId); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocId); + + return err; + +} + +void +sctpAssocRemAddrTable_entry_copy(sctpAssocRemAddrTable_entry * from, + sctpAssocRemAddrTable_entry * to) +{ + memcpy(to, from, sizeof(sctpAssocRemAddrTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + +void +sctpAssocRemAddrTable_entry_free(sctpAssocRemAddrTable_entry * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpAssocRemAddrTable_get_container(void) +{ + return sctpAssocRemAddrTable_container; +} + + +static void +sctpAssocRemAddrTable_entry_clear(void *what, void *magic) +{ + sctpAssocRemAddrTable_entry_free(what); +} + +void +sctpAssocRemAddrTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpAssocRemAddrTable_entry_clear, NULL); +} Index: agent/mibgroup/sctp-mib/sctpAssocTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpAssocTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpAssocTable.c (revision 17153) @@ -0,0 +1,517 @@ +/* + * Note: this file originally auto-generated by mib2c using + * mib2c -c mib2c.container.conf + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpAssocTable.h" + +static void _cache_free(netsnmp_cache * cache, void *magic); +static int _cache_load(netsnmp_cache * cache, void *vmagic); + +/* + * content of the sctpAssocTable + */ +static netsnmp_container *sctpAssocTable_container; + +/** Initializes the sctpAssocTable module */ +void +init_sctpAssocTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpAssocTable(); +} + +void +shutdown_sctpAssocTable(void) +{ + sctpAssocTable_container_clear(sctpAssocTable_container); +} + +/** Initialize the sctpAssocTable table by defining its contents and how it's structured */ +void +initialize_table_sctpAssocTable(void) +{ + static oid sctpAssocTable_oid[] = { 1, 3, 6, 1, 2, 1, 104, 1, 3 }; + size_t sctpAssocTable_oid_len = + OID_LENGTH(sctpAssocTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + netsnmp_cache *cache = NULL; + + reg = + netsnmp_create_handler_registration("sctpAssocTable", + sctpAssocTable_handler, + sctpAssocTable_oid, + sctpAssocTable_oid_len, + HANDLER_CAN_RWRITE); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpAssocTable\n"); + goto bail; + } + /** should a set on a non-existent row create a new one? */ + /** reg->modes |= HANDLER_CAN_NOT_CREATE; */ + + container = netsnmp_container_find("sctpAssocTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, "error creating container for sctpAssocTable\n"); + goto bail; + } + sctpAssocTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpAssocTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index: sctpAssocId */ + 0); + table_info->min_column = COLUMN_SCTPASSOCREMHOSTNAME; + table_info->max_column = COLUMN_SCTPASSOCDISCONTINUITYTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpAssocTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpAssocTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /************************************************* + * + * inject cache helper + */ + cache = netsnmp_cache_create(SCTP_TABLES_CACHE_TIMEOUT, /* timeout in seconds */ + _cache_load, _cache_free, + sctpAssocTable_oid, + sctpAssocTable_oid_len); + + if (NULL == cache) { + snmp_log(LOG_ERR, "error creating cache for sctpAssocTable\n"); + goto bail; + } + cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET + | NETSNMP_CACHE_AUTO_RELOAD | NETSNMP_CACHE_PRELOAD; + cache->magic = container; + + handler = netsnmp_cache_handler_get(cache); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error creating cache handler for sctpAssocTable\n"); + goto bail; + } + + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting cache handler for sctpAssocTable\n"); + goto bail; + } + handler = NULL; /* reg has it */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpAssocTable\n"); + goto bail; + } + + /* + * Initialise the contents of the table here + */ + + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); +/* following is not available innet-snmp-5.3.1 + if (cache) + netsnmp_cache_free(cache); + + if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + + +/** handles requests for the sctpAssocTable table */ +int +sctpAssocTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpAssocTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpAssocTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpAssocTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPASSOCREMHOSTNAME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, + (u_char *) + table_entry->sctpAssocRemHostName, + table_entry->sctpAssocRemHostName_len); + break; + case COLUMN_SCTPASSOCLOCALPORT: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocLocalPort); + break; + case COLUMN_SCTPASSOCREMPORT: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocRemPort); + break; + case COLUMN_SCTPASSOCREMPRIMADDRTYPE: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, + table_entry->sctpAssocRemPrimAddrType); + break; + case COLUMN_SCTPASSOCREMPRIMADDR: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, + (u_char *) + table_entry->sctpAssocRemPrimAddr, + table_entry->sctpAssocRemPrimAddr_len); + break; + case COLUMN_SCTPASSOCHEARTBEATINTERVAL: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocHeartBeatInterval); + break; + case COLUMN_SCTPASSOCSTATE: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, + table_entry->sctpAssocState); + break; + case COLUMN_SCTPASSOCINSTREAMS: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocInStreams); + break; + case COLUMN_SCTPASSOCOUTSTREAMS: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocOutStreams); + break; + case COLUMN_SCTPASSOCMAXRETR: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocMaxRetr); + break; + case COLUMN_SCTPASSOCPRIMPROCESS: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_UNSIGNED, + table_entry->sctpAssocPrimProcess); + break; + case COLUMN_SCTPASSOCT1EXPIREDS: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER, + table_entry->sctpAssocT1expireds); + break; + case COLUMN_SCTPASSOCT2EXPIREDS: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER, + table_entry->sctpAssocT2expireds); + break; + case COLUMN_SCTPASSOCRTXCHUNKS: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER, + table_entry->sctpAssocRtxChunks); + break; + case COLUMN_SCTPASSOCSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpAssocStartTime); + break; + case COLUMN_SCTPASSOCDISCONTINUITYTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpAssocDiscontinuityTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + /* + * Write-support + */ + case MODE_SET_RESERVE1: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + netsnmp_set_request_error(reqinfo, request, + SNMP_ERR_NOTWRITABLE); + } + break; + + case MODE_SET_RESERVE2: + case MODE_SET_FREE: + case MODE_SET_ACTION: + case MODE_SET_UNDO: + case MODE_SET_COMMIT: + break; + } + return SNMP_ERR_NOERROR; +} + +/** + * @internal + */ +static int +_cache_load(netsnmp_cache * cache, void *vmagic) +{ + DEBUGMSGTL(("internal:sctpAssocTable:_cache_load", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for sctpAssocTable_cache_load\n"); + return -1; + } + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + return sctpTables_load(); +} /* _cache_load */ + +/** + * @Internal + */ +/** remove a row from the table */ +static void +sctpAssocTable_freeEntry_cb(sctpAssocTable_entry * entry, void *magic) +{ + + sctpAssocTable_entry_free(entry); +} + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache * cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:sctpAssocTable:_cache_free", "called\n")); + + if ((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in sctpAssocTable_cache_free\n"); + return; + } + container = (netsnmp_container *) cache->magic; + + /* + * empty (but don't free) cache here + */ + CONTAINER_CLEAR(container, (netsnmp_container_obj_func *) + sctpAssocTable_freeEntry_cb, NULL); +} /* _cache_free */ + +sctpAssocTable_entry * +sctpAssocTable_entry_create(void) +{ + sctpAssocTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpAssocTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_ASSOC_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpAssocTable_entry_update_index(sctpAssocTable_entry * entry) +{ + netsnmp_variable_list var_sctpAssocId; + int err = 0; + + /* + * prepare the value to be converted + */ + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + var_sctpAssocId.next_variable = NULL; + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocId); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocId); + + return err; +} + +void +sctpAssocTable_entry_copy(sctpAssocTable_entry * from, + sctpAssocTable_entry * to) +{ + memcpy(to, from, sizeof(sctpAssocTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + + +void +sctpAssocTable_entry_free(sctpAssocTable_entry * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpAssocTable_get_container(void) +{ + return sctpAssocTable_container; +} + +static void +sctpAssocTable_entry_clear(void *what, void *magic) +{ + sctpAssocTable_entry_free(what); +} + +void +sctpAssocTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpAssocTable_entry_clear, NULL); +} Index: agent/mibgroup/sctp-mib/sctpTables_common.c =================================================================== --- agent/mibgroup/sctp-mib/sctpTables_common.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpTables_common.c (revision 17153) @@ -0,0 +1,441 @@ +#include "sctpTables_common.h" +#include "sctpAssocTable.h" +#include "sctpAssocRemAddrTable.h" +#include "sctpAssocLocalAddrTable.h" +#include "sctpLookupLocalPortTable.h" +#include "sctpLookupRemPortTable.h" +#include "sctpLookupRemHostNameTable.h" +#include "sctpLookupRemPrimIPAddrTable.h" +#include "sctpLookupRemIPAddrTable.h" + +static void +sctpAssocTable_collect_invalid(void *what, void *magic) +{ + sctpAssocTable_entry *entry = what; + netsnmp_container *to_delete = magic; + + if (entry->valid) + entry->valid = 0; + else + CONTAINER_INSERT(to_delete, entry); +} + +/* + * Remove all entries from sctpAssocTable, which are not marked as valid. + * All valid entries are then marked as invalid (to delete them in next cache + * load, if the entry is not updated). + */ +void +sctpAssocTable_delete_invalid(netsnmp_container *assocTable) +{ + netsnmp_container *to_delete = netsnmp_container_find("lifo"); + + CONTAINER_FOR_EACH(assocTable, sctpAssocTable_collect_invalid, + to_delete); + + while (CONTAINER_SIZE(to_delete)) { + sctpAssocTable_entry *entry = CONTAINER_FIRST(to_delete); + CONTAINER_REMOVE(assocTable, entry); + sctpAssocTable_entry_free(entry); + CONTAINER_REMOVE(to_delete, NULL); + } +} + +static void +sctpAssocRemAddrTable_collect_invalid(void *what, void *magic) +{ + sctpAssocRemAddrTable_entry *entry = what; + netsnmp_container *to_delete = magic; + + if (entry->valid) + entry->valid = 0; + else + CONTAINER_INSERT(to_delete, entry); +} + +/* + * Remove all entries from sctpAssocRemAddrTable, which are not marked as valid. + * All valid entries are then marked as invalid (to delete them in next cache + * load, if the entry is not updated). + */ +void +sctpAssocRemAddrTable_delete_invalid(netsnmp_container *remAddrTable) +{ + netsnmp_container *to_delete = netsnmp_container_find("lifo"); + + CONTAINER_FOR_EACH(remAddrTable, sctpAssocRemAddrTable_collect_invalid, + to_delete); + + while (CONTAINER_SIZE(to_delete)) { + sctpAssocRemAddrTable_entry *entry = CONTAINER_FIRST(to_delete); + CONTAINER_REMOVE(remAddrTable, entry); + sctpAssocRemAddrTable_entry_free(entry); + CONTAINER_REMOVE(to_delete, NULL); + } +} + +static void +sctpAssocLocalAddrTable_collect_invalid(void *what, void *magic) +{ + sctpAssocLocalAddrTable_entry *entry = what; + netsnmp_container *to_delete = magic; + + if (entry->valid) + entry->valid = 0; + else + CONTAINER_INSERT(to_delete, entry); +} + +/* + * Remove all entries from sctpAssocLocalAddrTable, which are not marked as valid. + * All valid entries are then marked as invalid (to delete them in next cache + * load, if the entry is not updated). + */ +void +sctpAssocLocalAddrTable_delete_invalid(netsnmp_container *localAddrTable) +{ + netsnmp_container *to_delete = netsnmp_container_find("lifo"); + + CONTAINER_FOR_EACH(localAddrTable, + sctpAssocLocalAddrTable_collect_invalid, to_delete); + + while (CONTAINER_SIZE(to_delete)) { + sctpAssocLocalAddrTable_entry *entry = CONTAINER_FIRST(to_delete); + CONTAINER_REMOVE(localAddrTable, entry); + sctpAssocLocalAddrTable_entry_free(entry); + CONTAINER_REMOVE(to_delete, NULL); + } +} + + +int +sctpAssocRemAddrTable_add_or_update(netsnmp_container *remAddrTable, + sctpAssocRemAddrTable_entry * entry) +{ + /* + * we have full sctpAssocLocalAddrTable entry, update or add it in the container + */ + sctpAssocRemAddrTable_entry *old; + + entry->valid = 1; + + /* + * try to find it in the container + */ + sctpAssocRemAddrTable_entry_update_index(entry); + old = CONTAINER_FIND(remAddrTable, entry); + + if (old != NULL) { + /* + * update existing entry, don't overwrite the timestamp + */ + time_t timestamp = old->sctpAssocRemAddrStartTime; + if (timestamp == 0 && entry->sctpAssocRemAddrStartTime == 0) + timestamp = netsnmp_get_agent_uptime(); /* set the timestamp if it was not set before */ + sctpAssocRemAddrTable_entry_copy(entry, old); + old->sctpAssocRemAddrStartTime = timestamp; + sctpAssocRemAddrTable_entry_free(entry); + + } else { + /* + * the entry is new, add it there + */ + if (entry->sctpAssocRemAddrStartTime == 0) { + entry->sctpAssocRemAddrStartTime = netsnmp_get_agent_uptime(); + } + CONTAINER_INSERT(remAddrTable, entry); + } + + return SNMP_ERR_NOERROR; +} + +int +sctpAssocLocalAddrTable_add_or_update(netsnmp_container *localAddrTable, + sctpAssocLocalAddrTable_entry * + entry) +{ + /* + * we have full sctpAssocLocalAddrTable entry, update or add it in the container + */ + sctpAssocLocalAddrTable_entry *old; + + entry->valid = 1; + + /* + * try to find it in the container + */ + sctpAssocLocalAddrTable_entry_update_index(entry); + old = CONTAINER_FIND(localAddrTable, entry); + + if (old != NULL) { + /* + * update existing entry, don't overwrite the timestamp + */ + time_t timestamp = old->sctpAssocLocalAddrStartTime; + if (timestamp == 0 && entry->sctpAssocLocalAddrStartTime == 0) + timestamp = netsnmp_get_agent_uptime(); /* set the timestamp if it was not set before */ + sctpAssocLocalAddrTable_entry_copy(entry, old); + old->sctpAssocLocalAddrStartTime = timestamp; + sctpAssocLocalAddrTable_entry_free(entry); + + } else { + /* + * the entry is new, add it there + */ + if (entry->sctpAssocLocalAddrStartTime == 0) { + entry->sctpAssocLocalAddrStartTime = + netsnmp_get_agent_uptime(); + } + CONTAINER_INSERT(localAddrTable, entry); + } + + return SNMP_ERR_NOERROR; +} + +int +sctpAssocTable_add_or_update(netsnmp_container *assocTable, + sctpAssocTable_entry * entry) +{ + /* + * we have full sctpAssocTable entry, update or add it in the container + */ + sctpAssocTable_entry *old; + + entry->valid = 1; + + /* + * try to find it in the container + */ + sctpAssocTable_entry_update_index(entry); + old = CONTAINER_FIND(assocTable, entry); + + if (old != NULL) { + /* + * update existing entry, don't overwrite the timestamp + */ + time_t timestamp = old->sctpAssocStartTime; + if (timestamp == 0 && entry->sctpAssocStartTime == 0 + && entry->sctpAssocState >= SCTPASSOCSTATE_ESTABLISHED) + timestamp = netsnmp_get_agent_uptime(); /* set the timestamp if it was not set before and entry reaches the right state */ + sctpAssocTable_entry_copy(entry, old); + old->sctpAssocStartTime = timestamp; + sctpAssocTable_entry_free(entry); + + } else { + /* + * the entry is new, add it there + */ + if (entry->sctpAssocStartTime == 0 + && entry->sctpAssocState >= SCTPASSOCSTATE_ESTABLISHED) { + entry->sctpAssocStartTime = netsnmp_get_agent_uptime(); + } + CONTAINER_INSERT(assocTable, entry); + } + + return SNMP_ERR_NOERROR; +} + +static void +sctpTables_add_local_port(sctpAssocTable_entry * assoc, + sctpTables_containers * containers) +{ + sctpLookupLocalPortTable_entry *entry; + + entry = sctpLookupLocalPortTable_entry_create(); + if (entry == NULL) { + DEBUGMSGTL(("sctp:tables:fill_lookup", + "cannot create sctpLookupLocalPortTable_entry")); + return; + } + + entry->sctpAssocId = assoc->sctpAssocId; + entry->sctpAssocLocalPort = assoc->sctpAssocLocalPort; + entry->sctpLookupLocalPortStartTime = assoc->sctpAssocStartTime; + sctpLookupLocalPortTable_entry_update_index(entry); + CONTAINER_INSERT(containers->sctpLookupLocalPortTable, entry); +} + +static void +sctpTables_add_rem_port(sctpAssocTable_entry * assoc, + sctpTables_containers * containers) +{ + sctpLookupRemPortTable_entry *entry; + + entry = sctpLookupRemPortTable_entry_create(); + if (entry == NULL) { + DEBUGMSGTL(("sctp:tables:fill_lookup", + "cannot create sctpLookupRemPortTable_entry")); + return; + } + + entry->sctpAssocId = assoc->sctpAssocId; + entry->sctpAssocRemPort = assoc->sctpAssocRemPort; + entry->sctpLookupRemPortStartTime = assoc->sctpAssocStartTime; + sctpLookupRemPortTable_entry_update_index(entry); + CONTAINER_INSERT(containers->sctpLookupRemPortTable, entry); +} + +static void +sctpTables_add_rem_hostname(sctpAssocTable_entry * assoc, + sctpTables_containers * containers) +{ + sctpLookupRemHostNameTable_entry *entry; + + if (assoc->sctpAssocRemHostName_len == 0) + return; /* the association does not know its hostname */ + + entry = sctpLookupRemHostNameTable_entry_create(); + if (entry == NULL) { + DEBUGMSGTL(("sctp:tables:fill_lookup", + "cannot create sctpLookupRemHostNameTable_entry")); + return; + } + + entry->sctpAssocId = assoc->sctpAssocId; + entry->sctpAssocRemHostName_len = assoc->sctpAssocRemHostName_len; + memcpy(entry->sctpAssocRemHostName, assoc->sctpAssocRemHostName, + assoc->sctpAssocRemHostName_len); + entry->sctpLookupRemHostNameStartTime = assoc->sctpAssocStartTime; + + sctpLookupRemHostNameTable_entry_update_index(entry); + CONTAINER_INSERT(containers->sctpLookupRemHostNameTable, entry); +} + +static void +sctpTables_add_rem_prim_ip_addr(sctpAssocTable_entry * assoc, + sctpTables_containers * containers) +{ + sctpLookupRemPrimIPAddrTable_entry *entry; + + entry = sctpLookupRemPrimIPAddrTable_entry_create(); + if (entry == NULL) { + DEBUGMSGTL(("sctp:tables:fill_lookup", + "cannot create sctpLookupRemPrimIPAddrTable_entry")); + return; + } + + entry->sctpAssocId = assoc->sctpAssocId; + entry->sctpAssocRemPrimAddrType = assoc->sctpAssocRemPrimAddrType; + entry->sctpAssocRemPrimAddr_len = assoc->sctpAssocRemPrimAddr_len; + memcpy(entry->sctpAssocRemPrimAddr, assoc->sctpAssocRemPrimAddr, + assoc->sctpAssocRemPrimAddr_len); + entry->sctpLookupRemPrimIPAddrStartTime = assoc->sctpAssocStartTime; + + sctpLookupRemPrimIPAddrTable_entry_update_index(entry); + CONTAINER_INSERT(containers->sctpLookupRemPrimIPAddrTable, entry); +} + +static void +sctpTables_fill_lookup_assoc(void *what, void *magic) +{ + sctpAssocTable_entry *entry = what; + sctpTables_containers *containers = magic; + + sctpTables_add_local_port(entry, containers); + sctpTables_add_rem_port(entry, containers); + sctpTables_add_rem_hostname(entry, containers); + sctpTables_add_rem_prim_ip_addr(entry, containers); +} + +static void +sctpTables_add_rem_ip_addr(sctpAssocRemAddrTable_entry * rem_addr, + sctpTables_containers * containers) +{ + sctpLookupRemIPAddrTable_entry *entry; + + entry = sctpLookupRemIPAddrTable_entry_create(); + if (entry == NULL) { + DEBUGMSGTL(("sctp:tables:fill_lookup", + "cannot create sctpLookupRemIPAddrTable_entry")); + return; + } + + entry->sctpAssocId = rem_addr->sctpAssocId; + entry->sctpAssocRemAddrType = rem_addr->sctpAssocRemAddrType; + entry->sctpAssocRemAddr_len = rem_addr->sctpAssocRemAddr_len; + memcpy(entry->sctpAssocRemAddr, rem_addr->sctpAssocRemAddr, + rem_addr->sctpAssocRemAddr_len); + entry->sctpLookupRemIPAddrStartTime = + rem_addr->sctpAssocRemAddrStartTime; + + sctpLookupRemIPAddrTable_entry_update_index(entry); + CONTAINER_INSERT(containers->sctpLookupRemIPAddrTable, entry); +} + +static void +sctpTables_fill_lookup_rem_addr(void *what, void *magic) +{ + sctpAssocRemAddrTable_entry *entry = what; + sctpTables_containers *containers = magic; + sctpTables_add_rem_ip_addr(entry, containers); +} + +int +sctpTables_fill_lookup(sctpTables_containers * containers) +{ + /* + * clear all the lookup tables + */ + sctpLookupLocalPortTable_container_clear(containers-> + sctpLookupLocalPortTable); + sctpLookupRemPortTable_container_clear(containers-> + sctpLookupRemPortTable); + sctpLookupRemHostNameTable_container_clear(containers-> + sctpLookupRemHostNameTable); + sctpLookupRemPrimIPAddrTable_container_clear(containers-> + sctpLookupRemPrimIPAddrTable); + sctpLookupRemIPAddrTable_container_clear(containers-> + sctpLookupRemIPAddrTable); + + /* + * fill the lookup tables + */ + CONTAINER_FOR_EACH(containers->sctpAssocTable, + sctpTables_fill_lookup_assoc, containers); + CONTAINER_FOR_EACH(containers->sctpAssocRemAddrTable, + sctpTables_fill_lookup_rem_addr, containers); + + return SNMP_ERR_NOERROR; +} + + + +int +sctpTables_load(void) +{ + sctpTables_containers containers; + int ret; + u_long flags = 0; + + containers.sctpAssocTable = sctpAssocTable_get_container(); + containers.sctpAssocRemAddrTable = + sctpAssocRemAddrTable_get_container(); + containers.sctpAssocLocalAddrTable = + sctpAssocLocalAddrTable_get_container(); + containers.sctpLookupLocalPortTable = + sctpLookupLocalPortTable_get_container(); + containers.sctpLookupRemPortTable = + sctpLookupRemPortTable_get_container(); + containers.sctpLookupRemHostNameTable = + sctpLookupRemHostNameTable_get_container(); + containers.sctpLookupRemPrimIPAddrTable = + sctpLookupRemPrimIPAddrTable_get_container(); + containers.sctpLookupRemIPAddrTable = + sctpLookupRemIPAddrTable_get_container(); + + ret = sctpTables_arch_load(&containers, &flags); + + if (flags | SCTP_TABLES_LOAD_FLAG_DELETE_INVALID) { + sctpAssocTable_delete_invalid(containers.sctpAssocTable); + sctpAssocRemAddrTable_delete_invalid(containers. + sctpAssocRemAddrTable); + sctpAssocLocalAddrTable_delete_invalid(containers. + sctpAssocLocalAddrTable); + } + + if (flags | SCTP_TABLES_LOAD_FLAG_AUTO_LOOKUP) { + ret = sctpTables_fill_lookup(&containers); + } + + return ret; +} Index: agent/mibgroup/sctp-mib/sctpAssocRemAddrTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpAssocRemAddrTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpAssocRemAddrTable.h (revision 17153) @@ -0,0 +1,71 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPASSOCREMADDRTABLE_H +#define SCTPASSOCREMADDRTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpAssocRemAddrTable(void); +void shutdown_sctpAssocRemAddrTable(void); +void initialize_table_sctpAssocRemAddrTable(void); +Netsnmp_Node_Handler sctpAssocRemAddrTable_handler; + +/* + * column number definitions for table sctpAssocRemAddrTable + */ +#define COLUMN_SCTPASSOCREMADDRTYPE 1 +#define COLUMN_SCTPASSOCREMADDR 2 +#define COLUMN_SCTPASSOCREMADDRACTIVE 3 +#define COLUMN_SCTPASSOCREMADDRHBACTIVE 4 +#define COLUMN_SCTPASSOCREMADDRRTO 5 +#define COLUMN_SCTPASSOCREMADDRMAXPATHRTX 6 +#define COLUMN_SCTPASSOCREMADDRRTX 7 +#define COLUMN_SCTPASSOCREMADDRSTARTTIME 8 + + +#define SCTP_ASSOC_REM_ADDR_TABLE_INDEX_SIZE 100 +/** Typical data structure for a row entry */ +struct sctpAssocRemAddrTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_ASSOC_REM_ADDR_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocId; + u_long sctpAssocRemAddrType; + char sctpAssocRemAddr[SCTP_IPADDRESS_SIZE]; + u_long sctpAssocRemAddr_len; + + /* + * Column values + */ + long sctpAssocRemAddrActive; + long sctpAssocRemAddrHBActive; + u_long sctpAssocRemAddrRTO; + u_long sctpAssocRemAddrMaxPathRtx; + u_long sctpAssocRemAddrRtx; + u_long sctpAssocRemAddrStartTime; + + int valid; +}; + +sctpAssocRemAddrTable_entry *sctpAssocRemAddrTable_entry_create(void); +int +sctpAssocRemAddrTable_entry_update_index(sctpAssocRemAddrTable_entry * + entry); +void +sctpAssocRemAddrTable_entry_copy(sctpAssocRemAddrTable_entry * from, + sctpAssocRemAddrTable_entry * to); +void +sctpAssocRemAddrTable_entry_free(sctpAssocRemAddrTable_entry * entry); + +void +sctpAssocRemAddrTable_container_clear(netsnmp_container *container); + +#endif /* SCTPASSOCREMADDRTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpLookupRemHostNameTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemHostNameTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemHostNameTable.c (revision 17153) @@ -0,0 +1,278 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpLookupRemHostNameTable.h" + +static netsnmp_container *sctpLookupRemHostNameTable_container; + +/** Initializes the sctpLookupRemHostNameTable module */ +void +init_sctpLookupRemHostNameTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpLookupRemHostNameTable(); +} + +void +shutdown_sctpLookupRemHostNameTable(void) +{ + sctpLookupRemHostNameTable_container_clear + (sctpLookupRemHostNameTable_container); +} + +/** Initialize the sctpLookupRemHostNameTable table by defining its contents and how it's structured */ +void +initialize_table_sctpLookupRemHostNameTable(void) +{ + static oid sctpLookupRemHostNameTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 8 }; + size_t sctpLookupRemHostNameTable_oid_len = + OID_LENGTH(sctpLookupRemHostNameTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpLookupRemHostNameTable", + sctpLookupRemHostNameTable_handler, + sctpLookupRemHostNameTable_oid, + sctpLookupRemHostNameTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpLookupRemHostNameTable\n"); + goto bail; + } + + container = + netsnmp_container_find + ("sctpLookupRemHostNameTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpLookupRemHostNameTable\n"); + goto bail; + } + sctpLookupRemHostNameTable_container = container; + + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemHostNameTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_OCTET_STR, /* index: sctpAssocRemHostName */ + ASN_UNSIGNED, /* index: sctpAssocId */ + 0); + table_info->min_column = COLUMN_SCTPLOOKUPREMHOSTNAMESTARTTIME; + table_info->max_column = COLUMN_SCTPLOOKUPREMHOSTNAMESTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemHostNameTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpLookupRemHostNameTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpLookupRemHostNameTable\n"); + goto bail; + } + + /* + * Initialise the contents of the table here + */ + + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + +/** handles requests for the sctpLookupRemHostNameTable table */ +int +sctpLookupRemHostNameTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpLookupRemHostNameTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpLookupRemHostNameTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpLookupRemHostNameTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPLOOKUPREMHOSTNAMESTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpLookupRemHostNameStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpLookupRemHostNameTable_entry * +sctpLookupRemHostNameTable_entry_create(void) +{ + sctpLookupRemHostNameTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpLookupRemHostNameTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_LOOKUP_REM_HOST_NAME_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpLookupRemHostNameTable_entry_update_index + (sctpLookupRemHostNameTable_entry * entry) +{ + netsnmp_variable_list var_sctpAssocRemHostName; + netsnmp_variable_list var_sctpAssocId; + int err = 0; + + /* + * prepare the value to be converted + */ + memset(&var_sctpAssocRemHostName, 0, sizeof(var_sctpAssocRemHostName)); + var_sctpAssocRemHostName.type = ASN_OCTET_STR; + var_sctpAssocRemHostName.next_variable = &var_sctpAssocId; + snmp_set_var_value(&var_sctpAssocRemHostName, + (u_char *) & entry->sctpAssocRemHostName, + entry->sctpAssocRemHostName_len); + + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + var_sctpAssocId.next_variable = NULL; + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocRemHostName); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocRemHostName); + + return err; +} + +void +sctpLookupRemHostNameTable_entry_copy(sctpLookupRemHostNameTable_entry * + from, + sctpLookupRemHostNameTable_entry * + to) +{ + memcpy(to, from, sizeof(sctpLookupRemHostNameTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + + +void +sctpLookupRemHostNameTable_entry_free(sctpLookupRemHostNameTable_entry * + entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpLookupRemHostNameTable_get_container(void) +{ + return sctpLookupRemHostNameTable_container; +} + + +static void +sctpLookupRemHostNameTable_entry_clear(void *what, void *magic) +{ + sctpLookupRemHostNameTable_entry_free(what); +} + +void +sctpLookupRemHostNameTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpLookupRemHostNameTable_entry_clear, + NULL); +} Index: agent/mibgroup/sctp-mib/sctpAssocTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpAssocTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpAssocTable.h (revision 17153) @@ -0,0 +1,99 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPASSOCTABLE_H +#define SCTPASSOCTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpAssocTable(void); +void shutdown_sctpAssocTable(void); +void initialize_table_sctpAssocTable(void); +Netsnmp_Node_Handler sctpAssocTable_handler; + +/* + * SCTP association states + */ +#define SCTPASSOCSTATE_CLOSED 1 +#define SCTPASSOCSTATE_COOKIEWAIT 2 +#define SCTPASSOCSTATE_COOKIEECHOED 3 +#define SCTPASSOCSTATE_ESTABLISHED 4 +#define SCTPASSOCSTATE_SHUTDOWNPENDING 5 +#define SCTPASSOCSTATE_SHUTDOWNSENT 6 +#define SCTPASSOCSTATE_SHUTDOWNRECEIVED 7 +#define SCTPASSOCSTATE_SHUTDOWNACKSENT 8 +#define SCTPASSOCSTATE_DELETETCB 9 + +/* + * column number definitions for table sctpAssocTable + */ +#define COLUMN_SCTPASSOCID 1 +#define COLUMN_SCTPASSOCREMHOSTNAME 2 +#define COLUMN_SCTPASSOCLOCALPORT 3 +#define COLUMN_SCTPASSOCREMPORT 4 +#define COLUMN_SCTPASSOCREMPRIMADDRTYPE 5 +#define COLUMN_SCTPASSOCREMPRIMADDR 6 +#define COLUMN_SCTPASSOCHEARTBEATINTERVAL 7 +#define COLUMN_SCTPASSOCSTATE 8 +#define COLUMN_SCTPASSOCINSTREAMS 9 +#define COLUMN_SCTPASSOCOUTSTREAMS 10 +#define COLUMN_SCTPASSOCMAXRETR 11 +#define COLUMN_SCTPASSOCPRIMPROCESS 12 +#define COLUMN_SCTPASSOCT1EXPIREDS 13 +#define COLUMN_SCTPASSOCT2EXPIREDS 14 +#define COLUMN_SCTPASSOCRTXCHUNKS 15 +#define COLUMN_SCTPASSOCSTARTTIME 16 +#define COLUMN_SCTPASSOCDISCONTINUITYTIME 17 + +#define SCTP_ASSOC_TABLE_INDEX_SIZE 100 +/** Data structure for a sctpAssocTable row entry */ +struct sctpAssocTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_ASSOC_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocId; + + /* + * Column values + */ + char sctpAssocRemHostName[SCTP_HOSTNAME_SIZE]; + u_long sctpAssocRemHostName_len; + u_long sctpAssocLocalPort; + u_long sctpAssocRemPort; + u_long sctpAssocRemPrimAddrType; + char sctpAssocRemPrimAddr[SCTP_IPADDRESS_SIZE]; + u_long sctpAssocRemPrimAddr_len; + u_long sctpAssocHeartBeatInterval; + long sctpAssocState; + long old_sctpAssocState; + u_long sctpAssocInStreams; + u_long sctpAssocOutStreams; + u_long sctpAssocMaxRetr; + u_long sctpAssocPrimProcess; + u_long sctpAssocT1expireds; + u_long sctpAssocT2expireds; + u_long sctpAssocRtxChunks; + u_long sctpAssocStartTime; + u_long sctpAssocDiscontinuityTime; + + int valid; +}; + +sctpAssocTable_entry *sctpAssocTable_entry_create(void); +int sctpAssocTable_entry_update_index(sctpAssocTable_entry * + entry); +void sctpAssocTable_entry_copy(sctpAssocTable_entry * from, + sctpAssocTable_entry * to); +void sctpAssocTable_entry_free(sctpAssocTable_entry * entry); + +void sctpAssocTable_container_clear(netsnmp_container + *container); + +#endif /* SCTPASSOCTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpAssocLocalAddrTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpAssocLocalAddrTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpAssocLocalAddrTable.c (revision 17153) @@ -0,0 +1,286 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpAssocLocalAddrTable.h" + +/* + * content of the sctpAssocLocalAddrTable + */ +static netsnmp_container *sctpAssocLocalAddrTable_container; + +/** Initializes the sctpAssocLocalAddrTable module */ +void +init_sctpAssocLocalAddrTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpAssocLocalAddrTable(); +} + +void +shutdown_sctpAssocLocalAddrTable(void) +{ + sctpAssocLocalAddrTable_container_clear + (sctpAssocLocalAddrTable_container); +} + +/** Initialize the sctpAssocLocalAddrTable table by defining its contents and how it's structured */ +void +initialize_table_sctpAssocLocalAddrTable(void) +{ + static oid sctpAssocLocalAddrTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 4 }; + size_t sctpAssocLocalAddrTable_oid_len = + OID_LENGTH(sctpAssocLocalAddrTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpAssocLocalAddrTable", + sctpAssocLocalAddrTable_handler, + sctpAssocLocalAddrTable_oid, + sctpAssocLocalAddrTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpAssocLocalAddrTable\n"); + goto bail; + } + + container = + netsnmp_container_find("sctpAssocLocalAddrTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpAssocLocalAddrTable\n"); + goto bail; + } + sctpAssocLocalAddrTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpAssocLocalAddrTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index: sctpAssocId */ + ASN_INTEGER, /* index: sctpAssocLocalAddrType */ + ASN_OCTET_STR, /* index: sctpAssocLocalAddr */ + 0); + table_info->min_column = COLUMN_SCTPASSOCLOCALADDRSTARTTIME; + table_info->max_column = COLUMN_SCTPASSOCLOCALADDRSTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpAssocLocalAddrTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpAssocLocalAddrTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpAssocLocalAddrTable\n"); + goto bail; + } + + /* + * Initialise the contents of the table here + */ + + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + +/** handles requests for the sctpAssocLocalAddrTable table */ +int +sctpAssocLocalAddrTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpAssocLocalAddrTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpAssocLocalAddrTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpAssocLocalAddrTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPASSOCLOCALADDRSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpAssocLocalAddrStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpAssocLocalAddrTable_entry * +sctpAssocLocalAddrTable_entry_create(void) +{ + sctpAssocLocalAddrTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpAssocLocalAddrTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_ASSOC_LOCAL_ADDR_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpAssocLocalAddrTable_entry_update_index(sctpAssocLocalAddrTable_entry * + entry) +{ + int err = 0; + + netsnmp_variable_list var_sctpAssocId; + netsnmp_variable_list var_sctpAssocLocalAddrType; + netsnmp_variable_list var_sctpAssocLocalAddr; + + /* + * prepare the values to be converted + */ + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + memset(&var_sctpAssocLocalAddrType, 0, + sizeof(var_sctpAssocLocalAddrType)); + var_sctpAssocLocalAddrType.type = ASN_INTEGER; + memset(&var_sctpAssocLocalAddr, 0, sizeof(var_sctpAssocLocalAddr)); + var_sctpAssocLocalAddr.type = ASN_OCTET_STR; + + var_sctpAssocId.next_variable = &var_sctpAssocLocalAddrType; + var_sctpAssocLocalAddrType.next_variable = &var_sctpAssocLocalAddr; + var_sctpAssocLocalAddr.next_variable = NULL; + + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + snmp_set_var_value(&var_sctpAssocLocalAddrType, + (u_char *) & entry->sctpAssocLocalAddrType, + sizeof(entry->sctpAssocLocalAddrType)); + snmp_set_var_value(&var_sctpAssocLocalAddr, + (u_char *) & entry->sctpAssocLocalAddr, + entry->sctpAssocLocalAddr_len * + sizeof(entry->sctpAssocLocalAddr[0])); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocId); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocId); + + return err; + +} + +void +sctpAssocLocalAddrTable_entry_copy(sctpAssocLocalAddrTable_entry * from, + sctpAssocLocalAddrTable_entry * to) +{ + memcpy(to, from, sizeof(sctpAssocLocalAddrTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + +void +sctpAssocLocalAddrTable_entry_free(sctpAssocLocalAddrTable_entry * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpAssocLocalAddrTable_get_container(void) +{ + return sctpAssocLocalAddrTable_container; +} + +static void +sctpAssocLocalAddrTable_entry_clear(void *what, void *magic) +{ + sctpAssocLocalAddrTable_entry_free(what); +} + +void +sctpAssocLocalAddrTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpAssocLocalAddrTable_entry_clear, NULL); +} Index: agent/mibgroup/sctp-mib/sctpTables_common.h =================================================================== --- agent/mibgroup/sctp-mib/sctpTables_common.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpTables_common.h (revision 17153) @@ -0,0 +1,112 @@ +#ifndef SCTP_TABLES_COMMON_H +#define SCTP_TABLES_COMMON_H + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +#define SCTP_IPADDRESS_SIZE 16 +#define SCTP_HOSTNAME_SIZE 255 + +#define INETADDRESSTYPE_IPV4 1 +#define INETADDRESSTYPE_IPV6 2 + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + +#define SCTP_TABLES_CACHE_TIMEOUT 30 + +/* + * Let the platform independent part delete all entries with valid==0. + */ +#define SCTP_TABLES_LOAD_FLAG_DELETE_INVALID 1 +/* + * Let the platform independent part automatically calculate the lookup tables. + */ +#define SCTP_TABLES_LOAD_FLAG_AUTO_LOOKUP 1 + +typedef struct sctpTables_containers_s { + netsnmp_container *sctpAssocTable; + netsnmp_container *sctpAssocRemAddrTable; + netsnmp_container *sctpAssocLocalAddrTable; + netsnmp_container *sctpLookupLocalPortTable; + netsnmp_container *sctpLookupRemPortTable; + netsnmp_container *sctpLookupRemHostNameTable; + netsnmp_container *sctpLookupRemPrimIPAddrTable; + netsnmp_container *sctpLookupRemIPAddrTable; +} sctpTables_containers; + +/* + * Forward declaration of some types. + */ +typedef struct sctpAssocTable_entry_s sctpAssocTable_entry; +typedef struct sctpAssocRemAddrTable_entry_s sctpAssocRemAddrTable_entry; +typedef struct sctpAssocLocalAddrTable_entry_s + sctpAssocLocalAddrTable_entry; +typedef struct sctpLookupLocalPortTable_entry_s + sctpLookupLocalPortTable_entry; +typedef struct sctpLookupRemPortTable_entry_s sctpLookupRemPortTable_entry; +typedef struct sctpLookupRemHostNameTable_entry_s + sctpLookupRemHostNameTable_entry; +typedef struct sctpLookupRemPrimIPAddrTable_entry_s + sctpLookupRemPrimIPAddrTable_entry; +typedef struct sctpLookupRemIPAddrTable_entry_s + sctpLookupRemIPAddrTable_entry; + +extern netsnmp_container *sctpAssocTable_get_container(void); +extern netsnmp_container *sctpAssocRemAddrTable_get_container(void); +extern netsnmp_container *sctpAssocLocalAddrTable_get_container(void); +extern netsnmp_container *sctpLookupLocalPortTable_get_container(void); +extern netsnmp_container *sctpLookupRemPortTable_get_container(void); +extern netsnmp_container *sctpLookupRemHostNameTable_get_container(void); +extern netsnmp_container *sctpLookupRemPrimIPAddrTable_get_container(void); +extern netsnmp_container *sctpLookupRemIPAddrTable_get_container(void); + +/* + * Platform independent helper. Reloads all sctp table containers, uses sctpTables_arch_load internally. + */ +extern int sctpTables_load(void); + + +/* + * Platform dependent loader of sctp tables. It gets the containers with 'old' values and it must update these containers to reflect actual state. It does not matter if it decides to clear the containers and fill them from scratch or just update the entries. + * If the function wants to use automatic removal of entries with valid==0, it must set the SCTP_TABLES_LOAD_FLAG_DELETE_INVALID flag and mark all valid entries (all 'old' entries are invalid by default). + */ +extern int sctpTables_arch_load(sctpTables_containers * containers, + u_long * flags); + +/* + * Add the entry to the table or overwrite it if it already exists. + * Don't overwrite timestamp. If the timestamp is not set and it should be, + * then set it. + * + * Caller must not use the entry after calling the function, it may be freed. + */ +extern int sctpAssocTable_add_or_update(netsnmp_container *assocTable, + sctpAssocTable_entry * entry); + +/* + * Add the entry to the table or overwrite it if it already exists. + * Don't overwrite timestamp. If the timestamp is not set and it should be, + * then set it. + * + * Caller must not use the entry after calling the function, it may be freed. + */ +extern int sctpAssocRemAddrTable_add_or_update(netsnmp_container + *remAddrTable, + sctpAssocRemAddrTable_entry + * entry); + +/* + * Add the entry to the table or overwrite it if it already exists. + * Don't overwrite timestamp. If the timestamp is not set and it should be, + * then set it. + * + * Caller must not use the entry after calling the function, it may be freed. + */ +extern int sctpAssocLocalAddrTable_add_or_update(netsnmp_container + *localAddrTable, + sctpAssocLocalAddrTable_entry + * entry); + +#endif /* SCTP_TABLES_COMMON_H */ Index: agent/mibgroup/sctp-mib/sctpScalars.c =================================================================== --- agent/mibgroup/sctp-mib/sctpScalars.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpScalars.c (revision 17153) @@ -0,0 +1,314 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include "sctpScalars.h" +#include "sctpScalars_common.h" + +oid sctp_stats_oid[] = { 1, 3, 6, 1, 2, 1, 104, 1, 1 }; +oid sctp_params_oid[] = { 1, 3, 6, 1, 2, 1, 104, 1, 2 }; + +/** Initializes the sctp_scalars module */ +void +init_sctpScalars(void) +{ + netsnmp_handler_registration *reginfo_stats; + netsnmp_handler_registration *reginfo_params; + + DEBUGMSGTL(("sctp:scalars:init", "Initializing\n")); + + reginfo_stats = + netsnmp_create_handler_registration("sctpStats", + sctp_stats_handler, + sctp_stats_oid, + OID_LENGTH(sctp_stats_oid), + HANDLER_CAN_RONLY); + netsnmp_register_scalar_group(reginfo_stats, SCTP_CURRESTAB, + SCTP_DISCONTINUITYTIME); + netsnmp_inject_handler(reginfo_stats, + netsnmp_get_cache_handler + (SCTP_STATS_CACHE_TIMEOUT, + netsnmp_access_sctp_stats_load, + netsnmp_access_sctp_stats_free, sctp_stats_oid, + OID_LENGTH(sctp_stats_oid))); + + + reginfo_params = + netsnmp_create_handler_registration("sctpParams", + sctp_params_handler, + sctp_params_oid, + OID_LENGTH(sctp_params_oid), + HANDLER_CAN_RONLY); + netsnmp_register_scalar_group(reginfo_params, SCTP_RTOALGORITHM, + SCTP_MAXINITRETR); + netsnmp_inject_handler(reginfo_params, + netsnmp_get_cache_handler + (SCTP_PARAMS_CACHE_TIMEOUT, + netsnmp_access_sctp_params_load, + netsnmp_access_sctp_params_free, + sctp_params_oid, OID_LENGTH(sctp_params_oid))); +} + +/** + * Handle request for sctpStats. + * Handles only one request at a time, serialize_handler is automatically added by netsnmp_register_scalar_group. + */ +int +sctp_stats_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *request) +{ + netsnmp_variable_list *requestvb; + int subid; + int ret; + + DEBUGMSGTL(("sctp:scalars:stats", "Handler - mode %s\n", + se_find_label_in_slist("agent_mode", reqinfo->mode))); + if (reqinfo->mode != MODE_GET) { + snmp_log(LOG_WARNING, "sctp/stats: Unsupported mode (%d)\n", + reqinfo->mode); + return SNMP_ERR_NOERROR; + } + + requestvb = request->requestvb; + subid = requestvb->name[OID_LENGTH(sctp_stats_oid)]; + DEBUGMSGTL(("sctp:scalars:stats", "oid: ")); + DEBUGMSGOID(("sctp:scalars:stats", requestvb->name, + requestvb->name_length)); + DEBUGMSG(("sctp:scalars:stats", "\n")); + + + /* + * Load the cache if it was not loaded before + */ + if (!netsnmp_cache_is_valid(reqinfo, reginfo->handlerName)) { + DEBUGMSGTL(("sctp:scalars:stats", "cache is not valid!\n")); + ret = netsnmp_access_sctp_stats_load(NULL, NULL); + if (ret < 0) { + DEBUGMSGTL(("sctp:scalars:stats", + "could not load sctp stats!\n")); + netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT); + return SNMP_ERR_NOERROR; + } + } + + switch (subid) { + + case SCTP_CURRESTAB: + snmp_set_var_typed_value(request->requestvb, ASN_GAUGE, + (u_char *) & sctp_stats.curr_estab, + sizeof(sctp_stats.curr_estab)); + break; + + case SCTP_ACTIVEESTABS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER, + (u_char *) & sctp_stats.active_estabs, + sizeof(sctp_stats.active_estabs)); + break; + + case SCTP_PASSIVEESTABS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER, + (u_char *) & sctp_stats.passive_estabs, + sizeof(sctp_stats.passive_estabs)); + break; + + case SCTP_ABORTEDS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER, + (u_char *) & sctp_stats.aborteds, + sizeof(sctp_stats.aborteds)); + break; + + case SCTP_SHUTDOWNS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER, + (u_char *) & sctp_stats.shutdowns, + sizeof(sctp_stats.shutdowns)); + break; + + case SCTP_OUTOFBLUES: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER, + (u_char *) & sctp_stats.out_of_blues, + sizeof(sctp_stats.out_of_blues)); + break; + + case SCTP_CHECKSUMERRORS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER, + (u_char *) & sctp_stats.checksum_errors, + sizeof(sctp_stats.checksum_errors)); + break; + + case SCTP_OUTCTRLCHUNKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.out_ctrl_chunks, + sizeof(sctp_stats.out_ctrl_chunks)); + break; + + case SCTP_OUTORDERCHUNKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.out_order_chunks, + sizeof(sctp_stats.out_order_chunks)); + break; + + case SCTP_OUTUNORDERCHUNKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & + sctp_stats.out_unorder_chunks, + sizeof(sctp_stats.out_unorder_chunks)); + break; + + case SCTP_INCTRLCHUNKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.in_ctrl_chunks, + sizeof(sctp_stats.in_ctrl_chunks)); + break; + + case SCTP_INORDERCHUNKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.in_order_chunks, + sizeof(sctp_stats.in_order_chunks)); + break; + + case SCTP_INUNORDERCHUNKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.in_unorder_chunks, + sizeof(sctp_stats.in_unorder_chunks)); + break; + + case SCTP_FRAGUSRMSGS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.frag_usr_msgs, + sizeof(sctp_stats.frag_usr_msgs)); + break; + + case SCTP_REASMUSRMSGS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.reasm_usr_msgs, + sizeof(sctp_stats.reasm_usr_msgs)); + break; + + case SCTP_OUTSCTPPACKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.out_sctp_packs, + sizeof(sctp_stats.out_sctp_packs)); + break; + + case SCTP_INSCTPPACKS: + snmp_set_var_typed_value(request->requestvb, ASN_COUNTER64, + (u_char *) & sctp_stats.in_sctp_packs, + sizeof(sctp_stats.in_sctp_packs)); + break; + + case SCTP_DISCONTINUITYTIME: + snmp_set_var_typed_value(request->requestvb, ASN_TIMETICKS, + (u_char *) & + sctp_stats.discontinuity_time, + sizeof(sctp_stats.discontinuity_time)); + break; + + default: + snmp_log(LOG_WARNING, "sctp/stats: Unsupported subid (%d)\n", + subid); + break; + } + return SNMP_ERR_NOERROR; +} + + +/** + * Handle request for sctpParams. + * Handles only one request at a time, serialize_handler is automatically added by netsnmp_register_scalar_group. + */ +int +sctp_params_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *request) +{ + netsnmp_variable_list *requestvb; + int subid; + int ret; + + DEBUGMSGTL(("sctp:scalars:params", "Handler - mode %s\n", + se_find_label_in_slist("agent_mode", reqinfo->mode))); + if (reqinfo->mode != MODE_GET) { + snmp_log(LOG_WARNING, "sctp/params: Unsupported mode (%d)\n", + reqinfo->mode); + return SNMP_ERR_NOERROR; + } + + requestvb = request->requestvb; + subid = requestvb->name[OID_LENGTH(sctp_stats_oid)]; + DEBUGMSGTL(("sctp:scalars:params", "oid: ")); + DEBUGMSGOID(("sctp:scalars:params", requestvb->name, + requestvb->name_length)); + DEBUGMSG(("sctp:scalars:params", "\n")); + + /* + * Load the cache if it was not loaded before + */ + if (!netsnmp_cache_is_valid(reqinfo, reginfo->handlerName)) { + DEBUGMSGTL(("sctp:scalars:params", "cache is not valid!\n")); + ret = netsnmp_access_sctp_params_load(NULL, NULL); + if (ret < 0) { + DEBUGMSGTL(("sctp:scalars:params", + "could not load sctp stats!\n")); + netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT); + return SNMP_ERR_NOERROR; + } + } + + switch (subid) { + + case SCTP_RTOALGORITHM: + snmp_set_var_typed_value(request->requestvb, ASN_INTEGER, + (u_char *) & sctp_params.rto_algorithm, + sizeof(sctp_params.rto_algorithm)); + break; + + case SCTP_RTOMIN: + snmp_set_var_typed_value(request->requestvb, ASN_UNSIGNED, + (u_char *) & sctp_params.rto_min, + sizeof(sctp_params.rto_min)); + break; + + case SCTP_RTOMAX: + snmp_set_var_typed_value(request->requestvb, ASN_UNSIGNED, + (u_char *) & sctp_params.rto_max, + sizeof(sctp_params.rto_max)); + break; + + case SCTP_RTOINITIAL: + snmp_set_var_typed_value(request->requestvb, ASN_UNSIGNED, + (u_char *) & sctp_params.rto_initial, + sizeof(sctp_params.rto_initial)); + break; + + case SCTP_MAXASSOCS: + snmp_set_var_typed_value(request->requestvb, ASN_INTEGER, + (u_char *) & sctp_params.max_assocs, + sizeof(sctp_params.max_assocs)); + break; + + case SCTP_VALCOOKIELIFE: + snmp_set_var_typed_value(request->requestvb, ASN_UNSIGNED, + (u_char *) & sctp_params.val_cookie_life, + sizeof(sctp_params.val_cookie_life)); + break; + + case SCTP_MAXINITRETR: + snmp_set_var_typed_value(request->requestvb, ASN_UNSIGNED, + (u_char *) & sctp_params.max_init_retr, + sizeof(sctp_params.max_init_retr)); + break; + + default: + snmp_log(LOG_WARNING, "sctp/params: Unsupported subid (%d)\n", + subid); + break; + } + return SNMP_ERR_NOERROR; +} Index: agent/mibgroup/sctp-mib/sctpLookupRemHostNameTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemHostNameTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemHostNameTable.h (revision 17153) @@ -0,0 +1,64 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPLOOKUPREMHOSTNAMETABLE_H +#define SCTPLOOKUPREMHOSTNAMETABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpLookupRemHostNameTable(void); +void shutdown_sctpLookupRemHostNameTable(void); +void initialize_table_sctpLookupRemHostNameTable(void); +Netsnmp_Node_Handler sctpLookupRemHostNameTable_handler; + +/* + * column number definitions for table sctpLookupRemHostNameTable + */ +#define COLUMN_SCTPLOOKUPREMHOSTNAMESTARTTIME 1 + +#define SCTP_LOOKUP_REM_HOST_NAME_TABLE_INDEX_SIZE 270 +/** Typical data structure for a row entry */ +struct sctpLookupRemHostNameTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_LOOKUP_REM_HOST_NAME_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + char sctpAssocRemHostName[SCTP_HOSTNAME_SIZE]; + u_long sctpAssocRemHostName_len; + u_long sctpAssocId; + + /* + * Column values + */ + u_long sctpLookupRemHostNameStartTime; + + int valid; +}; + +sctpLookupRemHostNameTable_entry* +sctpLookupRemHostNameTable_entry_create(void); + +int +sctpLookupRemHostNameTable_entry_update_index(sctpLookupRemHostNameTable_entry * + entry); + +void +sctpLookupRemHostNameTable_entry_copy(sctpLookupRemHostNameTable_entry * + from, + sctpLookupRemHostNameTable_entry * + to); + +void +sctpLookupRemHostNameTable_entry_free(sctpLookupRemHostNameTable_entry * + entry); + +void +sctpLookupRemHostNameTable_container_clear(netsnmp_container *container); + +#endif /* SCTPLOOKUPREMHOSTNAMETABLE_H */ Index: agent/mibgroup/sctp-mib/sctpTables_linux.c =================================================================== --- agent/mibgroup/sctp-mib/sctpTables_linux.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpTables_linux.c (revision 17153) @@ -0,0 +1,442 @@ +#include "sctpAssocTable.h" +#include "sctpAssocLocalAddrTable.h" +#include "sctpAssocRemAddrTable.h" +#include "sctpTables_common.h" + +#include <util_funcs.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <arpa/inet.h> + +/* + * Linux provides sctp statistics in /proc/net/sctp/assoc and + * /proc/net/sctp/remaddr. The 'assoc' file covers sctpAssocTable and + * sctpAssocLocalAddrTable, the later one contains sctpAssocRemAddrTable. + * + * Linux does *not* provide *StartTime timestamps. This implementation tries + * to guess these timestamps. + */ + + +#define PROC_PREFIX "/proc" +#define ASSOC_FILE PROC_PREFIX "/net/sctp/assocs" +#define REMADDR_FILE PROC_PREFIX "/net/sctp/remaddr" + +/* + * Convert string with ipv4 or ipv6 address to provided buffer. + */ +static int +convert_address(char *token, char *addr_buffer, u_long * addr_type, + u_long * addr_len) +{ + int family; + int ret; + + if (strchr(token, ':') != NULL) { + family = AF_INET6; + *addr_type = INETADDRESSTYPE_IPV6; + *addr_len = 16; + } else { + family = AF_INET; + *addr_type = INETADDRESSTYPE_IPV4; + *addr_len = 4; + } + ret = inet_pton(family, token, addr_buffer); + + if (ret <= 0) + return SNMP_ERR_GENERR; + return SNMP_ERR_NOERROR; +} + + +/* + * Parse local address part from assoc file. It assumes that strtok will return + * these addresses. The addresses are separated by space and the list ends + * with "<->". + */ +static int +parse_assoc_local_addresses(sctpAssocTable_entry * entry, + sctpTables_containers * containers) +{ + char *token; + int ret; + /* + * parse all local addresses + */ + + while ((token = strtok(NULL, " "))) { + sctpAssocLocalAddrTable_entry *localAddr; + char *ip = token; + + if (token[0] == '<') + break; /* local addresses finished */ + + if (token[0] == '*') + ip = token + 1; + + localAddr = sctpAssocLocalAddrTable_entry_create(); + if (localAddr == NULL) + return SNMP_ERR_GENERR; + + localAddr->sctpAssocId = entry->sctpAssocId; + ret = + convert_address(ip, localAddr->sctpAssocLocalAddr, + &localAddr->sctpAssocLocalAddrType, + &localAddr->sctpAssocLocalAddr_len); + if (ret != SNMP_ERR_NOERROR) { + sctpAssocLocalAddrTable_entry_free(localAddr); + return SNMP_ERR_GENERR; + } + + ret = + sctpAssocLocalAddrTable_add_or_update(containers-> + sctpAssocLocalAddrTable, + localAddr); + if (ret != SNMP_ERR_NOERROR) + return SNMP_ERR_GENERR; + } + return SNMP_ERR_NOERROR; +} + +/* + * Parse primary remote address part from assoc file. It assumes that strtok will return + * all remote addresses. The addresses are separated by space and the list ends with \t . + */ +static int +parse_assoc_remote_addresses(sctpAssocTable_entry * entry) +{ + char *token; + int ret = SNMP_ERR_GENERR; + + while ((token = strtok(NULL, " ")) && (token[0] != '\t')) { + if (token[0] == '*') { + /* + * that's the primary address + */ + ret = + convert_address(token + 1, entry->sctpAssocRemPrimAddr, + &entry->sctpAssocRemPrimAddrType, + &entry->sctpAssocRemPrimAddr_len); + } + } + return ret; +} + +static int +parse_assoc_line(char *line, sctpTables_containers * containers) +{ + unsigned long long inode; + char *token; + int ret; + sctpAssocTable_entry *entry; + + entry = sctpAssocTable_entry_create(); + if (entry == NULL) + return SNMP_ERR_GENERR; + + token = strtok(line, " "); /* ASSOC, ignore */ + token = strtok(NULL, " "); /* SOCK, ignore */ + token = strtok(NULL, " "); /* STY, ignore */ + token = strtok(NULL, " "); /* SST, ignore */ + token = strtok(NULL, " "); /* ST */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocState = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* HBKT */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocHeartBeatInterval = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* ASSOC-ID, store */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocId = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* TX_QUEUE, ignore */ + token = strtok(NULL, " "); /* RX_QUEUE, ignore */ + token = strtok(NULL, " "); /* UID, ignore */ + + token = strtok(NULL, " "); /* INODE */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + inode = strtoull(token, NULL, 10); + entry->sctpAssocPrimProcess = get_pid_from_inode(inode); + + token = strtok(NULL, " "); /* LPORT */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocLocalPort = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* RPORT */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocRemPort = strtol(token, NULL, 10); + + ret = parse_assoc_local_addresses(entry, containers); + if (ret != SNMP_ERR_NOERROR) + goto error; + + ret = parse_assoc_remote_addresses(entry); + if (ret != SNMP_ERR_NOERROR) + goto error; + + token = strtok(NULL, " "); /* HBINT */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocHeartBeatInterval = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* INS */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocInStreams = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* OUTS */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocOutStreams = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* MAXRT */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocMaxRetr = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* T1X */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocT1expireds = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* T2X */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocT2expireds = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* RXTC */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocRtxChunks = strtol(token, NULL, 10); + + entry->sctpAssocRemHostName[0] = 0; + entry->sctpAssocRemHostName_len = 0; + entry->sctpAssocDiscontinuityTime = 0; + + ret = sctpAssocTable_add_or_update(containers->sctpAssocTable, entry); + if (ret != SNMP_ERR_NOERROR) { + DEBUGMSGTL(("sctp:tables:load:assoc", + "error adding/updating the entry in container\n")); + return ret; + } + + return SNMP_ERR_NOERROR; + + error: + if (entry != NULL) + sctpAssocTable_entry_free(entry); + return ret; +} + + +/* + * Load assocTable and localAddrTable from /proc/net/sctp/assoc. Mark all added + * or updated entries as valid (so the missing, i.e. invalid, can be deleted). + */ +static int +load_assoc(sctpTables_containers * containers) +{ + FILE *f; + char line[1024]; + int ret = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("sctp:tables:load:assoc", "arch load(linux)\n")); + + f = fopen(ASSOC_FILE, "r"); + if (f == NULL) { + DEBUGMSGTL(("sctp:tables:load:assoc", + "arch load failed: can't open" ASSOC_FILE "\n")); + return SNMP_ERR_GENERR; + } + + /* + * ignore the header. + */ + fgets(line, sizeof(line), f); + + while (fgets(line, sizeof(line), f) != NULL) { + DEBUGMSGTL(("sctp:tables:load:assoc", "processing line: %s\n", + line)); + + ret = parse_assoc_line(line, containers); + if (ret != SNMP_ERR_NOERROR) { + DEBUGMSGTL(("sctp:tables:load:assoc", + "error parsing the line\n")); + } + } + fclose(f); + + return SNMP_ERR_NOERROR; +} + + +static int +parse_remaddr_line(char *line, sctpTables_containers * containers) +{ + char *token; + int ret; + sctpAssocRemAddrTable_entry *entry; + + entry = sctpAssocRemAddrTable_entry_create(); + if (entry == NULL) + return SNMP_ERR_GENERR; + + token = strtok(line, " "); /* rem. address */ + ret = + convert_address(token, entry->sctpAssocRemAddr, + &entry->sctpAssocRemAddrType, + &entry->sctpAssocRemAddr_len); + if (ret < 0) { + ret = SNMP_ERR_GENERR; + goto error; + } + + token = strtok(NULL, " "); /* assoc id */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocId = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* hb act */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + if (token[0] == '1') + entry->sctpAssocRemAddrHBActive = TRUTHVALUE_TRUE; + else + entry->sctpAssocRemAddrHBActive = TRUTHVALUE_FALSE; + + token = strtok(NULL, " "); /* rto */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocRemAddrRTO = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* max path rtx */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocRemAddrMaxPathRtx = strtol(token, NULL, 10); + + token = strtok(NULL, " "); /* rem addr rtx */ + if (token == NULL) { + ret = SNMP_ERR_GENERR; + goto error; + } + entry->sctpAssocRemAddrRtx = strtol(token, NULL, 10); + + entry->sctpAssocRemAddrStartTime = 0; + entry->sctpAssocRemAddrActive = TRUTHVALUE_TRUE; + + ret = + sctpAssocRemAddrTable_add_or_update(containers-> + sctpAssocRemAddrTable, entry); + if (ret != SNMP_ERR_NOERROR) { + DEBUGMSGTL(("sctp:load:remaddr", + "error adding/updating the entry in container\n")); + return ret; + } + + return SNMP_ERR_NOERROR; + + error: + if (entry != NULL) + sctpAssocRemAddrTable_entry_free(entry); + return ret; +} + +/* + * Load sctpAssocRemAddrTable from /proc/net/sctp/remaddr. Mark all added + * or updated entries as valid (so the missing, i.e. invalid, can be deleted). + */ +static int +load_remaddr(sctpTables_containers * containers) +{ + FILE *f; + char line[1024]; + int ret = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("sctp:load:remaddr", "arch load(linux)\n")); + + f = fopen(REMADDR_FILE, "r"); + if (f == NULL) { + DEBUGMSGTL(("sctp:load:remaddr", + "arch load failed: can't open" REMADDR_FILE "\n")); + return SNMP_ERR_GENERR; + } + + /* + * ignore the header. + */ + fgets(line, sizeof(line), f); + + while (fgets(line, sizeof(line), f) != NULL) { + DEBUGMSGTL(("sctp:load:remaddr", "processing line: %s\n", line)); + + ret = parse_remaddr_line(line, containers); + if (ret != SNMP_ERR_NOERROR) { + DEBUGMSGTL(("sctp:load:remaddr", "error parsing the line\n")); + } + } + fclose(f); + + return SNMP_ERR_NOERROR; +} + + +int +sctpTables_arch_load(sctpTables_containers * containers, u_long * flags) +{ + int ret = SNMP_ERR_NOERROR; + + *flags |= SCTP_TABLES_LOAD_FLAG_DELETE_INVALID; + *flags |= SCTP_TABLES_LOAD_FLAG_AUTO_LOOKUP; + + ret = load_assoc(containers); + if (ret != SNMP_ERR_NOERROR) + return ret; + + ret = load_remaddr(containers); + if (ret != SNMP_ERR_NOERROR) + return ret; + + return ret; +} Index: agent/mibgroup/sctp-mib/sctpLookupRemPortTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemPortTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemPortTable.c (revision 17153) @@ -0,0 +1,267 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpLookupRemPortTable.h" + +static netsnmp_container *sctpLookupRemPortTable_container; + +/** Initializes the sctpLookupRemPortTable module */ +void +init_sctpLookupRemPortTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpLookupRemPortTable(); +} + +void +shutdown_sctpLookupRemPortTable(void) +{ + sctpLookupRemPortTable_container_clear + (sctpLookupRemPortTable_container); +} + +/** Initialize the sctpLookupRemPortTable table by defining its contents and how it's structured */ +void +initialize_table_sctpLookupRemPortTable(void) +{ + static oid sctpLookupRemPortTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 7 }; + size_t sctpLookupRemPortTable_oid_len = + OID_LENGTH(sctpLookupRemPortTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpLookupRemPortTable", + sctpLookupRemPortTable_handler, + sctpLookupRemPortTable_oid, + sctpLookupRemPortTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpLookupRemPortTable\n"); + goto bail; + } + + container = + netsnmp_container_find("sctpLookupRemPortTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpLookupRemPortTable\n"); + goto bail; + } + sctpLookupRemPortTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemPortTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index: sctpAssocRemPort */ + ASN_UNSIGNED, /* index: sctpAssocId */ + 0); + table_info->min_column = COLUMN_SCTPLOOKUPREMPORTSTARTTIME; + table_info->max_column = COLUMN_SCTPLOOKUPREMPORTSTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemPortTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpLookupRemPortTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpLookupRemPortTable\n"); + goto bail; + } + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + +/** handles requests for the sctpLookupRemPortTable table */ +int +sctpLookupRemPortTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpLookupRemPortTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpLookupRemPortTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpLookupRemPortTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPLOOKUPREMPORTSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpLookupRemPortStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpLookupRemPortTable_entry * +sctpLookupRemPortTable_entry_create(void) +{ + sctpLookupRemPortTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpLookupRemPortTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_LOOKUP_REM_PORT_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpLookupRemPortTable_entry_update_index(sctpLookupRemPortTable_entry * + entry) +{ + netsnmp_variable_list var_sctpAssocRemPort; + netsnmp_variable_list var_sctpAssocId; + int err = 0; + + /* + * prepare the value to be converted + */ + memset(&var_sctpAssocRemPort, 0, sizeof(var_sctpAssocRemPort)); + var_sctpAssocRemPort.type = ASN_UNSIGNED; + var_sctpAssocRemPort.next_variable = &var_sctpAssocId; + snmp_set_var_value(&var_sctpAssocRemPort, + (u_char *) & entry->sctpAssocRemPort, + sizeof(entry->sctpAssocRemPort)); + + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + var_sctpAssocId.next_variable = NULL; + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocRemPort); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocRemPort); + + return err; +} + +void +sctpLookupRemPortTable_entry_copy(sctpLookupRemPortTable_entry * from, + sctpLookupRemPortTable_entry * to) +{ + memcpy(to, from, sizeof(sctpLookupRemPortTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + + +void +sctpLookupRemPortTable_entry_free(sctpLookupRemPortTable_entry * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpLookupRemPortTable_get_container(void) +{ + return sctpLookupRemPortTable_container; +} + + +static void +sctpLookupRemPortTable_entry_clear(void *what, void *magic) +{ + sctpLookupRemPortTable_entry_free(what); +} + +void +sctpLookupRemPortTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpLookupRemPortTable_entry_clear, NULL); +} Index: agent/mibgroup/sctp-mib/sctpAssocLocalAddrTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpAssocLocalAddrTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpAssocLocalAddrTable.h (revision 17153) @@ -0,0 +1,60 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPASSOCLOCALADDRTABLE_H +#define SCTPASSOCLOCALADDRTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpAssocLocalAddrTable(void); +void shutdown_sctpAssocLocalAddrTable(void); +void initialize_table_sctpAssocLocalAddrTable(void); +Netsnmp_Node_Handler sctpAssocLocalAddrTable_handler; + +/* + * column number definitions for table sctpAssocLocalAddrTable + */ +#define COLUMN_SCTPASSOCLOCALADDRTYPE 1 +#define COLUMN_SCTPASSOCLOCALADDR 2 +#define COLUMN_SCTPASSOCLOCALADDRSTARTTIME 3 + +#define SCTP_ASSOC_LOCAL_ADDR_TABLE_INDEX_SIZE 100 +/** Typical data structure for a row entry */ +struct sctpAssocLocalAddrTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_ASSOC_LOCAL_ADDR_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocId; + u_long sctpAssocLocalAddrType; + char sctpAssocLocalAddr[SCTP_IPADDRESS_SIZE]; + u_long sctpAssocLocalAddr_len; + + /* + * Column values + */ + u_long sctpAssocLocalAddrStartTime; + + int valid; +}; + +sctpAssocLocalAddrTable_entry *sctpAssocLocalAddrTable_entry_create(void); +int +sctpAssocLocalAddrTable_entry_update_index(sctpAssocLocalAddrTable_entry * + entry); +void +sctpAssocLocalAddrTable_entry_copy(sctpAssocLocalAddrTable_entry * from, + sctpAssocLocalAddrTable_entry * to); +void + sctpAssocLocalAddrTable_entry_free(sctpAssocLocalAddrTable_entry * entry); + +void sctpAssocLocalAddrTable_container_clear(netsnmp_container + *container); + +#endif /* SCTPASSOCLOCALADDRTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpScalars.h =================================================================== --- agent/mibgroup/sctp-mib/sctpScalars.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpScalars.h (revision 17153) @@ -0,0 +1,23 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $ + */ +#ifndef SCTP_SCALARS_H +#define SCTP_SCALARS_H +config_require(sctp-mib/sctpScalars_common) +#if defined( linux ) +config_require(sctp-mib/sctpScalars_linux) +#else +/* + * couldn't determine the correct file! + * require a bogus file to generate an error. + */ +config_require(sctp-mib/scalars-unknown - arch) +#endif +/* + * Initialize and register the sctpStats and sctpParams handlers. + */ +extern void init_sctpScalars(void); + + +#endif /* SCTP_SCALARS_H */ Index: agent/mibgroup/sctp-mib/sctpLookupRemPortTable.h =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemPortTable.h (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemPortTable.h (revision 17153) @@ -0,0 +1,57 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ +#ifndef SCTPLOOKUPREMPORTTABLE_H +#define SCTPLOOKUPREMPORTTABLE_H + +#include "sctpTables_common.h" + +/* + * function declarations + */ +void init_sctpLookupRemPortTable(void); +void shutdown_sctpLookupRemPortTable(void); +void initialize_table_sctpLookupRemPortTable(void); +Netsnmp_Node_Handler sctpLookupRemPortTable_handler; + +/* + * column number definitions for table sctpLookupRemPortTable + */ +#define COLUMN_SCTPLOOKUPREMPORTSTARTTIME 1 + +/** Typical data structure for a row entry */ +#define SCTP_LOOKUP_REM_PORT_TABLE_INDEX_SIZE 100 +struct sctpLookupRemPortTable_entry_s { + netsnmp_index oid_index; + oid oid_tmp[SCTP_LOOKUP_REM_PORT_TABLE_INDEX_SIZE]; + + /* + * Index values + */ + u_long sctpAssocRemPort; + u_long sctpAssocId; + + /* + * Column values + */ + u_long sctpLookupRemPortStartTime; + + int valid; +}; + +sctpLookupRemPortTable_entry *sctpLookupRemPortTable_entry_create(void); + +int +sctpLookupRemPortTable_entry_update_index(sctpLookupRemPortTable_entry * + entry); +void +sctpLookupRemPortTable_entry_copy(sctpLookupRemPortTable_entry * from, + sctpLookupRemPortTable_entry * to); +void +sctpLookupRemPortTable_entry_free(sctpLookupRemPortTable_entry * entry); + +void +sctpLookupRemPortTable_container_clear(netsnmp_container *container); + +#endif /* SCTPLOOKUPREMPORTTABLE_H */ Index: agent/mibgroup/sctp-mib/sctpScalars_common.c =================================================================== --- agent/mibgroup/sctp-mib/sctpScalars_common.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpScalars_common.c (revision 17153) @@ -0,0 +1,141 @@ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +#include "sctpScalars_common.h" + +netsnmp_sctp_stats sctp_stats; +static netsnmp_sctp_stats prev_sctp_stats; + +netsnmp_sctp_params sctp_params; +static netsnmp_sctp_params prev_sctp_params; + +static int need_wrap_check = 1; + +void +netsnmp_access_sctp_stats_init() +{ + netsnmp_access_sctp_stats_arch_init(); +} + +int +netsnmp_access_sctp_stats_load(netsnmp_cache * cache, void *magic) +{ + netsnmp_sctp_stats new_stats; + int ret; + + DEBUGMSGTL(("sctp:scalars:stats:load", "called\n")); + + ret = netsnmp_access_sctp_stats_arch_load(&new_stats); + if (ret < 0) { + DEBUGMSGTL(("sctp:scalars:stats:load", "arch load failed\n")); + return ret; + } + + /* + * If we've determined that we have 64 bit counters, just copy them. + */ + if (0 == need_wrap_check) { + memcpy(&sctp_stats, &new_stats, sizeof(new_stats)); + return 0; + } + + /* + * Update 32 bit counters + */ + sctp_stats.curr_estab = new_stats.curr_estab; + sctp_stats.active_estabs = new_stats.active_estabs; + sctp_stats.passive_estabs = new_stats.passive_estabs; + sctp_stats.aborteds = new_stats.aborteds; + sctp_stats.shutdowns = new_stats.shutdowns; + sctp_stats.out_of_blues = new_stats.out_of_blues; + sctp_stats.checksum_errors = new_stats.checksum_errors; + sctp_stats.discontinuity_time = new_stats.discontinuity_time; + + /* + * Update 64 bit counters + */ + netsnmp_c64_check32_and_update(&sctp_stats.out_ctrl_chunks, + &new_stats.out_ctrl_chunks, + &prev_sctp_stats.out_ctrl_chunks, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.out_order_chunks, + &new_stats.out_order_chunks, + &prev_sctp_stats.out_order_chunks, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.out_unorder_chunks, + &new_stats.out_unorder_chunks, + &prev_sctp_stats.out_unorder_chunks, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.in_ctrl_chunks, + &new_stats.in_ctrl_chunks, + &prev_sctp_stats.in_ctrl_chunks, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.in_order_chunks, + &new_stats.in_order_chunks, + &prev_sctp_stats.in_order_chunks, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.in_unorder_chunks, + &new_stats.in_unorder_chunks, + &prev_sctp_stats.in_unorder_chunks, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.frag_usr_msgs, + &new_stats.frag_usr_msgs, + &prev_sctp_stats.frag_usr_msgs, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.reasm_usr_msgs, + &new_stats.reasm_usr_msgs, + &prev_sctp_stats.reasm_usr_msgs, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.out_sctp_packs, + &new_stats.out_sctp_packs, + &prev_sctp_stats.out_sctp_packs, + &need_wrap_check); + netsnmp_c64_check32_and_update(&sctp_stats.in_sctp_packs, + &new_stats.in_sctp_packs, + &prev_sctp_stats.in_sctp_packs, + &need_wrap_check); + + /* + * Update prev_stats for next computation. + */ + memcpy(&prev_sctp_stats, &new_stats, sizeof(new_stats)); + return 0; +} + +void +netsnmp_access_sctp_stats_free(netsnmp_cache * cache, void *magic) +{ + /* + * Do nothing + */ +} + +void +netsnmp_access_sctp_params_init() +{ + netsnmp_access_sctp_params_arch_init(); +} + +int +netsnmp_access_sctp_params_load(netsnmp_cache * cache, void *magic) +{ + int ret; + + DEBUGMSGTL(("sctp:scalars:params:load", "called\n")); + + ret = netsnmp_access_sctp_params_arch_load(&sctp_params); + if (ret < 0) { + DEBUGMSGTL(("sctp:scalars:params:load", "arch load failed\n")); + return ret; + } + return 0; +} + +void +netsnmp_access_sctp_params_free(netsnmp_cache * cache, void *magic) +{ + /* + * Do nothing + */ +} Index: agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupRemPrimIPAddrTable.c (revision 17153) @@ -0,0 +1,283 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpLookupRemPrimIPAddrTable.h" + +static netsnmp_container *sctpLookupRemPrimIPAddrTable_container; + +/** Initializes the sctpLookupRemPrimIPAddrTable module */ +void +init_sctpLookupRemPrimIPAddrTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpLookupRemPrimIPAddrTable(); +} + +void +shutdown_sctpLookupRemPrimIPAddrTable(void) +{ + sctpLookupRemPrimIPAddrTable_container_clear + (sctpLookupRemPrimIPAddrTable_container); +} + +/** Initialize the sctpLookupRemPrimIPAddrTable table by defining its contents and how it's structured */ +void +initialize_table_sctpLookupRemPrimIPAddrTable(void) +{ + static oid sctpLookupRemPrimIPAddrTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 9 }; + size_t sctpLookupRemPrimIPAddrTable_oid_len = + OID_LENGTH(sctpLookupRemPrimIPAddrTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpLookupRemPrimIPAddrTable", + sctpLookupRemPrimIPAddrTable_handler, + sctpLookupRemPrimIPAddrTable_oid, + sctpLookupRemPrimIPAddrTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpLookupRemPrimIPAddrTable\n"); + goto bail; + } + + container = + netsnmp_container_find + ("sctpLookupRemPrimIPAddrTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpLookupRemPrimIPAddrTable\n"); + goto bail; + } + sctpLookupRemPrimIPAddrTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemPrimIPAddrTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: sctpAssocRemPrimAddrType */ + ASN_OCTET_STR, /* index: sctpAssocRemPrimAddr */ + ASN_UNSIGNED, /* index: sctpAssocId */ + 0); + table_info->min_column = COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME; + table_info->max_column = COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupRemPrimIPAddrTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpLookupRemPrimIPAddrTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpLookupRemPrimIPAddrTable\n"); + goto bail; + } + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + +/** handles requests for the sctpLookupRemPrimIPAddrTable table */ +int +sctpLookupRemPrimIPAddrTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpLookupRemPrimIPAddrTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpLookupRemPrimIPAddrTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpLookupRemPrimIPAddrTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPLOOKUPREMPRIMIPADDRSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpLookupRemPrimIPAddrStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpLookupRemPrimIPAddrTable_entry * +sctpLookupRemPrimIPAddrTable_entry_create(void) +{ + sctpLookupRemPrimIPAddrTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpLookupRemPrimIPAddrTable_entry); + if (entry != NULL) { + entry->oid_index.len = + SCTP_LOOKUP_REM_PRIM_IP_ADDR_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpLookupRemPrimIPAddrTable_entry_update_index + (sctpLookupRemPrimIPAddrTable_entry * entry) +{ + netsnmp_variable_list var_sctpAssocRemPrimAddrType; + netsnmp_variable_list var_sctpAssocRemPrimAddr; + netsnmp_variable_list var_sctpAssocId; + int err = 0; + + /* + * prepare the value to be converted + */ + memset(&var_sctpAssocRemPrimAddrType, 0, + sizeof(var_sctpAssocRemPrimAddrType)); + var_sctpAssocRemPrimAddrType.type = ASN_UNSIGNED; + var_sctpAssocRemPrimAddrType.next_variable = &var_sctpAssocRemPrimAddr; + snmp_set_var_value(&var_sctpAssocRemPrimAddrType, + (u_char *) & entry->sctpAssocRemPrimAddrType, + sizeof(entry->sctpAssocRemPrimAddrType)); + + memset(&var_sctpAssocRemPrimAddr, 0, sizeof(var_sctpAssocRemPrimAddr)); + var_sctpAssocRemPrimAddr.type = ASN_OCTET_STR; + var_sctpAssocRemPrimAddr.next_variable = &var_sctpAssocId; + snmp_set_var_value(&var_sctpAssocRemPrimAddr, + (u_char *) & entry->sctpAssocRemPrimAddr, + entry->sctpAssocRemPrimAddr_len); + + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + var_sctpAssocId.next_variable = NULL; + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocRemPrimAddrType); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocRemPrimAddrType); + + return err; +} + +void +sctpLookupRemPrimIPAddrTable_entry_copy(sctpLookupRemPrimIPAddrTable_entry + * from, + sctpLookupRemPrimIPAddrTable_entry + * to) +{ + memcpy(to, from, sizeof(sctpLookupRemPrimIPAddrTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + + +void +sctpLookupRemPrimIPAddrTable_entry_free(sctpLookupRemPrimIPAddrTable_entry + * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpLookupRemPrimIPAddrTable_get_container(void) +{ + return sctpLookupRemPrimIPAddrTable_container; +} + + +static void +sctpLookupRemPrimIPAddrTable_entry_clear(void *what, void *magic) +{ + sctpLookupRemPrimIPAddrTable_entry_free(what); +} + +void +sctpLookupRemPrimIPAddrTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpLookupRemPrimIPAddrTable_entry_clear, + NULL); +} Index: agent/mibgroup/sctp-mib/sctpLookupLocalPortTable.c =================================================================== --- agent/mibgroup/sctp-mib/sctpLookupLocalPortTable.c (revision 0) +++ agent/mibgroup/sctp-mib/sctpLookupLocalPortTable.c (revision 17153) @@ -0,0 +1,273 @@ +/* + * Note: this file originally auto-generated by mib2c using + * $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include <net-snmp/agent/table_container.h> +#include "sctpLookupLocalPortTable.h" + +static netsnmp_container *sctpLookupLocalPortTable_container; + +/** Initializes the sctpLookupLocalPortTable module */ +void +init_sctpLookupLocalPortTable(void) +{ + /* + * here we initialize all the tables we're planning on supporting + */ + initialize_table_sctpLookupLocalPortTable(); +} + +void +shutdown_sctpLookupLocalPortTable(void) +{ + sctpLookupLocalPortTable_container_clear + (sctpLookupLocalPortTable_container); +} + +/** Initialize the sctpLookupLocalPortTable table by defining its contents and how it's structured */ +void +initialize_table_sctpLookupLocalPortTable(void) +{ + static oid sctpLookupLocalPortTable_oid[] = + { 1, 3, 6, 1, 2, 1, 104, 1, 6 }; + size_t sctpLookupLocalPortTable_oid_len = + OID_LENGTH(sctpLookupLocalPortTable_oid); + netsnmp_handler_registration *reg = NULL; + netsnmp_mib_handler *handler = NULL; + netsnmp_container *container = NULL; + netsnmp_table_registration_info *table_info = NULL; + + reg = + netsnmp_create_handler_registration("sctpLookupLocalPortTable", + sctpLookupLocalPortTable_handler, + sctpLookupLocalPortTable_oid, + sctpLookupLocalPortTable_oid_len, + HANDLER_CAN_RONLY); + if (NULL == reg) { + snmp_log(LOG_ERR, + "error creating handler registration for sctpLookupLocalPortTable\n"); + goto bail; + } + + container = + netsnmp_container_find("sctpLookupLocalPortTable:table_container"); + if (NULL == container) { + snmp_log(LOG_ERR, + "error creating container for sctpLookupLocalPortTable\n"); + goto bail; + } + sctpLookupLocalPortTable_container = container; + + table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); + if (NULL == table_info) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupLocalPortTable\n"); + goto bail; + } + netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED, /* index: sctpAssocLocalPort */ + ASN_UNSIGNED, /* index: sctpAssocId */ + 0); + table_info->min_column = COLUMN_SCTPLOOKUPLOCALPORTSTARTTIME; + table_info->max_column = COLUMN_SCTPLOOKUPLOCALPORTSTARTTIME; + + /************************************************* + * + * inject container_table helper + */ + handler = netsnmp_container_table_handler_get(table_info, container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + if (NULL == handler) { + snmp_log(LOG_ERR, + "error allocating table registration for sctpLookupLocalPortTable\n"); + goto bail; + } + if (SNMPERR_SUCCESS != netsnmp_inject_handler(reg, handler)) { + snmp_log(LOG_ERR, + "error injecting container_table handler for sctpLookupLocalPortTable\n"); + goto bail; + } + handler = NULL; /* reg has it, will reuse below */ + + /* + * register the table + */ + if (SNMPERR_SUCCESS != netsnmp_register_table(reg, table_info)) { + snmp_log(LOG_ERR, + "error registering table handler for sctpLookupLocalPortTable\n"); + goto bail; + } + + /* + * Initialise the contents of the table here + */ + + + return; /* ok */ + + /* + * Some error occurred during registration. Clean up and bail. + */ + bail: /* not ok */ + + if (handler) + netsnmp_handler_free(handler); + +/* if (table_info) + netsnmp_table_registration_info_free(table_info); +*/ + if (container) + CONTAINER_FREE(container); + + if (reg) + netsnmp_handler_registration_free(reg); +} + + +/** handles requests for the sctpLookupLocalPortTable table */ +int +sctpLookupLocalPortTable_handler(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + sctpLookupLocalPortTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_entry = (sctpLookupLocalPortTable_entry *) + netsnmp_container_table_extract_context(request); + table_info = netsnmp_extract_table_info(request); + if ((NULL == table_entry) || (NULL == table_info)) { + snmp_log(LOG_ERR, + "could not extract table entry or info for sctpLookupLocalPortTable\n"); + snmp_set_var_typed_value(request->requestvb, + SNMP_ERR_GENERR, NULL, 0); + continue; + } + + switch (table_info->colnum) { + case COLUMN_SCTPLOOKUPLOCALPORTSTARTTIME: + if (!table_entry) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer(request->requestvb, + ASN_TIMETICKS, + table_entry->sctpLookupLocalPortStartTime); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} + +sctpLookupLocalPortTable_entry * +sctpLookupLocalPortTable_entry_create(void) +{ + sctpLookupLocalPortTable_entry *entry = + SNMP_MALLOC_TYPEDEF(sctpLookupLocalPortTable_entry); + if (entry != NULL) { + entry->oid_index.len = SCTP_LOOKUP_LOCAL_PORT_TABLE_INDEX_SIZE; + entry->oid_index.oids = entry->oid_tmp; + } + + return entry; +} + +int +sctpLookupLocalPortTable_entry_update_index(sctpLookupLocalPortTable_entry + * entry) +{ + netsnmp_variable_list var_sctpAssocLocalPort; + netsnmp_variable_list var_sctpAssocId; + int err = 0; + + /* + * prepare the value to be converted + */ + memset(&var_sctpAssocLocalPort, 0, sizeof(var_sctpAssocLocalPort)); + var_sctpAssocLocalPort.type = ASN_UNSIGNED; + var_sctpAssocLocalPort.next_variable = &var_sctpAssocId; + snmp_set_var_value(&var_sctpAssocLocalPort, + (u_char *) & entry->sctpAssocLocalPort, + sizeof(entry->sctpAssocLocalPort)); + + memset(&var_sctpAssocId, 0, sizeof(var_sctpAssocId)); + var_sctpAssocId.type = ASN_UNSIGNED; + var_sctpAssocId.next_variable = NULL; + snmp_set_var_value(&var_sctpAssocId, (u_char *) & entry->sctpAssocId, + sizeof(entry->sctpAssocId)); + + /* + * convert it + */ + err = + build_oid_noalloc(entry->oid_index.oids, entry->oid_index.len, + &entry->oid_index.len, NULL, 0, + &var_sctpAssocLocalPort); + if (err) + snmp_log(LOG_ERR, "error %d converting index to oid\n", err); + + /* + * release any memory allocated during the conversion + */ + snmp_reset_var_buffers(&var_sctpAssocLocalPort); + + return err; +} + +void +sctpLookupLocalPortTable_entry_copy(sctpLookupLocalPortTable_entry * from, + sctpLookupLocalPortTable_entry * to) +{ + memcpy(to, from, sizeof(sctpLookupLocalPortTable_entry)); + to->oid_index.oids = to->oid_tmp; +} + + +void +sctpLookupLocalPortTable_entry_free(sctpLookupLocalPortTable_entry * entry) +{ + if (entry != NULL) + SNMP_FREE(entry); +} + +netsnmp_container * +sctpLookupLocalPortTable_get_container(void) +{ + return sctpLookupLocalPortTable_container; +} + + +static void +sctpLookupLocalPortTable_entry_clear(void *what, void *magic) +{ + sctpLookupLocalPortTable_entry_free(what); +} + +void +sctpLookupLocalPortTable_container_clear(netsnmp_container *container) +{ + CONTAINER_CLEAR(container, sctpLookupLocalPortTable_entry_clear, NULL); +} Index: agent/mibgroup/sctp-mib.h =================================================================== --- agent/mibgroup/sctp-mib.h (revision 0) +++ agent/mibgroup/sctp-mib.h (revision 17153) @@ -0,0 +1,3 @@ +config_require(sctp-mib/sctpScalars) +config_require(sctp-mib/sctpTables) +config_add_mib(SCTP-MIB)