int main(int argc, char *argv[]) { int i, c; unsigned char mac[6]; char *flash = DEFAULTFLASH; char *mtdname = NULL; off_t macoffset = 0x24000; char *redboot = NULL; while ((c = getopt(argc, argv, "f:h?m:n:o:r:")) > 0) { switch (c) { case '?': case 'h': usage(0); case 'f': flash = optarg; break; case 'm': mtdname = optarg; break; case 'n': numeths = atoi(optarg); if ((numeths < 0) || (numeths > MAXETHS)) { printf("ERROR: bad number of ethernets?\n"); exit(1); } break; case 'o': macoffset = strtoul(optarg, NULL, 0); break; case 'r': redboot = optarg; break; default: usage(1); } } if (mtdname) flash = findmtddevice(mtdname); if (flash) { if (redboot) readmacredboot(flash, redboot); else readmacflash(flash, macoffset); } for (i = 0; (i < numeths); i++) { getmac(i, &mac[0]); setmac(i, &mac[0]); } return 0; }
int main(int argc, char *argv[]) { int i, p, c; unsigned char mac[6]; char *flash = DEFAULTFLASH; char *mtdname = NULL; off_t macoffset = 0x24000; char *redboot = NULL; int swapmacs = 0; int runflash = 0; while ((c = getopt(argc, argv, "h?b:dspm:n:o:r:f:")) > 0) { switch (c) { case '?': case 'h': usage(0); case 'b': if (basemac(optarg) < 0) { printf("ERROR: invalid base MAC\n"); exit(1); } flash = NULL; break; case 's': swapmacs++; break; case 'p': runflash++; break; case 'd': debug++; break; case 'f': flash = optarg; break; case 'm': mtdname = optarg; break; case 'n': numeths = atoi(optarg); if ((numeths < 0) || (numeths > MAXETHS)) { printf("ERROR: bad number of ethernets?\n"); exit(1); } break; case 'o': macoffset = strtoul(optarg, NULL, 0); break; case 'r': redboot = optarg; break; default: usage(1); } } if (mtdname) flash = findmtddevice(mtdname); if (runflash) { runflashmac(); } else if (flash) { if (redboot) readmacredboot(flash, redboot); else readmacflash(flash, macoffset); } for (i = 0; (i < numeths); i++) { p = (swapmacs) ? (i^1) : i; getmac(p, &mac[0]); setmac(i, &mac[0]); } return 0; }