xref: /freebsd/share/man/man9/ether_gen_addr.9 (revision 4e8d558c)
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.\" $FreeBSD$
30.\"
31.Dd June 1, 2021
32.Dt ETHER_GEN_ADDR 9
33.Os
34.Sh NAME
35.Nm ether_gen_addr
36.Nd "generate an arbitrary MAC address for use"
37.Sh SYNOPSIS
38.In sys/types.h
39.In sys/socket.h
40.In net/if.h
41.In net/if_var.h
42.In net/ethernet.h
43.Ft void
44.Fn ether_gen_addr "struct ifnet *ifp" "struct ether_addr *hwaddr"
45.Sh DESCRIPTION
46The
47.Fn ether_gen_addr
48function generates an arbitrary MAC address for use by an ethernet interface
49that does not have an assigned address.
50.Pp
51By default,
52.Nm
53attempts to generate a stable MAC address using the hostid of the jail that
54the
55.Ar ifp
56is being added to.
57During early boot, the hostid may not be set on machines that haven't yet
58populated
59.Pa /etc/hostid ,
60or on machines that do not use
61.Xr loader 8 .
62.Pp
63.Nm
64can fail to derive a MAC address due to memory allocation failure, or because
65the hostid has not been populated.
66In these cases, a locally-administered unicast MAC address will be randomly
67generated and returned via the
68.Ar hwaddr
69parameter.
70.Pp
71If
72.Nm
73succeeds, then it will return a MAC address in the FreeBSD Foundation OUI,
74.Dq 58:9c:fc ,
75via the
76.Ar hwaddr
77parameter.
78.Sh AUTHORS
79This manual page was written by
80.An Kyle Evans Aq Mt kevans@FreeBSD.org .
81