$NetBSD: patch-aj,v 1.1.1.1 2007/10/17 21:35:53 agc Exp $ --- lib/guestInfo/guestInfoPosix.c 2007/09/28 19:18:35 1.1 +++ lib/guestInfo/guestInfoPosix.c 2007/09/28 19:23:49 @@ -43,10 +43,11 @@ #include #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) # include # include # include +# include # include #endif #include "arpa/inet.h" @@ -134,7 +135,7 @@ }; -#if !defined(__FreeBSD__) +#if !defined(__FreeBSD__) && !defined(__NetBSD__) static int FindMacAddress(PNicInfo nicInfo, char *macAddress); #endif static int GetSystemBitness(void); @@ -191,7 +192,7 @@ *----------------------------------------------------------------------------- */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(__NetBSD__) Bool GuestInfoGetNicInfo(PNicInfo nicInfo) // IN: { @@ -283,7 +284,7 @@ return TRUE; } -#else /* FreeBSD */ +#else /* FreeBSD && !defined(__NetBSD__) */ Bool GuestInfoGetNicInfo(PNicInfo nicInfo) // IN: @@ -339,7 +340,10 @@ * Get the mac address for this interface. Some interfaces (like the * loopback interface) have no MAC address, and we skip them. */ -# ifndef sun +#ifdef __NetBSD__ + Debug("GuestInfo: Failed to get MAC address, skipping interface\n"); + continue; +#elif !defined(sun) if (ioctl(sockfd, SIOCGIFHWADDR, ifr) < 0) { Debug("GuestInfo: Failed to get MAC address, skipping interface\n"); continue; @@ -366,6 +370,7 @@ *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4), *(ptr + 5)); +#ifndef __NetBSD__ /* Which entry in nic info corresponds to this MAC address? */ macIndex = FindMacAddress(nicInfo, macAddress); if (macIndex < 0) { @@ -381,6 +386,7 @@ macAddress, sizeof macAddress); nicInfo->numNicEntries++; } +#endif /* Get the corresponding IP address. */ ifr->ifr_addr.sa_family = AF_INET; @@ -828,6 +834,20 @@ if (releaseLen != 0) { Str_Strncat(osName, outBufLen, buf.release, releaseLen); } + } else if (strstr(osNameFull, "NetBSD")) { + size_t nameLen = sizeof STR_OS_NETBSD - 1; + size_t releaseLen = 0; + + /* NetBSD, as usual, just DTRT */ + releaseLen = strlen(buf.release); + + if (nameLen + releaseLen + 1 > outBufLen) { + Debug("GuestInfoGetOSName: Error: buffer too small\n"); + return FALSE; + } + + Str_Strcpy(osName, STR_OS_NETBSD, outBufLen); + Str_Strncat(osName, outBufLen, buf.release, releaseLen); } else if (strstr(osNameFull, "SunOS")) { size_t nameLen = sizeof STR_OS_SOLARIS - 1; size_t releaseLen = 0; @@ -872,7 +892,7 @@ } -#if !defined(__FreeBSD__) +#if !defined(__FreeBSD__) && !defined(__NetBSD__) /* *----------------------------------------------------------------------------- * @@ -927,7 +947,7 @@ GetSystemBitness(void) { char buf[MAX_ARCH_NAME_LEN] = { 0 }; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__NetBSD__) int mib[2]; size_t len;