MCPcopy Create free account
hub / github.com/Icinga/icinga2 / check_ping6

Function check_ping6

plugins/check_ping.cpp:374–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374static int check_ping6(const printInfoStruct& pi, response& response)
375{
376 DWORD dwRepSize = sizeof(ICMPV6_ECHO_REPLY) + 8;
377 void *repBuf = reinterpret_cast<void *>(new BYTE[dwRepSize]);
378
379 int num = pi.num;
380 unsigned int rtt = 0;
381
382 if (l_Debug)
383 std::wcout << L"Parsing ip address" << '\n';
384
385 sockaddr_in6 ipDest6;
386 if (RtlIpv6StringToAddressEx(pi.ip.c_str(), &ipDest6.sin6_addr, &ipDest6.sin6_scope_id, &ipDest6.sin6_port)) {
387 std::wcout << pi.ip << " is not a valid ipv6 address" << '\n';
388 return 3;
389 }
390
391 ipDest6.sin6_family = AF_INET6;
392
393 sockaddr_in6 ipSource6;
394 ipSource6.sin6_addr = in6addr_any;
395 ipSource6.sin6_family = AF_INET6;
396 ipSource6.sin6_flowinfo = 0;
397 ipSource6.sin6_port = 0;
398
399 if (l_Debug)
400 std::wcout << L"Creating Icmp File" << '\n';
401
402 HANDLE hIcmp = Icmp6CreateFile();
403 if (hIcmp == INVALID_HANDLE_VALUE) {
404 printErrorInfo(GetLastError());
405
406 if (hIcmp)
407 IcmpCloseHandle(hIcmp);
408
409 if (repBuf)
410 delete reinterpret_cast<BYTE *>(repBuf);
411
412 return 3;
413 } else {
414 IP_OPTION_INFORMATION ipInfo = { 30, 0, 0, 0, NULL };
415
416 LARGE_INTEGER frequency;
417 QueryPerformanceFrequency(&frequency);
418
419 do {
420 LARGE_INTEGER timer1;
421 QueryPerformanceCounter(&timer1);
422
423 if (l_Debug)
424 std::wcout << L"Sending Icmp echo" << '\n';
425
426 if (!Icmp6SendEcho2(hIcmp, NULL, NULL, NULL, &ipSource6, &ipDest6,
427 NULL, 0, &ipInfo, repBuf, dwRepSize, pi.timeout)) {
428 response.dropped++;
429 if (l_Debug)
430 std::wcout << L"Dropped: Response was 0" << '\n';
431 continue;

Callers 1

wmainFunction · 0.85

Calls 1

printErrorInfoFunction · 0.85

Tested by

no test coverage detected