⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 address.cpp

📁 AirFart监听 802.11流量
💻 CPP
字号:
/*   This file is part of AirFart.   AirFart is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   AirFart is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with AirFart; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include "address.h"Address:: Address(unsigned char* new_macaddr, char* new_ssid, char* new_vendor_info){	#ifdef DEBUG_ADDRESS		printf("Calling Address::Address()...\n");	#endif	macaddr = new unsigned char[6];	memcpy(macaddr,new_macaddr,6);	vendor_info = new_vendor_info;	ssid = strdup(new_ssid);	packet_count = 0;}Address:: ~Address() {	// I hope there aren't any memory leaks	// Delete all the Packet structs	for (int i = 0; i < signal_queue.size(); i++) {		delete signal_queue[i];			}		// Delete the macaddr	delete macaddr;}void Address:: set_macaddr(unsigned char* new_macaddr) {	#ifdef DEBUG_ADDRESS		printf("Calling Address::set_macaddr()...\n");	#endif	macaddr = new_macaddr;}void Address:: set_ssid(char* new_ssid) {	#ifdef DEBUG_ADDRESS		printf("Calling Address::set_ssid()...\n");	#endif	ssid = new_ssid;}unsigned char* Address:: get_macaddr() {	#ifdef DEBUG_ADDRESS		printf("Calling Address::get_macaddr()...\n");	#endif	return macaddr;}char* Address:: get_ssid() {	#ifdef DEBUG_ADDRESS		printf("Calling Address::get_ssid()...\n");	#endif	return ssid;}void Address:: add_strength(int sig_strength) {	#ifdef DEBUG_ADDRESS		printf("Calling Address::add_strength()...\n");	#endif	/*		Every time a packet comes in, this method pushes the signal strength onto the		signal_queue; after the number of packets received has passed NUM_OF_SIGNALS			the oldest strength is poped off and then the new signal strength is pushed on	*/	Packet* newpacket = new Packet();	newpacket->strength = sig_strength;	//newpacket->time = newtime;  // set this later, just skip for now	if (signal_queue.size() == NUM_OF_SIGNALS) {		// The queue is full; we need to pop the first one off the front before we 		// push another on		signal_queue.pop_front();		signal_queue.push_back(newpacket);	} else {		// Otherwise just push this packet on the back		signal_queue.push_back(newpacket);	}	// Increment the packets received counter 	packet_count++;}void Address:: print_strengths(){	/*		This is used for debugging purposes	*/		printf("\tStrength: %d\%\n", calc_avg());	/*	for (int i = 0; i < signal_queue.size(); i++) {		printf("\t\ti=%d: %d\n", i, signal_queue[i]->strength);	}	*/}int Address:: calc_avg() {	#ifdef DEBUG_ADDRESS		printf("Calling Address::calc_avg()...\n");	#endif	int avg_strength = 0;		for (int i = 0; i < signal_queue.size(); i++) {		avg_strength += signal_queue[i]->strength;			}	avg_strength = avg_strength / signal_queue.size();	return avg_strength;}char* Address:: get_vendor_info(){	#ifdef DEBUG_ADDRESS		printf("Calling Address::get_vendor_info()...\n");	#endif	return vendor_info;}int Address:: get_packet_count(){	/*		This returns the number of packets that have been received on this mac address	*/	return packet_count;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -