ip_lookup.c revision bb1d9de55b0c95d4bd8ff7f06a294587a25a6c2e
/*
* Copyright (C) 2002-2003 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
# define KERNEL 1
# define _KERNEL 1
#endif
#if defined(__osf__)
# define _PROTO_NET_H_
#endif
#else
#endif
#if !defined(_KERNEL)
# include <string.h>
# define _KERNEL
# ifdef __OpenBSD__
struct file;
# endif
#endif
# ifdef __osf__
# endif
# include "radix_ipf_local.h"
# define _RADIX_H_
#endif
#if defined(__FreeBSD__)
#endif
#if defined(_KERNEL)
# endif
#endif
#include "netinet/ip_compat.h"
#include "netinet/ip_htable.h"
#include "netinet/ip_lookup.h"
#include "netinet/ipf_stack.h"
/* END OF INCLUDES */
#if !defined(lint)
static const char rcsid[] = "@(#)$Id: ip_lookup.c,v 2.35.2.7 2005/06/12 07:18:20 darrenr Exp $";
#endif
#ifdef IPFILTER_LOOKUP
/* ------------------------------------------------------------------------ */
/* Function: iplookup_init */
/* Returns: int - 0 = success, else error */
/* Parameters: Nil */
/* */
/* Initialise all of the subcomponents of the lookup infrstructure. */
/* ------------------------------------------------------------------------ */
int ip_lookup_init(ifs)
{
return -1;
return 0;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_unload */
/* Returns: int - 0 = success, else error */
/* Parameters: Nil */
/* */
/* Free up all pool related memory that has been allocated whilst IPFilter */
/* has been running. Also, do any other deinitialisation required such */
/* ip_lookup_init() can be called again, safely. */
/* ------------------------------------------------------------------------ */
void ip_lookup_unload(ifs)
{
ifs->ifs_ip_lookup_inited = 0;
}
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_ioctl */
/* Returns: int - 0 = success, else error */
/* space. */
/* cmd(I) - ioctl command number */
/* mode(I) - file mode bits used with open */
/* */
/* Handle ioctl commands sent to the ioctl device. For the most part, this */
/* involves just calling another function to handle the specifics of each */
/* command. */
/* ------------------------------------------------------------------------ */
void *ctx;
{
int err;
SPL_INT(s);
SPL_NET(s);
switch (cmd)
{
case SIOCLOOKUPADDNODE :
case SIOCLOOKUPADDNODEW :
break;
case SIOCLOOKUPDELNODE :
case SIOCLOOKUPDELNODEW :
break;
case SIOCLOOKUPADDTABLE :
break;
case SIOCLOOKUPDELTABLE :
break;
case SIOCLOOKUPSTAT :
case SIOCLOOKUPSTATW :
break;
case SIOCLOOKUPFLUSH :
break;
case SIOCLOOKUPITER :
break;
default :
break;
}
SPL_X(s);
return err;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_addnode */
/* Returns: int - 0 = success, else error */
/* Parameters: data(I) - pointer to data from ioctl call */
/* */
/* Add a new data node to a lookup structure. First, check to see if the */
/* parent structure refered to by name exists and if it does, then go on to */
/* add a node to it. */
/* ------------------------------------------------------------------------ */
{
ip_pool_node_t node, *m;
ip_pool_t *p;
int err;
if (err != 0)
return EFAULT;
{
case IPLT_POOL :
return EINVAL;
if (err != 0)
return EFAULT;
if (p == NULL)
return ESRCH;
/*
* add an entry to a pool - return an error if it already
* exists remove an entry from a pool - if it exists
* - in both cases, the pool *must* exist!
*/
if (m)
return EEXIST;
break;
case IPLT_HASH :
return EINVAL;
if (err != 0)
return EFAULT;
return ESRCH;
break;
default :
break;
}
return err;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_delnode */
/* Returns: int - 0 = success, else error */
/* Parameters: data(I) - pointer to data from ioctl call */
/* */
/* Delete a node from a lookup table by first looking for the table it is */
/* in and then deleting the entry that gets found. */
/* ------------------------------------------------------------------------ */
{
ip_pool_node_t node, *m;
ip_pool_t *p;
int err;
if (err != 0)
return EFAULT;
{
case IPLT_POOL :
return EINVAL;
if (err != 0)
return EFAULT;
if (!p)
return ESRCH;
if (m == NULL)
return ENOENT;
break;
case IPLT_HASH :
return EINVAL;
if (err != 0)
return EFAULT;
return ESRCH;
break;
default :
break;
}
return err;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_addtable */
/* Returns: int - 0 = success, else error */
/* Parameters: data(I) - pointer to data from ioctl call */
/* */
/* Create a new lookup table, if one doesn't already exist using the name */
/* for this one. */
/* ------------------------------------------------------------------------ */
{
int err;
if (err != 0)
return EFAULT;
{
case IPLT_POOL :
else
break;
case IPLT_HASH :
else
break;
default :
break;
}
return err;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_deltable */
/* Returns: int - 0 = success, else error */
/* Parameters: data(I) - pointer to data from ioctl call */
/* */
/* Decodes ioctl request to remove a particular hash table or pool and */
/* calls the relevant function to do the cleanup. */
/* ------------------------------------------------------------------------ */
{
int err;
if (err != 0)
return EFAULT;
/*
* create a new pool - fail if one already exists with
* the same #
*/
{
case IPLT_POOL :
break;
case IPLT_HASH :
break;
default :
break;
}
return err;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_stats */
/* Returns: int - 0 = success, else error */
/* Parameters: data(I) - pointer to data from ioctl call */
/* */
/* Copy statistical information from inside the kernel back to user space. */
/* ------------------------------------------------------------------------ */
{
int err;
if (err != 0)
return EFAULT;
{
case IPLT_POOL :
break;
case IPLT_HASH :
break;
default :
break;
}
return err;
}
/* ------------------------------------------------------------------------ */
/* Function: iplookup_flush */
/* Returns: int - 0 = success, else error */
/* Parameters: data(I) - pointer to data from ioctl call */
/* */
/* A flush is called when we want to flush all the nodes from a particular */
/* ------------------------------------------------------------------------ */
{
if (err != 0)
return EFAULT;
return EINVAL;
num = 0;
err = 0;
}
err = 0;
}
if (err == 0) {
}
return err;
}
int type;
void *ptr;
{
return;
switch (type)
{
case IPLT_POOL :
break;
case IPLT_HASH :
break;
}
}
void *data;
int uid;
void *ctx;
{
int err;
if (err != 0) {
#ifdef _KERNEL
(void) printf("fr_inobj\n");
#endif
return err;
}
#ifdef _KERNEL
#endif
return EINVAL;
}
#ifdef _KERNEL
#endif
return EINVAL;
}
return ESRCH;
}
{
case IPLT_POOL :
break;
case IPLT_HASH :
break;
default :
#ifdef _KERNEL
#endif
break;
}
return err;
}
void *data;
{
return;
{
case IPLT_HASH :
break;
case IPLT_POOL :
break;
}
}
#else /* IPFILTER_LOOKUP */
/*ARGSUSED*/
{
return EIO;
}
#endif /* IPFILTER_LOOKUP */