Example #1
0
File: util.c Project: sygard/rac
const char*
get_packet_type_name(int type)
{
	switch (type & IEEE80211_FCTL_FTYPE) {
	case IEEE80211_FTYPE_MGMT:
		if (MGMT_NAME_INDEX(type) <
		   sizeof(mgmt_names)/sizeof(struct pkt_names)) {
			if (mgmt_names[MGMT_NAME_INDEX(type)].c)
				return mgmt_names[MGMT_NAME_INDEX(type)].name;
		}
		break;
	case IEEE80211_FTYPE_CTL:
		if (CTRL_NAME_INDEX(type) <
		   sizeof(ctrl_names)/sizeof(struct pkt_names)) {
			if (ctrl_names[CTRL_NAME_INDEX(type)].c)
				return ctrl_names[CTRL_NAME_INDEX(type)].name;
		}
		break;
	case IEEE80211_FTYPE_DATA:
		if (DATA_NAME_INDEX(type) <
		   sizeof(data_names)/sizeof(struct pkt_names)) {
			if (data_names[DATA_NAME_INDEX(type)].c)
				return data_names[DATA_NAME_INDEX(type)].name;
		}
		break;
	}
	return "UNKNOW";
}
Example #2
0
struct pkt_name
get_packet_struct(u_int16_t type) {
	u_int16_t index;

	if (type == 1) /* special case for bad FCS */
		return badfcs;

	if (WLAN_FRAME_IS_MGMT(type)) {
		index = MGMT_NAME_INDEX(type);
		if (index < sizeof(mgmt_names)/sizeof(struct pkt_name)) {
			if (mgmt_names[index].c)
				return mgmt_names[index];
		}
	} else if (WLAN_FRAME_IS_CTRL(type)) {
		index = CTRL_NAME_INDEX(type);
		if (index < sizeof(ctrl_names)/sizeof(struct pkt_name)) {
			if (ctrl_names[index].c)
				return ctrl_names[index];
		}
	} else if (WLAN_FRAME_IS_DATA(type)) {
		index = DATA_NAME_INDEX(type);
		if (index < sizeof(data_names)/sizeof(struct pkt_name)) {
			if (data_names[index].c)
				return data_names[index];
		}
	}
	return unknow;
}