Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. how get gateway in qt?
Forum Updated to NodeBB v4.3 + New Features

how get gateway in qt?

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
6 Posts 3 Posters 2.9k Views 2 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.
  • V Offline
    V Offline
    valeriy
    wrote on last edited by
    #1

    I need to get gateway address. Function preparing adress must work on windows, linux, android and mb iOS. It is necessary to find address of router, that is connected to user.
    What can suggest me?
    my search turned only to topics that are written 3-4 years ago and methods dont work yet

    1 Reply Last reply
    0
    • V Offline
      V Offline
      valeriy
      wrote on last edited by
      #2

      i can use route -n, but how use it in my programm...hmmm....

      1 Reply Last reply
      0
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on last edited by
        #3

        @valeriy said:

        I need to get gateway address.

        As far as I know, Qt does not provide any specific functionality for that.

        There's actually quite a lot of complexity behind your simply-stated requirement. On most platforms, "the gateway" choice can depend on any and all properties of the connection being requested, but most commonly at least:

        • the chosen (automatically or explicit) network interface ;
        • the destination address.

        And in many cases, there's actually a list of available gateway addresses (often weighted) for any given combination, not just one.

        So it really does depend on what you're trying to do, how detailed / accurate you need to be, and how much variation you need to support. But regardless, you'll need a fair bit of platform-specific code to get a true gateway address.

        It is necessary to find address of router, that is connected to user.

        This sounds like you might interested in the super-simplistic home-user-attached-to-an-internet-router scenario (even that scenario gets complicated if, for example, they're using a VPN for work). In that case, depending on what you're trying to achieve, you might consider using a discovery protocol, like ICMP (or DLNA?) to detect the home router instead? At least that would not be platform dependant.

        Good luck! :)

        V kshegunovK 2 Replies Last reply
        2
        • Paul ColbyP Paul Colby

          @valeriy said:

          I need to get gateway address.

          As far as I know, Qt does not provide any specific functionality for that.

          There's actually quite a lot of complexity behind your simply-stated requirement. On most platforms, "the gateway" choice can depend on any and all properties of the connection being requested, but most commonly at least:

          • the chosen (automatically or explicit) network interface ;
          • the destination address.

          And in many cases, there's actually a list of available gateway addresses (often weighted) for any given combination, not just one.

          So it really does depend on what you're trying to do, how detailed / accurate you need to be, and how much variation you need to support. But regardless, you'll need a fair bit of platform-specific code to get a true gateway address.

          It is necessary to find address of router, that is connected to user.

          This sounds like you might interested in the super-simplistic home-user-attached-to-an-internet-router scenario (even that scenario gets complicated if, for example, they're using a VPN for work). In that case, depending on what you're trying to achieve, you might consider using a discovery protocol, like ICMP (or DLNA?) to detect the home router instead? At least that would not be platform dependant.

          Good luck! :)

          V Offline
          V Offline
          valeriy
          wrote on last edited by
          #4

          @Paul-Colby
          thanks for answer)

          Realy, i need programm to automatically detected router address for different platform.
          i found IRD Protocol, but how use it? :D
          can you help me?)

          1 Reply Last reply
          0
          • Paul ColbyP Paul Colby

            @valeriy said:

            I need to get gateway address.

            As far as I know, Qt does not provide any specific functionality for that.

            There's actually quite a lot of complexity behind your simply-stated requirement. On most platforms, "the gateway" choice can depend on any and all properties of the connection being requested, but most commonly at least:

            • the chosen (automatically or explicit) network interface ;
            • the destination address.

            And in many cases, there's actually a list of available gateway addresses (often weighted) for any given combination, not just one.

            So it really does depend on what you're trying to do, how detailed / accurate you need to be, and how much variation you need to support. But regardless, you'll need a fair bit of platform-specific code to get a true gateway address.

            It is necessary to find address of router, that is connected to user.

            This sounds like you might interested in the super-simplistic home-user-attached-to-an-internet-router scenario (even that scenario gets complicated if, for example, they're using a VPN for work). In that case, depending on what you're trying to achieve, you might consider using a discovery protocol, like ICMP (or DLNA?) to detect the home router instead? At least that would not be platform dependant.

            Good luck! :)

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @Paul-Colby said:

            like ICMP (or DLNA?) to detect the home router instead? At least that would not be platform dependant.

            I can't see how this wouldn't be platform dependent. How do you compose ICMP message without platform specific API?

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            2
            • Paul ColbyP Offline
              Paul ColbyP Offline
              Paul Colby
              wrote on last edited by
              #6

              @kshegunov said:

              I can't see how this wouldn't be platform dependent. How do you compose ICMP message without platform specific API?

              Oh, sorry. Yeah, you're right. I was (mistakenly) assuming that ICMP was on top of UDP, which Qt can handle natively. But since ICMP is actually a lower level protocol, it would indeed require platform-dependent code.

              Cheers.

              1 Reply Last reply
              1

              • Login

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