xref: /freebsd/share/examples/ipfilter/mlfk_rule.c (revision 2a63c3be158216222d89a073dcbd6a72ee4aab5a)
1 
2 /*
3  * Copyright (C) 2012 by Darren Reed.
4  *
5  * See the IPFILTER.LICENCE file for details on licencing.
6  *
7  * $Id$
8  */
9 
10 
11 #include <sys/param.h>
12 #include <sys/systm.h>
13 #include <sys/kernel.h>
14 #include <sys/module.h>
15 #include <sys/conf.h>
16 #include <sys/socket.h>
17 #include <sys/sysctl.h>
18 #include <net/if.h>
19 #include <netinet/in_systm.h>
20 #include <netinet/in.h>
21 
22 #include <netinet/ipl.h>
23 #include <netinet/ip_compat.h>
24 #include <netinet/ip_fil.h>
25 #include <netinet/ip_state.h>
26 #include <netinet/ip_nat.h>
27 #include <netinet/ip_auth.h>
28 #include <netinet/ip_frag.h>
29 
30 #include "ip_rules.h"
31 
32 extern ipf_main_softc_t ipfmain;
33 
34 static int
ipfrule_modevent(module_t mod,int type,void * unused)35 ipfrule_modevent(module_t mod, int type, void *unused)
36 {
37 	int error = 0;
38 
39 	switch (type)
40 	{
41 	case MOD_LOAD :
42 		error = ipfrule_add();
43 		if (!error)
44 			ipfmain.ipf_refcnt++;
45 		break;
46 	case MOD_UNLOAD :
47 		error = ipfrule_remove();
48 		if (!error)
49 			ipfmain.ipf_refcnt--;
50 		break;
51 	default:
52 		error = EINVAL;
53 		break;
54 	}
55 	return(error);
56 }
57 
58 static moduledata_t ipfrulemod = {
59 	"ipfrule",
60 	ipfrule_modevent,
61         0
62 };
63 DECLARE_MODULE(ipfrule, ipfrulemod, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY);
64 #ifdef	MODULE_DEPEND
65 MODULE_DEPEND(ipfrule, ipfilter, 1, 1, 1);
66 #endif
67 #ifdef	MODULE_VERSION
68 MODULE_VERSION(ipfrule, 1);
69 #endif
70