Print this page

        

*** 52,61 **** --- 52,75 ---- * @brief Functions to interact with the network sockets and NIC driver. * * */ + #ifdef __sun + /* + * These are needed to enable control messages on sendmsg(). + * I'll save the commentary on why the bend-over-backwards old way of doing + * sendmsg() is still around. + * + * STRICTLY SPEAKING this program should be linked against libxnet instead + * of libsocket because of these interfaces, but we'll cross that bridge + * when we get to it. + */ + #define _XOPEN_SOURCE 500 + #define __EXTENSIONS__ + #endif + #include "../ptpd.h" #ifdef PTPD_PCAP #ifdef HAVE_PCAP_PCAP_H #include <pcap/pcap.h>
*** 304,315 **** int ret; if(!strlen(ifaceName)) return 0; /* BSD* - AF_LINK gives us access to the hw address via struct sockaddr_dl */ - #ifdef AF_LINK struct ifaddrs *ifaddr, *ifa; if(getifaddrs(&ifaddr) == -1) { PERROR("Could not get interface list"); --- 318,329 ---- int ret; if(!strlen(ifaceName)) return 0; + #if defined(AF_LINK) && !defined(__sun) /* BSD* - AF_LINK gives us access to the hw address via struct sockaddr_dl */ struct ifaddrs *ifaddr, *ifa; if(getifaddrs(&ifaddr) == -1) { PERROR("Could not get interface list");
*** 345,356 **** end: freeifaddrs(ifaddr); return ret; - /* Linux, basically */ #else int sockfd; struct ifreq ifr; sockfd = socket(AF_INET, SOCK_DGRAM, 0); --- 359,370 ---- end: freeifaddrs(ifaddr); return ret; #else + /* Linux and Solarish systems have SIOCGIFHWADDR/SIOCGLIFHWADDR. Use it. */ int sockfd; struct ifreq ifr; sockfd = socket(AF_INET, SOCK_DGRAM, 0);
*** 358,368 **** if(sockfd < 0) { PERROR("Could not open test socket"); return -1; } ! memset(&ifr, 0, sizeof(struct ifreq)); strncpy(ifr.ifr_name, ifaceName, IFACE_NAME_LENGTH); if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) { DBGV("failed to request hardware address for %s", ifaceName); --- 372,382 ---- if(sockfd < 0) { PERROR("Could not open test socket"); return -1; } ! memset(&ifr, 0, sizeof (ifr)); strncpy(ifr.ifr_name, ifaceName, IFACE_NAME_LENGTH); if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) { DBGV("failed to request hardware address for %s", ifaceName);
*** 369,387 **** --- 383,409 ---- ret = -1; goto end; } + #ifdef __sun + int af = ifr.ifr_addr.sa_family; + #else int af = ifr.ifr_hwaddr.sa_family; + #endif if ( af == ARPHRD_ETHER || af == ARPHRD_IEEE802 #ifdef ARPHRD_INFINIBAND || af == ARPHRD_INFINIBAND #endif ) { + #ifdef __sun + memcpy(hwAddr, ifr.ifr_addr.sa_data, hwAddrSize); + #else memcpy(hwAddr, ifr.ifr_hwaddr.sa_data, hwAddrSize); + #endif ret = 1; } else { DBGV("Unsupported hardware address family on %s\n", ifaceName); ret = 0; }
*** 572,582 **** } static Boolean netSetMulticastTTL(int sockfd, int ttl) { ! #ifdef __OpenBSD__ uint8_t temp = (uint8_t) ttl; #else int temp = ttl; #endif --- 594,604 ---- } static Boolean netSetMulticastTTL(int sockfd, int ttl) { ! #if defined(__OpenBSD__) || defined(__sun) uint8_t temp = (uint8_t) ttl; #else int temp = ttl; #endif
*** 588,598 **** return TRUE; } static Boolean netSetMulticastLoopback(NetPath * netPath, Boolean value) { ! #ifdef __OpenBSD__ uint8_t temp = value ? 1 : 0; #else int temp = value ? 1 : 0; #endif DBG("Going to set multicast loopback with %d \n", temp); --- 610,620 ---- return TRUE; } static Boolean netSetMulticastLoopback(NetPath * netPath, Boolean value) { ! #if defined(__OpenBSD__) || defined(__sun) uint8_t temp = value ? 1 : 0; #else int temp = value ? 1 : 0; #endif DBG("Going to set multicast loopback with %d \n", temp);
*** 746,756 **** --- 768,782 ---- hostLookup(const char* hostname, Integer32* addr) { if (hostname[0]) { /* Attempt a DNS lookup first. */ struct hostent *host; + #ifdef __sun + host = getipnodebyname(hostname, AF_INET, AI_DEFAULT, &errno); + #else host = gethostbyname2(hostname, AF_INET); + #endif if (host != NULL) { if (host->h_length != 4) { PERROR("unicast host resolved to non ipv4" "address"); return FALSE;