xref: /freebsd/lib/libc/net/linkaddr.3 (revision e1f4e80c88a79061f195b21ac1a4c7e3768896c8)
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.\"
3558f0484fSRodney W. Grimes.\"     @(#)linkaddr.3	8.1 (Berkeley) 7/28/93
3658f0484fSRodney W. Grimes.\"
3758f0484fSRodney W. Grimes.Dd July 28, 1993
3858f0484fSRodney W. Grimes.Dt LINK_ADDR 3
3958f0484fSRodney W. Grimes.Os BSD 4.4
4058f0484fSRodney W. Grimes.Sh NAME
4158f0484fSRodney W. Grimes.Nm link_addr ,
4258f0484fSRodney W. Grimes.Nm link_ntoa
4358f0484fSRodney W. Grimes.Nd elementary address specification routines for link level access
4458f0484fSRodney W. Grimes.Sh SYNOPSIS
4558f0484fSRodney W. Grimes.Fd #include <sys/types.h>
4658f0484fSRodney W. Grimes.Fd #include <sys/socket.h>
4758f0484fSRodney W. Grimes.Fd #include <net/if_dl.h>
4858f0484fSRodney W. Grimes.Ft void
4958f0484fSRodney W. Grimes.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
5058f0484fSRodney W. Grimes.Ft char *
5158f0484fSRodney W. Grimes.Fn link_ntoa "const struct sockaddr_dl *sdl"
5258f0484fSRodney W. Grimes.Sh DESCRIPTION
5358f0484fSRodney W. GrimesThe routine
5458f0484fSRodney W. Grimes.Fn link_addr
5558f0484fSRodney W. Grimesinterprets character strings representing
5658f0484fSRodney W. Grimeslink-level addresses, returning binary information suitable
5758f0484fSRodney W. Grimesfor use in system calls.
5858f0484fSRodney W. GrimesThe routine
5958f0484fSRodney W. Grimes.Fn link_ntoa
6058f0484fSRodney W. Grimestakes
6158f0484fSRodney W. Grimesa link-level
6258f0484fSRodney W. Grimesaddress and returns an
6358f0484fSRodney W. Grimes.Tn ASCII
6458f0484fSRodney W. Grimesstring representing some of the information present,
6558f0484fSRodney W. Grimesincluding the link level address itself, and the interface name
6658f0484fSRodney W. Grimesor number, if present.
6758f0484fSRodney W. GrimesThis facility is experimental and is
6858f0484fSRodney W. Grimesstill subject to change.
6958f0484fSRodney W. Grimes.Pp
7058f0484fSRodney W. GrimesFor
7158f0484fSRodney W. Grimes.Fn link_addr ,
7258f0484fSRodney W. Grimesthe string
7358f0484fSRodney W. Grimes.Fa addr
7458f0484fSRodney W. Grimesmay contain
7558f0484fSRodney W. Grimesan optional network interface identifier of the form
7658f0484fSRodney W. Grimes.Dq "name unit-number" ,
7758f0484fSRodney W. Grimessuitable for the first argument to
78e1f4e80cSMike Pritchard.Xr ifconfig 8 ,
7958f0484fSRodney W. Grimesfollowed in all cases by a colon and
8058f0484fSRodney W. Grimesan interface address in the form of
8158f0484fSRodney W. Grimesgroups of hexadecimal digits
8258f0484fSRodney W. Grimesseparated by periods.
8358f0484fSRodney W. GrimesEach group represents a byte of address;
8458f0484fSRodney W. Grimesaddress bytes are filled left to right from
8558f0484fSRodney W. Grimeslow order bytes through high order bytes.
8658f0484fSRodney W. Grimes.Pp
8758f0484fSRodney W. Grimes.\" A regular expression may make this format clearer:
8858f0484fSRodney W. Grimes.\" .Bd -literal -offset indent
8958f0484fSRodney W. Grimes.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
9058f0484fSRodney W. Grimes.\" .Ed
9158f0484fSRodney W. Grimes.\" .Pp
9258f0484fSRodney W. GrimesThus
9358f0484fSRodney W. Grimes.Li le0:8.0.9.13.d.30
9458f0484fSRodney W. Grimesrepresents an ethernet address
9558f0484fSRodney W. Grimesto be transmitted on the first Lance ethernet interface.
9658f0484fSRodney W. Grimes.Sh RETURN VALUES
9758f0484fSRodney W. Grimes.Fn link_ntoa
9858f0484fSRodney W. Grimesalways returns a null terminated string.
9958f0484fSRodney W. Grimes.Fn link_addr
10058f0484fSRodney W. Grimeshas no return value.
10158f0484fSRodney W. Grimes(See
10258f0484fSRodney W. Grimes.Sx BUGS . )
10358f0484fSRodney W. Grimes.Sh SEE ALSO
10458f0484fSRodney W. Grimes.Xr iso 4 ,
10558f0484fSRodney W. Grimes.Sh HISTORY
10658f0484fSRodney W. GrimesThe
10758f0484fSRodney W. Grimes.Fn link_addr
10858f0484fSRodney W. Grimesand
10958f0484fSRodney W. Grimes.Fn link_ntoa
11058f0484fSRodney W. Grimesfunctions appeared in
11158f0484fSRodney W. Grimes.Bx 4.3 Reno  .
11258f0484fSRodney W. Grimes.Sh BUGS
11358f0484fSRodney W. GrimesThe returned values for link_ntoa
11458f0484fSRodney W. Grimesreside in a static memory area.
11558f0484fSRodney W. Grimes.Pp
11658f0484fSRodney W. GrimesThe function
11758f0484fSRodney W. Grimes.Fn link_addr
11858f0484fSRodney W. Grimesshould diagnose improperly formed input, and there should be an unambiguous
11958f0484fSRodney W. Grimesway to recognize this.
12058f0484fSRodney W. Grimes.Pp
12158f0484fSRodney W. GrimesIf the
12258f0484fSRodney W. Grimes.Va sdl_len
12358f0484fSRodney W. Grimesfield of the link socket address
12458f0484fSRodney W. Grimes.Fa sdl
12558f0484fSRodney W. Grimesis 0,
12658f0484fSRodney W. Grimes.Fn link_ntoa
12758f0484fSRodney W. Grimeswill not insert a colon before the interface address bytes.
12858f0484fSRodney W. GrimesIf this translated address is given to
12958f0484fSRodney W. Grimes.Fn link_addr
13058f0484fSRodney W. Grimeswithout inserting an initial colon,
13158f0484fSRodney W. Grimesthe latter will not interpret it correctly.
132