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
[-- Attachment #1 --]
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 = inetsw[ip_protox[IPPROTO_TCP]].pr_output;
> inetsw[ip_protox[IPPROTO_TCP]].pr_output = (pr_output_t
> *)my_tcp_output; break;
> case MOD_UNLOAD:
> uprintf("Skeleton KLD unloaded.\n");
> inetsw[ip_protox[IPPROTO_TCP]].pr_output = old_handler;
> break;
> default:
> err = 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
tcp_output() directly where needed. Depending on what you want to achive it
might be enough to hack up tcp_usr_send() and replace tcp_usrreqs.pru_send
instead. Replaceing tcp_output() is not easily possible. You could start
with telling us what you *really* want to do so we can point you to a
workable option.
<snipp>
--
/"\ Best regards, | mlaier@freebsd.org
\ / Max Laier | ICQ #67774661
X http://pf4freebsd.love2party.net/ | mlaier@EFnet
/ \ ASCII Ribbon Campaign | Against HTML Mail and News
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (FreeBSD)
iD8DBQBEi/msXyyEoT62BG0RAoJbAJ9phWmhrJVesn05D8DTRJPj4Kr0AwCfYhsS
1qI0LId/zt1FrCCu+GA/Ep8=
=slsg
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606111308.28468.max>
