• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: attached gateways
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: attached gateways


  • Subject: Re: attached gateways
  • From: "Jamie Wood" <email@hidden>
  • Date: Tue, 28 Jun 2005 11:05:08 -0700

To get at the router addresses that System Preferences is reporting, try System Configuration:

[jwood-pb:~] jwood% scutil
open
show State:/Network/Service/6/IPv4
<dictionary> {
 SubnetMasks : <array> {
   0 : 255.255.0.0
 }
 Addresses : <array> {
   0 : 10.11.254.63
 }
 Router : 10.11.0.1
 InterfaceName : en0
}
show State:/Network/Service/7/IPv4
<dictionary> {
 SubnetMasks : <array> {
   0 : 255.255.248.0
 }
 Addresses : <array> {
   0 : 172.24.145.162
 }
 Router : 172.24.144.1
 InterfaceName : en1
}


As you can see, the "Router" strings under State:/Network/Service/<service_id>/IPv4 will give the default route for the corresponding interface. You will just need to figure out which service ID corresponds to which interface (if you even care about that), or iterate through all the services and get the router addresses. This might change if you aren't using DHCP - I didn't try any other form of network configuration.


Search for "System Configuration" on developer.apple.com to learn more about the APIs, or search the archives of this mailing list.

Hope this helps,
Jamie


From: Dalton Hamilton <email@hidden>
To: Chase <email@hidden>
CC: email@hidden
Subject: Re: attached gateways
Date: Tue, 28 Jun 2005 19:15:02 +0200

Listen, if you really want to dynamically discover all available routers in a broadcast domain then you're going to need to use the method you were heading down. You need to join the multicast group and then read from the socket. However, if you're testing, you need to make IRDP is enabled on the router -- otherwise, you'll never receive anything.....



On Jun 28, 2005, at 6:55 PM, Chase wrote:

fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

Here is what the code to read from it looks like:

struct sockaddr_in from;
socklen_t len;
char buf[8192];
int result;

result = recvfrom(fd, buf, 8192, 0, (struct sockaddr *)&from, &len);

Hope this helps,


Thanks. It yields the same net effect, unfortunately.



Before I travel too far down this tangent (and drag you all with me), let me go back to the simple goal I'm trying to achieve:

My application simply needs to know the addresses of **all** of the routers attached to the computer's various networking interfaces.

For example, on my ibook, I have an airport connection to one router (192.168.0.250) and a cat5 connection to another router (192.168.1.250).

When I open system prefs, click "Network", and look at the TCP/IP section of Airport, I see "Router: 192.168.0.250".

When I look at the TCP/IP section for Built-in Ethernet, I see "Router: 192.168.1.250".


What is the simplest way to get that exact same information?

That's all I want.

- Chase


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: attached gateways
      • From: Chase <email@hidden>
References: 
 >Re: attached gateways (From: Dalton Hamilton <email@hidden>)

  • Prev by Date: Re: attached gateways
  • Next by Date: Re: attached gateways
  • Previous by thread: Re: attached gateways
  • Next by thread: Re: attached gateways
  • Index(es):
    • Date
    • Thread