c code or external app

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?

Reply to
David Peters
Loading thread data ...

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
Reply to
Tauno Voipio

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

Reply to
Craig Bergren

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.

Reply to
khuedinhpham

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.