summaryrefslogtreecommitdiff
path: root/common/socket.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2012-02-16 21:05:28 +0000
committerShawn Routhier <sar@isc.org>2012-02-16 21:05:28 +0000
commitb047bd385b742331828fd6911ed39f6cb9980ca9 (patch)
tree136475f16354814a99b44a7fc51107210eca3b64 /common/socket.c
parent865afd5e447e23e9af0b888c92a9e9ce6b38e7a8 (diff)
downloadisc-dhcp-b047bd385b742331828fd6911ed39f6cb9980ca9.tar.gz
Add support for Infiniband over sockets to the server and
relay code. We've tested this on Solaris and hope to expand support for Infiniband in the future. This patch also corrects some issues we found in the socket code. [ISC-Bugs #24245]
Diffstat (limited to 'common/socket.c')
-rw-r--r--common/socket.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/common/socket.c b/common/socket.c
index fa771281..21e1f5f0 100644
--- a/common/socket.c
+++ b/common/socket.c
@@ -3,7 +3,7 @@
BSD socket interface code... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -51,6 +51,7 @@
#include <net/if.h>
#include <sys/sockio.h>
#include <net/if_dl.h>
+#include <sys/dlpi.h>
#endif
#ifdef USE_SOCKET_FALLBACK
@@ -1067,7 +1068,7 @@ void maybe_setup_fallback ()
void
get_hw_addr(const char *name, struct hardware *hw) {
struct sockaddr_dl *dladdrp;
- int rv, sock, i;
+ int sock, i;
struct lifreq lifr;
memset(&lifr, 0, sizeof (lifr));
@@ -1101,7 +1102,8 @@ get_hw_addr(const char *name, struct hardware *hw) {
hw->hlen = sizeof (hw->hbuf);
srandom((long)gethrtime());
- for (i = 0; i < hw->hlen; ++i) {
+ hw->hbuf[0] = HTYPE_IPMP;
+ for (i = 1; i < hw->hlen; ++i) {
hw->hbuf[i] = random() % 256;
}
@@ -1114,8 +1116,27 @@ get_hw_addr(const char *name, struct hardware *hw) {
log_fatal("Couldn't get interface hardware address for %s: %m",
name);
dladdrp = (struct sockaddr_dl *)&lifr.lifr_addr;
- hw->hlen = dladdrp->sdl_alen;
- memcpy(hw->hbuf, LLADDR(dladdrp), hw->hlen);
+ hw->hlen = dladdrp->sdl_alen+1;
+ switch (dladdrp->sdl_type) {
+ case DL_CSMACD: /* IEEE 802.3 */
+ case DL_ETHER:
+ hw->hbuf[0] = HTYPE_ETHER;
+ break;
+ case DL_TPR:
+ hw->hbuf[0] = HTYPE_IEEE802;
+ break;
+ case DL_FDDI:
+ hw->hbuf[0] = HTYPE_FDDI;
+ break;
+ case DL_IB:
+ hw->hbuf[0] = HTYPE_INFINIBAND;
+ break;
+ default:
+ log_fatal("%s: unsupported DLPI MAC type %lu", name,
+ (unsigned long)dladdrp->sdl_type);
+ }
+
+ memcpy(hw->hbuf+1, LLADDR(dladdrp), hw->hlen-1);
if (sock != -1)
(void) close(sock);