Question about subioctls (was: Re: [Prism54-devel] Re: Just several thoughts & suggestions)

Jean Tourrilhes jt@hpl.hp.com
Wed, 14 Jan 2004 09:24:55 -0800


On Wed, Jan 14, 2004 at 12:11:35PM +0200, kaleda wrote:
> > > Currently there are 14 private ioctl's used. Total there are only 16
> > > private ioctls available. If we'll continue this way - soon we'll have
> > > no private ioctls.
> > 
> > 	When it concern Wireless Extensions, if you want me to get
> > involved, I would advise to cc me directly (I read mailing list
> > archive only ocasionally).
> 
> Thanks for your responce.
> I've just read comments in iht iwpriv.c, but I haven't understand one
> thing:
> when I use subioctls, should the parameters of subioctls be of the same
> type ?
> What I mean is, that in the iwpriv.c comments you have sample:
> 
> private ioctls master function declarations, which takes 2 ints as
> parameters, and subioctls take one int, as parameter (the first in is
> subioctl number).
> And the question is should all the subioctls have the same type (and
> count) of input parameters, or they can be different (e.g. subioctls No
> 1 takes 1 in, No2: 3 inst, No3: 1 sockaddr, and so on ?)

	Yes, iwpriv match sub-ioctls to ioctls by argument type,
therefore all the sub-ioctls of a specific ioctl must have the same
type. But, you can define as many ioctls as you want (well, up to 32).
	Example :
static const struct iw_priv_args sample_priv[] = {
	/* --- sub-ioctls handlers --- */
	{ SIOCIWFIRSTPRIV + 0,
	  IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "" },
	{ SIOCIWFIRSTPRIV + 0,
	  IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "" },
	/* --- sub-ioctls definitions --- */
	{ 0,
	  IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "macadd" },
	{ 1,
	  IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "macdel" },
	{ 2,
	  IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "mackick" },
	{ 0,
	  0, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, "macget" },
	/* --- more sub-ioctls handlers --- */
	{ SIOCIWFIRSTPRIV + 2,
	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
	{ SIOCIWFIRSTPRIV + 3,
	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
	/* --- more sub-ioctls definitions --- */
	{ 0,
	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "txratectrl" },
	{ 0,
	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gettxratectrl" },
	{ 1,
	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "beacon_int" },
	{ 1,
	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbeacon_int" },
}
	Note how set and get sub-ioctls have the same index number.

> Maybe you should add some more explanation about that in  iwpriv
> comments, 'cause I've read then 3 times, but its still confusing me :).
> And as I understand - comments, in wireless tools source - is the main
> WE documentation.

	Correct. That's why I pointed out to the HostAP driver that
has a more complete and functional example.

> Thanks in advance.
> Kaleda

	Good luck !

	Jean