1.\" Copyright (c) 1993 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Donn Seeley at BSDI. 6.\" 7.\" %sccs.include.redist.man% 8.\" 9.\" @(#)linkaddr.3 5.2 (Berkeley) 03/02/93 10.\" 11.Dd 12.Dt LINK_ADDR 3 13.Os BSD 4.4 14.Sh NAME 15.Nm link_addr , 16.Nm link_ntoa 17.Nd elementary address specification routines for link level access 18.Sh SYNOPSIS 19.Fd #include <sys/types.h> 20.Fd #include <sys/socket.h> 21.Fd #include <net/if_dl.h> 22.Ft void 23.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" 24.Ft char * 25.Fn link_ntoa "const struct sockaddr_dl *sdl" 26.Sh DESCRIPTION 27The routine 28.Fn link_addr 29interprets character strings representing 30link-level addresses, returning binary information suitable 31for use in system calls. 32The routine 33.Fn link_ntoa 34takes 35a link-level 36address and returns an 37.Tn ASCII 38string representing some of the information present, 39including the link level address itself, and the interface name 40or number, if present. 41This facility is experimental and is 42still subject to change. 43.Pp 44For 45.Fn link_addr , 46the string 47.Fa addr 48may contain 49an optional network interface identifier of the form 50.Dq "name unit-number" , 51suitable for the first argument to 52.Xr ifconfig 4 , 53followed in all cases by a colon and 54an interface address in the form of 55groups of hexadecimal digits 56separated by periods. 57Each group represents a byte of address; 58address bytes are filled left to right from 59low order bytes through high order bytes. 60.Pp 61.\" A regular expression may make this format clearer: 62.\" .Bd -literal -offset indent 63.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* 64.\" .Ed 65.\" .Pp 66Thus 67.Li le0:8.0.9.13.d.30 68represents an ethernet address 69to be transmitted on the first Lance ethernet interface. 70.Sh RETURN VALUES 71.Fn link_ntoa 72always returns a null terminated string. 73.Fn link_addr 74has no return value. 75(See 76.Sx BUGS . ) 77.Sh SEE ALSO 78.Xr iso 4 , 79.Sh HISTORY 80The 81.Fn link_addr 82and 83.Fn link_ntoa 84functions appeared in 85.Bx 4.3 Reno . 86.Sh BUGS 87The returned values for link_ntoa 88reside in a static memory area. 89.Pp 90The function 91.Fn link_addr 92should diagnose improperly formed input, and there should be an unambiguous 93way to recognize this. 94.Pp 95If the 96.Va sdl_len 97field of the link socket address 98.Fa sdl 99is 0, 100.Fn link_ntoa 101will not insert a colon before the interface address bytes. 102If this translated address is given to 103.Fn link_addr 104without inserting an initial colon, 105the latter will not interpret it correctly. 106