From owner-freebsd-net@FreeBSD.ORG Fri Sep 9 06:17:51 2005 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9203616A41F for ; Fri, 9 Sep 2005 06:17:51 +0000 (GMT) (envelope-from vys@renet.ru) Received: from mail.renet.ru (mail-local.renet.ru [82.116.32.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C038E43D48 for ; Fri, 9 Sep 2005 06:17:49 +0000 (GMT) (envelope-from vys@renet.ru) Received: from [82.116.32.17] (fox.renet.ru [82.116.32.17]) by mail.renet.ru (8.13.3/8.13.1) with ESMTP id j896Hk0P027216 for ; Fri, 9 Sep 2005 10:17:46 +0400 (MSD) Message-ID: <43212909.7060705@renet.ru> Date: Fri, 09 Sep 2005 10:17:45 +0400 From: "Vladimir Yu. Stepanov" User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: multipart/mixed; boundary="------------090304080609090509000802" X-Virus-Scanned: ClamAV version 0.86.2, clamav-milter version 0.86 on mail.renet.ru X-Virus-Status: Clean X-Spam-Status: No, score=-100.0 required=2.2 tests=BAYES_50, USER_IN_WHITELIST autolearn=no version=3.0.1 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on pantera.renet.ru X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: BPF patch for addition of good feature linux packet(7) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Sep 2005 06:17:51 -0000 This is a multi-part message in MIME format. --------------090304080609090509000802 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Hello! I made a modernization of bpf realization. It have a mind when we are trying to use bpf to account network statistic. When packets is catching by filter thereis imposible to determine the direction of packets flows. Due to this problem statistic accounts two times when packets is routes by the same interface, because this packets counts as incoming and outgoing traffic. The prototype of this patch is packet(7) on linux. This patch is fully compatible with all program uses the bpf. It adds the tags means traffic direction to the struct bpf_hdr. struct bpf_hdr { struct timeval bh_tstamp; /* time stamp */ bpf_u_int32 bh_caplen; /* length of captured portion */ bpf_u_int32 bh_datalen; /* original length of packet */ u_short bh_hdrlen; /* length of bpf header (this struct plus alignment padding) */ u_short bh_pkttype; /* packet type */ }; /* * Packet types. * For help to get some extra information. * It is taken from the description packet(7) in Linux system. */ #define BPFPKTTYPE_HOST 0 /* To us */ #define BPFPKTTYPE_BROADCAST 1 /* To all */ #define BPFPKTTYPE_MULTICAST 2 /* To group */ #define BPFPKTTYPE_OTHERHOST 3 /* To someone else */ #define BPFPKTTYPE_OUTGOING 4 /* Outgoing of any type */ #define BPFPKTTYPE_LOOPBACK 5 /* MC/BRD frame looped back */ #define BPFPKTTYPE_FASTROUTE 6 /* Fastrouted frame (if cannot detect MC/BRD type) */ --------------090304080609090509000802--