예제 #1
0
int is_usr_pw_matching(char *usr, char *pw)
{
	int i;
	struct login_param logindata[USR_NUM_MAX];

	if (0==rt_strcmp(usr, "yeejoin-admin") && 0==rt_strcmp(pw, "2012)%@*"))
		return 1;

	read_syscfgdata_tbl(SYSCFGDATA_TBL_LOGINDATA, 0, logindata);
	for (i=0; i<USR_NUM_MAX; ++i) {
		if ((0==rt_strcmp(usr, logindata[i].login.usr))
			&& (0==rt_strcmp(pw, logindata[i].login.pw)))
		    return 1;
	}

	return 0;
}
예제 #2
0
rt_err_t at24cxx_init(const char * device_name, const char * i2c_bus_name)
{
    int i;
    struct rt_i2c_bus_device* i2c_bus_device;
    
    /* initialize mutex */
    if (rt_mutex_init(&at24cxx_device.lock, device_name, RT_IPC_FLAG_FIFO) != RT_EOK)
    {
        rt_kprintf("init lock mutex failed\n");
        return -RT_ENOSYS;
    }

    /* we got i2c bus */
    i2c_bus_device = rt_i2c_bus_device_find(i2c_bus_name);
    if(i2c_bus_device == RT_NULL)
    {
        AT24CXX_TRACE("i2c device %s not found!\r\n", i2c_bus_device);
        return -RT_ENOSYS;
    }
    at24cxx_device.bus = i2c_bus_device;
    
    /* find match */
    for(i=0;i<ARRAY_SIZE(at24cxx_attr_table);i++)
    {
        if(!rt_strcmp(at24cxx_attr_table[i].name, device_name))
        {
            AT24CXX_TRACE("%s supported hardware:%s\r\n", __func__, device_name);
            at24cxx_device.attr = at24cxx_attr_table[i];
            break;
        }
    }
    
    /* devices not supported */
    if( i == ARRAY_SIZE(at24cxx_attr_table))
    {
        return RT_ERROR;
    }
    
    at24cxx_device.geometry.bytes_per_sector = at24cxx_device.attr.page_size;
    at24cxx_device.geometry.block_size = at24cxx_device.attr.page_size;
    at24cxx_device.geometry.sector_count = at24cxx_device.attr.total_size/at24cxx_device.attr.page_size;
    
    /* register device */
    at24cxx_device.parent.type    = RT_Device_Class_Block;
    at24cxx_device.parent.init    = init;
    at24cxx_device.parent.open    = open;
    at24cxx_device.parent.close   = close;
    at24cxx_device.parent.read 	  = read;
    at24cxx_device.parent.write   = write_page;
    at24cxx_device.parent.control = control;
    /* no private */
    at24cxx_device.parent.user_data = RT_NULL;

    rt_device_register(&at24cxx_device.parent, device_name,
                       RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
    
    return RT_EOK;
}
예제 #3
0
void* dlsym(void *handle, const char* symbol)
{
	int i;
	rt_module_t module;

	RT_ASSERT(handle != RT_NULL);

	module = (rt_module_t)handle;

	for(i=0; i<module->nsym; i++) {
		if (rt_strcmp(module->symtab[i].name, symbol) == 0)
			return (void*)module->symtab[i].addr;
	}

	return RT_NULL;
}
예제 #4
0
static rt_err_t mrvl_scan_card(struct rt_wlan_device* device, WlanConfig *config)
{
	rt_err_t result = RT_EOK;
	WlanCard *card;
	ScanResultItem * item;
	int ret, i;
	rt_uint8_t *scan_buf;

	RT_ASSERT(device != RT_NULL);
	card = WLAN_CARD(device);

	scan_buf = (rt_uint8_t*)rt_calloc(1, SCAN_BUFSZ);
	if (scan_buf == NULL)
	{
		WlanDebug(WlanErr,"WlanScan:alloc memory failed\r\n");
		return -RT_ERROR;
	}

	ret = SendSpecificScanConfig(card, config, scan_buf, SCAN_BUFSZ);
	if (ret != 0)
	{
		WlanDebug(WlanErr,"Filter channels scan failed\r\n");
		return -RT_ERROR;
	}

	if (card->ScanResultcount == 0)
	{
		ret = SendScanToGetAPInfo(card, scan_buf, SCAN_BUFSZ);
		if (ret != 0)
		{
			WlanDebug(WlanErr,"All channels scan failed\r\n");
			return -RT_ERROR;
		}
	}

	WlanDebug(WlanErr,"AP totaly %d\r\n",card->ScanResultcount);
	for (i = 0; i < card->ScanResultcount; i++)
	{
		item = card->ScanResultInfo + i;
		rt_kprintf("AP[%d]: %s  ", i + 1, item->Ssid.Ssid);
		rt_kprintf("BSSID:%x-%x-%x-%x-%x-%x ", item->MacAddress[0],
				item->MacAddress[1], item->MacAddress[2],
				item->MacAddress[3], item->MacAddress[4],
				item->MacAddress[5]);
		rt_kprintf("Channel:%d ", item->Channel);
		rt_kprintf("RSSI:0x%x ", item->Rssi);
		rt_kprintf("Privacy:0x%x ", item->Privacy);
		switch (item->Security)
		{
		case WEP:
			rt_kprintf("[WEP ]");
			break;
		case WPA_PSK:
			rt_kprintf("[WPA ]");
			break;
		case WPA2_PSK:
			rt_kprintf("[WPA2]");
			break;
		case NoSecurity:
			rt_kprintf("[NONE]");
		default:
			break;
		}
		rt_kprintf("\r\n");

		if (rt_strcmp(item->Ssid.Ssid, config->SSID) == 0)
		{
			/* set bs address and channel */
			config->channel = item->Channel;
			config->security = item->Security;
			if(item->Privacy == 0)
            {
                if(item->Security == WEP)
                {
                    config->security = NoSecurity;
                }
                else
                {
                    WlanDebug(WlanErr, "Privacy = 0 but Security != WEP\r\n");
                }
            }
			
			rt_memcpy(config->MacAddr, item->MacAddress, sizeof(item->MacAddress));
			break;
		}
	}

	/* release scan buffer */
	rt_free(scan_buf);

	card->ScanResulMuxsize=0;
	card->ScanResultInfo = RT_NULL;
	card->ScanResultcount=0;
}