Exemplo n.º 1
0
int airpcap_getchannel(struct tx80211 *in_tx)
{
	struct airpcap_data *apcap = in_tx->extra;
	unsigned int channel;

	if (AirpcapGetDeviceChannel(apcap->ad, &channel) != 1) {
		return TX80211_ENOCHANSET;
	}

	return channel;
}
Exemplo n.º 2
0
////////////////////////////////////////////////////////////////////////
//							main
////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
	PAirpcapHandle Ad;
	u_int channel;
	char name[255];
	char* p;

	beacon_total_length = 0;
	probe_total_length = 0;

	//
	// Ask the user to select an adapter. Configure it and open it.
	//
	Ad = getAirPcapAdapter();
	if (Ad == NULL)
	{
		exitApp(-1);
	}

	//
	// Get adapter channel
	//
	if (!AirpcapGetDeviceChannel(Ad, &channel))
	{
		printf("Error: error getting adapter channel.");
		exitApp(-1);
	}

	while(TRUE)
	{
		//
		// Get AP name from user
		//
		printf("AP Name: ");
		flushall();         /* kill any characters left in buffer */
		fgets(name, sizeof(name), stdin);

		//
		// Remove the ending \n from the string
		//
		if((p = strchr(name, '\n')) != NULL)
			*p = '\0';

		//
		// Max length of AP name is 32 characters
		//
		if (strlen(name) <= 32)
		{
			break;
		}
		else
		{
			printf("Error: AP name too long. Name must be 32 characters or less.\n\n");
		}
	}

	//
	// Now that we know the AP name and channel we
	// can make the beacon and probe response packets.
	//
	makePackets(name, (u_int8)channel);

	//
	// Start the listening thread
	//
	_beginthread(listenForProbeRequest, 0, Ad);

	//
	// Start looking for user exit key
	//
	_beginthread(waitForExit, 0, NULL);

	//
	// Notify the user that we are up and running
	//
	printf("\nStarted on channel %u!\n", channel);

	while (TRUE)
	{
		//
		// Send off a beacon
		//
		if (!AirpcapWrite(Ad, (char*)beacon, beacon_total_length))
		{
			printf("\nError sending beacon: %s\n", AirpcapGetLastError(Ad));
			exitApp(-1);
		}

		//
		// Wait 50ms
		//
		Sleep(50);
	}

	return 0;
}