18b4709faSBill Paul.\" Copyright (c) 1995 28b4709faSBill Paul.\" Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 38b4709faSBill Paul.\" 48b4709faSBill Paul.\" Redistribution and use in source and binary forms, with or without 58b4709faSBill Paul.\" modification, are permitted provided that the following conditions 68b4709faSBill Paul.\" are met: 78b4709faSBill Paul.\" 1. Redistributions of source code must retain the above copyright 88b4709faSBill Paul.\" notice, this list of conditions and the following disclaimer. 98b4709faSBill Paul.\" 2. Redistributions in binary form must reproduce the above copyright 108b4709faSBill Paul.\" notice, this list of conditions and the following disclaimer in the 118b4709faSBill Paul.\" documentation and/or other materials provided with the distribution. 128b4709faSBill Paul.\" 3. All advertising materials mentioning features or use of this software 138b4709faSBill Paul.\" must display the following acknowledgement: 148b4709faSBill Paul.\" This product includes software developed by Bill Paul. 158b4709faSBill Paul.\" 4. Neither the name of the author nor the names of any co-contributors 168b4709faSBill Paul.\" may be used to endorse or promote products derived from this software 178b4709faSBill Paul.\" without specific prior written permission. 188b4709faSBill Paul.\" 198b4709faSBill Paul.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 208b4709faSBill Paul.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 218b4709faSBill Paul.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 228b4709faSBill Paul.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 238b4709faSBill Paul.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 248b4709faSBill Paul.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 258b4709faSBill Paul.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 268b4709faSBill Paul.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 278b4709faSBill Paul.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 288b4709faSBill Paul.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 298b4709faSBill Paul.\" SUCH DAMAGE. 308b4709faSBill Paul.\" 317f3dea24SPeter Wemm.\" $FreeBSD$ 328b4709faSBill Paul.\" 338b4709faSBill Paul.Dd April 12, 1995 348b4709faSBill Paul.Dt ETHERS 3 35a307d598SRuslan Ermilov.Os 368b4709faSBill Paul.Sh NAME 378b4709faSBill Paul.Nm ethers , 388b4709faSBill Paul.Nm ether_line , 398b4709faSBill Paul.Nm ether_aton , 408b4709faSBill Paul.Nm ether_ntoa , 418b4709faSBill Paul.Nm ether_ntohost , 428b4709faSBill Paul.Nm ether_hostton 438b4709faSBill Paul.Nd Ethernet address conversion and lookup routines 4425bb73e0SAlexey Zelkin.Sh LIBRARY 4525bb73e0SAlexey Zelkin.Lb libc 468b4709faSBill Paul.Sh SYNOPSIS 4732eef9aeSRuslan Ermilov.In sys/types.h 4832eef9aeSRuslan Ermilov.In sys/socket.h 4932eef9aeSRuslan Ermilov.In net/ethernet.h 508b4709faSBill Paul.Ft int 516e641683SArchie Cobbs.Fn ether_line "const char *l" "struct ether_addr *e" "char *hostname" 528b4709faSBill Paul.Ft struct ether_addr * 536e641683SArchie Cobbs.Fn ether_aton "const char *a" 548b4709faSBill Paul.Ft char * 556e641683SArchie Cobbs.Fn ether_ntoa "const struct ether_addr *n" 568b4709faSBill Paul.Ft int 576e641683SArchie Cobbs.Fn ether_ntohost "char *hostname" "const struct ether_addr *e" 588b4709faSBill Paul.Ft int 596e641683SArchie Cobbs.Fn ether_hostton "const char *hostname" "struct ether_addr *e" 608b4709faSBill Paul.Sh DESCRIPTION 618b4709faSBill PaulThese functions operate on ethernet addresses using an 625c564baeSRuslan Ermilov.Vt ether_addr 638b4709faSBill Paulstructure, which is defined in the header file 64fe08efe6SRuslan Ermilov.In netinet/if_ether.h : 658b4709faSBill Paul.Bd -literal -offset indent 668b4709faSBill Paul/* 67453196ebSMike Pritchard * The number of bytes in an ethernet (MAC) address. 68453196ebSMike Pritchard */ 69453196ebSMike Pritchard#define ETHER_ADDR_LEN 6 70453196ebSMike Pritchard 71453196ebSMike Pritchard/* 728b4709faSBill Paul * Structure of a 48-bit Ethernet address. 738b4709faSBill Paul */ 748b4709faSBill Paulstruct ether_addr { 75453196ebSMike Pritchard u_char octet[ETHER_ADDR_LEN]; 768b4709faSBill Paul}; 778b4709faSBill Paul.Ed 788b4709faSBill Paul.Pp 798b4709faSBill PaulThe function 808b4709faSBill Paul.Fn ether_line 818b4709faSBill Paulscans 825c564baeSRuslan Ermilov.Fa l , 838b4709faSBill Paulan 848b4709faSBill Paul.Tn ASCII 858b4709faSBill Paulstring in 868b4709faSBill Paul.Xr ethers 5 878b4709faSBill Paulformat and sets 885c564baeSRuslan Ermilov.Fa e 898b4709faSBill Paulto the ethernet address specified in the string and 905c564baeSRuslan Ermilov.Fa h 91c6ff3a1bSSheldon Hearnto the hostname. 92c6ff3a1bSSheldon HearnThis function is used to parse lines from 938b4709faSBill Paul.Pa /etc/ethers 948b4709faSBill Paulinto their component parts. 958b4709faSBill Paul.Pp 968b4709faSBill PaulThe 978b4709faSBill Paul.Fn ether_aton 988b4709faSBill Paulfunction converts an 998b4709faSBill Paul.Tn ASCII 1008b4709faSBill Paulrepresentation of an ethernet address into an 1015c564baeSRuslan Ermilov.Vt ether_addr 102c6ff3a1bSSheldon Hearnstructure. 103c6ff3a1bSSheldon HearnLikewise, 1048b4709faSBill Paul.Fn ether_ntoa 1058b4709faSBill Paulconverts an ethernet address specified as an 1065c564baeSRuslan Ermilov.Vt ether_addr 1078b4709faSBill Paulstructure into an 1088b4709faSBill Paul.Tn ASCII 1098b4709faSBill Paulstring. 1108b4709faSBill Paul.Pp 1118b4709faSBill PaulThe 1128b4709faSBill Paul.Fn ether_ntohost 1138b4709faSBill Pauland 1148b4709faSBill Paul.Fn ether_hostton 1158b4709faSBill Paulfunctions map ethernet addresses to their corresponding hostnames 1168b4709faSBill Paulas specified in the 1178b4709faSBill Paul.Pa /etc/ethers 1188b4709faSBill Pauldatabase. 1191fae73b1SRuslan ErmilovThe 1208b4709faSBill Paul.Fn ether_ntohost 1211fae73b1SRuslan Ermilovfunction 1228b4709faSBill Paulconverts from ethernet address to hostname, and 1238b4709faSBill Paul.Fn ether_hostton 1248b4709faSBill Paulconverts from hostname to ethernet address. 1258b4709faSBill Paul.Sh RETURN VALUES 1261fae73b1SRuslan ErmilovThe 1278b4709faSBill Paul.Fn ether_line 1281fae73b1SRuslan Ermilovfunction 1298b4709faSBill Paulreturns zero on success and non-zero if it was unable to parse 1308b4709faSBill Paulany part of the supplied line 1315c564baeSRuslan Ermilov.Fa l . 1328b4709faSBill PaulIt returns the extracted ethernet address in the supplied 1335c564baeSRuslan Ermilov.Vt ether_addr 1348b4709faSBill Paulstructure 1355c564baeSRuslan Ermilov.Fa e 1368b4709faSBill Pauland the hostname in the supplied string 1375c564baeSRuslan Ermilov.Fa h . 1388b4709faSBill Paul.Pp 1398b4709faSBill PaulOn success, 1408b4709faSBill Paul.Fn ether_ntoa 1418b4709faSBill Paulreturns a pointer to a string containing an 1428b4709faSBill Paul.Tn ASCII 143c6ff3a1bSSheldon Hearnrepresentation of an ethernet address. 144c6ff3a1bSSheldon HearnIf it is unable to convert 1458b4709faSBill Paulthe supplied 1465c564baeSRuslan Ermilov.Vt ether_addr 147453196ebSMike Pritchardstructure, it returns a 148453196ebSMike Pritchard.Dv NULL 149c6ff3a1bSSheldon Hearnpointer. 150c6ff3a1bSSheldon HearnLikewise, 1518b4709faSBill Paul.Fn ether_aton 1528b4709faSBill Paulreturns a pointer to an 1535c564baeSRuslan Ermilov.Vt ether_addr 154453196ebSMike Pritchardstructure on success and a 155453196ebSMike Pritchard.Dv NULL 156453196ebSMike Pritchardpointer on failure. 1578b4709faSBill Paul.Pp 1588b4709faSBill PaulThe 1598b4709faSBill Paul.Fn ether_ntohost 1608b4709faSBill Pauland 1618b4709faSBill Paul.Fn ether_hostton 1628b4709faSBill Paulfunctions both return zero on success or non-zero if they were 1638b4709faSBill Paulunable to find a match in the 1648b4709faSBill Paul.Pa /etc/ethers 1658b4709faSBill Pauldatabase. 1668b4709faSBill Paul.Sh NOTES 1678b4709faSBill PaulThe user must insure that the hostname strings passed to the 1688b4709faSBill Paul.Fn ether_line , 1698b4709faSBill Paul.Fn ether_ntohost 1708b4709faSBill Pauland 1718b4709faSBill Paul.Fn ether_hostton 1728b4709faSBill Paulfunctions are large enough to contain the returned hostnames. 1738b4709faSBill Paul.Sh NIS INTERACTION 1748b4709faSBill PaulIf the 1758b4709faSBill Paul.Pa /etc/ethers 1768b4709faSBill Paulcontains a line with a single + in it, the 1778b4709faSBill Paul.Fn ether_ntohost 1788b4709faSBill Pauland 1798b4709faSBill Paul.Fn ether_hostton 1808b4709faSBill Paulfunctions will attempt to consult the NIS 1818b4709faSBill Paul.Pa ethers.byname 1828b4709faSBill Pauland 1838b4709faSBill Paul.Pa ethers.byaddr 1848b4709faSBill Paulmaps in addition to the data in the 1858b4709faSBill Paul.Pa /etc/ethers 1868b4709faSBill Paulfile. 1878b4709faSBill Paul.Sh SEE ALSO 188491a8429SRuslan Ermilov.Xr ethers 5 , 189491a8429SRuslan Ermilov.Xr yp 8 19024a0682cSRuslan Ermilov.Sh HISTORY 19124a0682cSRuslan ErmilovThis particular implementation of the 19224a0682cSRuslan Ermilov.Nm 19324a0682cSRuslan Ermilovlibrary functions were written for and first appeared in 19424a0682cSRuslan Ermilov.Fx 2.1 . 1958b4709faSBill Paul.Sh BUGS 1968b4709faSBill PaulThe 1978b4709faSBill Paul.Fn ether_aton 1988b4709faSBill Pauland 1998b4709faSBill Paul.Fn ether_ntoa 2008b4709faSBill Paulfunctions returns values that are stored in static memory areas 2018b4709faSBill Paulwhich may be overwritten the next time they are called. 202