xref: /illumos-gate/usr/src/uts/common/inet/ipf/ip_log.c (revision ae7a42b1)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (C) 1997-2003 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
6ab25eeb5Syz  * $Id: ip_log.c,v 2.75.2.7 2005/06/11 07:47:44 darrenr Exp $
77c478bd9Sstevel@tonic-gate  *
87ddc9b1aSDarren Reed  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
97c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
1094bdecd9SRob Gulewich  *
1194bdecd9SRob Gulewich  * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
127c478bd9Sstevel@tonic-gate  */
137c478bd9Sstevel@tonic-gate 
147c478bd9Sstevel@tonic-gate #include <sys/param.h>
157c478bd9Sstevel@tonic-gate #if defined(KERNEL) || defined(_KERNEL)
167c478bd9Sstevel@tonic-gate # undef KERNEL
177c478bd9Sstevel@tonic-gate # undef _KERNEL
187c478bd9Sstevel@tonic-gate # define        KERNEL	1
197c478bd9Sstevel@tonic-gate # define        _KERNEL	1
207c478bd9Sstevel@tonic-gate #endif
217c478bd9Sstevel@tonic-gate #if defined(__NetBSD__) && (NetBSD >= 199905) && !defined(IPFILTER_LKM) && \
227c478bd9Sstevel@tonic-gate     defined(_KERNEL)
237c478bd9Sstevel@tonic-gate # include "opt_ipfilter_log.h"
247c478bd9Sstevel@tonic-gate #endif
25ab25eeb5Syz #if defined(__FreeBSD__) && !defined(IPFILTER_LKM)
26ab25eeb5Syz # if defined(_KERNEL)
27ab25eeb5Syz #  if defined(__FreeBSD_version) && (__FreeBSD_version >= 300000)
28ab25eeb5Syz #   include "opt_ipfilter.h"
297c478bd9Sstevel@tonic-gate #  endif
30ab25eeb5Syz # else
31ab25eeb5Syz #  include <osreldate.h>
327c478bd9Sstevel@tonic-gate # endif
337c478bd9Sstevel@tonic-gate #endif
34*ae7a42b1SToomas Soome #ifdef SOLARIS
35*ae7a42b1SToomas Soome #undef	SOLARIS
36*ae7a42b1SToomas Soome #endif
37*ae7a42b1SToomas Soome #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
38*ae7a42b1SToomas Soome #define	SOLARIS	(1)
39*ae7a42b1SToomas Soome #else
40*ae7a42b1SToomas Soome #define	SOLARIS	(0)
41ab25eeb5Syz #endif
42ab25eeb5Syz #include <sys/errno.h>
43ab25eeb5Syz #include <sys/types.h>
44ab25eeb5Syz #include <sys/file.h>
45ab25eeb5Syz #ifndef _KERNEL
46ab25eeb5Syz # include <stdio.h>
47ab25eeb5Syz # include <string.h>
48ab25eeb5Syz # include <stdlib.h>
49ab25eeb5Syz # include <ctype.h>
50ab25eeb5Syz # define _KERNEL
51ab25eeb5Syz # define KERNEL
527c478bd9Sstevel@tonic-gate # ifdef __OpenBSD__
537c478bd9Sstevel@tonic-gate struct file;
547c478bd9Sstevel@tonic-gate # endif
55ab25eeb5Syz # include <sys/uio.h>
56ab25eeb5Syz # undef _KERNEL
57ab25eeb5Syz # undef KERNEL
58ab25eeb5Syz #endif
59ab25eeb5Syz #if __FreeBSD_version >= 220000 && defined(_KERNEL)
60ab25eeb5Syz # include <sys/fcntl.h>
61ab25eeb5Syz # include <sys/filio.h>
62ab25eeb5Syz #else
63ab25eeb5Syz # include <sys/ioctl.h>
64ab25eeb5Syz #endif
65ab25eeb5Syz #include <sys/time.h>
66ab25eeb5Syz #if defined(_KERNEL)
67ab25eeb5Syz # include <sys/systm.h>
68ab25eeb5Syz # if defined(NetBSD) && (__NetBSD_Version__ >= 104000000)
69ab25eeb5Syz #  include <sys/proc.h>
707c478bd9Sstevel@tonic-gate # endif
71ab25eeb5Syz #endif /* _KERNEL */
72af5f29ddSToomas Soome #if !defined(SOLARIS) && !defined(__hpux) && !defined(linux)
73ab25eeb5Syz # if (NetBSD > 199609) || (OpenBSD > 199603) || (__FreeBSD_version >= 300000)
74ab25eeb5Syz #  include <sys/dirent.h>
757c478bd9Sstevel@tonic-gate # else
76ab25eeb5Syz #  include <sys/dir.h>
777c478bd9Sstevel@tonic-gate # endif
78ab25eeb5Syz # include <sys/mbuf.h>
79ab25eeb5Syz #else
80ab25eeb5Syz # if !defined(__hpux) && defined(_KERNEL)
81ab25eeb5Syz #  include <sys/filio.h>
82ab25eeb5Syz #  include <sys/cred.h>
83ab25eeb5Syz #  include <sys/ddi.h>
84ab25eeb5Syz #  include <sys/sunddi.h>
85ab25eeb5Syz #  include <sys/ksynch.h>
86ab25eeb5Syz #  include <sys/kmem.h>
87ab25eeb5Syz #  include <sys/mkdev.h>
88ab25eeb5Syz #  include <sys/dditypes.h>
89ab25eeb5Syz #  include <sys/cmn_err.h>
90ab25eeb5Syz # endif /* !__hpux */
91ab25eeb5Syz #endif /* !SOLARIS && !__hpux */
92ab25eeb5Syz #if !defined(linux)
937c478bd9Sstevel@tonic-gate # include <sys/protosw.h>
94ab25eeb5Syz #endif
95ab25eeb5Syz #include <sys/socket.h>
967c478bd9Sstevel@tonic-gate 
97ab25eeb5Syz #include <net/if.h>
98ab25eeb5Syz #ifdef sun
99ab25eeb5Syz # include <net/af.h>
100ab25eeb5Syz #endif
101ab25eeb5Syz #if __FreeBSD_version >= 300000
102ab25eeb5Syz # include <net/if_var.h>
103ab25eeb5Syz #endif
104ab25eeb5Syz #include <net/route.h>
105ab25eeb5Syz #include <netinet/in.h>
106ab25eeb5Syz #ifdef __sgi
107ab25eeb5Syz # include <sys/ddi.h>
108ab25eeb5Syz # ifdef IFF_DRVRLOCK /* IRIX6 */
109ab25eeb5Syz #  include <sys/hashing.h>
1107c478bd9Sstevel@tonic-gate # endif
111ab25eeb5Syz #endif
112ab25eeb5Syz #if !defined(__hpux) && !defined(linux) && \
113ab25eeb5Syz     !(defined(__sgi) && !defined(IFF_DRVRLOCK)) /*IRIX<6*/
114ab25eeb5Syz # include <netinet/in_var.h>
115ab25eeb5Syz #endif
116ab25eeb5Syz #include <netinet/in_systm.h>
117ab25eeb5Syz #include <netinet/ip.h>
118ab25eeb5Syz #include <netinet/tcp.h>
119ab25eeb5Syz #include <netinet/udp.h>
120ab25eeb5Syz #include <netinet/ip_icmp.h>
121ab25eeb5Syz #ifdef USE_INET6
122ab25eeb5Syz # include <netinet/icmp6.h>
123ab25eeb5Syz #endif
124ab25eeb5Syz #if !defined(linux)
1257c478bd9Sstevel@tonic-gate # include <netinet/ip_var.h>
1267c478bd9Sstevel@tonic-gate #endif
127ab25eeb5Syz #ifndef _KERNEL
128ab25eeb5Syz # include <syslog.h>
129ab25eeb5Syz #endif
130ab25eeb5Syz #include "netinet/ip_compat.h"
131ab25eeb5Syz #include <netinet/tcpip.h>
132ab25eeb5Syz #include "netinet/ip_fil.h"
133ab25eeb5Syz #include "netinet/ip_nat.h"
134ab25eeb5Syz #include "netinet/ip_frag.h"
135ab25eeb5Syz #include "netinet/ip_state.h"
136ab25eeb5Syz #include "netinet/ip_auth.h"
137f4b3ec61Sdh #include "netinet/ipf_stack.h"
138ab25eeb5Syz #if (__FreeBSD_version >= 300000) || defined(__NetBSD__)
139ab25eeb5Syz # include <sys/malloc.h>
140ab25eeb5Syz #endif
141ab25eeb5Syz /* END OF INCLUDES */
1427c478bd9Sstevel@tonic-gate 
143ab25eeb5Syz #ifdef	IPFILTER_LOG
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate # if defined(IPL_SELECT)
146ab25eeb5Syz #  include	<machine/sys/user.h>
147ab25eeb5Syz #  include	<sys/kthread_iface.h>
148ab25eeb5Syz #  define	READ_COLLISION	0x001
1497c478bd9Sstevel@tonic-gate 
150ab25eeb5Syz iplog_select_t	iplog_ss[IPL_LOGMAX+1];
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate extern int selwait;
1537c478bd9Sstevel@tonic-gate # endif /* IPL_SELECT */
1547c478bd9Sstevel@tonic-gate 
155f4b3ec61Sdh /* ipl_magic never changes */
156