RE: Get the Mac address programmatically
RE: Get the Mac address programmatically
- Subject: RE: Get the Mac address programmatically
- From: "Jerry" <email@hidden>
- Date: Fri, 11 May 2007 13:34:14 -0700
Hi,
Thanks for the help. I tried this sample but it does not list all network
interface's Mac addresses. If I have multiple network cards, such as
Ethernet and Airport, it only shows the Ethernet's Mac address. I need a
solution that can list all active network card's Mac addresses on a Mac
machine.
Using System Configuration framework can give me all the MAC addresses of
network interfaces. I am still don't understand how come the dynamic store
does not reflect the hardware change after re-image a Mac. The only
assumption I have is that the System Configuration framework did not
communicates with a system-level daemon, configd, to manage network
configuration according to the Apple's
<http://developer.apple.com/documentation/Networking/Conceptual/SystemConfig
Frameworks/SC_UnderstandSchema/chapter_4_section_3.html> reference. Are
there other possibilities why the dynamic store contain the same MAC address
from the other machine that was used to create an OS image?
Thanks,
Jerry
-----Original Message-----
From: Shawn Erickson [ <mailto:email@hidden> mailto:email@hidden]
Sent: Thursday, May 10, 2007 6:11 PM
To: Jerry
Cc: email@hidden
Subject: Re: Get the Mac address programmatically
On 5/10/07, Jerry <email@hidden> wrote:
You can access the MAC address via IOKit.
Apple even has sample code showing how to do this. :)
< <http://developer.apple.com/samplecode/GetPrimaryMACAddress/index.html>
http://developer.apple.com/samplecode/GetPrimaryMACAddress/index.html>
-Shawn
On May 10, 2007, at 8:50 PM, Jerry wrote:
> Hi,
>
> Is there a way to directly retrieve the MAC address
> programmatically without
> using the System Configuration Framework?
>
> I was using the system configuration dynamic store to get the Mac
> address in
> my application, however, a client told me that the Mac address show
> in my
> application was incorrect. In other words, the Mac address they saw
> by using
> "ifconfig" is different from what they got using "scutil" in
> Terminal (my
> application shows the same wrong Mac address as in the scutil tool).
>
> Ex.
> Using "ifconfig en0" ==>> ether 00:03:93:c0:b1:08
> Then "scutil" with query "show Setup:/Network/Service/0/Ethernet" ==>>
> MACAddress : 00:0d:93:6c:1a:14
>
> The customer said all of their Macs have the same issue because
> they have
> all been imaged from the same MacOSX image. When they used ifconfig
> on each
> Mac, they all got the correct Mac address. But when they use scutil
> to query
> the dynamic store, all Macs show the same value which is 00:0d:
> 93:6c:1a:14.
> Since they have confirmed the issue, I believe the same Mac address
> was
> copied to many Mac machines and somehow the dynamic store did
> refresh its
> network state.
>
> According to the document:
>
> "In a running Mac OS X system, the dynamic store contains a
> snapshot of the
> current network state..." link
> <http://developer.apple.com/documentation/Networking/Conceptual/
> SystemConfig
> Fram> and
> "The System Configuration framework communicates with a system-
> level daemon,
> configd, to manage network configuration..."
> <http://developer.apple.com/documentation/Networking/Conceptual/
> SystemConfig
> Fram> link
>
> I think the configd is running on their Macs. Thus, the dynamic
> store should
> have the latest network status and the Mac address in the dynamic
> store
> should match the actual network card on each Mac machine. How come the
> dynamic store did not have the up-to-date information regarding the
> network
> status? If system configuration framework is not reliable, is there
> another
> way that I can get the accurate Mac address programmatically?
>
> Thanks,
> Jerry
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden