summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2004-05-26 22:59:55 +0000
committerbrooks <brooks@FreeBSD.org>2004-05-26 22:59:55 +0000
commit5b46c790ee2be794d0ddffea63668fec51c8f260 (patch)
tree911a427f57cebda0e7dc45f2fcb3047e0dfcc019 /usr.sbin
parent5ae1bd47055bb0a8824b70db8ecac0a96fa662c1 (diff)
downloadFreeBSD-src-5b46c790ee2be794d0ddffea63668fec51c8f260.zip
FreeBSD-src-5b46c790ee2be794d0ddffea63668fec51c8f260.tar.gz
Use new eui64(3) functions to print EUI-64s and to allow access to nodes
by EUI-64 and name. Reviewed by: simokawa
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/dconschat/dconschat.811
-rw-r--r--usr.sbin/dconschat/dconschat.c11
-rw-r--r--usr.sbin/fwcontrol/fwcontrol.c86
3 files changed, 87 insertions, 21 deletions
diff --git a/usr.sbin/dconschat/dconschat.8 b/usr.sbin/dconschat/dconschat.8
index 4f17d30..e11d224 100644
--- a/usr.sbin/dconschat/dconschat.8
+++ b/usr.sbin/dconschat/dconschat.8
@@ -157,9 +157,9 @@ bus follow.
.Bd -literal -offset indent
# fwcontrol
2 devices (info_len=2)
-node EUI64 status
- 1 0x7766554433221100 0
- 0 0x0011223344556677 1
+node EUI64 status
+ 1 77-66-55-44-33-22-11-00 0
+ 0 00-11-22-33-44-55-66-77 1
.Ed
.Pp
The EUI64 doesn't change unless you change the hardware
@@ -168,7 +168,7 @@ as the ethernet address.
Now we can run the
.Nm .
.Bd -literal -offset indent
-# dconschat -br -G 12345 -t 0x00112233445566677
+# dconschat -br -G 12345 -t 00-11-22-33-44-55-66-77
.Ed
.Pp
You'll get console output of the target and login prompt if a getty is
@@ -213,7 +213,7 @@ console local {
console remote {
master localhost;
type exec;
- exec /usr/sbin/dconschat -rh 25 -t 0x0011223344556677;
+ exec /usr/sbin/dconschat -rh 25 -t 00-11-22-33-44-55-66-77;
}
.Ed
.Sh FILES
@@ -232,6 +232,7 @@ console remote {
.Xr firewire 4 ,
.Xr fwohci 4 ,
.Xr gdb 4 ,
+.Xr eui64 5 ,
.Xr fwcontrol 8
.Sh AUTHORS
.An Hidetoshi Shimokawa Aq simokawa@FreeBSD.org
diff --git a/usr.sbin/dconschat/dconschat.c b/usr.sbin/dconschat/dconschat.c
index 9c8b89d..d343811 100644
--- a/usr.sbin/dconschat/dconschat.c
+++ b/usr.sbin/dconschat/dconschat.c
@@ -50,6 +50,7 @@
#include <netdb.h>
#include <err.h>
#include <string.h>
+#include <sys/eui64.h>
#include <sys/event.h>
#include <sys/time.h>
#include <arpa/telnet.h>
@@ -809,11 +810,11 @@ main(int argc, char **argv)
{
struct dcons_state *dc;
struct fw_eui64 eui;
+ struct eui64 target;
char devname[256], *core = NULL, *system = NULL;
int i, ch, error;
int unit=0, wildcard=0;
int port[DCONS_NPORT];
- u_int64_t target = 0;
bzero(&sc, sizeof(sc));
dc = &sc;
@@ -841,9 +842,11 @@ main(int argc, char **argv)
dc->flags |= F_REPLAY;
break;
case 't':
- target = strtoull(optarg, NULL, 0);
- eui.hi = target >> 32;
- eui.lo = target & (((u_int64_t)1 << 32) - 1);
+ if (eui64_hostton(optarg, &target) != 0 &&
+ eui64_aton(optarg, &target) != 0)
+ errx(1, "invalid target: %s", optarg);
+ eui.hi = ntohl(*(u_int32_t*)&(target.octet[0]));
+ eui.lo = ntohl(*(u_int32_t*)&(target.octet[4]));
dc->type = TYPE_FW;
break;
case 'u':
diff --git a/usr.sbin/fwcontrol/fwcontrol.c b/usr.sbin/fwcontrol/fwcontrol.c
index 99c13a6..c250723 100644
--- a/usr.sbin/fwcontrol/fwcontrol.c
+++ b/usr.sbin/fwcontrol/fwcontrol.c
@@ -39,6 +39,7 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
+#include <sys/eui64.h>
#include <dev/firewire/firewire.h>
#include <dev/firewire/iec13213.h>
#include <dev/firewire/fwphyreg.h>
@@ -76,6 +77,13 @@ usage(void)
exit(0);
}
+static void
+fweui2eui64(const struct fw_eui64 *fweui, struct eui64 *eui)
+{
+ *(u_int32_t*)&(eui->octet[0]) = htonl(fweui->hi);
+ *(u_int32_t*)&(eui->octet[4]) = htonl(fweui->lo);
+}
+
static struct fw_devlstreq *
get_dev(int fd)
{
@@ -90,22 +98,68 @@ get_dev(int fd)
return data;
}
+static int
+str2node(int fd, const char *nodestr)
+{
+ struct eui64 eui, tmpeui;
+ struct fw_devlstreq *data;
+ char *endptr;
+ int i, node;
+
+ if (nodestr == '\0')
+ return (-1);
+
+ /*
+ * Deal with classic node specifications.
+ */
+ node = strtol(nodestr, &endptr, 0);
+ if (*endptr == '\0')
+ goto gotnode;
+
+ /*
+ * Try to get an eui and match it against available nodes.
+ */
+ if (eui64_hostton(nodestr, &eui) != 0 && eui64_aton(nodestr, &eui) != 0)
+ return (-1);
+
+ data = get_dev(fd);
+
+ for (i = 0; i < data->info_len; i++) {
+ fweui2eui64(&data->dev[i].eui, &tmpeui);
+ if (memcmp(&eui, &tmpeui, sizeof(struct eui64)) == 0) {
+ node = data->dev[i].dst;
+ goto gotnode;
+ }
+ }
+ if (i >= data->info_len)
+ return (-1);
+
+gotnode:
+ if (node < 0 || node > 63)
+ return (-1);
+ else
+ return (node);
+}
+
static void
list_dev(int fd)
{
struct fw_devlstreq *data;
struct fw_devinfo *devinfo;
+ struct eui64 eui;
+ char addr[EUI64_SIZ];
int i;
data = get_dev(fd);
printf("%d devices (info_len=%d)\n", data->n, data->info_len);
- printf("node EUI64 status\n");
+ printf("node EUI64 status\n");
for (i = 0; i < data->info_len; i++) {
devinfo = &data->dev[i];
- printf("%4d 0x%08x%08x %6d\n",
+ fweui2eui64(&devinfo->eui, &eui);
+ eui64_ntoa(&eui, addr, sizeof(addr));
+ printf("%4d %s %6d\n",
(devinfo->status || i == 0) ? devinfo->dst : -1,
- devinfo->eui.hi,
- devinfo->eui.lo,
+ addr,
devinfo->status
);
}
@@ -220,6 +274,8 @@ set_pri_req(int fd, int pri_req)
{
struct fw_devlstreq *data;
struct fw_devinfo *devinfo;
+ struct eui64 eui;
+ char addr[EUI64_SIZ];
u_int32_t max, reg, old;
int i;
@@ -230,8 +286,10 @@ set_pri_req(int fd, int pri_req)
if (!devinfo->status)
continue;
reg = read_write_quad(fd, devinfo->eui, BUGET_REG, 1, 0);
- printf("%d %08x:%08x, %08x",
- devinfo->dst, devinfo->eui.hi, devinfo->eui.lo, reg);
+ fweui2eui64(&devinfo->eui, &eui);
+ eui64_ntoa(&eui, addr, sizeof(addr));
+ printf("%d %s, %08x",
+ devinfo->dst, addr, reg);
if (reg > 0 && pri_req >= 0) {
old = (reg & 0x3f);
max = (reg & 0x3f00) >> 8;
@@ -250,19 +308,23 @@ static void
parse_bus_info_block(u_int32_t *p, int info_len)
{
int i;
+ char addr[EUI64_SIZ];
struct bus_info *bi;
+ struct eui64 eui;
bi = (struct bus_info *)p;
+ fweui2eui64(&bi->eui64, &eui);
+ eui64_ntoa(&eui, addr, sizeof(addr));
printf("bus_name: 0x%04x\n"
"irmc:%d cmc:%d isc:%d bmc:%d pmc:%d\n"
"cyc_clk_acc:%d max_rec:%d max_rom:%d\n"
"generation:%d link_spd:%d\n"
- "EUI64: 0x%08x 0x%08x\n",
+ "EUI64: %s\n",
bi->bus_name,
bi->irmc, bi->cmc, bi->isc, bi->bmc, bi->pmc,
bi->cyc_clk_acc, bi->max_rec, bi->max_rom,
bi->generation, bi->link_spd,
- bi->eui64.hi, bi->eui64.lo);
+ addr);
}
static int
@@ -555,14 +617,14 @@ main(int argc, char **argv)
set_pri_req(fd, tmp);
break;
case 'c':
- tmp = strtol(optarg, NULL, 0);
open_dev(&fd, devbase);
+ tmp = str2node(fd, optarg);
get_crom(fd, tmp, crom_buf, len);
show_crom(crom_buf);
break;
case 'd':
- tmp = strtol(optarg, NULL, 0);
open_dev(&fd, devbase);
+ tmp = str2node(fd, optarg);
get_crom(fd, tmp, crom_buf, len);
dump_crom(crom_buf);
break;
@@ -576,8 +638,8 @@ main(int argc, char **argv)
show_crom(crom_buf);
break;
case 'o':
- tmp = strtol(optarg, NULL, 0);
open_dev(&fd, devbase);
+ tmp = str2node(fd, optarg);
send_link_on(fd, tmp);
break;
case 'p':
@@ -590,8 +652,8 @@ main(int argc, char **argv)
err(1, "ioctl");
break;
case 's':
- tmp = strtol(optarg, NULL, 0);
open_dev(&fd, devbase);
+ tmp = str2node(fd, optarg);
reset_start(fd, tmp);
break;
case 't':
OpenPOWER on IntegriCloud