- NetBSD Manual Pages
LINK_ADDR(3) NetBSD Library Functions Manual LINK_ADDR(3)
Powered by man-cgi (2020-09-24).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
link_addr, link_ntoa -- elementary address specification routines for
link level access
Standard C Library (libc, -lc)
link_addr(const char *addr, struct sockaddr_dl *sdl);
link_ntoa(const struct sockaddr_dl *sdl);
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.
Prior to a call to link_addr(), sdl->sdl_len must be initialized to the
size of the link-level socket structure, typically sizeof(struct
For link_addr(), the string addr may contain an optional network inter-
face identifier of the form ``name unit-number'', suitable for the first
argument to ifconfig(8), followed in all cases by a colon and an inter-
face 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:22.214.171.124.d.30 represents an ethernet address to be transmitted
on the first Lance ethernet interface.
link_ntoa() always returns a null terminated string. link_addr() has no
return value (See BUGS).
The link_addr() and link_ntoa() functions appeared in 4.3BSD-Reno.
The returned string for link_ntoa() resides in a static memory area. If
it would overflow this area, link_ntoa() silently truncates the result.
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.
NetBSD 9.99 December 7, 2016 NetBSD 9.99