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

📄 ieee80211softmac_io.c

📁 LINUX 2.6.17.4的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
				cpu_to_le16(WLAN_CAPABILITY_IBSS);	/*	(*pkt)->capability |= mac->ieee->short_slot ? 			cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;	 */	(*pkt)->capability |= mac->ieee->sec.level ?			cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;			/* Fill in Listen Interval (?) */	(*pkt)->listen_interval = cpu_to_le16(10);	/* Fill in the current AP MAC */	memcpy((*pkt)->current_ap, mac->ieee->bssid, ETH_ALEN);		data = (u8 *)(*pkt)->info_element;	/* Add SSID */	data = ieee80211softmac_add_essid(data, &net->essid); 	/* Add Rates */	data = ieee80211softmac_frame_add_rates(data, &mac->ratesinfo);	/* Return packet size */	return (data - (u8 *)(*pkt));}/* Create an authentication packet */static u32ieee80211softmac_auth(struct ieee80211_auth **pkt, 	struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,	u16 transaction, u16 status){	u8 *data;	/* Allocate Packet */	(*pkt) = (struct ieee80211_auth *)ieee80211softmac_alloc_mgt(		2 +		/* Auth Algorithm */		2 +		/* Auth Transaction Seq */		2 +		/* Status Code */		 /* Challenge Text IE */		mac->ieee->open_wep ? 0 : 		1 + 1 + WLAN_AUTH_CHALLENGE_LEN	);		if (unlikely((*pkt) == NULL))		return 0;	ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid);			/* Algorithm */	(*pkt)->algorithm = mac->ieee->open_wep ? 		cpu_to_le16(WLAN_AUTH_OPEN) :		cpu_to_le16(WLAN_AUTH_SHARED_KEY);	/* Transaction */	(*pkt)->transaction = cpu_to_le16(transaction);	/* Status */	(*pkt)->status = cpu_to_le16(status);		data = (u8 *)(*pkt)->info_element;	/* Challenge Text */	if(!mac->ieee->open_wep){		*data = MFIE_TYPE_CHALLENGE;		data++;				/* Copy the challenge in */		// *data = challenge length		// data += sizeof(u16);		// memcpy(data, challenge, challenge length);		// data += challenge length;				/* Add the full size to the packet length */	}	/* Return the packet size */	return (data - (u8 *)(*pkt));}/* Create a disassocation or deauthentication packet */static u32ieee80211softmac_disassoc_deauth(struct ieee80211_disassoc **pkt,	struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,	u16 type, u16 reason){	/* Allocate Packet */	(*pkt) = (struct ieee80211_disassoc *)ieee80211softmac_alloc_mgt(2);	if (unlikely((*pkt) == NULL))		return 0;	ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), type, net->bssid, net->bssid);	/* Reason */	(*pkt)->reason = cpu_to_le16(reason);	/* Return the packet size */	return (2 + IEEE80211_3ADDR_LEN);}/* Create a probe request packet */static u32ieee80211softmac_probe_req(struct ieee80211_probe_request **pkt,	struct ieee80211softmac_device *mac, struct ieee80211softmac_essid *essid){	u8 *data;		/* Allocate Packet */	(*pkt) = (struct ieee80211_probe_request *)ieee80211softmac_alloc_mgt(		/* SSID of requested network */		1 + 1 + IW_ESSID_MAX_SIZE +		/* Rates IE */		1 + 1 + IEEE80211SOFTMAC_MAX_RATES_LEN +		/* Extended Rates IE */		1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN 	);	if (unlikely((*pkt) == NULL))		return 0;	ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_PROBE_REQ, NULL, NULL);			data = (u8 *)(*pkt)->info_element;	/* Add ESSID (can be NULL) */	data = ieee80211softmac_add_essid(data, essid);	/* Add Rates */	data = ieee80211softmac_frame_add_rates(data, &mac->ratesinfo);	/* Return packet size */	return (data - (u8 *)(*pkt));}/* Create a probe response packet *//* FIXME: Not complete */static u32ieee80211softmac_probe_resp(struct ieee80211_probe_response **pkt,	struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net){	u8 *data;	/* Allocate Packet */	(*pkt) = (struct ieee80211_probe_response *)ieee80211softmac_alloc_mgt(		8 +		/* Timestamp */		2 +		/* Beacon Interval */		2 +		/* Capability Info */				/* SSID IE */		1 + 1 + IW_ESSID_MAX_SIZE +		7 + 		/* FH Parameter Set */		2 +		/* DS Parameter Set */		8 +		/* CF Parameter Set */		4 		/* IBSS Parameter Set */	);		if (unlikely((*pkt) == NULL))		return 0;	ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_PROBE_RESP, net->bssid, net->bssid);	data = (u8 *)(*pkt)->info_element;	/* Return the packet size */	return (data - (u8 *)(*pkt));}/* Sends a manangement packet * FIXME: document the use of the arg parameter * for _AUTH: (transaction #) | (status << 16) */intieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,	void *ptrarg, u32 type, u32 arg){	void *pkt = NULL;	u32 pkt_size = 0;	switch(type) {	case IEEE80211_STYPE_ASSOC_REQ:		pkt_size = ieee80211softmac_assoc_req((struct ieee80211_assoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);		break;	case IEEE80211_STYPE_REASSOC_REQ:		pkt_size = ieee80211softmac_reassoc_req((struct ieee80211_reassoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);		break;	case IEEE80211_STYPE_AUTH:		pkt_size = ieee80211softmac_auth((struct ieee80211_auth **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, (u16)(arg & 0xFFFF), (u16) (arg >> 16));		break;	case IEEE80211_STYPE_DISASSOC:	case IEEE80211_STYPE_DEAUTH:		pkt_size = ieee80211softmac_disassoc_deauth((struct ieee80211_disassoc **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, type, (u16)(arg & 0xFFFF));		break;	case IEEE80211_STYPE_PROBE_REQ:		pkt_size = ieee80211softmac_probe_req((struct ieee80211_probe_request **)(&pkt), mac, (struct ieee80211softmac_essid *)ptrarg);		break;	case IEEE80211_STYPE_PROBE_RESP:		pkt_size = ieee80211softmac_probe_resp((struct ieee80211_probe_response **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);		break;	default:                printkl(KERN_DEBUG PFX "Unsupported Management Frame type: %i\n", type);                return -EINVAL;	};	if(pkt_size == 0 || pkt == NULL) {		printkl(KERN_DEBUG PFX "Error, packet is nonexistant or 0 length\n");		return -ENOMEM;	}		/* Send the packet to the ieee80211 layer for tx */	/* we defined softmac->mgmt_xmit for this. Should we keep it	 * as it is (that means we'd need to wrap this into a txb),	 * modify the prototype (so it matches this function),	 * or get rid of it alltogether?	 * Does this work for you now?	 */	ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *)pkt, pkt_size);	kfree(pkt);	return 0;}/* Create an rts/cts frame */static u32ieee80211softmac_rts_cts(struct ieee80211_hdr_2addr **pkt,	struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, 	u32 type){	/* Allocate Packet */	(*pkt) = kmalloc(IEEE80211_2ADDR_LEN, GFP_ATOMIC);		memset(*pkt, 0, IEEE80211_2ADDR_LEN);	if((*pkt) == NULL)		return 0;	ieee80211softmac_hdr_2addr(mac, (*pkt), type, net->bssid);	return IEEE80211_2ADDR_LEN;}/* Sends a control packet */static intieee80211softmac_send_ctl_frame(struct ieee80211softmac_device *mac,	struct ieee80211softmac_network *net, u32 type, u32 arg){	void *pkt = NULL;	u32 pkt_size = 0;		switch(type) {	case IEEE80211_STYPE_RTS:	case IEEE80211_STYPE_CTS:		pkt_size = ieee80211softmac_rts_cts((struct ieee80211_hdr_2addr **)(&pkt), mac, net, type);		break;	default:		printkl(KERN_DEBUG PFX "Unsupported Control Frame type: %i\n", type);		return -EINVAL;	}	if(pkt_size == 0)		return -ENOMEM;		/* Send the packet to the ieee80211 layer for tx */	ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *) pkt, pkt_size);	kfree(pkt);	return 0;}

⌨️ 快捷键说明

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