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,                      | [EMAIL PROTECTED]
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | [EMAIL PROTECTED]
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News

Attachment: pgpxKMGGzwaZN.pgp
Description: PGP signature

Reply via email to