Esempio n. 1
0
void set_supported_rate(u8* SupportedRates, uint mode) 
{
_func_enter_;

	_memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
	
	switch (mode)
	{
		case WIRELESS_11B:
			_memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
			break;
		
		case WIRELESS_11G:
		case WIRELESS_11A:	
			_memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
			break;
		
		case WIRELESS_11BG:
			_memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
			_memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN);
			break;
	
	}
_func_exit_;	
}
Esempio n. 2
0
void os_indicate_disconnect( _adapter *adapter )
{
   //RT_PMKID_LIST   backupPMKIDList[ NUM_PMKID_CACHE ];
   u8              backupPMKIDIndex = 0;
   u8              backupTKIPCountermeasure = 0x00;
      
_func_enter_;

   indicate_wx_disassoc_event(adapter);	
   netif_carrier_off(adapter->pnetdev);
	
   if(adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)//802.1x
   {		 
        // Added by Albert 2009/02/18
        // We have to backup the PMK information for WiFi PMK Caching test item.
        //
        // Backup the btkip_countermeasure information.
        // When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds.
        
        _memset( &backupPMKIDList[ 0 ], 0x00, sizeof( RT_PMKID_LIST ) * NUM_PMKID_CACHE );

        _memcpy( &backupPMKIDList[ 0 ], &adapter->securitypriv.PMKIDList[ 0 ], sizeof( RT_PMKID_LIST ) * NUM_PMKID_CACHE );
        backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
        backupTKIPCountermeasure = adapter->securitypriv.btkip_countermeasure;

       _memset((unsigned char *)&adapter->securitypriv, 0, sizeof (struct security_priv));
       _init_timer(&(adapter->securitypriv.tkip_timer),adapter->pnetdev, use_tkipkey_handler, adapter);

       // Added by Albert 2009/02/18
       // Restore the PMK information to securitypriv structure for the following connection.
       _memcpy( &adapter->securitypriv.PMKIDList[ 0 ], &backupPMKIDList[ 0 ], sizeof( RT_PMKID_LIST ) * NUM_PMKID_CACHE );
       adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
       adapter->securitypriv.btkip_countermeasure = backupTKIPCountermeasure;

	adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
	adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;

   }
   else //reset values in securitypriv 
   {
   	//if(adapter->mlmepriv.fw_state & WIFI_STATION_STATE)
   	//{
	struct security_priv *psec_priv=&adapter->securitypriv;

	psec_priv->dot11AuthAlgrthm =dot11AuthAlgrthm_Open;  //open system
	psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
	psec_priv->dot11PrivacyKeyIndex = 0;

	psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
	psec_priv->dot118021XGrpKeyid = 1;

	psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
	psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;	
	psec_priv->wps_phase = _FALSE;
   	//}
   }

_func_exit_;

}
Esempio n. 3
0
int get_sec_ie(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len)
{
	u8 authmode, sec_idx, i;
	u8 wpa_oui[4]={0x0,0x50,0xf2,0x01};
	uint 	cnt;
	
_func_enter_;

	//Search required WPA or WPA2 IE and copy to sec_ie[ ]
	
	cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
	
	sec_idx=0;
		
	while(cnt<in_len)
	{
		authmode=in_ie[cnt];
		
		if((authmode==_WPA_IE_ID_)&&(_memcmp(&in_ie[cnt+2], &wpa_oui[0],4)==_TRUE))
		{	
				RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n get_wpa_ie: sec_idx=%d in_ie[cnt+1]+2=%d\n",sec_idx,in_ie[cnt+1]+2));		

				_memcpy(wpa_ie, &in_ie[cnt],in_ie[cnt+1]+2);

				for(i=0;i<(in_ie[cnt+1]+2);i=i+8){
					RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",wpa_ie[i],wpa_ie[i+1],wpa_ie[i+2],wpa_ie[i+3],wpa_ie[i+4],wpa_ie[i+5],wpa_ie[i+6],wpa_ie[i+7]));
				}

				*wpa_len=in_ie[cnt+1]+2;
				cnt+=in_ie[cnt+1]+2;  //get next
		}
		else
		{
			if(authmode==_WPA2_IE_ID_)
			{
				RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n get_rsn_ie: sec_idx=%d in_ie[cnt+1]+2=%d\n",sec_idx,in_ie[cnt+1]+2));		

				_memcpy(rsn_ie, &in_ie[cnt],in_ie[cnt+1]+2);

				for(i=0;i<(in_ie[cnt+1]+2);i=i+8){
					RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",rsn_ie[i],rsn_ie[i+1],rsn_ie[i+2],rsn_ie[i+3],rsn_ie[i+4],rsn_ie[i+5],rsn_ie[i+6],rsn_ie[i+7]));
				}

				*rsn_len=in_ie[cnt+1]+2;
				cnt+=in_ie[cnt+1]+2;  //get next
			}
			else
			{
				cnt+=in_ie[cnt+1]+2;   //get next
			}	
		}
		
	}
	
_func_exit_;

	return (*rsn_len+*wpa_len);
	
}
Esempio n. 4
0
u8 setstakey_cmd(_adapter *padapter, u8 *psta, u8 unicast_key)
{
	struct cmd_obj		*ph2c;
	struct set_stakey_parm	*psetstakey_para;
	struct cmd_priv		*pcmdpriv = &padapter->cmdpriv;
	struct set_stakey_rsp	*psetstakey_rsp = NULL;
	struct mlme_priv	*pmlmepriv = &padapter->mlmepriv;
	struct security_priv	*psecuritypriv = &padapter->securitypriv;
	struct sta_info		*sta = (struct sta_info*)psta;
	u8 res = _SUCCESS;

_func_enter_;

	ph2c = (struct cmd_obj*)_malloc(sizeof(struct cmd_obj));
	if (ph2c == NULL) {
		res = _FAIL;
		goto exit;
	}

	psetstakey_para = (struct set_stakey_parm*)_malloc(sizeof(struct set_stakey_parm));
	if (psetstakey_para == NULL) {
		_mfree((u8 *) ph2c, sizeof(struct cmd_obj));
		res = _FAIL;
		goto exit;
	}

	psetstakey_rsp = (struct set_stakey_rsp*)_malloc(sizeof(struct set_stakey_rsp));
	if (psetstakey_rsp == NULL) {
		_mfree((u8 *) ph2c, sizeof(struct cmd_obj));
		_mfree((u8 *) psetstakey_para, sizeof(struct set_stakey_parm));
		res = _FAIL;
		goto exit;
	}

	init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
	ph2c->rsp = (u8 *) psetstakey_rsp;
	ph2c->rspsz = sizeof(struct set_stakey_rsp);

	_memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);

	if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
		psetstakey_para->algorithm =(unsigned char) psecuritypriv->dot11PrivacyAlgrthm;
	else
		GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, _FALSE);

	if (unicast_key == _TRUE) {
		_memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
        } else {
		_memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid-1].skey, 16);
        }

	enqueue_cmd(pcmdpriv, ph2c);

exit:

_func_exit_;

	return res;
}
Esempio n. 5
0
int usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype)
{
	unsigned int pipe;
	int status;
	u8 reqtype;
	
	struct dvobj_priv  *pdvobjpriv = (struct dvobj_priv  *)pintfpriv->intf_dev;   
	struct usb_device *udev=pdvobjpriv->pusbdev;
		
	// Added by Albert 2010/02/09
	// For mstar platform, mstar suggests the address for USB IO should be 16 bytes alignment.
	// Trying to fix it here.

	u8 *palloc_buf, *pIo_buf;

	palloc_buf = _malloc( (u32) len + 16);
	
	if ( palloc_buf== NULL)
	{
		printk( "[%s] Can't alloc memory for vendor request\n", __FUNCTION__ );
		return(-1);
	}
	
	pIo_buf = palloc_buf + 16 -((uint)(palloc_buf) & 0x0f );
	
		
	if (requesttype == 0x01)
	{
		pipe = usb_rcvctrlpipe(udev, 0);//read_in
		reqtype =  RTL871X_VENQT_READ;		
	} 
	else 
	{
		pipe = usb_sndctrlpipe(udev, 0);//write_out
		reqtype =  RTL871X_VENQT_WRITE;		
		_memcpy( pIo_buf, pdata, len);
	}		
	
	status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, HZ/2);
	
	if (status < 0)
       {
		RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("reg 0x%x, usb_read8 TimeOut! status:0x%x value=0x%x\n", value, status, *(u32*)pdata));
       }
	else if ( status > 0 )   // Success this control transfer.
	{
               if ( requesttype == 0x01 )
               {   // For Control read transfer, we have to copy the read data from pIo_buf to pdata.
                       _memcpy( pdata, pIo_buf,  status );
               }
	}

	_mfree( palloc_buf, (u32) len + 16 );

	return status;

}
Esempio n. 6
0
sint amsdu_wlanhdr_to_ethhdr (union recv_frame *precvframe,  _pkt *skb)
{
	//remove the wlanhdr and add the eth_hdr
	u8			srcaddr[6];
	u8			desaddr[6];
	u8			RemoveLLCFlag=_FALSE;
	u8			*pLLC, *pFrame;
	u8			NeedCheckTypes=1;
	u8			LLCHeader[1][5]={	// Remember to check NeedCheckTypes
										{0x00,0x00,0x00,0x81,0x37},
									};
	
	int i;
	
_func_enter_;	
		pLLC = skb->data;

		// Get Source Address and Destination Address
		_memcpy(desaddr, pLLC - ETHERNET_HEADER_SIZE, ETH_ALEN);
		_memcpy(srcaddr, pLLC - ETHERNET_HEADER_SIZE + ETHERNET_ADDRESS_LENGTH, ETH_ALEN);

		
		pFrame = pLLC -ETHERNET_HEADER_SIZE;
		if(	*(pLLC + 0) == 0xaa	&& 
			*(pLLC + 1) == 0xaa	&& 
			*(pLLC + 2) == 0x03
			)
		{	
			// check if need remove LLC header
		
			RemoveLLCFlag=_TRUE;
			for(i=0;i<NeedCheckTypes;i++)
			{
				if(_memcmp((pLLC + 3), LLCHeader[i], 5))
				{
					RemoveLLCFlag=_FALSE;
					break;
				}
			}
			if(RemoveLLCFlag)
				pFrame += 8;
		}
			
		_memcpy(pFrame	, desaddr, ETH_ALEN);
		_memcpy(pFrame+6, srcaddr, ETH_ALEN);

		//2 Insert length field if LLC is not removed
		if(!RemoveLLCFlag)
		{
			u16 len=skb->len;

			*(pFrame + 12)=(u8)(len>>8);
			*(pFrame + 13)=(u8)(len&0xff);
		}
Esempio n. 7
0
/**
 * @ingroup DEV
 *
 * @param dmx_device_info
 */
static void bw_spi_dimmer_init(dmx_device_info_t *dmx_device_info, const uint8_t *dmx_data) {
	struct _rdm_sub_devices_info *rdm_sub_devices_info =  &(dmx_device_info)->rdm_sub_devices_info;

	(void)bw_spi_dimmer_start(&(dmx_device_info->device_info));
	bw_spi_dimmer_output(&dmx_device_info->device_info, 0);

	(void *)_memcpy(rdm_sub_devices_info, &sub_device_info, sizeof(struct _rdm_sub_devices_info));
	dmx_device_info->rdm_sub_devices_info.dmx_start_address = dmx_device_info->dmx_start_address;
	(void *)_memcpy(dmx_device_info->rdm_sub_devices_info.device_label, device_label, device_label_len);
	dmx_device_info->rdm_sub_devices_info.device_label_length = device_label_len;
}
Esempio n. 8
0
/*time_t*/ long mktime(/*struct tm*/ void *timp) {
#if !CAM_DRYOS
	return _mktime(timp);
#else
	int timp_ext[10]; // struct tm + a ptr
	_memcpy(timp_ext,timp,9*sizeof(int));
	timp_ext[9]=0;
	long retval = _mktime_ext(&timp_ext);
	_memcpy(timp,timp_ext,9*sizeof(int));
	return retval;
#endif
}
Esempio n. 9
0
u8 *set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source,
				unsigned int *frlen)
{
	_memcpy((void *)pbuf, (void *)source, len);
	*frlen = *frlen + len;
	return (pbuf + len);
}
Esempio n. 10
0
UByte voice_disConnectUser(PPIDType user)
{
    if (QuickData[user].EmptyMarker == 0) {
        ApplicationInstanceType *applicationInstanceData;
        PMIDType pmid;

        PPID2PMID((PMIDType *) pmid, user);
        applicationInstanceData = getApplicationInstance(pmid);

        if (applicationInstanceData->state == connected) {
            SignalType *CcReleasePrim;
            UByte Data[2] = { 0x2e, 00 };

            NewSignal(sizeof(SignalType) + 2, (void **) &CcReleasePrim);
            memcpy(CcReleasePrim->Address, pmid, 3);
            CcReleasePrim->Address[3] = 0x00;
            _memcpy(getCcReleasePrimTypeIE(CcReleasePrim), Data, 2);
            SendSignal((SignalType *) CcReleasePrim, IWU_PROCESS_ID, IWU_PRIMITIVE, CC_RELEASE_prim);
            applicationInstanceData->state = idle;
            return 0;
        } else {
            return 2;
        }
    } else {
        return 3;
    }
}
Esempio n. 11
0
int mbr_read(char* mbr_sector, unsigned long drive_total_sectors, unsigned long *part_start_sector,  unsigned long *part_length){
// return value: 1 - success, 0 - fail
// called only in VxWorks

 int offset=0x10; // points to partition #2
 int valid;

 if ((mbr_sector[0x1FE]!=0x55) || (mbr_sector[0x1FF]!=0xAA)) return 0; // signature check

 mbr_buf=_AllocateUncacheableMemory(SECTOR_SIZE);
 _memcpy(mbr_buf,mbr_sector,SECTOR_SIZE);
 drive_sectors=drive_total_sectors;

 while(offset>=0) {

  *part_start_sector=(*(unsigned short*)(mbr_sector+offset+0x1C8)<<16) | *(unsigned short*)(mbr_sector+offset+0x1C6);
  *part_length=(*(unsigned short*)(mbr_sector+offset+0x1CC)<<16) | *(unsigned short*)(mbr_sector+offset+0x1CA);

  valid= (*part_start_sector) && (*part_length) &&
         (*part_start_sector<=drive_total_sectors) &&
         (*part_start_sector+*part_length<=drive_total_sectors) &&
         ((mbr_sector[offset+0x1BE]==0) || (mbr_sector[offset+0x1BE]==0x80)); // status: 0x80 (active) or 0 (non-active)

  if (valid && ((mbr_sector[0x1C2+offset]==0x0B) || (mbr_sector[0x1C2+offset]==0x0C))) break;   // FAT32 secondary partition

  offset-=0x10;

 }

 return valid;
}
Esempio n. 12
0
u8 setbasicrate_cmd(_adapter *padapter, u8 *rateset)
{
	struct cmd_obj*			ph2c;
	struct setbasicrate_parm*	pssetbasicratepara;
	struct cmd_priv*		pcmdpriv=&padapter->cmdpriv;
	u8	res = _SUCCESS;

_func_enter_;

	ph2c = (struct cmd_obj*)_malloc(sizeof(struct cmd_obj));
	if (ph2c == NULL) {
		res= _FAIL;
		goto exit;
	}
	pssetbasicratepara = (struct setbasicrate_parm*)_malloc(sizeof(struct setbasicrate_parm)); 

	if (pssetbasicratepara == NULL) {
		_mfree((u8*) ph2c, sizeof(struct cmd_obj));
		res = _FAIL;
		goto exit;
	}

	init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, _SetBasicRate_CMD_);

	_memcpy(pssetbasicratepara->basicrates, rateset, NumRates);	   

	enqueue_cmd(pcmdpriv, ph2c);	
exit:	
_func_exit_;		
	return res;

}
Esempio n. 13
0
int mbr_read_dryos(unsigned long drive_total_sectors, char* mbr_sector ){
// Called only in DRYOS
 mbr_buf=_AllocateUncacheableMemory(SECTOR_SIZE);
 _memcpy(mbr_buf,mbr_sector,SECTOR_SIZE);
 drive_sectors=drive_total_sectors;
 return drive_total_sectors;
}
Esempio n. 14
0
u8 setrttbl_cmd(_adapter  *padapter, struct setratable_parm *prate_table)
{
	struct cmd_obj*			ph2c;
	struct setratable_parm *	psetrttblparm;	
	struct cmd_priv 			*pcmdpriv=&padapter->cmdpriv;
	u8	res=_SUCCESS;
_func_enter_;	

	ph2c = (struct cmd_obj*)_malloc(sizeof(struct cmd_obj));
	if(ph2c==NULL){
		res= _FAIL;
		goto exit;
		}
	psetrttblparm = (struct setratable_parm*)_malloc(sizeof(struct setratable_parm)); 

	if(psetrttblparm==NULL){
		_mfree((unsigned char *) ph2c, sizeof(struct	cmd_obj));
		res= _FAIL;
		goto exit;
	}

	init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable));

	_memcpy(psetrttblparm,prate_table,sizeof(struct setratable_parm));

	enqueue_cmd(pcmdpriv, ph2c);	
exit:
_func_exit_;	
	return res;

}
Esempio n. 15
0
void memcpy(void *target, const void *source, size_t len)
{
    int ch = DMA_CHANNEL;
    unsigned char *dp;
    
    if(len < 4)
        _memcpy(target, source, len);
    
    if(((unsigned int)source < 0xa0000000) && len)
        dma_cache_wback_inv((unsigned long)source, len);
    
    if(((unsigned int)target < 0xa0000000) && len)
        dma_cache_wback_inv((unsigned long)target, len);
    
    REG_DMAC_DSAR(ch) = PHYSADDR((unsigned long)source);
    REG_DMAC_DTAR(ch) = PHYSADDR((unsigned long)target); 
    REG_DMAC_DTCR(ch) = len / 4;
    REG_DMAC_DRSR(ch) = DMAC_DRSR_RS_AUTO;
    REG_DMAC_DCMD(ch) = DMAC_DCMD_DAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | DMAC_DCMD_DS_32BIT;
    
    REG_DMAC_DCCSR(ch) = DMAC_DCCSR_EN | DMAC_DCCSR_NDES;
    while (REG_DMAC_DTCR(ch));
    if(len % 4)
    {
        dp = (unsigned char*)((unsigned int)target + (len & (4 - 1)));
        for(i = 0; i < (len % 4); i++)
            *dp++ = *source;
    }
}
Esempio n. 16
0
int get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
{
	int match;
	uint cnt;	
	u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04};


	cnt=12;	
	match=_FALSE;
	while(cnt<in_len)
	{
		eid = in_ie[cnt];
		
		if((eid==_WPA_IE_ID_)&&(_memcmp(&in_ie[cnt+2], wps_oui, 4)==_TRUE))
		{
			_memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2);
			
			*wps_ielen = in_ie[cnt+1]+2;
			
			cnt+=in_ie[cnt+1]+2;

			match = _TRUE;
			break;
		}
		else
		{
			cnt+=in_ie[cnt+1]+2; //goto next	
		}		
		
	}	

	return match;

}
Esempio n. 17
0
u8 setMacAddr_cmd(_adapter *padapter, u8 *mac_addr)
{
	struct cmd_priv 		*pcmdpriv = &padapter->cmdpriv;
	struct cmd_obj			*ph2c;
	struct SetMacAddr_param	*psetMacAddr_para;

	u8 res = _SUCCESS;

_func_enter_;

	ph2c = (struct cmd_obj*)_malloc(sizeof(struct cmd_obj));
	if (ph2c == NULL) {
		res = _FAIL;
		goto exit;
	}

	psetMacAddr_para = (struct SetMacAddr_param*)_malloc(sizeof(struct SetMacAddr_param));
	if (psetMacAddr_para == NULL) {
		_mfree((u8 *) ph2c, sizeof(struct cmd_obj));
		res = _FAIL;
		goto exit;
	}

	init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para, _SetMacAddress_CMD_);

	_memcpy(psetMacAddr_para->MacAddr, mac_addr,ETH_ALEN);

	enqueue_cmd(pcmdpriv, ph2c);

exit:

_func_exit_;

	return res;
 }
Esempio n. 18
0
/*
 * from in memory data structure sb, copy dsuper_block
 * into buffer block. then send it for writing to write_blocks
 */
void testfs_write_super_block(struct super_block *sb) {
	char block[BLOCK_SIZE] = { 0 };

	assert(sizeof(struct dsuper_block) <= BLOCK_SIZE);
	sb->sb.modification_time = time(NULL);
	_memcpy(block, &sb->sb, sizeof(struct dsuper_block));
	write_blocks(sb, block, 0, 1);
}
Esempio n. 19
0
File: if.c Progetto: Benjins/GBADev
void AddDialogNode(DialogTree* tree, DialogNode node){
	DialogNode* newNodes = malloc(sizeof(DialogNode) * (tree->nodeCount+1));
	_memcpy(newNodes, tree->nodes, sizeof(DialogNode) * tree->nodeCount);
	newNodes[tree->nodeCount] = node;
	free(tree->nodes);
	tree->nodes = newNodes;
	tree->nodeCount++;
}
Esempio n. 20
0
static void rtc_read_time(struct tm *timeinfo)
{
    _memcpy((void*)timeinfo, (void*)&rtc_timeinfo, sizeof(struct tm));
    timeinfo->tm_mon++;
    timeinfo->tm_mday++;
    timeinfo->tm_wday++;
    timeinfo->tm_yday++;
}
Esempio n. 21
0
void
_main(void)
{
#if DEBUG
	usbgecko_init();
	usbgecko_printf("_main()\n");
#endif

	ios_reload();
#if DEBUG
	usbgecko_printf("ios_reload()\n");
#endif

	sync_before_read((void*)0x93010010, 0x1800);
	_memcpy((void*)0x80001800, (void*)0x93010010, 0x1800);
	sync_after_write((void*)0x80001800, 0x1800);
	if(*(vu32*)0xC0001804 == 0x53545542 && *(vu32*)0xC0001808 == 0x48415858) //stubhaxx
	{
		__asm(
			"sync ; isync\n"
			"lis %r3, 0x8000\n"
			"ori %r3, %r3, 0x1800\n"
			"mtlr %r3\n"
			"blr\n"
		);
	}
#if DEBUG
	usbgecko_printf("no loader stub, using internal\n");
#endif

	ios_cleanup();
#if DEBUG
	usbgecko_printf("ios_cleanup()\n");
#endif
	es_init();
#if DEBUG
	usbgecko_printf("es_init()\n");
#endif
	u64 ios_titleid = TITLE_ID(1, 35); //just to get away from the kernel
	es_launchtitle(ios_titleid);
#if DEBUG
	usbgecko_printf("es_launchtitle()\n");
#endif
	es_init();
#if DEBUG
	usbgecko_printf("es_init()\n");
#endif
	es_launchtitle(HBC_LULZ);
	es_launchtitle(HBC_108);
	es_launchtitle(HBC_JODI);
	es_launchtitle(HBC_HAXX);
	es_launchtitle(SYSTEM_MENU);
#if DEBUG
	usbgecko_printf("es_launchtitle()\n");
#endif

	while (1);
}
Esempio n. 22
0
/**
 * @ingroup DEV
 *
 * @param dmx_device_info
 */
static void ws2812_init(dmx_device_info_t * dmx_device_info, const uint8_t *dmx_data) {
	struct _rdm_sub_devices_info *rdm_sub_devices_info =  &(dmx_device_info)->rdm_sub_devices_info;

	bcm2835_spi_begin();

	(void *)_memcpy(rdm_sub_devices_info, &sub_device_info, sizeof(struct _rdm_sub_devices_info));
	dmx_device_info->rdm_sub_devices_info.dmx_start_address = dmx_device_info->dmx_start_address;
	(void *)_memcpy(dmx_device_info->rdm_sub_devices_info.device_label, device_label, device_label_len);
	dmx_device_info->rdm_sub_devices_info.device_label_length = device_label_len;

	// WS2812 specific
	if ((dmx_device_info->pixel_count == (uint8_t)0) || ((uint16_t) dmx_device_info->pixel_count * (uint16_t) WS2812_SLOTS_PER_PIXEL > (uint16_t) DMX_UNIVERSE_SIZE)) {
		dmx_device_info->pixel_count = (uint8_t) ((uint16_t) DMX_UNIVERSE_SIZE / (uint16_t) WS2812_SLOTS_PER_PIXEL);
	}

	dmx_device_info->rdm_sub_devices_info.dmx_footprint = dmx_device_info->pixel_count * (uint16_t) WS2812_SLOTS_PER_PIXEL;
	dmx_device_info->rdm_sub_devices_info.rdm_personalities->slots = dmx_device_info->pixel_count * (uint16_t) WS2812_SLOTS_PER_PIXEL;
}
Esempio n. 23
0
u8 set_802_11_add_wep(_adapter* padapter, NDIS_802_11_WEP *wep)
{
	u8	bdefaultkey;
	u8	btransmitkey;
	sint	keyid;
	struct security_priv *psecuritypriv = &padapter->securitypriv;
	u8	ret = _SUCCESS;

_func_enter_;

	bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? _FALSE : _TRUE;	//for ???
	btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? _TRUE : _FALSE;	//for ???
	keyid = wep->KeyIndex & 0x3fffffff;

	if (keyid >= WEP_KEYS) {
		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActSet_802_11_ADD_WEP: keyid>4 FAIL!\n"));
		ret = _FALSE;
		goto exit;
	}

	switch (wep->KeyLength)
	{
		case 5:
			psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
			RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:wep->KeyLength=5\n"));
			break;
		case 13:
			psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
			RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:wep->KeyLength=13\n"));
			break;
		default:
			psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
			RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:wep->KeyLength!=5 or 13\n"));
			break;
	}

	RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:befor memcpy, wep->KeyLength=0x%x wep->KeyIndex=0x%x  keyid =%x\n",wep->KeyLength,wep->KeyIndex,keyid));

	_memcpy(psecuritypriv->dot11DefKey[keyid].skey, &wep->KeyMaterial, wep->KeyLength);
	psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
	psecuritypriv->dot11PrivacyKeyIndex = keyid;

	RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("MgntActSet_802_11_ADD_WEP:security key material: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
		psecuritypriv->dot11DefKey[keyid].skey[0],psecuritypriv->dot11DefKey[keyid].skey[1],psecuritypriv->dot11DefKey[keyid].skey[2],
		psecuritypriv->dot11DefKey[keyid].skey[3],psecuritypriv->dot11DefKey[keyid].skey[4],psecuritypriv->dot11DefKey[keyid].skey[5],
		psecuritypriv->dot11DefKey[keyid].skey[6],psecuritypriv->dot11DefKey[keyid].skey[7],psecuritypriv->dot11DefKey[keyid].skey[8],
		psecuritypriv->dot11DefKey[keyid].skey[9],psecuritypriv->dot11DefKey[keyid].skey[10],psecuritypriv->dot11DefKey[keyid].skey[11],
		psecuritypriv->dot11DefKey[keyid].skey[12]));

	if (set_key(padapter, psecuritypriv, keyid) == _FAIL)
		ret = _FALSE;
exit:

_func_exit_;

	return ret;
}
Esempio n. 24
0
unsigned char *get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
{	
	int len;
	u16 val16;
	unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};		
	u8 *pbuf = pie;

	while(1) 
	{
		pbuf = get_ie(pbuf, _WPA_IE_ID_, &len, limit);

		if (pbuf) {

			//check if oui matches...
			if (_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == _FALSE) {

				goto check_next_ie;
			}

			//check version...
			_memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));

			val16 = le16_to_cpu(val16);
			if (val16 != 0x0001)
				goto check_next_ie;	

			*wpa_ie_len = *(pbuf + 1);

			return pbuf;

		}
		else {

			*wpa_ie_len = 0;			
			return NULL;
		}

check_next_ie:

		limit = limit - (pbuf - pie) - 2 - len;

		if (limit <= 0)
			break;

		pbuf += (2 + len);
		
	}
	
	*wpa_ie_len = 0;
	
	return NULL;

}
Esempio n. 25
0
//
// Added for WPA2-PSK, by Annie, 2005-09-20.
//
u8
query_802_11_capability(
	_adapter*		Adapter,
	u8*			pucBuf,
	u32 *		pulOutLen
)
{
	static NDIS_802_11_AUTHENTICATION_ENCRYPTION szAuthEnc[] = 
	{
		{Ndis802_11AuthModeOpen, Ndis802_11EncryptionDisabled}, 
		{Ndis802_11AuthModeOpen, Ndis802_11Encryption1Enabled},
		{Ndis802_11AuthModeShared, Ndis802_11EncryptionDisabled}, 
		{Ndis802_11AuthModeShared, Ndis802_11Encryption1Enabled},
		{Ndis802_11AuthModeWPA, Ndis802_11Encryption2Enabled}, 
		{Ndis802_11AuthModeWPA, Ndis802_11Encryption3Enabled},
		{Ndis802_11AuthModeWPAPSK, Ndis802_11Encryption2Enabled}, 
		{Ndis802_11AuthModeWPAPSK, Ndis802_11Encryption3Enabled},
		{Ndis802_11AuthModeWPANone, Ndis802_11Encryption2Enabled}, 
		{Ndis802_11AuthModeWPANone, Ndis802_11Encryption3Enabled},
		{Ndis802_11AuthModeWPA2, Ndis802_11Encryption2Enabled}, 
		{Ndis802_11AuthModeWPA2, Ndis802_11Encryption3Enabled},
		{Ndis802_11AuthModeWPA2PSK, Ndis802_11Encryption2Enabled}, 
		{Ndis802_11AuthModeWPA2PSK, Ndis802_11Encryption3Enabled}
	};	
	static ULONG	ulNumOfPairSupported = sizeof(szAuthEnc)/sizeof(NDIS_802_11_AUTHENTICATION_ENCRYPTION);
	NDIS_802_11_CAPABILITY * pCap = (NDIS_802_11_CAPABILITY *)pucBuf;
	u8*	pucAuthEncryptionSupported = (u8*) pCap->AuthenticationEncryptionSupported;


	pCap->Length = sizeof(NDIS_802_11_CAPABILITY);
	if(ulNumOfPairSupported > 1 )
		pCap->Length += 	(ulNumOfPairSupported-1) * sizeof(NDIS_802_11_AUTHENTICATION_ENCRYPTION);
	
	pCap->Version = 2;	
	pCap->NoOfPMKIDs = NUM_PMKID_CACHE;	
	pCap->NoOfAuthEncryptPairsSupported = ulNumOfPairSupported;

	if( sizeof (szAuthEnc) <= 240 )		// 240 = 256 - 4*4	// SecurityInfo.szCapability: only 256 bytes in size.
	{
		_memcpy( pucAuthEncryptionSupported, (u8*)szAuthEnc,  sizeof (szAuthEnc) );
		*pulOutLen = pCap->Length;
		return _TRUE;
	}
	else
	{
		*pulOutLen = 0;
		RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("_query_802_11_capability(): szAuthEnc size is too large.\n"));
		return _FALSE;
	}
}
Esempio n. 26
0
/*
sitesurvey_cmd(~)
	### NOTE:#### (!!!!)
	MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
*/
u8 sitesurvey_cmd(_adapter  *padapter, NDIS_802_11_SSID *pssid)
{
	struct cmd_obj*		ph2c;
	struct sitesurvey_parm*	psurveyPara;
	struct cmd_priv 	*pcmdpriv = &padapter->cmdpriv;
	struct mlme_priv	*pmlmepriv = &padapter->mlmepriv;

_func_enter_;	
	
	ph2c = (struct cmd_obj*)_malloc(sizeof(struct cmd_obj));
	if (ph2c == NULL)
		return _FAIL;

	psurveyPara = (struct sitesurvey_parm*)_malloc(sizeof(struct sitesurvey_parm)); 

	if (psurveyPara == NULL) {
		_mfree((unsigned char*) ph2c, sizeof(struct cmd_obj));
		return _FAIL;
	}

	free_network_queue(padapter);
	RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("\nflush  network queue\n\n"));

	init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey));

	psurveyPara->bsslimit = cpu_to_le32(48);
	psurveyPara->passive_mode = cpu_to_le32(1);
	psurveyPara->ss_ssidlen= cpu_to_le32(0);// pssid->SsidLength;

	if (pssid->SsidLength)
	{
		_memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength);
		psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength);
	}
	else
	{
		_memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1);
	}

	set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);

	enqueue_cmd(pcmdpriv, ph2c);

	_set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);

_func_exit_;		

	return _SUCCESS;
}
Esempio n. 27
0
u32 set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr)
{	
	u32 a_len;

	*pbuf = attr_id;
		
	*(u16*)(pbuf + 1) = cpu_to_le16(attr_len);

	if(pdata_attr)
		_memcpy(pbuf + 3, pdata_attr, attr_len);		
		
	a_len = attr_len + 3;
		
	return a_len;
}
Esempio n. 28
0
void putc(unsigned char c)
{
	u_short vid_mem_spot;

	//lock_mutex_block(&putc_mutex);

	switch(c)
	{
		case '\n':			// new line
			_csr_y++;
			_csr_x = 0;
			break;

		case '\r':			// carrige return
			_csr_y++;
			_csr_x = 0;
			break;

		case '\b':
			_csr_x--;
			break;

		default:			// normal charactor
			vid_mem_spot = ((_csr_y  * 80) + _csr_x);
			vid_mem_spot = vid_mem_spot << 1;	// multiply by 2

			vidmem2[vid_mem_spot] = c;
			vidmem2[vid_mem_spot + 1] = 0x07;	// white on black text
			_csr_x++;
			break;
	};

	if(_csr_x > 79)		// last charactor was at the end of the line
	{
		_csr_y++;	// next line down
		_csr_x = 0;
	};
	if(_csr_y > 24)		// we are at the bottom visable line
	{
		_memcpy(0xB8000, 0xB8000+(80*2), 24*80*2);	// scroll the video memory up a line
		_memsetw(0xB8000+(24*80*2), 0x0720, 80);	// clear the bottom line
		_csr_y=24;
	};

	update_cursor(_csr_y, _csr_x);

	//unlock_mutex(&putc_mutex);
};
Esempio n. 29
0
//	attr_content: The output buffer, contains the "body field" of P2P attribute.
//	attr_contentlen: The data length of the "body field" of P2P attribute.
int get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen)
{
	int match;
	uint cnt = 0;	
	u8 attr_id, p2p_oui[4]={0x50,0x6F,0x9A,0x09};


	match=_FALSE;

	if ( ( p2p_ie[ 0 ] != _VENDOR_SPECIFIC_IE_ ) ||
		( _memcmp( p2p_ie + 2, p2p_oui , 4 ) != _TRUE ) )
	{
		return( match );
	}

	//	1 ( P2P IE ) + 1 ( Length ) + 3 ( OUI ) + 1 ( OUI Type )
	cnt = 6;
	while( cnt < p2p_ielen )
	{
		u16	attrlen = le16_to_cpu(*(u16*)(p2p_ie + cnt + 1 ));
		
		attr_id = p2p_ie[cnt];
		if( attr_id == target_attr_id )
		{
			//	3 -> 1 byte for attribute ID field, 2 bytes for length field
			if(attr_content)
			_memcpy( attr_content, &p2p_ie[ cnt + 3 ], attrlen );
			
			if(attr_contentlen)
			*attr_contentlen = attrlen;
			
			cnt += attrlen + 3;

			match = _TRUE;
			break;
		}
		else
		{
			cnt += attrlen + 3; //goto next	
		}		
		
	}	

	return match;

}
Esempio n. 30
0
int get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *attr_content, uint *attr_contentlen)
{
	int match;
	uint cnt = 0;	
	u8 wps_oui[4]={0x00,0x50,0xF2,0x04};
	u16	attr_id;


	match=_FALSE;

	if ( ( wps_ie[ 0 ] != _VENDOR_SPECIFIC_IE_ ) ||
		( _memcmp( wps_ie + 2, wps_oui , 4 ) != _TRUE ) )
	{
		return( match );
	}

	//	1 ( WPS IE ) + 1 ( Length ) + 4 ( WPS OUI )
	cnt = 6;
	while( cnt < wps_ielen )
	{
		//	2 -> the length of WPS attribute type field.
		u16	attrlen = be16_to_cpu(*(u16*)(wps_ie + cnt + 2 ));
		
		attr_id = be16_to_cpu( *(u16*) ( wps_ie + cnt ) );
		if( attr_id == target_attr_id )
		{
			//	3 -> 1 byte for attribute ID field, 2 bytes for length field
			_memcpy( attr_content, &wps_ie[ cnt + 4 ], attrlen );
			
			*attr_contentlen = attrlen;
			
			cnt += attrlen + 4;

			match = _TRUE;
			break;
		}
		else
		{
			cnt += attrlen + 4; //goto next	
		}		
		
	}	

	return match;

}