LINK_ADDR(3) BSD Programmer's Manual LINK_ADDR(3)NAME
link_addr, link_ntoa - elementary address specification routines for link
level access
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, if present.
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(4), followed by an optional interface address in
the form of groups of one or two hexadecimal digits separated by periods
(.), colons (:) or dashes (-). Each group represents a byte of address;
address bytes are filled left to right from low order bytes through high
order bytes.
When both an interface identifier and interface address are specified,
they must be separated by a colon (:). When only one is specified, the
colon is optional.
When calling link_addr() the sdl_len field of sdl must be set to indicate
the total available length of sdl.
RETURN VALUESLink_ntoa() always returns a null terminated string.
Link_addr() has no return value. If the input was successfully parsed
link_addr() will set the sdl_family, sdl_len, sdl_nlen and sdl_alen
fields of sdl appropriately. If there are errors parsing the input, or
insufficient space was available in sdl->sdl_data, link_addr() will clear
all the fields in sdl.
EXAMPLES
Both an interface identifier and an interface address may be specified
as:
le0:8.0.9.13.d.30
When specifying only an interface name the colon is optional:
le0
lo0:
The colon is also optional when specifying only an interface address:
fc.0.32.1c.8.5
:0.0.1f.3c.23.09
SEE ALSOgetnameinfo(3), iso(4), route(8).
HISTORY
The link_addr() and link_ntoa() functions appeared in 4.3BSD-Reno.
BUGS
When using a colon as a delimiter for the components of the address is is
possible that the parser could become confused. The use of periods as
the delimiter for the address components is preferred.
The returned values for link_ntoa reside in a static memory area.
4.4BSD April 29, 1998 2