From owner-freebsd-net@FreeBSD.ORG Fri Mar 8 09:02:21 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CC3F22A9 for ; Fri, 8 Mar 2013 09:02:21 +0000 (UTC) (envelope-from vpenkoff@gmail.com) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com [IPv6:2a00:1450:4010:c03::229]) by mx1.freebsd.org (Postfix) with ESMTP id 54CAF21A for ; Fri, 8 Mar 2013 09:02:21 +0000 (UTC) Received: by mail-la0-f41.google.com with SMTP id fo12so1453281lab.28 for ; Fri, 08 Mar 2013 01:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=2qgRNo+YYSnep3Ug6FJjMu+/oIAqofY4vYaeBrNNTKY=; b=ZgwpewYvPXtm6MNt9Ssu1ohJ3oXVLgs2mC/Yk+DcAW5RECYcqo0QzJJR0/lWfcG1Qk tPyLeqCNnx+0WIrcjCHdyiqZxkC5oQkbbXUuOqwztZsdr8zd5VtMV0nAzSio7pNeo2UK SoFzsNSFuUJRtdzvcS0WmgOAMk4ejtMtNTawX65qCxPMMQk+pLHgZ8sUWaGCTdp6fSEO fejWb74VFIqjppfRGGa8CHfFUcwGPojHPcGBUOkOS6AkO1NyV4pCm84n6IpdMscvmCIR KKjUvv//Wng5G+eqK2SLNh34t67YUC3vqLB7lvyahXAhNEIK9bblz9PETHLmwPy2fYIf mOMg== MIME-Version: 1.0 X-Received: by 10.112.103.168 with SMTP id fx8mr778095lbb.32.1362733340257; Fri, 08 Mar 2013 01:02:20 -0800 (PST) Received: by 10.112.18.43 with HTTP; Fri, 8 Mar 2013 01:02:20 -0800 (PST) In-Reply-To: References: Date: Fri, 8 Mar 2013 11:02:20 +0200 Message-ID: Subject: BPF data representation From: Viktor Penkoff To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 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, 08 Mar 2013 09:02:21 -0000 Hi guys. I'm diggin some bpf stuff and i can't figure out, why there are 3 types of data representations: words, halfwords and bytes? I mean how can i know, which one is best in a place to use? In some basic example, e.g. for packet capturing, considering BPF's manual, i use for ETHERTYPE in the ethernet header a halfword representation, but for a IP address - word representation. Let's say we have some read instructions: BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETHERTYPE_IP, X, Y), .... BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 26), BPF_JUMP(BPF_JMP+BPF+JEQ+BPF_K, 0xABABABAB, X,Y) Can someone explain? Thanks!