LINK_ADDR(3) Library Functions Manual LINK_ADDR(3)

link_addr, link_ntoaelementary address specification routines for link level access

Standard C Library (libc, -lc)

#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);

The routine () interprets character strings representing link-level addresses, returning binary information suitable for use in system calls. The routine () 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.

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

The link_ntoa() function always returns a null terminated string. The link_addr() function has no return value. (See BUGS.)

getnameinfo(3)

The link_addr() and link_ntoa() functions appeared in 4.3BSD-Reno.

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.

February 28, 2007 macOS 15.0