├── .gitignore ├── AppleIntelWifiAdapter.xcodeproj └── project.pbxproj ├── AppleIntelWifiAdapter ├── AppleIntelWifiAdapterV2.cpp ├── AppleIntelWifiAdapterV2.hpp ├── HackIOEthernetInterface.h ├── HackIONetworkInterface.h ├── IWLCoex.cpp ├── IWLCtxtInfo.cpp ├── IWLCtxtInfo.hpp ├── IWLDebug.h ├── IWLDevice.cpp ├── IWLDevice.hpp ├── IWLFH.h ├── IWLInternal.cpp ├── IWLInternal.hpp ├── IWLPhyDb.cpp ├── IWLPhyDb.hpp ├── IWLUtils.cpp ├── Info.plist ├── apple80211 │ ├── IO80211Controller.h │ ├── IO80211Interface.h │ ├── IO80211SkywalkInterface.h │ ├── IO80211WorkLoop.h │ ├── IOEthernetController.h │ ├── IONetworkController.h │ ├── IOSkywalkEthernetInterface.h │ ├── apple80211_ioctl.h │ ├── apple80211_var.h │ └── apple80211_wps.h ├── compat │ ├── linux │ │ ├── bitfield.h │ │ ├── cfg80211.h │ │ ├── ieee80211.h │ │ ├── ieee80211_radiotap.h │ │ ├── kernel.h │ │ ├── mac80211.h │ │ ├── netdevice.h │ │ ├── nl80211.h │ │ ├── random.h │ │ ├── skbuff.h │ │ └── types.h │ └── openbsd │ │ ├── crypto │ │ ├── aes.c │ │ ├── aes.h │ │ ├── arc4.c │ │ ├── arc4.h │ │ ├── blf.c │ │ ├── blf.h │ │ ├── cast.c │ │ ├── cast.h │ │ ├── castsb.h │ │ ├── chacha_private.h │ │ ├── chachapoly.c │ │ ├── chachapoly.h │ │ ├── cmac.c │ │ ├── cmac.h │ │ ├── cryptodev.h │ │ ├── des_locl.h │ │ ├── ecb3_enc.c │ │ ├── ecb_enc.c │ │ ├── gmac.c │ │ ├── gmac.h │ │ ├── hmac.c │ │ ├── hmac.h │ │ ├── idgen.c │ │ ├── idgen.h │ │ ├── key_wrap.c │ │ ├── key_wrap.h │ │ ├── md5.c │ │ ├── md5.h │ │ ├── michael.c │ │ ├── michael.h │ │ ├── podd.h │ │ ├── poly1305.c │ │ ├── poly1305.h │ │ ├── rijndael.c │ │ ├── rijndael.h │ │ ├── rmd160.c │ │ ├── rmd160.h │ │ ├── set_key.c │ │ ├── sha1.c │ │ ├── sha1.h │ │ ├── sha2.c │ │ ├── sha2.h │ │ ├── sk.h │ │ └── spr.h │ │ ├── net80211 │ │ ├── CTimeout.cpp │ │ ├── _string.c │ │ ├── ieee80211.c │ │ ├── ieee80211.h │ │ ├── ieee80211_amrr.c │ │ ├── ieee80211_amrr.h │ │ ├── ieee80211_crypto.c │ │ ├── ieee80211_crypto.h │ │ ├── ieee80211_crypto_bip.c │ │ ├── ieee80211_crypto_ccmp.c │ │ ├── ieee80211_crypto_tkip.c │ │ ├── ieee80211_crypto_wep.c │ │ ├── ieee80211_input.c │ │ ├── ieee80211_ioctl.c │ │ ├── ieee80211_ioctl.h │ │ ├── ieee80211_mira.c │ │ ├── ieee80211_mira.h │ │ ├── ieee80211_node.c │ │ ├── ieee80211_node.h │ │ ├── ieee80211_output.c │ │ ├── ieee80211_pae_input.c │ │ ├── ieee80211_pae_output.c │ │ ├── ieee80211_priv.h │ │ ├── ieee80211_proto.c │ │ ├── ieee80211_proto.h │ │ ├── ieee80211_radiotap.h │ │ ├── ieee80211_regdomain.c │ │ ├── ieee80211_regdomain.h │ │ ├── ieee80211_rssadapt.c │ │ ├── ieee80211_rssadapt.h │ │ ├── ieee80211_var.h │ │ └── timeout.c │ │ └── sys │ │ ├── CTimeout.hpp │ │ ├── _arc4random.h │ │ ├── _buf.h │ │ ├── _if_ether.h │ │ ├── _if_media.h │ │ ├── _mbuf.h │ │ ├── _null.h │ │ ├── endian.h │ │ ├── timeout.h │ │ └── tree.h ├── device │ ├── IWLCSR.h │ ├── IWLDevice22000.h │ ├── IWLDevice7000.h │ ├── IWLDevice8000.h │ ├── IWLDevice9000.h │ ├── IWLDeviceBase.h │ ├── IWLDeviceList.h │ └── IWLPRPH.h ├── firmware │ ├── iwlwifi-3160-17.ucode │ ├── iwlwifi-3168-29.ucode │ ├── iwlwifi-7260-17.ucode │ ├── iwlwifi-7265-17.ucode │ ├── iwlwifi-7265D-27.ucode │ ├── iwlwifi-8000C-36.ucode │ ├── iwlwifi-8265-34.ucode │ ├── iwlwifi-8265-36.ucode │ ├── iwlwifi-9000-pu-b0-jf-b0-46.ucode │ ├── iwlwifi-9260-th-b0-jf-b0-46.ucode │ ├── iwlwifi-Qu-b0-hr-b0-48.ucode │ ├── iwlwifi-Qu-b0-jf-b0-48.ucode │ ├── iwlwifi-Qu-c0-hr-b0-48.ucode │ ├── iwlwifi-Qu-c0-jf-b0-48.ucode │ ├── iwlwifi-QuZ-a0-hr-b0-48.ucode │ ├── iwlwifi-QuZ-a0-jf-b0-48.ucode │ └── iwlwifi-cc-a0-48.ucode ├── fw │ ├── FWFile.h │ ├── FWImg.h │ ├── IWLFw.cpp │ ├── IWLUcodeParse.cpp │ ├── IWLUcodeParse.hpp │ ├── NotificationWait.cpp │ ├── NotificationWait.hpp │ ├── api │ │ ├── alive.h │ │ ├── binding.h │ │ ├── cmdhdr.h │ │ ├── coex.h │ │ ├── commands.h │ │ ├── config.h │ │ ├── context.h │ │ ├── d3.h │ │ ├── datapath.h │ │ ├── dbg-tlv.h │ │ ├── debug.h │ │ ├── filter.h │ │ ├── led.h │ │ ├── location.h │ │ ├── mac-cfg.h │ │ ├── mac.h │ │ ├── nan.h │ │ ├── nvm-reg.h │ │ ├── offload.h │ │ ├── paging.h │ │ ├── phy-ctxt.h │ │ ├── phy.h │ │ ├── power.h │ │ ├── rs.h │ │ ├── rx.h │ │ ├── scan.h │ │ ├── sf.h │ │ ├── soc.h │ │ ├── sta.h │ │ ├── stats.h │ │ ├── tdls.h │ │ ├── testing.h │ │ ├── time-event.h │ │ ├── tx.h │ │ └── txq.h │ └── fw-api.h ├── hack80211 │ ├── HackIO80211Interface.cpp │ └── HackIO80211Interface.h ├── mvm │ ├── IWLConstants.h │ ├── IWLMac80211.cpp │ ├── IWLMvmDriver.cpp │ ├── IWLMvmDriver.hpp │ ├── IWLMvmPhy.cpp │ ├── IWLMvmPhy.hpp │ ├── IWLMvmScan.cpp │ ├── IWLMvmScan.hpp │ ├── IWLMvmSmartFifo.cpp │ ├── IWLMvmSmartFifo.hpp │ ├── IWLMvmSta.cpp │ ├── IWLMvmSta.hpp │ ├── IWLMvmTransOpsGen1.cpp │ ├── IWLMvmTransOpsGen1.hpp │ ├── IWLMvmTransOpsGen2.cpp │ ├── IWLMvmTransOpsGen2.hpp │ ├── IWMHdr.h │ ├── Mvm.h │ ├── MvmCmd.hpp │ └── MvmTransOps.cpp ├── nvm │ ├── IWLNvm.cpp │ ├── IWLNvmParser.cpp │ ├── IWLNvmParser.hpp │ └── IWLeeprom.h └── trans │ ├── IWLIO.cpp │ ├── IWLIO.hpp │ ├── IWLSCD.h │ ├── IWLTransOps.h │ ├── IWLTransport.cpp │ ├── IWLTransport.hpp │ ├── IWLTransportRx.cpp │ ├── IWLTransportTx.cpp │ ├── TransHdr.h │ └── TransOpsCommon.cpp ├── README.md └── img ├── QQ20191102-195821.png └── QQ20191102-195905.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | DerivedData 3 | build 4 | xcuserdata 5 | xcshareddata 6 | project.xcworkspace 7 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.hpp: -------------------------------------------------------------------------------- 1 | /* add your code here */ 2 | #ifndef macroAppleIntelWifiAdapter_hpp 3 | #define AppleIntelWifiAdapter_hpp 4 | 5 | #include "HackIO80211Interface.h" 6 | #include 7 | #include "IOKit/network/IOGatedOutputQueue.h" 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include "IWLMvmDriver.hpp" 15 | 16 | OSDefineMetaClassAndStructors(CTimeout, OSObject) 17 | 18 | enum { 19 | kOffPowerState, 20 | kOnPowerState, 21 | kNumPowerStates 22 | }; 23 | 24 | static IOPMPowerState gPowerStates[kNumPowerStates] = { 25 | // kOffPowerState 26 | {kIOPMPowerStateVersion1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 27 | // kOnPowerState 28 | {kIOPMPowerStateVersion1, (kIOPMPowerOn | kIOPMDeviceUsable), kIOPMPowerOn, kIOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0} 29 | }; 30 | 31 | class AppleIntelWifiAdapterV2 : public IOEthernetController 32 | { 33 | OSDeclareDefaultStructors( AppleIntelWifiAdapterV2 ) 34 | 35 | public: 36 | 37 | bool init(OSDictionary *properties) override; 38 | void free() override; 39 | IOService* probe(IOService* provider, SInt32* score) override; 40 | bool start(IOService *provider) override; 41 | void stop(IOService *provider) override; 42 | IOReturn getHardwareAddress(IOEthernetAddress* addrP) override; 43 | IOReturn enable(IONetworkInterface *netif) override; 44 | IOReturn disable(IONetworkInterface *netif) override; 45 | IOReturn setPromiscuousMode(bool active) override; 46 | IOReturn setMulticastMode(bool active) override; 47 | IOOutputQueue * createOutputQueue() override; 48 | UInt32 outputPacket(mbuf_t, void * param) override; 49 | static void intrOccured(OSObject *object, IOInterruptEventSource *, int count); 50 | static bool intrFilter(OSObject *object, IOFilterInterruptEventSource *src); 51 | IONetworkInterface * createInterface() override; 52 | bool configureInterface(IONetworkInterface * interface) override; 53 | 54 | public: 55 | 56 | 57 | private: 58 | IWLMvmDriver *drv; 59 | IOGatedOutputQueue* fOutputQueue; 60 | IOInterruptEventSource* fInterrupt; 61 | IOEthernetInterface *netif; 62 | IOCommandGate *gate; 63 | IOWorkLoop* irqLoop; 64 | 65 | void releaseAll(); 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLCoex.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLCoex.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/8. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLMvmDriver.hpp" 10 | 11 | int IWLMvmDriver::sendBTInitConf() 12 | { 13 | iwl_bt_coex_cmd cmd; 14 | u32 mode; 15 | IOLockLock(trans->mutex); 16 | 17 | if(unlikely(m_pDevice->btForceAntMode != BT_FORCE_ANT_DIS)) 18 | { 19 | switch(m_pDevice->btForceAntMode) { 20 | case BT_FORCE_ANT_BT: 21 | mode = BT_COEX_BT; 22 | break; 23 | case BT_FORCE_ANT_WIFI: 24 | mode = BT_COEX_WIFI; 25 | break; 26 | default: 27 | WARN_ON(1); 28 | mode = 0; 29 | break; 30 | } 31 | } 32 | else { 33 | mode = m_pDevice->iwlwifi_mod_params.bt_coex_active ? BT_COEX_NW : BT_COEX_DISABLE; 34 | // if(IWL_MVM_BT_COEX_SYNC2SCO) 35 | } 36 | cmd.mode = cpu_to_le32(BT_COEX_WIFI); 37 | //cmd.enabled_modules |= cpu_to_le32(BT_COEX_SYNC2SCO_ENABLED); 38 | 39 | /* 40 | if(iwl_mvm_is_mplut_supported(m_pDevice)) { 41 | cmd.enabled_modules |= cpu_to_le32(BT_COEX_MPLUT_ENABLED); 42 | } 43 | */ 44 | cmd.enabled_modules = cpu_to_le32(BT_COEX_HIGH_BAND_RET); 45 | 46 | 47 | memset(&m_pDevice->lastBtNotif, 0, sizeof(m_pDevice->lastBtNotif)); 48 | memset(&m_pDevice->lastBtCiCmd, 0, sizeof(m_pDevice->lastBtCiCmd)); 49 | 50 | IOLockUnlock(trans->mutex); 51 | 52 | return sendCmdPdu(BT_CONFIG, 0, sizeof(cmd), &cmd); 53 | } 54 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLDebug.h: -------------------------------------------------------------------------------- 1 | // 2 | // IWLDebug.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/6. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLDebug_h 10 | #define IWLDebug_h 11 | 12 | #include 13 | 14 | #ifdef DEBUG 15 | #define DebugLog(args...) IOLog(args) 16 | #else 17 | #define DebugLog(args...) 18 | #endif 19 | 20 | #define TraceLog(args...) IOLog(args) 21 | 22 | #define __iwl_warn(args...) \ 23 | do { TraceLog("AppleIntelWifiAdapter WARN: " args); } while (0) 24 | 25 | #define __iwl_info(args...) \ 26 | do { TraceLog("AppleIntelWifiAdapter INFO: " args); } while (0) 27 | 28 | #define __iwl_crit(args...) \ 29 | do { TraceLog("AppleIntelWifiAdapter CRIT: " args); } while (0) 30 | 31 | #define __iwl_err(rfkill_prefix, trace_only, args...) \ 32 | do { if (!trace_only) TraceLog("AppleIntelWifiAdapter ERR: " args); } while (0) 33 | 34 | #define __iwl_dbg(level, limit, args...) \ 35 | do { ((!limit)) DebugLog("AppleIntelWifiAdapter DEBUG: " args); } while (0); 36 | 37 | /* No matter what is m (priv, bus, trans), this will work */ 38 | #define IWL_ERR_DEV(m, f, a...) \ 39 | do { \ 40 | __iwl_err(false, false, f, ## a); \ 41 | } while (0) 42 | #define IWL_ERR(m, f, a...) \ 43 | IWL_ERR_DEV(m, f, ## a) 44 | #define IWL_WARN(m, f, a...) \ 45 | do { \ 46 | __iwl_warn(f, ## a); \ 47 | } while (0) 48 | #define IWL_INFO(m, f, a...) \ 49 | do { \ 50 | __iwl_info(f, ## a); \ 51 | } while (0) 52 | #define IWL_CRIT(m, f, a...) \ 53 | do { \ 54 | __iwl_crit(f, ## a); \ 55 | } while (0) 56 | 57 | #define __IWL_DEBUG_DEV(level, limit, fmt, args...) \ 58 | do { \ 59 | __iwl_dbg(level, limit, fmt, ##args); \ 60 | } while (0) 61 | #define IWL_DEBUG(m, level, fmt, args...) \ 62 | __IWL_DEBUG_DEV(level, false, fmt, ##args) 63 | #define IWL_DEBUG_DEV(m, level, fmt, args...) \ 64 | __IWL_DEBUG_DEV(level, false, fmt, ##args) 65 | #define IWL_DEBUG_LIMIT(m, level, fmt, args...) \ 66 | __IWL_DEBUG_DEV(level, true, fmt, ##args) 67 | 68 | #endif /* IWLDebug_h */ 69 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLDevice.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLDevice.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by qcwap on 2020/1/5. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLDevice.hpp" 10 | 11 | bool IWLDevice::init(IOPCIDevice *pciDevice) 12 | { 13 | this->pciDevice = pciDevice; 14 | this->registerRWLock = IOSimpleLockAlloc(); 15 | UInt16 vendorID = pciDevice->configRead16(kIOPCIConfigVendorID); 16 | if (vendorID != PCI_VENDOR_ID_INTEL) { 17 | return false; 18 | } 19 | deviceID = pciDevice->configRead16(kIOPCIConfigDeviceID); 20 | for (int i = 0; i < ARRAY_SIZE(iwl_hw_card_ids); i++) { 21 | pci_device_id dev = iwl_hw_card_ids[i]; 22 | if (dev.device == deviceID) { 23 | this->cfg = (struct iwl_cfg *)dev.driver_data; 24 | break; 25 | } 26 | } 27 | subSystemDeviceID = pciDevice->configRead16(kIOPCIConfigSubSystemID); 28 | this->rx_sync_waitq = IOLockAlloc(); 29 | if(this->cfg != NULL) { 30 | pciDevice->retain(); 31 | return true; 32 | } 33 | else { 34 | this->pciDevice = NULL; 35 | return false; 36 | } 37 | } 38 | 39 | void IWLDevice::release() 40 | { 41 | if (this->registerRWLock) { 42 | IOSimpleLockFree(this->registerRWLock); 43 | this->registerRWLock = NULL; 44 | } 45 | if (this->rx_sync_waitq) { 46 | IOLockFree(this->rx_sync_waitq); 47 | this->rx_sync_waitq = NULL; 48 | } 49 | 50 | if(this->pciDevice) { 51 | this->pciDevice->release(); 52 | } 53 | } 54 | 55 | void IWLDevice::enablePCI() 56 | { 57 | pciDevice->setBusMasterEnable(true); 58 | pciDevice->setMemoryEnable(true); 59 | pciDevice->setIOEnable(true); 60 | } 61 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLInternal.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLInternal.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/6. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLInternal.hpp" 10 | #include 11 | 12 | struct iwl_dma_ptr* allocate_dma_buf(size_t size, mach_vm_address_t physical_mask) { 13 | IOOptionBits options = kIODirectionInOut | kIOMemoryPhysicallyContiguous | kIOMapInhibitCache; 14 | 15 | IOBufferMemoryDescriptor *bmd; 16 | bmd = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(kernel_task, options, size, physical_mask); 17 | 18 | IODMACommand *cmd = IODMACommand::withSpecification(kIODMACommandOutputHost64, 64, 0, IODMACommand::kMapped, 0, 1); 19 | cmd->setMemoryDescriptor(bmd); 20 | cmd->prepare(); 21 | 22 | IODMACommand::Segment64 seg; 23 | UInt64 ofs = 0; 24 | UInt32 numSegs = 1; 25 | 26 | if (cmd->gen64IOVMSegments(&ofs, &seg, &numSegs) != kIOReturnSuccess) { 27 | cmd->complete(); 28 | cmd->release(); 29 | cmd = NULL; 30 | 31 | bmd->complete(); 32 | bmd->release(); 33 | bmd = NULL; 34 | 35 | return NULL; 36 | } 37 | 38 | struct iwl_dma_ptr *result = (struct iwl_dma_ptr *) IOMalloc(sizeof(struct iwl_dma_ptr)); 39 | result->addr = bmd->getBytesNoCopy(); 40 | result->dma = seg.fIOVMAddr; 41 | result->size = size; 42 | result->bmd = bmd; 43 | result->cmd = cmd; 44 | return result; 45 | } 46 | 47 | struct iwl_dma_ptr* allocate_dma_buf32(size_t size) { 48 | IOOptionBits options = kIODirectionInOut | kIOMemoryPhysicallyContiguous | kIOMapInhibitCache; 49 | IOBufferMemoryDescriptor *bmd = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(kernel_task, options, size, 0x00000000ffffffffULL); 50 | bmd->prepare(); 51 | IODMACommand *cmd = IODMACommand::withSpecification(kIODMACommandOutputHost32, 32, 0, IODMACommand::kMapped, 0, 1); 52 | cmd->setMemoryDescriptor(bmd); 53 | cmd->prepare(); 54 | IODMACommand::Segment32 seg; 55 | UInt64 ofs = 0; 56 | UInt32 numSegs = 1; 57 | if (cmd->gen32IOVMSegments(&ofs, &seg, &numSegs) != kIOReturnSuccess) { 58 | cmd->complete(); 59 | cmd->release(); 60 | cmd = NULL; 61 | 62 | bmd->complete(); 63 | bmd->release(); 64 | bmd = NULL; 65 | return NULL; 66 | } 67 | struct iwl_dma_ptr *result = (struct iwl_dma_ptr *) IOMalloc(sizeof(struct iwl_dma_ptr)); 68 | result->addr = bmd->getBytesNoCopy(); 69 | result->dma = seg.fIOVMAddr; 70 | result->size = size; 71 | result->bmd = bmd; 72 | result->cmd = cmd; 73 | return result; 74 | } 75 | 76 | void free_dma_buf(struct iwl_dma_ptr *dma_ptr) { 77 | IODMACommand *cmd = static_cast(dma_ptr->cmd); 78 | cmd->complete(); 79 | cmd->release(); 80 | dma_ptr->cmd = NULL; 81 | 82 | IOBufferMemoryDescriptor *bmd = static_cast(dma_ptr->bmd); 83 | // bmd->complete(); 84 | bmd->release(); 85 | dma_ptr->bmd = NULL; 86 | 87 | dma_ptr->addr = NULL; 88 | dma_ptr->dma = 0; 89 | 90 | IOFree(dma_ptr, sizeof(struct iwl_dma_ptr)); 91 | } 92 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLInternal.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLInternal.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/6. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLInternal_hpp 10 | #define IWLInternal_hpp 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct iwl_dma_ptr { 17 | dma_addr_t dma; 18 | void *addr; 19 | size_t size; 20 | 21 | void *bmd; // IOBufferMemoryDescriptor 22 | void *cmd; // IODMACommand 23 | }; 24 | 25 | struct iwl_dma_ptr* allocate_dma_buf(size_t size, mach_vm_address_t physical_mask); 26 | struct iwl_dma_ptr* allocate_dma_buf32(size_t size); 27 | 28 | void free_dma_buf(struct iwl_dma_ptr *dma_ptr); 29 | 30 | #endif /* IWLInternal_hpp */ 31 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLPhyDb.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLPhyDb.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/8. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLPhyDb_hpp 10 | #define IWLPhyDb_hpp 11 | 12 | #include 13 | #include 14 | #include "IWLTransport.hpp" 15 | 16 | #define CHANNEL_NUM_SIZE 4 /* num of channels in calib_ch size */ 17 | 18 | struct iwl_phy_db_entry { 19 | u16 size; 20 | u8 *data; 21 | }; 22 | 23 | /** 24 | * struct iwl_phy_db - stores phy configuration and calibration data. 25 | * 26 | * @cfg: phy configuration. 27 | * @calib_nch: non channel specific calibration data. 28 | * @calib_ch: channel specific calibration data. 29 | * @n_group_papd: number of entries in papd channel group. 30 | * @calib_ch_group_papd: calibration data related to papd channel group. 31 | * @n_group_txp: number of entries in tx power channel group. 32 | * @calib_ch_group_txp: calibration data related to tx power chanel group. 33 | */ 34 | struct iwl_phy_db { 35 | struct iwl_phy_db_entry cfg; 36 | struct iwl_phy_db_entry calib_nch; 37 | int n_group_papd; 38 | struct iwl_phy_db_entry *calib_ch_group_papd; 39 | int n_group_txp; 40 | struct iwl_phy_db_entry *calib_ch_group_txp; 41 | IWLTransport *trans; 42 | }; 43 | 44 | enum iwl_phy_db_section_type { 45 | IWL_PHY_DB_CFG = 1, 46 | IWL_PHY_DB_CALIB_NCH, 47 | IWL_PHY_DB_UNUSED, 48 | IWL_PHY_DB_CALIB_CHG_PAPD, 49 | IWL_PHY_DB_CALIB_CHG_TXP, 50 | IWL_PHY_DB_MAX 51 | }; 52 | 53 | #define PHY_DB_CMD 0x6c 54 | 55 | /* for parsing of tx power channel group data that comes from the firmware*/ 56 | struct iwl_phy_db_chg_txp { 57 | __le32 space; 58 | __le16 max_channel_idx; 59 | } __packed; 60 | 61 | 62 | void iwl_phy_db_init(IWLTransport *trans, struct iwl_phy_db *phy_db); 63 | 64 | void iwl_phy_db_free(struct iwl_phy_db *phy_db); 65 | 66 | int iwl_phy_db_set_section(struct iwl_phy_db *phy_db, 67 | struct iwl_rx_packet *pkt); 68 | 69 | int iwl_phy_db_get_section_data(struct iwl_phy_db *phy_db, 70 | u32 type, u8 **data, u16 *size, u16 ch_id); 71 | 72 | int iwl_send_phy_db_data(struct iwl_phy_db *phy_db); 73 | 74 | #endif /* IWLPhyDb_hpp */ 75 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/IWLUtils.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLUtils.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/8. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLMvmDriver.hpp" 10 | 11 | /* 12 | * Will return 0 even if the cmd failed when RFKILL is asserted unless 13 | * CMD_WANT_SKB is set in cmd->flags. 14 | */ 15 | int IWLMvmDriver::sendCmd(struct iwl_host_cmd *cmd) 16 | { 17 | int ret; 18 | /* 19 | * Synchronous commands from this op-mode must hold 20 | * the mutex, this ensures we don't try to send two 21 | * (or more) synchronous commands at a time. 22 | */ 23 | //TODO 24 | // if (!(cmd->flags & CMD_ASYNC)) 25 | // lockdep_assert_held(&mvm->mutex); 26 | ret = trans->sendCmd(cmd); 27 | /* 28 | * If the caller wants the SKB, then don't hide any problems, the 29 | * caller might access the response buffer which will be NULL if 30 | * the command failed. 31 | */ 32 | if (cmd->flags & CMD_WANT_SKB) 33 | return ret; 34 | /* Silently ignore failures if RFKILL is asserted */ 35 | if (!ret || ret == -ERFKILL) 36 | return 0; 37 | return ret; 38 | } 39 | 40 | int IWLMvmDriver::sendCmdPdu(u32 id, u32 flags, u16 len, const void *data) 41 | { 42 | struct iwl_host_cmd cmd = { 43 | .id = id, 44 | .len = { len, }, 45 | .data = { data, }, 46 | .flags = flags, 47 | }; 48 | return sendCmd(&cmd); 49 | } 50 | 51 | int IWLMvmDriver::sendCmdPduStatus(u32 id, u16 len, const void* data, u32* status) 52 | { 53 | struct iwl_host_cmd cmd = { 54 | .id = id, 55 | .len = { len, }, 56 | .data = { data, } 57 | }; 58 | 59 | return sendCmdStatus(&cmd, status); 60 | } 61 | 62 | int IWLMvmDriver::sendCmdStatus(struct iwl_host_cmd *cmd, u32 *status) 63 | { 64 | struct iwl_rx_packet *pkt; 65 | struct iwl_cmd_response *resp; 66 | int ret, resp_len; 67 | // lockdep_assert_held(&mvm->mutex); 68 | /* 69 | * Only synchronous commands can wait for status, 70 | * we use WANT_SKB so the caller can't. 71 | */ 72 | if (cmd->flags & (CMD_ASYNC | CMD_WANT_SKB)) { 73 | IWL_ERR(0, "cmd flags %x", cmd->flags); 74 | return -EINVAL; 75 | } 76 | cmd->flags |= CMD_WANT_SKB; 77 | ret = trans->sendCmd(cmd); 78 | if (ret == -ERFKILL) { 79 | /* 80 | * The command failed because of RFKILL, don't update 81 | * the status, leave it as success and return 0. 82 | */ 83 | return 0; 84 | } else if (ret) { 85 | return ret; 86 | } 87 | pkt = cmd->resp_pkt; 88 | resp_len = iwl_rx_packet_payload_len(pkt); 89 | if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { 90 | ret = -EIO; 91 | goto out_free_resp; 92 | } 93 | resp = (struct iwl_cmd_response *)pkt->data; 94 | *status = le32_to_cpu(resp->status); 95 | out_free_resp: 96 | trans->freeResp(cmd); 97 | return ret; 98 | } 99 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | IOKitPersonalities 22 | 23 | AppleIntelWifiAdapterV2 24 | 25 | CFBundleIdentifier 26 | com.apple.AppleIntelWifiAdapterV2 27 | IOClass 28 | AppleIntelWifiAdapterV2 29 | IOPCIPrimaryMatch 30 | 0x00008086&0x0000ffff 31 | IOProviderClass 32 | IOPCIDevice 33 | 34 | 35 | NSHumanReadableCopyright 36 | Copyright © 2019 钟先耀. All rights reserved. 37 | OSBundleLibraries 38 | 39 | com.apple.iokit.IONetworkingFamily 40 | 3.2 41 | com.apple.iokit.IOPCIFamily 42 | 2.9 43 | com.apple.kpi.bsd 44 | 16.7 45 | com.apple.kpi.iokit 46 | 16.7 47 | com.apple.kpi.libkern 48 | 16.7 49 | com.apple.kpi.mach 50 | 16.7 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/apple80211/IO80211Interface.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _IO80211INTERFACE_H 3 | #define _IO80211INTERFACE_H 4 | 5 | /* 6 | * Kernel 7 | */ 8 | #if defined(KERNEL) && defined(__cplusplus) 9 | 10 | #include 11 | 12 | #if VERSION_MAJOR > 8 13 | #define _MODERN_BPF 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | enum IO80211LinkState 21 | { 22 | kIO80211NetworkLinkUndefined, // Starting link state when an interface is created 23 | kIO80211NetworkLinkDown, // Interface not capable of transmitting packets 24 | kIO80211NetworkLinkUp, // Interface capable of transmitting packets 25 | }; 26 | typedef enum IO80211LinkState IO80211LinkState; 27 | 28 | /*! @defined kIO80211InterfaceClass 29 | @abstract The name of the IO80211Interface class. 30 | */ 31 | #define kIO80211InterfaceClass "IO80211Interface" 32 | 33 | typedef UInt64 IO80211FlowQueueHash; 34 | class RSNSupplicant; 35 | class IOTimerEventSource; 36 | class IOGatedOutputQueue; 37 | class IO80211Controller; 38 | class IO80211Workloop; 39 | class IO80211ScanManager; 40 | class IO80211PeerManager; 41 | class IO80211FlowQueueDatabase; 42 | class IO80211InterfaceMonitor; 43 | class IO80211AssociationJoinSnapshot; 44 | 45 | struct apple80211_debug_command; 46 | struct apple80211_txstats; 47 | struct apple80211_chip_counters_tx; 48 | struct apple80211_chip_error_counters_tx; 49 | struct apple80211_chip_counters_rx; 50 | struct apple80211_ManagementInformationBasedot11_counters; 51 | struct apple80211_leaky_ap_stats; 52 | struct apple80211_leaky_ap_ssid_metrics; 53 | struct apple80211_interface_availability; 54 | struct apple80211_pmk_cache_data; 55 | struct apple80211_ap_cmp_data; 56 | struct TxPacketRequest; 57 | struct AWSRequest; 58 | struct packet_info_tx; 59 | struct userPrintCtx; 60 | 61 | typedef int apple80211_postMessage_tlv_types; 62 | 63 | class IO80211Interface : public IOEthernetInterface 64 | { 65 | OSDeclareDefaultStructors( IO80211Interface ); 66 | 67 | public: 68 | virtual bool terminate(unsigned int) APPLE_KEXT_OVERRIDE; 69 | virtual bool attach(IOService*) APPLE_KEXT_OVERRIDE; 70 | virtual void detach(IOService*) APPLE_KEXT_OVERRIDE; 71 | virtual bool init(IONetworkController*) APPLE_KEXT_OVERRIDE; 72 | virtual UInt32 inputPacket(mbuf_t packet, 73 | UInt32 length = 0, 74 | IOOptionBits options = 0, 75 | void * param = 0) APPLE_KEXT_OVERRIDE; 76 | virtual bool inputEvent(unsigned int, void*) APPLE_KEXT_OVERRIDE; 77 | virtual SInt32 performCommand(IONetworkController*, unsigned long, void*, void*) APPLE_KEXT_OVERRIDE; 78 | virtual IOReturn attachToDataLinkLayer(IOOptionBits, void*) APPLE_KEXT_OVERRIDE; 79 | virtual void detachFromDataLinkLayer(unsigned int, void*) APPLE_KEXT_OVERRIDE; 80 | virtual void setPoweredOnByUser(bool); 81 | virtual void setEnabledBySystem(bool); 82 | virtual bool setLinkState(IO80211LinkState, unsigned int); 83 | virtual bool setLinkState(IO80211LinkState, int, unsigned int); 84 | virtual UInt32 outputPacket(mbuf_t, void*); 85 | 86 | virtual bool setLinkQualityMetric(int); 87 | virtual void handleDebugCmd(apple80211_debug_command*); 88 | OSMetaClassDeclareReservedUnused( IO80211Interface, 0); 89 | OSMetaClassDeclareReservedUnused( IO80211Interface, 1); 90 | OSMetaClassDeclareReservedUnused( IO80211Interface, 2); 91 | OSMetaClassDeclareReservedUnused( IO80211Interface, 3); 92 | OSMetaClassDeclareReservedUnused( IO80211Interface, 4); 93 | OSMetaClassDeclareReservedUnused( IO80211Interface, 5); 94 | OSMetaClassDeclareReservedUnused( IO80211Interface, 6); 95 | OSMetaClassDeclareReservedUnused( IO80211Interface, 7); 96 | OSMetaClassDeclareReservedUnused( IO80211Interface, 8); 97 | OSMetaClassDeclareReservedUnused( IO80211Interface, 9); 98 | OSMetaClassDeclareReservedUnused( IO80211Interface, 10); 99 | OSMetaClassDeclareReservedUnused( IO80211Interface, 11); 100 | OSMetaClassDeclareReservedUnused( IO80211Interface, 12); 101 | OSMetaClassDeclareReservedUnused( IO80211Interface, 13); 102 | OSMetaClassDeclareReservedUnused( IO80211Interface, 14); 103 | OSMetaClassDeclareReservedUnused( IO80211Interface, 15); 104 | }; 105 | 106 | #endif /* defined(KERNEL) && defined(__cplusplus) */ 107 | 108 | #endif /* ! _IO80211INTERFACE_H */ 109 | 110 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/apple80211/IO80211SkywalkInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // IO80211SkywalkInterface.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2019/10/18. 6 | // Copyright © 2019 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IO80211SkywalkInterface_h 10 | #define IO80211SkywalkInterface_h 11 | 12 | #include "IOSkywalkEthernetInterface.h" 13 | 14 | class IO80211SkywalkInterface : IOSkywalkEthernetInterface { 15 | OSDeclareAbstractStructors(IO80211SkywalkInterface) 16 | 17 | public: 18 | 19 | }; 20 | 21 | #endif /* IO80211SkywalkInterface_h */ 22 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/apple80211/IO80211WorkLoop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IO80211WorkLoop.h 3 | * Family 4 | * 5 | * Created by Pete on 5/31/06. 6 | * Copyright 2006 Apple Computer, Inc. All rights reserved. 7 | * 8 | */ 9 | 10 | #include 11 | 12 | class IO80211WorkLoop : public IOWorkLoop 13 | { 14 | OSDeclareDefaultStructors( IO80211WorkLoop ) 15 | 16 | public: 17 | 18 | static IO80211WorkLoop * workLoop(); 19 | 20 | virtual void openGate() APPLE_KEXT_OVERRIDE; 21 | virtual void closeGate() APPLE_KEXT_OVERRIDE; 22 | virtual int sleepGate( void * event, UInt32 interuptibleType ) APPLE_KEXT_OVERRIDE; 23 | virtual int sleepGateDeadline( void * event, UInt32 interuptibleType, AbsoluteTime deadline ); 24 | virtual void wakeupGate( void * event, bool oneThread ) APPLE_KEXT_OVERRIDE; 25 | 26 | }; 27 | 28 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/apple80211/IOSkywalkEthernetInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // IOSkywalkEthernetInterface.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2019/10/18. 6 | // Copyright © 2019 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IOSkywalkEthernetInterface_h 10 | #define IOSkywalkEthernetInterface_h 11 | 12 | #include 13 | 14 | class IOSkywalkEthernetInterface : public IOEthernetController { 15 | OSDeclareAbstractStructors( IOSkywalkEthernetInterface ) 16 | 17 | public: 18 | 19 | }; 20 | 21 | #endif /* IOSkywalkEthernetInterface_h */ 22 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/linux/bitfield.h: -------------------------------------------------------------------------------- 1 | // 2 | // bitfield.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by qcwap on 2020/1/5. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef bitfield_h 10 | #define bitfield_h 11 | 12 | #include 13 | #include 14 | 15 | #define BITS_PER_LONG 64 16 | 17 | #define BITS_PER_LONG_LONG 64 18 | 19 | #define BIT(nr) (1UL << (nr)) 20 | #define BIT_ULL(nr) (1ULL << (nr)) 21 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 22 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 23 | #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) 24 | #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) 25 | #define BITS_PER_BYTE 8 26 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) 27 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 28 | #define __bf_shf(x) (__builtin_ffsll(x) - 1) 29 | #define FIELD_PREP(_mask, _val) \ 30 | ({ \ 31 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \ 32 | }) 33 | #define for_each_set_bit(bit, addr, size) \ 34 | for ((bit) = find_first_bit((addr), (size)); \ 35 | (bit) < (size); \ 36 | (bit) = find_next_bit((addr), (size), (bit) + 1)) 37 | 38 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) 39 | 40 | #define GENMASK(h, l) \ 41 | (((~(0UL)) - ((1UL) << (l)) + 1) & \ 42 | (~(0UL) >> (BITS_PER_LONG - 1 - (h)))) 43 | 44 | #define GENMASK_ULL(h, l) \ 45 | (((~(0ULL)) - ((1ULL) << (l)) + 1) & \ 46 | (~(0ULL) >> (BITS_PER_LONG_LONG - 1 - (h)))) 47 | 48 | static inline UInt64 OSBitwiseAtomic64(unsigned long and_mask, unsigned long or_mask, unsigned long xor_mask, unsigned long * value) 49 | { 50 | unsigned long oldValue; 51 | unsigned long newValue; 52 | 53 | do { 54 | oldValue = *value; 55 | newValue = ((oldValue & and_mask) | or_mask) ^ xor_mask; 56 | } while (! OSCompareAndSwap64(oldValue, newValue, value)); 57 | 58 | return oldValue; 59 | } 60 | 61 | static inline unsigned long OSBitAndAtomic64(unsigned long mask, unsigned long * value) 62 | { 63 | return OSBitwiseAtomic64(mask, 0, 0, value); 64 | } 65 | 66 | static inline unsigned long OSBitOrAtomic64(unsigned long mask, unsigned long * value) 67 | { 68 | return OSBitwiseAtomic64(-1, mask, 0, value); 69 | } 70 | 71 | static inline void set_bit(int nr, volatile unsigned long *addr) 72 | { 73 | unsigned long mask = BIT_MASK(nr); 74 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); 75 | OSBitOrAtomic64(mask, p); 76 | } 77 | 78 | static inline void clear_bit(int nr, volatile unsigned long *addr) 79 | { 80 | unsigned long mask = BIT_MASK(nr); 81 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); 82 | OSBitAndAtomic64(~mask, p); 83 | } 84 | 85 | static inline int test_and_set_bit(int nr, volatile unsigned long *addr) 86 | { 87 | unsigned long mask = BIT_MASK(nr); 88 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); 89 | unsigned long old; 90 | 91 | old = *p; 92 | *p = old | mask; 93 | 94 | return (old & mask) != 0; 95 | } 96 | 97 | static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) 98 | { 99 | unsigned long mask = BIT_MASK(nr); 100 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); 101 | unsigned long old; 102 | 103 | old = *p; 104 | *p = old & ~mask; 105 | 106 | return (old & mask) != 0; 107 | } 108 | 109 | static inline int 110 | test_bit(int nr, const volatile unsigned long *addr) 111 | { 112 | return (OSAddAtomic(0, addr) & (1 << nr)) != 0; 113 | } 114 | 115 | static inline int linux_fls(int x) 116 | { 117 | int r = 32; 118 | 119 | if (!x) 120 | return 0; 121 | if (!(x & 0xffff0000u)) { 122 | x <<= 16; 123 | r -= 16; 124 | } 125 | if (!(x & 0xff000000u)) { 126 | x <<= 8; 127 | r -= 8; 128 | } 129 | if (!(x & 0xf0000000u)) { 130 | x <<= 4; 131 | r -= 4; 132 | } 133 | if (!(x & 0xc0000000u)) { 134 | x <<= 2; 135 | r -= 2; 136 | } 137 | if (!(x & 0x80000000u)) { 138 | x <<= 1; 139 | r -= 1; 140 | } 141 | return r; 142 | } 143 | 144 | #endif /* bitfield_h */ 145 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/linux/random.h: -------------------------------------------------------------------------------- 1 | // 2 | // random.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/22. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef random_h 10 | #define random_h 11 | 12 | #include 13 | 14 | static inline void get_random_bytes(void *buf, int nbytes) 15 | { 16 | random_buf(buf, nbytes); 17 | } 18 | 19 | #endif /* random_h */ 20 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/linux/skbuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // skbuff.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/22. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef skbuff_h 10 | #define skbuff_h 11 | 12 | #include 13 | #include 14 | 15 | struct sk_buff { 16 | 17 | void *cb; 18 | void *data; 19 | }; 20 | 21 | struct sk_buff_head { 22 | struct sk_buff *next; 23 | struct sk_buff *prev; 24 | __u32 qlen; 25 | IOSimpleLock* lock; 26 | }; 27 | 28 | #endif /* skbuff_h */ 29 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/aes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * Copyright (c) 2016 Mike Belopuhov 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef _AES_H_ 27 | #define _AES_H_ 28 | 29 | #ifndef AES_MAXROUNDS 30 | #define AES_MAXROUNDS (14) 31 | #endif 32 | 33 | typedef struct aes_ctx { 34 | uint32_t sk[60]; 35 | uint32_t sk_exp[120]; 36 | 37 | unsigned num_rounds; 38 | } AES_CTX; 39 | 40 | int AES_Setkey(AES_CTX *, const uint8_t *, int); 41 | void AES_Encrypt(AES_CTX *, const uint8_t *, uint8_t *); 42 | void AES_Decrypt(AES_CTX *, const uint8_t *, uint8_t *); 43 | void AES_Encrypt_ECB(AES_CTX *, const uint8_t *, uint8_t *, size_t); 44 | void AES_Decrypt_ECB(AES_CTX *, const uint8_t *, uint8_t *, size_t); 45 | 46 | int AES_KeySetup_Encrypt(uint32_t *, const uint8_t *, int); 47 | int AES_KeySetup_Decrypt(uint32_t *, const uint8_t *, int); 48 | 49 | #endif /* _AES_H_ */ 50 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/arc4.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: arc4.c,v 1.3 2007/09/11 12:07:05 djm Exp $ */ 2 | /* 3 | * Copyright (c) 2003 Markus Friedl 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #define RC4SWAP(x,y) \ 23 | do { \ 24 | u_int8_t t = ctx->state[x]; \ 25 | ctx->state[x] = ctx->state[y]; \ 26 | ctx->state[y] = t; \ 27 | } while(0) 28 | 29 | void 30 | rc4_keysetup(struct rc4_ctx *ctx, u_char *key, u_int32_t klen) 31 | { 32 | u_int8_t x, y; 33 | u_int32_t i; 34 | 35 | x = y = 0; 36 | for (i = 0; i < RC4STATE; i++) 37 | ctx->state[i] = i; 38 | for (i = 0; i < RC4STATE; i++) { 39 | y = (key[x] + ctx->state[i] + y) & (RC4STATE - 1); 40 | RC4SWAP(i, y); 41 | x = (x + 1) % klen; 42 | } 43 | ctx->x = ctx->y = 0; 44 | } 45 | 46 | void 47 | rc4_crypt(struct rc4_ctx *ctx, u_char *src, u_char *dst, 48 | u_int32_t len) 49 | { 50 | u_int32_t i; 51 | 52 | for (i = 0; i < len; i++) { 53 | ctx->x = (ctx->x + 1) & (RC4STATE - 1); 54 | ctx->y = (ctx->state[ctx->x] + ctx->y) & (RC4STATE - 1); 55 | RC4SWAP(ctx->x, ctx->y); 56 | dst[i] = src[i] ^ ctx->state[ 57 | (ctx->state[ctx->x] + ctx->state[ctx->y]) & (RC4STATE - 1)]; 58 | } 59 | } 60 | 61 | void 62 | rc4_getbytes(struct rc4_ctx *ctx, u_char *dst, u_int32_t len) 63 | { 64 | u_int32_t i; 65 | 66 | for (i = 0; i < len; i++) { 67 | ctx->x = (ctx->x + 1) & (RC4STATE - 1); 68 | ctx->y = (ctx->state[ctx->x] + ctx->y) & (RC4STATE - 1); 69 | RC4SWAP(ctx->x, ctx->y); 70 | dst[i] = ctx->state[ 71 | (ctx->state[ctx->x] + ctx->state[ctx->y]) & (RC4STATE - 1)]; 72 | } 73 | } 74 | 75 | void 76 | rc4_skip(struct rc4_ctx *ctx, u_int32_t len) 77 | { 78 | for (; len > 0; len--) { 79 | ctx->x = (ctx->x + 1) & (RC4STATE - 1); 80 | ctx->y = (ctx->state[ctx->x] + ctx->y) & (RC4STATE - 1); 81 | RC4SWAP(ctx->x, ctx->y); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/arc4.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: arc4.h,v 1.3 2007/09/11 12:07:05 djm Exp $ */ 2 | /* 3 | * Copyright (c) 2003 Markus Friedl 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #define RC4STATE 256 19 | #define RC4KEYLEN 16 20 | 21 | struct rc4_ctx { 22 | u_int8_t x, y; 23 | u_int8_t state[RC4STATE]; 24 | }; 25 | 26 | void rc4_keysetup(struct rc4_ctx *, u_char *, u_int32_t) 27 | __attribute__((__bounded__(__buffer__,2,3))); 28 | void rc4_crypt(struct rc4_ctx *, u_char *, u_char *, u_int32_t) 29 | __attribute__((__bounded__(__buffer__,2,4))) 30 | __attribute__((__bounded__(__buffer__,3,4))); 31 | void rc4_getbytes(struct rc4_ctx *, u_char *, u_int32_t) 32 | __attribute__((__bounded__(__buffer__,2,3))); 33 | void rc4_skip(struct rc4_ctx *, u_int32_t); 34 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/blf.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: blf.h,v 1.6 2007/02/21 19:25:40 grunk Exp $ */ 2 | 3 | /* 4 | * Blowfish - a fast block cipher designed by Bruce Schneier 5 | * 6 | * Copyright 1997 Niels Provos 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. All advertising materials mentioning features or use of this software 18 | * must display the following acknowledgement: 19 | * This product includes software developed by Niels Provos. 20 | * 4. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _BLF_H_ 36 | #define _BLF_H_ 37 | 38 | /* Schneier states the maximum key length to be 56 bytes. 39 | * The way how the subkeys are initialized by the key up 40 | * to (N+2)*4 i.e. 72 bytes are utilized. 41 | * Warning: For normal blowfish encryption only 56 bytes 42 | * of the key affect all cipherbits. 43 | */ 44 | 45 | #define BLF_N 16 /* Number of Subkeys */ 46 | #define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */ 47 | #define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */ 48 | 49 | /* Blowfish context */ 50 | typedef struct BlowfishContext { 51 | u_int32_t S[4][256]; /* S-Boxes */ 52 | u_int32_t P[BLF_N + 2]; /* Subkeys */ 53 | } blf_ctx; 54 | 55 | /* Raw access to customized Blowfish 56 | * blf_key is just: 57 | * Blowfish_initstate( state ) 58 | * Blowfish_expand0state( state, key, keylen ) 59 | */ 60 | 61 | void Blowfish_encipher(blf_ctx *, u_int32_t *); 62 | void Blowfish_decipher(blf_ctx *, u_int32_t *); 63 | void Blowfish_initstate(blf_ctx *); 64 | void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t); 65 | void Blowfish_expandstate(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t); 66 | 67 | /* Standard Blowfish */ 68 | 69 | void blf_key(blf_ctx *, const u_int8_t *, u_int16_t); 70 | void blf_enc(blf_ctx *, u_int32_t *, u_int16_t); 71 | void blf_dec(blf_ctx *, u_int32_t *, u_int16_t); 72 | 73 | /* Converts u_int8_t to u_int32_t */ 74 | u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t , 75 | u_int16_t *); 76 | 77 | void blf_ecb_encrypt(blf_ctx *, u_int8_t *, u_int32_t); 78 | void blf_ecb_decrypt(blf_ctx *, u_int8_t *, u_int32_t); 79 | 80 | void blf_cbc_encrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); 81 | void blf_cbc_decrypt(blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t); 82 | #endif 83 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/cast.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: cast.h,v 1.2 2002/03/14 01:26:51 millert Exp $ */ 2 | 3 | /* 4 | * CAST-128 in C 5 | * Written by Steve Reid 6 | * 100% Public Domain - no warranty 7 | * Released 1997.10.11 8 | */ 9 | 10 | #ifndef _CAST_H_ 11 | #define _CAST_H_ 12 | 13 | typedef struct { 14 | u_int32_t xkey[32]; /* Key, after expansion */ 15 | int rounds; /* Number of rounds to use, 12 or 16 */ 16 | } cast_key; 17 | 18 | void cast_setkey(cast_key * key, u_int8_t * rawkey, int keybytes); 19 | void cast_encrypt(cast_key * key, u_int8_t * inblock, u_int8_t * outblock); 20 | void cast_decrypt(cast_key * key, u_int8_t * inblock, u_int8_t * outblock); 21 | 22 | #endif /* ifndef _CAST_H_ */ 23 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/chachapoly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Mike Belopuhov 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | int 25 | chacha20_setkey(void *sched, u_int8_t *key, int len) 26 | { 27 | struct chacha20_ctx *ctx = (struct chacha20_ctx *)sched; 28 | 29 | if (len != CHACHA20_KEYSIZE + CHACHA20_SALT) 30 | return (-1); 31 | 32 | /* initial counter is 1 */ 33 | ctx->nonce[0] = 1; 34 | memcpy(ctx->nonce + CHACHA20_CTR, key + CHACHA20_KEYSIZE, 35 | CHACHA20_SALT); 36 | chacha_keysetup((chacha_ctx *)&ctx->block, key, CHACHA20_KEYSIZE * 8); 37 | return (0); 38 | } 39 | 40 | void 41 | chacha20_reinit(caddr_t key, u_int8_t *iv) 42 | { 43 | struct chacha20_ctx *ctx = (struct chacha20_ctx *)key; 44 | 45 | chacha_ivsetup((chacha_ctx *)ctx->block, iv, ctx->nonce); 46 | } 47 | 48 | void 49 | chacha20_crypt(caddr_t key, u_int8_t *data) 50 | { 51 | struct chacha20_ctx *ctx = (struct chacha20_ctx *)key; 52 | 53 | chacha_encrypt_bytes((chacha_ctx *)ctx->block, data, data, 54 | CHACHA20_BLOCK_LEN); 55 | } 56 | 57 | void 58 | Chacha20_Poly1305_Init(void *xctx) 59 | { 60 | CHACHA20_POLY1305_CTX *ctx = (CHACHA20_POLY1305_CTX *)xctx; 61 | 62 | memset(ctx, 0, sizeof(*ctx)); 63 | } 64 | 65 | void 66 | Chacha20_Poly1305_Setkey(void *xctx, const uint8_t *key, uint16_t klen) 67 | { 68 | CHACHA20_POLY1305_CTX *ctx = (CHACHA20_POLY1305_CTX *)xctx; 69 | 70 | /* salt is provided with the key material */ 71 | memcpy(ctx->nonce + CHACHA20_CTR, key + CHACHA20_KEYSIZE, 72 | CHACHA20_SALT); 73 | chacha_keysetup((chacha_ctx *)&ctx->chacha, key, CHACHA20_KEYSIZE * 8); 74 | } 75 | 76 | void 77 | Chacha20_Poly1305_Reinit(void *xctx, const uint8_t *iv, uint16_t ivlen) 78 | { 79 | CHACHA20_POLY1305_CTX *ctx = (CHACHA20_POLY1305_CTX *)xctx; 80 | 81 | /* initial counter is 0 */ 82 | chacha_ivsetup((chacha_ctx *)&ctx->chacha, iv, ctx->nonce); 83 | chacha_encrypt_bytes((chacha_ctx *)&ctx->chacha, ctx->key, ctx->key, 84 | POLY1305_KEYLEN); 85 | poly1305_init((poly1305_state *)&ctx->poly, ctx->key); 86 | } 87 | 88 | int 89 | Chacha20_Poly1305_Update(void *xctx, const uint8_t *data, uint16_t len) 90 | { 91 | static const char zeroes[POLY1305_BLOCK_LEN] = {0}; 92 | CHACHA20_POLY1305_CTX *ctx = (CHACHA20_POLY1305_CTX *)xctx; 93 | size_t rem; 94 | 95 | poly1305_update((poly1305_state *)&ctx->poly, data, len); 96 | 97 | /* number of bytes in the last 16 byte block */ 98 | rem = (len + POLY1305_BLOCK_LEN) & (POLY1305_BLOCK_LEN - 1); 99 | if (rem > 0) 100 | poly1305_update((poly1305_state *)&ctx->poly, (const unsigned char *)zeroes, 101 | (size_t)(POLY1305_BLOCK_LEN - rem)); 102 | return (0); 103 | } 104 | 105 | void 106 | Chacha20_Poly1305_Final(uint8_t tag[POLY1305_TAGLEN], void *xctx) 107 | { 108 | CHACHA20_POLY1305_CTX *ctx = (CHACHA20_POLY1305_CTX *)xctx; 109 | 110 | poly1305_finish((poly1305_state *)&ctx->poly, tag); 111 | memset(ctx, 0, sizeof(*ctx)); 112 | } 113 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/chachapoly.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Mike Belopuhov 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef _CHACHAPOLY_H_ 18 | #define _CHACHAPOLY_H_ 19 | 20 | #define CHACHA20_KEYSIZE 32 21 | #define CHACHA20_CTR 4 22 | #define CHACHA20_SALT 4 23 | #define CHACHA20_NONCE 8 24 | #define CHACHA20_BLOCK_LEN 64 25 | 26 | struct chacha20_ctx { 27 | uint8_t block[CHACHA20_BLOCK_LEN]; 28 | uint8_t nonce[CHACHA20_NONCE]; 29 | }; 30 | 31 | int chacha20_setkey(void *, u_int8_t *, int); 32 | void chacha20_reinit(caddr_t, u_int8_t *); 33 | void chacha20_crypt(caddr_t, u_int8_t *); 34 | 35 | 36 | #define POLY1305_KEYLEN 32 37 | #define POLY1305_TAGLEN 16 38 | #define POLY1305_BLOCK_LEN 16 39 | 40 | struct poly1305_ctx { 41 | /* r, h, pad, leftover */ 42 | unsigned long state[5+5+4]; 43 | size_t leftover; 44 | unsigned char buffer[POLY1305_BLOCK_LEN]; 45 | unsigned char final; 46 | }; 47 | 48 | typedef struct { 49 | uint8_t key[POLY1305_KEYLEN]; 50 | /* counter, salt */ 51 | uint8_t nonce[CHACHA20_NONCE]; 52 | struct chacha20_ctx chacha; 53 | struct poly1305_ctx poly; 54 | } CHACHA20_POLY1305_CTX; 55 | 56 | void Chacha20_Poly1305_Init(void *); 57 | void Chacha20_Poly1305_Setkey(void *, const uint8_t *, uint16_t); 58 | void Chacha20_Poly1305_Reinit(void *, const uint8_t *, uint16_t); 59 | int Chacha20_Poly1305_Update(void *, const uint8_t *, uint16_t); 60 | void Chacha20_Poly1305_Final(uint8_t[POLY1305_TAGLEN], void *); 61 | 62 | #endif /* _CHACHAPOLY_H_ */ 63 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/cmac.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: cmac.c,v 1.3 2017/05/02 17:07:06 mikeb Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2008 Damien Bergamini 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* 20 | * This code implements the CMAC (Cipher-based Message Authentication) 21 | * algorithm described in FIPS SP800-38B using the AES-128 cipher. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #define LSHIFT(v, r) do { \ 31 | int i; \ 32 | for (i = 0; i < 15; i++) \ 33 | (r)[i] = (v)[i] << 1 | (v)[i + 1] >> 7; \ 34 | (r)[15] = (v)[15] << 1; \ 35 | } while (0) 36 | 37 | #define XOR(v, r) do { \ 38 | int i; \ 39 | for (i = 0; i < 16; i++) \ 40 | (r)[i] ^= (v)[i]; \ 41 | } while (0) 42 | 43 | void 44 | AES_CMAC_Init(AES_CMAC_CTX *ctx) 45 | { 46 | memset(ctx->X, 0, sizeof ctx->X); 47 | ctx->M_n = 0; 48 | } 49 | 50 | void 51 | AES_CMAC_SetKey(AES_CMAC_CTX *ctx, const u_int8_t key[AES_CMAC_KEY_LENGTH]) 52 | { 53 | AES_Setkey(&ctx->aesctx, key, 16); 54 | } 55 | 56 | void 57 | AES_CMAC_Update(AES_CMAC_CTX *ctx, const u_int8_t *data, u_int len) 58 | { 59 | u_int mlen; 60 | 61 | if (ctx->M_n > 0) { 62 | mlen = MIN(16 - ctx->M_n, len); 63 | memcpy(ctx->M_last + ctx->M_n, data, mlen); 64 | ctx->M_n += mlen; 65 | if (ctx->M_n < 16 || len == mlen) 66 | return; 67 | XOR(ctx->M_last, ctx->X); 68 | AES_Encrypt(&ctx->aesctx, ctx->X, ctx->X); 69 | data += mlen; 70 | len -= mlen; 71 | } 72 | while (len > 16) { /* not last block */ 73 | XOR(data, ctx->X); 74 | AES_Encrypt(&ctx->aesctx, ctx->X, ctx->X); 75 | data += 16; 76 | len -= 16; 77 | } 78 | /* potential last block, save it */ 79 | memcpy(ctx->M_last, data, len); 80 | ctx->M_n = len; 81 | } 82 | 83 | void 84 | AES_CMAC_Final(u_int8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *ctx) 85 | { 86 | u_int8_t K[16]; 87 | 88 | /* generate subkey K1 */ 89 | memset(K, 0, sizeof K); 90 | AES_Encrypt(&ctx->aesctx, K, K); 91 | 92 | if (K[0] & 0x80) { 93 | LSHIFT(K, K); 94 | K[15] ^= 0x87; 95 | } else 96 | LSHIFT(K, K); 97 | 98 | if (ctx->M_n == 16) { 99 | /* last block was a complete block */ 100 | XOR(K, ctx->M_last); 101 | } else { 102 | /* generate subkey K2 */ 103 | if (K[0] & 0x80) { 104 | LSHIFT(K, K); 105 | K[15] ^= 0x87; 106 | } else 107 | LSHIFT(K, K); 108 | 109 | /* padding(M_last) */ 110 | ctx->M_last[ctx->M_n] = 0x80; 111 | while (++ctx->M_n < 16) 112 | ctx->M_last[ctx->M_n] = 0; 113 | 114 | XOR(K, ctx->M_last); 115 | } 116 | XOR(ctx->M_last, ctx->X); 117 | AES_Encrypt(&ctx->aesctx, ctx->X, digest); 118 | 119 | memset(K, 0, sizeof K); 120 | } 121 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/cmac.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: cmac.h,v 1.3 2017/05/02 17:07:06 mikeb Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2008 Damien Bergamini 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef _CMAC_H_ 20 | #define _CMAC_H_ 21 | 22 | #define AES_CMAC_KEY_LENGTH 16 23 | #define AES_CMAC_DIGEST_LENGTH 16 24 | 25 | typedef struct _AES_CMAC_CTX { 26 | AES_CTX aesctx; 27 | u_int8_t X[16]; 28 | u_int8_t M_last[16]; 29 | u_int M_n; 30 | } AES_CMAC_CTX; 31 | 32 | //__BEGIN_DECLS 33 | void AES_CMAC_Init(AES_CMAC_CTX *); 34 | void AES_CMAC_SetKey(AES_CMAC_CTX *, const u_int8_t [AES_CMAC_KEY_LENGTH]); 35 | void AES_CMAC_Update(AES_CMAC_CTX *, const u_int8_t *, u_int) 36 | __attribute__((__bounded__(__string__,2,3))); 37 | void AES_CMAC_Final(u_int8_t [AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *) 38 | __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH))); 39 | //__END_DECLS 40 | 41 | #endif /* _CMAC_H_ */ 42 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/ecb3_enc.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ecb3_enc.c,v 1.3 2013/11/18 18:49:53 brad Exp $ */ 2 | 3 | /* lib/des/ecb3_enc.c */ 4 | /* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) 5 | * All rights reserved. 6 | * 7 | * This file is part of an SSL implementation written 8 | * by Eric Young (eay@mincom.oz.au). 9 | * The implementation was written so as to conform with Netscapes SSL 10 | * specification. This library and applications are 11 | * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE 12 | * as long as the following conditions are aheared to. 13 | * 14 | * Copyright remains Eric Young's, and as such any Copyright notices in 15 | * the code are not to be removed. If this code is used in a product, 16 | * Eric Young should be given attribution as the author of the parts used. 17 | * This can be in the form of a textual message at program startup or 18 | * in documentation (online or textual) provided with the package. 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 1. Redistributions of source code must retain the copyright 24 | * notice, this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright 26 | * notice, this list of conditions and the following disclaimer in the 27 | * documentation and/or other materials provided with the distribution. 28 | * 3. All advertising materials mentioning features or use of this software 29 | * must display the following acknowledgement: 30 | * This product includes software developed by Eric Young (eay@mincom.oz.au) 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 41 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 42 | * SUCH DAMAGE. 43 | * 44 | * The licence and distribution terms for any publically available version or 45 | * derivative of this code cannot be changed. i.e. this code cannot simply be 46 | * copied and put under another distribution licence 47 | * [including the GNU Public Licence.] 48 | */ 49 | 50 | #include "des_locl.h" 51 | 52 | void 53 | des_ecb3_encrypt(des_cblock (*input), des_cblock (*output), 54 | des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3, 55 | int encrypt) 56 | { 57 | register u_int32_t l0, l1; 58 | register unsigned char *in, *out; 59 | u_int32_t ll[2]; 60 | 61 | in = (unsigned char *) input; 62 | out = (unsigned char *) output; 63 | c2l(in, l0); 64 | c2l(in, l1); 65 | IP(l0, l1); 66 | ll[0] = l0; 67 | ll[1] = l1; 68 | des_encrypt2(ll, ks1, encrypt); 69 | des_encrypt2(ll, ks2, !encrypt); 70 | des_encrypt2(ll, ks3, encrypt); 71 | l0 = ll[0]; 72 | l1 = ll[1]; 73 | FP(l1, l0); 74 | l2c(l0, out); 75 | l2c(l1, out); 76 | } 77 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/ecb_enc.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ecb_enc.c,v 1.6 2015/12/10 21:00:51 naddy Exp $ */ 2 | 3 | /* lib/des/ecb_enc.c */ 4 | /* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) 5 | * All rights reserved. 6 | * 7 | * This file is part of an SSL implementation written 8 | * by Eric Young (eay@mincom.oz.au). 9 | * The implementation was written so as to conform with Netscapes SSL 10 | * specification. This library and applications are 11 | * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE 12 | * as long as the following conditions are aheared to. 13 | * 14 | * Copyright remains Eric Young's, and as such any Copyright notices in 15 | * the code are not to be removed. If this code is used in a product, 16 | * Eric Young should be given attribution as the author of the parts used. 17 | * This can be in the form of a textual message at program startup or 18 | * in documentation (online or textual) provided with the package. 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 1. Redistributions of source code must retain the copyright 24 | * notice, this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright 26 | * notice, this list of conditions and the following disclaimer in the 27 | * documentation and/or other materials provided with the distribution. 28 | * 3. All advertising materials mentioning features or use of this software 29 | * must display the following acknowledgement: 30 | * This product includes software developed by Eric Young (eay@mincom.oz.au) 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 41 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 42 | * SUCH DAMAGE. 43 | * 44 | * The licence and distribution terms for any publically available version or 45 | * derivative of this code cannot be changed. i.e. this code cannot simply be 46 | * copied and put under another distribution licence 47 | * [including the GNU Public Licence.] 48 | */ 49 | 50 | #include "des_locl.h" 51 | #include "spr.h" 52 | 53 | void 54 | des_encrypt2(u_int32_t *data, des_key_schedule ks, int encrypt) 55 | { 56 | register u_int32_t l, r, t, u; 57 | #ifdef DES_USE_PTR 58 | register unsigned char *des_SP=(unsigned char *)des_SPtrans; 59 | #endif 60 | register int i; 61 | register u_int32_t *s; 62 | 63 | u = data[0]; 64 | r = data[1]; 65 | 66 | /* Things have been modified so that the initial rotate is 67 | * done outside the loop. This required the 68 | * des_SPtrans values in sp.h to be rotated 1 bit to the right. 69 | * One perl script later and things have a 5% speed up on a sparc2. 70 | * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> 71 | * for pointing this out. */ 72 | l = (r << 1) | (r >> 31); 73 | r = (u << 1) | (u >> 31); 74 | 75 | /* clear the top bits on machines with 8byte longs */ 76 | l &= 0xffffffffL; 77 | r &= 0xffffffffL; 78 | 79 | s = (u_int32_t *) ks; 80 | /* I don't know if it is worth the effort of loop unrolling the 81 | * inner loop */ 82 | if (encrypt) { 83 | for (i = 0; i < 32; i += 4) { 84 | D_ENCRYPT(l, r, i + 0); /* 1 */ 85 | D_ENCRYPT(r, l, i + 2); /* 2 */ 86 | } 87 | } else { 88 | for (i = 30; i > 0; i -= 4) { 89 | D_ENCRYPT(l, r, i - 0); /* 16 */ 90 | D_ENCRYPT(r, l, i - 2); /* 15 */ 91 | } 92 | } 93 | l = (l >> 1) | (l << 31); 94 | r = (r >> 1) | (r << 31); 95 | /* clear the top bits on machines with 8byte longs */ 96 | l &= 0xffffffffL; 97 | r &= 0xffffffffL; 98 | 99 | data[0] = l; 100 | data[1] = r; 101 | l = r = t = u = 0; 102 | } 103 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/gmac.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: gmac.c,v 1.10 2017/05/02 11:44:32 mikeb Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2010 Mike Belopuhov 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* 20 | * This code implements the Message Authentication part of the 21 | * Galois/Counter Mode (as being described in the RFC 4543) using 22 | * the AES cipher. FIPS SP 800-38D describes the algorithm details. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | void ghash_gfmul(uint32_t *, uint32_t *, uint32_t *); 33 | void ghash_update_mi(GHASH_CTX *, uint8_t *, size_t); 34 | 35 | /* Allow overriding with optimized MD function */ 36 | void (*ghash_update)(GHASH_CTX *, uint8_t *, size_t) = ghash_update_mi; 37 | 38 | /* Computes a block multiplication in the GF(2^128) */ 39 | void 40 | ghash_gfmul(uint32_t *X, uint32_t *Y, uint32_t *product) 41 | { 42 | uint32_t v[4]; 43 | uint32_t z[4] = { 0, 0, 0, 0}; 44 | uint8_t *x = (uint8_t *)X; 45 | uint32_t mask; 46 | int i; 47 | 48 | v[0] = betoh32(Y[0]); 49 | v[1] = betoh32(Y[1]); 50 | v[2] = betoh32(Y[2]); 51 | v[3] = betoh32(Y[3]); 52 | 53 | for (i = 0; i < GMAC_BLOCK_LEN * 8; i++) { 54 | /* update Z */ 55 | mask = !!(x[i >> 3] & (1 << (~i & 7))); 56 | mask = ~(mask - 1); 57 | z[0] ^= v[0] & mask; 58 | z[1] ^= v[1] & mask; 59 | z[2] ^= v[2] & mask; 60 | z[3] ^= v[3] & mask; 61 | 62 | /* update V */ 63 | mask = ~((v[3] & 1) - 1); 64 | v[3] = (v[2] << 31) | (v[3] >> 1); 65 | v[2] = (v[1] << 31) | (v[2] >> 1); 66 | v[1] = (v[0] << 31) | (v[1] >> 1); 67 | v[0] = (v[0] >> 1) ^ (0xe1000000 & mask); 68 | } 69 | 70 | product[0] = htobe32(z[0]); 71 | product[1] = htobe32(z[1]); 72 | product[2] = htobe32(z[2]); 73 | product[3] = htobe32(z[3]); 74 | } 75 | 76 | void 77 | ghash_update_mi(GHASH_CTX *ctx, uint8_t *X, size_t len) 78 | { 79 | uint32_t *x = (uint32_t *)X; 80 | uint32_t *s = (uint32_t *)ctx->S; 81 | uint32_t *y = (uint32_t *)ctx->Z; 82 | int i; 83 | 84 | for (i = 0; i < len / GMAC_BLOCK_LEN; i++) { 85 | s[0] = y[0] ^ x[0]; 86 | s[1] = y[1] ^ x[1]; 87 | s[2] = y[2] ^ x[2]; 88 | s[3] = y[3] ^ x[3]; 89 | 90 | ghash_gfmul((uint32_t *)ctx->S, (uint32_t *)ctx->H, 91 | (uint32_t *)ctx->S); 92 | 93 | y = s; 94 | x += 4; 95 | } 96 | 97 | bcopy(ctx->S, ctx->Z, GMAC_BLOCK_LEN); 98 | } 99 | 100 | #define AESCTR_NONCESIZE 4 101 | 102 | void 103 | AES_GMAC_Init(void *xctx) 104 | { 105 | AES_GMAC_CTX *ctx = (AES_GMAC_CTX *)xctx; 106 | 107 | bzero(ctx->ghash.H, GMAC_BLOCK_LEN); 108 | bzero(ctx->ghash.S, GMAC_BLOCK_LEN); 109 | bzero(ctx->ghash.Z, GMAC_BLOCK_LEN); 110 | bzero(ctx->J, GMAC_BLOCK_LEN); 111 | } 112 | 113 | void 114 | AES_GMAC_Setkey(void *xctx, const uint8_t *key, uint16_t klen) 115 | { 116 | AES_GMAC_CTX *ctx = (AES_GMAC_CTX *)xctx; 117 | 118 | AES_Setkey(&ctx->K, key, klen - AESCTR_NONCESIZE); 119 | /* copy out salt to the counter block */ 120 | bcopy(key + klen - AESCTR_NONCESIZE, ctx->J, AESCTR_NONCESIZE); 121 | /* prepare a hash subkey */ 122 | AES_Encrypt(&ctx->K, ctx->ghash.H, ctx->ghash.H); 123 | } 124 | 125 | void 126 | AES_GMAC_Reinit(void *xctx, const uint8_t *iv, uint16_t ivlen) 127 | { 128 | AES_GMAC_CTX *ctx = (AES_GMAC_CTX *)xctx; 129 | 130 | /* copy out IV to the counter block */ 131 | bcopy(iv, ctx->J + AESCTR_NONCESIZE, ivlen); 132 | } 133 | 134 | int 135 | AES_GMAC_Update(void *xctx, const uint8_t *data, uint16_t len) 136 | { 137 | AES_GMAC_CTX *ctx = (AES_GMAC_CTX *)xctx; 138 | uint32_t blk[4] = { 0, 0, 0, 0 }; 139 | int plen; 140 | 141 | if (len > 0) { 142 | plen = len % GMAC_BLOCK_LEN; 143 | if (len >= GMAC_BLOCK_LEN) 144 | (*ghash_update)(&ctx->ghash, (uint8_t *)data, 145 | len - plen); 146 | if (plen) { 147 | memcpy((uint8_t *)blk, (uint8_t *)data + (len - plen), 148 | plen); 149 | (*ghash_update)(&ctx->ghash, (uint8_t *)blk, 150 | GMAC_BLOCK_LEN); 151 | } 152 | } 153 | return (0); 154 | } 155 | 156 | void 157 | AES_GMAC_Final(uint8_t digest[GMAC_DIGEST_LEN], void *xctx) 158 | { 159 | AES_GMAC_CTX *ctx = (AES_GMAC_CTX *)xctx; 160 | uint8_t keystream[GMAC_BLOCK_LEN]; 161 | int i; 162 | 163 | /* do one round of GCTR */ 164 | ctx->J[GMAC_BLOCK_LEN - 1] = 1; 165 | AES_Encrypt(&ctx->K, ctx->J, keystream); 166 | for (i = 0; i < GMAC_DIGEST_LEN; i++) 167 | digest[i] = ctx->ghash.S[i] ^ keystream[i]; 168 | memset(keystream, 0, sizeof(keystream)); 169 | } 170 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/gmac.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: gmac.h,v 1.6 2017/05/02 11:44:32 mikeb Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2010 Mike Belopuhov 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef _GMAC_H_ 20 | #define _GMAC_H_ 21 | 22 | #include 23 | 24 | #define GMAC_BLOCK_LEN 16 25 | #define GMAC_DIGEST_LEN 16 26 | 27 | typedef struct _GHASH_CTX { 28 | uint8_t H[GMAC_BLOCK_LEN]; /* hash subkey */ 29 | uint8_t S[GMAC_BLOCK_LEN]; /* state */ 30 | uint8_t Z[GMAC_BLOCK_LEN]; /* initial state */ 31 | } GHASH_CTX; 32 | 33 | typedef struct _AES_GMAC_CTX { 34 | GHASH_CTX ghash; 35 | AES_CTX K; 36 | uint8_t J[GMAC_BLOCK_LEN]; /* counter block */ 37 | } AES_GMAC_CTX; 38 | 39 | //__BEGIN_DECLS 40 | extern void (*ghash_update)(GHASH_CTX *, uint8_t *, size_t); 41 | 42 | void AES_GMAC_Init(void *); 43 | void AES_GMAC_Setkey(void *, const uint8_t *, uint16_t); 44 | void AES_GMAC_Reinit(void *, const uint8_t *, uint16_t); 45 | int AES_GMAC_Update(void *, const uint8_t *, uint16_t); 46 | void AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN], void *); 47 | //__END_DECLS 48 | 49 | #endif /* _GMAC_H_ */ 50 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/hmac.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: hmac.h,v 1.3 2012/12/05 23:20:15 deraadt Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2008 Damien Bergamini 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef _HMAC_H_ 20 | #define _HMAC_H_ 21 | 22 | typedef struct _HMAC_MD5_CTX { 23 | MD5_CTX ctx; 24 | u_int8_t key[MD5_BLOCK_LENGTH]; 25 | u_int key_len; 26 | } HMAC_MD5_CTX; 27 | 28 | typedef struct _HMAC_SHA1_CTX { 29 | SHA1_CTX ctx; 30 | u_int8_t key[SHA1_BLOCK_LENGTH]; 31 | u_int key_len; 32 | } HMAC_SHA1_CTX; 33 | 34 | typedef struct _HMAC_SHA256_CTX { 35 | SHA2_CTX ctx; 36 | u_int8_t key[SHA256_BLOCK_LENGTH]; 37 | u_int key_len; 38 | } HMAC_SHA256_CTX; 39 | 40 | //__BEGIN_DECLS 41 | 42 | void HMAC_MD5_Init(HMAC_MD5_CTX *, const u_int8_t *, u_int) 43 | __attribute__((__bounded__(__string__,2,3))); 44 | void HMAC_MD5_Update(HMAC_MD5_CTX *, const u_int8_t *, u_int) 45 | __attribute__((__bounded__(__string__,2,3))); 46 | void HMAC_MD5_Final(u_int8_t [MD5_DIGEST_LENGTH], HMAC_MD5_CTX *) 47 | __attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH))); 48 | 49 | void HMAC_SHA1_Init(HMAC_SHA1_CTX *, const u_int8_t *, u_int) 50 | __attribute__((__bounded__(__string__,2,3))); 51 | void HMAC_SHA1_Update(HMAC_SHA1_CTX *, const u_int8_t *, u_int) 52 | __attribute__((__bounded__(__string__,2,3))); 53 | void HMAC_SHA1_Final(u_int8_t [SHA1_DIGEST_LENGTH], HMAC_SHA1_CTX *) 54 | __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH))); 55 | 56 | void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const u_int8_t *, u_int) 57 | __attribute__((__bounded__(__string__,2,3))); 58 | void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const u_int8_t *, u_int) 59 | __attribute__((__bounded__(__string__,2,3))); 60 | void HMAC_SHA256_Final(u_int8_t [SHA256_DIGEST_LENGTH], HMAC_SHA256_CTX *) 61 | __attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH))); 62 | 63 | //__END_DECLS 64 | 65 | #endif /* _HMAC_H_ */ 66 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/idgen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Damien Miller 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | /* 18 | * IDGEN32: non-repeating ID generation covering an almost maximal 32-bit 19 | * range. 20 | * 21 | * IDGEN32 is based on public domain SKIP32 by Greg Rose. 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #define time_second 20 32 | 33 | static const u_int8_t idgen32_ftable[256] = { 34 | 0xa3, 0xd7, 0x09, 0x83, 0xf8, 0x48, 0xf6, 0xf4, 35 | 0xb3, 0x21, 0x15, 0x78, 0x99, 0xb1, 0xaf, 0xf9, 36 | 0xe7, 0x2d, 0x4d, 0x8a, 0xce, 0x4c, 0xca, 0x2e, 37 | 0x52, 0x95, 0xd9, 0x1e, 0x4e, 0x38, 0x44, 0x28, 38 | 0x0a, 0xdf, 0x02, 0xa0, 0x17, 0xf1, 0x60, 0x68, 39 | 0x12, 0xb7, 0x7a, 0xc3, 0xe9, 0xfa, 0x3d, 0x53, 40 | 0x96, 0x84, 0x6b, 0xba, 0xf2, 0x63, 0x9a, 0x19, 41 | 0x7c, 0xae, 0xe5, 0xf5, 0xf7, 0x16, 0x6a, 0xa2, 42 | 0x39, 0xb6, 0x7b, 0x0f, 0xc1, 0x93, 0x81, 0x1b, 43 | 0xee, 0xb4, 0x1a, 0xea, 0xd0, 0x91, 0x2f, 0xb8, 44 | 0x55, 0xb9, 0xda, 0x85, 0x3f, 0x41, 0xbf, 0xe0, 45 | 0x5a, 0x58, 0x80, 0x5f, 0x66, 0x0b, 0xd8, 0x90, 46 | 0x35, 0xd5, 0xc0, 0xa7, 0x33, 0x06, 0x65, 0x69, 47 | 0x45, 0x00, 0x94, 0x56, 0x6d, 0x98, 0x9b, 0x76, 48 | 0x97, 0xfc, 0xb2, 0xc2, 0xb0, 0xfe, 0xdb, 0x20, 49 | 0xe1, 0xeb, 0xd6, 0xe4, 0xdd, 0x47, 0x4a, 0x1d, 50 | 0x42, 0xed, 0x9e, 0x6e, 0x49, 0x3c, 0xcd, 0x43, 51 | 0x27, 0xd2, 0x07, 0xd4, 0xde, 0xc7, 0x67, 0x18, 52 | 0x89, 0xcb, 0x30, 0x1f, 0x8d, 0xc6, 0x8f, 0xaa, 53 | 0xc8, 0x74, 0xdc, 0xc9, 0x5d, 0x5c, 0x31, 0xa4, 54 | 0x70, 0x88, 0x61, 0x2c, 0x9f, 0x0d, 0x2b, 0x87, 55 | 0x50, 0x82, 0x54, 0x64, 0x26, 0x7d, 0x03, 0x40, 56 | 0x34, 0x4b, 0x1c, 0x73, 0xd1, 0xc4, 0xfd, 0x3b, 57 | 0xcc, 0xfb, 0x7f, 0xab, 0xe6, 0x3e, 0x5b, 0xa5, 58 | 0xad, 0x04, 0x23, 0x9c, 0x14, 0x51, 0x22, 0xf0, 59 | 0x29, 0x79, 0x71, 0x7e, 0xff, 0x8c, 0x0e, 0xe2, 60 | 0x0c, 0xef, 0xbc, 0x72, 0x75, 0x6f, 0x37, 0xa1, 61 | 0xec, 0xd3, 0x8e, 0x62, 0x8b, 0x86, 0x10, 0xe8, 62 | 0x08, 0x77, 0x11, 0xbe, 0x92, 0x4f, 0x24, 0xc5, 63 | 0x32, 0x36, 0x9d, 0xcf, 0xf3, 0xa6, 0xbb, 0xac, 64 | 0x5e, 0x6c, 0xa9, 0x13, 0x57, 0x25, 0xb5, 0xe3, 65 | 0xbd, 0xa8, 0x3a, 0x01, 0x05, 0x59, 0x2a, 0x46 66 | }; 67 | 68 | static u_int16_t 69 | idgen32_g(u_int8_t *key, int k, u_int16_t w) 70 | { 71 | u_int8_t g1, g2, g3, g4, g5, g6; 72 | u_int o = k * 4; 73 | 74 | g1 = (w >> 8) & 0xff; 75 | g2 = w & 0xff; 76 | 77 | g3 = idgen32_ftable[g2 ^ key[o++ & (IDGEN32_KEYLEN - 1)]] ^ g1; 78 | g4 = idgen32_ftable[g3 ^ key[o++ & (IDGEN32_KEYLEN - 1)]] ^ g2; 79 | g5 = idgen32_ftable[g4 ^ key[o++ & (IDGEN32_KEYLEN - 1)]] ^ g3; 80 | g6 = idgen32_ftable[g5 ^ key[o++ & (IDGEN32_KEYLEN - 1)]] ^ g4; 81 | 82 | return (g5 << 8) | g6; 83 | } 84 | 85 | static u_int32_t 86 | idgen32_permute(struct idgen32_ctx *ctx, u_int32_t in) 87 | { 88 | u_int i, r; 89 | u_int16_t wl, wr; 90 | 91 | wl = (in >> 16) & 0x7fff; 92 | wr = in & 0xffff; 93 | 94 | /* Doubled up rounds, with an odd round at the end to swap */ 95 | for (i = r = 0; i < IDGEN32_ROUNDS / 2; ++i) { 96 | wr ^= (idgen32_g(ctx->id32_key, r, wl) ^ r); 97 | r++; 98 | wl ^= (idgen32_g(ctx->id32_key, r, wr) ^ r) & 0x7fff; 99 | r++; 100 | } 101 | wr ^= (idgen32_g(ctx->id32_key, r, wl) ^ r); 102 | 103 | return (wl << 16) | wr; 104 | } 105 | 106 | static void 107 | idgen32_rekey(struct idgen32_ctx *ctx) 108 | { 109 | ctx->id32_counter = 0; 110 | ctx->id32_hibit ^= 0x80000000; 111 | ctx->id32_offset = arc4random(); 112 | arc4random_buf(ctx->id32_key, sizeof(ctx->id32_key)); 113 | ctx->id32_rekey_time = time_second + IDGEN32_REKEY_TIME; 114 | } 115 | 116 | void 117 | idgen32_init(struct idgen32_ctx *ctx) 118 | { 119 | bzero(ctx, sizeof(*ctx)); 120 | ctx->id32_hibit = arc4random() & 0x80000000; 121 | idgen32_rekey(ctx); 122 | } 123 | 124 | u_int32_t 125 | idgen32(struct idgen32_ctx *ctx) 126 | { 127 | u_int32_t ret; 128 | 129 | do { 130 | /* Rekey a little early to avoid "card counting" attack */ 131 | if (ctx->id32_counter > IDGEN32_REKEY_LIMIT || 132 | ctx->id32_rekey_time < time_second) 133 | idgen32_rekey(ctx); 134 | ret = ctx->id32_hibit | idgen32_permute(ctx, 135 | (ctx->id32_offset + ctx->id32_counter++) & 0x7fffffff); 136 | } while (ret == 0); /* Zero IDs are often special, so avoid */ 137 | 138 | return ret; 139 | } 140 | 141 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/idgen.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: idgen.h,v 1.3 2013/06/05 05:45:54 djm Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Damien Miller 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #define IDGEN32_ROUNDS 31 19 | #define IDGEN32_KEYLEN 32 20 | #define IDGEN32_REKEY_LIMIT 0x60000000 21 | #define IDGEN32_REKEY_TIME 600 22 | 23 | struct idgen32_ctx { 24 | u_int32_t id32_counter; 25 | u_int32_t id32_offset; 26 | u_int32_t id32_hibit; 27 | u_int8_t id32_key[IDGEN32_KEYLEN]; 28 | time_t id32_rekey_time; 29 | }; 30 | 31 | void idgen32_init(struct idgen32_ctx *); 32 | u_int32_t idgen32(struct idgen32_ctx *); 33 | 34 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/key_wrap.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: key_wrap.c,v 1.5 2017/05/02 17:07:06 mikeb Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2008 Damien Bergamini 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* 20 | * This code implements the AES Key Wrap algorithm described in RFC 3394. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | static const u_int8_t IV[8] = 31 | { 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6 }; 32 | 33 | void 34 | aes_key_wrap_set_key(aes_key_wrap_ctx *ctx, const u_int8_t *K, size_t K_len) 35 | { 36 | AES_Setkey(&ctx->ctx, K, K_len); 37 | } 38 | 39 | void 40 | aes_key_wrap_set_key_wrap_only(aes_key_wrap_ctx *ctx, const u_int8_t *K, 41 | size_t K_len) 42 | { 43 | AES_Setkey(&ctx->ctx, K, K_len); 44 | } 45 | 46 | void 47 | aes_key_wrap(aes_key_wrap_ctx *ctx, const u_int8_t *P, size_t n, u_int8_t *C) 48 | { 49 | u_int64_t B[2], t; 50 | u_int8_t *A, *R; 51 | size_t i; 52 | int j; 53 | 54 | memmove(C + 8, P, n * 8); /* P and C may overlap */ 55 | A = C; /* A points to C[0] */ 56 | memcpy(A, IV, 8); /* A = IV, an initial value */ 57 | 58 | for (j = 0, t = 1; j <= 5; j++) { 59 | R = C + 8; 60 | for (i = 1; i <= n; i++, t++) { 61 | /* B = A | R[i] */ 62 | memcpy(&B[0], A, 8); 63 | memcpy(&B[1], R, 8); 64 | /* B = AES(K, B) */ 65 | AES_Encrypt(&ctx->ctx, (const uint8_t *)(caddr_t)B, (uint8_t *)(caddr_t)B); 66 | /* MSB(64, B) = MSB(64, B) ^ t */ 67 | B[0] ^= htobe64(t); 68 | /* A = MSB(64, B) */ 69 | memcpy(A, &B[0], 8); 70 | /* R[i] = LSB(64, B) */ 71 | memcpy(R, &B[1], 8); 72 | 73 | R += 8; 74 | } 75 | } 76 | memset(B, 0, sizeof B); 77 | } 78 | 79 | int 80 | aes_key_unwrap(aes_key_wrap_ctx *ctx, const u_int8_t *C, u_int8_t *P, size_t n) 81 | { 82 | u_int64_t B[2], t; 83 | u_int8_t A[8], *R; 84 | size_t i; 85 | int j; 86 | 87 | memcpy(A, C, 8); /* A = C[0] */ 88 | memmove(P, C + 8, n * 8); /* P and C may overlap */ 89 | 90 | for (j = 5, t = 6 * n; j >= 0; j--) { 91 | R = P + (n - 1) * 8; 92 | for (i = n; i >= 1; i--, t--) { 93 | /* MSB(64, B) = A */ 94 | memcpy(&B[0], A, 8); 95 | /* MSB(64, B) = MSB(64, B) ^ t */ 96 | B[0] ^= htobe64(t); 97 | /* B = MSB(64, B) | R[i] */ 98 | memcpy(&B[1], R, 8); 99 | /* B = AES-1(K, B) */ 100 | AES_Decrypt(&ctx->ctx, (const uint8_t *)(caddr_t)B, (uint8_t *)(caddr_t)B); 101 | /* A = MSB(64, B) */ 102 | memcpy(A, &B[0], 8); 103 | /* R[i] = LSB(64, B) */ 104 | memcpy(R, &B[1], 8); 105 | 106 | R -= 8; 107 | } 108 | } 109 | memset(B, 0, sizeof B); 110 | 111 | /* check that A is an appropriate initial value */ 112 | return timingsafe_bcmp(A, IV, 8) != 0; 113 | } 114 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/key_wrap.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: key_wrap.h,v 1.3 2017/05/02 17:07:06 mikeb Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2008 Damien Bergamini 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef _KEY_WRAP_H_ 20 | #define _KEY_WRAP_H_ 21 | 22 | extern int timingsafe_bcmp(const void *b1, const void *b2, size_t n); 23 | 24 | typedef struct _aes_key_wrap_ctx { 25 | AES_CTX ctx; 26 | } aes_key_wrap_ctx; 27 | 28 | //__BEGIN_DECLS 29 | 30 | void aes_key_wrap_set_key(aes_key_wrap_ctx *, const u_int8_t *, size_t); 31 | void aes_key_wrap_set_key_wrap_only(aes_key_wrap_ctx *, const u_int8_t *, 32 | size_t); 33 | void aes_key_wrap(aes_key_wrap_ctx *, const u_int8_t *, size_t, u_int8_t *); 34 | int aes_key_unwrap(aes_key_wrap_ctx *, const u_int8_t *, u_int8_t *, 35 | size_t); 36 | //__END_DECLS 37 | 38 | #endif /* _KEY_WRAP_H_ */ 39 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/md5.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: md5.h,v 1.3 2014/11/16 17:39:09 tedu Exp $ */ 2 | 3 | /* 4 | * This code implements the MD5 message-digest algorithm. 5 | * The algorithm is due to Ron Rivest. This code was 6 | * written by Colin Plumb in 1993, no copyright is claimed. 7 | * This code is in the public domain; do with it what you wish. 8 | * 9 | * Equivalent code is available from RSA Data Security, Inc. 10 | * This code has been tested against that, and is equivalent, 11 | * except that you don't need to include two pages of legalese 12 | * with every copy. 13 | */ 14 | 15 | #ifndef _MD5_H_ 16 | #define _MD5_H_ 17 | 18 | #define MD5_BLOCK_LENGTH 64 19 | #define MD5_DIGEST_LENGTH 16 20 | 21 | typedef struct MD5Context { 22 | u_int32_t state[4]; /* state */ 23 | u_int64_t count; /* number of bits, mod 2^64 */ 24 | u_int8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */ 25 | } MD5_CTX; 26 | 27 | //__BEGIN_DECLS 28 | void MD5Init(MD5_CTX *); 29 | void MD5Update(MD5_CTX *, const void *, size_t) 30 | __attribute__((__bounded__(__string__,2,3))); 31 | void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *) 32 | __attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH))); 33 | void MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]) 34 | __attribute__((__bounded__(__minbytes__,1,4))) 35 | __attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH))); 36 | //__END_DECLS 37 | 38 | #endif /* _MD5_H_ */ 39 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/michael.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: michael.c,v 1.2 2008/07/21 19:52:45 damien Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2005, 2006 Reyk Floeter 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | /* 20 | * Implementation of the Michael MIC as defined in IEEE 802.11i for TKIP. 21 | * The MIC generates a 64bit digest, which shouldn't be used for any other 22 | * applications except TKIP. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #define ROL(n, x) (((x) << (n)) | ((x) >> (32 - (n)))) 31 | #define ROR(n, x) (((x) >> (n)) | ((x) << (32 - (n)))) 32 | #define XSWAP(x) (((x) & 0xff00ff00UL) >> 8 | ((x) & 0x00ff00ffUL) << 8) 33 | 34 | #if defined(__STRICT_ALIGNMENT) || _BYTE_ORDER != _LITTLE_ENDIAN 35 | #define GETLE32(x) ((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24) 36 | #define PUTLE32(x, v) ((x)[0] = (u_int8_t)(v), \ 37 | (x)[1] = (u_int8_t)((v) >> 8), \ 38 | (x)[2] = (u_int8_t)((v) >> 16), \ 39 | (x)[3] = (u_int8_t)((v) >> 24)) 40 | #else 41 | #define GETLE32(x) (*((u_int32_t *)(x))) 42 | #define PUTLE32(x, v) (*((u_int32_t *)(x)) = (v)) 43 | #endif 44 | 45 | #define MICHAEL_BLOCK(l, r) do { \ 46 | r ^= ROL(17, l); \ 47 | l += r; \ 48 | r ^= XSWAP(l); \ 49 | l += r; \ 50 | r ^= ROL(3, l); \ 51 | l += r; \ 52 | r ^= ROR(2, l); \ 53 | l += r; \ 54 | } while (0) 55 | 56 | void 57 | michael_init(MICHAEL_CTX *ctx) 58 | { 59 | bzero(ctx, sizeof(MICHAEL_CTX)); 60 | } 61 | 62 | void 63 | michael_update(MICHAEL_CTX *ctx, const u_int8_t *data, u_int len) 64 | { 65 | int i; 66 | 67 | for (i = 0; i < len; i++) { 68 | ctx->michael_state |= data[i] << (ctx->michael_count << 3); 69 | ctx->michael_count++; 70 | 71 | if (ctx->michael_count >= MICHAEL_RAW_BLOCK_LENGTH) { 72 | ctx->michael_l ^= ctx->michael_state; 73 | MICHAEL_BLOCK(ctx->michael_l, ctx->michael_r); 74 | ctx->michael_state = ctx->michael_count = 0; 75 | } 76 | } 77 | } 78 | 79 | void 80 | michael_final(u_int8_t digest[MICHAEL_DIGEST_LENGTH], MICHAEL_CTX *ctx) 81 | { 82 | static const u_int8_t pad[] = 83 | { 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 84 | 85 | michael_update(ctx, pad, sizeof(pad)); 86 | 87 | PUTLE32(digest, ctx->michael_l); 88 | PUTLE32(digest + MICHAEL_RAW_BLOCK_LENGTH, ctx->michael_r); 89 | } 90 | 91 | void 92 | michael_key(const u_int8_t *key, MICHAEL_CTX *ctx) 93 | { 94 | ctx->michael_l = ctx->michael_key[0] = 95 | GETLE32(key); 96 | ctx->michael_r = ctx->michael_key[1] = 97 | GETLE32(key + MICHAEL_RAW_BLOCK_LENGTH); 98 | } 99 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/michael.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: michael.h,v 1.2 2012/12/05 23:20:15 deraadt Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2005, 2006 Reyk Floeter 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef _MICHAEL_H_ 20 | #define _MICHAEL_H_ 21 | 22 | #define MICHAEL_BLOCK_LENGTH 8 23 | #define MICHAEL_RAW_BLOCK_LENGTH 4 24 | #define MICHAEL_DIGEST_LENGTH 8 25 | 26 | typedef struct michael_context { 27 | u_int32_t michael_key[2]; 28 | u_int32_t michael_l, michael_r; 29 | u_int32_t michael_state; 30 | u_int michael_count; 31 | } MICHAEL_CTX; 32 | 33 | //__BEGIN_DECLS 34 | void michael_init(MICHAEL_CTX *); 35 | void michael_update(MICHAEL_CTX *, const u_int8_t *, u_int) 36 | __attribute__((__bounded__(__buffer__, 2, 3))); 37 | void michael_final(u_int8_t [MICHAEL_DIGEST_LENGTH], MICHAEL_CTX *) 38 | __attribute__((__bounded__(__minbytes__, 1, 39 | MICHAEL_DIGEST_LENGTH))); 40 | void michael_key(const u_int8_t *, MICHAEL_CTX *) 41 | __attribute__((__bounded__(__minbytes__, 1, 42 | MICHAEL_BLOCK_LENGTH))); 43 | //__END_DECLS 44 | 45 | #endif /* _MICHAEL_H_ */ 46 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/podd.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: podd.h,v 1.1 2000/02/28 23:13:05 deraadt Exp $ */ 2 | 3 | /* lib/des/podd.h */ 4 | /* Copyright (C) 1995 Eric Young (eay@mincom.oz.au) 5 | * All rights reserved. 6 | * 7 | * This file is part of an SSL implementation written 8 | * by Eric Young (eay@mincom.oz.au). 9 | * The implementation was written so as to conform with Netscapes SSL 10 | * specification. This library and applications are 11 | * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE 12 | * as long as the following conditions are aheared to. 13 | * 14 | * Copyright remains Eric Young's, and as such any Copyright notices in 15 | * the code are not to be removed. If this code is used in a product, 16 | * Eric Young should be given attribution as the author of the parts used. 17 | * This can be in the form of a textual message at program startup or 18 | * in documentation (online or textual) provided with the package. 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 1. Redistributions of source code must retain the copyright 24 | * notice, this list of conditions and the following disclaimer. 25 | * 2. Redistributions in binary form must reproduce the above copyright 26 | * notice, this list of conditions and the following disclaimer in the 27 | * documentation and/or other materials provided with the distribution. 28 | * 3. All advertising materials mentioning features or use of this software 29 | * must display the following acknowledgement: 30 | * This product includes software developed by Eric Young (eay@mincom.oz.au) 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 41 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 42 | * SUCH DAMAGE. 43 | * 44 | * The licence and distribution terms for any publically available version or 45 | * derivative of this code cannot be changed. i.e. this code cannot simply be 46 | * copied and put under another distribution licence 47 | * [including the GNU Public Licence.] 48 | */ 49 | 50 | static const unsigned char odd_parity[256]={ 51 | 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 52 | 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, 53 | 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, 54 | 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, 55 | 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, 56 | 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, 57 | 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, 58 | 112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, 59 | 128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, 60 | 145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, 61 | 161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, 62 | 176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, 63 | 193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, 64 | 208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, 65 | 224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, 66 | 241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; 67 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/poly1305.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Public Domain poly1305 from Andrew Moon 3 | * 4 | * poly1305 implementation using 32 bit * 32 bit = 64 bit multiplication 5 | * and 64 bit addition from https://github.com/floodyberry/poly1305-donna 6 | */ 7 | 8 | #ifndef _POLY1305_H_ 9 | #define _POLY1305_H_ 10 | 11 | #define poly1305_block_size 16 12 | 13 | typedef struct poly1305_state { 14 | unsigned long r[5]; 15 | unsigned long h[5]; 16 | unsigned long pad[4]; 17 | size_t leftover; 18 | unsigned char buffer[poly1305_block_size]; 19 | unsigned char final; 20 | } poly1305_state; 21 | 22 | void poly1305_init(poly1305_state *, const unsigned char[32]); 23 | void poly1305_update(poly1305_state *, const unsigned char *, size_t); 24 | void poly1305_finish(poly1305_state *, unsigned char[16]); 25 | 26 | #endif /* _POLY1305_H_ */ 27 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/rijndael.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: rijndael.h,v 1.13 2008/06/09 07:49:45 djm Exp $ */ 2 | 3 | /** 4 | * rijndael-alg-fst.h 5 | * 6 | * @version 3.0 (December 2000) 7 | * 8 | * Optimised ANSI C code for the Rijndael cipher (now AES) 9 | * 10 | * @author Vincent Rijmen 11 | * @author Antoon Bosselaers 12 | * @author Paulo Barreto 13 | * 14 | * This code is hereby placed in the public domain. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 17 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #ifndef __RIJNDAEL_H 29 | #define __RIJNDAEL_H 30 | 31 | #define AES_MAXKEYBITS (256) 32 | #define AES_MAXKEYBYTES (AES_MAXKEYBITS/8) 33 | /* for 256-bit keys, fewer for less */ 34 | #define AES_MAXROUNDS 14 35 | 36 | typedef unsigned char u8; 37 | typedef unsigned short u16; 38 | typedef unsigned int u32; 39 | 40 | /* The structure for key information */ 41 | typedef struct { 42 | int enc_only; /* context contains only encrypt schedule */ 43 | int Nr; /* key-length-dependent number of rounds */ 44 | u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */ 45 | u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */ 46 | } rijndael_ctx; 47 | 48 | int rijndael_set_key(rijndael_ctx *, const u_char *, int); 49 | int rijndael_set_key_enc_only(rijndael_ctx *, const u_char *, int); 50 | void rijndael_decrypt(rijndael_ctx *, const u_char *, u_char *); 51 | void rijndael_encrypt(rijndael_ctx *, const u_char *, u_char *); 52 | 53 | int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int); 54 | int rijndaelKeySetupDec(unsigned int [], const unsigned char [], int); 55 | void rijndaelEncrypt(const unsigned int [], int, const unsigned char [], 56 | unsigned char []); 57 | 58 | #endif /* __RIJNDAEL_H */ 59 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/rmd160.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: rmd160.h,v 1.5 2009/07/05 19:33:46 millert Exp $ */ 2 | /* 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef _RMD160_H 26 | #define _RMD160_H 27 | 28 | #define RMD160_BLOCK_LENGTH 64 29 | #define RMD160_DIGEST_LENGTH 20 30 | 31 | /* RMD160 context. */ 32 | typedef struct RMD160Context { 33 | u_int32_t state[5]; /* state */ 34 | u_int64_t count; /* number of bits, mod 2^64 */ 35 | u_char buffer[RMD160_BLOCK_LENGTH]; /* input buffer */ 36 | } RMD160_CTX; 37 | 38 | //__BEGIN_DECLS 39 | void RMD160Init(RMD160_CTX *); 40 | void RMD160Transform(u_int32_t [5], const u_char [RMD160_BLOCK_LENGTH]) 41 | __attribute__((__bounded__(__minbytes__,1,5))) 42 | __attribute__((__bounded__(__minbytes__,2,RMD160_BLOCK_LENGTH))); 43 | void RMD160Update(RMD160_CTX *, const u_char *, u_int32_t) 44 | __attribute__((__bounded__(__string__,2,3))); 45 | void RMD160Final(u_char [RMD160_DIGEST_LENGTH], RMD160_CTX *) 46 | __attribute__((__bounded__(__minbytes__,1,RMD160_DIGEST_LENGTH))); 47 | //__END_DECLS 48 | 49 | #endif /* _RMD160_H */ 50 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/sha1.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: sha1.h,v 1.6 2014/11/16 17:39:09 tedu Exp $ */ 2 | 3 | /* 4 | * SHA-1 in C 5 | * By Steve Reid 6 | * 100% Public Domain 7 | */ 8 | 9 | #ifndef _SHA1_H_ 10 | #define _SHA1_H_ 11 | 12 | #define SHA1_BLOCK_LENGTH 64 13 | #define SHA1_DIGEST_LENGTH 20 14 | 15 | typedef struct { 16 | u_int32_t state[5]; 17 | u_int64_t count; 18 | unsigned char buffer[SHA1_BLOCK_LENGTH]; 19 | } SHA1_CTX; 20 | 21 | void SHA1Init(SHA1_CTX * context); 22 | void SHA1Transform(u_int32_t state[5], const unsigned char buffer[SHA1_BLOCK_LENGTH]); 23 | void SHA1Update(SHA1_CTX *context, const void *data, unsigned int len); 24 | void SHA1Final(unsigned char digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context); 25 | 26 | #endif /* _SHA1_H_ */ 27 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/crypto/sha2.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: sha2.h,v 1.5 2014/11/16 17:39:09 tedu Exp $ */ 2 | 3 | /* 4 | * FILE: sha2.h 5 | * AUTHOR: Aaron D. Gifford 6 | * 7 | * Copyright (c) 2000-2001, Aaron D. Gifford 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the copyright holder nor the names of contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ 35 | */ 36 | 37 | #ifndef _SHA2_H 38 | #define _SHA2_H 39 | 40 | 41 | /*** SHA-256/384/512 Various Length Definitions ***********************/ 42 | #define SHA256_BLOCK_LENGTH 64 43 | #define SHA256_DIGEST_LENGTH 32 44 | #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) 45 | #define SHA384_BLOCK_LENGTH 128 46 | #define SHA384_DIGEST_LENGTH 48 47 | #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) 48 | #define SHA512_BLOCK_LENGTH 128 49 | #define SHA512_DIGEST_LENGTH 64 50 | #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 51 | 52 | 53 | /*** SHA-256/384/512 Context Structure *******************************/ 54 | typedef struct _SHA2_CTX { 55 | union { 56 | u_int32_t st32[8]; 57 | u_int64_t st64[8]; 58 | } state; 59 | u_int64_t bitcount[2]; 60 | u_int8_t buffer[SHA512_BLOCK_LENGTH]; 61 | } SHA2_CTX; 62 | 63 | //__BEGIN_DECLS 64 | void SHA256Init(SHA2_CTX *); 65 | void SHA256Update(SHA2_CTX *, const void *, size_t) 66 | __attribute__((__bounded__(__string__,2,3))); 67 | void SHA256Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA2_CTX *) 68 | __attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH))); 69 | 70 | void SHA384Init(SHA2_CTX *); 71 | void SHA384Update(SHA2_CTX *, const void *, size_t) 72 | __attribute__((__bounded__(__string__,2,3))); 73 | void SHA384Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA2_CTX *) 74 | __attribute__((__bounded__(__minbytes__,1,SHA384_DIGEST_LENGTH))); 75 | 76 | void SHA512Init(SHA2_CTX *); 77 | void SHA512Update(SHA2_CTX *, const void *, size_t) 78 | __attribute__((__bounded__(__string__,2,3))); 79 | void SHA512Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA2_CTX *) 80 | __attribute__((__bounded__(__minbytes__,1,SHA512_DIGEST_LENGTH))); 81 | //__END_DECLS 82 | 83 | #endif /* _SHA2_H */ 84 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/CTimeout.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // CTimeout.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/30. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "CTimeout.hpp" 10 | 11 | void CTimeout::timeoutOccurred(OSObject* owner, IOTimerEventSource* timer) 12 | { 13 | CTimeout *tm = (CTimeout*)owner; 14 | //callback 15 | tm->to_func(tm->to_arg); 16 | } 17 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/_string.c: -------------------------------------------------------------------------------- 1 | // 2 | // _string.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/30. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef _string_c 10 | #define _string_c 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | int timingsafe_bcmp(const void *b1, const void *b2, size_t n) 17 | { 18 | const unsigned char *p1 = (const unsigned char *)b1, *p2 = (const unsigned char *)b2; 19 | int ret = 0; 20 | 21 | for (; n > 0; n--) 22 | ret |= *p1++ ^ *p2++; 23 | return (ret != 0); 24 | } 25 | 26 | 27 | 28 | 29 | #endif /* _string_c */ 30 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/ieee80211_amrr.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ieee80211_amrr.c,v 1.12 2019/02/24 09:36:28 stsp Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 5 | * Damien Bergamini 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #define is_success(amn) \ 36 | ((amn)->amn_retrycnt < (amn)->amn_txcnt / 10) 37 | #define is_failure(amn) \ 38 | ((amn)->amn_retrycnt > (amn)->amn_txcnt / 3) 39 | #define is_enough(amn) \ 40 | ((amn)->amn_txcnt > 10) 41 | #define reset_cnt(amn) \ 42 | do { (amn)->amn_txcnt = (amn)->amn_retrycnt = 0; } while (0) 43 | 44 | static inline int 45 | is_min_rate(struct ieee80211_node *ni) 46 | { 47 | return (ni->ni_txrate == 0); 48 | } 49 | 50 | static inline int 51 | is_max_rate(struct ieee80211_node *ni) 52 | { 53 | return (ni->ni_txrate == ni->ni_rates.rs_nrates - 1); 54 | } 55 | 56 | static inline void 57 | increase_rate(struct ieee80211_node *ni) 58 | { 59 | ni->ni_txrate++; 60 | } 61 | 62 | static inline void 63 | decrease_rate(struct ieee80211_node *ni) 64 | { 65 | ni->ni_txrate--; 66 | } 67 | 68 | void 69 | ieee80211_amrr_node_init(const struct ieee80211_amrr *amrr, 70 | struct ieee80211_amrr_node *amn) 71 | { 72 | amn->amn_success = 0; 73 | amn->amn_recovery = 0; 74 | amn->amn_txcnt = amn->amn_retrycnt = 0; 75 | amn->amn_success_threshold = amrr->amrr_min_success_threshold; 76 | } 77 | 78 | /* 79 | * Update ni->ni_txrate. 80 | */ 81 | void 82 | ieee80211_amrr_choose(struct ieee80211_amrr *amrr, struct ieee80211_node *ni, 83 | struct ieee80211_amrr_node *amn) 84 | { 85 | #define RV(rate) ((rate) & IEEE80211_RATE_VAL) 86 | int need_change = 0; 87 | 88 | if (is_success(amn) && is_enough(amn)) { 89 | amn->amn_success++; 90 | if (amn->amn_success >= amn->amn_success_threshold && 91 | !is_max_rate(ni)) { 92 | amn->amn_recovery = 1; 93 | amn->amn_success = 0; 94 | increase_rate(ni); 95 | DPRINTF(("increase rate=%d,#tx=%d,#retries=%d\n", 96 | RV(ni->ni_rates.rs_rates[ni->ni_txrate]), 97 | amn->amn_txcnt, amn->amn_retrycnt)); 98 | need_change = 1; 99 | } else { 100 | amn->amn_recovery = 0; 101 | } 102 | } else if (is_failure(amn)) { 103 | amn->amn_success = 0; 104 | if (!is_min_rate(ni)) { 105 | if (amn->amn_recovery) { 106 | amn->amn_success_threshold *= 2; 107 | if (amn->amn_success_threshold > 108 | amrr->amrr_max_success_threshold) 109 | amn->amn_success_threshold = 110 | amrr->amrr_max_success_threshold; 111 | } else { 112 | amn->amn_success_threshold = 113 | amrr->amrr_min_success_threshold; 114 | } 115 | decrease_rate(ni); 116 | DPRINTF(("decrease rate=%d,#tx=%d,#retries=%d\n", 117 | RV(ni->ni_rates.rs_rates[ni->ni_txrate]), 118 | amn->amn_txcnt, amn->amn_retrycnt)); 119 | need_change = 1; 120 | } 121 | amn->amn_recovery = 0; 122 | } 123 | 124 | if (is_enough(amn) || need_change) 125 | reset_cnt(amn); 126 | #undef RV 127 | } 128 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/ieee80211_amrr.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ieee80211_amrr.h,v 1.4 2007/06/16 13:17:05 damien Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 5 | * Damien Bergamini 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | #ifndef _NET80211_IEEE80211_AMRR_H_ 20 | #define _NET80211_IEEE80211_AMRR_H_ 21 | 22 | /*- 23 | * Naive implementation of the Adaptive Multi Rate Retry algorithm: 24 | * 25 | * "IEEE 802.11 Rate Adaptation: A Practical Approach" 26 | * Mathieu Lacage, Hossein Manshaei, Thierry Turletti 27 | * INRIA Sophia - Projet Planete 28 | * http://www-sop.inria.fr/rapports/sophia/RR-5208.html 29 | */ 30 | 31 | /* 32 | * Rate control settings. 33 | */ 34 | struct ieee80211_amrr { 35 | u_int amrr_min_success_threshold; 36 | u_int amrr_max_success_threshold; 37 | }; 38 | 39 | #define IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD 1 40 | #define IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD 15 41 | 42 | /* 43 | * Rate control state for a given node. 44 | */ 45 | struct ieee80211_amrr_node { 46 | u_int amn_success; 47 | u_int amn_recovery; 48 | u_int amn_success_threshold; 49 | u_int amn_txcnt; 50 | u_int amn_retrycnt; 51 | }; 52 | 53 | void ieee80211_amrr_node_init(const struct ieee80211_amrr *, 54 | struct ieee80211_amrr_node *); 55 | void ieee80211_amrr_choose(struct ieee80211_amrr *, struct ieee80211_node *, 56 | struct ieee80211_amrr_node *); 57 | 58 | #endif /* _NET80211_IEEE80211_AMRR_H_ */ 59 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/ieee80211_mira.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ieee80211_mira.h,v 1.5 2019/02/27 04:10:40 stsp Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2016 Stefan Sperling 5 | * Copyright (c) 2016 Theo Buehler 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #ifndef _NET80211_IEEE80211_MIRA_H_ 21 | #define _NET80211_IEEE80211_MIRA_H_ 22 | 23 | /* 24 | * MiRA - "MIMO Rate Adaptation in 802.11n Wireless Networks" 25 | * Ioannis Pefkianakis, Yun Hu, Starsky H.Y. Wong, Hao Yang, Songwu Lu 26 | * http://www.cs.ucla.edu/wing/publication/papers/Pefkianakis.MOBICOM10.pdf 27 | */ 28 | 29 | /* 30 | * Goodput statistics struct. Measures the effective data rate of an MCS 31 | * index and contains data related to time-based probing to a new rate. 32 | * All uint64_t numbers in this struct use fixed-point arithmetic. 33 | */ 34 | struct ieee80211_mira_goodput_stats { 35 | uint64_t measured; /* Most recently measured goodput. */ 36 | uint64_t average; /* Average measured goodput. */ 37 | uint64_t average_agg; /* Average number of subframes per frame. */ 38 | uint64_t stddeviation; /* Goodput standard deviation. */ 39 | 40 | /* These fields are used while calculating probe intervals: */ 41 | uint64_t loss; /* This rate's loss percentage SFER. */ 42 | uint32_t nprobes; /* Number of probe attempts. */ 43 | uint32_t nprobe_bytes; /* Number of bytes sent while probing. */ 44 | int probe_interval; /* Probe interval for this rate. */ 45 | int probe_timeout_triggered; /* It is time to probe this rate. */ 46 | }; 47 | 48 | /* 49 | * Rate control state. 50 | */ 51 | struct ieee80211_mira_node { 52 | /* 53 | * Fields set by drivers before calling ieee80211_mira_choose(). 54 | */ 55 | uint32_t frames; /* Increment per (sub-)frame transmitted. */ 56 | uint32_t retries; /* Increment per Tx retry (frame not ACKed). */ 57 | uint32_t txfail; /* Increment per Tx failure (also not ACKed). */ 58 | uint32_t ampdu_size; /* Length of last (aggregated) frame sent. */ 59 | uint32_t agglen; /* Number of subframes in last frame (1-64). */ 60 | 61 | /* 62 | * Private fields for use by the rate control algorithm. 63 | */ 64 | 65 | /* Bitmaps MCS 0-31. */ 66 | uint32_t valid_rates; 67 | uint32_t candidate_rates; 68 | uint32_t probed_rates; 69 | 70 | /* Timeouts which trigger time-driven probing. */ 71 | CTimeout* probe_to[2]; 72 | #define IEEE80211_MIRA_PROBE_TO_INVALID -1 73 | #define IEEE80211_MIRA_PROBE_TO_UP 0 74 | #define IEEE80211_MIRA_PROBE_TO_DOWN 1 75 | int probe_timer_expired[2]; 76 | 77 | /* Probing state. */ 78 | int probing; 79 | #define IEEE80211_MIRA_NOT_PROBING 0x0 80 | #define IEEE80211_MIRA_PROBING_DOWN 0x1 81 | #define IEEE80211_MIRA_PROBING_UP 0x2 82 | #define IEEE80211_MIRA_PROBING_INTER 0x4 /* combined with UP or DOWN */ 83 | 84 | /* The current best MCS found by probing. */ 85 | int best_mcs; 86 | 87 | /* Goodput statistics for each MCS. */ 88 | struct ieee80211_mira_goodput_stats g[IEEE80211_HT_RATESET_NUM_MCS]; 89 | 90 | /* Interference observation window (see MiRA paper section 5.2). */ 91 | int ifwnd; 92 | uint32_t ifwnd_frames; 93 | uint32_t ifwnd_retries; 94 | uint32_t ifwnd_txfail; 95 | 96 | /* Current RTS threshold for this node. */ 97 | int rts_threshold; 98 | }; 99 | 100 | /* Initialize rate control state. */ 101 | void ieee80211_mira_node_init(struct ieee80211_mira_node *); 102 | 103 | /* Called by drivers from the Tx completion interrupt handler. */ 104 | void ieee80211_mira_choose(struct ieee80211_mira_node *, 105 | struct ieee80211com *, struct ieee80211_node *); 106 | 107 | /* Cancel timeouts scheduled by ieee80211_mira_choose(). */ 108 | void ieee80211_mira_cancel_timeouts(struct ieee80211_mira_node *); 109 | 110 | /* Returns RTS threshold to be used for a frame about to be transmitted. */ 111 | int ieee80211_mira_get_rts_threshold(struct ieee80211_mira_node *, 112 | struct ieee80211com *, struct ieee80211_node *, size_t); 113 | 114 | #endif /* _NET80211_IEEE80211_MIRA_H_ */ 115 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/ieee80211_priv.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ieee80211_priv.h,v 1.5 2009/01/26 19:09:41 damien Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2008 Damien Bergamini 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef _NET80211_IEEE80211_PRIV_H_ 20 | #define _NET80211_IEEE80211_PRIV_H_ 21 | 22 | #ifdef IEEE80211_DEBUG 23 | extern int ieee80211_debug; 24 | #define DPRINTF(X) do { \ 25 | if (ieee80211_debug) { \ 26 | printf("%s: ", __func__); \ 27 | printf X; \ 28 | } \ 29 | } while(0) 30 | #else 31 | #define DPRINTF(X) 32 | #endif 33 | 34 | #define SEQ_LT(a,b) \ 35 | ((((u_int16_t)(a) - (u_int16_t)(b)) & 0xfff) > 2048) 36 | 37 | #define IEEE80211_AID_SET(b, w) \ 38 | ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32))) 39 | #define IEEE80211_AID_CLR(b, w) \ 40 | ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32))) 41 | #define IEEE80211_AID_ISSET(b, w) \ 42 | ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32))) 43 | 44 | #define IEEE80211_RSNIE_MAXLEN \ 45 | (2 + /* Version */ \ 46 | 4 + /* Group Data Cipher Suite */ \ 47 | 2 + /* Pairwise Cipher Suite Count */ \ 48 | 4 * 2 + /* Pairwise Cipher Suite List (max 2) */ \ 49 | 2 + /* AKM Suite List Count */ \ 50 | 4 * 4 + /* AKM Suite List (max 4) */ \ 51 | 2 + /* RSN Capabilities */ \ 52 | 2 + /* PMKID Count */ \ 53 | 16 * 1 + /* PMKID List (max 1) */ \ 54 | 4) /* 11w: Group Integrity Cipher Suite */ 55 | 56 | #define IEEE80211_WPAIE_MAXLEN \ 57 | (4 + /* MICROSOFT_OUI */ \ 58 | 2 + /* Version */ \ 59 | 4 + /* Group Cipher Suite */ \ 60 | 2 + /* Pairwise Cipher Suite Count */ \ 61 | 4 * 2 + /* Pairwise Cipher Suite List (max 2) */ \ 62 | 2 + /* AKM Suite List Count */ \ 63 | 4 * 2) /* AKM Suite List (max 2) */ 64 | 65 | struct ieee80211_rsnparams { 66 | u_int16_t rsn_nakms; 67 | u_int32_t rsn_akms; 68 | u_int16_t rsn_nciphers; 69 | u_int32_t rsn_ciphers; 70 | enum ieee80211_cipher rsn_groupcipher; 71 | enum ieee80211_cipher rsn_groupmgmtcipher; 72 | u_int16_t rsn_caps; 73 | u_int8_t rsn_npmkids; 74 | const u_int8_t *rsn_pmkids; 75 | }; 76 | 77 | /* unaligned big endian access */ 78 | #define BE_READ_2(p) \ 79 | ((u_int16_t) \ 80 | ((((const u_int8_t *)(p))[0] << 8) | \ 81 | (((const u_int8_t *)(p))[1]))) 82 | 83 | #define BE_READ_8(p) \ 84 | ((u_int64_t)(p)[0] << 56 | (u_int64_t)(p)[1] << 48 | \ 85 | (u_int64_t)(p)[2] << 40 | (u_int64_t)(p)[3] << 32 | \ 86 | (u_int64_t)(p)[4] << 24 | (u_int64_t)(p)[5] << 16 | \ 87 | (u_int64_t)(p)[6] << 8 | (u_int64_t)(p)[7]) 88 | 89 | #define BE_WRITE_2(p, v) do { \ 90 | ((u_int8_t *)(p))[0] = (v) >> 8; \ 91 | ((u_int8_t *)(p))[1] = (v) & 0xff; \ 92 | } while (0) 93 | 94 | #define BE_WRITE_8(p, v) do { \ 95 | (p)[0] = (v) >> 56; (p)[1] = (v) >> 48; \ 96 | (p)[2] = (v) >> 40; (p)[3] = (v) >> 32; \ 97 | (p)[4] = (v) >> 24; (p)[5] = (v) >> 16; \ 98 | (p)[6] = (v) >> 8; (p)[7] = (v); \ 99 | } while (0) 100 | 101 | /* unaligned little endian access */ 102 | #define LE_READ_2(p) \ 103 | ((u_int16_t) \ 104 | ((((const u_int8_t *)(p))[0]) | \ 105 | (((const u_int8_t *)(p))[1] << 8))) 106 | 107 | #define LE_READ_4(p) \ 108 | ((u_int32_t) \ 109 | ((((const u_int8_t *)(p))[0]) | \ 110 | (((const u_int8_t *)(p))[1] << 8) | \ 111 | (((const u_int8_t *)(p))[2] << 16) | \ 112 | (((const u_int8_t *)(p))[3] << 24))) 113 | 114 | #define LE_READ_6(p) \ 115 | ((u_int64_t)(p)[5] << 40 | (u_int64_t)(p)[4] << 32 | \ 116 | (u_int64_t)(p)[3] << 24 | (u_int64_t)(p)[2] << 16 | \ 117 | (u_int64_t)(p)[1] << 8 | (u_int64_t)(p)[0]) 118 | 119 | #define LE_WRITE_2(p, v) do { \ 120 | ((u_int8_t *)(p))[0] = (v) & 0xff; \ 121 | ((u_int8_t *)(p))[1] = (v) >> 8; \ 122 | } while (0) 123 | 124 | #define LE_WRITE_4(p, v) do { \ 125 | (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \ 126 | (p)[1] = (v) >> 8; (p)[0] = (v); \ 127 | } while (0) 128 | 129 | #define LE_WRITE_6(p, v) do { \ 130 | (p)[5] = (v) >> 40; (p)[4] = (v) >> 32; \ 131 | (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \ 132 | (p)[1] = (v) >> 8; (p)[0] = (v); \ 133 | } while (0) 134 | 135 | #endif /* _NET80211_IEEE80211_PRIV_H_ */ 136 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/ieee80211_rssadapt.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ieee80211_rssadapt.h,v 1.5 2010/07/17 16:25:09 damien Exp $ */ 2 | /* $NetBSD: ieee80211_rssadapt.h,v 1.3 2004/05/06 03:03:20 dyoung Exp $ */ 3 | 4 | /*- 5 | * Copyright (c) 2003, 2004 David Young. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or 8 | * without modification, are permitted provided that the following 9 | * conditions are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following 14 | * disclaimer in the documentation and/or other materials provided 15 | * with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David 21 | * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 28 | * OF SUCH DAMAGE. 29 | */ 30 | #ifndef _NET80211_IEEE80211_RSSADAPT_H_ 31 | #define _NET80211_IEEE80211_RSSADAPT_H_ 32 | 33 | /* Data-rate adaptation loosely based on "Link Adaptation Strategy 34 | * for IEEE 802.11 WLAN via Received Signal Strength Measurement" 35 | * by Javier del Prado Pavon and Sunghyun Choi. 36 | */ 37 | 38 | /* Buckets for frames 0-128 bytes long, 129-1024, 1025-maximum. */ 39 | #define IEEE80211_RSSADAPT_BKTS 3 40 | #define IEEE80211_RSSADAPT_BKT0 128 41 | #define IEEE80211_RSSADAPT_BKTPOWER 3 /* 2**_BKTPOWER */ 42 | 43 | #define ieee80211_rssadapt_thresh_new \ 44 | (ieee80211_rssadapt_thresh_denom - ieee80211_rssadapt_thresh_old) 45 | #define ieee80211_rssadapt_decay_new \ 46 | (ieee80211_rssadapt_decay_denom - ieee80211_rssadapt_decay_old) 47 | #define ieee80211_rssadapt_avgrssi_new \ 48 | (ieee80211_rssadapt_avgrssi_denom - ieee80211_rssadapt_avgrssi_old) 49 | 50 | struct ieee80211_rssadapt_expavgctl { 51 | /* RSS threshold decay. */ 52 | u_int rc_decay_denom; 53 | u_int rc_decay_old; 54 | /* RSS threshold update. */ 55 | u_int rc_thresh_denom; 56 | u_int rc_thresh_old; 57 | /* RSS average update. */ 58 | u_int rc_avgrssi_denom; 59 | u_int rc_avgrssi_old; 60 | }; 61 | 62 | struct ieee80211_rssadapt { 63 | /* exponential average RSSI << 8 */ 64 | u_int16_t ra_avg_rssi; 65 | /* Tx failures in this update interval */ 66 | u_int32_t ra_nfail; 67 | /* Tx successes in this update interval */ 68 | u_int32_t ra_nok; 69 | /* exponential average packets/second */ 70 | u_int32_t ra_pktrate; 71 | /* RSSI threshold for each Tx rate */ 72 | u_int16_t ra_rate_thresh[IEEE80211_RSSADAPT_BKTS] 73 | [IEEE80211_RATE_SIZE]; 74 | struct timeval ra_last_raise; 75 | struct timeval ra_raise_interval; 76 | }; 77 | 78 | /* Properties of a Tx packet, for link adaptation. */ 79 | struct ieee80211_rssdesc { 80 | u_int id_len; /* Tx packet length */ 81 | u_int id_rateidx; /* index into ni->ni_rates */ 82 | struct ieee80211_node *id_node; /* destination STA MAC */ 83 | u_int8_t id_rssi; /* destination STA avg RSS @ 84 | * Tx time 85 | */ 86 | }; 87 | 88 | void ieee80211_rssadapt_updatestats(struct ieee80211_rssadapt *); 89 | void ieee80211_rssadapt_input(struct ieee80211com *, 90 | const struct ieee80211_node *, struct ieee80211_rssadapt *, int); 91 | void ieee80211_rssadapt_lower_rate(struct ieee80211com *, 92 | const struct ieee80211_node *, struct ieee80211_rssadapt *, 93 | const struct ieee80211_rssdesc *); 94 | void ieee80211_rssadapt_raise_rate(struct ieee80211com *, 95 | struct ieee80211_rssadapt *, const struct ieee80211_rssdesc *); 96 | int ieee80211_rssadapt_choose(struct ieee80211_rssadapt *, 97 | const struct ieee80211_rateset *, const struct ieee80211_frame *, 98 | u_int, int, const char *, int); 99 | #ifdef IEEE80211_DEBUG 100 | extern int ieee80211_rssadapt_debug; 101 | #endif /* IEEE80211_DEBUG */ 102 | 103 | #endif /* _NET80211_IEEE80211_RSSADAPT_H_ */ 104 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/net80211/timeout.c: -------------------------------------------------------------------------------- 1 | // 2 | // timeout.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/30. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef timeout_cpp 10 | #define timeout_cpp 11 | 12 | #include 13 | 14 | static IOWorkLoop *_fWorkloop = NULL; 15 | 16 | void initTimeout(IOWorkLoop *workloop) 17 | { 18 | _fWorkloop = workloop; 19 | } 20 | 21 | void releaseTimeout() 22 | { 23 | _fWorkloop = NULL; 24 | } 25 | 26 | int splnet() 27 | { 28 | // _fWorkloop->disableAllInterrupts(); 29 | // _fWorkloop->disableAllEventSources(); 30 | return 1; 31 | } 32 | 33 | void splx(int s) 34 | { 35 | // _fWorkloop->enableAllInterrupts(); 36 | // _fWorkloop->enableAllEventSources(); 37 | } 38 | 39 | void timeout_set(CTimeout **t, void (*fn)(void *), void *arg) 40 | { 41 | if (*t == NULL) { 42 | *t = new CTimeout(); 43 | } 44 | ((CTimeout*)*t)->to_func = fn; 45 | ((CTimeout*)*t)->to_arg = arg; 46 | } 47 | 48 | int timeout_add_msec(CTimeout **to, int msecs) 49 | { 50 | if (*to == NULL) { 51 | *to = new CTimeout(); 52 | } 53 | if (((CTimeout*)*to)->tm) { 54 | _fWorkloop->removeEventSource(((CTimeout*)*to)->tm); 55 | OSSafeReleaseNULL(((CTimeout*)*to)->tm); 56 | } 57 | ((CTimeout*)*to)->tm = IOTimerEventSource::timerEventSource(((CTimeout*)*to), OSMemberFunctionCast(IOTimerEventSource::Action, ((CTimeout*)*to), &CTimeout::timeoutOccurred)); 58 | if (((CTimeout*)*to)->tm == 0) 59 | return 0; 60 | _fWorkloop->addEventSource(((CTimeout*)*to)->tm); 61 | ((CTimeout*)*to)->tm->enable(); 62 | ((CTimeout*)*to)->tm->setTimeoutMS(msecs); 63 | return 1; 64 | } 65 | 66 | int timeout_add_sec(CTimeout **to, int secs) 67 | { 68 | return timeout_add_msec(to, secs * 1000); 69 | } 70 | 71 | int timeout_add_usec(CTimeout **to, int usecs) 72 | { 73 | return timeout_add_msec(to, (int) usecs / 1000); 74 | } 75 | 76 | int timeout_del(CTimeout **to) 77 | { 78 | IOLog("timeout_del\n"); 79 | if (!((CTimeout*)*to)) { 80 | IOLog("timeout_del timeout NULL\n"); 81 | return 0; 82 | } 83 | if (((CTimeout*)*to)->tm) { 84 | ((CTimeout*)*to)->tm->cancelTimeout(); 85 | if (_fWorkloop) { 86 | _fWorkloop->removeEventSource(((CTimeout*)*to)->tm); 87 | } 88 | OSSafeReleaseNULL(((CTimeout*)*to)->tm); 89 | } 90 | OSSafeReleaseNULL(*to); 91 | return 1; 92 | } 93 | 94 | int timeout_pending(CTimeout **to) 95 | { 96 | if (!((CTimeout*)*to) || !((CTimeout*)*to)->tm || !((CTimeout*)*to)->tm->isEnabled()) { 97 | return 0; 98 | } 99 | return 1; 100 | } 101 | 102 | #endif /* timeout_cpp */ 103 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/sys/CTimeout.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // CTimeout.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/30. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef CTimeout_h 10 | #define CTimeout_h 11 | 12 | #include 13 | #include 14 | 15 | 16 | class CTimeout : public OSObject { 17 | OSDeclareDefaultStructors(CTimeout) 18 | 19 | public: 20 | void timeoutOccurred(OSObject* owner, IOTimerEventSource* timer); 21 | 22 | public: 23 | IOTimerEventSource* tm; 24 | void (*to_func)(void *); /* function to call */ 25 | void *to_arg; /* function argument */ 26 | }; 27 | 28 | #endif /* CTimeout_h */ 29 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/sys/_arc4random.h: -------------------------------------------------------------------------------- 1 | // 2 | // _arc4random.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/22. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef _arc4random_h 10 | #define _arc4random_h 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | /* Add platform entropy 32 bytes (256 bits) at a time. */ 20 | #define ADD_ENTROPY 32 21 | 22 | /* Re-seed from the platform RNG after generating this many bytes. */ 23 | #define BYTES_BEFORE_RESEED 1600000 24 | 25 | static inline u_int32_t arc4random() 26 | { 27 | u_int32_t r; 28 | read_random(&r, sizeof(r)); 29 | return r; 30 | } 31 | 32 | static inline void arc4random_buf(void *buf, size_t n) 33 | { 34 | read_random(buf, (u_int)n); 35 | } 36 | 37 | static inline u_int32_t arc4random_uniform(u_int32_t upper_bound) 38 | { 39 | u_int32_t r, min; 40 | 41 | if (upper_bound < 2) 42 | return 0; 43 | 44 | /* 2**32 % x == (2**32 - x) % x */ 45 | min = -upper_bound % upper_bound; 46 | 47 | /* 48 | * This could theoretically loop forever but each retry has 49 | * p > 0.5 (worst case, usually far better) of selecting a 50 | * number inside the range we need, so it should rarely need 51 | * to re-roll. 52 | */ 53 | for (;;) { 54 | r = arc4random(); 55 | if (r >= min) 56 | break; 57 | } 58 | 59 | return r % upper_bound; 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/sys/_buf.h: -------------------------------------------------------------------------------- 1 | // 2 | // _buf.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/25. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef _buf_h 10 | #define _buf_h 11 | 12 | /* Macros to clear/set/test flags. */ 13 | #define SET(t, f) (t) |= (f) 14 | #define CLR(t, f) (t) &= ~(f) 15 | #define ISSET(t, f) ((t) & (f)) 16 | 17 | #endif /* _buf_h */ 18 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/sys/_null.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: _null.h,v 1.2 2016/09/09 22:07:58 millert Exp $ */ 2 | 3 | /* 4 | * Written by Todd C. Miller, September 9, 2016 5 | * Public domain. 6 | */ 7 | 8 | #ifndef NULL 9 | #if !defined(__cplusplus) 10 | #define NULL ((void *)0) 11 | #elif __cplusplus >= 201103L 12 | #define NULL nullptr 13 | #elif defined(__GNUG__) 14 | #define NULL __null 15 | #else 16 | #define NULL 0L 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/compat/openbsd/sys/timeout.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: timeout.h,v 1.29 2019/07/12 00:04:59 cheloha Exp $ */ 2 | /* 3 | * Copyright (c) 2000-2001 Artur Grabowski 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. The name of the author may not be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 17 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 18 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _SYS_TIMEOUT_H_ 28 | #define _SYS_TIMEOUT_H_ 29 | 30 | 31 | #include 32 | #include 33 | #include /* _Q_INVALIDATE */ 34 | #include 35 | #include 36 | #include 37 | 38 | #define _KERNEL 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | void initTimeout(IOWorkLoop *workloop); 46 | void releaseTimeout(); 47 | int splnet(); 48 | void splx(int s); 49 | void timeout_set(CTimeout **t, void (*fn)(void *), void *arg); 50 | int timeout_add_msec(CTimeout **to, int msecs); 51 | int timeout_add_sec(CTimeout **to, int secs); 52 | int timeout_add_usec(CTimeout **to, int usecs); 53 | int timeout_del(CTimeout **to); 54 | int timeout_pending(CTimeout **to); 55 | 56 | #endif /* _SYS_TIMEOUT_H_ */ 57 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-3160-17.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-3160-17.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-3168-29.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-3168-29.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-7260-17.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-7260-17.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-7265-17.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-7265-17.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-7265D-27.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-7265D-27.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-8000C-36.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-8000C-36.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-8265-34.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-8265-34.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-8265-36.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-8265-36.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-9000-pu-b0-jf-b0-46.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-9000-pu-b0-jf-b0-46.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-9260-th-b0-jf-b0-46.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-9260-th-b0-jf-b0-46.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-Qu-b0-hr-b0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-Qu-b0-hr-b0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-Qu-b0-jf-b0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-Qu-b0-jf-b0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-Qu-c0-hr-b0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-Qu-c0-hr-b0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-Qu-c0-jf-b0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-Qu-c0-jf-b0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-QuZ-a0-hr-b0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-QuZ-a0-hr-b0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-QuZ-a0-jf-b0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-QuZ-a0-jf-b0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/firmware/iwlwifi-cc-a0-48.ucode: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/AppleIntelWifiAdapter/firmware/iwlwifi-cc-a0-48.ucode -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/IWLUcodeParse.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLUcodeParse.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLUcodeParse_hpp 10 | #define IWLUcodeParse_hpp 11 | 12 | #include 13 | 14 | #include "FWFile.h" 15 | #include "FWImg.h" 16 | #include "IWLDevice.hpp" 17 | 18 | class IWLUcodeParse { 19 | 20 | public: 21 | 22 | IWLUcodeParse(IWLDevice *drv); 23 | ~IWLUcodeParse(); 24 | 25 | bool parseFW(const void *raw, size_t len, struct iwl_fw *fw, struct iwl_firmware_pieces *pieces); 26 | 27 | bool parseV1V2Firmware(const void *raw, size_t len, struct iwl_fw *fw, struct iwl_firmware_pieces *pieces); 28 | 29 | bool parseTLVFirmware(const void *raw, size_t len, struct iwl_fw *fw, struct iwl_firmware_pieces *pieces); 30 | 31 | /* 32 | * These functions are just to extract uCode section data from the pieces 33 | * structure. 34 | */ 35 | struct fw_sec *getSec(struct iwl_firmware_pieces *pieces, enum iwl_ucode_type type, int sec); 36 | 37 | void alloccSecData(struct iwl_firmware_pieces *pieces, enum iwl_ucode_type type, int sec); 38 | 39 | void setSecSize(struct iwl_firmware_pieces *pieces, enum iwl_ucode_type type, int sec, size_t size); 40 | 41 | void setSecOffset(iwl_firmware_pieces *pieces, enum iwl_ucode_type type, int sec, u32 offset); 42 | 43 | size_t getSecSize(struct iwl_firmware_pieces *pieces, enum iwl_ucode_type type, int sec); 44 | 45 | void setSecData(struct iwl_firmware_pieces *pieces, enum iwl_ucode_type type, int sec, const void *data); 46 | 47 | int storeUcodeSec(struct iwl_firmware_pieces *pieces, const void *data, enum iwl_ucode_type type, int size); 48 | 49 | void setUcodeApiFlags(const u8 *data, struct iwl_ucode_capabilities *capa); 50 | 51 | void setUcodeCapabilities(const u8 *data, struct iwl_ucode_capabilities *capa); 52 | 53 | int setDefaultCalib(const u8 *data); 54 | 55 | int storeCscheme(struct iwl_fw *fw, const u8 *data, const u32 len); 56 | 57 | const char *reducedFWName(const char *name); 58 | 59 | int allocUcode(struct iwl_firmware_pieces *pieces, enum iwl_ucode_type type); 60 | 61 | int allocFWDesc(struct fw_desc *desc, struct fw_sec *sec); 62 | 63 | void freeFWDesc(struct fw_desc *desc); 64 | 65 | void freeFWImg(struct fw_img *img); 66 | 67 | void deAllocUcode(); 68 | 69 | private: 70 | 71 | IWLDevice *drv; 72 | }; 73 | 74 | #endif /* IWLUcodeParse_hpp */ 75 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/NotificationWait.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NotificationWait.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/8. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "NotificationWait.hpp" 10 | #include 11 | 12 | void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_wait) 13 | { 14 | notif_wait->notif_wait_lock = IOSimpleLockAlloc(); 15 | STAILQ_INIT(¬if_wait->notif_waits); 16 | notif_wait->notif_waitq = IOLockAlloc(); 17 | } 18 | 19 | bool iwl_notification_wait(struct iwl_notif_wait_data *notif_wait, struct iwl_rx_packet *pkt) 20 | { 21 | bool triggered = false; 22 | 23 | if (!STAILQ_EMPTY(¬if_wait->notif_waits)) { 24 | struct iwl_notification_wait *w; 25 | 26 | //IOSimpleLockLock(notif_wait->notif_wait_lock); 27 | STAILQ_FOREACH(w, ¬if_wait->notif_waits, list) { 28 | int i; 29 | bool found = false; 30 | 31 | /* 32 | * If it already finished (triggered) or has been 33 | * aborted then don't evaluate it again to avoid races, 34 | * Otherwise the function could be called again even 35 | * though it returned true before 36 | */ 37 | if (w->triggered || w->aborted) 38 | continue; 39 | 40 | for (i = 0; i < w->n_cmds; i++) { 41 | u16 rec_id = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); 42 | 43 | if (w->cmds[i] == rec_id || (!iwl_cmd_groupid(w->cmds[i]) && DEF_ID(w->cmds[i]) == rec_id)) { 44 | found = true; 45 | break; 46 | } 47 | } 48 | if (!found) 49 | continue; 50 | 51 | if (!w->fn || w->fn(notif_wait, pkt, w->fn_data)) { 52 | w->triggered = true; 53 | triggered = true; 54 | } 55 | } 56 | //IOSimpleLockUnlock(notif_wait->notif_wait_lock); 57 | } 58 | 59 | return triggered; 60 | } 61 | 62 | void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_wait) 63 | { 64 | struct iwl_notification_wait *wait_entry; 65 | 66 | //IOSimpleLockLock(notif_wait->notif_wait_lock); 67 | STAILQ_FOREACH(wait_entry, ¬if_wait->notif_waits, list) 68 | wait_entry->aborted = true; 69 | //IOSimpleLockUnlock(notif_wait->notif_wait_lock); 70 | 71 | // TODO: Implement 72 | //wake_up_all(¬if_wait->notif_waitq); 73 | IOLockLock(notif_wait->notif_waitq); 74 | STAILQ_FOREACH(wait_entry, ¬if_wait->notif_waits, list) 75 | IOLockWakeup(notif_wait->notif_waitq, wait_entry, true); 76 | IOLockUnlock(notif_wait->notif_waitq); 77 | } 78 | 79 | void 80 | iwl_init_notification_wait(struct iwl_notif_wait_data *notif_wait, struct iwl_notification_wait *wait_entry, 81 | const u16 *cmds, int n_cmds, 82 | bool (*fn)(struct iwl_notif_wait_data *notif_wait, struct iwl_rx_packet *pkt, void *data), 83 | void *fn_data) 84 | { 85 | if (WARN_ON(n_cmds > MAX_NOTIF_CMDS)) 86 | n_cmds = MAX_NOTIF_CMDS; 87 | 88 | wait_entry->fn = fn; 89 | wait_entry->fn_data = fn_data; 90 | wait_entry->n_cmds = n_cmds; 91 | memcpy(wait_entry->cmds, cmds, n_cmds * sizeof(u16)); 92 | wait_entry->triggered = false; 93 | wait_entry->aborted = false; 94 | 95 | //IOSimpleLockLock(notif_wait->notif_wait_lock); 96 | STAILQ_INSERT_HEAD(¬if_wait->notif_waits, wait_entry, list); 97 | //IOSimpleLockUnlock(notif_wait->notif_wait_lock); 98 | } 99 | 100 | void iwl_remove_notification(struct iwl_notif_wait_data *notif_wait, 101 | struct iwl_notification_wait *wait_entry) 102 | { 103 | //IOSimpleLockLock(notif_wait->notif_wait_lock); 104 | STAILQ_REMOVE_HEAD(¬if_wait->notif_waits, list); 105 | //IOSimpleLockUnlock(notif_wait->notif_wait_lock); 106 | } 107 | 108 | int iwl_wait_notification(struct iwl_notif_wait_data *notif_wait, struct iwl_notification_wait *wait_entry, 109 | unsigned long timeout) 110 | { 111 | int ret = 0; 112 | 113 | IOLockLock(notif_wait->notif_waitq); 114 | AbsoluteTime deadline; 115 | clock_interval_to_deadline((u32)timeout, kMillisecondScale, (UInt64 *) &deadline); 116 | 117 | ret = IOLockSleepDeadline(notif_wait->notif_waitq, wait_entry, deadline, THREAD_INTERRUPTIBLE); 118 | iwl_remove_notification(notif_wait, wait_entry); 119 | IOLockUnlock(notif_wait->notif_waitq); 120 | 121 | if (wait_entry->aborted) 122 | return -EIO; 123 | 124 | /* return value is always >= 0 */ 125 | if (ret != THREAD_AWAKENED) 126 | return -ETIMEDOUT; 127 | return 0; 128 | } 129 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/NotificationWait.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // NotificationWait.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/8. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef NotificationWait_hpp 10 | #define NotificationWait_hpp 11 | 12 | #include "../trans/TransHdr.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define MAX_NOTIF_CMDS 5 20 | 21 | /** 22 | * struct iwl_notification_wait - notification wait entry 23 | * @list: list head for global list 24 | * @fn: Function called with the notification. If the function 25 | * returns true, the wait is over, if it returns false then 26 | * the waiter stays blocked. If no function is given, any 27 | * of the listed commands will unblock the waiter. 28 | * @cmds: command IDs 29 | * @n_cmds: number of command IDs 30 | * @triggered: waiter should be woken up 31 | * @aborted: wait was aborted 32 | * 33 | * This structure is not used directly, to wait for a 34 | * notification declare it on the stack, and call 35 | * iwl_init_notification_wait() with appropriate 36 | * parameters. Then do whatever will cause the ucode 37 | * to notify the driver, and to wait for that then 38 | * call iwl_wait_notification(). 39 | * 40 | * Each notification is one-shot. If at some point we 41 | * need to support multi-shot notifications (which 42 | * can't be allocated on the stack) we need to modify 43 | * the code for them. 44 | */ 45 | struct iwl_notification_wait { 46 | STAILQ_ENTRY(iwl_notification_wait) list; 47 | 48 | bool (*fn)(struct iwl_notif_wait_data *notif_data, 49 | struct iwl_rx_packet *pkt, void *data); 50 | void *fn_data; 51 | 52 | u16 cmds[MAX_NOTIF_CMDS]; 53 | u8 n_cmds; 54 | bool triggered, aborted; 55 | }; 56 | 57 | struct iwl_notif_wait_data { 58 | STAILQ_HEAD(, iwl_notification_wait) notif_waits; 59 | IOSimpleLock *notif_wait_lock; 60 | IOLock *notif_waitq; 61 | }; 62 | 63 | /* caller functions */ 64 | void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_data); 65 | bool iwl_notification_wait(struct iwl_notif_wait_data *notif_data, struct iwl_rx_packet *pkt); 66 | void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_data); 67 | 68 | static inline void 69 | iwl_notification_notify(struct iwl_notif_wait_data *notif_data) 70 | { 71 | struct iwl_notification_wait *wait_entry; 72 | IOLockLock(notif_data->notif_waitq); 73 | STAILQ_FOREACH(wait_entry, ¬if_data->notif_waits, list) 74 | IOLockWakeup(notif_data->notif_waitq, wait_entry, true); 75 | IOLockUnlock(notif_data->notif_waitq); 76 | } 77 | 78 | static inline void 79 | iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_data, 80 | struct iwl_rx_packet *pkt) 81 | { 82 | if (iwl_notification_wait(notif_data, pkt)) { 83 | iwl_notification_notify(notif_data); 84 | } 85 | 86 | } 87 | 88 | /* user functions */ 89 | void __acquires(wait_entry) 90 | iwl_init_notification_wait(struct iwl_notif_wait_data *notif_data, struct iwl_notification_wait *wait_entry, 91 | const u16 *cmds, int n_cmds, 92 | bool (*fn)(struct iwl_notif_wait_data *notif_data, struct iwl_rx_packet *pkt, void *data), 93 | void *fn_data); 94 | 95 | int __must_check __releases(wait_entry) 96 | iwl_wait_notification(struct iwl_notif_wait_data *notif_data, struct iwl_notification_wait *wait_entry, 97 | unsigned long timeout); 98 | 99 | void __releases(wait_entry) 100 | iwl_remove_notification(struct iwl_notif_wait_data *notif_data, struct iwl_notification_wait *wait_entry); 101 | 102 | #endif /* NotificationWait_hpp */ 103 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/api/context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file is provided under a dual BSD/GPLv2 license. When using or 4 | * redistributing this file, you may do so under either license. 5 | * 6 | * GPL LICENSE SUMMARY 7 | * 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of version 2 of the GNU General Public License as 14 | * published by the Free Software Foundation. 15 | * 16 | * This program is distributed in the hope that it will be useful, but 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * General Public License for more details. 20 | * 21 | * The full GNU General Public License is included in this distribution 22 | * in the file called COPYING. 23 | * 24 | * Contact Information: 25 | * Intel Linux Wireless 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 | * 28 | * BSD LICENSE 29 | * 30 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 | * All rights reserved. 34 | * 35 | * Redistribution and use in source and binary forms, with or without 36 | * modification, are permitted provided that the following conditions 37 | * are met: 38 | * 39 | * * Redistributions of source code must retain the above copyright 40 | * notice, this list of conditions and the following disclaimer. 41 | * * Redistributions in binary form must reproduce the above copyright 42 | * notice, this list of conditions and the following disclaimer in 43 | * the documentation and/or other materials provided with the 44 | * distribution. 45 | * * Neither the name Intel Corporation nor the names of its 46 | * contributors may be used to endorse or promote products derived 47 | * from this software without specific prior written permission. 48 | * 49 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 50 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 51 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 52 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 53 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 54 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 55 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 56 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 57 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 58 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 | * 61 | *****************************************************************************/ 62 | 63 | #ifndef __iwl_fw_api_context_h__ 64 | #define __iwl_fw_api_context_h__ 65 | 66 | /** 67 | * enum iwl_ctxt_id_and_color - ID and color fields in context dword 68 | * @FW_CTXT_ID_POS: position of the ID 69 | * @FW_CTXT_ID_MSK: mask of the ID 70 | * @FW_CTXT_COLOR_POS: position of the color 71 | * @FW_CTXT_COLOR_MSK: mask of the color 72 | * @FW_CTXT_INVALID: value used to indicate unused/invalid 73 | */ 74 | enum iwl_ctxt_id_and_color { 75 | FW_CTXT_ID_POS = 0, 76 | FW_CTXT_ID_MSK = 0xff << FW_CTXT_ID_POS, 77 | FW_CTXT_COLOR_POS = 8, 78 | FW_CTXT_COLOR_MSK = 0xff << FW_CTXT_COLOR_POS, 79 | FW_CTXT_INVALID = 0xffffffff, 80 | }; 81 | 82 | #define FW_CMD_ID_AND_COLOR(_id, _color) (((_id) << FW_CTXT_ID_POS) |\ 83 | ((_color) << FW_CTXT_COLOR_POS)) 84 | 85 | /* Possible actions on PHYs, MACs and Bindings */ 86 | enum iwl_ctxt_action { 87 | FW_CTXT_ACTION_STUB = 0, 88 | FW_CTXT_ACTION_ADD, 89 | FW_CTXT_ACTION_MODIFY, 90 | FW_CTXT_ACTION_REMOVE, 91 | FW_CTXT_ACTION_NUM 92 | }; /* COMMON_CONTEXT_ACTION_API_E_VER_1 */ 93 | 94 | #endif /* __iwl_fw_api_context_h__ */ 95 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/api/led.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file is provided under a dual BSD/GPLv2 license. When using or 4 | * redistributing this file, you may do so under either license. 5 | * 6 | * GPL LICENSE SUMMARY 7 | * 8 | * Copyright(c) 2017 Intel Deutschland GmbH 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of version 2 of the GNU General Public License as 12 | * published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * General Public License for more details. 18 | * 19 | * The full GNU General Public License is included in this distribution 20 | * in the file called COPYING. 21 | * 22 | * Contact Information: 23 | * Intel Linux Wireless 24 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 | * 26 | * BSD LICENSE 27 | * 28 | * Copyright(c) 2017 Intel Deutschland GmbH 29 | * All rights reserved. 30 | * 31 | * Redistribution and use in source and binary forms, with or without 32 | * modification, are permitted provided that the following conditions 33 | * are met: 34 | * 35 | * * Redistributions of source code must retain the above copyright 36 | * notice, this list of conditions and the following disclaimer. 37 | * * Redistributions in binary form must reproduce the above copyright 38 | * notice, this list of conditions and the following disclaimer in 39 | * the documentation and/or other materials provided with the 40 | * distribution. 41 | * * Neither the name Intel Corporation nor the names of its 42 | * contributors may be used to endorse or promote products derived 43 | * from this software without specific prior written permission. 44 | * 45 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 46 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 47 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 48 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 49 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 51 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 52 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 53 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 54 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 55 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 | * 57 | *****************************************************************************/ 58 | 59 | #ifndef __iwl_fw_api_led_h__ 60 | #define __iwl_fw_api_led_h__ 61 | 62 | /** 63 | * struct iwl_led_cmd - LED switching command 64 | * 65 | * @status: LED status (on/off) 66 | */ 67 | struct iwl_led_cmd { 68 | __le32 status; 69 | } __packed; /* LEDS_CMD_API_S_VER_2 */ 70 | 71 | #endif /* __iwl_fw_api_led_h__ */ 72 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/api/offload.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file is provided under a dual BSD/GPLv2 license. When using or 4 | * redistributing this file, you may do so under either license. 5 | * 6 | * GPL LICENSE SUMMARY 7 | * 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of version 2 of the GNU General Public License as 14 | * published by the Free Software Foundation. 15 | * 16 | * This program is distributed in the hope that it will be useful, but 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * General Public License for more details. 20 | * 21 | * The full GNU General Public License is included in this distribution 22 | * in the file called COPYING. 23 | * 24 | * Contact Information: 25 | * Intel Linux Wireless 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 | * 28 | * BSD LICENSE 29 | * 30 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 31 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 | * All rights reserved. 34 | * 35 | * Redistribution and use in source and binary forms, with or without 36 | * modification, are permitted provided that the following conditions 37 | * are met: 38 | * 39 | * * Redistributions of source code must retain the above copyright 40 | * notice, this list of conditions and the following disclaimer. 41 | * * Redistributions in binary form must reproduce the above copyright 42 | * notice, this list of conditions and the following disclaimer in 43 | * the documentation and/or other materials provided with the 44 | * distribution. 45 | * * Neither the name Intel Corporation nor the names of its 46 | * contributors may be used to endorse or promote products derived 47 | * from this software without specific prior written permission. 48 | * 49 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 50 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 51 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 52 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 53 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 54 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 55 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 56 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 57 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 58 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 | * 61 | *****************************************************************************/ 62 | 63 | #ifndef __iwl_fw_api_offload_h__ 64 | #define __iwl_fw_api_offload_h__ 65 | 66 | /** 67 | * enum iwl_prot_offload_subcmd_ids - protocol offload commands 68 | */ 69 | enum iwl_prot_offload_subcmd_ids { 70 | /** 71 | * @STORED_BEACON_NTF: &struct iwl_stored_beacon_notif 72 | */ 73 | STORED_BEACON_NTF = 0xFF, 74 | }; 75 | 76 | #define MAX_STORED_BEACON_SIZE 600 77 | 78 | /** 79 | * struct iwl_stored_beacon_notif - Stored beacon notification 80 | * 81 | * @system_time: system time on air rise 82 | * @tsf: TSF on air rise 83 | * @beacon_timestamp: beacon on air rise 84 | * @band: band, matches &RX_RES_PHY_FLAGS_BAND_24 definition 85 | * @channel: channel this beacon was received on 86 | * @rates: rate in ucode internal format 87 | * @byte_count: frame's byte count 88 | * @data: beacon data, length in @byte_count 89 | */ 90 | struct iwl_stored_beacon_notif { 91 | __le32 system_time; 92 | __le64 tsf; 93 | __le32 beacon_timestamp; 94 | __le16 band; 95 | __le16 channel; 96 | __le32 rates; 97 | __le32 byte_count; 98 | u8 data[MAX_STORED_BEACON_SIZE]; 99 | } __packed; /* WOWLAN_STROED_BEACON_INFO_S_VER_2 */ 100 | 101 | #endif /* __iwl_fw_api_offload_h__ */ 102 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/api/paging.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file is provided under a dual BSD/GPLv2 license. When using or 4 | * redistributing this file, you may do so under either license. 5 | * 6 | * GPL LICENSE SUMMARY 7 | * 8 | * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of version 2 of the GNU General Public License as 14 | * published by the Free Software Foundation. 15 | * 16 | * This program is distributed in the hope that it will be useful, but 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * General Public License for more details. 20 | * 21 | * The full GNU General Public License is included in this distribution 22 | * in the file called COPYING. 23 | * 24 | * Contact Information: 25 | * Intel Linux Wireless 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 | * 28 | * BSD LICENSE 29 | * 30 | * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. 31 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 32 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 33 | * All rights reserved. 34 | * 35 | * Redistribution and use in source and binary forms, with or without 36 | * modification, are permitted provided that the following conditions 37 | * are met: 38 | * 39 | * * Redistributions of source code must retain the above copyright 40 | * notice, this list of conditions and the following disclaimer. 41 | * * Redistributions in binary form must reproduce the above copyright 42 | * notice, this list of conditions and the following disclaimer in 43 | * the documentation and/or other materials provided with the 44 | * distribution. 45 | * * Neither the name Intel Corporation nor the names of its 46 | * contributors may be used to endorse or promote products derived 47 | * from this software without specific prior written permission. 48 | * 49 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 50 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 51 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 52 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 53 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 54 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 55 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 56 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 57 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 58 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 | * 61 | *****************************************************************************/ 62 | #ifndef __iwl_fw_api_paging_h__ 63 | #define __iwl_fw_api_paging_h__ 64 | 65 | #define NUM_OF_FW_PAGING_BLOCKS 33 /* 32 for data and 1 block for CSS */ 66 | 67 | /** 68 | * struct iwl_fw_paging_cmd - paging layout 69 | * 70 | * Send to FW the paging layout in the driver. 71 | * 72 | * @flags: various flags for the command 73 | * @block_size: the block size in powers of 2 74 | * @block_num: number of blocks specified in the command. 75 | * @device_phy_addr: virtual addresses from device side 76 | */ 77 | struct iwl_fw_paging_cmd { 78 | __le32 flags; 79 | __le32 block_size; 80 | __le32 block_num; 81 | __le32 device_phy_addr[NUM_OF_FW_PAGING_BLOCKS]; 82 | } __packed; /* FW_PAGING_BLOCK_CMD_API_S_VER_1 */ 83 | 84 | #endif /* __iwl_fw_api_paging_h__ */ 85 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/api/soc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file is provided under a dual BSD/GPLv2 license. When using or 4 | * redistributing this file, you may do so under either license. 5 | * 6 | * GPL LICENSE SUMMARY 7 | * 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 | * Copyright(c) 2019 Intel Deutschland GmbH 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of version 2 of the GNU General Public License as 15 | * published by the Free Software Foundation. 16 | * 17 | * This program is distributed in the hope that it will be useful, but 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * General Public License for more details. 21 | * 22 | * The full GNU General Public License is included in this distribution 23 | * in the file called COPYING. 24 | * 25 | * Contact Information: 26 | * Intel Linux Wireless 27 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 28 | * 29 | * BSD LICENSE 30 | * 31 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 32 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 33 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 34 | * Copyright(c) 2019 Intel Deutschland GmbH 35 | * All rights reserved. 36 | * 37 | * Redistribution and use in source and binary forms, with or without 38 | * modification, are permitted provided that the following conditions 39 | * are met: 40 | * 41 | * * Redistributions of source code must retain the above copyright 42 | * notice, this list of conditions and the following disclaimer. 43 | * * Redistributions in binary form must reproduce the above copyright 44 | * notice, this list of conditions and the following disclaimer in 45 | * the documentation and/or other materials provided with the 46 | * distribution. 47 | * * Neither the name Intel Corporation nor the names of its 48 | * contributors may be used to endorse or promote products derived 49 | * from this software without specific prior written permission. 50 | * 51 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 52 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 53 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 54 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 55 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 56 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 57 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 58 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 59 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 60 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 61 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 | * 63 | *****************************************************************************/ 64 | 65 | #ifndef __iwl_fw_api_soc_h__ 66 | #define __iwl_fw_api_soc_h__ 67 | 68 | #define SOC_CONFIG_CMD_FLAGS_DISCRETE BIT(0) 69 | #define SOC_CONFIG_CMD_FLAGS_LOW_LATENCY BIT(1) 70 | 71 | /** 72 | * struct iwl_soc_configuration_cmd - Set device stabilization latency 73 | * 74 | * @flags: soc settings flags. In VER_1, we can only set the DISCRETE 75 | * flag, because the FW treats the whole value as an integer. In 76 | * VER_2, we can set the bits independently. 77 | * @latency: time for SOC to ensure stable power & XTAL 78 | */ 79 | struct iwl_soc_configuration_cmd { 80 | __le32 flags; 81 | __le32 latency; 82 | } __packed; /* 83 | * SOC_CONFIGURATION_CMD_S_VER_1 (see description above) 84 | * SOC_CONFIGURATION_CMD_S_VER_2 85 | */ 86 | 87 | #endif /* __iwl_fw_api_soc_h__ */ 88 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/fw/fw-api.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * This file is provided under a dual BSD/GPLv2 license. When using or 4 | * redistributing this file, you may do so under either license. 5 | * 6 | * GPL LICENSE SUMMARY 7 | * 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 | * Copyright (C) 2018 Intel Corporation 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of version 2 of the GNU General Public License as 15 | * published by the Free Software Foundation. 16 | * 17 | * This program is distributed in the hope that it will be useful, but 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * General Public License for more details. 21 | * 22 | * The full GNU General Public License is included in this distribution 23 | * in the file called COPYING. 24 | * 25 | * Contact Information: 26 | * Intel Linux Wireless 27 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 28 | * 29 | * BSD LICENSE 30 | * 31 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 32 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 33 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 34 | * Copyright (C) 2018 Intel Corporation 35 | * All rights reserved. 36 | * 37 | * Redistribution and use in source and binary forms, with or without 38 | * modification, are permitted provided that the following conditions 39 | * are met: 40 | * 41 | * * Redistributions of source code must retain the above copyright 42 | * notice, this list of conditions and the following disclaimer. 43 | * * Redistributions in binary form must reproduce the above copyright 44 | * notice, this list of conditions and the following disclaimer in 45 | * the documentation and/or other materials provided with the 46 | * distribution. 47 | * * Neither the name Intel Corporation nor the names of its 48 | * contributors may be used to endorse or promote products derived 49 | * from this software without specific prior written permission. 50 | * 51 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 52 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 53 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 54 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 55 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 56 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 57 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 58 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 59 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 60 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 61 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 | * 63 | *****************************************************************************/ 64 | 65 | #ifndef __fw_api_h__ 66 | #define __fw_api_h__ 67 | 68 | #include "tdls.h" 69 | #include "mac-cfg.h" 70 | #include "offload.h" 71 | #include "context.h" 72 | #include "time-event.h" 73 | #include "datapath.h" 74 | #include "phy.h" 75 | #include "config.h" 76 | #include "soc.h" 77 | #include "alive.h" 78 | #include "binding.h" 79 | #include "cmdhdr.h" 80 | #include "coex.h" 81 | #include "commands.h" 82 | #include "d3.h" 83 | #include "filter.h" 84 | #include "led.h" 85 | #include "mac.h" 86 | #include "nvm-reg.h" 87 | #include "phy-ctxt.h" 88 | #include "power.h" 89 | #include "rs.h" 90 | #include "rx.h" 91 | #include "scan.h" 92 | #include "sf.h" 93 | #include "sta.h" 94 | #include "stats.h" 95 | #include "location.h" 96 | #include "tx.h" 97 | #include "testing.h" 98 | 99 | #endif /* __fw_api_h__ */ 100 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/hack80211/HackIO80211Interface.h: -------------------------------------------------------------------------------- 1 | // 2 | // HackIO80211Interface.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/10. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef HackIO80211Interface_h 10 | #define HackIO80211Interface_h 11 | 12 | //#include 13 | #include "HackIOEthernetInterface.h" 14 | #include 15 | #include 16 | 17 | #define IFNAMSIZ 16 18 | 19 | enum IO80211LinkState 20 | { 21 | kIO80211NetworkLinkUndefined, // Starting link state when an interface is created 22 | kIO80211NetworkLinkDown, // Interface not capable of transmitting packets 23 | kIO80211NetworkLinkUp, // Interface capable of transmitting packets 24 | }; 25 | typedef enum IO80211LinkState IO80211LinkState; 26 | 27 | /*! @defined kIO80211InterfaceClass 28 | @abstract The name of the IO80211Interface class. 29 | */ 30 | 31 | #define kHackIO80211InterfaceClass "HackIO80211Interface" 32 | 33 | typedef UInt64 IO80211FlowQueueHash; 34 | class RSNSupplicant; 35 | class IOTimerEventSource; 36 | class IOGatedOutputQueue; 37 | class IO80211Controller; 38 | class IO80211Workloop; 39 | class IO80211ScanManager; 40 | class IO80211PeerManager; 41 | class IO80211FlowQueueDatabase; 42 | class IO80211InterfaceMonitor; 43 | class IO80211AssociationJoinSnapshot; 44 | 45 | struct apple80211_debug_command; 46 | struct apple80211_txstats; 47 | struct apple80211_chip_counters_tx; 48 | struct apple80211_chip_error_counters_tx; 49 | struct apple80211_chip_counters_rx; 50 | struct apple80211_ManagementInformationBasedot11_counters; 51 | struct apple80211_leaky_ap_stats; 52 | struct apple80211_leaky_ap_ssid_metrics; 53 | struct apple80211_interface_availability; 54 | struct apple80211_pmk_cache_data; 55 | struct apple80211_ap_cmp_data; 56 | struct TxPacketRequest; 57 | struct AWSRequest; 58 | struct packet_info_tx; 59 | struct userPrintCtx; 60 | 61 | typedef int apple80211_postMessage_tlv_types; 62 | 63 | #define IOCTL_GET 3224398281LL 64 | #define IOCTL_SET 2150656456LL 65 | 66 | struct apple80211req 67 | { 68 | char req_if_name[IFNAMSIZ]; // 16 bytes 69 | int req_type; // 4 bytes 70 | int req_val; // 4 bytes 71 | u_int32_t req_len; // 4 bytes 72 | void *req_data; // 4 bytes 73 | }; 74 | 75 | class HackIO80211Interface : public IOEthernetInterface 76 | { 77 | OSDeclareDefaultStructors( HackIO80211Interface ); 78 | 79 | public: 80 | virtual bool terminate(unsigned int) APPLE_KEXT_OVERRIDE; 81 | virtual bool attach(IOService*) APPLE_KEXT_OVERRIDE; 82 | virtual void detach(IOService*) APPLE_KEXT_OVERRIDE; 83 | virtual bool init(IONetworkController*) APPLE_KEXT_OVERRIDE; 84 | virtual UInt32 inputPacket(mbuf_t packet, 85 | UInt32 length = 0, 86 | IOOptionBits options = 0, 87 | void * param = 0) APPLE_KEXT_OVERRIDE; 88 | virtual bool inputEvent(unsigned int, void*) APPLE_KEXT_OVERRIDE; 89 | virtual SInt32 performCommand(IONetworkController*, unsigned long, void*, void*) APPLE_KEXT_OVERRIDE; 90 | virtual IOReturn attachToDataLinkLayer(IOOptionBits, void*) APPLE_KEXT_OVERRIDE; 91 | virtual void detachFromDataLinkLayer(unsigned int, void*) APPLE_KEXT_OVERRIDE; 92 | virtual void setPoweredOnByUser(bool); 93 | virtual void setEnabledBySystem(bool); 94 | virtual bool setLinkState(IO80211LinkState, unsigned int); 95 | virtual bool setLinkState(IO80211LinkState, int, unsigned int); 96 | virtual UInt32 outputPacket(mbuf_t, void*); 97 | 98 | bool configureInterface(IOEthernetController *controller); 99 | 100 | virtual bool setLinkQualityMetric(int); 101 | virtual void handleDebugCmd(apple80211_debug_command*); 102 | 103 | UInt64 IO80211InterfaceUserSpaceToKernelApple80211Request(void *arg, apple80211req *req, unsigned long ctl); 104 | 105 | int performGatedCommand(void *a2, void *a3, void *a4, void *a5, void *a6); 106 | 107 | int apple80211_ioctl(HackIO80211Interface *netif, UInt64 method, apple80211req *a6); 108 | 109 | int apple80211_ioctl_set(HackIO80211Interface *netif, apple80211req *a6); 110 | 111 | int apple80211_ioctl_get(HackIO80211Interface *netif, apple80211req *a6); 112 | }; 113 | 114 | #endif /* HackIO80211Interface_h */ 115 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmDriver.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmDriver.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/17. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmDriver_hpp 10 | #define IWLMvmDriver_hpp 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "IWLTransOps.h" 17 | #include "../fw/IWLUcodeParse.hpp" 18 | #include "IWLNvmParser.hpp" 19 | #include "IWLPhyDb.hpp" 20 | #include "IWMHdr.h" 21 | 22 | class IWLMvmDriver : public OSObject { 23 | OSDeclareDefaultStructors( IWLMvmDriver ); 24 | public: 25 | 26 | /* MARK: IOKit-related initialization code */ 27 | 28 | bool init(IOPCIDevice *pciDevice); 29 | 30 | void release(); 31 | 32 | bool probe(); 33 | 34 | bool start(); 35 | 36 | /* MARK: Firmware loading */ 37 | static void reqFWCallback( 38 | OSKextRequestTag requestTag, 39 | OSReturn result, 40 | const void* resourceData, 41 | uint32_t resourceDataLength, 42 | void* context); 43 | 44 | /* MARK: Callbacks from the IOKit driver */ 45 | 46 | bool drvStart(); 47 | 48 | int irqHandler(int irq, void *dev_id); 49 | 50 | void stopDevice();//iwl_mvm_stop_device 51 | 52 | 53 | //fw 54 | 55 | /** 56 | * iwl_get_nvm - retrieve NVM data from firmware 57 | * 58 | * Allocates a new iwl_nvm_data structure, fills it with 59 | * NVM data, and returns it to caller. 60 | */ 61 | struct iwl_nvm_data *getNvm(IWLTransport *trans, 62 | const struct iwl_fw *fw); 63 | 64 | int loadUcodeWaitAlive(enum iwl_ucode_type ucode_type);//iwl_mvm_load_ucode_wait_alive 65 | 66 | int runInitMvmUCode(bool read_nvm);//iwl_run_init_mvm_ucode 67 | 68 | int runUnifiedMvmUcode(bool read_nvm); 69 | 70 | int nvmInit();//iwl_nvm_init 71 | 72 | int sendPhyCfgCmd();//iwl_send_phy_cfg_cmd 73 | 74 | int sendTXAntCfg(u8 valid_tx_ant);//iwl_send_tx_ant_cfg 75 | 76 | struct iwl_mcc_update_resp *updateMcc(const char *alpha2, enum iwl_mcc_source src_id);//iwl_mvm_update_mcc 77 | 78 | int initMcc();//iwl_mvm_init_mcc 79 | 80 | void rxChubUpdateMcc(struct iwl_rx_cmd_buffer *rxb);//iwl_mvm_rx_chub_update_mcc 81 | 82 | //bt coex 83 | int sendBTInitConf(); //iwl_mvm_send_bt_init_conf 84 | 85 | //utils 86 | int sendCmd(struct iwl_host_cmd *cmd); 87 | 88 | int sendCmdPdu(u32 id, u32 flags, u16 len, const void *data);//iwl_mvm_send_cmd_pdu 89 | 90 | int sendCmdStatus(struct iwl_host_cmd *cmd, u32 *status);//iwl_mvm_send_cmd_status 91 | 92 | int sendCmdPduStatus(u32 id, u16 len, const void* data, u32* status); 93 | 94 | 95 | bool enableDevice(); 96 | 97 | 98 | ///openbsd ieee80211 99 | bool ieee80211Init(); 100 | 101 | void ieee80211Release(); 102 | 103 | bool ieee80211Run(); 104 | 105 | void iwm_setup_ht_rates(); 106 | 107 | int iwm_binding_cmd(struct iwm_node *in, uint32_t action); 108 | 109 | typedef int (*BgScanAction)(struct ieee80211com *ic); 110 | int iwm_bgscan(struct ieee80211com *ic); 111 | 112 | typedef struct ieee80211_node *(*NodeAllocAction)(struct ieee80211com *ic); 113 | struct ieee80211_node *iwm_node_alloc(struct ieee80211com *ic); 114 | 115 | typedef int (*NewStateAction)(struct ieee80211com *, enum ieee80211_state, int); 116 | int iwm_newstate(struct ieee80211com *, enum ieee80211_state, int); 117 | 118 | public: 119 | IOEthernetController* controller; 120 | IWLDevice *m_pDevice; 121 | 122 | IWLTransport *trans; 123 | 124 | IWLTransOps *trans_ops; 125 | 126 | /* MARK: Rx handlers */ 127 | static void btCoexNotif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 128 | static void rxFwErrorNotif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 129 | static void rxMfuartNotif(struct iwl_mvm* mvm, struct iwl_rx_cmd_buffer *rxb); 130 | 131 | private: 132 | 133 | IOLock *fwLoadLock; 134 | 135 | struct iwl_phy_db phy_db; 136 | 137 | }; 138 | 139 | static inline bool iwl_mvm_has_new_rx_api(struct iwl_fw *fw) 140 | { 141 | return fw_has_capa(&fw->ucode_capa, 142 | IWL_UCODE_TLV_CAPA_MULTI_QUEUE_RX_SUPPORT); 143 | } 144 | 145 | #endif /* IWLMvmDriver_hpp */ 146 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmPhy.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmPhy.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmPhy_hpp 10 | #define IWLMvmPhy_hpp 11 | 12 | #include "IWLMvmDriver.hpp" 13 | 14 | int 15 | iwl_phy_ctxt_add(IWLMvmDriver* drv, struct iwl_phy_ctx *ctxt, 16 | struct ieee80211_channel *chan, 17 | uint8_t chains_static, uint8_t chains_dynamic); 18 | 19 | int 20 | iwl_phy_ctxt_changed(IWLMvmDriver* drv, 21 | struct iwl_phy_ctx *ctxt, struct ieee80211_channel *chan, 22 | uint8_t chains_static, uint8_t chains_dynamic); 23 | 24 | int 25 | iwl_phy_ctxt_apply(IWLMvmDriver* drv, 26 | struct iwl_phy_ctx *ctxt, 27 | uint8_t chains_static, uint8_t chains_dynamic, 28 | uint32_t action, uint32_t apply_time); 29 | 30 | void 31 | iwl_phy_ctxt_cmd_data(IWLMvmDriver* drv, 32 | struct iwl_phy_context_cmd *cmd, struct ieee80211_channel *chan, 33 | uint8_t chains_static, uint8_t chains_dynamic); 34 | 35 | void 36 | iwl_phy_ctxt_cmd_hdr(IWLMvmDriver* drv, struct iwl_phy_ctx *ctxt, 37 | struct iwl_phy_context_cmd *cmd, uint32_t action, uint32_t apply_time); 38 | 39 | 40 | #endif /* IWLMvmPhy_hpp */ 41 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmScan.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmScan.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLMvmScan.hpp" 10 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmScan.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmScan.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmScan_hpp 10 | #define IWLMvmScan_hpp 11 | 12 | #endif /* IWLMvmScan_hpp */ 13 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmSmartFifo.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLMvmSmartFifo.hpp" 10 | 11 | void iwl_fill_sf_cmd(IWLMvmDriver* dev, iwl_sf_cfg_cmd* cmd, ieee80211_node* ni) { 12 | int i, j, watermark; 13 | 14 | cmd->watermark[SF_LONG_DELAY_ON] = htole32(SF_W_MARK_SCAN); 15 | 16 | /* 17 | * If we are in association flow - check antenna configuration 18 | * capabilities of the AP station, and choose the watermark accordingly. 19 | */ 20 | if (ni) { 21 | #ifndef IEEE80211_NO_HT 22 | if (ni->ni_flags & IEEE80211_NODE_HT) { 23 | #ifdef notyet 24 | if (ni->ni_rxmcs[2] != 0) 25 | watermark = IWM_SF_W_MARK_MIMO3; 26 | else if (ni->ni_rxmcs[1] != 0) 27 | watermark = IWM_SF_W_MARK_MIMO2; 28 | else 29 | #endif 30 | watermark = SF_W_MARK_SISO; 31 | } else 32 | #endif 33 | watermark = SF_W_MARK_LEGACY; 34 | 35 | } else { 36 | watermark = SF_W_MARK_MIMO2; 37 | } 38 | 39 | cmd->watermark[SF_FULL_ON] = htole32(watermark); 40 | 41 | for (i = 0; i < SF_NUM_SCENARIO; i++) { 42 | for (j = 0; j < SF_NUM_TIMEOUT_TYPES; j++) { 43 | cmd->long_delay_timeouts[i][j] = 44 | htole32(SF_LONG_DELAY_AGING_TIMER); 45 | } 46 | } 47 | 48 | if (ni) { 49 | memcpy(cmd->full_on_timeouts, iwl_sf_full_timeout, 50 | sizeof(iwl_sf_full_timeout)); 51 | } else { 52 | memcpy(cmd->full_on_timeouts, iwl_sf_full_timeout_def, 53 | sizeof(iwl_sf_full_timeout_def)); 54 | } 55 | } 56 | 57 | int iwl_sf_config(IWLMvmDriver* drv, int new_state) { 58 | IWLTransport* trans = drv->trans; 59 | ieee80211com* ic = &trans->m_pDevice->ie_ic; 60 | if(!ic) 61 | return -1; 62 | 63 | struct iwl_sf_cfg_cmd sf_cmd = { 64 | .state = htole32(new_state), 65 | }; 66 | 67 | /* 68 | if(trans->m_pDevice->cfg->trans.device_family == IWL_DEVICE_FAMILY_8000) 69 | sf_cmd.state |= htole32(SF_CFG_DUMMY_NOTIF_OFF); 70 | */ 71 | 72 | switch (new_state) { 73 | case SF_UNINIT: 74 | case SF_INIT_OFF: 75 | iwl_fill_sf_cmd(drv, &sf_cmd, NULL); 76 | break; 77 | case SF_FULL_ON: 78 | iwl_fill_sf_cmd(drv, &sf_cmd, ic->ic_bss); 79 | break; 80 | default: 81 | return EINVAL; 82 | } 83 | 84 | return drv->sendCmdPdu(REPLY_SF_CFG_CMD, CMD_ASYNC, sizeof(sf_cmd), &sf_cmd); 85 | } 86 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmSmartFifo.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmSmartFifo.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmSmartFifo_hpp 10 | #define IWLMvmSmartFifo_hpp 11 | 12 | #include "../fw/api/sf.h" 13 | #include "../trans/IWLTransport.hpp" 14 | #include "../mvm/IWLMvmDriver.hpp" 15 | 16 | static const uint32_t 17 | iwl_sf_full_timeout_def[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = { 18 | { 19 | htole32(SF_SINGLE_UNICAST_AGING_TIMER_DEF), 20 | htole32(SF_SINGLE_UNICAST_IDLE_TIMER_DEF) 21 | }, 22 | { 23 | htole32(SF_AGG_UNICAST_AGING_TIMER_DEF), 24 | htole32(SF_AGG_UNICAST_IDLE_TIMER_DEF) 25 | }, 26 | { 27 | htole32(SF_MCAST_AGING_TIMER_DEF), 28 | htole32(SF_MCAST_IDLE_TIMER_DEF) 29 | }, 30 | { 31 | htole32(SF_BA_AGING_TIMER_DEF), 32 | htole32(SF_BA_IDLE_TIMER_DEF) 33 | }, 34 | { 35 | htole32(SF_TX_RE_AGING_TIMER_DEF), 36 | htole32(SF_TX_RE_IDLE_TIMER_DEF) 37 | }, 38 | }; 39 | 40 | static const uint32_t 41 | iwl_sf_full_timeout[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = { 42 | { 43 | htole32(SF_SINGLE_UNICAST_AGING_TIMER), 44 | htole32(SF_SINGLE_UNICAST_IDLE_TIMER) 45 | }, 46 | { 47 | htole32(SF_AGG_UNICAST_AGING_TIMER), 48 | htole32(SF_AGG_UNICAST_IDLE_TIMER) 49 | }, 50 | { 51 | htole32(SF_MCAST_AGING_TIMER), 52 | htole32(SF_MCAST_IDLE_TIMER) 53 | }, 54 | { 55 | htole32(SF_BA_AGING_TIMER), 56 | htole32(SF_BA_IDLE_TIMER) 57 | }, 58 | { 59 | htole32(SF_TX_RE_AGING_TIMER), 60 | htole32(SF_TX_RE_IDLE_TIMER) 61 | }, 62 | }; 63 | 64 | 65 | int iwl_sf_config(IWLMvmDriver* drv, int new_state); 66 | void iwl_fill_sf_cmd(IWLMvmDriver* drv, iwl_sf_cfg_cmd *sf_cmd, ieee80211_node *ni); 67 | 68 | #endif /* IWLMvmSmartFifo_hpp */ 69 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmSta.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmSta.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLMvmSta.hpp" 10 | 11 | bool 12 | iwl_trans_txq_enable_cfg(IWLTransport *trans, int queue, u16 ssn, 13 | const struct iwl_trans_txq_scd_cfg *cfg, 14 | unsigned int queue_wdg_timeout); 15 | 16 | int iwl_enable_txq(IWLMvmDriver* drv, int sta_id, int qid, int fifo) { 17 | struct iwl_scd_txq_cfg_cmd cfg = { 18 | .tx_fifo = fifo, 19 | .sta_id = sta_id, 20 | .action = 1, 21 | .scd_queue = qid, 22 | .window = IWL_FRAME_LIMIT, 23 | .aggregate = false, 24 | }; 25 | int err; 26 | 27 | if((err = drv->sendCmdPdu(SCD_QUEUE_CFG, 0, sizeof(cfg), &cfg))) { 28 | return err; 29 | } 30 | IOInterruptState state; 31 | if(!drv->trans->grabNICAccess(&state)) 32 | return 1; 33 | 34 | drv->trans->iwlWritePRPHNoGrab(SCD_EN_CTRL, drv->trans->iwlReadPRPHNoGrab(SCD_EN_CTRL) | qid); 35 | 36 | drv->trans->releaseNICAccess(&state); 37 | 38 | return err; 39 | } 40 | 41 | int iwl_mvm_add_aux_sta(IWLMvmDriver* drv) { 42 | iwl_mvm_add_sta_cmd cmd; 43 | int err; 44 | uint32_t status; 45 | 46 | err = iwl_enable_txq(drv, 1, IWL_MVM_DQA_AUX_QUEUE, IWL_MVM_TX_FIFO_MCAST); 47 | if(err) 48 | return err; 49 | 50 | memset(&cmd, 0, sizeof(cmd)); 51 | cmd.sta_id = 1; 52 | cmd.mac_id_n_color = 53 | htole32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)); 54 | cmd.tfd_queue_msk = htole32(1 << IWL_MVM_DQA_AUX_QUEUE); 55 | cmd.tid_disable_tx = htole16(0xffff); 56 | 57 | status = ADD_STA_SUCCESS; 58 | err = drv->sendCmdPduStatus(ADD_STA, sizeof(cmd), &cmd, &status); 59 | if (err == 0 && status != ADD_STA_SUCCESS) 60 | err = -EIO; 61 | 62 | return err; 63 | } 64 | 65 | /* send station add/update command to firmware */ 66 | int iwl_mvm_sta_send_to_fw(IWLMvmDriver* drv, struct iwm_node *in, bool update, unsigned int flags) 67 | { 68 | struct ieee80211com *ic = &drv->m_pDevice->ie_ic; 69 | struct iwl_mvm_add_sta_cmd add_sta_cmd = { 70 | .sta_id = IWM_STATION_ID, 71 | .mac_id_n_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(in->in_id, in->in_color)), 72 | .add_modify = update ? 1 : 0, 73 | .tid_disable_tx = cpu_to_le16(0xffff), 74 | }; 75 | add_sta_cmd.station_flags_msk = 76 | cpu_to_le32(STA_FLG_FAT_EN_MSK | STA_FLG_MIMO_EN_MSK | STA_FLG_RTS_MIMO_PROT); 77 | int ret; 78 | u32 status; 79 | u32 agg_size = 0, mpdu_dens = 0; 80 | 81 | if (fw_has_api(&drv->m_pDevice->fw.ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) { 82 | //TODO zxy if use tdls, its type is IWL_STA_TDLS_LINK, but we now ignore it. 83 | //sta->tdls ? IWL_STA_TDLS_LINK : IWL_STA_LINK; 84 | add_sta_cmd.station_type = IWL_STA_LINK; 85 | } 86 | if (!update || (flags & STA_MODIFY_QUEUES)) { 87 | IEEE80211_ADDR_COPY(&add_sta_cmd.addr, in->in_ni.ni_bssid); 88 | 89 | if (!iwl_mvm_has_new_tx_api(drv->m_pDevice)) { 90 | add_sta_cmd.tfd_queue_msk = 91 | cpu_to_le32(0);//mvm_sta->tfd_queue_msk = 0; 92 | 93 | if (flags & STA_MODIFY_QUEUES) 94 | add_sta_cmd.modify_mask |= STA_MODIFY_QUEUES; 95 | } else { 96 | WARN_ON(flags & STA_MODIFY_QUEUES); 97 | } 98 | } 99 | // switch (sta->bandwidth) { 100 | // case IEEE80211_STA_RX_BW_160: 101 | // add_sta_cmd.station_flags |= cpu_to_le32(STA_FLG_FAT_EN_160MHZ); 102 | // /* fall through */ 103 | // case IEEE80211_STA_RX_BW_80: 104 | // add_sta_cmd.station_flags |= cpu_to_le32(STA_FLG_FAT_EN_80MHZ); 105 | // /* fall through */ 106 | // case IEEE80211_STA_RX_BW_40: 107 | // add_sta_cmd.station_flags |= cpu_to_le32(STA_FLG_FAT_EN_40MHZ); 108 | // /* fall through */ 109 | // case IEEE80211_STA_RX_BW_20: 110 | // if (sta->ht_cap.ht_supported) 111 | // add_sta_cmd.station_flags |= 112 | // cpu_to_le32(STA_FLG_FAT_EN_20MHZ); 113 | // break; 114 | // } 115 | if (in->in_ni.ni_flags & IEEE80211_NODE_HT) { 116 | add_sta_cmd.station_flags_msk 117 | |= htole32(STA_FLG_MAX_AGG_SIZE_MSK | 118 | STA_FLG_AGG_MPDU_DENS_MSK); 119 | 120 | add_sta_cmd.station_flags 121 | |= htole32(STA_FLG_MAX_AGG_SIZE_64K); 122 | switch (ic->ic_ampdu_params & IEEE80211_AMPDU_PARAM_SS) { 123 | case IEEE80211_AMPDU_PARAM_SS_2: 124 | add_sta_cmd.station_flags 125 | |= htole32(STA_FLG_AGG_MPDU_DENS_2US); 126 | break; 127 | case IEEE80211_AMPDU_PARAM_SS_4: 128 | add_sta_cmd.station_flags 129 | |= htole32(STA_FLG_AGG_MPDU_DENS_4US); 130 | break; 131 | case IEEE80211_AMPDU_PARAM_SS_8: 132 | add_sta_cmd.station_flags 133 | |= htole32(STA_FLG_AGG_MPDU_DENS_8US); 134 | break; 135 | case IEEE80211_AMPDU_PARAM_SS_16: 136 | add_sta_cmd.station_flags 137 | |= htole32(STA_FLG_AGG_MPDU_DENS_16US); 138 | break; 139 | default: 140 | break; 141 | } 142 | } 143 | 144 | status = ADD_STA_SUCCESS; 145 | ret = drv->sendCmdPduStatus(ADD_STA, iwl_mvm_add_sta_cmd_size(drv->m_pDevice), 146 | &add_sta_cmd, &status); 147 | if (!ret && (status & IWL_ADD_STA_STATUS_MASK) != ADD_STA_SUCCESS) 148 | ret = EIO; 149 | 150 | return ret; 151 | } 152 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmSta.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmSta.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/19/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmSta_hpp 10 | #define IWLMvmSta_hpp 11 | 12 | #include "../trans/IWLTransport.hpp" 13 | #include "../mvm/IWLMvmDriver.hpp" 14 | 15 | /* 16 | * New version of ADD_STA_sta command added new fields at the end of the 17 | * structure, so sending the size of the relevant API's structure is enough to 18 | * support both API versions. 19 | */ 20 | static inline int iwl_mvm_add_sta_cmd_size(IWLDevice *mvm) 21 | { 22 | if (iwl_mvm_has_new_rx_api(mvm) || 23 | fw_has_api(&mvm->fw.ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) 24 | return sizeof(struct iwl_mvm_add_sta_cmd); 25 | else 26 | return sizeof(struct iwl_mvm_add_sta_cmd_v7); 27 | } 28 | 29 | int iwl_mvm_add_aux_sta(IWLMvmDriver* drv); 30 | 31 | int iwl_mvm_sta_send_to_fw(IWLMvmDriver* drv, struct iwm_node *in, bool update, unsigned int flags); 32 | 33 | #endif /* IWLMvmSta_hpp */ 34 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen1.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmTransOpsGen1.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/13. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmTransOpsGen1_hpp 10 | #define IWLMvmTransOpsGen1_hpp 11 | 12 | #include "IWLIO.hpp" 13 | #include "IWLTransOps.h" 14 | 15 | class IWLMvmTransOpsGen1 : public IWLTransOps { 16 | 17 | 18 | public: 19 | 20 | IWLMvmTransOpsGen1() {} 21 | IWLMvmTransOpsGen1(IWLTransport *trans) : IWLTransOps(trans) {} 22 | virtual ~IWLMvmTransOpsGen1() {} 23 | 24 | int nicInit() override; 25 | 26 | void fwAlive(UInt32 scd_addr) override; 27 | 28 | int startFW(const struct fw_img *fw, bool run_in_rfkill) override; 29 | 30 | void stopDevice() override; 31 | 32 | void stopDeviceDirectly() override; 33 | 34 | int apmInit() override; 35 | 36 | void apmStop(bool op_mode_leave) override; 37 | 38 | int forcePowerGating() override {return 0;}; 39 | 40 | private: 41 | int txInit(); 42 | 43 | int rxInit(); 44 | 45 | void setPwr(bool vaux); 46 | }; 47 | 48 | #endif /* IWLMvmTransOpsGen1_hpp */ 49 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWLMvmTransOpsGen2.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLMvmTransOpsGen2.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/13. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLMvmTransOpsGen2_hpp 10 | #define IWLMvmTransOpsGen2_hpp 11 | 12 | #include "IWLTransOps.h" 13 | 14 | class IWLMvmTransOpsGen2 : public IWLTransOps { 15 | 16 | public: 17 | 18 | IWLMvmTransOpsGen2() {} 19 | IWLMvmTransOpsGen2(IWLTransport *trans) : IWLTransOps(trans) {} 20 | virtual ~IWLMvmTransOpsGen2() {} 21 | 22 | int nicInit() override; 23 | 24 | void fwAlive(UInt32 scd_addr) override; 25 | 26 | int startFW(const struct fw_img *fw, bool run_in_rfkill) override; 27 | 28 | void stopDevice() override; 29 | 30 | void stopDeviceDirectly() override; 31 | 32 | int apmInit() override; 33 | 34 | void apmStop(bool op_mode_leave) override; 35 | 36 | int forcePowerGating() override; 37 | 38 | private: 39 | int txInit(int txq_id, int queue_size); 40 | 41 | int rxInit(); 42 | }; 43 | 44 | #endif /* IWLMvmTransOpsGen2_hpp */ 45 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/IWMHdr.h: -------------------------------------------------------------------------------- 1 | // 2 | // IWMHdr.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by qcwap on 2020/2/21. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWMHdr_h 10 | #define IWMHdr_h 11 | 12 | #include "../compat/openbsd/net80211/ieee80211_var.h" 13 | #include "../compat/openbsd/net80211/ieee80211_amrr.h" 14 | #include "../compat/openbsd/net80211/ieee80211_mira.h" 15 | #include "../fw/api/phy-ctxt.h" 16 | 17 | #define IWM_MIN_DBM -100 18 | #define IWM_MAX_DBM -33 /* realistic guess */ 19 | 20 | #define IWM_STATION_ID 0 21 | #define IWM_AUX_STA_ID 1 22 | 23 | 24 | struct iwm_node { 25 | struct ieee80211_node in_ni; 26 | struct iwl_phy_ctx *in_phyctxt; 27 | 28 | uint16_t in_id; 29 | uint16_t in_color; 30 | 31 | struct ieee80211_amrr_node in_amn; 32 | struct ieee80211_mira_node in_mn; 33 | 34 | /* Set in 11n mode if we don't receive ACKs for OFDM frames. */ 35 | int ht_force_cck; 36 | 37 | }; 38 | 39 | #endif /* IWMHdr_h */ 40 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/mvm/MvmTransOps.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // MvmTransOps.cpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/1. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLTransOps.h" 10 | 11 | void IWLTransOps::nicConfig() 12 | { 13 | u8 radio_cfg_type, radio_cfg_step, radio_cfg_dash; 14 | u32 reg_val = 0; 15 | u32 phy_config = iwl_mvm_get_phy_config(trans->m_pDevice); 16 | 17 | radio_cfg_type = (phy_config & FW_PHY_CFG_RADIO_TYPE) >> 18 | FW_PHY_CFG_RADIO_TYPE_POS; 19 | radio_cfg_step = (phy_config & FW_PHY_CFG_RADIO_STEP) >> 20 | FW_PHY_CFG_RADIO_STEP_POS; 21 | radio_cfg_dash = (phy_config & FW_PHY_CFG_RADIO_DASH) >> 22 | FW_PHY_CFG_RADIO_DASH_POS; 23 | 24 | /* SKU control */ 25 | reg_val |= CSR_HW_REV_STEP(trans->m_pDevice->hw_rev) << 26 | CSR_HW_IF_CONFIG_REG_POS_MAC_STEP; 27 | reg_val |= CSR_HW_REV_DASH(trans->m_pDevice->hw_rev) << 28 | CSR_HW_IF_CONFIG_REG_POS_MAC_DASH; 29 | 30 | /* radio configuration */ 31 | reg_val |= radio_cfg_type << CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE; 32 | reg_val |= radio_cfg_step << CSR_HW_IF_CONFIG_REG_POS_PHY_STEP; 33 | reg_val |= radio_cfg_dash << CSR_HW_IF_CONFIG_REG_POS_PHY_DASH; 34 | 35 | WARN_ON((radio_cfg_type << CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE) & 36 | ~CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE); 37 | 38 | /* 39 | * TODO: Bits 7-8 of CSR in 8000 HW family and higher set the ADC 40 | * sampling, and shouldn't be set to any non-zero value. 41 | * The same is supposed to be true of the other HW, but unsetting 42 | * them (such as the 7260) causes automatic tests to fail on seemingly 43 | * unrelated errors. Need to further investigate this, but for now 44 | * we'll separate cases. 45 | */ 46 | if (trans->m_pDevice->cfg->trans.device_family < IWL_DEVICE_FAMILY_8000) 47 | reg_val |= CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI; 48 | 49 | //TODO now not needed 50 | // if (iwl_fw_dbg_is_d3_debug_enabled(&mvm->fwrt)) 51 | // reg_val |= CSR_HW_IF_CONFIG_REG_D3_DEBUG; 52 | 53 | trans->setBitMask(CSR_HW_IF_CONFIG_REG, 54 | CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH | 55 | CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP | 56 | CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE | 57 | CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP | 58 | CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH | 59 | CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | 60 | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI | 61 | CSR_HW_IF_CONFIG_REG_D3_DEBUG, 62 | reg_val); 63 | 64 | IWL_INFO(0, "Radio type=0x%x-0x%x-0x%x\n", radio_cfg_type, 65 | radio_cfg_step, radio_cfg_dash); 66 | 67 | /* 68 | * W/A : NIC is stuck in a reset state after Early PCIe power off 69 | * (PCIe power is lost before PERST# is asserted), causing ME FW 70 | * to lose ownership and not being able to obtain it back. 71 | */ 72 | if (!trans->m_pDevice->cfg->apmg_not_supported) 73 | trans->iwlSetBitsMaskPRPH(APMG_PS_CTRL_REG, 74 | APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS, 75 | ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); 76 | } 77 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/nvm/IWLNvmParser.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLNvmParser.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/2. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLNvmParser_hpp 10 | #define IWLNvmParser_hpp 11 | 12 | #include "IWLeeprom.h" 13 | #include "IWLTransport.hpp" 14 | #include "../fw/api/nvm-reg.h" 15 | #include "../fw/api/commands.h" 16 | #include "IWLTransOps.h" 17 | 18 | #include 19 | #include 20 | 21 | /* radio config bits (actual values from NVM definition) */ 22 | #define NVM_RF_CFG_DASH_MSK(x) (x & 0x3) /* bits 0-1 */ 23 | #define NVM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ 24 | #define NVM_RF_CFG_TYPE_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ 25 | #define NVM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ 26 | #define NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ 27 | #define NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ 28 | 29 | #define EXT_NVM_RF_CFG_FLAVOR_MSK(x) ((x) & 0xF) 30 | #define EXT_NVM_RF_CFG_DASH_MSK(x) (((x) >> 4) & 0xF) 31 | #define EXT_NVM_RF_CFG_STEP_MSK(x) (((x) >> 8) & 0xF) 32 | #define EXT_NVM_RF_CFG_TYPE_MSK(x) (((x) >> 12) & 0xFFF) 33 | #define EXT_NVM_RF_CFG_TX_ANT_MSK(x) (((x) >> 24) & 0xF) 34 | #define EXT_NVM_RF_CFG_RX_ANT_MSK(x) (((x) >> 28) & 0xF) 35 | 36 | /** 37 | * enum iwl_nvm_sbands_flags - modification flags for the channel profiles 38 | * 39 | * @IWL_NVM_SBANDS_FLAGS_LAR: LAR is enabled 40 | * @IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ: disallow 40, 80 and 160MHz on 5GHz 41 | */ 42 | enum iwl_nvm_sbands_flags { 43 | IWL_NVM_SBANDS_FLAGS_LAR = BIT(0), 44 | IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ = BIT(1), 45 | }; 46 | 47 | void iwl_set_hw_address_from_csr(IWLTransport *trans, 48 | struct iwl_nvm_data *data); 49 | 50 | /** 51 | * iwl_parse_nvm_data - parse NVM data and return values 52 | * 53 | * This function parses all NVM values we need and then 54 | * returns a (newly allocated) struct containing all the 55 | * relevant values for driver use. The struct must be freed 56 | * later with iwl_free_nvm_data(). 57 | */ 58 | struct iwl_nvm_data * 59 | iwl_parse_nvm_data(IWLTransport *trans, const struct iwl_cfg *cfg, 60 | const struct iwl_fw *fw, 61 | const __be16 *nvm_hw, const __le16 *nvm_sw, 62 | const __le16 *nvm_calib, const __le16 *regulatory, 63 | const __le16 *mac_override, const __le16 *phy_sku, 64 | u8 tx_chains, u8 rx_chains); 65 | 66 | /** 67 | * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW 68 | * 69 | * This function parses the regulatory channel data received as a 70 | * MCC_UPDATE_CMD command. It returns a newly allocation regulatory domain, 71 | * to be fed into the regulatory core. In case the geo_info is set handle 72 | * accordingly. An ERR_PTR is returned on error. 73 | * If not given to the regulatory core, the user is responsible for freeing 74 | * the regdomain returned here with kfree. 75 | */ 76 | struct ieee80211_regdomain * 77 | iwl_parse_nvm_mcc_info(IWLDevice *dev, const struct iwl_cfg *cfg, 78 | int num_of_ch, __le32 *channels, u16 fw_mcc, 79 | u16 geo_info, u16 cap); 80 | 81 | /** 82 | * iwl_read_external_nvm - Reads external NVM from a file into nvm_sections 83 | */ 84 | int iwl_read_external_nvm(IWLTransport *trans, 85 | const char *nvm_file_name, 86 | struct iwl_nvm_section *nvm_sections); 87 | 88 | void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data, 89 | unsigned int len); 90 | 91 | void iwl_init_sbands(IWLTransport *trans, 92 | struct iwl_nvm_data *data, 93 | const void *nvm_ch_flags, u8 tx_chains, 94 | u8 rx_chains, u32 sbands_flags, bool v4); 95 | 96 | #endif /* IWLNvmParser_hpp */ 97 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/nvm/IWLeeprom.h: -------------------------------------------------------------------------------- 1 | // 2 | // IWLeeprom.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/2/1. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLeeprom_h 10 | #define IWLeeprom_h 11 | 12 | //#include 13 | #include 14 | #include 15 | #include 16 | 17 | struct iwl_nvm_data { 18 | int n_hw_addrs; 19 | u8 hw_addr[ETH_ALEN]; 20 | 21 | u8 calib_version; 22 | __le16 calib_voltage; 23 | 24 | __le16 raw_temperature; 25 | __le16 kelvin_temperature; 26 | __le16 kelvin_voltage; 27 | __le16 xtal_calib[2]; 28 | 29 | bool sku_cap_band_24ghz_enable; 30 | bool sku_cap_band_52ghz_enable; 31 | bool sku_cap_11n_enable; 32 | bool sku_cap_11ac_enable; 33 | bool sku_cap_11ax_enable; 34 | bool sku_cap_amt_enable; 35 | bool sku_cap_ipan_enable; 36 | bool sku_cap_mimo_disabled; 37 | 38 | u16 radio_cfg_type; 39 | u8 radio_cfg_step; 40 | u8 radio_cfg_dash; 41 | u8 radio_cfg_pnum; 42 | u8 valid_tx_ant, valid_rx_ant; 43 | 44 | u32 nvm_version; 45 | s8 max_tx_pwr_half_dbm; 46 | 47 | bool lar_enabled; 48 | bool vht160_supported; 49 | //TODO 50 | // struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; 51 | struct ieee80211_channel channels[]; 52 | }; 53 | 54 | /** 55 | * struct iwl_nvm_section - describes an NVM section in memory. 56 | * 57 | * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD, 58 | * and saved for later use by the driver. Not all NVM sections are saved 59 | * this way, only the needed ones. 60 | */ 61 | struct iwl_nvm_section { 62 | u16 length; 63 | const u8 *data; 64 | }; 65 | 66 | #endif /* IWLeeprom_h */ 67 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/trans/IWLIO.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IWLIO.hpp 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/13. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLIO_hpp 10 | #define IWLIO_hpp 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "../device/IWLDeviceBase.h" 18 | #include "../IWLDevice.hpp" 19 | 20 | #define IWL_POLL_INTERVAL 10 21 | 22 | /* Max time to wait for nmi interrupt */ 23 | #define IWL_TRANS_NMI_TIMEOUT (HZ / 4 * CPTCFG_IWL_TIMEOUT_FACTOR) 24 | 25 | class IWLIO { 26 | 27 | 28 | public: 29 | 30 | bool init(IWLDevice *device); 31 | 32 | void release(); 33 | 34 | bool grabNICAccess(IOInterruptState *state); 35 | 36 | void releaseNICAccess(IOInterruptState *state); 37 | 38 | int iwlReadMem(u32 addr, void *buf, int dwords); 39 | 40 | u32 iwlReadMem32(u32 addr); 41 | 42 | int iwlWriteMem(u32 addr, void *buf, int dwords); 43 | 44 | u32 iwlWriteMem32(u32 addr, u32 val); 45 | 46 | void setPMI(bool state); 47 | 48 | void setBitMask(u32 reg, u32 mask, u32 val); 49 | 50 | void setBit(u32 reg, u32 mask); 51 | 52 | void clearBit(u32 reg, u32 mask); 53 | 54 | void iwlWrite8(u32 ofs, u8 val); 55 | 56 | void iwlWrite32(u32 ofs, u32 val); 57 | 58 | void iwlWrite64(u64 ofs, u64 val); 59 | 60 | void iwlWriteDirect32(u32 reg, u32 value); 61 | 62 | void iwlWriteDirect64(u64 reg, u64 value); 63 | 64 | u32 iwlRead32(u32 ofs); 65 | 66 | u32 iwlReadDirect32(u32 reg); 67 | 68 | int iwlPollBit(u32 addr, 69 | u32 bits, u32 mask, int timeout); 70 | 71 | int iwlPollPRPHBit(u32 addr, u32 bits, u32 mask, int timeout); 72 | 73 | void iwlSetBitsPRPH(u32 ofs, u32 mask); 74 | 75 | void iwlSetBitsMaskPRPH(u32 ofs, u32 bits, u32 mask); 76 | 77 | void iwlClearBitsPRPH(u32 ofs, u32 mask); 78 | 79 | int iwlPollDirectBit(u32 addr, u32 mask, int timeout); 80 | 81 | u32 iwlReadPRPH(u32 ofs); 82 | 83 | u32 iwlReadPRPHNoGrab(u32 ofs); 84 | 85 | void iwlWritePRPH(u32 addr, u32 val); 86 | 87 | void iwlWritePRPHNoGrab(u32 addr, u32 val); 88 | 89 | void iwlWritePRPH64NoGrab(u64 ofs, u64 val); 90 | 91 | /* 92 | * UMAC periphery address space changed from 0xA00000 to 0xD00000 starting from 93 | * device family AX200. So peripheries used in families above and below AX200 94 | * should go through iwl_..._umac_..._prph. 95 | */ 96 | u32 iwlUmacPRPH(u32 ofs); 97 | 98 | u32 iwlReadUmacPRPHNoGrab(u32 ofs); 99 | 100 | u32 iwlReadUmacPRPH(u32 ofs); 101 | 102 | void iwlWriteUmacPRPHNoGrab(u32 ofs, u32 val); 103 | 104 | void iwlWriteUmacPRPH(u32 ofs, u32 val); 105 | 106 | int iwlPollUmacPRPHBit(u32 addr, u32 bits, u32 mask, int timeout); 107 | 108 | u32 iwlReadShr(u32 reg); 109 | 110 | void iwlWriteShr(u32 reg, u32 val); 111 | 112 | void iwlForceNmi(); 113 | 114 | protected: 115 | 116 | 117 | private: 118 | 119 | void osWriteInt8(uintptr_t byteOffset, uint8_t data); 120 | 121 | public: 122 | IWLDevice *m_pDevice; 123 | 124 | 125 | private: 126 | 127 | IOMemoryMap *fMemMap; 128 | 129 | volatile void *fHwBase; 130 | 131 | }; 132 | 133 | #endif /* IWLIO_hpp */ 134 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/trans/IWLSCD.h: -------------------------------------------------------------------------------- 1 | // 2 | // IWLSCD.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by Harrison Ford on 2/16/20. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #include "IWLTransport.hpp" 10 | #ifndef IWLSCD_h 11 | #define IWLSCD_h 12 | 13 | static inline void iwl_scd_txq_set_chain(IWLTransport *trans, 14 | u16 txq_id) 15 | { 16 | //iwl_set_bits_prph(trans, SCD_QUEUECHAIN_SEL, BIT(txq_id)); 17 | trans->iwlSetBitsPRPH(SCD_QUEUECHAIN_SEL, BIT(txq_id)); 18 | } 19 | 20 | static inline void iwl_scd_txq_enable_agg(IWLTransport *trans, 21 | u16 txq_id) 22 | { 23 | trans->iwlSetBitsPRPH(SCD_AGGR_SEL, BIT(txq_id)); 24 | } 25 | 26 | static inline void iwl_scd_txq_disable_agg(IWLTransport *trans, 27 | u16 txq_id) 28 | { 29 | trans->iwlSetBitsPRPH(SCD_AGGR_SEL, BIT(txq_id)); 30 | } 31 | 32 | static inline void iwl_scd_disable_agg(IWLTransport *trans) 33 | { 34 | trans->iwlSetBitsPRPH(SCD_AGGR_SEL, 0); 35 | } 36 | 37 | static inline void iwl_scd_activate_fifos(IWLTransport *trans) 38 | { 39 | trans->iwlSetBitsPRPH(SCD_TXFACT, IWL_MASK(0, 7)); 40 | } 41 | 42 | static inline void iwl_scd_deactivate_fifos(IWLTransport *trans) 43 | { 44 | trans->iwlSetBitsPRPH(SCD_TXFACT, 0); 45 | } 46 | 47 | static inline void iwl_scd_enable_set_active(IWLTransport *trans, 48 | u32 value) 49 | { 50 | trans->iwlSetBitsPRPH(SCD_EN_CTRL, value); 51 | } 52 | 53 | static inline unsigned int SCD_QUEUE_WRPTR(unsigned int chnl) 54 | { 55 | if (chnl < 20) 56 | return SCD_BASE + 0x18 + chnl * 4; 57 | WARN_ON_ONCE(chnl >= 32); 58 | return SCD_BASE + 0x284 + (chnl - 20) * 4; 59 | } 60 | 61 | static inline unsigned int SCD_QUEUE_RDPTR(unsigned int chnl) 62 | { 63 | if (chnl < 20) 64 | return SCD_BASE + 0x68 + chnl * 4; 65 | WARN_ON_ONCE(chnl >= 32); 66 | return SCD_BASE + 0x2B4 + chnl * 4; 67 | } 68 | 69 | static inline unsigned int SCD_QUEUE_STATUS_BITS(unsigned int chnl) 70 | { 71 | if (chnl < 20) 72 | return SCD_BASE + 0x10c + chnl * 4; 73 | WARN_ON_ONCE(chnl >= 32); 74 | return SCD_BASE + 0x334 + chnl * 4; 75 | } 76 | 77 | static inline void iwl_scd_txq_set_inactive(IWLTransport *trans, 78 | u16 txq_id) 79 | { 80 | trans->iwlSetBitsPRPH(SCD_QUEUE_STATUS_BITS(txq_id), 81 | (0 << SCD_QUEUE_STTS_REG_POS_ACTIVE)| 82 | (1 << SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); 83 | } 84 | 85 | #endif /* IWLSCD_h */ 86 | -------------------------------------------------------------------------------- /AppleIntelWifiAdapter/trans/IWLTransOps.h: -------------------------------------------------------------------------------- 1 | // 2 | // IWLTransOps.h 3 | // AppleIntelWifiAdapter 4 | // 5 | // Created by 钟先耀 on 2020/1/13. 6 | // Copyright © 2020 钟先耀. All rights reserved. 7 | // 8 | 9 | #ifndef IWLTransOps_h 10 | #define IWLTransOps_h 11 | 12 | #include 13 | #include "IWLTransport.hpp" 14 | #include "IWLDevice.hpp" 15 | #include "Mvm.h" 16 | 17 | class IWLTransOps { 18 | 19 | public: 20 | 21 | IWLTransOps() {} 22 | IWLTransOps(IWLTransport *trans); 23 | virtual ~IWLTransOps() {} 24 | 25 | void nicConfig(); 26 | 27 | int startHW(); 28 | 29 | bool setHWRFKillState(bool state); 30 | 31 | void setRfKillState(bool state);//iwl_trans_pcie_rf_kill 32 | 33 | void handleStopRFKill(bool was_in_rfkill); 34 | 35 | void irqRfKillHandle();//iwl_pcie_handle_rfkill_irq 36 | 37 | bool checkHWRFKill(); 38 | 39 | bool fwRunning(); 40 | 41 | virtual int nicInit() = 0; 42 | 43 | /* 44 | * Start up NIC's basic functionality after it has been reset 45 | * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop()) 46 | * NOTE: This does not load uCode nor start the embedded processor 47 | */ 48 | virtual int apmInit() = 0; 49 | 50 | virtual void apmStop(bool op_mode_leave) = 0; 51 | 52 | virtual void fwAlive(UInt32 scd_addr) = 0; 53 | 54 | virtual int startFW(const struct fw_img *fw, bool run_in_rfkill) = 0; 55 | 56 | virtual void stopDevice() = 0; //iwl_trans_pcie_stop_device and iwl_trans_pcie_gen2_stop_device 57 | 58 | virtual void stopDeviceDirectly() = 0;//_iwl_trans_pcie_gen2_stop_device and _iwl_trans_pcie_stop_device 59 | 60 | virtual int forcePowerGating() = 0; 61 | 62 | 63 | private: 64 | 65 | 66 | public: 67 | IWLTransport *trans; 68 | 69 | 70 | private: 71 | 72 | }; 73 | 74 | #endif /* IWLTransOps_h */ 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Intel Wifi adapter on MacOS, the code is rewrite from Linux `iwlwifi` open source code. As of the last commit, the card initial routine is done. 2 | 3 | ## This repo will not be update since my new Intel WiFi driver project is here [itlwm](https://github.com/zxystd/itlwm). 4 | ## Intel Wifi team is continuing develope this project [AppleIntelWifi](https://github.com/AppleIntelWifi). 5 | 6 | **** 7 | 针对Apple未公开的AirPort程序进行的研究 8 | 9 | 目前基于10.15api 10 | 11 | 闲暇时间鼓捣。。。 12 | 13 | ## 使用方法, 14 | xcode编译完成后 15 | ``` Bash 16 | sudo chown -R root:wheel AppleIntelWifiAdapterV2.kext/ 17 | sudo kextload -v AppleIntelWifiAdapterV2.kext/ 18 | ``` 19 | 20 | ![图片1](https://github.com/zxystd/AppleIntelWifiAdapter/raw/master/img/QQ20191102-195821.png) 21 | ![图片2](https://github.com/zxystd/AppleIntelWifiAdapter/raw/master/img/QQ20191102-195905.png) 22 | -------------------------------------------------------------------------------- /img/QQ20191102-195821.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/img/QQ20191102-195821.png -------------------------------------------------------------------------------- /img/QQ20191102-195905.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxystd/AppleIntelWifiAdapter/0e64b8ad3aab303f264ea1f1099c27de8b3a7d46/img/QQ20191102-195905.png --------------------------------------------------------------------------------