157741Ssklower.\" Copyright (c) 1993 The Regents of the University of California. 257741Ssklower.\" 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*58387Sbostic.\" @(#)linkaddr.3 5.2 (Berkeley) 03/02/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 36*58387Sbosticaddress and returns an 3757741Ssklower.Tn ASCII 38*58387Sbosticstring representing some of the information present, 39*58387Sbosticincluding the link level address itself, and the interface name 40*58387Sbosticor number, if present. 41*58387SbosticThis facility is experimental and is 42*58387Sbosticstill subject to change. 4357741Ssklower.Pp 44*58387SbosticFor 45*58387Sbostic.Fn link_addr , 46*58387Sbosticthe string 47*58387Sbostic.Fa addr 48*58387Sbosticmay contain 49*58387Sbostican optional network interface identifier of the form 50*58387Sbostic.Dq "name unit-number" , 5157741Ssklowersuitable for the first argument to 52*58387Sbostic.Xr ifconfig 4 , 53*58387Sbosticfollowed in all cases by a colon and 54*58387Sbostican interface address in the form of 55*58387Sbosticgroups of hexadecimal digits 56*58387Sbosticseparated by periods. 57*58387SbosticEach group represents a byte of address; 58*58387Sbosticaddress bytes are filled left to right from 59*58387Sbosticlow order bytes through high order bytes. 6057741Ssklower.Pp 61*58387Sbostic.\" A regular expression may make this format clearer: 62*58387Sbostic.\" .Bd -literal -offset indent 63*58387Sbostic.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* 64*58387Sbostic.\" .Ed 65*58387Sbostic.\" .Pp 66*58387SbosticThus 67*58387Sbostic.Li le0:8.0.9.13.d.30 68*58387Sbosticrepresents an ethernet address 69*58387Sbosticto 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. 89*58387Sbostic.Pp 9057741SsklowerThe function 9157741Ssklower.Fn link_addr 9257741Ssklowershould diagnose improperly formed input, and there should be an unambiguous 9357741Ssklowerway to recognize this. 94*58387Sbostic.Pp 95*58387SbosticIf the 96*58387Sbostic.Va sdl_len 97*58387Sbosticfield of the link socket address 98*58387Sbostic.Fa sdl 99*58387Sbosticis 0, 100*58387Sbostic.Fn link_ntoa 101*58387Sbosticwill not insert a colon before the interface address bytes. 102*58387SbosticIf this translated address is given to 103*58387Sbostic.Fn link_addr 104*58387Sbosticwithout inserting an initial colon, 105*58387Sbosticthe latter will not interpret it correctly. 106