From owner-freebsd-net@FreeBSD.ORG Sun Jun 11 11:08:44 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B66EF16A41B for ; Sun, 11 Jun 2006 11:08:44 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id A95C643D46 for ; Sun, 11 Jun 2006 11:08:43 +0000 (GMT) (envelope-from max@love2party.net) Received: from [88.64.176.255] (helo=amd64.laiers.local) by mrelayeu.kundenserver.de (node=mrelayeu10) with ESMTP (Nemesis), id 0ML31I-1FpNnx0V3g-0000RU; Sun, 11 Jun 2006 13:08:31 +0200 From: Max Laier Organization: FreeBSD To: freebsd-net@freebsd.org Date: Sun, 11 Jun 2006 13:08:13 +0200 User-Agent: KMail/1.9.1 References: <52706.81.107.58.115.1149986191.squirrel@webmail.rsc.cx> In-Reply-To: <52706.81.107.58.115.1149986191.squirrel@webmail.rsc.cx> X-Face: ,,8R(x[kmU]tKN@>gtH1yQE4aslGdu+2]; R]*pL,U>^H?)gW@49@wdJ`H<=?utf-8?q?=25=7D*=5FBD=0A=09U=5For=3D=5CmOZf764=26nYj=3DJYbR1PW0ud?=>|!~,,CPC.1-D$FG@0h3#'5"k{V]a~.<=?utf-8?q?mZ=7D44=23Se=7Em=0A=09Fe=7E=5C=5DX5B=5D=5Fxj?=(ykz9QKMw_l0C2AQ]}Ym8)fU MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5383948.DQHWhtUWyu"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200606111308.28468.max@love2party.net> X-Provags-ID: kundenserver.de abuse@kundenserver.de login:61c499deaeeba3ba5be80f48ecc83056 Cc: Shaun Colley Subject: Re: Unexpected behavior after altering inetsw[] switch table 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: Sun, 11 Jun 2006 11:08:44 -0000 --nextPart5383948.DQHWhtUWyu Content-Type: text/plain; charset="iso-8859-6" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Sunday 11 June 2006 02:36, Shaun Colley wrote: > I'm writing a kernel module whose job is to modify the inetsw[] switch > table for the IPPROTO_TCP protocol. The pr_output hook for TCP needs to > be changed, such that my own custom tcp_output function will be called > when transmitting TCP packets. The reason for doing this is so that I can > do some modification on TCP packets before they are transmitted, but the > semantics of this are not important. > > The part of the module of interest is: > > --- > switch (what) { > case MOD_LOAD: /* kldload */ > uprintf("Skeleton KLD loaded.\n"); > old_handler =3D inetsw[ip_protox[IPPROTO_TCP]].pr_output; > inetsw[ip_protox[IPPROTO_TCP]].pr_output =3D (pr_output_t > *)my_tcp_output; break; > case MOD_UNLOAD: > uprintf("Skeleton KLD unloaded.\n"); > inetsw[ip_protox[IPPROTO_TCP]].pr_output =3D old_handler; > break; > default: > err =3D EINVAL; > break; > } > --- > > my_tcp_output is a hacked version of tcp_output. As you can see in netinet/in_proto.c, tcp does not use pr_output, but calls= =20 tcp_output() directly where needed. Depending on what you want to achive i= t=20 might be enough to hack up tcp_usr_send() and replace tcp_usrreqs.pru_send= =20 instead. Replaceing tcp_output() is not easily possible. You could start=20 with telling us what you *really* want to do so we can point you to a=20 workable option. =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart5383948.DQHWhtUWyu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (FreeBSD) iD8DBQBEi/msXyyEoT62BG0RAoJbAJ9phWmhrJVesn05D8DTRJPj4Kr0AwCfYhsS 1qI0LId/zt1FrCCu+GA/Ep8= =slsg -----END PGP SIGNATURE----- --nextPart5383948.DQHWhtUWyu--