Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ipf / mlo_rule.c
blobb9d837de0c778ffeb33b219c295bf49ad9b122f2
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 1993-2001 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 */
10 #include <sys/param.h>
11 #include <sys/systm.h>
12 #include <sys/conf.h>
13 #include <sys/proc.h>
14 #include <sys/ioctl.h>
15 #include <sys/kernel.h>
16 #include <sys/mbuf.h>
17 #include <sys/exec.h>
18 #include <sys/socket.h>
19 #include <net/if.h>
20 #include <netinet/in_systm.h>
21 #include <netinet/in.h>
22 #include <netinet/ip.h>
23 #include <net/route.h>
24 #include <netinet/ip_var.h>
25 #include <netinet/tcp.h>
26 #include <netinet/tcpip.h>
27 #include <sys/lkm.h>
28 #include "ip_compat.h"
29 #include "ip_fil.h"
30 #include "ip_rules.h"
33 #ifdef IPFILTER_LKM
35 static int ipfruleaction __P((struct lkm_table *, int));
37 int ipfrule __P((struct lkm_table *, int, int));
40 MOD_MISC("IPFilter Rules");
42 int ipfrule(lkmtp, cmd, ver)
43 struct lkm_table *lkmtp;
44 int cmd, ver;
46 DISPATCH(lkmtp, cmd, ver, ipfruleaction, ipfruleaction, ipfruleaction);
49 int lkmexists __P((struct lkm_table *)); /* defined in /sys/kern/kern_lkm.c */
51 static int ipfruleaction(lkmtp, cmd)
52 struct lkm_table *lkmtp;
53 int cmd;
55 int err = 0;
57 switch (cmd)
59 case LKM_E_LOAD :
60 if (lkmexists(lkmtp))
61 return EEXIST;
63 err = ipfrule_add();
64 if (!err)
65 fr_refcnt++;
66 break;
67 case LKM_E_UNLOAD :
68 err = ipfrule_remove();
69 if (!err)
70 fr_refcnt--;
71 break;
72 case LKM_E_STAT :
73 break;
74 default:
75 err = EIO;
76 break;
78 return err;
80 #endif /* IPFILTER_LKM */