Пример #1
0
static int scan_loop(void)
{
	unsigned char req_data[MAX_PACKET_LEN];
	int len;

	while (1)
	{
		if (wd_status.link_status == 0) {
			len = fill_find_network_req(req_data, 1);
			set_data(req_data, len);

			process_events_by_mask(5000, WDS_LINK_STATUS);

			if (wd_status.link_status == 0) {
				wmlog_msg(2, "Network not found.");
			} else {
				wmlog_msg(2, "Network found.");
			}
		} else {
			len = fill_connection_params_req(req_data);
			set_data(req_data, len);

			process_events_by_mask(500, WDS_RSSI | WDS_CINR | WDS_TXPWR | WDS_FREQ | WDS_BSID);

			wmlog_msg(2, "RSSI: %d   CINR: %f   TX Power: %d   Frequency: %d", wd_status.rssi, wd_status.cinr, wd_status.txpwr, wd_status.freq);
			wmlog_msg(2, "BSID: %02x:%02x:%02x:%02x:%02x:%02x", wd_status.bsid[0], wd_status.bsid[1], wd_status.bsid[2], wd_status.bsid[3], wd_status.bsid[4], wd_status.bsid[5]);

			len = fill_state_req(req_data);
			set_data(req_data, len);

			process_events_by_mask(500, WDS_STATE);

			wmlog_msg(2, "State: %s   Number: %d   Response: %d", wimax_states[wd_status.state], wd_status.state, wd_status.link_status);

			if (first_nego_flag) {
				first_nego_flag = 0;
				len = fill_find_network_req(req_data, 2);
				set_data(req_data, len);
			}

			process_events_by_mask(5000, WDS_LINK_STATUS);
		}
	}

	return 0;
}
Пример #2
0
static int scan_loop(void)
{
	unsigned char req_data[MAX_PACKET_LEN];
	int len;
	DIR *wimax_dir;
	FILE *wimax_file;

	while (1)
	{
		if((wimax_dir = opendir("/tmp/wimax")) == NULL)
			mkdir("/tmp/wimax", 0777);
		else
			closedir(wimax_dir);

		if (wd_status.link_status == 0) {
			len = fill_find_network_req(req_data, 1);
			set_data(req_data, len);

			process_events_by_mask(5000, WDS_LINK_STATUS);

			if((wimax_file = fopen("/tmp/wimax/link_status", "w+")) != NULL){
				fprintf(wimax_file, "%d", wd_status.link_status);
				fclose(wimax_file);
			}

			wmlog_msg(2, "Network not found.");
		} else {
			len = fill_connection_params_req(req_data);
			set_data(req_data, len);

			process_events_by_mask(500, WDS_RSSI | WDS_CINR | WDS_TXPWR | WDS_FREQ | WDS_BSID);

			wmlog_msg(0, "RSSI: %d   CINR: %f   TX Power: %d   Frequency: %d", wd_status.rssi, wd_status.cinr, wd_status.txpwr, wd_status.freq);
			wmlog_msg(0, "BSID: %02x:%02x:%02x:%02x:%02x:%02x", wd_status.bsid[0], wd_status.bsid[1], wd_status.bsid[2], wd_status.bsid[3], wd_status.bsid[4], wd_status.bsid[5]);

			if((wimax_file = fopen("/tmp/wimax/link_status", "w+")) != NULL){
				fprintf(wimax_file, "%d", wd_status.link_status);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/mac", "w+")) != NULL){
				fprintf(wimax_file, "%02x:%02x:%02x:%02x:%02x:%02x", wd_status.mac[0], wd_status.mac[1], wd_status.mac[2], wd_status.mac[3], wd_status.mac[4], wd_status.mac[5]);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/rssi", "w+")) != NULL){
				fprintf(wimax_file, "%hd", wd_status.rssi);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/cinr", "w+")) != NULL){
				fprintf(wimax_file, "%f", wd_status.cinr);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/bsid", "w+")) != NULL){
				fprintf(wimax_file, "%02x:%02x:%02x:%02x:%02x:%02x", wd_status.bsid[0], wd_status.bsid[1], wd_status.bsid[2], wd_status.bsid[3], wd_status.bsid[4], wd_status.bsid[5]);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/txpwr", "w+")) != NULL){
				fprintf(wimax_file, "%hu", wd_status.txpwr);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/freq", "w+")) != NULL){
				fprintf(wimax_file, "%u", wd_status.freq);
				fclose(wimax_file);
			}

			if((wimax_file = fopen("/tmp/wimax/state", "w+")) != NULL){
				fprintf(wimax_file, "%d", wd_status.state);
				fclose(wimax_file);
			}

			len = fill_state_req(req_data);
			set_data(req_data, len);

			process_events_by_mask(500, WDS_STATE);

			wmlog_msg(2, "State: %s   Number: %d   Response: %d", wimax_states[wd_status.state], wd_status.state, wd_status.link_status);

			if (first_nego_flag) {
				first_nego_flag = 0;
				len = fill_find_network_req(req_data, 2);
				set_data(req_data, len);
			}

			process_events_by_mask(5000, WDS_LINK_STATUS);
		}
		
		sleep(SCAN_INTERVAL);
	}

	return 0;
}