xref: /freebsd/lib/libc/net/linkaddr.3 (revision 010b7c6c74c7382441b6b574b2741b61c4a6bcc4)
158f0484fSRodney W. Grimes.\" Copyright (c) 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
558f0484fSRodney W. Grimes.\" Donn Seeley at BSDI.
658f0484fSRodney W. Grimes.\"
758f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
858f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
958f0484fSRodney W. Grimes.\" are met:
1058f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
1158f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
1258f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1358f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1458f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
1558f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
1658f0484fSRodney W. Grimes.\"    must display the following acknowledgement:
1758f0484fSRodney W. Grimes.\"	This product includes software developed by the University of
1858f0484fSRodney W. Grimes.\"	California, Berkeley and its contributors.
1958f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
2058f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
2158f0484fSRodney W. Grimes.\"    without specific prior written permission.
2258f0484fSRodney W. Grimes.\"
2358f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2458f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2558f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2658f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2758f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2858f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2958f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3058f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3158f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3258f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3358f0484fSRodney W. Grimes.\" SUCH DAMAGE.
3458f0484fSRodney W. Grimes.\"
35010b7c6cSGarrett Wollman.\"     From: @(#)linkaddr.3	8.1 (Berkeley) 7/28/93
36010b7c6cSGarrett Wollman.\"	$Id$
3758f0484fSRodney W. Grimes.\"
38010b7c6cSGarrett Wollman.Dd June 17, 1996
3958f0484fSRodney W. Grimes.Dt LINK_ADDR 3
4058f0484fSRodney W. Grimes.Os BSD 4.4
4158f0484fSRodney W. Grimes.Sh NAME
4258f0484fSRodney W. Grimes.Nm link_addr ,
4358f0484fSRodney W. Grimes.Nm link_ntoa
4458f0484fSRodney W. Grimes.Nd elementary address specification routines for link level access
4558f0484fSRodney W. Grimes.Sh SYNOPSIS
4658f0484fSRodney W. Grimes.Fd #include <sys/types.h>
4758f0484fSRodney W. Grimes.Fd #include <sys/socket.h>
4858f0484fSRodney W. Grimes.Fd #include <net/if_dl.h>
4958f0484fSRodney W. Grimes.Ft void
5058f0484fSRodney W. Grimes.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
5158f0484fSRodney W. Grimes.Ft char *
5258f0484fSRodney W. Grimes.Fn link_ntoa "const struct sockaddr_dl *sdl"
5358f0484fSRodney W. Grimes.Sh DESCRIPTION
5458f0484fSRodney W. GrimesThe routine
5558f0484fSRodney W. Grimes.Fn link_addr
5658f0484fSRodney W. Grimesinterprets character strings representing
5758f0484fSRodney W. Grimeslink-level addresses, returning binary information suitable
5858f0484fSRodney W. Grimesfor use in system calls.
5958f0484fSRodney W. GrimesThe routine
6058f0484fSRodney W. Grimes.Fn link_ntoa
6158f0484fSRodney W. Grimestakes
6258f0484fSRodney W. Grimesa link-level
6358f0484fSRodney W. Grimesaddress and returns an
6458f0484fSRodney W. Grimes.Tn ASCII
6558f0484fSRodney W. Grimesstring representing some of the information present,
6658f0484fSRodney W. Grimesincluding the link level address itself, and the interface name
6758f0484fSRodney W. Grimesor number, if present.
6858f0484fSRodney W. GrimesThis facility is experimental and is
6958f0484fSRodney W. Grimesstill subject to change.
7058f0484fSRodney W. Grimes.Pp
7158f0484fSRodney W. GrimesFor
7258f0484fSRodney W. Grimes.Fn link_addr ,
7358f0484fSRodney W. Grimesthe string
7458f0484fSRodney W. Grimes.Fa addr
7558f0484fSRodney W. Grimesmay contain
7658f0484fSRodney W. Grimesan optional network interface identifier of the form
7758f0484fSRodney W. Grimes.Dq "name unit-number" ,
7858f0484fSRodney W. Grimessuitable for the first argument to
79e1f4e80cSMike Pritchard.Xr ifconfig 8 ,
8058f0484fSRodney W. Grimesfollowed in all cases by a colon and
8158f0484fSRodney W. Grimesan interface address in the form of
8258f0484fSRodney W. Grimesgroups of hexadecimal digits
8358f0484fSRodney W. Grimesseparated by periods.
8458f0484fSRodney W. GrimesEach group represents a byte of address;
8558f0484fSRodney W. Grimesaddress bytes are filled left to right from
8658f0484fSRodney W. Grimeslow order bytes through high order bytes.
8758f0484fSRodney W. Grimes.Pp
8858f0484fSRodney W. Grimes.\" A regular expression may make this format clearer:
8958f0484fSRodney W. Grimes.\" .Bd -literal -offset indent
9058f0484fSRodney W. Grimes.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
9158f0484fSRodney W. Grimes.\" .Ed
9258f0484fSRodney W. Grimes.\" .Pp
9358f0484fSRodney W. GrimesThus
9458f0484fSRodney W. Grimes.Li le0:8.0.9.13.d.30
9558f0484fSRodney W. Grimesrepresents an ethernet address
9658f0484fSRodney W. Grimesto be transmitted on the first Lance ethernet interface.
97010b7c6cSGarrett Wollman.Pp
98010b7c6cSGarrett WollmanThe direct use of these functions is deprecated in favor of the
99010b7c6cSGarrett Wollman.Xr addr2ascii 3
100010b7c6cSGarrett Wollmaninterface; however, portable programs cannot rely on the latter as it is
101010b7c6cSGarrett Wollmannot yet widely implemented.
10258f0484fSRodney W. Grimes.Sh RETURN VALUES
10358f0484fSRodney W. Grimes.Fn link_ntoa
10458f0484fSRodney W. Grimesalways returns a null terminated string.
10558f0484fSRodney W. Grimes.Fn link_addr
10658f0484fSRodney W. Grimeshas no return value.
10758f0484fSRodney W. Grimes(See
10858f0484fSRodney W. Grimes.Sx BUGS . )
109010b7c6cSGarrett Wollman.Sh SEE ALSO
110010b7c6cSGarrett Wollman.Xr addr2ascii 3
111e40f3f85SMike Pritchard.\" .Xr iso 4
11258f0484fSRodney W. Grimes.Sh HISTORY
11358f0484fSRodney W. GrimesThe
11458f0484fSRodney W. Grimes.Fn link_addr
11558f0484fSRodney W. Grimesand
11658f0484fSRodney W. Grimes.Fn link_ntoa
11758f0484fSRodney W. Grimesfunctions appeared in
11858f0484fSRodney W. Grimes.Bx 4.3 Reno  .
11958f0484fSRodney W. Grimes.Sh BUGS
12058f0484fSRodney W. GrimesThe returned values for link_ntoa
12158f0484fSRodney W. Grimesreside in a static memory area.
12258f0484fSRodney W. Grimes.Pp
12358f0484fSRodney W. GrimesThe function
12458f0484fSRodney W. Grimes.Fn link_addr
12558f0484fSRodney W. Grimesshould diagnose improperly formed input, and there should be an unambiguous
12658f0484fSRodney W. Grimesway to recognize this.
12758f0484fSRodney W. Grimes.Pp
12858f0484fSRodney W. GrimesIf the
12958f0484fSRodney W. Grimes.Va sdl_len
13058f0484fSRodney W. Grimesfield of the link socket address
13158f0484fSRodney W. Grimes.Fa sdl
13258f0484fSRodney W. Grimesis 0,
13358f0484fSRodney W. Grimes.Fn link_ntoa
13458f0484fSRodney W. Grimeswill not insert a colon before the interface address bytes.
13558f0484fSRodney W. GrimesIf this translated address is given to
13658f0484fSRodney W. Grimes.Fn link_addr
13758f0484fSRodney W. Grimeswithout inserting an initial colon,
13858f0484fSRodney W. Grimesthe latter will not interpret it correctly.
139