Module: check_mk
Branch: master
Commit: f54d61dcd4ee391dac528689c4cae17047746647
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f54d61dcd4ee39…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Oct 15 10:48:16 2015 +0200
fixed display of ipv6 adresses in winows agent
---
agents/windows/ListenSocket.cc | 30 +++++++++++++++-------
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 830464 -> 830464 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 830464 -> 830464 bytes
agents/windows/check_mk_agent.cc | 2 +-
agents/windows/check_mk_agent.exe | Bin 748032 -> 748032 bytes
agents/windows/check_mk_agent.msi | Bin 1836544 -> 1836544 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 748032 -> 748032 bytes
agents/windows/install_agent-64.exe | Bin 383040 -> 383129 bytes
agents/windows/install_agent.exe | Bin 374028 -> 374076 bytes
10 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/agents/windows/ListenSocket.cc b/agents/windows/ListenSocket.cc
index 41abdd3..7134952 100644
--- a/agents/windows/ListenSocket.cc
+++ b/agents/windows/ListenSocket.cc
@@ -36,6 +36,10 @@ extern void debug(char *text);
#define debug(C)
#endif
+
+static const size_t INET6_ADDRSTRLEN = 46;
+
+
ListenSocket::ListenSocket(int port, const only_from_t &source_whitelist, bool
supportIPV6)
: _source_whitelist(source_whitelist)
, _supports_ipv4(true)
@@ -172,17 +176,25 @@ SOCKET ListenSocket::init_listen_socket(int port)
std::string ListenSocket::readableIP(SOCKET connection)
{
- SOCKADDR_IN6 remote_addr;
- int addrlen = sizeof(SOCKADDR_IN6);
- getpeername(connection, (sockaddr*)&remote_addr, &addrlen);
- char ip_hr[256];
- if (remote_addr.sin6_family == AF_INET6) {
- u_char *ip = remote_addr.sin6_addr.u.Byte;
- snprintf(ip_hr, sizeof(ip_hr), "%c.%c.%c.%c",
+ sockaddr_storage addr;
+ int addrlen = sizeof(sockaddr_storage);
+ getpeername(connection, (sockaddr*)&addr, &addrlen);
+
+ char ip_hr[INET6_ADDRSTRLEN];
+
+ if (addr.ss_family == AF_INET) {
+ sockaddr_in *s = (sockaddr_in*)&addr;
+ u_char *ip = (u_char*)&s->sin_addr;
+ snprintf(ip_hr, INET6_ADDRSTRLEN, "%u.%u.%u.%u",
ip[0], ip[1], ip[2], ip[3]);
+ } else if (addr.ss_family == AF_INET6) { // AF_INET6
+ sockaddr_in6 *s = (sockaddr_in6*)&addr;
+ uint16_t *ip = s->sin6_addr.u.Word;
+ snprintf(ip_hr, INET6_ADDRSTRLEN, "%x:%x:%x:%x:%x:%x:%x:%x",
+ ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7]);
+ } else {
+ snprintf(ip_hr, INET6_ADDRSTRLEN, "None");
}
- else
- snprintf(ip_hr, sizeof(ip_hr), "None");
return ip_hr;
}
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 2d78492..68d5f38 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-547
+553
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index d213c84..559385d 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index 1d74658..99d7d46 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index cc05f26..26a2ef8 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -2936,7 +2936,7 @@ void section_check_mk(SOCKET &out, const Environment &env)
it_from != g_config->onlyFrom().end(); ++it_from ) {
ipspec *is = *it_from;
if (is->ipv6) {
- output(out, " %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x/%d",
+ output(out, " %x:%x:%x:%x:%x:%x:%x:%x/%d",
is->ip.v6.address[0], is->ip.v6.address[1],
is->ip.v6.address[2], is->ip.v6.address[3],
is->ip.v6.address[4], is->ip.v6.address[5],
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index fbb0452..ac39027 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 4b572c2..d062b36 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 2a5bca2..67c9306 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index e73958c..d095da5 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 51a81e7..0a2779b 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ