c code or external app

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I am working on an application that requires changing IP, gateway, or subnet
mask information.  Is it best to build in calls to do this or is it best to
call external applications (ifconfig and route) to make the changes?

Re: c code or external app
Quoted text here. Click to load it

Just open a TCP or UDP socket and use the appropriate ioctl()'s
on the socket.

Please understand that this kind of operation needs that the
process has superuser rights (root).


Tauno Voipio
tauno voipio (at) iki fi

Re: c code or external app

Quoted text here. Click to load it

Yes and yes.  If you want the changes to be permanent, you will want to
update configuration files.

Re: c code or external app
The answer is YES and NO.  It is all matter of your taste, choice and
how details you know about your system.

For instance, if you are not very familiar with all the configuration
files then from your C code call the external function (call execXX
function family) and pass the parameter to it.  If you are familiar
with all configuration file for your particular platform then modify
the configuration file (read/write to configuration file).

Personally, for me since I will do a very similar thing in the near
future, my choice is to modify the configuration files and then reboot
the system.  

Good luck.

Site Timeline