return fmt.Sprintf("{%08X-%04X-%04X-%02X-%02X}", winGuid.Data1, winGuid.Data2, winGuid.Data3, winGuid.Data4[:2], winGuid.Data4[2:])
** Copyright (C) 2001-2023 Zabbix SIA
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"git.zabbix.com/ap/plugin-support/plugin"
"golang.org/x/sys/windows"
errorEmptyIpTable = "Empty IP address table returned."
errorCannotFindIf = "Cannot obtain network interface information."
func (p *Plugin) nToIP(addr uint32) net.IP {
b := (*[4]byte)(unsafe.Pointer(&addr))
return net.IPv4(b[0], b[1], b[2], b[3])
func (p *Plugin) getIpAddrTable() (addrs []win32.MIB_IPADDRROW, err error) {
var ipTable *win32.MIB_IPADDRTABLE
var sizeIn, sizeOut uint32
if sizeOut, err = win32.GetIpAddrTable(nil, 0, false); err != nil {
buf := make([]byte, sizeIn)
ipTable = (*win32.MIB_IPADDRTABLE)(unsafe.Pointer(&buf[0]))
if sizeOut, err = win32.GetIpAddrTable(ipTable, sizeIn, false); err != nil {
return (*win32.RGMIB_IPADDRROW)(unsafe.Pointer(&ipTable.Table[0]))[:ipTable.NumEntries:ipTable.NumEntries], nil