From 1ca2a1632d7325ee26b2c701b38c1d2e2fcb6f80 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 27 Apr 2006 00:56:34 +0000 Subject: 2006-04-27 Richard Braun Manuel Menal * device/if_hdr.h (struct ifnet): Added new members `if_snd_port_list' and `if_snd_port_list_lock'. * device/net_io.c: Reworked to improve BPF support. Filters can be applied to ingress packets, egress packets, or both. * device/subrs.c: Initialize the `if_snd_port_list' and `if_snd_port_list_lock'. * include/device/bpf.h [0]: Enable unconditionally. Include . (BPF_IN, BPF_OUT): New macros. * include/device/net_status.h (NETF_TYPE_MASK, NETF_IN, NETF_OUT): New macros. (struct net_rcv_msg): New member `sent'. * linux/dev/glue/net.c: Mark ingress packets as received and inject egress packets into the packet filters. --- include/device/bpf.h | 11 ++++++----- include/device/net_status.h | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/device/bpf.h b/include/device/bpf.h index 05cbf9bd..a4c4eef4 100644 --- a/include/device/bpf.h +++ b/include/device/bpf.h @@ -72,7 +72,8 @@ #ifndef _DEVICE_BPF_H_ #define _DEVICE_BPF_H_ -#if 0 /* not used in MK now */ +#include /* u_short */ + /* * Alignment macros. BPF_WORDALIGN rounds up to the next * even multiple of BPF_ALIGNMENT. @@ -115,14 +116,14 @@ struct bpf_version { #define DLT_PPP 9 /* Point-to-point Protocol */ #define DLT_FDDI 10 /* FDDI */ -#endif /* 0 */ - /* * The instruction encondings. */ -/* Magic number for the first instruction */ -#define BPF_BEGIN NETF_BPF +/* Magic number and flags for the first instruction */ +#define BPF_BEGIN NETF_BPF +#define BPF_IN NETF_IN +#define BPF_OUT NETF_OUT /* instruction classes */ #define BPF_CLASS(code) ((code) & 0x07) diff --git a/include/device/net_status.h b/include/device/net_status.h index dbf5e39f..5131ef53 100644 --- a/include/device/net_status.h +++ b/include/device/net_status.h @@ -98,6 +98,11 @@ struct net_status { * 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 +117,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<