2 * $Id: ether_mod_load.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
5 * FreeBSD 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
36 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/sysproto.h>
41 #include <sys/mount.h>
43 #include <sys/sysent.h>
46 #include <sys/errno.h>
47 #include <sys/queue.h>
49 #include <sys/socket.h>
50 #include <sys/socketvar.h>
51 #include <sys/protosw.h>
52 #include <sys/kernel.h>
53 #include <sys/sockio.h>
55 #include <net/if_dl.h>
56 #include <net/if_types.h>
57 #include <net/if_var.h>
58 #include <net/radix.h>
60 extern int ether_output_spoof __P((struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *));
61 int ether_spoof(struct lkm_table *lkp, int cmd, int ver);
66 etherspoof_load(struct lkm_table *lkp, int cmd)
74 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next)
76 if (ifp->if_output == ether_output)
78 ifp->if_output = ether_output_spoof;
79 printf("Interface %s fixed\n", ifp->if_name);
83 printf("Ethernet MAC Address Fix Loaded\n");
87 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next)
89 if (ifp->if_output == ether_output_spoof)
91 ifp->if_output = ether_output;
92 printf("Interface %s unfixed\n", ifp->if_name);
95 printf("Ethernet MAC Address Fix Unloaded\n");
105 int ether_spoof(struct lkm_table *lkp, int cmd, int ver)
107 DISPATCH(etherspoof, lkp, cmd, ver, etherspoof_load, etherspoof_load, lkm_nullcmd);