Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ipf / mlso_rule.c
blobca15b48086d90ee0e97492d784cc60fcab842574
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2000 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
8 #pragma ident "@(#)Id: mlso_rule.c,v 2.4 2002/08/10 14:00:15 darrenr Exp"
10 #include <sys/systm.h>
11 #include <sys/types.h>
12 #include <sys/param.h>
13 #include <sys/errno.h>
14 #include <sys/uio.h>
15 #include <sys/buf.h>
16 #include <sys/modctl.h>
17 #include <sys/open.h>
18 #include <sys/kmem.h>
19 #include <sys/conf.h>
20 #include <sys/cmn_err.h>
21 #include <sys/stat.h>
22 #include <sys/cred.h>
23 #include <sys/dditypes.h>
24 #include <sys/stream.h>
25 #include <sys/poll.h>
26 #include <sys/autoconf.h>
27 #include <sys/byteorder.h>
28 #include <sys/socket.h>
29 #include <sys/dlpi.h>
30 #include <sys/stropts.h>
31 #include <sys/sockio.h>
32 #include <net/if.h>
33 #if SOLARIS2 >= 6
34 # include <net/if_types.h>
35 #endif
36 #include <net/af.h>
37 #include <net/route.h>
38 #include <netinet/in.h>
39 #include <netinet/in_systm.h>
40 #include <netinet/if_ether.h>
41 #include <netinet/ip.h>
42 #include <netinet/ip_var.h>
43 #include <netinet/tcp.h>
44 #include <netinet/udp.h>
45 #include <netinet/tcpip.h>
46 #include <netinet/ip_icmp.h>
47 #include <sys/ddi.h>
48 #include <sys/sunddi.h>
49 #include "ip_compat.h"
50 #include "ip_fil.h"
51 #include "ip_rules.h"
53 char _depends_on[] = "drv/ipf";
56 extern struct mod_ops mod_miscops;
57 static struct modlmisc ipfrulemod = {
58 &mod_miscops,
59 "IP Filter rules"
62 static struct modlinkage modlink1 = {
63 MODREV_1,
64 &ipfrulemod,
65 NULL
69 int _init()
71 int ipfruleinst;
73 ipfruleinst = mod_install(&modlink1);
74 #ifdef IPFRULEDEBUG
75 cmn_err(CE_NOTE, "IP Filter Rules: _init() = %d", ipfruleinst);
76 #endif
78 if (ipfruleinst == 0) {
79 if (fr_running >= 0) {
80 ipfruleinst = ipfrule_add();
81 if (!ipfruleinst)
82 fr_refcnt++;
83 else {
84 cmn_err(CE_NOTE,
85 "IP Filter Rules: ipfrule_add failed");
86 ipfruleinst = -1;
88 } else
89 ipfruleinst = -1;
91 if (ipfruleinst == 0)
92 cmn_err(CE_CONT, "IP Filter Rules: loaded\n");
93 return ipfruleinst;
97 int _fini(void)
99 int ipfruleinst;
101 ipfruleinst = mod_remove(&modlink1);
102 #ifdef IPFRULEDEBUG
103 cmn_err(CE_NOTE, "IP Filter Rules: _fini() = %d", ipfruleinst);
104 #endif
105 if (ipfruleinst == 0) {
106 ipfruleinst = ipfrule_remove();
107 if (!ipfruleinst)
108 fr_refcnt--;
109 else
110 ipfruleinst = -1;
112 if (ipfruleinst == 0)
113 cmn_err(CE_CONT, "IP Filter Rules: unloaded\n");
114 return ipfruleinst;
118 int _info(modinfop)
119 struct modinfo *modinfop;
121 int ipfruleinst;
123 ipfruleinst = mod_info(&modlink1, modinfop);
124 #ifdef IPFRULEDEBUG
125 cmn_err(CE_NOTE, "IP Filter Rules: _info(%x) = %x",
126 modinfop, ipfruleinst);
127 #endif
128 return ipfruleinst;