Re: _IOR/W with if_tun

From: Rob Warnock (rpw3_at_rpw3.org)
Date: 10/29/05


Date: Sat, 29 Oct 2005 06:17:15 -0500

bsder <snort_sam@yahoo.com> wrote:
+---------------
| Can anyone tell me what does the following codes do:
| /* ioctl's for get/set debug */
| #define TUNSDEBUG _IOW('t', 90, int)
| #define TUNGDEBUG _IOR('t', 89, int)
| #define TUNSIFINFO _IOW('t', 91, struct tuninfo)
| #define TUNGIFINFO _IOR('t', 92, struct tuninfo)
| #define TUNSLMODE _IOW('t', 93, int)
+---------------

Generally speaking, the _IOR macro is used to define codes
for ioctl()s which only return values back into user space
[a "IOctl Read", you might say], whereas the _IOW macro is
used for ioctl()s which set ["IOctl Write"] values into the
kernel. You can also see this in that the TUNGxxx codes are
for "Getting" ("Reading") values whereas the TUNSxxx codes
are for "Setting" ("Writing") values into the system.

See <sys/ttycom.h> for another example.

+---------------
| I tried to find out the implementation of the _IOR/W functions,
| but I found nothing in the src directory.
+---------------

Look in "/usr/src/sys/net/if_tun.c", routine "tunioctl()".
All your questions will be answered. ;-} ;-}

-Rob

-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607



Relevant Pages

  • Re: How to register Vendor-defined IOCTL fail message to Eventlog?
    ... Do not use IOCTL codes as event ID codes. ... Include this header your other files. ... Maxim Shatskih, Windows DDK MVP ...
    (microsoft.public.development.device.drivers)
  • Re: IOCTL Codes
    ... When you call ioctl, the codes and ... > are passed to the ioctl function of the device driver associated with the ... drivers, it is conflicting with the lower TY/SIO layers of my driver. ...
    (comp.os.vxworks)