Returns currently-set MAC address of given interface. This is distinct from the
interface's hardware MAC address.
@return {string}
423413
function getInterfaceMAC (device) {
  if (process.platform === 'darwin' || process.platform === 'linux') {
    let output
    try {
      output = cp.execSync(quote(['ifconfig', device]), { stdio: 'pipe' }).toString()
    } catch (err) {
      return null
    }

    const address = MAC_ADDRESS_RE.exec(output)
    return address && normalize(address[0])
  } else if (process.platform === 'win32') {
    console.error('No windows support for this method yet - PR welcome!')
  }
}
198492
public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostString(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
            throw new IllegalArgumentException("Invalid swift client object", e);
        }
    }
176368
def interface_by_macaddr(self, macaddr):
        '''
        
        '''
        macaddr = EthAddr(macaddr)
        for devname,iface in self._devinfo.items():
            if iface.ethaddr == macaddr:
                return iface
        raise KeyError("No device has MAC address {}".format(macaddr))
1356533
def get_mac_address_table(self):
        """"""
        mac_address_table = []

        switch_style = self.device.facts.get("switch_style", "")
        if switch_style == "VLAN_L2NG":
            mac_table = junos_views.junos_mac_address_table_switch_l2ng(self.device)
        elif switch_style == "BRIDGE_DOMAIN":
            mac_table = junos_views.junos_mac_address_table(self.device)
        else:  # switch_style == "VLAN"
            mac_table = junos_views.junos_mac_address_table_switch(self.device)

        try:
            mac_table.get()
        except RpcError as e:
            # Device hasn't got it's l2 subsystem running
            # Don't error but just return an empty result
            if "l2-learning subsystem" in e.message:
                return []
            else:
                raise

        mac_table_items = mac_table.items()

        default_values = {
            "mac": "",
            "interface": "",
            "vlan": 0,
            "static": False,
            "active": True,
            "moves": 0,
            "last_move": 0.0,
        }

        for mac_table_entry in mac_table_items:
            mac_entry = default_values.copy()
            mac_entry.update({elem[0]: elem[1] for elem in mac_table_entry[1]})
            mac = mac_entry.get("mac")

            # JUNOS returns '*' for Type = Flood
            if mac == "*":
                continue

            mac_entry["mac"] = napalm.base.helpers.mac(mac)
            mac_address_table.append(mac_entry)

        return mac_address_table
1232425
def set_mac(self, mac):
        
        mac = map(ord, mac)
        ifreq = struct.pack('16sH6B8', self.name, socket.AF_UNIX, *mac)
        fcntl.ioctl(self.fileno(), self.SIOCSIFHWADDR, ifreq)
124859
public static synchronized String getLocalIpAddress(int timeoutMs) {
    if (sLocalIP != null) {
      return sLocalIP;
    }

    try {
      InetAddress address = InetAddress.getLocalHost();
      LOG.debug("address: {} isLoopbackAddress: {}, with host {} {}", address,
          address.isLoopbackAddress(), address.getHostAddress(), address.getHostName());

      // Make sure that the address is actually reachable since in some network configurations
      // it is possible for the InetAddress.getLocalHost() call to return a non-reachable
      // address e.g. a broadcast address
      if (!isValidAddress(address, timeoutMs)) {
        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();

        // Make getNetworkInterfaces have the same order of network interfaces as listed on
        // unix-like systems. This optimization can help avoid to get some special addresses, such
        // as loopback address"127.0.0.1", virtual bridge address "192.168.122.1" as far as
        // possible.
        if (!WINDOWS) {
          List<NetworkInterface> netIFs = Collections.list(networkInterfaces);
          Collections.reverse(netIFs);
          networkInterfaces = Collections.enumeration(netIFs);
        }

        while (networkInterfaces.hasMoreElements()) {
          NetworkInterface ni = networkInterfaces.nextElement();
          Enumeration<InetAddress> addresses = ni.getInetAddresses();
          while (addresses.hasMoreElements()) {
            address = addresses.nextElement();

            // Address must not be link local or loopback. And it must be reachable
            if (isValidAddress(address, timeoutMs)) {
              sLocalIP = address.getHostAddress();
              return sLocalIP;
            }
          }
        }

        LOG.warn("Your hostname, {} resolves to a loopback/non-reachable address: {}, "
                  +  "but we couldn't find any external IP address!",
                  InetAddress.getLocalHost().getHostName(), address.getHostAddress());
      }

      sLocalIP = address.getHostAddress();
      return sLocalIP;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
988309
public byte[] getHardwareAddress()
  {
    if (CurrentTime.isTest() || System.getProperty("test.mac") != null) {
      return new byte[] { 10, 0, 0, 0, 0, 10 };
    }
    
    for (NetworkInterfaceBase nic : getNetworkInterfaces()) {
      if (! nic.isLoopback()) {
        return nic.getHardwareAddress();
      }
    }
    
    try {
      InetAddress localHost = InetAddress.getLocalHost();
      
      return localHost.getAddress();
    } catch (Exception e) {
      log.log(Level.FINER, e.toString(), e);
    }
    
    return new byte[0];
  }
860496
public static String getMacAddress() {
		try {
			List<String> macAddress = new ArrayList<String>();

			Enumeration<NetworkInterface> enumNetWorkInterface = NetworkInterface.getNetworkInterfaces();
			while (enumNetWorkInterface.hasMoreElements()) {
				NetworkInterface netWorkInterface = enumNetWorkInterface.nextElement();
				byte[] hardwareAddress = netWorkInterface.getHardwareAddress();
				if (hardwareAddress != null && netWorkInterface.isUp() && !netWorkInterface.isVirtual()) {
					String displayName = netWorkInterface.getDisplayName().toLowerCase();
					if (!displayName.contains("virtual") && !displayName.contains("tunnel")) {
						String strMac = "";
						for (int i = 0; i < hardwareAddress.length; i++) {
							strMac += String.format("%02X%s", hardwareAddress[i], (i < hardwareAddress.length - 1) ? "-" : "");
						}
						if (strMac.trim().length() > 0) {
							macAddress.add(strMac);
						}
					}
				}
			}
			return macAddress.toString().replace(",", ";").replace("[", "").replace("]", "");
		} catch (Exception e) {
			throw new JKException(e);
		}
	}
1139588
def get_mac(self):
        
        command = const.CMD_OPTIONS_RRQ
        command_string = b'MAC\x00'
        response_size = 1024

        cmd_response = self.__send_command(command, command_string, response_size)
        if cmd_response.get('status'):
            mac = self.__data.split(b'=', 1)[-1].split(b'\x00')[0]
            return mac.decode()
        else:
            raise ZKErrorResponse("can't read mac address")
1309323
public Address currentAddress(KeyChain.KeyPurpose purpose) {
        DeterministicKeyChain chain = getActiveKeyChain();
        Script.ScriptType outputScriptType = chain.getOutputScriptType();
        if (chain.isMarried()) {
            Address current = currentAddresses.get(purpose);
            if (current == null) {
                current = freshAddress(purpose);
                currentAddresses.put(purpose, current);
            }
            return current;
        } else if (outputScriptType == Script.ScriptType.P2PKH || outputScriptType == Script.ScriptType.P2WPKH) {
            return Address.fromKey(params, currentKey(purpose), outputScriptType);
        } else {
            throw new IllegalStateException(chain.getOutputScriptType().toString());
        }
    }
866363
def _find_interfaces_ip(mac):
    '''
    
    '''
    try:
        mac = napalm_helpers.convert(napalm_helpers.mac, mac)
    except AddrFormatError:
        return ('', '', [])

    all_interfaces = _get_mine('net.interfaces')
    all_ipaddrs = _get_mine('net.ipaddrs')

    for device, device_interfaces in six.iteritems(all_interfaces):
        if not device_interfaces.get('result', False):
            continue
        for interface, interface_details in six.iteritems(device_interfaces.get('out', {})):
            try:
                interface_mac = napalm_helpers.convert(napalm_helpers.mac, interface_details.get('mac_address'))
            except AddrFormatError:
                continue
            if mac != interface_mac:
                continue
            interface_ipaddrs = all_ipaddrs.get(device, {}).get('out', {}).get(interface, {})
            ip_addresses = interface_ipaddrs.get('ipv4', {})
            ip_addresses.update(interface_ipaddrs.get('ipv6', {}))
            interface_ips = ['{0}/{1}'.format(ip_addr,
                                              addr_details.get('prefix_length', '32'))
                             for ip_addr, addr_details in six.iteritems(ip_addresses)]
            return device, interface, interface_ips

    return ('', '', [])
978407
private Mac mac() throws IOException {
        try {
            final Mac mac = Mac.getInstance(this.alg);
            mac.init(this.key);
            return mac;
        } catch (final NoSuchAlgorithmException | InvalidKeyException err) {
            throw new IOException(err);
        }
    }
156085
def addr=(val)
      unless val.to_s =~ /^#{Util::RX_MAC_ADDR}$/
        raise(ArgumentError, "invalid mac address #{val.inspect}")
      end
      raw = Util.unhexify(val, /[:-]/)
      self[:data].to_ptr.write_string(raw, ETH_ADDR_LEN)
    end
627372
def get_device_mac(self) -> str:
        ''''''
        output, _ = self._execute(
            '-s', self.device_sn, 'shell', 'cat', '/sys/class/net/wlan0/address')
        return output.strip()
398641
function getLocalIPAddress () {
  const ifaces = os.networkInterfaces()

  let address = null
  let addresses = null
  let size = null
  let flag = false

  for (let ifname in ifaces) {
    addresses = ifaces[ifname]
    size = addresses.length

    while (size--) {
      let iface = addresses[size]
      if (iface.family === 'IPv4' && iface.internal === false) {
        address = iface.address
        flag = true
        break
      }
    }

    if (flag) break
  }
  return address
}
116427
function(callback){
      ubeacon.getMeshDeviceId( function( deviceAddress ){
        console.log( '[ubeacon] Device address is: ' + deviceAddress + ' (0x' + deviceAddress.toString(16) + ')' );
        callback(null);
      });
    }
458358
function (testOverride) {
    var ret = '127.0.0.1'
    os = testOverride || os
    var interfaces = os.networkInterfaces()

    Object.keys(interfaces).forEach(function (el) {
      interfaces[el].forEach(function (el2) {
        if (!el2.internal && el2.family === 'IPv4') {
          ret = el2.address
        }
      })
    })

    return ret
  }