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