Beispiel #1
0
static int bgscan_learn_load(struct bgscan_learn_data *data)
{
	FILE *f;
	char buf[128];
	struct bgscan_learn_bss *bss;

	if (data->fname == NULL) {
		return 0;
	}

	f = fopen(data->fname, "r");
	if (f == NULL) {
		return 0;
	}

	wpa_printf(MSG_DEBUG, "bgscan learn: Loading data from %s", data->fname);

	if (fgets(buf, sizeof(buf), f) == NULL || os_strncmp(buf, "wpa_supplicant-bgscan-learn\n", 28) != 0) {
		wpa_printf(MSG_INFO, "bgscan learn: Invalid data file %s", data->fname);
		fclose(f);
		return -1;
	}

	while (fgets(buf, sizeof(buf), f)) {
		if (os_strncmp(buf, "BSS ", 4) == 0) {
			bss = os_zalloc(sizeof(*bss));
			if (!bss) {
				continue;
			}
			if (hwaddr_aton(buf + 4, bss->bssid) < 0) {
				bss_free(bss);
				continue;
			}
			bss->freq = atoi(buf + 4 + 18);
			dl_list_add(&data->bss, &bss->list);
			wpa_printf(MSG_DEBUG, "bgscan learn: Loaded BSS " "entry: " MACSTR " freq=%d", MAC2STR(bss->bssid), bss->freq);
		}

		if (os_strncmp(buf, "NEIGHBOR ", 9) == 0) {
			u8 addr[ETH_ALEN];

			if (hwaddr_aton(buf + 9, addr) < 0) {
				continue;
			}
			bss = bgscan_learn_get_bss(data, addr);
			if (bss == NULL) {
				continue;
			}
			if (hwaddr_aton(buf + 9 + 18, addr) < 0) {
				continue;
			}

			bgscan_learn_add_neighbor(bss, addr);
		}
	}

	fclose(f);
	return 0;
}
Beispiel #2
0
void reinit(void)
{
  default_lmask = DEFAULT_LMASK ;
  strcpy(_q_term, DEFAULT_TERM) ;
  strrncpy(default_attr, DEFAULT_ATTR, NNAME_MAX) ;
  strrncpy(_q_attr, default_attr, NNAME_MAX) ;
  default_search_type = DEFAULT_SEARCH_TYPE ;
  default_op = DEFAULT_OP ;
  if ( _q_db != NULL ) {
    bss_free(_q_db) ;
    _q_db = NULL ;
  }
  _q_aw = DEFAULT_AW ;
  _q_gw = DEFAULT_GW ;
  _q_maxgap = DEFAULT_MAXGAP ;
  _q_target = DEFAULT_TARGET ;
  _q_find_flags = default_ffl = DEFAULT_FFL ;
  _q_set = DEFAULT_SET ;
  _q_lastrec =  DEFAULT_LASTREC ;
  _q_rec = DEFAULT_REC ;
  _q_recnum = DEFAULT_RECNUM ;
  default_format = DEFAULT_FORMAT ;
  default_k1 = DEFAULT_K1 ; default_k2 = DEFAULT_K2 ; default_k3 = DEFAULT_K3 ;
  default_k4 = DEFAULT_K4 ; default_k5 = DEFAULT_K5 ; default_k6 = DEFAULT_K6 ;
  default_k7 = DEFAULT_K7 ;
  default_k8 = DEFAULT_K8 ;
  default_bm25_b = DEFAULT_B ;
  default_b3 = DEFAULT_B3 ;
  default_avedoclen = DEFAULT_AVEDOCLEN ;
  default_avequerylen = DEFAULT_AVEQUERYLEN ;
  _q_qtf = DEFAULT_QTF ;
  default_p_unit = DEFAULT_P_UNIT ; default_p_step = DEFAULT_P_STEP ;
  default_p_maxlen = DEFAULT_P_MAXLEN ;
  default_wfunc = DEFAULT_WFUNC ;
  default_scorefunc = DEFAULT_SCOREFUNC ;
  _q_wnumber = DEFAULT_WNUMBER ;
  _q_ttf = DEFAULT_TTF ;
  _q_wtfactor = DEFAULT_WTFACTOR ;
  _q_r = DEFAULT_R ;
  default_bigr = DEFAULT_BIGR ;
  _q_s = DEFAULT_S ;
  default_bigs = DEFAULT_BIGS ;
  default_rload = DEFAULT_RLOAD ;
  default_bigrload = DEFAULT_BIGRLOAD ;
  default_theta = DEFAULT_THETA ;
  default_tnp = DEFAULT_TNP ;
  default_tnt = DEFAULT_TNT ;
  default_cttf = DEFAULT_CTTF ;
  default_lamda = DEFAULT_LAMDA ;
  default_bign = DEFAULT_BIGN ;
  _q_shownumber = DEFAULT_SHOW_NUMBER ;
  _q_db_flags = DEFAULT_DB_FLAGS ;
  lastweight = DEFAULT_LASTWEIGHT ;
  lastn = DEFAULT_LASTN ;
  last_ttf = DEFAULT_LAST_TTF ;
  _q_code = DEFAULT_TS ;
  _q_noerror = DEFAULT_NOERROR ;
}
static void bgscan_learn_deinit(void *priv)
{
	struct bgscan_learn_data *data = priv;
	struct bgscan_learn_bss *bss, *n;

	bgscan_learn_save(data);
	eloop_cancel_timeout(bgscan_learn_timeout, data, NULL);
	if (data->signal_threshold)
		wpa_drv_signal_monitor(data->wpa_s, 0, 0);
	os_free(data->fname);
	dl_list_for_each_safe(bss, n, &data->bss, struct bgscan_learn_bss,
			      list) {
		dl_list_del(&bss->list);
		bss_free(bss);
	}
	os_free(data->supp_freqs);
	os_free(data);
}
Beispiel #4
0
void
iexit(void)
{
  bss_free(bss_Outbuf) ;
  bss_exit();
}