2 * lib/ib.c This file contains an implementation of the "Infiniband"
5 * Version: $Id: ib.c,v 1.1 2008/10/03 01:52:03 ecki Exp $
7 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
8 * Copyright 1993 MicroWalt Corporation
9 * Tom Duffy <tduffy@sun.com>
11 * This program is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software
14 * Foundation; either version 2 of the License, or (at
15 * your option) any later version.
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <net/if_arp.h>
23 #include <linux/if_infiniband.h>
30 #include "net-support.h"
31 #include "pathnames.h"
35 extern struct hwtype ib_hwtype;
38 /* Display an InfiniBand address in readable format. */
39 static char *pr_ib(unsigned char *ptr)
41 static char buff[128];
46 for (i = 0; i < INFINIBAND_ALEN; i++) {
47 pos += sprintf(pos, "%02X:", (*ptr++ & 0377));
49 buff[strlen(buff) - 1] = '\0';
51 /* snprintf(buff, sizeof(buff), "%02X:%02X:%02X:%02X:%02X:%02X",
52 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
53 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
60 /* Input an Infiniband address and convert to binary. */
61 static int in_ib(char *bufp, struct sockaddr *sap)
68 sap->sa_family = ib_hwtype.type;
73 while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) {
78 else if (c >= 'a' && c <= 'f')
80 else if (c >= 'A' && c <= 'F')
84 fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
93 else if (c >= 'a' && c <= 'f')
95 else if (c >= 'A' && c <= 'F')
97 else if (c == ':' || c == 0)
101 fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
108 *ptr++ = (unsigned char) (val & 0377);
111 /* We might get a semicolon here - not required. */
113 if (i == INFINIBAND_ALEN) {
115 fprintf(stderr, _("in_ib(%s): trailing : ignored!\n"),
124 /* That's it. Any trailing junk? */
125 if ((i == INFINIBAND_ALEN) && (*bufp != '\0')) {
127 fprintf(stderr, _("in_ib(%s): trailing junk!\n"), orig);
133 fprintf(stderr, "in_ib(%s): %s\n", orig, pr_ib(sap->sa_data));
140 struct hwtype ib_hwtype =
142 "infiniband", NULL, ARPHRD_INFINIBAND, INFINIBAND_ALEN,
147 #endif /* HAVE_HWIB */