--On 2002-01-17 18:16:08 -0800 [EMAIL PROTECTED] wrote:

> Florent Parent writes:
>> Anyone has an example on how to setsockopt on a ksocket node in netgraph?
>>
>>     struct opts {
>>         int level;
>>         int name;
>>         int value;
>>     } myopts = { SOL_SOCKET, SO_REUSEADDR, 1
>>     };
>>
>>     ret = NgSendMsg(cs, epath, NGM_KSOCKET_COOKIE, NGM_KSOCKET_SETOPT,
>>                           (struct ng_ksocket_sockopt *)&myopts,
>> sizeof(myopts)));
>>
>> return error 14 "Bad address".
>>
>> Did some tracing in ng_ksocket.c and the struct sockopt sent as argument
>> to  sosetopt() seems to contains sane values:
>>
>> sopt.sopt_val = 0xc182452c  (pointer dereferences to 1)
>> sopt.sopt_valsize = 4
>
> What kind of socket?

UDP

>
> What version of FreeBSD?

4.5-PRERELEASE (~ 2 weeks old)


> That should work.. if the error is coming from the sosetopt()
> call then it's a socket problem rather than a netgraph problem.
>
> What if you create the socket normally and call setsockopt()?

Well that works just fine. I've attached normal.c which is a dummy example 
using standard socket calls, and I've attached netgraph.c which wants to do 
the same thing using a ksocket node. The latter fails with the following 
debug:

netgraph: SENDING MESSAGE:
netgraph: SOCKADDR: { fam=32 len=9 addr=".dummy" }
netgraph: NG_MESG :
netgraph:   vers   2
netgraph:   arglen 12
netgraph:   flags  0
netgraph:   token  3
netgraph:   cookie KSOCKET (942710669)
netgraph:   cmd    7
netgraph:   args (12 bytes)
netgraph: 0000:  ff ff 00 00 00 02 00 00 01 00 00 00 
............
netgraph: sendto(.dummy): Bad address
.dummy Cannot setopt the ksocket node: Bad address


It has to be the way I'm presenting the socket options arguments through 
the netgraph interface. This is why I originally asked for any example on 
doing a setsockopt through netgraph.

Thanks for the help

Florent.

Attachment: netgraph.c
Description: Binary data

Attachment: normal.c
Description: Binary data

Reply via email to