Socket Options Error

I've been testing some code and using ktrace to debug. The following error is occurring,

Code:
setsockopt -1 errno 22 Invalid argument

it is linked the following line of code.

Code:
int on = 1;
setsockopt(sockfd, IPPROTO_IPV6, IPV6_DSTOPTS, &on, sizeof(on));

sockfd is working fine as the rest of the application works and network traffic flows (over IPv6).

Testing on FreeBSD 7.3-RELEASE GENERIC i386

Is this a bug or am I missing something?
 
What kind of socket is it?

This option is only allowed to be set on SOCK_DGRAM or SOCK_RAW socket.
 
Looks fine but ip6(4) says:

IPV6_DSTOPTS int *
Get or set whether the destination options from subsequent packets will be provided as ancillary data along with the payload in subsequent recvmsg(2) calls. The option is stored in the following structure in the ancillary data returned:
Code:
	     struct ip6_dest {
		     u_int8_t ip6d_nxt;      /* next header */
		     u_int8_t ip6d_len;      /* length in units of 8 octets */
	     /* followed by options */
	     } __packed;
The inet6_option_space() routine and family of routines may be used to manipulate this data.

This option requires superuser privileges.
 
expl said:
What kind of socket is it?

This option is only allowed to be set on SOCK_DGRAM or SOCK_RAW socket.

I've tried it with SOCK_DGRAM and it still happens.

@SirDice I'm compiling and running the code as root.
 
Back
Top