/* Function to get custom MAC address */
int
dhd_custom_get_mac_address(unsigned char *buf)
{
	int ret = 0;

	WL_TRACE(("%s Enter\n", __FUNCTION__));
	if (!buf)
		return -EINVAL;

	/* Customer access to MAC address stored outside of DHD driver */
#if defined(CONFIG_MACH_MAHIMAHI) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
	/* Lin - this will call wifi_control_data->get_mac_addr (dhd_linux.c) */
	ret = wifi_get_mac_addr(buf);
#endif

#ifdef EXAMPLE_GET_MAC
	/* EXAMPLE code */
	{
		struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
		bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
	}
#endif /* EXAMPLE_GET_MAC */

	return ret;
}
예제 #2
0
/* Function to get custom MAC address */
int
dhd_custom_get_mac_address(unsigned char *buf)
{
    int ret = 0;

    WL_TRACE(("%s Enter\n", __FUNCTION__));
    if (!buf)
        return -EINVAL;

    /* Customer access to MAC address stored outside of DHD driver */
#if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
    if ((mac[0] != 0) || (mac[1] != 0)) {
        bcopy((char *)&mac, buf, 6);
        return ret;
    }
    ret = wifi_get_mac_addr(buf);
#endif

#ifdef EXAMPLE_GET_MAC
    /* EXAMPLE code */
    {
        struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
        bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
    }
#endif /* EXAMPLE_GET_MAC */

    return ret;
}
예제 #3
0
/* Function to get custom MAC address */
int
dhd_custom_get_mac_address(unsigned char *buf)
{
	int ret = 0;
	WL_TRACE(("%s Enter\n", __FUNCTION__));
	if (!buf)
		return -EINVAL;

	/* Customer access to MAC address stored outside of DHD driver */
#ifdef CONFIG_WIFI_CONTROL_FUNC
	ret = wifi_get_mac_addr(buf);
#endif /* CONFIG_WIFI_CONTROL_FUNC */
#ifdef CONFIG_WIFI_CONTROL_EXPORT
	memcpy(buf, bcm_wlan_mac, sizeof(bcm_wlan_mac));
#endif /* CONFIG_WIFI_CONTROL_EXPORT */

#ifdef EXAMPLE_GET_MAC
	/* EXAMPLE code */
	{
		struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
		bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
	}
#endif /* EXAMPLE_GET_MAC */

	return ret;
}
int
dhd_custom_get_mac_address(unsigned char *buf)
{
	int ret = 0;

	WL_TRACE(("%s Enter\n", __FUNCTION__));
	if (!buf)
		return -EINVAL;

	
#if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
	ret = wifi_get_mac_addr(buf);
#endif

#ifdef EXAMPLE_GET_MAC
	
	{
		struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
		bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
	}
#endif 

	return ret;
}
예제 #5
0
/* Function to get custom MAC address */
int
dhd_custom_get_mac_address(unsigned char *buf)
{
	int ret = 0;

	WL_TRACE(("%s Enter\n", __FUNCTION__));
	if (!buf)
		return -EINVAL;

	/* Customer access to MAC address stored outside of DHD driver */
#if defined(CONFIG_MACH_MAHIMAHI) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
	/* Lin - this will call wifi_control_data->get_mac_addr (dhd_linux.c) */
	ret = wifi_get_mac_addr(buf);
#endif

#ifdef EXAMPLE_GET_MAC
	/* EXAMPLE code */
	{
		struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
		bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
	}
#endif /* EXAMPLE_GET_MAC */

#ifdef CUSTOMER_HW_PT
	if (ret != 0) {
		char panmac_path[] = "/dev/panmac";
		static struct ether_addr mac;
		static int custom_mac_applied = 0;

		if ( custom_mac_applied )
		{
			memcpy(buf, &mac, sizeof(struct ether_addr));
			return 0;
		}

		ret = dhd_read_mac_from_file(panmac_path, &mac);

		if ( ret == 0 )
		{
			memcpy(buf, &mac, sizeof(struct ether_addr));
			custom_mac_applied = 1;
		}
		else
		{
			int i;
			char rand_panmac_path[] = "/data/misc/wifi/panmac";

			ret = dhd_read_mac_from_file(rand_panmac_path, &mac);
			if ( ret != 0 )
			{
				mac.octet[0] = 0x00;
				mac.octet[1] = 0x0f;
				mac.octet[2] = 0xe4;
				for ( i = 3; i < ETHER_ADDR_LEN; i++ )
					get_random_bytes(&mac.octet[i], 1);

				dhd_write_mac_to_file(rand_panmac_path, &mac);
			}
			memcpy(buf, &mac, sizeof(struct ether_addr));
			custom_mac_applied = 1;
			ret = 0;
		}
	}
#endif

	return ret;
}
//FIH-ADD+]
int
dhd_custom_get_mac_address(unsigned char *buf)
{
	int ret = 0;

	WL_TRACE(("%s Enter\n", __FUNCTION__));
	if (!buf)
		return -EINVAL;

	/* Customer access to MAC address stored outside of DHD driver */
#if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
	ret = wifi_get_mac_addr(buf);
#endif
//FIH-ADD+[
    if (getwlanmac != 0) {
        bcopy(cached_mac, buf, ETHER_ADDR_LEN);
        printk(KERN_INFO "%s:[WIFI] cached MAC address: '%02x:%02x:%02x:%02x:%02x:%02x'\n", __func__,
                cached_mac[0], cached_mac[1], cached_mac[2], cached_mac[3], cached_mac[4], cached_mac[5]);
    } else {
        unsigned char cMacaddr[ETHER_ADDR_LEN];

	    memset(cMacaddr, 0, sizeof(cMacaddr));
        ret = rpc_nv_read_wlan_mac_addr(cMacaddr);

        if (ret == 0) {
            fih_wifi_mac_swap(cMacaddr);
            printk(KERN_INFO "%s:[WIFI] read MAC(nv 4678): '%02x:%02x:%02x:%02x:%02x:%02x\n'", __func__,
                    cMacaddr[0], cMacaddr[1], cMacaddr[2], cMacaddr[3], cMacaddr[4], cMacaddr[5]);
            if (cMacaddr[0] == 0x0 && cMacaddr[1] == 0x0 && cMacaddr[2] == 0x0
                 && cMacaddr[3] == 0x0 && cMacaddr[4] == 0x0 && cMacaddr[5] == 0x0) {
                printk("%s: zero Mac is not acceptable, return error\n", __func__);
                return -EINVAL;
            }
            else {
                bcopy(cMacaddr, buf, ETHER_ADDR_LEN);
                bcopy(cMacaddr, cached_mac, ETHER_ADDR_LEN);
            }
#if 0	/* Do not check SoMC mac */
            if ( fih_mac_is_se_mac(cMacaddr) ) {
                bcopy(cMacaddr, buf, ETHER_ADDR_LEN);
                bcopy(cMacaddr, cached_mac, ETHER_ADDR_LEN);
            } else {
                printk(KERN_INFO "%s:[WIFI]MAC from NV is not of SEMC\n", __func__);
                fih_generate_mac(cMacaddr, buf);
            }
#endif
        } else {
            printk("%s: failed to get MAC address from NV \n", __func__);
            /* fih_generate_mac(cMacaddr, buf);
            *
            * MAC is empty in NV, break from Wi-Fi init function
            */
            return -EINVAL;
        }

        getwlanmac = 1;
        //Update the new mac address based on NV item 4678
        printk("[Wlan] MAC address: '%02x:%02x:%02x:%02x:%02x:%02x'\n", cached_mac[0], cached_mac[1], cached_mac[2], cached_mac[3], cached_mac[4], cached_mac[5]);
    }
//FIH-ADD+]
#ifdef EXAMPLE_GET_MAC
	/* EXAMPLE code */
	{
		struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
		bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
	}
#endif /* EXAMPLE_GET_MAC */

	return ret;
}
/* Function to get custom MAC address */
int
dhd_custom_get_mac_address(unsigned char *buf)
{
	int ret = 0;

	WL_TRACE(("%s Enter\n", __FUNCTION__));
	if (!buf)
		return -EINVAL;

	/* Customer access to MAC address stored outside of DHD driver */
#if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
	ret = wifi_get_mac_addr(buf);
#endif

//#ifdef EXAMPLE_GET_MAC
	/* EXAMPLE code */
	{
	    
	    char text[128];
	    int len;
	    void *image = NULL;
	    char *p_start=NULL;  
        char text_addr[12];
         
		struct ether_addr ea_example = {{0xc8, 0x56, 0x78, 0x9a, 0xbc, 0xde}};
        

		bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
         buf[4]=random32()&0xff;
         buf[5]=random32()&0xff;
        image = dhd_os_open_image("/persist/WCNSS_qcom_cfg.ini");
        if (image == NULL)
            WL_ERROR(("%s can't open wncss config file!!!\n", __FUNCTION__));  

        	/* Download image */
#if defined(NDISVER) && (NDISVER >= 0x0630)
	while ((len = dhd_os_get_image_block((char*)text, 127, image, FALSE))) {
#else
	while ((len = dhd_os_get_image_block((char*)text, 127, image))) {
#endif /* NDSIVER && (NDISVER >= 0x0680) */
		if (len < 0) {
			  WL_ERROR(("%s get address data failed (%d)\n", __FUNCTION__,len));
			    goto err;;
			
		}
        if(text[0]=='#')
            continue;
         if ((p_start=strstr(text, "Intf0MacAddress")))
            {
                if ((p_start=strstr(text, "="))){

                                        
                      scru_ascii_2_hex (p_start+1, 12,text_addr);  
 
                        memcpy(buf,text_addr,6);   
                     
                        printk("get wifi NV address=%x:%x:%x:%x:%x:%x\n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]); 
                        ret = 0;      
                break;
                    }
            }

         
       }
    err:
        if (image){
		dhd_os_close_image(image);
          
            }
        
	}
//#endif /* EXAMPLE_GET_MAC */

	return ret;
}
#endif /* GET_CUSTOM_MAC_ENABLE */

/* Customized Locale table : OPTIONAL feature */
const struct cntry_locales_custom translate_custom_table[] = {
/* Table should be filled out based on custom platform regulatory requirement */
#ifdef EXAMPLE_TABLE
	{"",   "XY", 4},  /* Universal if Country code is unknown or empty */
	{"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
	{"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
	{"EU", "EU", 5},  /* European union countries to : EU regrev 05 */
	{"AT", "EU", 5},
	{"BE", "EU", 5},
	{"BG", "EU", 5},
	{"CY", "EU", 5},
	{"CZ", "EU", 5},
	{"DK", "EU", 5},
	{"EE", "EU", 5},
	{"FI", "EU", 5},
	{"FR", "EU", 5},
	{"DE", "EU", 5},
	{"GR", "EU", 5},
	{"HU", "EU", 5},
	{"IE", "EU", 5},
	{"IT", "EU", 5},
	{"LV", "EU", 5},
	{"LI", "EU", 5},
	{"LT", "EU", 5},
	{"LU", "EU", 5},
	{"MT", "EU", 5},
	{"NL", "EU", 5},
	{"PL", "EU", 5},
	{"PT", "EU", 5},
	{"RO", "EU", 5},
	{"SK", "EU", 5},
	{"SI", "EU", 5},
	{"ES", "EU", 5},
	{"SE", "EU", 5},
	{"GB", "EU", 5},
	{"KR", "XY", 3},
	{"AU", "XY", 3},
	{"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
	{"TW", "XY", 3},
	{"AR", "XY", 3},
	{"MX", "XY", 3},
	{"IL", "IL", 0},
	{"CH", "CH", 0},
	{"TR", "TR", 0},
	{"NO", "NO", 0},
#endif /* EXMAPLE_TABLE */
};


/* Customized Locale convertor
*  input : ISO 3166-1 country abbreviation
*  output: customized cspec
*/
void get_customized_country_code(char *country_iso_code, wl_country_t *cspec)
{
#if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))

	struct cntry_locales_custom *cloc_ptr;

	if (!cspec)
		return;

	cloc_ptr = wifi_get_country_code(country_iso_code);
	if (cloc_ptr) {
		strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
		cspec->rev = cloc_ptr->custom_locale_rev;
	}
	return;
#else
	int size, i;

	size = ARRAYSIZE(translate_custom_table);

	if (cspec == 0)
		 return;

	if (size == 0)
		 return;

	for (i = 0; i < size; i++) {
		if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) == 0) {
			memcpy(cspec->ccode,
				translate_custom_table[i].custom_locale, WLC_CNTRY_BUF_SZ);
			cspec->rev = translate_custom_table[i].custom_locale_rev;
			return;
		}
	}
#ifdef EXAMPLE_TABLE
	/* if no country code matched return first universal code from translate_custom_table */
	memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
	cspec->rev = translate_custom_table[0].custom_locale_rev;
#endif /* EXMAPLE_TABLE */
	return;
#endif /* defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) */
}