static int ex_pccard_silicom_cb(const struct pccard_tuple *tuple, void *arg) { u_char *enaddr = arg; int i; if (tuple->code != CISTPL_FUNCE) return (0); if (tuple->length != 15) return (0); if (pccard_tuple_read_1(tuple, 6) != 6) return (0); for (i = 0; i < 6; i++) enaddr[i] = pccard_tuple_read_1(tuple, 7 + i); return (1); }
static int pccard_build_cis(const struct pccard_tuple *tuple, void *argp) { struct cis_buffer *cis; int i; uint8_t ch; cis = (struct cis_buffer *)argp; /* * CISTPL_END is a special case, it has no length field. */ if (tuple->code == CISTPL_END) { if (cis->len + 1 > sizeof(cis->buffer)) return (ENOSPC); cis->buffer[cis->len++] = tuple->code; return (0); } if (cis->len + 2 + tuple->length > sizeof(cis->buffer)) return (ENOSPC); cis->buffer[cis->len++] = tuple->code; cis->buffer[cis->len++] = tuple->length; for (i = 0; i < tuple->length; i++) { ch = pccard_tuple_read_1(tuple, i); cis->buffer[cis->len++] = ch; } return (0); }
static int fe_pccard_xircom_mac(const struct pccard_tuple *tuple, void *argp) { uint8_t *enaddr = argp; int i; #if 1 /* * We fail to map the CIS twice, for reasons unknown. We * may fix this in the future by loading the CIS with a sane * CIS from userland. */ static uint8_t defaultmac[ETHER_ADDR_LEN] = { 0x00, 0x80, 0xc7, 0xed, 0x16, 0x7b }; /* Copy the MAC ADDR and return success */ for (i = 0; i < ETHER_ADDR_LEN; i++) enaddr[i] = defaultmac[i]; #else /* FUNCE is not after FUNCID, so we gotta go find it */ if (tuple->code != 0x22) return (0); /* Make sure this is a sane node */ if (tuple->length < ETHER_ADDR_LEN + 3) return (0); /* Copy the MAC ADDR and return success */ for (i = 0; i < ETHER_ADDR_LEN; i++) enaddr[i] = pccard_tuple_read_1(tuple, i + 3); #endif return (1); }
static int ep_pccard_mac(const struct pccard_tuple *tuple, void *argp) { uint8_t *enaddr = argp; int i; /* Code 0x88 is 3com's special cis node contianing the MAC */ if (tuple->code != 0x88) return (0); /* Make sure this is a sane node */ if (tuple->length < ETHER_ADDR_LEN) return (0); /* Copy the MAC ADDR and return success */ for (i = 0; i < ETHER_ADDR_LEN; i += 2) { enaddr[i] = pccard_tuple_read_1(tuple, i + 1); enaddr[i + 1] = pccard_tuple_read_1(tuple, i); } return (1); }