--On 2002-01-18 11:55:09 +0100 [EMAIL PROTECTED] wrote:
> But socket options (on this level) are a predefined struct. Here's an
> example from some code I am working on:
>
> struct sockopt sopt;
>
> /* some code removed */
>
> bzero(&sopt, sizeof(sopt));
> sopt.sopt_level = SOL_SOCKET;
> sopt.sopt_name = SO_SNDBUF;
> bufsiz = 128 * 1024; /* XXX */
> sopt.sopt_val = &bufsiz;
> sopt.sopt_valsize = sizeof(bufsiz);
>
> Hope this clears a few things up =) (BTW, I'm not using netgraph after
> this code, but I know from reading the netgraph source that this struct
> sockopt is what is used).
>
> Doc
Hi,
However I need to use the netgraph interface to access the socket. I cannot
use the struct sockopt directly. struct sockopt is set in
ng_ksocket_rcvmsg().
Poking around sosetopt(): sopt.sopt_p is used to determine whether copyin()
or bcopy() will be used to copy data from sopt.sopt_val.
The struct sockopt and the sopt_p member is set inside ng_ksocket_rcvmsg().
I commented out the sopt_p definition to force the use of bcopy() instead
of copyin() and now my code now works ok.
Could it be that sopt_val points to kernel space instead of user space and
causes copyin() to fail with EFAULT ?
Florent.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message