1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-18 08:02:48 +00:00

Introduce SCTP-MIB patch for FreeBSD.

This patch was already submitted to upstream.

Submitted by:	rrs
This commit is contained in:
Jun Kuriyama 2009-01-25 14:19:16 +00:00
parent 6090af05b0
commit 53bb537d6a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=226846
18 changed files with 894 additions and 2 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= snmp
PORTVERSION= 5.4.2.1
PORTREVISION= 1
CATEGORIES= net-mgmt ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp
@ -92,7 +93,7 @@ NET_SNMP_LOGFILE?= /var/log/snmpd.log
NET_SNMP_PERSISTENTDIR?=/var/net-snmp
NET_SNMP_MIB_MODULES?= ${NET_SNMP_MIB_MODULE_LIST}
NET_SNMP_MIB_MODULE_LIST=host disman/event-mib smux mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio
NET_SNMP_MIB_MODULE_LIST=host disman/event-mib smux mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio sctp-mib
.if defined(WITH_MFD_REWRITES)
CONFIGURE_ARGS+=--enable-mfd-rewrites

View File

@ -0,0 +1,34 @@
--- agent/helpers/cache_handler.c.orig 2009-01-25 22:40:13.000000000 +0900
+++ agent/helpers/cache_handler.c 2009-01-25 22:44:30.000000000 +0900
@@ -173,6 +173,31 @@
return cache;
}
+/** frees a cache
+ */
+int
+netsnmp_cache_free(netsnmp_cache *cache)
+{
+ netsnmp_cache *pos;
+
+ if (NULL == cache)
+ return SNMPERR_SUCCESS;
+
+ for (pos = cache_head; pos; pos = pos->next) {
+ if (pos == cache) {
+ snmp_log(LOG_WARNING, "not freeing cache (still in list)\n");
+ return SNMP_ERR_GENERR;
+ }
+ }
+
+ if (cache->rootoid)
+ free(cache->rootoid);
+
+ free(cache);
+
+ return SNMPERR_SUCCESS;
+}
+
/** callback function to call cache load function */
static void
_timer_reload(unsigned int regNo, void *clientargs)

View File

@ -0,0 +1,11 @@
--- include/net-snmp/agent/cache_handler.h.orig 2009-01-25 22:37:09.000000000 +0900
+++ include/net-snmp/agent/cache_handler.h 2009-01-25 22:38:07.000000000 +0900
@@ -85,6 +85,8 @@
netsnmp_cache_create(int timeout, NetsnmpCacheLoad * load_hook,
NetsnmpCacheFree * free_hook,
oid * rootoid, int rootoid_len);
+ int netsnmp_cache_free(netsnmp_cache *cache);
+
netsnmp_mib_handler *
netsnmp_cache_handler_get(netsnmp_cache* cache);

View File

@ -0,0 +1,11 @@
--- configure.orig 2009-01-25 21:34:07.000000000 +0900
+++ configure 2009-01-25 21:34:30.000000000 +0900
@@ -6074,7 +6074,7 @@
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
+ inttypes.h stdint.h unistd.h stdarg.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_header" >&5

View File

@ -0,0 +1,11 @@
--- agent/mibgroup/sctp-mib/sctpScalars.h.orig 2009-01-23 23:43:37.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpScalars.h 2009-01-23 23:44:12.000000000 +0900
@@ -7,6 +7,8 @@
config_require(sctp-mib/sctpScalars_common)
#if defined( linux )
config_require(sctp-mib/sctpScalars_linux)
+#elif defined ( freebsd7 )
+config_require(sctp-mib/sctpScalars_freebsd)
#else
/*
* couldn't determine the correct file!

View File

@ -0,0 +1,106 @@
--- agent/mibgroup/sctp-mib/sctpScalars_freebsd.c.orig 1970-01-01 09:00:00.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpScalars_freebsd.c 2009-01-23 23:49:22.000000000 +0900
@@ -0,0 +1,103 @@
+#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>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_constants.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"
+
+void
+netsnmp_access_sctp_stats_arch_init()
+{
+}
+
+int
+netsnmp_access_sctp_stats_arch_load(netsnmp_sctp_stats * sctp_stats)
+{
+ struct sctpstat stat;
+ size_t len = sizeof(struct sctpstat);
+
+ if (sysctlbyname("net.inet.sctp.stats", &stat, &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ memset(sctp_stats, 0, sizeof(netsnmp_sctp_stats));
+ sctp_stats->curr_estab = stat.sctps_currestab;
+ sctp_stats->active_estabs = stat.sctps_activeestab;
+ sctp_stats->passive_estabs = stat.sctps_passiveestab;
+ sctp_stats->aborteds = stat.sctps_aborted;
+ sctp_stats->shutdowns = stat.sctps_shutdown;
+ sctp_stats->out_of_blues = stat.sctps_outoftheblue;
+ sctp_stats->checksum_errors = stat.sctps_checksumerrors;
+ sctp_stats->out_ctrl_chunks.low = stat.sctps_outcontrolchunks;
+ sctp_stats->out_order_chunks.low = stat.sctps_outorderchunks;
+ sctp_stats->out_unorder_chunks.low = stat.sctps_outunorderchunks;
+ sctp_stats->in_ctrl_chunks.low = stat.sctps_incontrolchunks;
+ sctp_stats->in_order_chunks.low = stat.sctps_inorderchunks;
+ sctp_stats->in_unorder_chunks.low = stat.sctps_inunorderchunks;
+ sctp_stats->frag_usr_msgs.low = stat.sctps_fragusrmsgs;
+ sctp_stats->reasm_usr_msgs.low = stat.sctps_reasmusrmsgs;
+ sctp_stats->out_sctp_packs.low = stat.sctps_outpackets;
+ sctp_stats->in_sctp_packs.low = stat.sctps_inpackets;
+ 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;
+ size_t len = sizeof(uint32_t);
+ unsigned int cnt = 0;
+
+ sctp_params->rto_algorithm = NETSNMP_SCTP_ALGORITHM_VANJ;
+ sctp_params->max_assocs = SCTP_MAX_NUM_OF_ASOC;
+ if (sysctlbyname("net.inet.sctp.rto_max",
+ &sctp_params->rto_max,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.rto_min",
+ &sctp_params->rto_min,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.rto_initial",
+ &sctp_params->rto_initial,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.valid_cookie_life",
+ &sctp_params->val_cookie_life,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.init_rtx_max",
+ &sctp_params->max_init_retr,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ return 0;
+}

View File

@ -0,0 +1,11 @@
--- agent/mibgroup/sctp-mib/sctpTables.h.orig 2009-01-23 23:46:39.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpTables.h 2009-01-23 23:47:35.000000000 +0900
@@ -14,6 +14,8 @@
config_require(sctp-mib/sctpAssocTable)
#if defined( linux )
config_require(sctp-mib/sctpTables_linux)
+#elif defined( freebsd7 )
+config_require(sctp-mib/sctpTables_freebsd)
#else
/*
* couldn't determine the correct file!

View File

@ -0,0 +1,13 @@
--- agent/mibgroup/sctp-mib/sctpTables_common.h.orig 2009-01-23 23:42:34.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpTables_common.h 2009-01-23 23:43:11.000000000 +0900
@@ -5,6 +5,10 @@
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
+#if defined(freebsd7)
+#define netsnmp_table_registration_info_free SNMP_FREE
+#endif
+
#define SCTP_IPADDRESS_SIZE 16
#define SCTP_HOSTNAME_SIZE 255

View File

@ -0,0 +1,248 @@
--- agent/mibgroup/sctp-mib/sctpTables_freebsd.c.orig 1970-01-01 09:00:00.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpTables_freebsd.c 2009-01-23 23:52:37.000000000 +0900
@@ -0,0 +1,245 @@
+#include "sctpAssocTable.h"
+#include "sctpAssocLocalAddrTable.h"
+#include "sctpAssocRemAddrTable.h"
+#include "sctpTables_common.h"
+
+#include <util_funcs.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_constants.h>
+
+
+static int
+parse_assoc_local_addresses(sctpTables_containers * containers,
+ struct xsctp_laddr *xladdr)
+{
+ int ret;
+ sctpAssocLocalAddrTable_entry *entry;
+ entry = sctpAssocLocalAddrTable_entry_create();
+ if (entry == NULL)
+ return SNMP_ERR_GENERR;
+
+ entry->sctpAssocId = 0;
+ if (xladdr->address.sa.sa_family == AF_INET) {
+ entry->sctpAssocLocalAddrType = INETADDRESSTYPE_IPV4;
+ entry->sctpAssocLocalAddr_len = 4;
+ memcpy(entry->sctpAssocLocalAddr,
+ &xladdr->address.sin.sin_addr,
+ entry->sctpAssocLocalAddr_len);
+ } else if (xladdr->address.sa.sa_family == AF_INET6) {
+ entry->sctpAssocLocalAddrType = INETADDRESSTYPE_IPV6;
+ entry->sctpAssocLocalAddr_len = 16;
+ memcpy(entry->sctpAssocLocalAddr,
+ &xladdr->address.sin6.sin6_addr,
+ entry->sctpAssocLocalAddr_len);
+ }
+ entry->sctpAssocLocalAddrStartTime = xladdr->start_time.tv_sec;
+ ret = sctpAssocLocalAddrTable_add_or_update(containers->sctpAssocLocalAddrTable,
+ entry);
+ if (ret != SNMP_ERR_NOERROR)
+ return SNMP_ERR_GENERR;
+
+ return SNMP_ERR_NOERROR;
+}
+
+static int
+parse_assoc_xstcb(sctpTables_containers * containers, struct xsctp_tcb *xstcb)
+{
+ long inode;
+ char *token;
+ int ret;
+ sctpAssocTable_entry *entry;
+
+ entry = sctpAssocTable_entry_create();
+ if (entry == NULL)
+ return SNMP_ERR_GENERR;
+
+ switch (xstcb->state) {
+ case SCTP_STATE_INUSE:
+ entry->sctpAssocState = SCTPASSOCSTATE_DELETETCB;
+ break;
+ case SCTP_STATE_COOKIE_WAIT:
+ entry->sctpAssocState = SCTPASSOCSTATE_COOKIEWAIT;
+ break;
+ case SCTP_STATE_COOKIE_ECHOED:
+ entry->sctpAssocState = SCTPASSOCSTATE_COOKIEECHOED;
+ break;
+ case SCTP_STATE_OPEN:
+ entry->sctpAssocState = SCTPASSOCSTATE_ESTABLISHED;
+ break;
+ case SCTP_STATE_SHUTDOWN_SENT:
+ entry->sctpAssocState = SCTPASSOCSTATE_SHUTDOWNSENT;
+ break;
+ case SCTP_STATE_SHUTDOWN_RECEIVED:
+ entry->sctpAssocState = SCTPASSOCSTATE_SHUTDOWNRECEIVED;
+ break;
+ case SCTP_STATE_SHUTDOWN_ACK_SENT:
+ entry->sctpAssocState = SCTPASSOCSTATE_SHUTDOWNACKSENT;
+ break;
+ default:
+ case SCTP_STATE_EMPTY:
+ entry->sctpAssocState = SCTPASSOCSTATE_CLOSED;
+ break;
+ };
+ entry->sctpAssocHeartBeatInterval = xstcb->heartbeat_interval;
+ entry->sctpAssocId = 0;
+ entry->sctpAssocPrimProcess = xstcb->primary_process;
+ entry->sctpAssocLocalPort = xstcb->local_port;
+ entry->sctpAssocRemPort = xstcb->remote_port;
+ entry->sctpAssocHeartBeatInterval = xstcb->heartbeat_interval;
+ entry->sctpAssocInStreams = xstcb->in_streams;
+ entry->sctpAssocOutStreams = xstcb->out_streams;
+ entry->sctpAssocMaxRetr = xstcb->max_nr_retrans;
+ entry->sctpAssocT1expireds = xstcb->T1_expireries;
+ entry->sctpAssocRtxChunks = xstcb->retransmitted_tsns;
+ entry->sctpAssocT2expireds = xstcb->T2_expireries;
+ entry->sctpAssocRemHostName[0] = 0;
+ entry->sctpAssocRemHostName_len = 0;
+ entry->sctpAssocDiscontinuityTime = xstcb->discontinuity_time.tv_sec;
+ entry->sctpAssocStartTime = xstcb->start_time.tv_sec;
+
+ ret = sctpAssocTable_add_or_update(containers->sctpAssocTable, entry);
+ if (ret != SNMP_ERR_NOERROR) {
+ return ret;
+ }
+
+ return SNMP_ERR_NOERROR;
+}
+
+
+static int
+parse_remaddr_xraddr(sctpTables_containers * containers,
+ struct xsctp_raddr *xraddr)
+{
+ char *token;
+ int ret;
+ sctpAssocRemAddrTable_entry *entry;
+
+ entry = sctpAssocRemAddrTable_entry_create();
+ if (entry == NULL)
+ return SNMP_ERR_GENERR;
+
+
+ entry->sctpAssocId = 0;
+
+ if(xraddr->active)
+ entry->sctpAssocRemAddrActive = TRUTHVALUE_TRUE;
+ else
+ entry->sctpAssocRemAddrActive = TRUTHVALUE_FALSE;
+
+ if (xraddr->heartbeat_enabled)
+ entry->sctpAssocRemAddrHBActive = TRUTHVALUE_TRUE;
+ else
+ entry->sctpAssocRemAddrHBActive = TRUTHVALUE_FALSE;
+
+ entry->sctpAssocRemAddrRTO = xraddr->rto;
+ entry->sctpAssocRemAddrMaxPathRtx = xraddr->max_path_rtx;
+ entry->sctpAssocRemAddrRtx = xraddr->rtx;
+ entry->sctpAssocRemAddrStartTime = xraddr->start_time.tv_sec;
+
+ if (xraddr->address.sa.sa_family == AF_INET) {
+ entry->sctpAssocRemAddrType = INETADDRESSTYPE_IPV4;
+ entry->sctpAssocRemAddr_len = 4;
+ memcpy(entry->sctpAssocRemAddr,
+ &xraddr->address.sin.sin_addr,
+ entry->sctpAssocRemAddr_len);
+ } else if (xraddr->address.sa.sa_family == AF_INET6) {
+ entry->sctpAssocRemAddrType = INETADDRESSTYPE_IPV6;
+ entry->sctpAssocRemAddr_len = 16;
+ memcpy(entry->sctpAssocRemAddr,
+ &xraddr->address.sin6.sin6_addr,
+ entry->sctpAssocRemAddr_len);
+ }
+ ret =
+ sctpAssocRemAddrTable_add_or_update(containers->
+ sctpAssocRemAddrTable, entry);
+ if (ret != SNMP_ERR_NOERROR) {
+ return ret;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+int
+sctpTables_arch_load(sctpTables_containers * containers, u_long * flags)
+{
+ int ret = SNMP_ERR_NOERROR;
+ size_t len;
+ caddr_t buf;
+ unsigned int offset;
+ struct xsctp_inpcb *xinp;
+ struct xsctp_tcb *xstcb;
+ struct xsctp_laddr *xladdr;
+ struct xsctp_raddr *xraddr;
+ sa_family_t family;
+ void *addr;
+
+
+ *flags |= SCTP_TABLES_LOAD_FLAG_DELETE_INVALID;
+ *flags |= SCTP_TABLES_LOAD_FLAG_AUTO_LOOKUP;
+ len = 0;
+ if (sysctlbyname("net.inet.sctp.assoclist", 0, &len, 0, 0) < 0) {
+ printf("Error %d (%s) could not get the assoclist\n", errno, strerror(errno));
+ return(-1);
+ }
+ if ((buf = (caddr_t)malloc(len)) == 0) {
+ printf("malloc %lu bytes failed.\n", (long unsigned)len);
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.assoclist", buf, &len, 0, 0) < 0) {
+ printf("Error %d (%s) could not get the assoclist\n", errno, strerror(errno));
+ free(buf);
+ return(-1);
+ }
+ offset = 0;
+ xinp = (struct xsctp_inpcb *)(buf + offset);
+ while (xinp->last == 0) {
+ /* for each INP */
+ offset += sizeof(struct xsctp_inpcb);
+ /* Local addresses */
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ while (xladdr->last == 0) {
+ offset += sizeof(struct xsctp_laddr);
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_laddr);
+ /* Associations */
+ xstcb = (struct xsctp_tcb *)(buf + offset);
+ while (xstcb->last == 0) {
+ xstcb = (struct xsctp_tcb *)(buf + offset);
+ offset += sizeof(struct xsctp_tcb);
+ parse_assoc_xstcb(containers, xstcb);
+ /* Local addresses */
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ while (xladdr->last == 0) {
+ parse_assoc_local_addresses(containers, xladdr);
+ offset += sizeof(struct xsctp_laddr);
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_laddr);
+
+ /* Remote addresses */
+ xraddr = (struct xsctp_raddr *)(buf + offset);
+ while (xraddr->last == 0) {
+ parse_remaddr_xraddr(containers, xraddr);
+ offset += sizeof(struct xsctp_raddr);
+ xraddr = (struct xsctp_raddr *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_raddr);
+ xstcb = (struct xsctp_tcb *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_tcb);
+ xinp = (struct xsctp_inpcb *)(buf + offset);
+ }
+ free((void *)buf);
+ return ret;
+}

View File

@ -7,6 +7,7 @@
PORTNAME= snmp
PORTVERSION= 5.4.2.1
PORTREVISION= 1
CATEGORIES= net-mgmt ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp
@ -92,7 +93,7 @@ NET_SNMP_LOGFILE?= /var/log/snmpd.log
NET_SNMP_PERSISTENTDIR?=/var/net-snmp
NET_SNMP_MIB_MODULES?= ${NET_SNMP_MIB_MODULE_LIST}
NET_SNMP_MIB_MODULE_LIST=host disman/event-mib smux mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio
NET_SNMP_MIB_MODULE_LIST=host disman/event-mib smux mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio sctp-mib
.if defined(WITH_MFD_REWRITES)
CONFIGURE_ARGS+=--enable-mfd-rewrites

View File

@ -0,0 +1,34 @@
--- agent/helpers/cache_handler.c.orig 2009-01-25 22:40:13.000000000 +0900
+++ agent/helpers/cache_handler.c 2009-01-25 22:44:30.000000000 +0900
@@ -173,6 +173,31 @@
return cache;
}
+/** frees a cache
+ */
+int
+netsnmp_cache_free(netsnmp_cache *cache)
+{
+ netsnmp_cache *pos;
+
+ if (NULL == cache)
+ return SNMPERR_SUCCESS;
+
+ for (pos = cache_head; pos; pos = pos->next) {
+ if (pos == cache) {
+ snmp_log(LOG_WARNING, "not freeing cache (still in list)\n");
+ return SNMP_ERR_GENERR;
+ }
+ }
+
+ if (cache->rootoid)
+ free(cache->rootoid);
+
+ free(cache);
+
+ return SNMPERR_SUCCESS;
+}
+
/** callback function to call cache load function */
static void
_timer_reload(unsigned int regNo, void *clientargs)

View File

@ -0,0 +1,11 @@
--- include/net-snmp/agent/cache_handler.h.orig 2009-01-25 22:37:09.000000000 +0900
+++ include/net-snmp/agent/cache_handler.h 2009-01-25 22:38:07.000000000 +0900
@@ -85,6 +85,8 @@
netsnmp_cache_create(int timeout, NetsnmpCacheLoad * load_hook,
NetsnmpCacheFree * free_hook,
oid * rootoid, int rootoid_len);
+ int netsnmp_cache_free(netsnmp_cache *cache);
+
netsnmp_mib_handler *
netsnmp_cache_handler_get(netsnmp_cache* cache);

View File

@ -0,0 +1,11 @@
--- configure.orig 2009-01-25 21:34:07.000000000 +0900
+++ configure 2009-01-25 21:34:30.000000000 +0900
@@ -6074,7 +6074,7 @@
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
+ inttypes.h stdint.h unistd.h stdarg.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_header" >&5

View File

@ -0,0 +1,11 @@
--- agent/mibgroup/sctp-mib/sctpScalars.h.orig 2009-01-23 23:43:37.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpScalars.h 2009-01-23 23:44:12.000000000 +0900
@@ -7,6 +7,8 @@
config_require(sctp-mib/sctpScalars_common)
#if defined( linux )
config_require(sctp-mib/sctpScalars_linux)
+#elif defined ( freebsd7 )
+config_require(sctp-mib/sctpScalars_freebsd)
#else
/*
* couldn't determine the correct file!

View File

@ -0,0 +1,106 @@
--- agent/mibgroup/sctp-mib/sctpScalars_freebsd.c.orig 1970-01-01 09:00:00.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpScalars_freebsd.c 2009-01-23 23:49:22.000000000 +0900
@@ -0,0 +1,103 @@
+#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>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_constants.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"
+
+void
+netsnmp_access_sctp_stats_arch_init()
+{
+}
+
+int
+netsnmp_access_sctp_stats_arch_load(netsnmp_sctp_stats * sctp_stats)
+{
+ struct sctpstat stat;
+ size_t len = sizeof(struct sctpstat);
+
+ if (sysctlbyname("net.inet.sctp.stats", &stat, &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ memset(sctp_stats, 0, sizeof(netsnmp_sctp_stats));
+ sctp_stats->curr_estab = stat.sctps_currestab;
+ sctp_stats->active_estabs = stat.sctps_activeestab;
+ sctp_stats->passive_estabs = stat.sctps_passiveestab;
+ sctp_stats->aborteds = stat.sctps_aborted;
+ sctp_stats->shutdowns = stat.sctps_shutdown;
+ sctp_stats->out_of_blues = stat.sctps_outoftheblue;
+ sctp_stats->checksum_errors = stat.sctps_checksumerrors;
+ sctp_stats->out_ctrl_chunks.low = stat.sctps_outcontrolchunks;
+ sctp_stats->out_order_chunks.low = stat.sctps_outorderchunks;
+ sctp_stats->out_unorder_chunks.low = stat.sctps_outunorderchunks;
+ sctp_stats->in_ctrl_chunks.low = stat.sctps_incontrolchunks;
+ sctp_stats->in_order_chunks.low = stat.sctps_inorderchunks;
+ sctp_stats->in_unorder_chunks.low = stat.sctps_inunorderchunks;
+ sctp_stats->frag_usr_msgs.low = stat.sctps_fragusrmsgs;
+ sctp_stats->reasm_usr_msgs.low = stat.sctps_reasmusrmsgs;
+ sctp_stats->out_sctp_packs.low = stat.sctps_outpackets;
+ sctp_stats->in_sctp_packs.low = stat.sctps_inpackets;
+ 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;
+ size_t len = sizeof(uint32_t);
+ unsigned int cnt = 0;
+
+ sctp_params->rto_algorithm = NETSNMP_SCTP_ALGORITHM_VANJ;
+ sctp_params->max_assocs = SCTP_MAX_NUM_OF_ASOC;
+ if (sysctlbyname("net.inet.sctp.rto_max",
+ &sctp_params->rto_max,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.rto_min",
+ &sctp_params->rto_min,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.rto_initial",
+ &sctp_params->rto_initial,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.valid_cookie_life",
+ &sctp_params->val_cookie_life,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.init_rtx_max",
+ &sctp_params->max_init_retr,
+ &len, NULL, 0) < 0) {
+ return(-1);
+ }
+ return 0;
+}

View File

@ -0,0 +1,11 @@
--- agent/mibgroup/sctp-mib/sctpTables.h.orig 2009-01-23 23:46:39.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpTables.h 2009-01-23 23:47:35.000000000 +0900
@@ -14,6 +14,8 @@
config_require(sctp-mib/sctpAssocTable)
#if defined( linux )
config_require(sctp-mib/sctpTables_linux)
+#elif defined( freebsd7 )
+config_require(sctp-mib/sctpTables_freebsd)
#else
/*
* couldn't determine the correct file!

View File

@ -0,0 +1,13 @@
--- agent/mibgroup/sctp-mib/sctpTables_common.h.orig 2009-01-23 23:42:34.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpTables_common.h 2009-01-23 23:43:11.000000000 +0900
@@ -5,6 +5,10 @@
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
+#if defined(freebsd7)
+#define netsnmp_table_registration_info_free SNMP_FREE
+#endif
+
#define SCTP_IPADDRESS_SIZE 16
#define SCTP_HOSTNAME_SIZE 255

View File

@ -0,0 +1,248 @@
--- agent/mibgroup/sctp-mib/sctpTables_freebsd.c.orig 1970-01-01 09:00:00.000000000 +0900
+++ agent/mibgroup/sctp-mib/sctpTables_freebsd.c 2009-01-23 23:52:37.000000000 +0900
@@ -0,0 +1,245 @@
+#include "sctpAssocTable.h"
+#include "sctpAssocLocalAddrTable.h"
+#include "sctpAssocRemAddrTable.h"
+#include "sctpTables_common.h"
+
+#include <util_funcs.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_constants.h>
+
+
+static int
+parse_assoc_local_addresses(sctpTables_containers * containers,
+ struct xsctp_laddr *xladdr)
+{
+ int ret;
+ sctpAssocLocalAddrTable_entry *entry;
+ entry = sctpAssocLocalAddrTable_entry_create();
+ if (entry == NULL)
+ return SNMP_ERR_GENERR;
+
+ entry->sctpAssocId = 0;
+ if (xladdr->address.sa.sa_family == AF_INET) {
+ entry->sctpAssocLocalAddrType = INETADDRESSTYPE_IPV4;
+ entry->sctpAssocLocalAddr_len = 4;
+ memcpy(entry->sctpAssocLocalAddr,
+ &xladdr->address.sin.sin_addr,
+ entry->sctpAssocLocalAddr_len);
+ } else if (xladdr->address.sa.sa_family == AF_INET6) {
+ entry->sctpAssocLocalAddrType = INETADDRESSTYPE_IPV6;
+ entry->sctpAssocLocalAddr_len = 16;
+ memcpy(entry->sctpAssocLocalAddr,
+ &xladdr->address.sin6.sin6_addr,
+ entry->sctpAssocLocalAddr_len);
+ }
+ entry->sctpAssocLocalAddrStartTime = xladdr->start_time.tv_sec;
+ ret = sctpAssocLocalAddrTable_add_or_update(containers->sctpAssocLocalAddrTable,
+ entry);
+ if (ret != SNMP_ERR_NOERROR)
+ return SNMP_ERR_GENERR;
+
+ return SNMP_ERR_NOERROR;
+}
+
+static int
+parse_assoc_xstcb(sctpTables_containers * containers, struct xsctp_tcb *xstcb)
+{
+ long inode;
+ char *token;
+ int ret;
+ sctpAssocTable_entry *entry;
+
+ entry = sctpAssocTable_entry_create();
+ if (entry == NULL)
+ return SNMP_ERR_GENERR;
+
+ switch (xstcb->state) {
+ case SCTP_STATE_INUSE:
+ entry->sctpAssocState = SCTPASSOCSTATE_DELETETCB;
+ break;
+ case SCTP_STATE_COOKIE_WAIT:
+ entry->sctpAssocState = SCTPASSOCSTATE_COOKIEWAIT;
+ break;
+ case SCTP_STATE_COOKIE_ECHOED:
+ entry->sctpAssocState = SCTPASSOCSTATE_COOKIEECHOED;
+ break;
+ case SCTP_STATE_OPEN:
+ entry->sctpAssocState = SCTPASSOCSTATE_ESTABLISHED;
+ break;
+ case SCTP_STATE_SHUTDOWN_SENT:
+ entry->sctpAssocState = SCTPASSOCSTATE_SHUTDOWNSENT;
+ break;
+ case SCTP_STATE_SHUTDOWN_RECEIVED:
+ entry->sctpAssocState = SCTPASSOCSTATE_SHUTDOWNRECEIVED;
+ break;
+ case SCTP_STATE_SHUTDOWN_ACK_SENT:
+ entry->sctpAssocState = SCTPASSOCSTATE_SHUTDOWNACKSENT;
+ break;
+ default:
+ case SCTP_STATE_EMPTY:
+ entry->sctpAssocState = SCTPASSOCSTATE_CLOSED;
+ break;
+ };
+ entry->sctpAssocHeartBeatInterval = xstcb->heartbeat_interval;
+ entry->sctpAssocId = 0;
+ entry->sctpAssocPrimProcess = xstcb->primary_process;
+ entry->sctpAssocLocalPort = xstcb->local_port;
+ entry->sctpAssocRemPort = xstcb->remote_port;
+ entry->sctpAssocHeartBeatInterval = xstcb->heartbeat_interval;
+ entry->sctpAssocInStreams = xstcb->in_streams;
+ entry->sctpAssocOutStreams = xstcb->out_streams;
+ entry->sctpAssocMaxRetr = xstcb->max_nr_retrans;
+ entry->sctpAssocT1expireds = xstcb->T1_expireries;
+ entry->sctpAssocRtxChunks = xstcb->retransmitted_tsns;
+ entry->sctpAssocT2expireds = xstcb->T2_expireries;
+ entry->sctpAssocRemHostName[0] = 0;
+ entry->sctpAssocRemHostName_len = 0;
+ entry->sctpAssocDiscontinuityTime = xstcb->discontinuity_time.tv_sec;
+ entry->sctpAssocStartTime = xstcb->start_time.tv_sec;
+
+ ret = sctpAssocTable_add_or_update(containers->sctpAssocTable, entry);
+ if (ret != SNMP_ERR_NOERROR) {
+ return ret;
+ }
+
+ return SNMP_ERR_NOERROR;
+}
+
+
+static int
+parse_remaddr_xraddr(sctpTables_containers * containers,
+ struct xsctp_raddr *xraddr)
+{
+ char *token;
+ int ret;
+ sctpAssocRemAddrTable_entry *entry;
+
+ entry = sctpAssocRemAddrTable_entry_create();
+ if (entry == NULL)
+ return SNMP_ERR_GENERR;
+
+
+ entry->sctpAssocId = 0;
+
+ if(xraddr->active)
+ entry->sctpAssocRemAddrActive = TRUTHVALUE_TRUE;
+ else
+ entry->sctpAssocRemAddrActive = TRUTHVALUE_FALSE;
+
+ if (xraddr->heartbeat_enabled)
+ entry->sctpAssocRemAddrHBActive = TRUTHVALUE_TRUE;
+ else
+ entry->sctpAssocRemAddrHBActive = TRUTHVALUE_FALSE;
+
+ entry->sctpAssocRemAddrRTO = xraddr->rto;
+ entry->sctpAssocRemAddrMaxPathRtx = xraddr->max_path_rtx;
+ entry->sctpAssocRemAddrRtx = xraddr->rtx;
+ entry->sctpAssocRemAddrStartTime = xraddr->start_time.tv_sec;
+
+ if (xraddr->address.sa.sa_family == AF_INET) {
+ entry->sctpAssocRemAddrType = INETADDRESSTYPE_IPV4;
+ entry->sctpAssocRemAddr_len = 4;
+ memcpy(entry->sctpAssocRemAddr,
+ &xraddr->address.sin.sin_addr,
+ entry->sctpAssocRemAddr_len);
+ } else if (xraddr->address.sa.sa_family == AF_INET6) {
+ entry->sctpAssocRemAddrType = INETADDRESSTYPE_IPV6;
+ entry->sctpAssocRemAddr_len = 16;
+ memcpy(entry->sctpAssocRemAddr,
+ &xraddr->address.sin6.sin6_addr,
+ entry->sctpAssocRemAddr_len);
+ }
+ ret =
+ sctpAssocRemAddrTable_add_or_update(containers->
+ sctpAssocRemAddrTable, entry);
+ if (ret != SNMP_ERR_NOERROR) {
+ return ret;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+int
+sctpTables_arch_load(sctpTables_containers * containers, u_long * flags)
+{
+ int ret = SNMP_ERR_NOERROR;
+ size_t len;
+ caddr_t buf;
+ unsigned int offset;
+ struct xsctp_inpcb *xinp;
+ struct xsctp_tcb *xstcb;
+ struct xsctp_laddr *xladdr;
+ struct xsctp_raddr *xraddr;
+ sa_family_t family;
+ void *addr;
+
+
+ *flags |= SCTP_TABLES_LOAD_FLAG_DELETE_INVALID;
+ *flags |= SCTP_TABLES_LOAD_FLAG_AUTO_LOOKUP;
+ len = 0;
+ if (sysctlbyname("net.inet.sctp.assoclist", 0, &len, 0, 0) < 0) {
+ printf("Error %d (%s) could not get the assoclist\n", errno, strerror(errno));
+ return(-1);
+ }
+ if ((buf = (caddr_t)malloc(len)) == 0) {
+ printf("malloc %lu bytes failed.\n", (long unsigned)len);
+ return(-1);
+ }
+ if (sysctlbyname("net.inet.sctp.assoclist", buf, &len, 0, 0) < 0) {
+ printf("Error %d (%s) could not get the assoclist\n", errno, strerror(errno));
+ free(buf);
+ return(-1);
+ }
+ offset = 0;
+ xinp = (struct xsctp_inpcb *)(buf + offset);
+ while (xinp->last == 0) {
+ /* for each INP */
+ offset += sizeof(struct xsctp_inpcb);
+ /* Local addresses */
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ while (xladdr->last == 0) {
+ offset += sizeof(struct xsctp_laddr);
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_laddr);
+ /* Associations */
+ xstcb = (struct xsctp_tcb *)(buf + offset);
+ while (xstcb->last == 0) {
+ xstcb = (struct xsctp_tcb *)(buf + offset);
+ offset += sizeof(struct xsctp_tcb);
+ parse_assoc_xstcb(containers, xstcb);
+ /* Local addresses */
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ while (xladdr->last == 0) {
+ parse_assoc_local_addresses(containers, xladdr);
+ offset += sizeof(struct xsctp_laddr);
+ xladdr = (struct xsctp_laddr *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_laddr);
+
+ /* Remote addresses */
+ xraddr = (struct xsctp_raddr *)(buf + offset);
+ while (xraddr->last == 0) {
+ parse_remaddr_xraddr(containers, xraddr);
+ offset += sizeof(struct xsctp_raddr);
+ xraddr = (struct xsctp_raddr *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_raddr);
+ xstcb = (struct xsctp_tcb *)(buf + offset);
+ }
+ offset += sizeof(struct xsctp_tcb);
+ xinp = (struct xsctp_inpcb *)(buf + offset);
+ }
+ free((void *)buf);
+ return ret;
+}