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 358b4709faSBill Paul.Os FreeBSD 2.1 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 478b4709faSBill Paul.Fd #include <sys/types.h> 488b4709faSBill Paul.Fd #include <sys/socket.h> 4913629194SGarrett Wollman.Fd #include <net/ethernet.h> 508b4709faSBill Paul.Ft int 518b4709faSBill Paul.Fn ether_line "char *l" "struct ether_addr *e" "char *hostname" 528b4709faSBill Paul.Ft struct ether_addr * 538b4709faSBill Paul.Fn ether_aton "char *a" 548b4709faSBill Paul.Ft char * 558b4709faSBill Paul.Fn ether_ntoa "struct ether_addr *n" 568b4709faSBill Paul.Ft int 578b4709faSBill Paul.Fn ether_ntohost "char *hostname" "struct ether_addr *e" 588b4709faSBill Paul.Ft int 598b4709faSBill Paul.Fn ether_hostton "char *hostname" "struct ether_addr *e" 608b4709faSBill Paul.Sh DESCRIPTION 618b4709faSBill PaulThese functions operate on ethernet addresses using an 628b4709faSBill Paul.Ar ether_addr 638b4709faSBill Paulstructure, which is defined in the header file 648b4709faSBill Paul.Aq Pa 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 828b4709faSBill Paul.Ar l , 838b4709faSBill Paulan 848b4709faSBill Paul.Tn ASCII 858b4709faSBill Paulstring in 868b4709faSBill Paul.Xr ethers 5 878b4709faSBill Paulformat and sets 888b4709faSBill Paul.Ar e 898b4709faSBill Paulto the ethernet address specified in the string and 908b4709faSBill Paul.Ar 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 1018b4709faSBill Paul.Ar ether_addr 102c6ff3a1bSSheldon Hearnstructure. 103c6ff3a1bSSheldon HearnLikewise, 1048b4709faSBill Paul.Fn ether_ntoa 1058b4709faSBill Paulconverts an ethernet address specified as an 1068b4709faSBill Paul.Ar 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. 1198b4709faSBill Paul.Fn ether_ntohost 1208b4709faSBill Paulconverts from ethernet address to hostname, and 1218b4709faSBill Paul.Fn ether_hostton 1228b4709faSBill Paulconverts from hostname to ethernet address. 1238b4709faSBill Paul.Sh RETURN VALUES 1248b4709faSBill Paul.Fn ether_line 1258b4709faSBill Paulreturns zero on success and non-zero if it was unable to parse 1268b4709faSBill Paulany part of the supplied line 1278b4709faSBill Paul.Ar l . 1288b4709faSBill PaulIt returns the extracted ethernet address in the supplied 1298b4709faSBill Paul.Ar ether_addr 1308b4709faSBill Paulstructure 1318b4709faSBill Paul.Ar e 1328b4709faSBill Pauland the hostname in the supplied string 1338b4709faSBill Paul.Ar h . 1348b4709faSBill Paul.Pp 1358b4709faSBill PaulOn success, 1368b4709faSBill Paul.Fn ether_ntoa 1378b4709faSBill Paulreturns a pointer to a string containing an 1388b4709faSBill Paul.Tn ASCII 139c6ff3a1bSSheldon Hearnrepresentation of an ethernet address. 140c6ff3a1bSSheldon HearnIf it is unable to convert 1418b4709faSBill Paulthe supplied 1428b4709faSBill Paul.Ar ether_addr 143453196ebSMike Pritchardstructure, it returns a 144453196ebSMike Pritchard.Dv NULL 145c6ff3a1bSSheldon Hearnpointer. 146c6ff3a1bSSheldon HearnLikewise, 1478b4709faSBill Paul.Fn ether_aton 1488b4709faSBill Paulreturns a pointer to an 1498b4709faSBill Paul.Ar ether_addr 150453196ebSMike Pritchardstructure on success and a 151453196ebSMike Pritchard.Dv NULL 152453196ebSMike Pritchardpointer on failure. 1538b4709faSBill Paul.Pp 1548b4709faSBill PaulThe 1558b4709faSBill Paul.Fn ether_ntohost 1568b4709faSBill Pauland 1578b4709faSBill Paul.Fn ether_hostton 1588b4709faSBill Paulfunctions both return zero on success or non-zero if they were 1598b4709faSBill Paulunable to find a match in the 1608b4709faSBill Paul.Pa /etc/ethers 1618b4709faSBill Pauldatabase. 1628b4709faSBill Paul.Sh NOTES 1638b4709faSBill PaulThe user must insure that the hostname strings passed to the 1648b4709faSBill Paul.Fn ether_line , 1658b4709faSBill Paul.Fn ether_ntohost 1668b4709faSBill Pauland 1678b4709faSBill Paul.Fn ether_hostton 1688b4709faSBill Paulfunctions are large enough to contain the returned hostnames. 1698b4709faSBill Paul.Sh NIS INTERACTION 1708b4709faSBill PaulIf the 1718b4709faSBill Paul.Pa /etc/ethers 1728b4709faSBill Paulcontains a line with a single + in it, the 1738b4709faSBill Paul.Fn ether_ntohost 1748b4709faSBill Pauland 1758b4709faSBill Paul.Fn ether_hostton 1768b4709faSBill Paulfunctions will attempt to consult the NIS 1778b4709faSBill Paul.Pa ethers.byname 1788b4709faSBill Pauland 1798b4709faSBill Paul.Pa ethers.byaddr 1808b4709faSBill Paulmaps in addition to the data in the 1818b4709faSBill Paul.Pa /etc/ethers 1828b4709faSBill Paulfile. 1838b4709faSBill Paul.Sh SEE ALSO 18478b0b234SMike Pritchard.Xr yp 4 , 18578b0b234SMike Pritchard.Xr ethers 5 1868b4709faSBill Paul.Sh BUGS 1878b4709faSBill Paul.Pp 1888b4709faSBill PaulThe 1898b4709faSBill Paul.Fn ether_aton 1908b4709faSBill Pauland 1918b4709faSBill Paul.Fn ether_ntoa 1928b4709faSBill Paulfunctions returns values that are stored in static memory areas 1938b4709faSBill Paulwhich may be overwritten the next time they are called. 1948b4709faSBill Paul.Sh HISTORY 1958b4709faSBill PaulThis particular implementation of the 1968b4709faSBill Paul.Nm ethers 197a2d402aaSMike Pritchardlibrary functions were written for and first appeared in 198a2d402aaSMike Pritchard.Fx 2.1 . 199