ioctl()

UNIX, gnu cc compiler, SUN Ultra 60

Hello, this is my first post, so please bear with me. I'm currently developing a test environment for a network subsystem that, when live, accesses databases and other network elements.

However, my test environment will be run offline, so I need to fake the compiler out on several instances. I was wondering if anyone knew the details of the ioctl() command. I have already written a dummy function in its place, but right now the compiler gets confused because there are two definitions of ioctl(), but I need to have it see the one I wrote...

Anyone have an idea? Thanks a lot.

This page might be usefull for you check it out.

http://www.mkssoftware.com/docs/man3/ioctl.3.asp

its a brief explanation of ioctl() and some examples also from the explanation i figured it out something similar with what you are looking for. Might help.

I'm not exactly sure what you're asking about
but you probably do NOT want to create your
own "ioctl()". Since "ioctl()" is a UNIX system
call, it may be easier to just define it out
something like...

#ifndef TESTRUN
ioctl(...);
#else
...do some dummy thing
#endif

Then when you "make" the program just use...

make .... -DTESTRUN

...to build the "test" program.

Briefly the ioctl function is called with three arguments. The first is a file descriptor, a socket in the case of network programming. The second argument is the request, e.g. what you want to do, there are many of them like SIOCGIFADDR which returns to you the protocol address assigned to your interface. The third argument is a pointer and it depends of the request, for instance if you want to get interface configuration parameters the pointer is of struct ifconf type. You can check the manual page of ioctl_list so as to get a list of the available requests.
The problem is that ioctl is not the same for all unix like os, it may vary. Last week I was trying to configure a proxy arp server with ioctl but the damn thing was not working properly. I posted a mail to the linux kernel mailing list but anfortunately nobody answered.

On Solaris, you may want to check out

man streamio

It lists ioctls for Solaris.
From your post it looks as if you are writing a distributed system, so you may want want to
check out

man rpc

Atle