@@ -1439,45 +1439,6 @@ errortxcount++;
14391439return ;
14401440}
14411441/*---------------------------------------------------------------------------*/
1442- static inline __attribute__((always_inline )) void send_80211_associationrequest2rg (apdata_t * apdata )
1443- {
1444- ssize_t ii ;
1445-
1446- ii = RTHTX_SIZE ;
1447- macftx = (ieee80211_mac_t * )& wltxbuffer [ii ];
1448- macftx -> type = IEEE80211_FTYPE_MGMT ;
1449- macftx -> subtype = IEEE80211_STYPE_ASSOC_REQ ;
1450- wltxbuffer [ii + 1 ] = 0 ;
1451- macftx -> duration = HCXTXDURATION ;
1452- memcpy (macftx -> addr1 , apdata -> maca , ETH_ALEN );
1453- memcpy (macftx -> addr2 , macclientrg , ETH_ALEN );
1454- memcpy (macftx -> addr3 , apdata -> maca , ETH_ALEN );
1455- macftx -> sequence = __hcx16le (seqcounter2 ++ << 4 );
1456- if (seqcounter1 > 4095 ) seqcounter2 = 1 ;
1457- ii += MAC_SIZE_NORM ;
1458- memcpy (& wltxbuffer [ii ], & associationrequestcapa , ASSOCIATIONREQUESTCAPA_SIZE );
1459- ii += ASSOCIATIONREQUESTCAPA_SIZE ;
1460- wltxbuffer [ii ++ ] = 0 ;
1461- wltxbuffer [ii ++ ] = apdata -> essidlen ;
1462- memcpy (& wltxbuffer [ii ], apdata -> essid , apdata -> essidlen );
1463- ii += apdata -> essidlen ;
1464- memcpy (& wltxbuffer [ii ], & associationrequestdata , ASSOCIATIONREQUEST_SIZE );
1465- wltxbuffer [ii + OFFSETGCS ] = apdata -> gcs ;
1466- wltxbuffer [ii + OFFSETPCS ] = apdata -> pcs ;
1467- wltxbuffer [ii + OFFSETAKM ] = apdata -> akm ;
1468- ii += ASSOCIATIONREQUEST_SIZE ;
1469- if ((write (fd_socket_tx , & wltxbuffer , ii )) == ii )
1470- {
1471- errortxcount = 0 ;
1472- return ;
1473- }
1474- #ifdef HCXDEBUG
1475- fprintf (fh_debug , "write associationrequest failed: %s\n" , strerror (errno ));
1476- #endif
1477- errortxcount ++ ;
1478- return ;
1479- }
1480- /*---------------------------------------------------------------------------*/
14811442static inline __attribute__((always_inline )) void send_80211_associationrequest2 (apdata_t * apdata )
14821443{
14831444ssize_t ii ;
@@ -1542,57 +1503,6 @@ errortxcount++;
15421503return ;
15431504}
15441505/*---------------------------------------------------------------------------*/
1545- static inline __attribute__((always_inline )) void send_80211_authenticationrequestrg (void )
1546- {
1547- macftx = (ieee80211_mac_t * )& wltxbuffer [RTHTX_SIZE ];
1548- macftx -> type = IEEE80211_FTYPE_MGMT ;
1549- macftx -> subtype = IEEE80211_STYPE_AUTH ;
1550- wltxbuffer [RTHTX_SIZE + 1 ] = 0 ;
1551- macftx -> duration = HCXTXDURATION ;
1552- memcpy (macftx -> addr1 , macfrx -> addr2 , ETH_ALEN );
1553- memcpy (macftx -> addr2 , macclientrg , ETH_ALEN );
1554- memcpy (macftx -> addr3 , macfrx -> addr3 , ETH_ALEN );
1555- macftx -> sequence = __hcx16le (seqcounter2 ++ << 4 );
1556- if (seqcounter1 > 4095 ) seqcounter2 = 1 ;
1557- memcpy (& wltxbuffer [RTHTX_SIZE + MAC_SIZE_NORM ], & authenticationrequestdata , AUTHENTICATIONREQUEST_SIZE );
1558- if ((write (fd_socket_tx , & wltxbuffer , RTHTX_SIZE + MAC_SIZE_NORM + AUTHENTICATIONREQUEST_SIZE )) == RTHTX_SIZE + MAC_SIZE_NORM + AUTHENTICATIONREQUEST_SIZE )
1559- {
1560- errortxcount = 0 ;
1561- return ;
1562- }
1563- #ifdef HCXDEBUG
1564- fprintf (fh_debug , "write_80211_authenticationrequest failed: %s\n" , strerror (errno ));
1565- #endif
1566- errortxcount ++ ;
1567- return ;
1568- }
1569- /*---------------------------------------------------------------------------*/
1570- static inline __attribute__((always_inline )) void send_80211_disassociationaca (u8 * fmcl , u8 * toap )
1571- {
1572- macftx = (ieee80211_mac_t * )& wltxbuffer [RTHTX_SIZE ];
1573- macftx -> type = IEEE80211_FTYPE_MGMT ;
1574- macftx -> subtype = IEEE80211_STYPE_DISASSOC ;
1575- wltxbuffer [RTHTX_SIZE + 1 ] = 0 ;
1576- macftx -> duration = HCXTXDURATION ;
1577- memcpy (macftx -> addr1 , toap , ETH_ALEN );
1578- memcpy (macftx -> addr2 , fmcl , ETH_ALEN );
1579- memcpy (macftx -> addr3 , toap , ETH_ALEN );
1580- macftx -> sequence = __hcx16le (seqcounter1 ++ << 4 );
1581- if (seqcounter1 > BCD_MAX ) seqcounter1 = 1 ;
1582- wltxbuffer [RTHTX_SIZE + MAC_SIZE_NORM ] = WLAN_REASON_DISASSOC_STA_HAS_LEFT ;
1583- wltxbuffer [RTHTX_SIZE + MAC_SIZE_NORM + 1 ] = 0 ;
1584- if ((write (fd_socket_tx , wltxbuffer , RTHTX_SIZE + MAC_SIZE_NORM + 2 )) == RTHTX_SIZE + MAC_SIZE_NORM + 2 )
1585- {
1586- errortxcount = 0 ;
1587- return ;
1588- }
1589- #ifdef HCXDEBUG
1590- fprintf (fh_debug , "write_80211_disassociation121 failed: %s\n" , strerror (errno ));
1591- #endif
1592- errortxcount ++ ;
1593- return ;
1594- }
1595- /*---------------------------------------------------------------------------*/
15961506static inline __attribute__((always_inline )) void send_80211_disassociationcaa (u8 * tocl , u8 * fmap )
15971507{
15981508macftx = (ieee80211_mac_t * )& wltxbuffer [RTHTX_SIZE ];
@@ -3553,146 +3463,6 @@ while(nla_ok(pos, nestremlen))
35533463return 0 ;
35543464}
35553465/*---------------------------------------------------------------------------*/
3556- /*
3557- Linux Generic Netlink protocol
3558- Netlink message header (type: 0x0025)
3559- Command: NL80211_CMD_NEW_INTERFACE (7)
3560- Family Version: 0
3561- Reserved
3562- Linux 802.11 Netlink
3563- Attribute: NL80211_ATTR_WIPHY
3564- Len: 8
3565- Type: 0x0001, NL80211_ATTR_WIPHY (1)
3566- Attribute Value: 0x00000003 (3)
3567- Attribute: NL80211_ATTR_IFNAME
3568- Len: 12
3569- Type: 0x0004, NL80211_ATTR_IFNAME (4)
3570- Interface Name: hcxmon0
3571- Attribute: NL80211_ATTR_IFTYPE
3572- Len: 8
3573- Type: 0x0005, NL80211_ATTR_IFTYPE (5)
3574- Attribute Type: NL80211_IFTYPE_MONITOR (6)
3575- */
3576-
3577- static inline bool nl_set_interface (void )
3578- {
3579- static size_t ii ;
3580- static ssize_t i ;
3581- static ssize_t msglen ;
3582- static int nlremlen = 0 ;
3583- static struct nlmsghdr * nlh ;
3584- static struct genlmsghdr * glh ;
3585- static struct nlattr * nla ;
3586- static struct nlmsgerr * nle ;
3587- static u32 * wiphytmp ;
3588- static u64 * wdevtmp ;
3589- static u32 * ifidxtmp ;
3590- static u8 * vimactmp ;
3591- static char * ifnametmp ;
3592-
3593- i = 0 ;
3594- nlh = (struct nlmsghdr * )nltxbuffer ;
3595- nlh -> nlmsg_type = nlfamily ;
3596- nlh -> nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK ;
3597- nlh -> nlmsg_seq = nlseqcounter ++ ;
3598- nlh -> nlmsg_pid = hcxpid ;
3599- i += sizeof (struct nlmsghdr );
3600- glh = (struct genlmsghdr * )(nltxbuffer + i );
3601- glh -> cmd = NL80211_CMD_NEW_INTERFACE ;
3602- glh -> version = 1 ;
3603- glh -> reserved = 0 ;
3604- i += sizeof (struct genlmsghdr );
3605- nla = (struct nlattr * )(nltxbuffer + i );
3606- nla -> nla_len = 8 ;
3607-
3608- nla -> nla_type = NL80211_ATTR_WIPHY ;
3609- //*(u32*)nla_data(nla) = phyindex;
3610- i += 8 ;
3611- nla = (struct nlattr * )(nltxbuffer + i );
3612- nla -> nla_len = 8 ;
3613-
3614- nla -> nla_type = NL80211_ATTR_IFNAME ;
3615- //memcpy(nla_data(nla), hcxname, hcxnamelen);
3616- i += 8 ;
3617- nla = (struct nlattr * )(nltxbuffer + i );
3618- nla -> nla_len = 8 ;
3619-
3620-
3621- nla -> nla_type = NL80211_ATTR_IFTYPE ;
3622- * (u32 * )nla_data (nla ) = NL80211_IFTYPE_MONITOR ;
3623- i += 8 ;
3624- if (((ifakttype & IFTYPEMONACT ) == IFTYPEMONACT ) && (activemonitorflag == true))
3625- {
3626- nla = (struct nlattr * )(nltxbuffer + i );
3627- nla -> nla_len = 8 ;
3628- nla -> nla_type = NL80211_ATTR_MNTR_FLAGS ;
3629- nla = (struct nlattr * )nla_data (nla );
3630- nla -> nla_len = 4 ;
3631- nla -> nla_type = NL80211_MNTR_FLAG_ACTIVE ;
3632- i += 8 ;
3633- }
3634- nlh -> nlmsg_len = i ;
3635- if ((write (fd_socket_nl , nltxbuffer , i )) != i ) return false;
3636-
3637- while (1 )
3638- {
3639- msglen = read (fd_socket_nl , & nlrxbuffer , NLRX_SIZE );
3640- if (msglen == -1 ) break ;
3641- if (msglen == 0 ) break ;
3642- wiphytmp = NULL ;
3643- wdevtmp = NULL ;
3644- ifidxtmp = NULL ;;
3645- vimactmp = NULL ;;
3646- ifnametmp = NULL ;
3647- for (nlh = (struct nlmsghdr * )nlrxbuffer ; NLMSG_OK (nlh , (u32 )msglen ); nlh = NLMSG_NEXT (nlh , msglen ))
3648- {
3649- if (nlh -> nlmsg_type == NLMSG_DONE ) return true;
3650- if (nlh -> nlmsg_type == NLMSG_ERROR )
3651- {
3652- nle = (struct nlmsgerr * )(nlrxbuffer + sizeof (struct nlmsghdr ));
3653- if (nle -> error == 0 ) return true;
3654- errorcount ++ ;
3655- nlfamily = 0 ;
3656- return false;
3657- }
3658- glh = (struct genlmsghdr * )NLMSG_DATA (nlh );
3659- if (glh -> cmd != NL80211_CMD_NEW_INTERFACE ) continue ;
3660- nla = (struct nlattr * )((unsigned char * )NLMSG_DATA (nlh ) + sizeof (struct genlmsghdr ));
3661- nlremlen = NLMSG_PAYLOAD (nlh , 0 ) - 4 ;
3662- while (nla_ok (nla , nlremlen ))
3663- {
3664- if (nla -> nla_type == NL80211_ATTR_WDEV ) wdevtmp = nla_data (nla );
3665- if (nla -> nla_type == NL80211_ATTR_IFINDEX ) ifidxtmp = nla_data (nla );
3666- if (nla -> nla_type == NL80211_ATTR_IFNAME ) ifnametmp = nla_data (nla );
3667- if (nla -> nla_type == NL80211_ATTR_WIPHY ) wiphytmp = nla_data (nla );
3668- if (nla -> nla_type == NL80211_ATTR_MAC )
3669- {
3670- if (nla -> nla_len == 10 ) vimactmp = nla_data (nla );
3671- }
3672- nla = nla_next (nla , & nlremlen );
3673- }
3674- for (ii = 0 ; ii < ifpresentlistcounter ; ii ++ )
3675- {
3676- if ((ifpresentlist + ii )-> wiphy == * (int * )wiphytmp )
3677- {
3678- if (ifidxtmp != NULL ) (ifpresentlist + ii )-> index = * (u32 * )ifidxtmp ;
3679- if (wdevtmp != NULL )
3680- {
3681- if ((ifpresentlist + ii )-> wdev != 0 )
3682- {
3683- if ((ifpresentlist + ii )-> wdev != * (u64 * )wdevtmp ) (ifpresentlist + ii )-> type |= IF_IS_SHARED ;
3684- }
3685- (ifpresentlist + ii )-> wdev = * (u64 * )wdevtmp ;
3686- }
3687- if (vimactmp != NULL )memcpy ((ifpresentlist + ii )-> vimac , vimactmp , ETH_ALEN );
3688- if (ifnametmp != NULL )strncpy ((ifpresentlist + ii )-> name , ifnametmp , IF_NAMESIZE );
3689- }
3690- }
3691- }
3692- }
3693- return false;
3694- }
3695- /*---------------------------------------------------------------------------*/
36963466static bool nl_get_interfacelist (void )
36973467{
36983468static size_t ii ;
0 commit comments