diff --git a/core/monitor/rtw_radiotap.c b/core/monitor/rtw_radiotap.c index e9ebc7d..1f9fc49 100644 --- a/core/monitor/rtw_radiotap.c +++ b/core/monitor/rtw_radiotap.c @@ -402,8 +402,10 @@ sint rtw_fill_radiotap_hdr(_adapter *padapter, struct rx_pkt_attrib *a, u8 *buf) } if (a->ampdu_eof) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN); tmp_16bit |= cpu_to_le16(IEEE80211_RADIOTAP_AMPDU_EOF); +#endif } _rtw_memcpy(&hdr_buf[rt_len], &tmp_16bit, 2); diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index dea2456..a5145e6 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -17,6 +17,10 @@ #ifdef __KERNEL__ #include #include + #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + #include +#endif #include #include #include @@ -168,7 +172,42 @@ static void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, } -static void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, + unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPX; + memcpy(networkAddr + 1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr + 5, ipxNodeAddr, 6); +} + + +static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, + unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPX; + memcpy(networkAddr + 1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr + 5, (unsigned char *)ipxSocketAddr, 2); +} + + +static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr, + unsigned short *network, unsigned char *node) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_APPLE; + memcpy(networkAddr + 1, (unsigned char *)network, 2); + networkAddr[3] = *node; +} +#endif + + +static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, unsigned char *ac_mac, unsigned short *sid) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -296,6 +335,7 @@ static int __nat25_network_hash(unsigned char *networkAddr) x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; return x & (NAT25_HASH_SIZE - 1); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) } else if (networkAddr[0] == NAT25_IPX) { unsigned long x; @@ -309,6 +349,7 @@ static int __nat25_network_hash(unsigned char *networkAddr) x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3]; return x & (NAT25_HASH_SIZE - 1); +#endif } else if (networkAddr[0] == NAT25_PPPOE) { unsigned long x; @@ -855,6 +896,229 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) } } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + /*---------------------------------------------------*/ + /* Handle IPX and Apple Talk frame */ + /*---------------------------------------------------*/ + else if ((protocol == __constant_htons(ETH_P_IPX)) || + (protocol == __constant_htons(ETH_P_ATALK)) || + (protocol == __constant_htons(ETH_P_AARP))) { + unsigned char ipx_header[2] = {0xFF, 0xFF}; + struct ipxhdr *ipx = NULL; + struct elapaarp *ea = NULL; + struct ddpehdr *ddp = NULL; + unsigned char *framePtr = skb->data + ETH_HLEN; + + if (protocol == __constant_htons(ETH_P_IPX)) { + RTW_INFO("NAT25: Protocol=IPX (Ethernet II)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { /* if(protocol <= __constant_htons(ETH_FRAME_LEN)) */ + if (!memcmp(ipx_header, framePtr, 2)) { + RTW_INFO("NAT25: Protocol=IPX (Ethernet 802.3)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { + unsigned char ipx_8022_type = 0xE0; + unsigned char snap_8022_type = 0xAA; + + if (*framePtr == snap_8022_type) { + unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */ + unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */ + unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */ + + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + RTW_INFO("NAT25: Protocol=IPX (Ethernet SNAP)\n"); + ipx = (struct ipxhdr *)framePtr; + } else if (!memcmp(aarp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ea = (struct elapaarp *)framePtr; + } else if (!memcmp(ddp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ddp = (struct ddpehdr *)framePtr; + } else { + DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], + framePtr[1], framePtr[2], framePtr[3], framePtr[4]); + return -1; + } + } else if (*framePtr == ipx_8022_type) { + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_header, framePtr, 2)) { + RTW_INFO("NAT25: Protocol=IPX (Ethernet 802.2)\n"); + ipx = (struct ipxhdr *)framePtr; + } else + return -1; + } + } + } + + /* IPX */ + if (ipx != NULL) { + switch (method) { + case NAT25_CHECK: + if (!memcmp(skb->data + ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { + RTW_INFO("NAT25: Check IPX skb_copy\n"); + return 0; + } + return -1; + + case NAT25_INSERT: { + RTW_INFO("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n", + ipx->ipx_dest.net, + ipx->ipx_dest.node[0], + ipx->ipx_dest.node[1], + ipx->ipx_dest.node[2], + ipx->ipx_dest.node[3], + ipx->ipx_dest.node[4], + ipx->ipx_dest.node[5], + ipx->ipx_dest.sock, + ipx->ipx_source.net, + ipx->ipx_source.node[0], + ipx->ipx_source.node[1], + ipx->ipx_source.node[2], + ipx->ipx_source.node[3], + ipx->ipx_source.node[4], + ipx->ipx_source.node[5], + ipx->ipx_source.sock); + + if (!memcmp(skb->data + ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { + RTW_INFO("NAT25: Use IPX Net, and Socket as network addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); + + /* change IPX source node addr to wlan STA address */ + memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); + } else + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); + + __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + } + return 0; + + case NAT25_LOOKUP: { + if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) { + RTW_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* replace IPX destination node addr with Lookup destination MAC addr */ + memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); + } else { + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + } + } + return 0; + + default: + return -1; + } + } + + /* AARP */ + else if (ea != NULL) { + /* Sanity check fields. */ + if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { + DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return 0; + + case NAT25_INSERT: { + /* change to AARP source mac address to wlan STA address */ + memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); + + RTW_INFO("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); + + __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + } + return 0; + + case NAT25_LOOKUP: { + RTW_INFO("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* change to AARP destination mac address to Lookup result */ + memcpy(ea->hw_dst, skb->data, ETH_ALEN); + } + return 0; + + default: + return -1; + } + } + + /* DDP */ + else if (ddp != NULL) { + switch (method) { + case NAT25_CHECK: + return -1; + + case NAT25_INSERT: { + RTW_INFO("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); + + __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + } + return 0; + + case NAT25_LOOKUP: { + RTW_INFO("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + } + return 0; + + default: + return -1; + } + } + + return -1; + } +#endif + /*---------------------------------------------------*/ /* Handle PPPoE frame */ /*---------------------------------------------------*/ diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 5ee17ea..ce9eb22 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -16320,6 +16320,12 @@ u8 rtw_set_chbw_hdl(_adapter *padapter, u8 *pbuf) } LeaveAllPowerSaveModeDirect(padapter); + +#ifdef CONFIG_MONITOR_MODE_XMIT + pmlmeext->cur_channel = set_ch_parm->ch; + pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; + pmlmeext->cur_bwmode = set_ch_parm->bw; +#endif /* CONFIG_MONITOR_MODE_XMIT */ set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 21b9321..ea52160 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -4068,9 +4068,8 @@ int recv_frame_monitor(_adapter *padapter, union recv_frame *rframe) /* read skb information from recv frame */ pskb = rframe->u.hdr.pkt; - pskb->head = rframe->u.hdr.rx_head; - pskb->data = rframe->u.hdr.rx_data; pskb->len = rframe->u.hdr.len; + pskb->data = rframe->u.hdr.rx_data; skb_set_tail_pointer(pskb, rframe->u.hdr.len); if (ndev->type == ARPHRD_IEEE80211_RADIOTAP) { diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 2c6a4f9..13b46f9 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -4899,10 +4899,12 @@ s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev) if (unlikely(skb->len < rtap_len)) goto fail; +#ifndef CONFIG_MONITOR_MODE_XMIT if (rtap_len != 12) { RTW_INFO("radiotap len (should be 14): %d\n", rtap_len); goto fail; } +#endif /* CONFIG_MONITOR_MODE_XMIT */ _rtw_pktfile_read(&pktfile, dummybuf, rtap_len-sizeof(struct ieee80211_radiotap_header)); len = len - rtap_len; #endif diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index 053e51c..ab693ef 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -26,7 +26,11 @@ int usb_init_recv_priv(_adapter *padapter, u16 ini_in_buf_sz) #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, - (void(*))usb_recv_tasklet, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)) + (void(*)(unsigned long))usb_recv_tasklet, +#else + (void *)usb_recv_tasklet, +#endif (unsigned long)padapter); #endif /* PLATFORM_LINUX */ diff --git a/hal/phydm/phydm_debug.h b/hal/phydm/phydm_debug.h index ab10431..06e809b 100644 --- a/hal/phydm/phydm_debug.h +++ b/hal/phydm/phydm_debug.h @@ -89,7 +89,7 @@ #define PHYDM_SNPRINTF snprintf #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) #undef pr_debug - #define pr_debug _RTW_DBG + #define pr_debug printk #define RT_PRINTK(fmt, args...) pr_debug(fmt, ## args) #define RT_DISP(dbgtype, dbgflag, printstr) #define RT_TRACE(adapter, comp, drv_level, fmt, args...) \ diff --git a/hal/rtl8822b/usb/rtl8822bu_xmit.c b/hal/rtl8822b/usb/rtl8822bu_xmit.c index d287b54..8bf20ad 100644 --- a/hal/rtl8822b/usb/rtl8822bu_xmit.c +++ b/hal/rtl8822b/usb/rtl8822bu_xmit.c @@ -878,7 +878,11 @@ s32 rtl8822bu_init_xmit_priv(PADAPTER padapter) #ifdef PLATFORM_LINUX tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*))rtl8822bu_xmit_tasklet, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)) + (void(*)(unsigned long))rtl8822bu_xmit_tasklet, +#else + (void *)rtl8822bu_xmit_tasklet, +#endif (unsigned long)padapter); #endif #ifdef CONFIG_TX_EARLY_MODE diff --git a/install-driver.sh b/install-driver.sh index e046253..9f11f0f 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -120,30 +120,30 @@ echo "Script: ${SCRIPT_NAME} v${SCRIPT_VERSION}" # information that helps with bug reports # display architecture -echo "Arch:${KARCH}" +echo ": ${KARCH}" # display total memory in system -grep MemTotal /proc/meminfo +#grep MemTotal /proc/meminfo # display kernel version -echo "Kernel: ${KVER}" +echo ": ${KVER}" # display gcc version gcc_ver=$(gcc --version | grep -i gcc) -echo "gcc: "${gcc_ver} +echo ": "${gcc_ver} -# display dkms version -# run if dkms is installed +# display dkms version if installed if command -v dkms >/dev/null 2>&1 then - dkms --version + dkms_ver=$(dkms --version) + echo ": "${dkms_ver} fi -# display secure mode status -# run if mokutil is installed +# display secure mode status if mokutil is installed if command -v mokutil >/dev/null 2>&1 then - mokutil --sb-state + sb_state=$(mokutil --sb-state) + echo ": "${sb_state} fi # display ISO 3166-1 alpha-2 Country Code diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 5dfa3e1..38f1aa1 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -5108,9 +5108,11 @@ void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint f ie_offset = _REASOCREQ_IE_OFFSET_; memset(&sinfo, 0, sizeof(sinfo)); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)) sinfo.filled = STATION_INFO_ASSOC_REQ_IES; sinfo.assoc_req_ies = pmgmt_frame + WLAN_HDR_A3_LEN + ie_offset; sinfo.assoc_req_ies_len = frame_len - WLAN_HDR_A3_LEN - ie_offset; +#endif cfg80211_new_sta(ndev, get_addr2_ptr(pmgmt_frame), &sinfo, GFP_ATOMIC); } #else /* defined(RTW_USE_CFG80211_STA_EVENT) */ @@ -6208,11 +6210,15 @@ static int cfg80211_rtw_set_channel(struct wiphy *wiphy #endif , struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) { +#ifdef CONFIG_WIFI_MONITOR + _adapter *padapter = wiphy_to_adapter(wiphy); +#else /* CONFIG_WIFI_MONITOR */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) _adapter *padapter = (_adapter *)rtw_netdev_priv(ndev); #else _adapter *padapter = wiphy_to_adapter(wiphy); #endif +#endif /* CONFIG_WIFI_MONITOR */ int chan_target = (u8) ieee80211_frequency_to_channel(chan->center_freq); int chan_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; int chan_width = CHANNEL_WIDTH_20; diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 05854ef..7b25f29 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -3937,7 +3937,7 @@ int _netdev_open(struct net_device *pnetdev) #ifdef CONFIG_IOCTL_CFG80211 rtw_cfg80211_init_wdev_data(padapter); #endif - rtw_netif_carrier_on(pnetdev); /* call this func when rtw_joinbss_event_callback return success */ + /* rtw_netif_carrier_on(pnetdev); */ /* call this func when rtw_joinbss_event_callback return success */ rtw_netif_wake_queue(pnetdev); #ifdef CONFIG_BR_EXT @@ -4058,7 +4058,7 @@ int _netdev_open(struct net_device *pnetdev) rtw_set_pwr_state_check_timer(pwrctrlpriv); #endif - rtw_netif_carrier_on(pnetdev); /* call this func when rtw_joinbss_event_callback return success */ + /* rtw_netif_carrier_on(pnetdev); */ /* call this func when rtw_joinbss_event_callback return success */ rtw_netif_wake_queue(pnetdev); #ifdef CONFIG_BR_EXT diff --git a/os_dep/linux/recv_linux.c b/os_dep/linux/recv_linux.c index aff1855..14fc295 100644 --- a/os_dep/linux/recv_linux.c +++ b/os_dep/linux/recv_linux.c @@ -353,7 +353,6 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, const u8 *da, const u8 *s { sub_skb = rtw_skb_clone(prframe->u.hdr.pkt); if (sub_skb) { - sub_skb->head = msdu; sub_skb->data = msdu; sub_skb->len = msdu_len; skb_set_tail_pointer(sub_skb, msdu_len); @@ -619,9 +618,8 @@ void rtw_hostapd_mlme_rx(_adapter *padapter, union recv_frame *precv_frame) if (skb == NULL) return; - skb->head = precv_frame->u.hdr.rx_head; skb->data = precv_frame->u.hdr.rx_data; - skb_set_tail_pointer(skb, precv_frame->u.hdr.rx_tail - precv_frame->u.hdr.rx_data); + skb->tail = precv_frame->u.hdr.rx_tail; skb->len = precv_frame->u.hdr.len; /* pskb_copy = rtw_skb_copy(skb); @@ -663,7 +661,6 @@ int rtw_recv_monitor(_adapter *padapter, union recv_frame *precv_frame) goto _recv_drop; } - skb->head = precv_frame->u.hdr.rx_head; skb->data = precv_frame->u.hdr.rx_data; skb_set_tail_pointer(skb, precv_frame->u.hdr.len); skb->len = precv_frame->u.hdr.len; @@ -688,7 +685,6 @@ inline void rtw_rframe_set_os_pkt(union recv_frame *rframe) { _pkt *skb = rframe->u.hdr.pkt; - skb->head = rframe->u.hdr.rx_head; skb->data = rframe->u.hdr.rx_data; skb_set_tail_pointer(skb, rframe->u.hdr.len); skb->len = rframe->u.hdr.len; diff --git a/remove-driver.sh b/remove-driver.sh index 6ebaf78..257a36a 100755 --- a/remove-driver.sh +++ b/remove-driver.sh @@ -91,10 +91,10 @@ fi # information that helps with bug reports # display kernel version -echo "Kernel: ${KVER}" +echo ": ${KVER}" # display architecture -echo "Arch : ${KARCH}" +echo ": ${KARCH}" # determine if dkms is installed and run the appropriate routines if command -v dkms >/dev/null 2>&1