Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jun 2006 13:08:13 +0200
From:      Max Laier <max@love2party.net>
To:        freebsd-net@freebsd.org
Cc:        Shaun Colley <shaun@rsc.cx>
Subject:   Re: Unexpected behavior after altering inetsw[] switch table
Message-ID:  <200606111308.28468.max@love2party.net>
In-Reply-To: <52706.81.107.58.115.1149986191.squirrel@webmail.rsc.cx>
References:  <52706.81.107.58.115.1149986191.squirrel@webmail.rsc.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
--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.

<snipp>

=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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606111308.28468.max>