> Could anybody advise me on this:
> For an implementation of IGMPv3, I had to extend the socket api
> following the draft(s). I had to add two ioctl commands:
> SIO_GET_MULTICAST_FILTER and SIO_SET_MULTICAST_FILTER. The argument is a
> structure that has a variable size. FreeBSD uses some macros, and the
> one I added looks like
> #define SIO_SET_MULTICAST_FILTER _IOWR('s', 63, struct ip_msfilter*)
> I couldn't use 'struct ip_msfilter' since this structure has a variable
> size. Now this macro makes a unsigned long from all this, where the
> length of the structure is encoded using sizeof(struct ip_msfilter*).
> This makes the ioctl pre-processing (sys_generic.c) copy 4 bytes from
> this pointer into the kernel. But this data is worthless to me, since it
> is the first 4 bytes of the structure itself. What I want is the pointer
This is what this should give you - a pointer to the structure
> I understand that I can do this by making people pass the
> address of a pointer to ioctl(), but this is kind of ugly I think. And
> besides, the other OS'es don't need this.
The ioctl interface is standard, everyone does it this way. If you think
about it for a moment, when you're defining an _IOWR() ioctl, you're
telling the macros that you want the kernel to be able to modify the
pointer that you're passing in, so of course it has to have storage space
in user space.
If you're passing in a pointer to a structure elsewhere, you should be
using _IOR() anyway, since you don't want the pointer copied back out.
In this case, the interface is the same purely for orthagonality's sake.
\\ Give a man a fish, and you feed him for a day. \\ Mike Smith
\\ Tell him he should learn how to fish himself, \\ email@example.com
\\ and he'll hate you for a lifetime. \\ firstname.lastname@example.org
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message