From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 19 14:25:23 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC44A1065693 for ; Tue, 19 Jan 2010 14:25:23 +0000 (UTC) (envelope-from lsimakov@gmail.com) Received: from mail-fx0-f218.google.com (mail-fx0-f218.google.com [209.85.220.218]) by mx1.freebsd.org (Postfix) with ESMTP id 81C9A8FC28 for ; Tue, 19 Jan 2010 14:25:23 +0000 (UTC) Received: by mail-fx0-f218.google.com with SMTP id 10so756851fxm.14 for ; Tue, 19 Jan 2010 06:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=lO3yNmqXVab0qoKb38cJ9IqrDB9aB+KKmbLt6IIFV+U=; b=TZ/Arn51rXZJl3I0YzUOtvudPUHUDpqTCvUiay/0FcWmMHN6uaa5rGrDakn0WtQ9K0 79fb8s1YEKeYb/tKzz4GBxqidMfVWMQSKMnBgGVRMTDHpOnpPTe5KZjVjr31f5FyFEEM rKfuUEtYfWgtts8OTn5snAL32bayVD/asjyHA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=CeCc2EPd1cELUF+pV8ecZT2fbOG+nNYkEKuVnOzwzLMxxgJO99e4t/xCpb6Y4C/ke4 602yvuKfwwTFRwJDeCeWzQoUSmRkLZ1pPdo/81Y4eDDUfZJzu+R7SnT26377GvaZjwaM 8woYS6Wqv5PtYOimvCrtQFjuqfgSL6E/CZTeQ= MIME-Version: 1.0 Received: by 10.216.88.139 with SMTP id a11mr2880908wef.50.1263911122954; Tue, 19 Jan 2010 06:25:22 -0800 (PST) In-Reply-To: <201001151711.23061.max@love2party.net> References: <201001151711.23061.max@love2party.net> Date: Tue, 19 Jan 2010 17:25:22 +0300 Message-ID: From: q q To: Max Laier Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: Q:possibility PFIL+mbuf use for packet spawning X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2010 14:25:24 -0000 I coded all checksum calculations code. All works ok when i just modifying data of packets(like all T letters to Q letters) But now i get some strange error: packet1: TestMessage. packet2: 2nd message im using on first packet only next code(data is a pointer to char* from mbuf containing strings): TEST[0]='G'; TEST[1]='\0'; int res=m_append(*m,2,TEST); m_fixhdr(*m); printf("res cames from m_append:%d \n",res); printf("new data string is %s \n",data); iph->ip_len+=2;//modifying IP header length Then recalculatin IP and TCP cheksums(correctly seems because network doesnt drop packets) And server got message:"Test Message.Qnd message" As well server reply with ACK=25. So seems no new chars were added. Seems like im overwriting 2nd packet. But why this happening? Thank you :) Yours, Qspirit. PS sorry Max for double mail, forgot to add cc hackers. 2010/1/15 Max Laier > On Friday 15 January 2010 12:26:06 q q wrote: > > I'm using pfil as packet filter for packet modifications. > > > > Is it possible to spawn new packets to network from pfil using mbuf? > > You can call into ip_output with a new mbuf to send a new packet. See for > example pf_send_tcp in contrib/pf/net/pf.c > > > Another question: im using m_append to change packet length and add > > data(its working, at least server got longer message) but when i > wireshark > > clients packets(win machine) i see that i got acknoledge on older length > > not on new one. Am i missunderstanding something? > > Assuming you are talking about tcp packets (otherwise there wouldn't be an > ack), you have to alter the tcp header, checksums, etc. as well. Just > adding > data doesn't work. > > Regards, > -- > Max >