1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _SYS_PFMOD_H 28 #define _SYS_PFMOD_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * Ioctls. 38 */ 39 #define PFIOC ('P' << 8) 40 #define PFIOCSETF (PFIOC|1) /* replace current packet filter */ 41 42 #define ENMAXFILTERS 255 /* maximum filter short words */ 43 #define PF_MAXFILTERS 2047 /* max short words for newpacketfilt */ 44 45 /* 46 * filter structure for SETF 47 */ 48 struct packetfilt { 49 uchar_t Pf_Priority; /* priority of filter */ 50 uchar_t Pf_FilterLen; /* length of filter cmd list */ 51 ushort_t Pf_Filter[ENMAXFILTERS]; /* filter command list */ 52 }; 53 54 /* 55 * The extended packet filter structure 56 */ 57 struct Pf_ext_packetfilt { 58 uchar_t Pf_Priority; /* priority of filter */ 59 unsigned int Pf_FilterLen; /* length of filter cmd list */ 60 ushort_t Pf_Filter[PF_MAXFILTERS]; /* filter command list */ 61 }; 62 63 /* 64 * We now allow specification of up to MAXFILTERS (short) words of a filter 65 * command list to be applied to incoming packets to determine if 66 * those packets should be given to a particular open ethernet file. 67 * Alternatively, PF_MAXFILTERS and Pf_ext_packetfilt structure can be 68 * used in case even bigger filter command list is needed. 69 * 70 * In this context, "word" means a short (16-bit) integer. 71 * 72 * Each open enet file specifies the filter command list via ioctl. 73 * Each filter command list specifies a sequence of actions that leaves a 74 * boolean value on the top of an internal stack. Each word of the 75 * command list specifies an action from the set {PUSHLIT, PUSHZERO, 76 * PUSHWORD+N} which respectively push the next word of the filter, zero, 77 * or word N of the incoming packet on the stack, and a binary operator 78 * from the set {EQ, LT, LE, GT, GE, AND, OR, XOR} which operates on the 79 * top two elements of the stack and replaces them with its result. The 80 * special action NOPUSH and the special operator NOP can be used to only 81 * perform the binary operation or to only push a value on the stack. 82 * 83 * If the final value of the filter operation is true, then the packet is 84 * accepted for the open file which specified the filter. 85 */ 86 87 /* these must sum to sizeof (ushort_t)! */ 88 #define ENF_NBPA 10 /* # bits / action */ 89 #define ENF_NBPO 6 /* # bits / operator */ 90 91 /* binary operators */ 92 #define ENF_NOP (0 << ENF_NBPA) 93 #define ENF_EQ (1 << ENF_NBPA) 94 #define ENF_LT (2 << ENF_NBPA) 95 #define ENF_LE (3 << ENF_NBPA) 96 #define ENF_GT (4 << ENF_NBPA) 97 #define ENF_GE (5 << ENF_NBPA) 98 #define ENF_AND (6 << ENF_NBPA) 99 #define ENF_OR (7 << ENF_NBPA) 100 #define ENF_XOR (8 << ENF_NBPA) 101 #define ENF_COR (9 << ENF_NBPA) 102 #define ENF_CAND (10 << ENF_NBPA) 103 #define ENF_CNOR (11 << ENF_NBPA) 104 #define ENF_CNAND (12 << ENF_NBPA) 105 #define ENF_NEQ (13 << ENF_NBPA) 106 107 /* stack actions */ 108 #define ENF_NOPUSH 0 109 #define ENF_PUSHLIT 1 110 #define ENF_PUSHZERO 2 111 #define ENF_PUSHONE 3 112 #define ENF_PUSHFFFF 4 113 #define ENF_PUSHFF00 5 114 #define ENF_PUSH00FF 6 115 #define ENF_PUSHWORD 16 116 117 #ifdef __cplusplus 118 } 119 #endif 120 121 #endif /* _SYS_PFMOD_H */ 122