--- Gnu-Mach/include/device/net_status.h 2020/09/02 04:36:57 1.1.1.1 +++ Gnu-Mach/include/device/net_status.h 2020/09/02 04:45:35 1.1.1.3 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1991,1990,1989 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -72,6 +72,7 @@ struct net_status { #define NET_DSTADDR (('n'<<16) + 3) +#define NET_FLAGS (('n'<<16) + 4) /* * Input packet filter definition @@ -83,7 +84,7 @@ struct net_status { * We allow specification of up to NET_MAX_FILTER (short) words of a filter * command list to be applied to incoming packets to determine if * those packets should be given to a particular network input filter. - * + * * Each network filter specifies the filter command list via net_add_filter. * Each filter command list specifies a sequences of actions which leave a * boolean value on the top of an internal stack. Each word of the @@ -94,10 +95,15 @@ struct net_status { * top two elements of the stack and replaces them with its result. The * special action NOPUSH and the special operator NOP can be used to only * perform the binary operation or to only push a value on the stack. - * + * * If the final value of the filter operation is true, then the packet is * accepted for the filter. - * + * + * The first filter_t object is a header which allows to set flags for the + * filter code. Main flags concern the direction of packets. This header is + * split in the same way NETF words are : the 6 MSB bits indicate the type + * of filter while the 10 LSB bits are the flags. For native NETF filters, + * clear the 6 MSB bits (which is why there is no dedicated macro). */ typedef unsigned short filter_t; @@ -112,6 +118,14 @@ typedef filter_t *filter_array_t; #define NETF_ARG(word) ((word) & 0x3ff) #define NETF_OP(word) (((word)>>NETF_NBPA)&0x3f) +/* filter types */ +#define NETF_TYPE_MASK (((1 << NETF_NBPO) - 1) << NETF_NBPA) +#define NETF_BPF (1 << NETF_NBPA) + +/* flags */ +#define NETF_IN 0x1 +#define NETF_OUT 0x2 + /* binary operators */ #define NETF_NOP (0<