[BACK]Return to ethers.3 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / net

File: [cvs.NetBSD.org] / src / lib / libc / net / ethers.3 (download)

Revision 1.13, Wed Apr 16 13:34:41 2003 UTC (21 years ago) by wiz
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, netbsd-3-base, netbsd-3-1-RELEASE, netbsd-3-1-RC4, netbsd-3-1-RC3, netbsd-3-1-RC2, netbsd-3-1-RC1, netbsd-3-1-1-RELEASE, netbsd-3-1, netbsd-3-0-RELEASE, netbsd-3-0-RC6, netbsd-3-0-RC5, netbsd-3-0-RC4, netbsd-3-0-RC3, netbsd-3-0-RC2, netbsd-3-0-RC1, netbsd-3-0-3-RELEASE, netbsd-3-0-2-RELEASE, netbsd-3-0-1-RELEASE, netbsd-3-0, netbsd-3, netbsd-2-base, netbsd-2-1-RELEASE, netbsd-2-1-RC6, netbsd-2-1-RC5, netbsd-2-1-RC4, netbsd-2-1-RC3, netbsd-2-1-RC2, netbsd-2-1-RC1, netbsd-2-1, netbsd-2-0-base, netbsd-2-0-RELEASE, netbsd-2-0-RC5, netbsd-2-0-RC4, netbsd-2-0-RC3, netbsd-2-0-RC2, netbsd-2-0-RC1, netbsd-2-0-3-RELEASE, netbsd-2-0-2-RELEASE, netbsd-2-0-1-RELEASE, netbsd-2-0, netbsd-2, mjf-devfs2-base, mjf-devfs2, matt-premerge-20091211, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-premerge-20101231, matt-mips64-base2, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, localcount-20160914, keiichi-mipv6-base, keiichi-mipv6, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, cube-autoconf-base, cube-autoconf, christos-time_t-nbase, christos-time_t-base, christos-time_t, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver, abandoned-netbsd-4-base, abandoned-netbsd-4
Changes since 1.12: +5 -5 lines

Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.

.\"	$NetBSD: ethers.3,v 1.13 2003/04/16 13:34:41 wiz Exp $
.\"
.\" Written by roland@frob.com.  Public domain.
.\"
.Dd November 2, 1997
.Dt ETHERS 3
.Os
.Sh NAME
.Nm ether_ntoa ,
.Nm ether_aton ,
.Nm ether_ntohost ,
.Nm ether_hostton ,
.Nm ether_line ,
.Nd get ethers entry
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/types.h
.In sys/socket.h
.In net/if.h
.In net/if_ether.h
.Ft char *
.Fn ether_ntoa "const struct ether_addr *e"
.Ft struct ether_addr *
.Fn ether_aton "const char *s"
.Ft int
.Fn ether_ntohost "char *hostname" "const struct ether_addr *e"
.Ft int
.Fn ether_hostton "const char *hostname" "struct ether_addr *e"
.Ft int
.Fn ether_line "const char *line" "struct ether_addr *e" "char *hostname"
.Sh DESCRIPTION
Ethernet addresses are represented by the
following structure:
.Bd -literal -offset indent
struct ether_addr {
        u_char  ether_addr_octet[6];
};
.Ed
.Pp
The
.Fn ether_ntoa
function converts this structure into an ASCII string of the form
``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated
by colons.  It returns a pointer to a static buffer that is reused for
each call.
The
.Fn ether_aton
converts an ASCII string of the same form and to a structure
containing the 6 octets of the address.  It returns a pointer to a
static structure that is reused for each call.
.Pp
The
.Fn ether_ntohost
and
.Fn ether_hostton
functions interrogate the data base mapping host names to Ethernet
addresses,
.Pa /etc/ethers .
The
.Fn ether_ntohost
function looks up the given Ethernet address and writes the associated
host name into the character buffer passed.
The
.Fn ether_hostton
function looks up the given host name and writes the associated
Ethernet address into the structure passed.  Both functions return
zero if they find the requested host name or address, and -1 if not.
Each call reads
.Pa /etc/ethers
from the beginning; if a + appears alone on a line in the file, then
.Fn ether_hostton
will consult the
.Pa ethers.byname
YP map, and
.Fn ether_ntohost
will consult the
.Pa ethers.byaddr
YP map.
.Pp
The
.Fn ether_line
function parses a line from the
.Pa /etc/ethers
file and fills in the passed ``struct ether_addr'' and character
buffer with the Ethernet address and host name on the line.  It
returns zero if the line was successfully parsed and -1 if not.
.Pp
The
.Fa hostname
buffer for
.Fn ether_line
and
.Fn ether_ntohost
should be at least
.Dv MAXHOSTNAMELEN
+ 1
characters long, to prevent a buffer overflow during parsing.
.Sh FILES
.Bl -tag -width /etc/ethers -compact
.It Pa /etc/ethers
.El
.Sh SEE ALSO
.Xr ethers 5
.Sh HISTORY
The
.Fn ether_ntoa ,
.Fn ether_aton ,
.Fn ether_ntohost ,
.Fn ether_hostton ,
and
.Fn ether_line
functions were adopted from
.Tn SunOS
and appeared in
.Nx 1.0 .
.Sh BUGS
The data space used by these functions is static; if future use
requires the data, it should be copied before any subsequent calls to
these functions overwrite it.