Skip to content

Commit 78bea24

Browse files
committed
Surround the changed lines with #if directives
Adopt rickywu0421's suggestion: Surrounding the changed lines with #if directives is better since there are only a few lines changed.
1 parent 54b37e6 commit 78bea24

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

vwifi.c

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,10 +1579,15 @@ static int vwifi_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
15791579

15801580
return 0;
15811581
}
1582-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
1582+
15831583
static int vwifi_change_beacon(struct wiphy *wiphy,
15841584
struct net_device *ndev,
1585-
struct cfg80211_beacon_data *info)
1585+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
1586+
struct cfg80211_beacon_data *info
1587+
#else
1588+
struct cfg80211_ap_update *info
1589+
#endif
1590+
)
15861591
{
15871592
struct vwifi_vif *vif = ndev_get_vwifi_vif(ndev);
15881593
int ie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN;
@@ -1593,49 +1598,23 @@ static int vwifi_change_beacon(struct wiphy *wiphy,
15931598
* 2. tail: beacon IEs after TIM IE
15941599
* We combine them and store them in vif->beacon_ie.
15951600
*/
1601+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
15961602
head_ie_len = info->head_len - ie_offset;
15971603
tail_ie_len = info->tail_len;
1598-
1599-
if (likely(head_ie_len + tail_ie_len <= IE_MAX_LEN)) {
1600-
vif->beacon_ie_len = head_ie_len + tail_ie_len;
1601-
memset(vif->beacon_ie, 0, IE_MAX_LEN);
1602-
memcpy(vif->beacon_ie, &info->head[ie_offset], head_ie_len);
1603-
memcpy(vif->beacon_ie + head_ie_len, info->tail, tail_ie_len);
1604-
1605-
pr_info(
1606-
"%s: head_ie_len (before TIM IE) = %d, tail_ie_len = "
1607-
"%d",
1608-
__func__, head_ie_len, tail_ie_len);
1609-
} else {
1610-
pr_info("%s: IE exceed %d bytes!\n", __func__, IE_MAX_LEN);
1611-
return 1;
1612-
}
1613-
1614-
return 0;
1615-
}
16161604
#else
1617-
static int vwifi_change_beacon(struct wiphy *wiphy,
1618-
struct net_device *ndev,
1619-
struct cfg80211_ap_update *info)
1620-
{
1621-
struct vwifi_vif *vif = ndev_get_vwifi_vif(ndev);
1622-
int ie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN;
1623-
int head_ie_len, tail_ie_len;
1624-
1625-
/* cfg80211 and some user-space programs treat IEs as two-part:
1626-
* 1. head: 802.11 beacon frame header + beacon IEs before TIM IE
1627-
* 2. tail: beacon IEs after TIM IE
1628-
* We combine them and store them in vif->beacon_ie.
1629-
*/
16301605
head_ie_len = info->beacon.head_len - ie_offset;
16311606
tail_ie_len = info->beacon.tail_len;
1632-
1607+
#endif
16331608
if (likely(head_ie_len + tail_ie_len <= IE_MAX_LEN)) {
16341609
vif->beacon_ie_len = head_ie_len + tail_ie_len;
16351610
memset(vif->beacon_ie, 0, IE_MAX_LEN);
1611+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
1612+
memcpy(vif->beacon_ie, &info->head[ie_offset], head_ie_len);
1613+
memcpy(vif->beacon_ie + head_ie_len, info->tail, tail_ie_len);
1614+
#else
16361615
memcpy(vif->beacon_ie, &info->beacon.head[ie_offset], head_ie_len);
16371616
memcpy(vif->beacon_ie + head_ie_len, info->beacon.tail, tail_ie_len);
1638-
1617+
#endif
16391618
pr_info(
16401619
"%s: head_ie_len (before TIM IE) = %d, tail_ie_len = "
16411620
"%d",
@@ -1647,7 +1626,7 @@ static int vwifi_change_beacon(struct wiphy *wiphy,
16471626

16481627
return 0;
16491628
}
1650-
#endif
1629+
16511630
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
16521631
static int vwifi_add_key(struct wiphy *wiphy,
16531632
struct net_device *ndev,

0 commit comments

Comments
 (0)