Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]QProcess and DHCP
Forum Updated to NodeBB v4.3 + New Features

[Solved]QProcess and DHCP

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 4.9k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    I have searched google on how to get the dhcp settings and the ip, gateway and mask from a debian machine.
    Maybe I have to read the ifconfig and get the values there but I really don't know.

    Anyone who has done this or have some ideas about how to handle this.

    My app runs with root privileges.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      You might be interested in "this discussion":http://developer.qt.nokia.com/forums/viewthread/6579/

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on last edited by
        #3

        Is there another way to make and get this settings from debian 6.0
        or do I need to get qt 4.7 to get apropriate libs I'm on qt 4.6.3 for the moment.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          You can write your own wrapper that will invoke any Linux/Debian related commands to get the information you need. But this will not be very portable....

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            fluca: On the other hand calling a custom script to extract the information makes it easier to adapt the program to other linux environments: All you need to change is a script, not the code of the application itself.

            Considering that linux keeps changing quite fast (e.g. arch already deprecated the ifconfig tool) and the network setup varies a lot between distributions that might be a nice feature.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fluca1978
              wrote on last edited by
              #6

              With "being less portable" I was meaning that you have to check the script for each deploy you are going to use. Having Qt portable across platforms, and having to rely on a platform specific script does not sound to me very portable. Nevertheless, I agree that changing a script is usually a quick and simple task, and can also be automated checking which platform the system is running an getting the right information in the right way (e.g., uname switch). The fact that Linux is changing so much and so fast makes it hard to deal with all possible deployments. Maybe /proc/net could come in help here, but again this is a linux specific feature and it is not going to work on other systems.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                True, if there is a Qt way of getting the information that is definitely preferred.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  toho71
                  wrote on last edited by
                  #8

                  Maybe I did this more complex then it realy needs to be.
                  I simple used this code
                  @void GlobalParams::getMyIP()
                  {
                  QNetworkInterface *inter = new QNetworkInterface();
                  QList<QNetworkInterface> list = inter->allInterfaces();

                  for (int i = 0; i < list.size(); ++i) {
                   if (list.at(i).name().startsWith("eth0"))
                   {
                          QNetworkInterface iface = QNetworkInterface::interfaceFromName(list.at(i).name());
                          QList<QNetworkAddressEntry> entries = iface.addressEntries();
                          if (!entries.isEmpty())
                          {
                              QNetworkAddressEntry entry = entries.first();
                              ip = entry.ip();
                              netMask = entry.netmask();
                              gateway = entry.broadcast();
                          }
                   }
                  

                  }
                  @

                  But as tou could see my gateway is filled up with the broadcastadress.
                  And thats not what I want.

                  Someone who knows how too get this:
                  I have seen some code but it was not so obvious like this so I would like some simple example if there is one around.

                  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