pfilstream.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (C) 2000, 2003 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
struct uio;
#ifdef HPUX_1111
#endif
#ifdef sun
#endif
#ifdef __hpux
# include <sys/dlpi_ext.h>
#endif
#ifdef sun
# if SOLARIS2 >= 8
# endif
# if SOLARIS2 >= 10
# endif
#endif
#ifdef sun
# include <pfild.h>
#else
# include "compat.h"
# include "pfil.h"
# include "qif.h"
# include "pfild.h"
#endif
#if SOLARIS2 >= 10
#endif
#ifdef PFILDEBUG
#else
# define PRINT(l,x) ;
#endif
#ifndef IP_DL_SAP
# define IP_DL_SAP 0x800
#endif
#ifdef PFILDEBUG
/* ------------------------------------------------------------------------ */
/* Function: pfil_printmchain */
/* Returns: void */
/* Parameters: mp(I) - pointer to mblk message */
/* */
/* This is primarly for debugging purposes - print out the contents of a */
/* STREAMS mblk message, just by data block type or also contents (in hex) */
/* if the value of pfil_debug has been turned up enough. */
/* ------------------------------------------------------------------------ */
{
u_char c, *s, *r;
int i;
/*LINTED: E_CONSTANT_CONDITION*/
c = *s++;
if (c >= 0x20 && c < 0x7f)
*r++ = c;
else
*r++ = '.';
*r = '\0';
#ifdef __hpux
#else
(void)sprintf(t, "%02x", c);
#endif
t += 2;
i++;
if ((i & 15) == 0) {
/*LINTED: E_CONSTANT_CONDITION*/
t = buf;
} else if ((i & 3) == 0)
*t++ = ' ';
}
if (t > buf) {
/*LINTED: E_CONSTANT_CONDITION*/
cbuf));
}
}
}
/* ------------------------------------------------------------------------ */
/* Function: pfil_printioctl */
/* Returns: void */
/* Parameters: mp(I) - pointer to mblk message with ioctl */
/* */
/* This is primarly for debugging purposes - print out in a more legible */
/* format what an ioctl is. */
/* ------------------------------------------------------------------------ */
{
char buf[80], l;
return;
#ifdef __hpux
#else
#endif
switch (cmd >> 24)
{
case 0x20:
break;
case 0x40:
break;
case 0x80:
break;
case 0xc0:
break;
default :
#ifdef __hpux
#else
#endif
break;
}
cmd &= 0x00ffffff;
#ifdef __hpux
#else
#endif
/*LINTED: E_CONSTANT_CONDITION*/
"!pfil_printioctl: %s (%d) cr %p id %d flag 0x%x count %ld error %d rval %d\n",
}
#endif
/* ------------------------------------------------------------------------ */
/* Function: pfilbind */
/* Returns: int - 0 == success, else error */
/* Parameters: q(I) - pointer to queue */
/* Write Lock: pfil_rw */
/* */
/* Check to see if a queue (or the otherside of it) is missing a qif_t */
/* structure. If neither have one then allocate a new one, else copy the */
/* q_ptr from one to the other. */
/* ------------------------------------------------------------------------ */
{
/* LINTED: E_CONSTANT_CONDITION */
/* LINTED: E_CONSTANT_CONDITION */
return qif_attach(q);
}
/* ------------------------------------------------------------------------ */
/* Function: pfilwput_ioctl */
/* Returns: void */
/* Parameters: q(I) - pointer to queue */
/* mp(I) - pointer to STREAMS message */
/* */
/* Handles ioctls for both the STREAMS module and driver. */
/* ------------------------------------------------------------------------ */
{
/* LINTED: E_CONSTANT_CONDITION */
"!pfilwput_ioctl(%p,%p) ioctl(%x,%d,%x,%ld,%d,%d) [%s]\n",
#ifdef PFILDEBUG
#endif
return;
}
{
case DL_IOC_HDR_INFO : {
/*
* Fastpath information ioctl. Update the expected size for
* headers on this queue using to match that in this message.
* Whilst this may not be an IOCACK with the header attached,
* it can also be an indication that something has changed so
* doing an update may not be a bad idea.
* If fastpath headers ever have variable length, this will
* not work.
*/
}
break;
}
#if SOLARIS2 >= 10
case SIOCSLIFNAME:
return;
}
break;
#else /* pre-S10 */
#ifdef SIOCGTUNPARAM
case SIOCGTUNPARAM :
qif_attach(q);
break;
#endif
#endif /* pre-S10 */
default:
break;
}
return;
}
#if SOLARIS2 >= 10
/*
* Update interface configuration data from pfild message.
*/
static void
{
int i;
int numifs;
return;
for (i = 0; i < numifs; i++) {
/* LINTED: E_CONSTANT_CONDITION */
LIFNAMSIZ) == 0 &&
sizeof (ifaddrslist[i].localaddr));
sizeof (ifaddrslist[i].netmask));
sizeof (ifaddrslist[i].broadaddr));
sizeof (ifaddrslist[i].dstaddr));
}
}
}
}
/*
* Update valid address set data from pfild message.
*/
{
int sap;
return;
}
}
#endif /* SOLARIS2 >= 10 */
/************************************************************************
* STREAMS device functions
*/
/* ------------------------------------------------------------------------ */
/* Function: pfilwput */
/* Returns: void */
/* Parameters: q(I) - pointer to queue */
/* mp(I) - pointer to STREAMS message */
/* */
/* This is only called for interaction with pfil itself, as the driver */
/* not do any IO, this should never be called except to handle ioctl's and */
/* so all other messages are free'd and no reply sent back. */
/* pfilwput also handles PFILCMD_IFADDRS and PFILCMD_IFADDRSET messages */
/* ------------------------------------------------------------------------ */
{
#ifdef PFILDEBUG
/* LINTED: E_CONSTANT_CONDITION */
#endif
{
#if SOLARIS2 >= 10
case M_PROTO:
/*
* Is it a valid PFILCMD message?
*/
/*LINTED: E_CONSTANT_CONDITION*/
break;
}
/*
* It's a message from pfild. Remember pfild's read queue for
* later use when sending packets; then process this message.
*/
switch (cmd) {
case PFILCMD_IFADDRS:
break;
case PFILCMD_IFADDRSET:
break;
default:
break;
}
break;
#endif
case M_IOCTL:
case ND_SET :
case ND_GET :
if (pfil_ioctl_nd(q, mp)) {
} else {
}
break;
default:
break;
}
return;
default:
break;
}
}
/************************************************************************
* STREAMS module functions
*/
/* ------------------------------------------------------------------------ */
/* Function: pfilmodwput */
/* Returns: Void. */
/* Parameters: q(I) - pointer to queue */
/* mp(I) - pointer to STREAMS message */
/* */
/* This function is called as part of the STREAMS module message processing */
/* for messages going down to the device drivers. */
/* ------------------------------------------------------------------------ */
{
union DL_primitives *dl;
/* LINTED: E_CONSTANT_CONDITION */
{
case M_PROTO :
case M_PCPROTO :
/* LINTED: E_CONSTANT_CONDITION */
break;
}
/*FALLTHROUGH*/
case M_DATA :
/* LINTED: E_CONSTANT_CONDITION */
"pfilmodwput", i, (void *)mp));
return;
else if (i > 0) {
return;
}
}
break;
case M_IOCTL:
pfilwput_ioctl(q, mp);
return;
default :
break;
}
return;
}
/* ------------------------------------------------------------------------ */
/* Function: pfilmodrput */
/* Returns: void */
/* Parameters: q(I) - pointer to queue */
/* mp(I) - pointer to STREAMS message */
/* */
/* This function is called as part of the STREAMS module message processing */
/* for messages going up to the protocol stack. */
/* ------------------------------------------------------------------------ */
{
union DL_primitives *dl;
dl_bind_ack_t *b;
/* LINTED: E_CONSTANT_CONDITION */
#ifdef DL_IOC_HDR_INFO
case M_IOCACK :
{
}
/*FALLTHROUGH*/
}
#endif /* DL_IOC_HDR_INFO */
#ifdef PFILDEBUG
case M_IOCNAK :
#endif
break;
case M_PROTO :
case M_PCPROTO :
/* LINTED: E_CONSTANT_CONDITION */
switch (dl->dl_primitive)
{
case DL_UNITDATA_IND :
break;
case DL_SUBS_BIND_ACK :
if (qif->qf_waitack > 0) {
c = (dl_subs_bind_ack_t *)dl;
/* XXX: What is this message? */
#if 0
#else
c->dl_subs_sap_length);
#endif
}
(void) pfilbind(q);
if (qif->qf_waitack > 0)
qif->qf_waitack--;
}
break;
case DL_BIND_ACK :
b = (dl_bind_ack_t *)dl;
}
if (b->dl_sap == IEEESAP_SNAP) {
qif->qf_waitack++;
break;
}
(void) pfilbind(q);
break;
default :
break;
}
break;
/*FALLTHROUGH*/
case M_DATA :
/* LINTED: E_CONSTANT_CONDITION */
"!pfilmodrput: mp %p pfil_precheck=%d\n",
(void *)mp, i));
return;
else if (i > 0) {
return;
}
} else {
break;
}
default :
break;
}
}
/* ------------------------------------------------------------------------ */
/* Function: pfil_drv_priv */
/* Returns: int - 0 == success, EPERM for error. */
/* Parameters: cr(I) - pointer to credential information */
/* */
/* Checks to see if the caller has enough credentials. */
/* ------------------------------------------------------------------------ */
{
#if SOLARIS2 >= 10
#else
#endif
}
/************************************************************************
* kernel module initialization
*/
/* ------------------------------------------------------------------------ */
/* Function: pfil_startup */
/* Returns: void */
/* Parameters: None. */
/* */
/* Initialise pfil data strutures. */
/* ------------------------------------------------------------------------ */
void pfil_startup()
{
}