From owner-freebsd-ipfw@FreeBSD.ORG Tue Mar 4 11:31:07 2008 Return-Path: Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B46631065677; Tue, 4 Mar 2008 11:31:07 +0000 (UTC) (envelope-from vadim_nuclight@mail.ru) Received: from mx27.mail.ru (mx27.mail.ru [194.67.23.23]) by mx1.freebsd.org (Postfix) with ESMTP id 76DE58FC1D; Tue, 4 Mar 2008 11:31:07 +0000 (UTC) (envelope-from vadim_nuclight@mail.ru) Received: from [78.140.2.241] (port=36158 helo=nuclight.avtf.net) by mx27.mail.ru with asmtp id 1JWVMP-000KA9-00; Tue, 04 Mar 2008 14:31:05 +0300 Date: Tue, 04 Mar 2008 17:30:58 +0600 To: araujo@freebsd.org References: <200802261908.m1QJ8n5N023371@freefall.freebsd.org> <47C4F2D1.5080703@yandex.ru> <47C5516F.9080200@FreeBSD.org> <47C64BB7.60309@yandex.ru> <47C68CD1.10409@FreeBSD.org> <47CCC0AA.5030106@FreeBSD.org> From: "Vadim Goncharov" Organization: AVTF TPU Hostel Content-Type: text/plain; format=flowed; delsp=yes; charset=koi8-r MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <47CCC0AA.5030106@FreeBSD.org> User-Agent: Opera M2/7.54 (Win32, build 3865) X-Mras: OK Cc: stas@mbsd.msk.ru, Luigi Rizzo , Oleg Bulyzhin , freebsd-ipfw@freebsd.org, "Andrey V. Elsukov" , Julian Elischer , Ion-Mihai Tetcu , "Bruce M. Simpson" Subject: Re: ipfw modip [DF|TOS|DSCP|TTL] X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Mar 2008 11:31:07 -0000 04.03.08 @ 09:23 Marcelo Araujo wrote: > Hi all, > I started a work to create a new function called of modip, but I've some > doubts around this implementation. > I created inside of ipfw2.c a case statement called of TOK_SETMODIP, I > check if user passed one of the options(DF,TOS,DSCP,TTL), after set an > int with the respective value. > Now, I need to call O_SETMODIP within ip_fw2.c going with parameter > opmodip, and inside O_SETMODIP I can do a goto to O_SETIPTOSPRE as > example. Only as example - no O_SETIPTOSPRE should be in actual patch... > ipfw2.c: > 4913 /* New Implementation MODIP. */ > 4914 /* [DF|TOS|DSCP|TTL] */ > 4915 case TOK_SETMODIP: { > 4916 int opmodip = 0; > 4917 NEED1("need modip [DF|TOS|DSCP|TTL] arg\n"); You're checking only one argument, but there are two - e.g. "tos" and actual arg. > 4918 if (_substrcmp(*av, "DF") == 0 || > 4919 _substrcmp(*av, "df") == 0) { > 4920 opmodip = 1; Operation constants for O_MODIP should be #defines in ip_fw.h rather than plain 1, 2, 3, etc. > 4938 fill_cmd(cmd, O_SETMODIP, 0, modip); Why "modip" var, not "opmodip" you've used before? > 4939 ac--; av++; > 4940 printf("Value %d\n", opmodip); > 4941 break; > 4942 } > When I execute the ipfw with the option I've this output: > island# ipfw add modip > ipfw: need modip [DF|TOS|DSCP|TTL] arg > > and > > island# ipfw add modip tos > TOS.... > ipfw: invalid flag tos > > I'd like to pass as follows: > island# ipfw add modip tos flashover ip from any to any > > My problem I believe are in fill_cmd(). > Somebody can help me with this problem? I think problem is in "ac--; av++" count times, not in fill_cmd() which is only instruction setter, not parser. -- WBR, Vadim Goncharov