ip_fil.c revision 7663b81667fda05833f609eceac713f0a83c2347
/*
* Copyright (C) 1993-2001, 2003 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#if !defined(lint)
#endif
#ifndef SOLARIS
#endif
# define KERNEL 1
# define _KERNEL 1
#endif
#if defined(__FreeBSD__) && !defined(__FreeBSD_version)
# if defined(IPFILTER_LKM)
# ifndef __FreeBSD_cc_version
# include <osreldate.h>
# else
# if __FreeBSD_cc_version < 430000
# include <osreldate.h>
# endif
# endif
# endif
#endif
#ifdef _KERNEL
#else
# define _KERNEL
# ifdef __OpenBSD__
struct file;
# endif
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#ifdef __sgi
#endif
#if !SOLARIS
# else
# endif
#else
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#ifdef __hpux
# define _NET_ROUTE_INCLUDED
#endif
#ifdef sun
#endif
#if __FreeBSD_version >= 300000
#endif
#ifdef __sgi
# ifdef IFF_DRVRLOCK /* IRIX6 */
# endif
#endif
!defined(__hpux)
#endif
#include <netinet/in_systm.h>
#if defined(__osf__)
# include <netinet/tcp_timer.h>
#endif
#include <unistd.h>
#include <syslog.h>
#ifdef __hpux
#endif
#if SOLARIS2 >= 10
#include "ip_compat.h"
#include "ip_fil.h"
#include "ip_nat.h"
#include "ip_frag.h"
#include "ip_state.h"
#include "ip_proxy.h"
#include "ip_auth.h"
#else
#include "netinet/ip_compat.h"
#include "netinet/ip_state.h"
#include "netinet/ip_proxy.h"
#endif
#ifdef IPFILTER_SYNC
#endif
#ifdef IPFILTER_SCAN
#endif
#if SOLARIS2 >= 10
#include "ip_pool.h"
#else
#endif
#ifdef IPFILTER_COMPILED
# include "netinet/ip_rules.h"
#endif
#endif
#ifdef __hpux
struct rtentry;
#endif
#if !defined(__osf__)
#endif
#include "ipt.h"
static int nifs = 0;
struct sockaddr *));
struct sockaddr *));
#else
# if TRU64 >= 1885
# else
# endif
#endif
int iplattach()
{
fr_running = 1;
return 0;
}
int ipldetach()
{
fr_running = -1;
return 0;
}
static int frzerostats(data)
{
int error;
fr_getstat(&fio);
if (error)
return EFAULT;
return 0;
}
/*
* Filter ioctl interface.
*/
int dev;
#if defined(__NetBSD__) || defined(__OpenBSD__) || \
#else
int cmd;
#endif
int mode;
{
SPL_NET(s);
if (unit == IPL_LOGNAT) {
if (fr_running > 0)
else
SPL_X(s);
return error;
}
if (unit == IPL_LOGSTATE) {
if (fr_running > 0)
else
SPL_X(s);
return error;
}
if (unit == IPL_LOGAUTH) {
if (fr_running > 0) {
} else {
fr_active, 1);
}
} else {
}
} else
SPL_X(s);
return error;
}
if (unit == IPL_LOGSYNC) {
#ifdef IPFILTER_SYNC
if (fr_running > 0)
else
#endif
SPL_X(s);
return error;
}
if (unit == IPL_LOGSCAN) {
#ifdef IPFILTER_SCAN
if (fr_running > 0)
else
#endif
SPL_X(s);
return error;
}
if (unit == IPL_LOGLOOKUP) {
if (fr_running > 0)
else
SPL_X(s);
return error;
}
switch (cmd)
{
case FIONREAD :
#ifdef IPFILTER_LOG
sizeof(iplused[IPL_LOGIPF]));
#endif
break;
case SIOCFRENB :
else {
if (error)
break;
if (tmp)
else
}
break;
case SIOCSETFF :
else
break;
case SIOCGETFF :
break;
case SIOCFUNCL :
break;
case SIOCINAFR :
case SIOCRMAFR :
case SIOCADAFR :
case SIOCZRLST :
else
break;
case SIOCINIFR :
case SIOCRMIFR :
case SIOCADIFR :
else
break;
case SIOCSWAPA :
else {
}
break;
case SIOCGETFS :
fr_getstat(&fio);
break;
case SIOCFRZST :
else
break;
case SIOCIPFFL :
else {
if (!error) {
}
}
break;
#ifdef USE_INET6
case SIOCIPFL6 :
else {
if (!error) {
}
}
break;
#endif
case SIOCSTLCK :
if (error == 0) {
fr_state_lock = tmp;
fr_nat_lock = tmp;
fr_frag_lock = tmp;
fr_auth_lock = tmp;
} else
break;
#ifdef IPFILTER_LOG
case SIOCIPFFB :
else
break;
#endif /* IPFILTER_LOG */
case SIOCGFRST :
break;
case SIOCFRSYN :
else {
frsync();
}
break;
default :
break;
}
SPL_X(s);
return error;
}
void fr_forgetifp(ifp)
void *ifp;
{
register frentry_t *f;
f->fr_ifa = (void *)-1;
f->fr_ifa = (void *)-1;
f->fr_ifa = (void *)-1;
f->fr_ifa = (void *)-1;
#ifdef USE_INET6
f->fr_ifa = (void *)-1;
f->fr_ifa = (void *)-1;
f->fr_ifa = (void *)-1;
f->fr_ifa = (void *)-1;
#endif
}
void fr_resolvdest(fdp, v)
int v;
{
}
}
#else
# if TRU64 >= 1885
char *cp;
# else
# endif
#endif
struct mbuf *m;
struct sockaddr *s;
{
return 0;
}
static int write_output(ifp, m, s)
#else
# if TRU64 >= 1885
char *cp;
# else
# endif
#endif
struct mbuf *m;
struct sockaddr *s;
{
char fname[32];
int fd;
#else
#endif
if (fd == -1) {
perror("open");
return -1;
}
return 0;
}
char *name;
int v;
{
name = "anon0";
return ifp;
}
#else
name = "anon0";
return ifp;
}
#endif
if (!ifneta) {
if (!ifneta)
return NULL;
if (!ifneta[0]) {
return NULL;
}
nifs = 1;
} else {
old_ifneta = ifneta;
nifs++;
if (!ifneta) {
nifs = 0;
return NULL;
}
nifs--;
return NULL;
}
}
#else
;
if (*s && isdigit(*s)) {
} else {
}
#endif
return ifp;
}
char *get_ifname(ifp)
{
#if defined(__OpenBSD__) || defined(__NetBSD__)
#else
#endif
return ifname;
}
void init_ifp()
{
char fname[32];
int fd;
if (fd == -1)
perror("open");
else
}
#else
if (fd == -1)
perror("open");
else
}
#endif
}
{
if (!ifp)
return 0; /* no routing table out here */
# if TRU64 >= 1885
# else
# endif
#endif
return 0;
}
int fr_send_reset(fin)
{
verbose("- TCP RST sent\n");
return 0;
}
int type;
int dst;
{
verbose("- TCP RST sent\n");
return 0;
}
void frsync()
{
return;
}
void m_freem(m)
mb_t *m;
{
return;
}
mb_t *m;
{
}
{
char *start;
ioc = 0;
ioc++;
continue;
}
if (left > 0)
ioc++;
}
if (left > 0)
return EFAULT;
}
return 0;
}
{
static int iss_seq_off = 0;
/*
* Compute the base value of the ISS. It is a hash
* of (saddr, sport, daddr, dport, secret).
*/
/* MD5Update(&ctx, ipf_iss_secret, sizeof(ipf_iss_secret)); */
/*
* Now increment our "timer", and add it in to
* the computed value.
*
* XXX Use `addin'?
* XXX TCP_ISSINCR too large to use?
*/
iss_seq_off += 0x00010000;
newiss += iss_seq_off;
return newiss;
}
/* ------------------------------------------------------------------------ */
/* Function: fr_nextipid */
/* Returns: int - 0 == success, -1 == error (packet should be droppped) */
/* Parameters: fin(I) - pointer to packet information */
/* */
/* Returns the next IPv4 ID to use for this packet. */
/* ------------------------------------------------------------------------ */
{
MUTEX_EXIT(&ipf_rw);
return id;
}
{
}
#ifdef USE_INET6
{
}
#endif