/*
* Copyright (c) 2009 Theo de Raadt
* Copyright (c) 2020 Roy Marples
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* In order to obtain unique initial Ethernet address on a host,
* do some randomisation. It's not meant for anything but avoiding
* hard-coding an address.
*/
cprng_fast(&enaddr[3], 3);
/* Those steps are mandatory for an Ethernet driver. */
if_initialize(ifp);
ether_ifattach(ifp, enaddr);
if_register(ifp);
/* Notify our link state */
vether_mediachange(ifp);
/*
* The bridge has magically already done all the work for us,
* and we only need to discard the packets.
*/
static void
vether_start(struct ifnet *ifp)
{
struct mbuf *m;
for (;;) {
IFQ_DEQUEUE(&ifp->if_snd, m);
if (m == NULL)
break;
bpf_mtap(ifp, m, BPF_D_OUT);
m_freem(m);
if_statinc(ifp, if_opackets);
}
}
static void
vether_stop(struct ifnet *ifp, __unused int disable)
{
ifp->if_flags &= ~IFF_RUNNING;
}
static int
vether_ioctl(struct ifnet *ifp, unsigned long cmd, void *data)
{
int error = 0;
switch (cmd) {
case SIOCADDMULTI:
case SIOCDELMULTI:
break;