From owner-freebsd-net@FreeBSD.ORG Tue Jan 12 00:12:11 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36EFF1065672 for ; Tue, 12 Jan 2010 00:12:11 +0000 (UTC) (envelope-from julian@elischer.org) Received: from utility-0.aerioconnect.net (utility-0.aerioconnect.net [216.240.32.11]) by mx1.freebsd.org (Postfix) with ESMTP id 054B88FC12 for ; Tue, 12 Jan 2010 00:12:10 +0000 (UTC) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by utility-0.aerioconnect.net (8.13.1/8.13.1) with ESMTP id o0C0CAkE002741; Mon, 11 Jan 2010 16:12:10 -0800 X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id 2D3702D6010; Mon, 11 Jan 2010 16:12:10 -0800 (PST) Message-ID: <4B4BBE59.9010908@elischer.org> Date: Mon, 11 Jan 2010 16:12:09 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Maxim Ignatenko References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: ng_patch node 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: Tue, 12 Jan 2010 00:12:11 -0000 Maxim Ignatenko wrote: > Hi, > I've written netgraph node able to modify arbitrary (8|16|32)-bit > unsigned integer in passing packets. Node applies one of =,+,-,&,| and > ^ operations to number at given offset. > Modification applied to each packet received on "in" hook. If "out" > hook is connected - resulting packets passed on it, otherwise - > returned back on "in" (for more easy use with ng_ipfw). Packets > received on "out" hook passed on "in" unmodified. > Node supports two control messages: "getconfig" and "setconfig". > Configuration represented in next structure: > struct ng_patch_config { > uint32_t value; /* argument passed to requested operation */ > uint32_t offset; /* offset in bytes */ > uint32_t length; /* 1,2 or 4 bytes */ > uint32_t mode; /* operation code: 1 - "=", 2 - "+", 3 - > "-", 4 - "&", 5 - "|", 6 - "^" */ > }; > Same names used in ASCII representation. > > I wanted to make ipfw able to modify TTL and ToS fields in IP packets, > but after some generalization idea looked like described above. I like it :-) if you can provide a short man page, I can commit it for you.