- Fix IPv6 handling for libwrap (1).

- Show IPv4 port number as unsigned instead of signed in /var/log/snmpd.log.
- Treat physmem as u_long, not int.  This fixes hrMmemorySize over 4GB.

Submitted by:	ume (1)
Pointy hat to:	kuriyama (1)
This commit is contained in:
Jun Kuriyama 2008-01-11 23:17:32 +00:00
parent eb57fa6a10
commit dd44d4b2fb
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=205472
18 changed files with 216 additions and 78 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= snmp
PORTVERSION= 5.3.2
PORTREVISION= 0
PORTREVISION= 1
CATEGORIES= net-mgmt ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View file

@ -1,6 +1,15 @@
--- agent/mibgroup/host/hr_storage.c.orig Fri Oct 7 07:55:23 2005
+++ agent/mibgroup/host/hr_storage.c Wed Nov 30 12:01:05 2005
@@ -233,6 +233,10 @@
--- agent/mibgroup/host/hr_storage.c.orig 2007-06-08 19:33:58.000000000 +0900
+++ agent/mibgroup/host/hr_storage.c 2008-01-11 21:37:48.767962726 +0900
@@ -229,7 +229,7 @@
mach_port_t myHost;
#endif
-static int physmem, pagesize;
+static u_long physmem, pagesize;
static void parse_storage_config(const char *, char *);
/*********************
@@ -252,6 +252,10 @@
void sol_get_swapinfo(int *, int *);
#endif
@ -11,7 +20,7 @@
#define HRSTORE_MEMSIZE 1
#define HRSTORE_INDEX 2
#define HRSTORE_TYPE 3
@@ -472,7 +476,8 @@
@@ -499,7 +503,8 @@
NULL,
"Memory Buffers", /* HRS_TYPE_MBUF */
"Real Memory", /* HRS_TYPE_MEM */
@ -21,7 +30,7 @@
};
@@ -611,6 +616,7 @@
@@ -647,6 +652,7 @@
storage_type_id[storage_type_len - 1] = 3; /* Virtual Mem */
break;
case HRS_TYPE_MBUF:
@ -29,7 +38,7 @@
storage_type_id[storage_type_len - 1] = 1; /* Other */
break;
default:
@@ -704,7 +710,7 @@
@@ -752,7 +758,7 @@
long_return = memory_totals.t_vm;
#endif
break;
@ -38,7 +47,7 @@
case HRS_TYPE_MEM:
long_return = physmem;
break;
@@ -726,13 +732,45 @@
@@ -774,13 +780,45 @@
i++)
long_return += mbstat.m_mtypes[i];
#elif defined(MBSTAT_SYMBOL) && defined(STRUCT_MBSTAT_HAS_M_MBUFS)
@ -84,7 +93,7 @@
default:
#if NO_DUMMY_VALUES
goto try_next;
@@ -796,6 +834,12 @@
@@ -856,6 +894,12 @@
#endif
#elif defined(MBSTAT_SYMBOL) && defined(STRUCT_MBSTAT_HAS_M_CLUSTERS)
long_return = mbstat.m_clusters - mbstat.m_clfree; /* unlikely, but... */
@ -97,7 +106,7 @@
#elif defined(NO_DUMMY_VALUES)
goto try_next;
#else
@@ -803,6 +847,11 @@
@@ -863,6 +907,11 @@
#endif
break;
#endif /* !linux && !solaris2 && !hpux10 && !hpux11 && ... */
@ -109,7 +118,7 @@
default:
#if NO_DUMMY_VALUES
goto try_next;
@@ -829,7 +878,11 @@
@@ -889,7 +938,11 @@
break;
#if !defined(linux) && !defined(solaris2) && !defined(hpux10) && !defined(hpux11) && defined(MBSTAT_SYMBOL)
case HRS_TYPE_MBUF:
@ -121,11 +130,10 @@
break;
#endif /* !linux && !solaris2 && !hpux10 && !hpux11 && MBSTAT_SYMBOL */
default:
@@ -955,3 +1008,97 @@
*usedP = ainfo.ani_resv;
@@ -1015,6 +1068,100 @@
}
#endif /* solaris2 */
+
+#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
+void
+collect_mbuf(long *long_mbuf, long *long_mbufc)
@ -219,3 +227,7 @@
+#endif
+}
+#endif
+
#ifdef WIN32
char *win_realpath(const char *file_name, char *resolved_name)
{

View file

@ -1,12 +1,14 @@
--- snmplib/snmpTCPIPv6Domain.c.orig Sat Oct 16 03:52:29 2004
+++ snmplib/snmpTCPIPv6Domain.c Mon Oct 25 09:22:06 2004
@@ -95,13 +95,21 @@
Index: snmplib/snmpTCPIPv6Domain.c
diff -u -p snmplib/snmpTCPIPv6Domain.c.orig snmplib/snmpTCPIPv6Domain.c
--- snmplib/snmpTCPIPv6Domain.c.orig Fri Sep 16 19:30:49 2005
+++ snmplib/snmpTCPIPv6Domain.c Fri Jan 11 13:40:09 2008
@@ -96,13 +96,24 @@ netsnmp_tcp6_fmtaddr(netsnmp_transport *
if (to == NULL) {
return strdup("TCP/IPv6: unknown");
} else {
- char addr[INET6_ADDRSTRLEN];
- char tmp[INET6_ADDRSTRLEN + 8];
+ char tmp[NI_MAXHOST];
+ char addr[NI_MAXHOST], tmp[NI_MAXHOST + NI_MAXSERV + 12];
- sprintf(tmp, "TCP/IPv6: [%s]:%hd",
- inet_ntop(AF_INET6, (void *) &(to->sin6_addr), addr,
@ -20,10 +22,13 @@
+#ifndef NI_WITHSCOPEID
+#define NI_WITHSCOPEID 0
+#endif
+ if (getnameinfo(to, sizeof(struct sockaddr_in6), tmp, sizeof(tmp),
+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ if (getnameinfo((struct sockaddr *)to, sizeof(struct sockaddr_in6),
+ addr, sizeof(addr), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ return strdup("UDP/IPv6: unknown");
+ }
+ snprintf(tmp, sizeof(tmp), "TCP/IPv6: [%s]:%hd", addr,
+ ntohs(to->sin6_port));
+ return strdup(tmp);
}
}

View file

@ -1,12 +1,14 @@
--- snmplib/snmpUDPIPv6Domain.c.orig 2007-08-20 17:06:42.000000000 +0900
+++ snmplib/snmpUDPIPv6Domain.c 2007-12-21 09:58:31.316414938 +0900
@@ -103,13 +103,21 @@
Index: snmplib/snmpUDPIPv6Domain.c
diff -u -p snmplib/snmpUDPIPv6Domain.c.orig snmplib/snmpUDPIPv6Domain.c
--- snmplib/snmpUDPIPv6Domain.c.orig Mon Aug 20 17:06:42 2007
+++ snmplib/snmpUDPIPv6Domain.c Fri Jan 11 13:39:36 2008
@@ -103,13 +103,24 @@ netsnmp_udp6_fmtaddr(netsnmp_transport *
if (to == NULL) {
return strdup("UDP/IPv6: unknown");
} else {
- char addr[INET6_ADDRSTRLEN];
- char tmp[INET6_ADDRSTRLEN + 18];
+ char tmp[NI_MAXHOST];
+ char addr[NI_MAXHOST], tmp[NI_MAXHOST + NI_MAXSERV + 12];
- sprintf(tmp, "UDP/IPv6: [%s]:%hu",
- inet_ntop(AF_INET6, (void *) &(to->sin6_addr), addr,
@ -20,10 +22,13 @@
+#ifndef NI_WITHSCOPEID
+#define NI_WITHSCOPEID 0
+#endif
+ if (getnameinfo(to, sizeof(struct sockaddr_in6), tmp, sizeof(tmp),
+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ if (getnameinfo((struct sockaddr *)to, sizeof(struct sockaddr_in6),
+ addr, sizeof(addr), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ return strdup("UDP/IPv6: unknown");
+ }
+ snprintf(tmp, sizeof(tmp), "UDP/IPv6: [%s]:%hu", addr,
+ ntohs(to->sin6_port));
+ return strdup(tmp);
}
}

View file

@ -0,0 +1,11 @@
--- snmplib/snmpUDPDomain.c.orig 2008-01-11 21:53:12.214973877 +0900
+++ snmplib/snmpUDPDomain.c 2008-01-11 21:54:13.707245200 +0900
@@ -105,7 +105,7 @@
inet_ntoa(addr_pair->local_addr));
} else {
sprintf(tmp, "UDP: [%s]->", inet_ntoa(addr_pair->local_addr));
- sprintf(tmp + strlen(tmp), "[%s]:%hd",
+ sprintf(tmp + strlen(tmp), "[%s]:%hu",
inet_ntoa(to->sin_addr), ntohs(to->sin_port));
}
return strdup(tmp);

View file

@ -0,0 +1,13 @@
Index: agent/snmp_agent.c
diff -u -p agent/snmp_agent.c.orig agent/snmp_agent.c
--- agent/snmp_agent.c.orig Thu Aug 16 22:31:40 2007
+++ agent/snmp_agent.c Fri Jan 11 13:06:27 2008
@@ -819,7 +819,7 @@ netsnmp_agent_check_packet(netsnmp_sessi
}
#ifdef USE_LIBWRAP
/* Catch udp,udp6,tcp,tcp6 transports using "[" */
- tcpudpaddr = strstr(addr_string, "[");
+ tcpudpaddr = strrchr(addr_string, '[');
if ( tcpudpaddr != 0 ) {
char sbuf[64];
char *xp;

View file

@ -7,7 +7,7 @@
PORTNAME= snmp
PORTVERSION= 5.3.2
PORTREVISION= 0
PORTREVISION= 1
CATEGORIES= net-mgmt ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View file

@ -1,6 +1,15 @@
--- agent/mibgroup/host/hr_storage.c.orig Fri Oct 7 07:55:23 2005
+++ agent/mibgroup/host/hr_storage.c Wed Nov 30 12:01:05 2005
@@ -233,6 +233,10 @@
--- agent/mibgroup/host/hr_storage.c.orig 2007-06-08 19:33:58.000000000 +0900
+++ agent/mibgroup/host/hr_storage.c 2008-01-11 21:37:48.767962726 +0900
@@ -229,7 +229,7 @@
mach_port_t myHost;
#endif
-static int physmem, pagesize;
+static u_long physmem, pagesize;
static void parse_storage_config(const char *, char *);
/*********************
@@ -252,6 +252,10 @@
void sol_get_swapinfo(int *, int *);
#endif
@ -11,7 +20,7 @@
#define HRSTORE_MEMSIZE 1
#define HRSTORE_INDEX 2
#define HRSTORE_TYPE 3
@@ -472,7 +476,8 @@
@@ -499,7 +503,8 @@
NULL,
"Memory Buffers", /* HRS_TYPE_MBUF */
"Real Memory", /* HRS_TYPE_MEM */
@ -21,7 +30,7 @@
};
@@ -611,6 +616,7 @@
@@ -647,6 +652,7 @@
storage_type_id[storage_type_len - 1] = 3; /* Virtual Mem */
break;
case HRS_TYPE_MBUF:
@ -29,7 +38,7 @@
storage_type_id[storage_type_len - 1] = 1; /* Other */
break;
default:
@@ -704,7 +710,7 @@
@@ -752,7 +758,7 @@
long_return = memory_totals.t_vm;
#endif
break;
@ -38,7 +47,7 @@
case HRS_TYPE_MEM:
long_return = physmem;
break;
@@ -726,13 +732,45 @@
@@ -774,13 +780,45 @@
i++)
long_return += mbstat.m_mtypes[i];
#elif defined(MBSTAT_SYMBOL) && defined(STRUCT_MBSTAT_HAS_M_MBUFS)
@ -84,7 +93,7 @@
default:
#if NO_DUMMY_VALUES
goto try_next;
@@ -796,6 +834,12 @@
@@ -856,6 +894,12 @@
#endif
#elif defined(MBSTAT_SYMBOL) && defined(STRUCT_MBSTAT_HAS_M_CLUSTERS)
long_return = mbstat.m_clusters - mbstat.m_clfree; /* unlikely, but... */
@ -97,7 +106,7 @@
#elif defined(NO_DUMMY_VALUES)
goto try_next;
#else
@@ -803,6 +847,11 @@
@@ -863,6 +907,11 @@
#endif
break;
#endif /* !linux && !solaris2 && !hpux10 && !hpux11 && ... */
@ -109,7 +118,7 @@
default:
#if NO_DUMMY_VALUES
goto try_next;
@@ -829,7 +878,11 @@
@@ -889,7 +938,11 @@
break;
#if !defined(linux) && !defined(solaris2) && !defined(hpux10) && !defined(hpux11) && defined(MBSTAT_SYMBOL)
case HRS_TYPE_MBUF:
@ -121,11 +130,10 @@
break;
#endif /* !linux && !solaris2 && !hpux10 && !hpux11 && MBSTAT_SYMBOL */
default:
@@ -955,3 +1008,97 @@
*usedP = ainfo.ani_resv;
@@ -1015,6 +1068,100 @@
}
#endif /* solaris2 */
+
+#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
+void
+collect_mbuf(long *long_mbuf, long *long_mbufc)
@ -219,3 +227,7 @@
+#endif
+}
+#endif
+
#ifdef WIN32
char *win_realpath(const char *file_name, char *resolved_name)
{

View file

@ -1,12 +1,14 @@
--- snmplib/snmpTCPIPv6Domain.c.orig Sat Oct 16 03:52:29 2004
+++ snmplib/snmpTCPIPv6Domain.c Mon Oct 25 09:22:06 2004
@@ -95,13 +95,21 @@
Index: snmplib/snmpTCPIPv6Domain.c
diff -u -p snmplib/snmpTCPIPv6Domain.c.orig snmplib/snmpTCPIPv6Domain.c
--- snmplib/snmpTCPIPv6Domain.c.orig Fri Sep 16 19:30:49 2005
+++ snmplib/snmpTCPIPv6Domain.c Fri Jan 11 13:40:09 2008
@@ -96,13 +96,24 @@ netsnmp_tcp6_fmtaddr(netsnmp_transport *
if (to == NULL) {
return strdup("TCP/IPv6: unknown");
} else {
- char addr[INET6_ADDRSTRLEN];
- char tmp[INET6_ADDRSTRLEN + 8];
+ char tmp[NI_MAXHOST];
+ char addr[NI_MAXHOST], tmp[NI_MAXHOST + NI_MAXSERV + 12];
- sprintf(tmp, "TCP/IPv6: [%s]:%hd",
- inet_ntop(AF_INET6, (void *) &(to->sin6_addr), addr,
@ -20,10 +22,13 @@
+#ifndef NI_WITHSCOPEID
+#define NI_WITHSCOPEID 0
+#endif
+ if (getnameinfo(to, sizeof(struct sockaddr_in6), tmp, sizeof(tmp),
+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ if (getnameinfo((struct sockaddr *)to, sizeof(struct sockaddr_in6),
+ addr, sizeof(addr), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ return strdup("UDP/IPv6: unknown");
+ }
+ snprintf(tmp, sizeof(tmp), "TCP/IPv6: [%s]:%hd", addr,
+ ntohs(to->sin6_port));
+ return strdup(tmp);
}
}

View file

@ -1,12 +1,14 @@
--- snmplib/snmpUDPIPv6Domain.c.orig 2007-08-20 17:06:42.000000000 +0900
+++ snmplib/snmpUDPIPv6Domain.c 2007-12-21 09:58:31.316414938 +0900
@@ -103,13 +103,21 @@
Index: snmplib/snmpUDPIPv6Domain.c
diff -u -p snmplib/snmpUDPIPv6Domain.c.orig snmplib/snmpUDPIPv6Domain.c
--- snmplib/snmpUDPIPv6Domain.c.orig Mon Aug 20 17:06:42 2007
+++ snmplib/snmpUDPIPv6Domain.c Fri Jan 11 13:39:36 2008
@@ -103,13 +103,24 @@ netsnmp_udp6_fmtaddr(netsnmp_transport *
if (to == NULL) {
return strdup("UDP/IPv6: unknown");
} else {
- char addr[INET6_ADDRSTRLEN];
- char tmp[INET6_ADDRSTRLEN + 18];
+ char tmp[NI_MAXHOST];
+ char addr[NI_MAXHOST], tmp[NI_MAXHOST + NI_MAXSERV + 12];
- sprintf(tmp, "UDP/IPv6: [%s]:%hu",
- inet_ntop(AF_INET6, (void *) &(to->sin6_addr), addr,
@ -20,10 +22,13 @@
+#ifndef NI_WITHSCOPEID
+#define NI_WITHSCOPEID 0
+#endif
+ if (getnameinfo(to, sizeof(struct sockaddr_in6), tmp, sizeof(tmp),
+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ if (getnameinfo((struct sockaddr *)to, sizeof(struct sockaddr_in6),
+ addr, sizeof(addr), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ return strdup("UDP/IPv6: unknown");
+ }
+ snprintf(tmp, sizeof(tmp), "UDP/IPv6: [%s]:%hu", addr,
+ ntohs(to->sin6_port));
+ return strdup(tmp);
}
}

View file

@ -0,0 +1,11 @@
--- snmplib/snmpUDPDomain.c.orig 2008-01-11 21:53:12.214973877 +0900
+++ snmplib/snmpUDPDomain.c 2008-01-11 21:54:13.707245200 +0900
@@ -105,7 +105,7 @@
inet_ntoa(addr_pair->local_addr));
} else {
sprintf(tmp, "UDP: [%s]->", inet_ntoa(addr_pair->local_addr));
- sprintf(tmp + strlen(tmp), "[%s]:%hd",
+ sprintf(tmp + strlen(tmp), "[%s]:%hu",
inet_ntoa(to->sin_addr), ntohs(to->sin_port));
}
return strdup(tmp);

View file

@ -0,0 +1,13 @@
Index: agent/snmp_agent.c
diff -u -p agent/snmp_agent.c.orig agent/snmp_agent.c
--- agent/snmp_agent.c.orig Thu Aug 16 22:31:40 2007
+++ agent/snmp_agent.c Fri Jan 11 13:06:27 2008
@@ -819,7 +819,7 @@ netsnmp_agent_check_packet(netsnmp_sessi
}
#ifdef USE_LIBWRAP
/* Catch udp,udp6,tcp,tcp6 transports using "[" */
- tcpudpaddr = strstr(addr_string, "[");
+ tcpudpaddr = strrchr(addr_string, '[');
if ( tcpudpaddr != 0 ) {
char sbuf[64];
char *xp;

View file

@ -7,7 +7,7 @@
PORTNAME= snmp
PORTVERSION= 5.3.2
PORTREVISION= 0
PORTREVISION= 1
CATEGORIES= net-mgmt ipv6
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= net-snmp

View file

@ -1,6 +1,15 @@
--- agent/mibgroup/host/hr_storage.c.orig Fri Oct 7 07:55:23 2005
+++ agent/mibgroup/host/hr_storage.c Wed Nov 30 12:01:05 2005
@@ -233,6 +233,10 @@
--- agent/mibgroup/host/hr_storage.c.orig 2007-06-08 19:33:58.000000000 +0900
+++ agent/mibgroup/host/hr_storage.c 2008-01-11 21:37:48.767962726 +0900
@@ -229,7 +229,7 @@
mach_port_t myHost;
#endif
-static int physmem, pagesize;
+static u_long physmem, pagesize;
static void parse_storage_config(const char *, char *);
/*********************
@@ -252,6 +252,10 @@
void sol_get_swapinfo(int *, int *);
#endif
@ -11,7 +20,7 @@
#define HRSTORE_MEMSIZE 1
#define HRSTORE_INDEX 2
#define HRSTORE_TYPE 3
@@ -472,7 +476,8 @@
@@ -499,7 +503,8 @@
NULL,
"Memory Buffers", /* HRS_TYPE_MBUF */
"Real Memory", /* HRS_TYPE_MEM */
@ -21,7 +30,7 @@
};
@@ -611,6 +616,7 @@
@@ -647,6 +652,7 @@
storage_type_id[storage_type_len - 1] = 3; /* Virtual Mem */
break;
case HRS_TYPE_MBUF:
@ -29,7 +38,7 @@
storage_type_id[storage_type_len - 1] = 1; /* Other */
break;
default:
@@ -704,7 +710,7 @@
@@ -752,7 +758,7 @@
long_return = memory_totals.t_vm;
#endif
break;
@ -38,7 +47,7 @@
case HRS_TYPE_MEM:
long_return = physmem;
break;
@@ -726,13 +732,45 @@
@@ -774,13 +780,45 @@
i++)
long_return += mbstat.m_mtypes[i];
#elif defined(MBSTAT_SYMBOL) && defined(STRUCT_MBSTAT_HAS_M_MBUFS)
@ -84,7 +93,7 @@
default:
#if NO_DUMMY_VALUES
goto try_next;
@@ -796,6 +834,12 @@
@@ -856,6 +894,12 @@
#endif
#elif defined(MBSTAT_SYMBOL) && defined(STRUCT_MBSTAT_HAS_M_CLUSTERS)
long_return = mbstat.m_clusters - mbstat.m_clfree; /* unlikely, but... */
@ -97,7 +106,7 @@
#elif defined(NO_DUMMY_VALUES)
goto try_next;
#else
@@ -803,6 +847,11 @@
@@ -863,6 +907,11 @@
#endif
break;
#endif /* !linux && !solaris2 && !hpux10 && !hpux11 && ... */
@ -109,7 +118,7 @@
default:
#if NO_DUMMY_VALUES
goto try_next;
@@ -829,7 +878,11 @@
@@ -889,7 +938,11 @@
break;
#if !defined(linux) && !defined(solaris2) && !defined(hpux10) && !defined(hpux11) && defined(MBSTAT_SYMBOL)
case HRS_TYPE_MBUF:
@ -121,11 +130,10 @@
break;
#endif /* !linux && !solaris2 && !hpux10 && !hpux11 && MBSTAT_SYMBOL */
default:
@@ -955,3 +1008,97 @@
*usedP = ainfo.ani_resv;
@@ -1015,6 +1068,100 @@
}
#endif /* solaris2 */
+
+#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
+void
+collect_mbuf(long *long_mbuf, long *long_mbufc)
@ -219,3 +227,7 @@
+#endif
+}
+#endif
+
#ifdef WIN32
char *win_realpath(const char *file_name, char *resolved_name)
{

View file

@ -1,12 +1,14 @@
--- snmplib/snmpTCPIPv6Domain.c.orig Sat Oct 16 03:52:29 2004
+++ snmplib/snmpTCPIPv6Domain.c Mon Oct 25 09:22:06 2004
@@ -95,13 +95,21 @@
Index: snmplib/snmpTCPIPv6Domain.c
diff -u -p snmplib/snmpTCPIPv6Domain.c.orig snmplib/snmpTCPIPv6Domain.c
--- snmplib/snmpTCPIPv6Domain.c.orig Fri Sep 16 19:30:49 2005
+++ snmplib/snmpTCPIPv6Domain.c Fri Jan 11 13:40:09 2008
@@ -96,13 +96,24 @@ netsnmp_tcp6_fmtaddr(netsnmp_transport *
if (to == NULL) {
return strdup("TCP/IPv6: unknown");
} else {
- char addr[INET6_ADDRSTRLEN];
- char tmp[INET6_ADDRSTRLEN + 8];
+ char tmp[NI_MAXHOST];
+ char addr[NI_MAXHOST], tmp[NI_MAXHOST + NI_MAXSERV + 12];
- sprintf(tmp, "TCP/IPv6: [%s]:%hd",
- inet_ntop(AF_INET6, (void *) &(to->sin6_addr), addr,
@ -20,10 +22,13 @@
+#ifndef NI_WITHSCOPEID
+#define NI_WITHSCOPEID 0
+#endif
+ if (getnameinfo(to, sizeof(struct sockaddr_in6), tmp, sizeof(tmp),
+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ if (getnameinfo((struct sockaddr *)to, sizeof(struct sockaddr_in6),
+ addr, sizeof(addr), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ return strdup("UDP/IPv6: unknown");
+ }
+ snprintf(tmp, sizeof(tmp), "TCP/IPv6: [%s]:%hd", addr,
+ ntohs(to->sin6_port));
+ return strdup(tmp);
}
}

View file

@ -1,12 +1,14 @@
--- snmplib/snmpUDPIPv6Domain.c.orig 2007-08-20 17:06:42.000000000 +0900
+++ snmplib/snmpUDPIPv6Domain.c 2007-12-21 09:58:31.316414938 +0900
@@ -103,13 +103,21 @@
Index: snmplib/snmpUDPIPv6Domain.c
diff -u -p snmplib/snmpUDPIPv6Domain.c.orig snmplib/snmpUDPIPv6Domain.c
--- snmplib/snmpUDPIPv6Domain.c.orig Mon Aug 20 17:06:42 2007
+++ snmplib/snmpUDPIPv6Domain.c Fri Jan 11 13:39:36 2008
@@ -103,13 +103,24 @@ netsnmp_udp6_fmtaddr(netsnmp_transport *
if (to == NULL) {
return strdup("UDP/IPv6: unknown");
} else {
- char addr[INET6_ADDRSTRLEN];
- char tmp[INET6_ADDRSTRLEN + 18];
+ char tmp[NI_MAXHOST];
+ char addr[NI_MAXHOST], tmp[NI_MAXHOST + NI_MAXSERV + 12];
- sprintf(tmp, "UDP/IPv6: [%s]:%hu",
- inet_ntop(AF_INET6, (void *) &(to->sin6_addr), addr,
@ -20,10 +22,13 @@
+#ifndef NI_WITHSCOPEID
+#define NI_WITHSCOPEID 0
+#endif
+ if (getnameinfo(to, sizeof(struct sockaddr_in6), tmp, sizeof(tmp),
+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ if (getnameinfo((struct sockaddr *)to, sizeof(struct sockaddr_in6),
+ addr, sizeof(addr), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID)) {
+ return strdup("UDP/IPv6: unknown");
+ }
+ snprintf(tmp, sizeof(tmp), "UDP/IPv6: [%s]:%hu", addr,
+ ntohs(to->sin6_port));
+ return strdup(tmp);
}
}

View file

@ -0,0 +1,11 @@
--- snmplib/snmpUDPDomain.c.orig 2008-01-11 21:53:12.214973877 +0900
+++ snmplib/snmpUDPDomain.c 2008-01-11 21:54:13.707245200 +0900
@@ -105,7 +105,7 @@
inet_ntoa(addr_pair->local_addr));
} else {
sprintf(tmp, "UDP: [%s]->", inet_ntoa(addr_pair->local_addr));
- sprintf(tmp + strlen(tmp), "[%s]:%hd",
+ sprintf(tmp + strlen(tmp), "[%s]:%hu",
inet_ntoa(to->sin_addr), ntohs(to->sin_port));
}
return strdup(tmp);

View file

@ -0,0 +1,13 @@
Index: agent/snmp_agent.c
diff -u -p agent/snmp_agent.c.orig agent/snmp_agent.c
--- agent/snmp_agent.c.orig Thu Aug 16 22:31:40 2007
+++ agent/snmp_agent.c Fri Jan 11 13:06:27 2008
@@ -819,7 +819,7 @@ netsnmp_agent_check_packet(netsnmp_sessi
}
#ifdef USE_LIBWRAP
/* Catch udp,udp6,tcp,tcp6 transports using "[" */
- tcpudpaddr = strstr(addr_string, "[");
+ tcpudpaddr = strrchr(addr_string, '[');
if ( tcpudpaddr != 0 ) {
char sbuf[64];
char *xp;