---
name: "linkaddr"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/linkaddr"
---

# linkaddr(3)

elementary address specification routines for link level access

## NAME

**link\_addr**, **link\_ntoa** – elementary address specification routines for link level access

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/socket.h\>**

**#include \<net/if\_dl.h\>**

*void*\

**link\_addr**(*const char \*addr*, *struct sockaddr\_dl \*sdl*);

*char* *\**\

**link\_ntoa**(*const struct sockaddr\_dl \*sdl*);

## DESCRIPTION

The routine **link\_addr**() interprets character strings representing link-level addresses, returning binary information suitable for use in system calls. The routine **link\_ntoa**() takes a link-level address and returns an ASCII string representing some of the information present, including the link level address itself, and the interface name or number, if present. This facility is experimental and is still subject to change.

For **link\_addr**(), the string *addr* may contain an optional network interface identifier of the form “name unit-number”, suitable for the first argument to [ifconfig(8)](/ifconfig/8.md), followed in all cases by a colon and an interface address in the form of groups of hexadecimal digits separated by periods. Each group represents a byte of address; address bytes are filled left to right from low order bytes through high order bytes.

Thus le0:8.0.9.13.d.30 represents an ethernet address to be transmitted on the first Lance ethernet interface.

## RETURN VALUES

The **link\_ntoa**() function always returns a null terminated string. The **link\_addr**() function has no return value. (See BUGS.)

## SEE ALSO

[getnameinfo(3)](/getnameinfo/3.md)

## HISTORY

The **link\_addr**() and **link\_ntoa**() functions appeared in 4.3BSD-Reno.

## BUGS

The returned values for link\_ntoa reside in a static memory area.

The function **link\_addr**() should diagnose improperly formed input, and there should be an unambiguous way to recognize this.

If the *sdl\_len* field of the link socket address *sdl* is 0, **link\_ntoa**() will not insert a colon before the interface address bytes. If this translated address is given to **link\_addr**() without inserting an initial colon, the latter will not interpret it correctly.
