"Secondary", "Monitor"
};
-static int hex2num_i(char c)
-{
- if (c >= '0' && c <= '9')
- return c - '0';
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
- return -1;
-}
-
-/**
- * hwaddr_aton - Convert ASCII string to MAC address
- * @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
- * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
- * Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
- */
-static int hwaddr_aton_i(const char *txt, u8 *addr)
-{
- int i;
-
- for (i = 0; i < 6; i++) {
- int a, b;
-
- a = hex2num_i(*txt++);
- if (a < 0)
- return -1;
- b = hex2num_i(*txt++);
- if (b < 0)
- return -1;
- *addr++ = (a << 4) | b;
- if (i < 5 && *txt++ != ':')
- return -1;
- }
-
- return 0;
-}
-
void indicate_wx_scan_complete_event(struct adapter *padapter)
{
union iwreq_data wrqu;
while (phead != plist) {
pnetwork = container_of(plist, struct wlan_network, list);
- if (hwaddr_aton_i(data, bssid)) {
+ if (!mac_pton(data, bssid)) {
DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data);
spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
return -EINVAL;
if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) {
ret = -1;
} else {
- int jj, kk;
-
/* Add this profile information into pwdinfo->profileinfo */
/* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */
- for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3)
- pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]);
+ if (!mac_pton(extra + 1,
+ pwdinfo->profileinfo[pwdinfo->profileindex].peermac))
+ return -EINVAL;
pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0');
memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen);
int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
- u8 peerMACStr[17] = {0x00};
+ u8 peerMACStr[18] = {0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17))
return -EFAULT;
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
+ if (!mac_pton(peerMACStr, peerMAC))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
- u8 peerMACStr[17] = {0x00};
+ u8 peerMACStr[18] = {0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17))
return -EFAULT;
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
+ if (!mac_pton(peerMACStr, peerMAC))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
- u8 peerMACStr[17] = {0x00};
+ u8 peerMACStr[18] = {0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17))
return -EFAULT;
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
+ if (!mac_pton(peerMACStr, peerMAC))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
- u8 peerMACStr[17] = {0x00};
+ u8 peerMACStr[18] = {0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17))
return -EFAULT;
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
+ if (!mac_pton(peerMACStr, peerMAC))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
- u8 peerMACStr[17] = {0x00};
+ u8 peerMACStr[18] = {0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17))
return -EFAULT;
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]);
+ if (!mac_pton(peerMACStr, peerMAC))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO)
return -1;
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]);
+ if (!mac_pton(extra, peerMAC))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
int ret = 0;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
- int jj, kk;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
pinvite_req_info->token = 3;
}
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]);
+ if (!mac_pton(extra, pinvite_req_info->peer_macaddr))
+ return -EINVAL;
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
if (uintPeerChannel) {
/* Store the GO's bssid */
- for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3)
- pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]);
+ if (!mac_pton(extra + 18, pinvite_req_info->go_bssid))
+ return -EINVAL;
/* Store the GO's ssid */
pinvite_req_info->ssidlen = wrqu->data.length - 36;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
u8 peerMAC[ETH_ALEN] = {0x00};
- int jj, kk;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *plist, *phead;
struct __queue *queue = &(pmlmepriv->scanned_queue);
pwdinfo->tx_prov_disc_info.benable = false;
}
- for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
- peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]);
+ if (!mac_pton(extra, peerMAC))
+ return -EINVAL;
if (!memcmp(&extra[18], "display", 7)) {
pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA;