1*2fe8fb19SBen Gras.\" $NetBSD: linkaddr.3,v 1.10 2003/08/07 16:43:11 agc Exp $ 2*2fe8fb19SBen Gras.\" 3*2fe8fb19SBen Gras.\" Copyright (c) 1993 4*2fe8fb19SBen Gras.\" The Regents of the University of California. All rights reserved. 5*2fe8fb19SBen Gras.\" 6*2fe8fb19SBen Gras.\" This code is derived from software contributed to Berkeley by 7*2fe8fb19SBen Gras.\" Donn Seeley at BSDI. 8*2fe8fb19SBen Gras.\" 9*2fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without 10*2fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions 11*2fe8fb19SBen Gras.\" are met: 12*2fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright 13*2fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer. 14*2fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 15*2fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer in the 16*2fe8fb19SBen Gras.\" documentation and/or other materials provided with the distribution. 17*2fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors 18*2fe8fb19SBen Gras.\" may be used to endorse or promote products derived from this software 19*2fe8fb19SBen Gras.\" without specific prior written permission. 20*2fe8fb19SBen Gras.\" 21*2fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22*2fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23*2fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24*2fe8fb19SBen Gras.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25*2fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26*2fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27*2fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28*2fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29*2fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30*2fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*2fe8fb19SBen Gras.\" SUCH DAMAGE. 32*2fe8fb19SBen Gras.\" 33*2fe8fb19SBen Gras.\" @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 34*2fe8fb19SBen Gras.\" 35*2fe8fb19SBen Gras.Dd July 28, 1993 36*2fe8fb19SBen Gras.Dt LINK_ADDR 3 37*2fe8fb19SBen Gras.Os 38*2fe8fb19SBen Gras.Sh NAME 39*2fe8fb19SBen Gras.Nm link_addr , 40*2fe8fb19SBen Gras.Nm link_ntoa 41*2fe8fb19SBen Gras.Nd elementary address specification routines for link level access 42*2fe8fb19SBen Gras.Sh LIBRARY 43*2fe8fb19SBen Gras.Lb libc 44*2fe8fb19SBen Gras.Sh SYNOPSIS 45*2fe8fb19SBen Gras.In sys/types.h 46*2fe8fb19SBen Gras.In sys/socket.h 47*2fe8fb19SBen Gras.In net/if_dl.h 48*2fe8fb19SBen Gras.Ft void 49*2fe8fb19SBen Gras.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" 50*2fe8fb19SBen Gras.Ft char * 51*2fe8fb19SBen Gras.Fn link_ntoa "const struct sockaddr_dl *sdl" 52*2fe8fb19SBen Gras.Sh DESCRIPTION 53*2fe8fb19SBen GrasThe routine 54*2fe8fb19SBen Gras.Fn link_addr 55*2fe8fb19SBen Grasinterprets character strings representing link-level addresses, 56*2fe8fb19SBen Grasreturning binary information suitable for use in system calls. 57*2fe8fb19SBen GrasThe routine 58*2fe8fb19SBen Gras.Fn link_ntoa 59*2fe8fb19SBen Grastakes a link-level address and returns an 60*2fe8fb19SBen Gras.Tn ASCII 61*2fe8fb19SBen Grasstring representing some of the information present, including the 62*2fe8fb19SBen Graslink level address itself, and the interface name or number, if present. 63*2fe8fb19SBen GrasThis facility is experimental and is still subject to change. 64*2fe8fb19SBen Gras.Pp 65*2fe8fb19SBen GrasPrior to a call to 66*2fe8fb19SBen Gras.Fn link_addr , 67*2fe8fb19SBen Gras.Fa sdl-\*[Gt]sdl_len 68*2fe8fb19SBen Grasmust be initialized to the size of the link-level socket structure, 69*2fe8fb19SBen Grastypically 70*2fe8fb19SBen Gras.Fa sizeof(struct sockaddr_dl) . 71*2fe8fb19SBen Gras.Pp 72*2fe8fb19SBen GrasFor 73*2fe8fb19SBen Gras.Fn link_addr , 74*2fe8fb19SBen Grasthe string 75*2fe8fb19SBen Gras.Fa addr 76*2fe8fb19SBen Grasmay contain 77*2fe8fb19SBen Grasan optional network interface identifier of the form 78*2fe8fb19SBen Gras.Dq "name unit-number" , 79*2fe8fb19SBen Grassuitable for the first argument to 80*2fe8fb19SBen Gras.Xr ifconfig 8 , 81*2fe8fb19SBen Grasfollowed in all cases by a colon and 82*2fe8fb19SBen Grasan interface address in the form of 83*2fe8fb19SBen Grasgroups of hexadecimal digits 84*2fe8fb19SBen Grasseparated by periods. 85*2fe8fb19SBen GrasEach group represents a byte of address; 86*2fe8fb19SBen Grasaddress bytes are filled left to right from 87*2fe8fb19SBen Graslow order bytes through high order bytes. 88*2fe8fb19SBen Gras.Pp 89*2fe8fb19SBen Gras.\" A regular expression may make this format clearer: 90*2fe8fb19SBen Gras.\" .Bd -literal -offset indent 91*2fe8fb19SBen Gras.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* 92*2fe8fb19SBen Gras.\" .Ed 93*2fe8fb19SBen Gras.\" .Pp 94*2fe8fb19SBen GrasThus 95*2fe8fb19SBen Gras.Li le0:8.0.9.13.d.30 96*2fe8fb19SBen Grasrepresents an ethernet address 97*2fe8fb19SBen Grasto be transmitted on the first Lance ethernet interface. 98*2fe8fb19SBen Gras.Sh RETURN VALUES 99*2fe8fb19SBen Gras.Fn link_ntoa 100*2fe8fb19SBen Grasalways returns a null terminated string. 101*2fe8fb19SBen Gras.Fn link_addr 102*2fe8fb19SBen Grashas no return value (See 103*2fe8fb19SBen Gras.Sx BUGS ) . 104*2fe8fb19SBen Gras.Sh SEE ALSO 105*2fe8fb19SBen Gras.Xr ethers 3 , 106*2fe8fb19SBen Gras.Xr iso 4 107*2fe8fb19SBen Gras.Sh HISTORY 108*2fe8fb19SBen GrasThe 109*2fe8fb19SBen Gras.Fn link_addr 110*2fe8fb19SBen Grasand 111*2fe8fb19SBen Gras.Fn link_ntoa 112*2fe8fb19SBen Grasfunctions appeared in 113*2fe8fb19SBen Gras.Bx 4.3 Reno . 114*2fe8fb19SBen Gras.Sh BUGS 115*2fe8fb19SBen GrasThe returned values for 116*2fe8fb19SBen Gras.Fn link_ntoa 117*2fe8fb19SBen Grasreside in a static memory area. 118*2fe8fb19SBen Gras.Pp 119*2fe8fb19SBen GrasThe function 120*2fe8fb19SBen Gras.Fn link_addr 121*2fe8fb19SBen Grasshould diagnose improperly formed input, and there should be an unambiguous 122*2fe8fb19SBen Grasway to recognize this. 123*2fe8fb19SBen Gras.Pp 124*2fe8fb19SBen GrasIf the 125*2fe8fb19SBen Gras.Va sdl_len 126*2fe8fb19SBen Grasfield of the link socket address 127*2fe8fb19SBen Gras.Fa sdl 128*2fe8fb19SBen Grasis 0, 129*2fe8fb19SBen Gras.Fn link_ntoa 130*2fe8fb19SBen Graswill not insert a colon before the interface address bytes. 131*2fe8fb19SBen GrasIf this translated address is given to 132*2fe8fb19SBen Gras.Fn link_addr 133*2fe8fb19SBen Graswithout inserting an initial colon, 134*2fe8fb19SBen Grasthe latter will not interpret it correctly. 135