Exemplo n.º 1
0
static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
{
	char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };

	if (iw->ssid(ifname, buf))
		memset(buf, 0, sizeof(buf));

	return format_ssid(buf);
}
Exemplo n.º 2
0
/**
 * Lookup a station attached to an access point
 */
static struct SQDB_SubStation *
sqdb_lookup_substation(
	 struct SQDB *sqdb, 
	 const unsigned char *mac_address,
	 const unsigned char *bssid)
{
	struct SQDB_AccessPoint *access_point;
	struct SQDB_SubStation *substation;

	/* Find the access point first */
	access_point = sqdb_create_bssid(sqdb, bssid);

	/* Lookup the mac address within this access point */
	for (substation = access_point->substations; substation; substation = substation->next) {
		if (memcmp(mac_address, substation->mac_address, 6) == 0)
			break;
	}

	/* If not found, create a new one */
	if (substation == NULL) {
		struct XMAC *xmac;
		char myssid[256];
		unsigned myssid_length;

		substation = (struct SQDB_SubStation*)malloc(sizeof(*substation));
		memset(substation, 0, sizeof(*substation));
		memcpy(substation->mac_address, mac_address, 6);
		substation->next = access_point->substations;
		access_point->substations = substation;
		
		/* Create a link to this from the master MAC address registery */
		xmac = xmac_create(&sqdb->macs, mac_address);
		xmac->type = STATION_TYPE_STA;
		xmac->sta = substation;


		myssid_length = format_ssid(myssid, sizeof(myssid), (char*)access_point->ssid.value,  access_point->ssid.length);

		SQUIRREL_EVENT("[%02X:%02X:%02X:%02X:%02X:%02X] "
			"SSID=\"%.*s\" "
			"%.*s"
			"station=%02X:%02X:%02X:%02X:%02X:%02X"
			"\n",
			PRINTMAC(bssid),
			myssid_length, myssid, 
			(access_point->ssid.length>16)?0:(16-access_point->ssid.length), "                 ",
			PRINTMAC(mac_address)
			);
	}
	
	return substation;
}
Exemplo n.º 3
0
static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
{
	int i, x, len;
	char buf[IWINFO_BUFSIZE];
	struct iwinfo_scanlist_entry *e;

	if (iw->scanlist(ifname, buf, &len))
	{
		printf("Scanning not possible\n\n");
		return;
	}
	else if (len <= 0)
	{
		printf("No scan results\n\n");
		return;
	}

	for (i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++)
	{
		e = (struct iwinfo_scanlist_entry *) &buf[i];

		printf("Cell %02d - Address: %s\n",
			x,
			format_bssid(e->mac));
		printf("          ESSID: %s\n",
			format_ssid(e->ssid));
		printf("          Mode: %s  Channel: %s\n",
			e->mode ? (char *)e->mode : "unknown",
			format_channel(e->channel));
		printf("          Signal: %s  Quality: %s/%s\n",
			format_signal(e->signal - 0x100),
			format_quality(e->quality),
			format_quality_max(e->quality_max));
		printf("          Encryption: %s\n\n",
			format_encryption(&e->crypto));
	}
}
Exemplo n.º 4
0
unsigned sqdb_add_probe_request(
	struct SQDB *sqdb, 
	const unsigned char *src_mac,
	struct SQDB_String ssid,
	struct SQDB_RateList rates1,
	struct SQDB_RateList rates2
)
{
	struct SQDB_Station *entry;
	unsigned is_new = false;

	pixie_enter_critical_section(sqdb->cs);

	/*  
	 * Look up the entry in the hash table 
	 */
	{
		struct SQDB_Station **r_entry;
		unsigned index = bssid_hash(src_mac);

		r_entry = &sqdb->stations[index];
		while ((*r_entry) && memcmp((*r_entry)->mac_address, src_mac, 6) != 0)
			r_entry = &((*r_entry)->next);
		if (*r_entry == NULL) {
			struct XMAC *xmac;
			char myssid[256];
			unsigned myssid_length;

			*r_entry = (struct SQDB_Station*)malloc(sizeof(**r_entry));
			memset(*r_entry, 0, sizeof(**r_entry));
			memcpy((*r_entry)->mac_address, src_mac, 6);
			sqdb_string_copy(&(*r_entry)->ssid.ssid, &ssid);
			is_new = true;

			/* Create a link to this from the master MAC address registery */
			xmac = xmac_create(&sqdb->macs, src_mac);
			xmac->type = STATION_TYPE_STA_ALONE;
			xmac->sta_alone = *r_entry;

			myssid_length = format_ssid(myssid, sizeof(myssid), (const char*)ssid.value,  ssid.length);

			SQUIRREL_EVENT(" %02X:%02X:%02X:%02X:%02X:%02X  "
				"probe=\"%.*s\" "
				"%.*s"
				"\n",
				PRINTMAC(src_mac),
				myssid_length, myssid, 
				(ssid.length>16)?0:(16-ssid.length), "                 "
				);
		}
		entry = *r_entry;
	}
    
    entry->probe_count++;

	/*
	 * See if the SSID of the network has changed. This should
	 * never really happen.
	 */
	if (!sqdb_string_is_equal(&entry->ssid.ssid, &ssid)) {
		struct EntrySSID **r;
		unsigned found = 0;

		for (r=&entry->ssid.next; *r; r = &((*r)->next)) {
			if (sqdb_string_is_equal(&(*r)->ssid, &ssid)) {
				found = 1;
				break;
			}
		}
		if (!found) {
			char myssid[256];
			unsigned myssid_length;

			myssid_length = format_ssid(myssid, sizeof(myssid), (const char*)ssid.value,  ssid.length);

			*r = (struct EntrySSID*)malloc(sizeof(**r));
			memset(*r, 0, sizeof(**r));
			sqdb_string_copy(&(*r)->ssid, &ssid);
			SQUIRREL_EVENT(" %02X:%02X:%02X:%02X:%02X:%02X  probe=\"%.*s\"\n", 
				PRINTMAC(src_mac), myssid_length, myssid);
		}
	}

	/*
	 * See if the Rates fields are the same
	 */
	if (!sqdb_ratesfield_equal(&entry->rates1, &rates1)) {
		sqdb_ratesfield_copy(&entry->rates1, &rates1);
	}
	if (!sqdb_ratesfield_equal(&entry->rates2, &rates2)) {
		sqdb_ratesfield_copy(&entry->rates2, &rates2);
	}


	pixie_leave_critical_section(sqdb->cs);
	return 0;
}