Ejemplo n.º 1
0
def interfaces():
    '''Returns a list of all network interface names'''
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = {}
    for interface in network_interfaces:
        interfaces[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
            SCNetworkInterfaceGetBSDName(interface),
            SCNetworkInterfaceGetHardwareAddressString(interface))
    return interfaces
Ejemplo n.º 2
0
def get_networkinterfacelist(network_interfaces):
    '''Returns a list of all network interface names'''
    d = {}
    for interface in network_interfaces:
        bsdName = SCNetworkInterfaceGetBSDName(interface)
        if 'en' in bsdName:
            d[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
                bsdName, SCNetworkInterfaceGetHardwareAddressString(interface))

    return d
Ejemplo n.º 3
0
def fact():
    """Returns a list of all network interface names"""
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = {}
    for interface in network_interfaces:
        interfaces[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
            SCNetworkInterfaceGetBSDName(interface),
            SCNetworkInterfaceGetHardwareAddressString(interface),
        )

    return {factoid: str(interfaces)}
Ejemplo n.º 4
0
def fact():
    '''Returns the mac address of this Mac'''
    net_config = SCDynamicStoreCreate(None, "net", None, None)
    states = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/IPv4")
    primary_interface = states["PrimaryInterface"]
    primary_device = [
        x for x in SCNetworkInterfaceCopyAll()
        if SCNetworkInterfaceGetBSDName(x) == primary_interface
    ][0]
    primary_MAC = SCNetworkInterfaceGetHardwareAddressString(primary_device)
    return {factoid: primary_MAC}
def get_wifi_interface():
    """Returns the name of the wifi interface."""
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = {}
    for interface in network_interfaces:
        interfaces[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
            SCNetworkInterfaceGetBSDName(interface),
            SCNetworkInterfaceGetHardwareAddressString(interface),
        )
    wifi_interface = None
    try:
        wifi_interface = interfaces["Wi-Fi"][0]
    except KeyError:
        pass
    return wifi_interface
Ejemplo n.º 6
0
def do_get_interface_info(scnetworkinterface):
    info = {}
    bsdname = SCNetworkInterfaceGetBSDName(scnetworkinterface)
    if bsdname:
        info["name"] = str(bsdname)
    hw = SCNetworkInterfaceGetHardwareAddressString(scnetworkinterface)
    if hw:
        info["hardware-address"] = str(hw)
    t = SCNetworkInterfaceGetInterfaceType(scnetworkinterface)
    if t:
        info["adapter-type"] = str(t)
    #SCNetworkInterfaceGetLocalizedDisplayName
    p = SCNetworkInterfaceGetSupportedProtocolTypes(scnetworkinterface)
    if p:
        info["protocols"] = tuple(str(x) for x in p)
    return info
Ejemplo n.º 7
0
def get_en0_mac():
    '''Returns the MAC layer address of en0'''
    for interface in SCNetworkInterfaceCopyAll():
        if SCNetworkInterfaceGetBSDName(interface) == "en0":
            return SCNetworkInterfaceGetHardwareAddressString(interface)
    return None