490 if (isdigit(chr)) {
491 val = (val << 4) + chr - '0';
492 } else if (isxdigit(chr)) {
493 val = (val << 4) + chr -
494 (isupper(chr) ? 'A' : 'a') + 10;
495 } else if (isspace(chr) && dig == 0) {
496 continue;
497 } else if (chr == ':' || chr == '-' ||
498 isspace(chr)) {
499 dig = 1;
500 } else {
501 goto failed;
502 }
503 if (++dig == 2) {
504 *outbuf++ = val;
505 maclen++;
506 dig = val = 0;
507 }
508 }
509 } else {
510 if (dlpi_info(dh, &dlinfo, 0) != DLPI_SUCCESS) {
511 dlpi_close(dh);
512 goto failed;
513 }
514 maclen = dlinfo.di_physaddrlen;
515 (void) memcpy(outbuf, dlinfo.di_physaddr, maclen);
516 dlpi_close(dh);
517 if (hwtype == -1)
518 hwtype = dlpi_arptype(dlinfo.di_mactype);
519 }
520 }
521 if (hwtype == -1)
522 goto failed;
523 *hwret = htons(hwtype);
524 return (maclen);
525
526 failed:
527 *ierrnop = ITAB_BAD_NUMBER;
528 return (-1);
529 }
530
|
490 if (isdigit(chr)) {
491 val = (val << 4) + chr - '0';
492 } else if (isxdigit(chr)) {
493 val = (val << 4) + chr -
494 (isupper(chr) ? 'A' : 'a') + 10;
495 } else if (isspace(chr) && dig == 0) {
496 continue;
497 } else if (chr == ':' || chr == '-' ||
498 isspace(chr)) {
499 dig = 1;
500 } else {
501 goto failed;
502 }
503 if (++dig == 2) {
504 *outbuf++ = val;
505 maclen++;
506 dig = val = 0;
507 }
508 }
509 } else {
510 if (dlpi_bind(dh, DLPI_ANY_SAP, NULL) !=
511 DLPI_SUCCESS || dlpi_info(dh, &dlinfo, 0) !=
512 DLPI_SUCCESS) {
513 dlpi_close(dh);
514 goto failed;
515 }
516 maclen = dlinfo.di_physaddrlen;
517 (void) memcpy(outbuf, dlinfo.di_physaddr, maclen);
518 dlpi_close(dh);
519 if (hwtype == -1)
520 hwtype = dlpi_arptype(dlinfo.di_mactype);
521 }
522 }
523 if (hwtype == -1)
524 goto failed;
525 *hwret = htons(hwtype);
526 return (maclen);
527
528 failed:
529 *ierrnop = ITAB_BAD_NUMBER;
530 return (-1);
531 }
532
|