diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pccard/pccardd/cardd.c | 56 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardd/cardd.h | 11 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardd/file.c | 22 |
3 files changed, 80 insertions, 9 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c index f542d60..404aa56 100644 --- a/usr.sbin/pccard/pccardd/cardd.c +++ b/usr.sbin/pccard/pccardd/cardd.c @@ -35,6 +35,7 @@ static const char rcsid[] = #include <unistd.h> #include <errno.h> #include <fcntl.h> +#include <ctype.h> #include <sys/ioctl.h> #include "cardd.h" @@ -45,6 +46,7 @@ static void card_inserted(struct slot *); static void card_removed(struct slot *); static void pr_cmd(struct cmd *); static void read_ether(struct slot *); +static void read_ether_attr2(struct slot *sp); /* * Dump configuration file data. @@ -228,8 +230,18 @@ card_inserted(struct slot *sp) sp->cis->manuf, sp->cis->vers); return; } - if (cp->ether) - read_ether(sp); + if (cp->ether) { + struct ether *e = 0; + e = cp->ether; + switch (e->type) { + case ETHTYPE_ATTR2: + read_ether_attr2(sp); + break; + default: + read_ether(sp); + break; + } + } if ((sp->config = assign_driver(cp)) == NULL) return; if (assign_io(sp)) { @@ -259,7 +271,7 @@ read_ether(struct slot *sp) { unsigned char net_addr[12]; - lseek(sp->fd, (off_t)sp->card->ether, SEEK_SET); + lseek(sp->fd, (off_t)sp->card->ether->value, SEEK_SET); if (read(sp->fd, net_addr, sizeof(net_addr)) != sizeof(net_addr)) { logerr("read err on net addr"); return; @@ -276,6 +288,44 @@ read_ether(struct slot *sp) } /* + * Megahertz X-Jack Ethernet uses unique way to get/set MAC + * address of the card. + */ +static void +read_ether_attr2(struct slot *sp) +{ + int i; + char *hexaddr; + + hexaddr = sp->cis->add_info2; + for (i = 0; i < 6; i++) + sp->eaddr[i] = 0; + if (!hexaddr) + return; + if (strlen(hexaddr) != 12) + return; + for (i = 0; i < 12; i++) + if (!isxdigit(hexaddr[i])) + return; + for (i = 0; i < 6; i++) { + u_int d; + char s[3]; + s[0] = hexaddr[i * 2]; + s[1] = hexaddr[i * 2 + 1]; + s[2] = '\0'; + if (!sscanf(s, "%x", &d)) { + int j; + for (j = 0; j < 6; j++) + sp->eaddr[j] = 0; + return; + } + sp->eaddr[i] = (u_char)d; + } + sp->flags |= EADDR_CONFIGED; +} + + +/* * assign_driver - Assign driver to card. * First, see if an existing driver is already setup. */ diff --git a/usr.sbin/pccard/pccardd/cardd.h b/usr.sbin/pccard/pccardd/cardd.h index a9a3ffa..8f255db 100644 --- a/usr.sbin/pccard/pccardd/cardd.h +++ b/usr.sbin/pccard/pccardd/cardd.h @@ -53,11 +53,20 @@ struct card_config { char inuse; }; +struct ether { + struct ether *next; + int type; + int value; +}; + +#define ETHTYPE_GENERIC 0 +#define ETHTYPE_ATTR2 1 + struct card { struct card *next; char *manuf; char *version; - int ether; /* For net cards, ether at offset */ + struct ether *ether; /* For net cards, ether at offset */ int reset_time; /* Reset time */ int iosize; /* I/O window size (ignore location) */ struct card_config *config; /* List of configs */ diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c index a1ed59f..9d9b6fa 100644 --- a/usr.sbin/pccard/pccardd/file.c +++ b/usr.sbin/pccard/pccardd/file.c @@ -213,10 +213,11 @@ parsefile(void) static void parse_card(void) { - char *man, *vers; + char *man, *vers, *tmp; struct card *cp; int i, iosize; struct card_config *confp, *lastp; + struct ether *ether; confp = 0; man = newstr(next_tok()); @@ -277,11 +278,22 @@ parse_card(void) break; case KWD_ETHER: /* ether */ - cp->ether = num_tok(); - if (cp->ether == -1) { - error("illegal ether address offset"); - cp->ether = 0; + ether = xmalloc(sizeof(*ether)); + ether->type = ETHTYPE_GENERIC; + tmp = next_tok(); + if (strcmp("attr2", tmp) == 0) + ether->type = ETHTYPE_ATTR2; + else { + pusht = 1; + ether->value = num_tok(); + if (ether->value == -1) { + error("illegal ether address offset"); + free(ether); + break; + } } + ether->next = cp->ether; + cp->ether = ether; break; case KWD_INSERT: /* insert */ |