Subject: Re: How to add if-IOCTL?
To: Bill Studenmund <wrstuden@loki.stanford.edu>
From: Heiko W.Rupp <hwr@pilhuhn.de>
List: tech-net
Date: 08/06/1998 21:26:08
On Wed, Aug 06, 1997 at 10:47:35AM -0700, Bill Studenmund wrote:
> I think what you need to do is bind a socket to that interface (I'm not
> exactly sure how to do this) and then do the ioctl.
Hm? I have defined an ioctl like this:
#define LODEBUG _IOW('t', 100 , int)
When I add a 'case LODEBUG:' to the ioctl switch(), then
I can pass e.g.
err=ioctl(s,SIOCSIFDSTADDR,(caddr_t)&ifr);
successfully, but not
err=ioctl(s,LODEBUG,(caddr_t)&ifr);
Here I get a 'Operation not supported' and also a printf() within
the loioctl does not get printed. This makes me think that there
must be some place in the kernel that decides if such an ioctl is
passed down to a driver or not.
> You realize that the argument passed to the ioctl, the ifreq structure
> in your example above, is an argument for the ioctl routine? I.E. your
Yes, sure.
> I think the only file which will need changing is net/if_loop.c, in its
> ioctl processing routine.
This is what I also thought ;-)
> Right. Network interfaces don't have /def/ files, which is really only
> a problem if you want to do something to the interface and not the
> communications flowing through it.
Hmmm. SIOCSIFADDR also does something to the interface and not to the
data that is flowing through.
> _IOR ioctls only pass in arguments, _IOW ones pass out arguments, and
> _IOWR ones pass both in and out arguments.
Ok, thanks.
Now that I look at it again ..
I did
#define LODEBUG _IOW('t', 100 , int)
where the 't', I have seen (i think) with th if_tun driver.
But the the other ones from sys/sockio.h that deal with an
interface either have a 'i' or a 'u'. Will try it with 'i' and/or 'u'.
Is there any documentation about that?
Thanks.
Heiko
--
See <a href="http://www.netbsd.org">NetBSD</a> for a multiplatform OS
Koennen wir jetzt die Prinzipienreiterei lassen und uns wieder den
wirklich wichtigen Dingen zuwenden?
-- Tilman Schmidt in de.admin.news.groups