Re: Getting HW built-in ethernet address
Re: Getting HW built-in ethernet address
- Subject: Re: Getting HW built-in ethernet address
- From: Tomas Zahradnicky <email@hidden>
- Date: Sat, 3 Aug 2002 00:04:28 +0200
I think the easiest way to do this on Mac OS X is to use
the System Configuration Framework. Information on each
network interface and device is available in a fairly simple
set of dictionaries.
Look at XML file /var/db/SystemConfiguration/preferences.xml
on your system to get a feel for the structure of the dictionaries.
You'll quickly recognize entries like "Ethernet Built-in"
for key "UserDefinedName" and find the corresponding hardware
address.
Of course you could use IOKit directly, but this is more complex
and intended for configuring drivers. Finally, there are a bunch
of techniques for different Ethernet hardware and software for
Mac OS 9 and below, but I would try to avoid these unless you really
need them.
Accessing the System Configuration Framework is much simpler if
you can use Cocoa. CFDictionary and CFPropertyList are just
NSDictionary with a clumsier interface. A couple things to
watch out for are:
- Each time you call into the System Configuration Framework,
previously returned dictionaries may be autoreleased.
Make sure you retain anything you want to keep around.
- Check for non-existent (null) entries at each step as you
walk through the dictionaries. Some 3rd party devices don't
provide a "UserDefinedName" for example.
Once you get it, the System Configuration Framework is a vast
improvement over the previous collection of diverse APIs.
Kind Regards,
Thanks Peter!
-Tomas
--
# Tomas Zahradnicky, Jr
# The Czech Technical University
# Dept of Computer Science, FEE-CTU Prague
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.