Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Setting ip address using qt

Setting ip address using qt

Scheduled Pinned Locked Moved Mobile and Embedded
17 Posts 5 Posters 25.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goetz
    wrote on last edited by
    #7

    Does your code work from the command line?

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • P Offline
      P Offline
      prabhuraj
      wrote on last edited by
      #8

      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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #9

        You can include the C code in your Qt application. C++ is downwards compatible to C, so your system calls can be used in your Qt code too.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • P Offline
          P Offline
          prabhuraj
          wrote on last edited by
          #10

          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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #11

            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.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • P Offline
              P Offline
              prabhuraj
              wrote on last edited by
              #12

              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?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #13

                So why don't you use the means of the C application within your C++ application? Just copy 'n paste that damn code into your Qt app, it is that simple.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  prabhuraj
                  wrote on last edited by
                  #14

                  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

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    prabhuraj
                    wrote on last edited by
                    #15

                    Hi,
                    When I run the code on Qt I get following errors.
                    SIOCSIFADDR: Permission denied
                    SIOCSIFFLAGS: Permission denied
                    SIOCSIFNETMASK: Permission denied
                    SIOCSIFFLAGS: Permission denied

                    I know these are because of root permission but not getting how to solve.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lgeyer
                      wrote on last edited by
                      #16

                      [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).

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        robi
                        wrote on last edited by
                        #17

                        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

                        robi

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved