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

📄 rtmp_info.c

📁 TP Link 321 Linux Driver
💻 C
📖 第 1 页 / 共 5 页
字号:
	}	return 0;}int rt_ioctl_siwrts(struct net_device *dev,			   struct iw_request_info *info,			   struct iw_param *rts, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	u16 val;    //check if the interface is down	if ((dev->flags & IFF_UP) == 0)		 return -ENETDOWN;    if (pAdapter->RTUSBCmdThr_pid < 0)        return -ENETDOWN;	if (rts->disabled)		val = MAX_RTS_THRESHOLD;	else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)		return -EINVAL;	else if (rts->value == 0)		val = MAX_RTS_THRESHOLD;	else		val = rts->value;		if (val != pAdapter->PortCfg.RtsThreshold)		pAdapter->PortCfg.RtsThreshold = val;	return 0;}int rt_ioctl_giwrts(struct net_device *dev,			   struct iw_request_info *info,			   struct iw_param *rts, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;    if (pAdapter->RTUSBCmdThr_pid < 0)        return -ENETDOWN;	rts->value = pAdapter->PortCfg.RtsThreshold;	rts->disabled = (rts->value == MAX_RTS_THRESHOLD);	rts->fixed = 1;	return 0;}int rt_ioctl_siwfrag(struct net_device *dev,			struct iw_request_info *info,			struct iw_param *rts, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	u16 val;    //check if the interface is down	if ((dev->flags & IFF_UP) == 0)		 return -ENETDOWN;    if (pAdapter->RTUSBCmdThr_pid < 0)        return -ENETDOWN;	if (rts->disabled)		val = MAX_FRAG_THRESHOLD;	else if (rts->value >= MIN_FRAG_THRESHOLD || rts->value <= MAX_FRAG_THRESHOLD)		val = __cpu_to_le16(rts->value & ~0x1); /* even numbers only */	else if (rts->value == 0)		val = MAX_FRAG_THRESHOLD;	else		return -EINVAL;	pAdapter->PortCfg.FragmentThreshold = val;	return 0;}int rt_ioctl_giwfrag(struct net_device *dev,			struct iw_request_info *info,			struct iw_param *rts, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;    if (pAdapter->RTUSBCmdThr_pid < 0)        return -ENETDOWN;	rts->value = pAdapter->PortCfg.FragmentThreshold;	rts->disabled = (rts->value == 2346);	rts->fixed = 1;	return 0;}int rt_ioctl_siwencode(struct net_device *dev,			  struct iw_request_info *info,			  struct iw_point *erq, char *keybuf){	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) dev->priv;	union {		char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1];		NDIS_802_11_WEP keyinfo;	} WepKey;	int 	index, i, len;	CHAR	kid = 0;	#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT	if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli	{	    //check if the interface is down		if ((dev->flags & IFF_UP) == 0)			 return -ENETDOWN;	    if (pAd->RTUSBCmdThr_pid < 0)	        return -ENETDOWN;		DBGPRINT(RT_DEBUG_TRACE,"%s(): erq->length = %d, erq->flags = %x\n", __FUNCTION__, erq->length, erq->flags);				// Check if the request is disable the Encryption.		if (erq->flags & IW_ENCODE_DISABLED)		{			//Set the Wep/Cipher as Disabled			pAd->PortCfg.PairCipher = Ndis802_11WEPDisabled;			pAd->PortCfg.GroupCipher = Ndis802_11WEPDisabled;			pAd->PortCfg.WepStatus = Ndis802_11WEPDisabled;			//Set the AuthMode as Open.			pAd->PortCfg.AuthMode = Ndis802_11AuthModeOpen;						goto done;		}		/* Ok,  we need to enable Encryption  */		// Check if we have the KeyIdx in request. 		//  If index=0 => it means set key for current TxKey Indx, i.e., the DefaultKey,		//     index>0 => set key for key entry with index as (index-1).		index = (erq->flags & IW_ENCODE_INDEX);		if ((erq->length > IW_ENCODING_TOKEN_MAX) 			|| ((index < 0) || (index >= NR_WEP_KEYS)))			return -EINVAL;		index = ((index > 0) ? (index - 1) : pAd->PortCfg.DefaultKeyId);		// Set the Wep/Cipher as WEP enabled		pAd->PortCfg.PairCipher = Ndis802_11WEPEnabled;		pAd->PortCfg.GroupCipher = Ndis802_11WEPEnabled;		pAd->PortCfg.WepStatus = Ndis802_11WEPEnabled;				// Set the AuthMode depends on flags(IW_ENCODE_RESTRICTED/IW_ENCODE_OPEN) of request.		if (erq->flags & IW_ENCODE_RESTRICTED)			pAd->PortCfg.AuthMode = Ndis802_11AuthModeShared;		else			pAd->PortCfg.AuthMode = Ndis802_11AuthModeOpen;		// Set the key index/value		if(erq->length > 0)		{			// We need to set the key value into specific key index.			NdisZeroMemory(&WepKey, sizeof(WepKey));			// Does it possible the erq->length < WEP_SMALL_KEY_LEN ??			len = (erq->length >= WEP_LARGE_KEY_LEN ? WEP_LARGE_KEY_LEN : WEP_SMALL_KEY_LEN);						NdisZeroMemory(pAd->SharedKey[index].Key,  sizeof(pAd->SharedKey[index].Key));			NdisMoveMemory(pAd->SharedKey[index].Key, keybuf, len);			pAd->SharedKey[index].KeyLen = len;						NdisMoveMemory(WepKey.keyinfo.KeyMaterial, keybuf, len);			WepKey.keyinfo.KeyIndex = 0x80000000 + index;			WepKey.keyinfo.KeyLength = len;			DBGPRINT(RT_DEBUG_TRACE, "SharedKey[%d]:", index);			for (i=0; i < len; i++)				DBGPRINT_RAW(RT_DEBUG_TRACE, " %x", pAd->SharedKey[index].Key[i]);			DBGPRINT(RT_DEBUG_TRACE, "\n");						// need to enqueue cmd to thread			RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1);		} 		else		{			// Just set the defaultKey Index.			pAd->PortCfg.DefaultKeyId = index;		}		// for debug		for(i = 0; i < NR_WEP_KEYS; i++)		{			char *keyBuf = &pAd->SharedKey[i].Key[0];			DBGPRINT(RT_DEBUG_TRACE, "%s():SharedKey[%d]=0x%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x, KeyLen = %d, isDefault=%d!\n", 						__FUNCTION__, i, keyBuf[0],keyBuf[1], keyBuf[2], keyBuf[3], keyBuf[4], keyBuf[5], keyBuf[6],						keyBuf[7], keyBuf[8], keyBuf[9], keyBuf[10], keyBuf[11], keyBuf[12],pAd->SharedKey[i].KeyLen, 						(pAd->PortCfg.DefaultKeyId == i ? 1 : 0));		}			done:		pAd->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;				DBGPRINT(RT_DEBUG_TRACE, "%s():AuthMode=%x, WepStatus=%x!\n", 					__FUNCTION__, pAd->PortCfg.AuthMode, pAd->PortCfg.WepStatus);		return 0;	}	else	{#endif	    //check if the interface is down		if ((dev->flags & IFF_UP) == 0)			 return -ENETDOWN;	    if (pAd->RTUSBCmdThr_pid < 0)	        return -ENETDOWN;		NdisZeroMemory(&WepKey, sizeof(WepKey));				if (erq->flags & IW_ENCODE_DISABLED)		{			pAd->PortCfg.PairCipher = Ndis802_11WEPDisabled;			pAd->PortCfg.GroupCipher = Ndis802_11WEPDisabled;			pAd->PortCfg.WepStatus = Ndis802_11WEPDisabled;		}		else		{			pAd->PortCfg.PairCipher = Ndis802_11WEPEnabled;			pAd->PortCfg.GroupCipher = Ndis802_11WEPEnabled;			pAd->PortCfg.WepStatus = Ndis802_11WEPEnabled;		}		if (erq->flags & IW_ENCODE_RESTRICTED)			pAd->PortCfg.AuthMode = Ndis802_11AuthModeShared;		else 			pAd->PortCfg.AuthMode = Ndis802_11AuthModeOpen;		if(pAd->PortCfg.WepStatus == Ndis802_11WEPDisabled)			pAd->PortCfg.AuthMode = Ndis802_11AuthModeOpen;				if ((erq->flags & IW_ENCODE_DISABLED) == 0) 		{			/* Enable crypto. */			if (erq->length > IFNAMSIZ)				return -EINVAL;			/* Old solution to take  default key  */			index = (erq->flags & IW_ENCODE_INDEX) ;			if((index < 0) || (index > NR_WEP_KEYS))				return -EINVAL; 				DBGPRINT(RT_DEBUG_TRACE," erq->flags = %x\n",erq->flags);						if (index != 0)			{				pAd->PortCfg.DefaultKeyId = index -1;			}			if ((erq->length == 1) && (index == 0))			{				/* New solution to take  default key  when old way not work, not change KeyMaterial*/				NdisMoveMemory(&kid, keybuf, 1 );				if((index < 0) || (index >= NR_WEP_KEYS))					return -EINVAL; 									DBGPRINT(RT_DEBUG_TRACE,"kid = %d , erq->length = %d\n",kid, erq->length);				if (kid > 0)					pAd->PortCfg.DefaultKeyId = kid-1;				else 					pAd->PortCfg.DefaultKeyId = 0;			}			else			{					DBGPRINT(RT_DEBUG_TRACE,"DefaultKeyId = %d , erq->length = %d, flags 0x%x\n",pAd->PortCfg.DefaultKeyId, erq->length,erq->flags);				len = erq->length;				if(len > WEP_LARGE_KEY_LEN)					len = WEP_LARGE_KEY_LEN;									// If this instruction default key				NdisZeroMemory(pAd->SharedKey[pAd->PortCfg.DefaultKeyId].Key,  MAX_LEN_OF_KEY);				NdisMoveMemory(pAd->SharedKey[pAd->PortCfg.DefaultKeyId].Key, keybuf, len);				NdisMoveMemory(WepKey.keyinfo.KeyMaterial, keybuf, len);				WepKey.keyinfo.KeyIndex = 0x80000000 + pAd->PortCfg.DefaultKeyId;				WepKey.keyinfo.KeyLength = len;				pAd->SharedKey[pAd->PortCfg.DefaultKeyId].KeyLen =(UCHAR) (len <= WEP_SMALL_KEY_LEN ? WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN);				DBGPRINT(RT_DEBUG_TRACE,"SharedKey	");				for (i=0; i < 5;i++)					DBGPRINT_RAW(RT_DEBUG_TRACE,"	%x ", pAd->SharedKey[pAd->PortCfg.DefaultKeyId].Key[i]);				DBGPRINT(RT_DEBUG_TRACE,   "\n");				// need to enqueue cmd to thread				RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1);			}					}		DBGPRINT(RT_DEBUG_TRACE, "==>rt_ioctl_siwencode::AuthMode=%x\n",pAd->PortCfg.AuthMode);		DBGPRINT(RT_DEBUG_TRACE, "==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAd->PortCfg.DefaultKeyId , pAd->SharedKey[pAd->PortCfg.DefaultKeyId].KeyLen);		DBGPRINT(RT_DEBUG_TRACE, "==>rt_ioctl_siwencode::WepStatus=%x\n",pAd->PortCfg.WepStatus);		return 0;#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT	}#endif}intrt_ioctl_giwencode(struct net_device *dev,			  struct iw_request_info *info,			  struct iw_point *erq, char *key){	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)dev->priv;	int keyIdx;	     if (pAd->RTUSBCmdThr_pid < 0)        return -ENETDOWN;	keyIdx = erq->flags & IW_ENCODE_INDEX;	DBGPRINT(RT_DEBUG_TRACE, "%s(): Request keyIdx=%d\n", __FUNCTION__, keyIdx);	if (pAd->PortCfg.WepStatus == Ndis802_11WEPDisabled)	{		erq->length = 0;		erq->flags = IW_ENCODE_DISABLED;		return 0;	} 	// The keyIndex of user space is start from 1 to NR_WEP_KEYS(4), but start from 0 in our driver.	if (keyIdx > NR_WEP_KEYS)		return -EINVAL; 	// If the keyIdx send from user space is 0, it means want to get the DefaultKey.	keyIdx = (keyIdx == 0 ? pAd->PortCfg.DefaultKeyId : (keyIdx - 1));			// Does it possible erq->length < SharedKey[keyIdx].KeyLen ???	if (erq->length < pAd->SharedKey[keyIdx].KeyLen)		return -EINVAL;	// copy wep key with specific keyIndex and set related flags.	erq->length = pAd->SharedKey[keyIdx].KeyLen;	memcpy(key, pAd->SharedKey[keyIdx].Key, erq->length);	erq->flags = (keyIdx + 1);					/* return to user space, so need plus 1 */	erq->flags |= IW_ENCODE_ENABLED;			/* Encoding enabled */	if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeShared)		erq->flags |= IW_ENCODE_RESTRICTED;		/* Refuse non-encoded packets */	else		erq->flags |= IW_ENCODE_OPEN;			/* Accept non-encoded packets */			return 0;}#if WIRELESS_EXT > 17static int rt_ioctl_siwauth(struct net_device *dev,					struct iw_request_info *info,					union iwreq_data *wrqu, char *extra){	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)dev->priv;	struct iw_param *param = &wrqu->param;		    //check if the interface is down	if ((dev->flags & IFF_UP) == 0)		 return -ENETDOWN;    if (pAd->RTUSBCmdThr_pid < 0)        return -ENETDOWN;			switch (param->flags & IW_AUTH_INDEX) {#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT		case IW_AUTH_WPA_VERSION:			if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli			{				pAd->PortCfg.wx_wpa_version = param->value;				DBGPRINT(RT_DEBUG_TRACE, "%s(): set wx_wpa_version=%d!\n", __FUNCTION__, pAd->PortCfg.wx_wpa_version);			}			break;					case IW_AUTH_CIPHER_PAIRWISE:			if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli			{				pAd->PortCfg.wx_pairwise = param->value;				DBGPRINT(RT_DEBUG_TRACE, "%s(): set wx_pairwise=%d!\n", __FUNCTION__, pAd->PortCfg.wx_pairwise);			}			break;					case IW_AUTH_CIPHER_GROUP:			if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli			{				pAd->PortCfg.wx_groupCipher= param->value;				DBGPRINT(RT_DEBUG_TRACE, "%s(): set wx_groupCipher=%d!\n", __FUNCTION__, pAd->PortCfg.wx_groupCipher);			}			break;					case IW_AUTH_KEY_MGMT:			if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli			{				pAd->PortCfg.wx_key_mgmt = param->value;				DBGPRINT(RT_DEBUG_TRACE, "%s(): set wx_key_mgmt=%d!\n", __FUNCTION__, pAd->PortCfg.wx_key_mgmt);			}			break;		case IW_AUTH_80211_AUTH_ALG:			if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli			{				pAd->PortCfg.wx_auth_alg = param->value;				DBGPRINT(RT_DEBUG_TRACE, "%s(): set wx_auth_alg=%d!\n", __FUNCTION__, pAd->PortCfg.wx_auth_alg);			}			break;#endif		case IW_AUTH_TKIP_COUNTERMEASURES:			// WPA MIC error should block association attempt for 60 seconds		    pAd->PortCfg.bBlockAssoc = (param->value > 0 ? TRUE : FALSE);			DBGPRINT(RT_DEBUG_TRACE, "%s(): set bBlockAssoc=%d!\n", __FUNCTION__, pAd->PortCfg.bBlockAssoc);			break;		case IW_AUTH_DROP_UNENCRYPTED:			DBGPRINT(RT_DEBUG_TRACE, "%s(): UserSpace call SIOCAUTH to do IW_AUTH_DROP_UNENCRYPTED, value=%d!\n", __FUNCTION__, param->value);			break;		case IW_AUTH_WPA_ENABLED:			//ret = ipw_wpa_enable(priv, param->value); //What should our driver do in here			DBGPRINT(RT_DEBUG_TRACE, "%s(): set IW_AUTH_WPA_ENABLED=%d!\n", __FUNCTION__, param->value);			break;		case IW_AUTH_RX_UNENCRYPTED_EAPOL:			//TODO, allow_unencrypted_eapol, yeah, we always support unencrypted EAPOL can pass.			DBGPRINT(RT_DEBUG_TRACE, "%s(): set IW_AUTH_RX_UNENCRYPTED_EAPOL=%d!\n", __FUNCTION__, param->value);			break;		case IW_AUTH_ROAMING_CONTROL:			//TODO			DBGPRINT(RT_DEBUG_TRACE, "%s(): set IW_AUTH_ROAMING_CONTROL=%d!\n", __FUNCTION__, param->value);			break;		case IW_AUTH_PRIVACY_INVOKED:			//TODO			DBGPRINT(RT_DEBUG_TRACE, "%s(): set IW_AUTH_PRIVACY_INVOKED=%d!\n", __FUNCTION__, param->value);			break;		default:			DBGPRINT(RT_DEBUG_TRACE, "%s(): unknown setting =0x%x!\n", __FUNCTION__, param->flags);			return -EOPNOTSUPP;	}#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT	if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli		pAd->PortCfg.wx_need_sync |= 1;#endif 	return 0;	}

⌨️ 快捷键说明

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