xref: /freebsd/share/man/man9/ether_gen_addr.9 (revision 069ac184)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (C) 2021 Kyle Evans <kevans@FreeBSD.org>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice(s), this list of conditions and the following disclaimer as
11.\"    the first lines of this file unmodified other than the possible
12.\"    addition of one or more copyright notices.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice(s), this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
18.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
21.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27.\" DAMAGE.
28.\"
29.Dd June 1, 2021
30.Dt ETHER_GEN_ADDR 9
31.Os
32.Sh NAME
33.Nm ether_gen_addr
34.Nd "generate an arbitrary MAC address for use"
35.Sh SYNOPSIS
36.In sys/types.h
37.In sys/socket.h
38.In net/if.h
39.In net/if_var.h
40.In net/ethernet.h
41.Ft void
42.Fn ether_gen_addr "struct ifnet *ifp" "struct ether_addr *hwaddr"
43.Sh DESCRIPTION
44The
45.Fn ether_gen_addr
46function generates an arbitrary MAC address for use by an ethernet interface
47that does not have an assigned address.
48.Pp
49By default,
50.Nm
51attempts to generate a stable MAC address using the hostid of the jail that
52the
53.Ar ifp
54is being added to.
55During early boot, the hostid may not be set on machines that haven't yet
56populated
57.Pa /etc/hostid ,
58or on machines that do not use
59.Xr loader 8 .
60.Pp
61.Nm
62can fail to derive a MAC address due to memory allocation failure, or because
63the hostid has not been populated.
64In these cases, a locally-administered unicast MAC address will be randomly
65generated and returned via the
66.Ar hwaddr
67parameter.
68.Pp
69If
70.Nm
71succeeds, then it will return a MAC address in the FreeBSD Foundation OUI,
72.Dq 58:9c:fc ,
73via the
74.Ar hwaddr
75parameter.
76.Sh AUTHORS
77This manual page was written by
78.An Kyle Evans Aq Mt kevans@FreeBSD.org .
79