xref: /freebsd/lib/libc/net/linkaddr.3 (revision 1fae73b137bfc5a237d7258e3c667ba87a36b7ff)
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
367f3dea24SPeter Wemm.\" $FreeBSD$
3758f0484fSRodney W. Grimes.\"
38010b7c6cSGarrett Wollman.Dd June 17, 1996
3958f0484fSRodney W. Grimes.Dt LINK_ADDR 3
40a307d598SRuslan Ermilov.Os
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
4525bb73e0SAlexey Zelkin.Sh LIBRARY
4625bb73e0SAlexey Zelkin.Lb libc
4758f0484fSRodney W. Grimes.Sh SYNOPSIS
4832eef9aeSRuslan Ermilov.In sys/types.h
4932eef9aeSRuslan Ermilov.In sys/socket.h
5032eef9aeSRuslan Ermilov.In net/if_dl.h
5158f0484fSRodney W. Grimes.Ft void
5258f0484fSRodney W. Grimes.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
5358f0484fSRodney W. Grimes.Ft char *
5458f0484fSRodney W. Grimes.Fn link_ntoa "const struct sockaddr_dl *sdl"
5558f0484fSRodney W. Grimes.Sh DESCRIPTION
5658f0484fSRodney W. GrimesThe routine
5758f0484fSRodney W. Grimes.Fn link_addr
5858f0484fSRodney W. Grimesinterprets character strings representing
5958f0484fSRodney W. Grimeslink-level addresses, returning binary information suitable
6058f0484fSRodney W. Grimesfor use in system calls.
6158f0484fSRodney W. GrimesThe routine
6258f0484fSRodney W. Grimes.Fn link_ntoa
6358f0484fSRodney W. Grimestakes
6458f0484fSRodney W. Grimesa link-level
6558f0484fSRodney W. Grimesaddress and returns an
6658f0484fSRodney W. Grimes.Tn ASCII
6758f0484fSRodney W. Grimesstring representing some of the information present,
6858f0484fSRodney W. Grimesincluding the link level address itself, and the interface name
6958f0484fSRodney W. Grimesor number, if present.
7058f0484fSRodney W. GrimesThis facility is experimental and is
7158f0484fSRodney W. Grimesstill subject to change.
7258f0484fSRodney W. Grimes.Pp
7358f0484fSRodney W. GrimesFor
7458f0484fSRodney W. Grimes.Fn link_addr ,
7558f0484fSRodney W. Grimesthe string
7658f0484fSRodney W. Grimes.Fa addr
7758f0484fSRodney W. Grimesmay contain
7858f0484fSRodney W. Grimesan optional network interface identifier of the form
7958f0484fSRodney W. Grimes.Dq "name unit-number" ,
8058f0484fSRodney W. Grimessuitable for the first argument to
81e1f4e80cSMike Pritchard.Xr ifconfig 8 ,
8258f0484fSRodney W. Grimesfollowed in all cases by a colon and
8358f0484fSRodney W. Grimesan interface address in the form of
8458f0484fSRodney W. Grimesgroups of hexadecimal digits
8558f0484fSRodney W. Grimesseparated by periods.
8658f0484fSRodney W. GrimesEach group represents a byte of address;
8758f0484fSRodney W. Grimesaddress bytes are filled left to right from
8858f0484fSRodney W. Grimeslow order bytes through high order bytes.
8958f0484fSRodney W. Grimes.Pp
9058f0484fSRodney W. Grimes.\" A regular expression may make this format clearer:
9158f0484fSRodney W. Grimes.\" .Bd -literal -offset indent
9258f0484fSRodney W. Grimes.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
9358f0484fSRodney W. Grimes.\" .Ed
9458f0484fSRodney W. Grimes.\" .Pp
9558f0484fSRodney W. GrimesThus
9658f0484fSRodney W. Grimes.Li le0:8.0.9.13.d.30
9758f0484fSRodney W. Grimesrepresents an ethernet address
9858f0484fSRodney W. Grimesto be transmitted on the first Lance ethernet interface.
99010b7c6cSGarrett Wollman.Pp
100010b7c6cSGarrett WollmanThe direct use of these functions is deprecated in favor of the
101010b7c6cSGarrett Wollman.Xr addr2ascii 3
102010b7c6cSGarrett Wollmaninterface; however, portable programs cannot rely on the latter as it is
103010b7c6cSGarrett Wollmannot yet widely implemented.
10458f0484fSRodney W. Grimes.Sh RETURN VALUES
1051fae73b1SRuslan ErmilovThe
10658f0484fSRodney W. Grimes.Fn link_ntoa
1071fae73b1SRuslan Ermilovfunction
10858f0484fSRodney W. Grimesalways returns a null terminated string.
1091fae73b1SRuslan ErmilovThe
11058f0484fSRodney W. Grimes.Fn link_addr
1111fae73b1SRuslan Ermilovfunction
11258f0484fSRodney W. Grimeshas no return value.
11358f0484fSRodney W. Grimes(See
11458f0484fSRodney W. Grimes.Sx BUGS . )
115010b7c6cSGarrett Wollman.Sh SEE ALSO
116010b7c6cSGarrett Wollman.Xr addr2ascii 3
117e40f3f85SMike Pritchard.\" .Xr iso 4
11858f0484fSRodney W. Grimes.Sh HISTORY
11958f0484fSRodney W. GrimesThe
12058f0484fSRodney W. Grimes.Fn link_addr
12158f0484fSRodney W. Grimesand
12258f0484fSRodney W. Grimes.Fn link_ntoa
12358f0484fSRodney W. Grimesfunctions appeared in
12458f0484fSRodney W. Grimes.Bx 4.3 Reno  .
12558f0484fSRodney W. Grimes.Sh BUGS
12658f0484fSRodney W. GrimesThe returned values for link_ntoa
12758f0484fSRodney W. Grimesreside in a static memory area.
12858f0484fSRodney W. Grimes.Pp
12958f0484fSRodney W. GrimesThe function
13058f0484fSRodney W. Grimes.Fn link_addr
13158f0484fSRodney W. Grimesshould diagnose improperly formed input, and there should be an unambiguous
13258f0484fSRodney W. Grimesway to recognize this.
13358f0484fSRodney W. Grimes.Pp
13458f0484fSRodney W. GrimesIf the
13558f0484fSRodney W. Grimes.Va sdl_len
13658f0484fSRodney W. Grimesfield of the link socket address
13758f0484fSRodney W. Grimes.Fa sdl
13858f0484fSRodney W. Grimesis 0,
13958f0484fSRodney W. Grimes.Fn link_ntoa
14058f0484fSRodney W. Grimeswill not insert a colon before the interface address bytes.
14158f0484fSRodney W. GrimesIf this translated address is given to
14258f0484fSRodney W. Grimes.Fn link_addr
14358f0484fSRodney W. Grimeswithout inserting an initial colon,
14458f0484fSRodney W. Grimesthe latter will not interpret it correctly.
145