From owner-freebsd-net@FreeBSD.ORG Thu Jul 10 02:41:00 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 069F3266 for ; Thu, 10 Jul 2014 02:41:00 +0000 (UTC) Received: from mail-qa0-x22a.google.com (mail-qa0-x22a.google.com [IPv6:2607:f8b0:400d:c00::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BA3DD2512 for ; Thu, 10 Jul 2014 02:40:59 +0000 (UTC) Received: by mail-qa0-f42.google.com with SMTP id j15so864458qaq.1 for ; Wed, 09 Jul 2014 19:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=a6cWY+MPn6D61LJhKdZ6Mm07SSUSzBlGv3FRKhnOh9o=; b=Oy+VpIMtiDfxhbe3AhMv9Xm3Gba94ShR6AYa+Uc2AFOoSvnJnH7vkqlUANash7G5+j kPoL1E3ZsoT+xEt7t2rWbdtWMhfwaDRV0xhxFwzwsiaGD0F9+4270DW1eq2r0ZoByQki vaJkxW9FxJRL8Je9vi8735ypxB7td3cz+WEjRNCzvROmV7OcBZRJhI8aPudVZNn3+tF8 fB5akJ8LNdoml1oQxtB4V/PAdbb/olW9NiFqjsbI6iSxSXx6Jnp8ClF9U/5mvU3NrhJ4 jRtXTM8fKqc2qt2AciPZQjITRMizIF7VKWi7ea8rLq5zmnytEs6/Xz4q6+s8N8SycDTr OqYQ== MIME-Version: 1.0 X-Received: by 10.140.19.109 with SMTP id 100mr73227508qgg.80.1404960058791; Wed, 09 Jul 2014 19:40:58 -0700 (PDT) Received: by 10.224.7.5 with HTTP; Wed, 9 Jul 2014 19:40:58 -0700 (PDT) In-Reply-To: References: <53BD7317.9030008@freebsd.org> Date: Thu, 10 Jul 2014 10:40:58 +0800 Message-ID: Subject: Re: A question on modifying packet. From: Niu Zhixiong To: Sami Halabi , freebsd-net@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jul 2014 02:41:00 -0000 Sry, The problem is that I receive the packet from this NIC and send this packet via the same NIC? Does netmap can help me? Regards, Niu Zhixiong =EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF= =BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D kaiaixi@gmail.com On Thu, Jul 10, 2014 at 1:47 AM, Sami Halabi wrote: > use netgraph. > In theory it should work.. in practice It worked for me once, but couldn'= t > repeat the success. > > See ng_patch. Here is the code i tried: > kldload ng_patch > kldload ng_ipfw > /usr/sbin/ngctl -f- << SEQ > mkpeer ipfw: patch 300 in > name ipfw:300 src_dst_chg > msg src_dst_chg: setconfig { count=3D2 csum_flags=3D1 > ops=3D[ \ > { mode=3D1 value=3D0xc0a8e609 length=3D4 offset= =3D12 } \ > { mode=3D1 value=3D0xc0a8e680 length=3D4 offset= =3D16 } ] } > SEQ > /sbin/ipfw add 600 netgraph 300 log ip from any to 239.0.0.19 dst-port > 1234 in via vlan999 > > Sami > On 7/9/14, 1:01 PM, Niu Zhixiong wrote: > >> Hi, all >> I have only one NIC. I want to capture packets from one certain ip addre= ss >> and change the both src and dst addresses and forward to other destinati= on >> via the same NIC. It is possible? Is there any library to help me do thi= s? >> > there is no library, but look at how natd does this using divert sockets. > > >> >> Regards, >> Niu Zhixiong >> =EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D= =EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D=EF=BC=8D >> kaiaixi@gmail.com >> _______________________________________________ >> freebsd-net@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-net >> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >> >> >> > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >