// AppendMACAddr encodes and inserts an Hardware (MAC) address.
971581
func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte {
	dst = append(dst, byte(majorTypeTags|additionalTypeIntUint16))
	dst = append(dst, byte(additionalTypeTagNetworkAddr>>8))
	dst = append(dst, byte(additionalTypeTagNetworkAddr&0xff))
	return e.AppendBytes(dst, ha)
}
761214
func (w *WalletKit) NextAddr(ctx context.Context,
	req *AddrRequest) (*AddrResponse, error) {

	addr, err := w.cfg.Wallet.NewAddress(lnwallet.WitnessPubKey, false)
	if err != nil {
		return nil, err
	}

	return &AddrResponse{
		Addr: addr.String(),
	}, nil
}
639192
func (r *URIBuilder) ServerAddr(s string) *URIBuilder {
	r.serverAddr = s
	return r
}
427150
func lookupAddr(ctx context.Context, resolver *net.Resolver, host string) (string, error) {
	// Resolve the IP address or hostname to an IP address.
	addrs, err := resolver.LookupIPAddr(ctx, host)
	if err != nil {
		return "", errors.Wrap(err, "looking up IP addresses")
	}
	if len(addrs) == 0 {
		return "", fmt.Errorf("cannot resolve %q to an address", host)
	}

	// LookupIPAddr() can return a mix of IPv6 and IPv4
	// addresses. Return the first IPv4 address if possible.
	for _, addr := range addrs {
		if ip := addr.IP.To4(); ip != nil {
			return ip.String(), nil
		}
	}

	// No IPv4 address, return the first resolved address instead.
	return addrs[0].String(), nil
}
688280
func LinkSetHardwareAddr(link Link, hwaddr net.HardwareAddr) error {
	return pkgHandle.LinkSetHardwareAddr(link, hwaddr)
}
944184
func (c *Conn) RemoteAddr() net.Addr {
	if !c.ok() {
		return nil
	}
	return c.raddr
}
464887
func SetInterfaceMac(name string, macaddr string) error {
	iface, err := netlink.LinkByName(name)
	if err != nil {
		return err
	}
	hwaddr, err := net.ParseMAC(macaddr)
	if err != nil {
		return err
	}
	return netlink.LinkSetHardwareAddr(iface, hwaddr)
}
144668
func (m *Message) AddCC(emailAddr string) {
	m.cc = append(m.cc, emailAddr)
}
1271829
func validMacAddress(macaddr string) error {
	if _, err := net.ParseMAC(macaddr); err != nil {
		return fmt.Errorf("Can not parse MAC address: %s", err)
	}

	if _, err := FindInterfaceByMacAddress(macaddr); err == nil {
		return fmt.Errorf("MAC Address already assigned on the host: %s", macaddr)
	}

	return nil
}
1064786
func UnixAddrToSockaddr(addr *net.UnixAddr) (Sockaddr, int) {
	t := 0
	switch addr.Net {
	case "unix":
		t = SOCK_STREAM
	case "unixgram":
		t = SOCK_DGRAM
	case "unixpacket":
		t = SOCK_SEQPACKET
	default:
		return nil, 0
	}
	return &SockaddrUnix{Name: addr.Name}, t
}
1159863
func (a *Addresses) Append(address *Address) {
	a.addresses = append(a.addresses, address.address)
}
399960
func (c *connector) RemoteAddr() string {
	if nil != c.conn {
		return c.conn.RemoteAddr().String()
	}

	return ""
}
1111597
func GetBridgedDeviceName(macAddr string) (string, error) {
	stdout, _, err := runner.Run("list", "bridgedifs")
	if err != nil {
		return "", err
	}
	if matches := networkRegexp.FindAllString(stdout, -1); len(matches) > 0 {
		// Each match is a device
		for _, device := range matches {
			var mac, name string
			// Find the mac address and the name
			for _, line := range strings.Split(device, "\n") {
				if strings.Contains(line, "HardwareAddress") {
					mac = strings.TrimSpace(strings.TrimPrefix(line, "HardwareAddress:"))
				}
				if strings.Contains(line, "Name:") {
					name = strings.TrimSpace(strings.TrimPrefix(line, "Name:"))
				}
			}
			if strings.Contains(macAddr, mac) {
				return name, nil
			}
		}
	}
	return "", nil
}
1218447
func FindInterfaceByMacAddress(macaddr string) (*net.Interface, error) {
	if macaddr == "" {
		return nil, errors.New("Empty MAC address specified!")
	}

	ifcs, err := net.Interfaces()
	if err != nil {
		return nil, err
	}

	hwaddr, err := net.ParseMAC(macaddr)
	if err != nil {
		return nil, err
	}

	for _, ifc := range ifcs {
		if bytes.Equal(hwaddr, ifc.HardwareAddr) {
			return &ifc, nil
		}
	}

	return nil, fmt.Errorf("Could not find interface with MAC address on the host: %s", macaddr)
}
913779
func (brs *BranchRecoveryState) AddAddr(index uint32, addr btcutil.Address) {
	brs.addresses[index] = addr
}
128243
func (c Context) IPAddr(key string, ip net.IP) Context {
	c.l.context = enc.AppendIPAddr(enc.AppendKey(c.l.context, key), ip)
	return c
}
73979
func MacaddrSend(db XODB, v0 pgtypes.Macaddr) ([]byte, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.macaddr_send($1)`

	// run query
	var ret []byte
	XOLog(sqlstr, v0)
	err = db.QueryRow(sqlstr, v0).Scan(&ret)
	if err != nil {
		return nil, err
	}

	return ret, nil
}