Setting ip address using qt
-
Hi volker..
For changing the ip adress, first I developed a small c application using linux system call and also successfully changed it. eg I used "ifconfig eth0 192.168.2.200 netmask 255.255.255.0 up". Al of this stuff I did it in root mode on PC.
I did a few modifications for Qt as mentioned above and tried to run but not been able to change the IP address.I agree to what you said that I should have root access to change the IP address but the code is running the code on the embedded device in the root mode. Do I have to provide any root permission through Qt?Please suggest any idea if you have.
Thanks
-
I truly appreciate your reply volker..
Do you mean I can write an application in c and include it in Qt directly? If you have any idea about it please elaborate it. Any links of how to do it and run it will also be very helpful.I again want to mention that this code will be used on an embedded device.Please help me regarding this.
Waiting for your reply.Thanks
-
You never write an application in language X and "include" it into another application.
You have your C application to set the IP address. That contains some code (snippet), hopefully in a function or method. You can integrate that snippet in any other C or C++ application and call that method. This has nothing to do with embedded or desktop.
-
I developed a c application for changing the Ip address and it worked perfectly fine.I made the changes as mentioned in the above code snippet.I also made the changes and used arg() instead of sprintf() as per your suggestion but still I am not been able to change the Ip address. Can you please go through the above snippet of code and let me know if I have done any mistakes?
-
Hi,
I tried various things but its not working.The thing is,the Qt application needs root permission to run the code.I searched as to how to give root permission to Qt app but with no success.Can anyone tell me how to give root permission to Qt app?Thanks
-
Hi,
When I run the code on Qt I get following errors.
SIOCSIFADDR: Permission denied
SIOCSIFFLAGS: Permission denied
SIOCSIFNETMASK: Permission denied
SIOCSIFFLAGS: Permission deniedI know these are because of root permission but not getting how to solve.
-
[quote author="prabhuraj" date="1316169665"]BTW the target device is executing the code in root mode.[/quote]
[quote author="prabhuraj" date="1316176111"]The code executing and running on the linux embedded device is in root mode but still the code is not working fine.[/quote]
[quote author="prabhuraj" date="1316234927"]Al of this stuff I did it in root mode on PC.[/quote]
[quote author="prabhuraj" date="1316234927"]I agree to what you said that I should have root access to change the IP address but the code is running the code on the embedded device in the root mode.[/quote]Is your application now executed as root or isn't it?
If not: you cannot elevate privileges from an unprivileged process. You will have to use an external application having the setuid bit set, like sudo, or you will have to set the setuid bit on your application itself (don't do this unless you know what you are doing).
-
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html you can get idea how to integrate c code in c++ then may be you can solve your probably i hope