2 * $Id: ether_mod_load.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
5 * OpenBSD ether_mod_load.c - lkm replacement for ether_output
7 * Copyright (c) 1998, 1999, 2000 Mike D. Schiffman <mike@infonexus.com>
8 * Original code and idea 1997 Thomas Ptacek <tqbf@pobox.com>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/param.h>
37 #include <sys/systm.h>
39 #include <sys/mount.h>
43 #include <sys/errno.h>
44 #include <sys/queue.h>
46 #include <sys/socket.h>
47 #include <sys/socketvar.h>
48 #include <sys/protosw.h>
49 #include <sys/kernel.h>
50 #include <sys/sockio.h>
52 #include <net/if_dl.h>
53 #include <net/if_types.h>
54 #include <net/radix.h>
56 extern int ether_output_spoof __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *));
57 int ether_spoof(struct lkm_table *lkp, int cmd, int ver);
59 MOD_MISC("etherspoof");
62 etherspoof_load(struct lkm_table *lkp, int cmd)
70 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
72 if (ifp->if_output == ether_output)
74 ifp->if_output = ether_output_spoof;
75 printf("Interface %s fixed\n", ifp->if_xname);
79 printf("Ethernet MAC Address Fix Loaded\n");
83 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
85 if (ifp->if_output == ether_output_spoof)
87 ifp->if_output = ether_output;
88 printf("Interface %s unfixed\n", ifp->if_xname);
91 printf("Ethernet MAC Address Fix Unloaded\n");
101 int ether_spoof(struct lkm_table *lkp, int cmd, int ver)
103 DISPATCH(lkp, cmd, ver, etherspoof_load, etherspoof_load, lkm_nofunc);