int wl_probe(char *name) { int ret, val; if (isListed("probe_blacklist", name)) return -1; #if 0 //defined(linux) char buf[DEV_TYPE_LEN]; if ((ret = wl_get_dev_type(name, buf, DEV_TYPE_LEN)) < 0) { // fprintf(stderr,"dev type=%s fail\n",name); addList("probe_blacklist", name); return ret; } /* * Check interface */ // fprintf(stderr,"dev type=%s\n",buf); if (strncmp(buf, "wl", 2)) { addList("probe_blacklist", name); return -1; } #else /* * Check interface */ if ((ret = wl_ioctl(name, WLC_GET_MAGIC, &val, sizeof(val)))) { // fprintf(stderr,"magic fail\n"); addList("probe_blacklist", name); return ret; } #endif if ((ret = wl_ioctl(name, WLC_GET_VERSION, &val, sizeof(val)))) { // fprintf(stderr,"version fail\n"); addList("probe_blacklist", name); return ret; } if (val > WLC_IOCTL_VERSION) { // fprintf(stderr,"version fail %d\n",val); addList("probe_blacklist", name); return -1; } return ret; }
void addList(char *listname, char *value) { int listlen = 0; if (isListed(listname, value)) return; char *list = nvram_get(listname); char *newlist; if (list) listlen = strlen(list); newlist = safe_malloc(strlen(value + 2) + listlen); if (list) sprintf(newlist, "%s %s", list, value); else sprintf(newlist, "%s", value); nvram_set(listname, newlist); free(newlist); }