1/* $FreeBSD$ */ 2 3/* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 */ 9/* #pragma ident "@(#)solaris.c 1.12 6/5/96 (C) 1995 Darren Reed"*/ 10 11/*typedef unsigned int spustate_t;*/ 12struct uio; 13 14#include <sys/types.h> 15#include <sys/cmn_err.h> 16#include <sys/kernel.h> 17#include <sys/systm.h> 18#include <sys/malloc.h> 19#include <sys/conf.h> 20#include <sys/callout.h> 21#include <sys/moddefs.h> 22#include <sys/io.h> 23#include <sys/wsio.h> 24#include <sys/param.h> 25#include <sys/errno.h> 26#include <sys/byteorder.h> 27#include <sys/socket.h> 28#include <sys/stropts.h> 29#include <net/if.h> 30#include <net/af.h> 31#include <net/route.h> 32#include <netinet/in.h> 33#include <netinet/in_systm.h> 34#include <netinet/if_ether.h> 35#include <netinet/ip.h> 36#include <netinet/ip_var.h> 37#include <netinet/tcp.h> 38#include <netinet/udp.h> 39#include <netinet/tcpip.h> 40#include <netinet/ip_icmp.h> 41 42#include "ip_compat.h" 43#include "ip_fil.h" 44#include "ip_rules.h" 45 46 47/* 48 * Driver Header 49 */ 50static drv_info_t ipf_drv_info = { 51 "IP Filter Rules", /* type */ 52 "pseudo", /* class */ 53 DRV_PSEUDO|DRV_SAVE_CONF|DRV_MP_SAFE, /* flags */ 54 -1, /* b_major */ 55 -1, /* c_major */ 56 NULL, /* cdio */ 57 NULL, /* gio_private */ 58 NULL, /* cdio_private */ 59}; 60 61 62extern struct mod_operations gio_mod_ops; 63static drv_info_t ipf_drv_info; 64extern struct mod_conf_data ipf_conf_data; 65 66static struct mod_type_data ipf_drv_link = { 67 IPL_VERSION, (void *)NULL 68}; 69 70static struct modlink ipf_mod_link[] = { 71 { &gio_mod_ops, (void *)&ipf_drv_link }, 72 { NULL, (void *)NULL } 73}; 74 75struct modwrapper ipf_wrapper = { 76 MODREV, 77 ipf_load, 78 ipf_unload, 79 (void (*)())NULL, 80 (void *)&ipf_conf_data, 81 ipf_mod_link 82}; 83 84 85static int ipf_load(void *arg) 86{ 87 int i; 88 89 i = ipfrule_add(); 90 if (!i) 91 ipf_refcnt--; 92#ifdef IPFDEBUG 93 printf("IP Filter Rules: ipfrule_add() = %d\n", i); 94#endif 95 if (!i) 96 cmn_err(CE_CONT, "IP Filter Rules: Loaded\n"); 97 return i; 98} 99 100 101static int ipf_unload(void *arg) 102{ 103 int i; 104 105 i = ipfrule_remove(); 106 if (!i) 107 ipf_refcnt--; 108#ifdef IPFDEBUG 109 printf("IP Filter Rules: ipfrule_remove() = %d\n", i); 110#endif 111 if (!i) 112 cmn_err(CE_CONT, "IP Filter Rules: Unloaded\n"); 113 return i; 114} 115