int scan(char * devname){ char mac[14]={0x7a,0x7a,0x7a,0x7a,0x7a, 0x5b,0x5b,0x5b,0x5b,0x5b, 0x3c,0x6d,0x9e,0x5e}; int res; unsigned char ch; struct sockdata *sk=nrf_socket(devname); if(!sk)return -1; CHECK(set_if_down(sk),res,err); CHECK(setmac(sk,mac,sizeof(mac)),res,err); CHECK(setpipes(sk,0x1),res, err); CHECK(getpipes(sk,&ch),res,err); if(ch!=0x1)printf("set-get pipes not consistent."); for(ch=0;ch<127;++ch){ CHECK(setchannel(sk,ch),res,err); CHECK(set_if_up(sk),res,err); sleep(1); CHECK(set_if_down(sk),res,err); CHECK(getrpd(sk,rpd+ch),res,err); } ret: close_rawsocket(sk); return res; err: perror("Error in scan"); goto ret; }
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; }