Make Dt match installed file name.
[netbsd-mini2440.git] / dist / ipf / mlf_rule.c
blob731ef5e439c49d5c802d1bb41839ccd7fc280ffe
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 1993-2001 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
8 /*
9 * 29/12/94 Added code from Marc Huber <huber@fzi.de> to allow it to allocate
10 * its own major char number! Way cool patch!
14 #include <sys/param.h>
16 #if defined(__FreeBSD__) && (__FreeBSD__ > 1)
17 # ifdef IPFILTER_LKM
18 # include <osreldate.h>
19 # define ACTUALLY_LKM_NOT_KERNEL
20 # else
21 # include <sys/osreldate.h>
22 # endif
23 #endif
24 #include <sys/systm.h>
25 #if defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)
26 # include <sys/conf.h>
27 # include <sys/kernel.h>
28 # ifdef DEVFS
29 # include <sys/devfsext.h>
30 # endif /*DEVFS*/
31 #endif
32 #include <sys/conf.h>
33 #include <sys/file.h>
34 #if defined(__FreeBSD_version) && (__FreeBSD_version >= 300000)
35 # include <sys/lock.h>
36 #endif
37 #include <sys/stat.h>
38 #include <sys/proc.h>
39 #include <sys/kernel.h>
40 #include <sys/vnode.h>
41 #include <sys/namei.h>
42 #include <sys/malloc.h>
43 #include <sys/mount.h>
44 #include <sys/exec.h>
45 #include <sys/mbuf.h>
46 #if BSD >= 199506
47 # include <sys/sysctl.h>
48 #endif
49 #if (__FreeBSD_version >= 300000)
50 # include <sys/socket.h>
51 #endif
52 #if (__FreeBSD_version >= 199511)
53 #include <net/if.h>
54 #include <netinet/in_systm.h>
55 #include <netinet/in.h>
56 #include <netinet/ip.h>
57 #include <net/route.h>
58 #include <netinet/ip_var.h>
59 #include <netinet/tcp.h>
60 #include <netinet/tcpip.h>
61 #endif
62 #if (__FreeBSD__ > 1)
63 # include <sys/sysent.h>
64 #endif
65 #include <sys/lkm.h>
66 #include "netinet/ip_compat.h"
67 #include "netinet/ip_fil.h"
68 #include "netinet/ip_rules.h"
71 int xxxinit __P((struct lkm_table *, int, int));
73 #if !defined(__FreeBSD_version) || (__FreeBSD_version < 220000)
74 MOD_DEV(IPL_VERSION, LM_DT_CHAR, -1, &ipldevsw);
75 #endif
77 static int ipfrule_ioctl __P((struct lkm_table *, int));
79 #if defined(__FreeBSD_version) && (__FreeBSD_version < 220000)
81 int xxxinit(lkmtp, cmd, ver)
82 struct lkm_table *lkmtp;
83 int cmd, ver;
85 DISPATCH(lkmtp, cmd, ver, ipfrule_ioctl, ipfrule_ioctl, ipfrule_ioctl);
87 #else /* __FREEBSD_version >= 220000 */
88 # ifdef IPFILTER_LKM
89 # include <sys/exec.h>
91 # if (__FreeBSD_version >= 300000)
92 MOD_MISC(ipfrule);
93 # else
94 MOD_DECL(ipfrule);
97 static struct lkm_misc _module = {
98 LM_MISC,
99 LKM_VERSION,
100 "IP Filter rules",
103 # endif
106 int ipfrule __P((struct lkm_table *, int, int));
109 int ipfrule(lkmtp, cmd, ver)
110 struct lkm_table *lkmtp;
111 int cmd, ver;
113 # if (__FreeBSD_version >= 300000)
114 MOD_DISPATCH(ipfrule, lkmtp, cmd, ver, ipfrule_ioctl, ipfrule_ioctl,
115 ipfrule_ioctl);
116 # else
117 DISPATCH(lkmtp, cmd, ver, ipfrule_ioctl, ipfrule_ioctl, ipfrule_ioctl);
118 # endif
120 # endif /* IPFILTER_LKM */
123 int ipfrule_load(lkmtp, cmd)
124 struct lkm_table *lkmtp;
125 int cmd;
127 return ipfrule_add();
131 int ipfrule_unload(lkmtp, cmd)
132 struct lkm_table *lkmtp;
133 int cmd;
135 return ipfrule_remove();
139 static int ipfrule_ioctl(lkmtp, cmd)
140 struct lkm_table *lkmtp;
141 int cmd;
143 int err = 0;
145 switch (cmd)
147 case LKM_E_LOAD :
148 if (lkmexists(lkmtp))
149 return EEXIST;
151 err = ipfrule_load(lkmtp, cmd);
152 if (!err)
153 fr_refcnt++;
154 break;
155 case LKM_E_UNLOAD :
156 err = ipfrule_unload(lkmtp, cmd);
157 if (!err)
158 fr_refcnt--;
159 break;
160 case LKM_E_STAT :
161 break;
162 default:
163 err = EIO;
164 break;
166 return err;
168 #endif /* _FreeBSD_version */