xref: /csrg-svn/lib/libc/net/linkaddr.3 (revision 64081)
1*64081Sbostic.\" Copyright (c) 1993
2*64081Sbostic.\"	The Regents of the University of California.  All rights reserved.
357741Ssklower.\"
457741Ssklower.\" This code is derived from software contributed to Berkeley by
557741Ssklower.\" Donn Seeley at BSDI.
657741Ssklower.\"
757741Ssklower.\" %sccs.include.redist.man%
857741Ssklower.\"
9*64081Sbostic.\"     @(#)linkaddr.3	8.1 (Berkeley) 07/28/93
1057741Ssklower.\"
1157741Ssklower.Dd
1257741Ssklower.Dt LINK_ADDR 3
1357741Ssklower.Os BSD 4.4
1457741Ssklower.Sh NAME
1557741Ssklower.Nm link_addr ,
1657741Ssklower.Nm link_ntoa
1757741Ssklower.Nd elementary address specification routines for link level access
1857741Ssklower.Sh SYNOPSIS
1957741Ssklower.Fd #include <sys/types.h>
2057741Ssklower.Fd #include <sys/socket.h>
2157741Ssklower.Fd #include <net/if_dl.h>
2257741Ssklower.Ft void
2357741Ssklower.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
2457741Ssklower.Ft char *
2557741Ssklower.Fn link_ntoa "const struct sockaddr_dl *sdl"
2657741Ssklower.Sh DESCRIPTION
2757741SsklowerThe routine
2857741Ssklower.Fn link_addr
2957741Ssklowerinterprets character strings representing
3057741Ssklowerlink-level addresses, returning binary information suitable
3157741Ssklowerfor use in system calls.
3257741SsklowerThe routine
3357741Ssklower.Fn link_ntoa
3457741Ssklowertakes
3557741Ssklowera link-level
3658387Sbosticaddress and returns an
3757741Ssklower.Tn ASCII
3858387Sbosticstring representing some of the information present,
3958387Sbosticincluding the link level address itself, and the interface name
4058387Sbosticor number, if present.
4158387SbosticThis facility is experimental and is
4258387Sbosticstill subject to change.
4357741Ssklower.Pp
4458387SbosticFor
4558387Sbostic.Fn link_addr ,
4658387Sbosticthe string
4758387Sbostic.Fa addr
4858387Sbosticmay contain
4958387Sbostican optional network interface identifier of the form
5058387Sbostic.Dq "name unit-number" ,
5157741Ssklowersuitable for the first argument to
5258387Sbostic.Xr ifconfig 4 ,
5358387Sbosticfollowed in all cases by a colon and
5458387Sbostican interface address in the form of
5558387Sbosticgroups of hexadecimal digits
5658387Sbosticseparated by periods.
5758387SbosticEach group represents a byte of address;
5858387Sbosticaddress bytes are filled left to right from
5958387Sbosticlow order bytes through high order bytes.
6057741Ssklower.Pp
6158387Sbostic.\" A regular expression may make this format clearer:
6258387Sbostic.\" .Bd -literal -offset indent
6358387Sbostic.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
6458387Sbostic.\" .Ed
6558387Sbostic.\" .Pp
6658387SbosticThus
6758387Sbostic.Li le0:8.0.9.13.d.30
6858387Sbosticrepresents an ethernet address
6958387Sbosticto be transmitted on the first Lance ethernet interface.
7057741Ssklower.Sh RETURN VALUES
7157741Ssklower.Fn link_ntoa
7257741Sskloweralways returns a null terminated string.
7357741Ssklower.Fn link_addr
7457741Ssklowerhas no return value.
7557741Ssklower(See
7657741Ssklower.Sx BUGS . )
7757741Ssklower.Sh SEE ALSO
7857741Ssklower.Xr iso 4 ,
7957741Ssklower.Sh HISTORY
8057741SsklowerThe
8157741Ssklower.Fn link_addr
8257741Ssklowerand
8357741Ssklower.Fn link_ntoa
8457741Ssklowerfunctions appeared in
8557741Ssklower.Bx 4.3 Reno  .
8657741Ssklower.Sh BUGS
8757741SsklowerThe returned values for link_ntoa
8857741Ssklowerreside in a static memory area.
8958387Sbostic.Pp
9057741SsklowerThe function
9157741Ssklower.Fn link_addr
9257741Ssklowershould diagnose improperly formed input, and there should be an unambiguous
9357741Ssklowerway to recognize this.
9458387Sbostic.Pp
9558387SbosticIf the
9658387Sbostic.Va sdl_len
9758387Sbosticfield of the link socket address
9858387Sbostic.Fa sdl
9958387Sbosticis 0,
10058387Sbostic.Fn link_ntoa
10158387Sbosticwill not insert a colon before the interface address bytes.
10258387SbosticIf this translated address is given to
10358387Sbostic.Fn link_addr
10458387Sbosticwithout inserting an initial colon,
10558387Sbosticthe latter will not interpret it correctly.
106