CWNetwork获得WiFi安全模式

时间:2015-05-20 09:50:04

标签: objective-c corewlan

我正在尝试使用以下代码获取安全模式:

main()
{
    CWNetwork *network = [self.scanResults objectAtIndex:row];
    NSLog(@"%@", network);
    NSLog(@"%@", [self securityStringForNetwork:network]);
 }

- (NSString*)securityStringForNetwork:(CWNetwork *)network;
{
    NSString *securityString = @"Unknown";

    if ([network supportsSecurity:kCWSecurityNone])
        securityString = @"None";
    else if ([network supportsSecurity:kCWSecurityWEP])
        securityString = @"WEP";
    else if ([network supportsSecurity:kCWSecurityWPAPersonal])
        securityString = @"WPA Personal";
    else if ([network supportsSecurity:kCWSecurityWPAPersonalMixed])
        securityString = @"WPA Personal Mixed";
    else if ([network supportsSecurity:kCWSecurityWPA2Personal])
        securityString = @"WPA2 Personal";
    else if ([network supportsSecurity:kCWSecurityPersonal])
        securityString = @"Personal";
    else if ([network supportsSecurity:kCWSecurityDynamicWEP])
        securityString = @"Dynamic WEP";
    else if ([network supportsSecurity:kCWSecurityWPAEnterprise])
        securityString = @"WPA Enterprise";
    else if ([network supportsSecurity:kCWSecurityWPAEnterpriseMixed])
        securityString = @"WPA Enterprise Mixed";
    else if ([network supportsSecurity:kCWSecurityWPA2Enterprise])
        securityString = @"WPA2 Enterprise";
    else if ([network supportsSecurity:kCWSecurityEnterprise])
        securityString = @"Enterprise";

    return securityString;
}

第一个NSLog显示:

WPA2个人

,第二个NSLog显示:

WPA个人混合

我意识到supportsSecurity方法可能会在几种类型的安全性上返回YES。

如何获得网络的确切安全模式?

0 个答案:

没有答案