mln_rule.c revision 254219
1/* 2 * Copyright (C) 2012 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 */ 7 8#include <sys/param.h> 9#include <sys/systm.h> 10#include <sys/conf.h> 11#include <sys/proc.h> 12#include <sys/ioctl.h> 13#include <sys/kernel.h> 14#include <sys/mbuf.h> 15#include <sys/exec.h> 16#include <sys/socket.h> 17#include <net/if.h> 18#include <netinet/in_systm.h> 19#include <netinet/in.h> 20#include <netinet/ip.h> 21#include <net/route.h> 22#include <netinet/ip_var.h> 23#include <netinet/tcp.h> 24#include <netinet/tcpip.h> 25#include <sys/lkm.h> 26#include "ip_compat.h" 27#include "ip_fil.h" 28#include "ip_rules.h" 29 30 31static int ipfruleaction __P((struct lkm_table *, int)); 32 33#ifdef IPFILTER_LKM 34# if NetBSD >= 199706 35int ipfrule_lkmentry __P((struct lkm_table *, int, int)); 36# else 37int xxxinit __P((struct lkm_table *, int, int)); 38# endif 39 40 41MOD_MISC("IPFilter Rules"); 42 43# if NetBSD >= 199706 44int ipfrule_lkmentry(lkmtp, cmd, ver) 45# else 46int xxxinit(lkmtp, cmd, ver) 47# endif 48 struct lkm_table *lkmtp; 49 int cmd, ver; 50{ 51 DISPATCH(lkmtp, cmd, ver, ipfruleaction, ipfruleaction, ipfruleaction); 52} 53 54static int ipfruleaction(lkmtp, cmd) 55 struct lkm_table *lkmtp; 56 int cmd; 57{ 58 int err = 0; 59 60 switch (cmd) 61 { 62 case LKM_E_LOAD : 63 if (lkmexists(lkmtp)) 64 return EEXIST; 65 66 err = ipfrule_add(); 67 if (!err) 68 ipf_refcnt++; 69 break; 70 case LKM_E_UNLOAD : 71 err = ipfrule_remove(); 72 if (!err) 73 ipf_refcnt--; 74 break; 75 case LKM_E_STAT : 76 break; 77 default: 78 err = EIO; 79 break; 80 } 81 return err; 82} 83#endif /* IPFILTER_LKM */ 84