.\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Donn Seeley at BSDI. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 .\" $Id: link_addr.3,v 1.1.1.1 1999-12-09 16:26:01 kuriyama Exp $ .\" .Dd June 17, 1996 .Dt LINK_ADDR 3 .Os BSD 4.4 .Sh 名称 .Nm link_addr , .Nm link_ntoa .Nd リンクレベルアクセス用基本アドレス定義ルーチン .Sh 書式 .Fd #include .Fd #include .Fd #include .Ft void .Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" .Ft char * .Fn link_ntoa "const struct sockaddr_dl *sdl" .Sh 解説 .Fn link_addr ルーチンは、リンクレベルアドレスを表す文字列を変換し、 システムコールで使用するのに適したバイナリ情報を返します。 .Fn link_ntoa ルーチンは、リンクレベルアドレスを引数に取り、リンクレベルアドレス自身、 インタフェース名、存在する場合はその番号などを含んだ現在の情報を示す .Tn ASCII 文字列を返します。 この機能は、まだ試用段階であり、変更される可能性があります。 .Pp .Fn link_addr のために、文字列 .Fa addr には、 .Xr ifconfig 8 の第一引数となりうる .Dq "name unit-number" という形の任意指定のネットワークインタフェース識別子を含むことができ、 その後にコロン、そしてピリオドで区切られた 16 進数の組の形の インタフェースアドレスが続きます。 それぞれの組はアドレスの 1 バイトを示しており、 アドレスバイトは左から右へ、 低位のバイトから高位のバイトで占められます。 .Pp .\" A regular expression may make this format clearer: .\" .Bd -literal -offset indent .\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* .\" .Ed .\" .Pp このように、 .Li le0:8.0.9.13.d.30 は初期の Lance イーサネットインタフェース上に 変換されるイーサネットアドレスを表します。 .Pp これらの関数を直接使うのは避けられる傾向があり、むしろ .Xr addr2ascii 3 インタフェースが使われます。しかし、このインタフェースは、まだ広くは 実装されていないので、 可搬性のあるプログラムでこのインタフェースに依存するわけにはいきません。 .Sh 戻り値 .Fn link_ntoa は、常にヌルで終了する文字列を返します。 .Fn link_addr 関数は戻り値を返しません。( .Sx バグ 参照のこと。) .Sh 関連項目 .Xr addr2ascii 3 .Sh 歴史 関数 .Fn link_addr および .Fn link_ntoa は .Bx 4.3-Reno から登場しています。 .Sh バグ .Fn link_ntoa の戻り値は静的なメモリ領域にあります。 .Pp 関数 .Fn link_addr は、不適切な形式の入力を診断する機能が必要であり、 これを認証する明快な方法が必要となります。 .Pp リンクソケットアドレスの .Va sdl_len フィールドが 0 の場合、 .Fn link_ntoa は、インタフェースアドレスバイトの前にコロンを挿入しません。 この変換されたアドレスが最初のコロンを挿入せずに .Fn link_addr に渡される場合、変換後のアドレスは正しく解釈されません。