• 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: Get Router using SystemConfigration Framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get Router using SystemConfigration Framework


  • Subject: Re: Get Router using SystemConfigration Framework
  • From: Quinn <email@hidden>
  • Date: Mon, 26 Jan 2009 10:58:19 +0000

You can get this information from the dynamic store.  For example:

$ scutil
l> list
subKey [0] = Plugin:IPConfiguration
subKey [1] = Plugin:InterfaceNamer
[...]
subKey [40] = State:/Network/Service/8F28FF39-E1AE-41A2-AC5B-E6940730E8E7/IPv4
[...]
show State:/Network/Service/8F28FF39-E1AE-41A2-AC5B-E6940730E8E7/IPv4
<dictionary> {
  Router : 10.0.40.1
  Addresses : <array> {
    0 : 10.0.40.15
  }
  SubnetMasks : <array> {
    0 : 255.255.255.0
  }
  InterfaceName : en0
  [...]
}

You can do a similar thing using the System Configuration framework dynamic store API:

o Iterate over all of the IPv4 network services in the "State" domain. Use SCDynamicStoreKeyCreateNetworkServiceEntity to build the key pattern, with the domain kSCDynamicStoreDomainState, the service ID of kSCCompAnyRegex, and the entity as IPv4. Then wrap this pattern inside CFArray and pass it to the patterns parameter of SCDynamicStoreCopyMultiple.

o Within each result, get the kSCPropInterfaceName property, looking for "en0". Then get the kSCPropNetIPv4Router to get the router info.

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
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: Get Router using SystemConfigration Framework
      • From: Link Dupont <email@hidden>
References: 
 >Get Router using SystemConfigration Framework (From: Link Dupont <email@hidden>)

  • Prev by Date: Re: Documentation/purpose for com.apple.network.identification key in SystemConfiguration?
  • Next by Date: Re: Get Router using SystemConfigration Framework
  • Previous by thread: Get Router using SystemConfigration Framework
  • Next by thread: Re: Get Router using SystemConfigration Framework
  • Index(es):
    • Date
    • Thread