 |
 |
|
 |
10-10-2008, 04:57 AM
|
#1 (permalink)
|
|
Junior Member
Join Date: Oct 2008
Posts: 5
Rep Power: 0
|
iPhone MAC-Address ???
How can i get the iPhones (Wi-Fi) MAC-Address ?
in "SystemConfiguration.framework" is a Function that seems to tell the MAC but has the "__IPHONE_NA" -> Not Available >>>>
CFStringRef
SCNetworkInterfaceGetHardwareAddressString (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_NA);
"<IOKit/network/IOEthernetController.h>" isn't available on iPhone, too.
Please help me...
|
|
|
10-10-2008, 08:02 AM
|
#2 (permalink)
|
|
Senior Member
Join Date: Sep 2008
Posts: 279
Rep Power: 1
|
Quote:
Originally Posted by md582
How can i get the iPhones (Wi-Fi) MAC-Address ?
in "SystemConfiguration.framework" is a Function that seems to tell the MAC but has the "__IPHONE_NA" -> Not Available >>>>
CFStringRef
SCNetworkInterfaceGetHardwareAddressString (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_NA);
"<IOKit/network/IOEthernetController.h>" isn't available on iPhone, too.
Please help me...

|
My router gave me mine.. but I guess you want it programatically?
|
|
|
10-10-2008, 06:45 PM
|
#3 (permalink)
|
|
Junior Member
Join Date: Oct 2008
Posts: 5
Rep Power: 0
|
yes, programatically !!!
i see it @*preferences > general > info ! But i need it in my program !!!
|
|
|
10-12-2008, 06:43 AM
|
#5 (permalink)
|
|
Junior Member
Join Date: Oct 2008
Posts: 5
Rep Power: 0
|
I think the iPhone doesn't have a IPv6 Address ? I only get the IPv4 with this code ! And IPv6 is not the MAC-Address !?
I thought i can use the <in.h> like this >>
...
struct ifreq ifr;
...
a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
printf("%02x:%02x:%02x:%02x:%02x:%02x\n", a[0],a[1],a[2],a[3],a[4],a[5]);
...
but the <in.h> hasn't the "ifr_hwaddr" like Linux has !! ??
see this >> from my Mac !!!
struct ifreq {
#ifndef IFNAMSIZ
#define IFNAMSIZ IF_NAMESIZE
#endif
char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
short ifru_flags;
int ifru_metric;
int ifru_mtu;
int ifru_phys;
int ifru_media;
int ifru_intval;
caddr_t ifru_data;
struct ifdevmtu ifru_devmtu;
struct ifkpi ifru_kpi;
} ifr_ifru;
and this from Linux >>>
166 union {
167 struct sockaddr ifru_addr;
168 struct sockaddr ifru_dstaddr;
169 struct sockaddr ifru_broadaddr;
170 struct sockaddr ifru_netmask;
171 struct sockaddr ifru_hwaddr;
172 short ifru_flags;
173 int ifru_ivalue;
174 int ifru_mtu;
175 struct ifmap ifru_map;
176 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
177 char ifru_newname[IFNAMSIZ];
178 void __user * ifru_data;
179 struct if_settings ifru_settings;
180 } ifr_ifru;
on my MAC (and iPhone) i'm missing the "ifr_hwaddr" !!
|
|
|
10-12-2008, 10:44 AM
|
#6 (permalink)
|
|
Senior Member
Join Date: Sep 2008
Posts: 1,431
Rep Power: 2
|
Yes, the phone has no IPv6 address, and the IPv6 address isn't the MAC address.
One other thought. On the Mac ifconfig can figure out the Mac address. The ifconfig source is opensource as part of Darwin. You can get it from this page:
Apple - Public Source - Darwin - Projects
It's in a project called network_cmds.
Of course the sources on that page aren't necessarily sources that will work on the phone.
|
|
|
10-12-2008, 12:18 PM
|
#7 (permalink)
|
|
Junior Member
Join Date: Oct 2008
Posts: 5
Rep Power: 0
|
i have downloaded this and it seems that it uses "ioctl" for this....
but i can't get it working...
|
|
|
10-12-2008, 01:07 PM
|
#8 (permalink)
|
|
Senior Member
Join Date: Sep 2008
Posts: 1,431
Rep Power: 2
|
I guess it's possible that ioctl is disabled as part of the sandbox.
Why do you want the machine's MAC address?
Maybe you need to use up one of your support incidents to figure this out.
Some time in the next week or so the NDA should be officially lifted by Apple and it should be possible to ask this kind of question on the Apple networking list and get an answer.
|
|
|
10-25-2008, 12:59 PM
|
#9 (permalink)
|
|
Junior Member
Join Date: Oct 2008
Posts: 5
Rep Power: 0
|
the code
If someone else needs it :
This is the code > (i got help from devforums.apple.com)
Quote:
#if ! defined(IFT_ETHER)
#define IFT_ETHER 0x6/* Ethernet CSMACD */
#endif
- (IBAction)testActionid)sender
{
#pragma unused(sender)
BOOL &nb sp;   ; success;
struct ifaddrs * addrs;
const struct ifaddrs * cursor;
const struct sockaddr_dl * dlAddr;
const uint8_t * base;
int &nbs p; i;
success = getifaddrs(&addrs) == 0;
if (success) {
cursor = addrs;
while (cursor != NULL) {
& nbsp; fprintf(stderr, "%s\n", cursor->ifa_name);
& nbsp; if ( (cursor->ifa_addr->sa_family == AF_LINK)
& nbsp; && (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER) ) {
& nbsp; dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;
& nbsp; fprintf(stderr, " sdl_nlen = %d\n", dlAddr->sdl_nlen);
& nbsp; fprintf(stderr, " sdl_alen = %d\n", dlAddr->sdl_alen);
& nbsp; base = (const uint8_t *) &dlAddr->sdl_data[dlAddr->sdl_nlen];
& nbsp; fprintf(stderr, " ");
& nbsp; for (i = 0; i < dlAddr->sdl_alen; i++) {
& nbsp; if (i != 0) {
& nbsp; fprintf(stderr, ":");
& nbsp; }
& nbsp; fprintf(stderr, "%02x", base[i]);
& nbsp; }
& nbsp; fprintf(stderr, "\n");
& nbsp; }
& nbsp; cursor = cursor->ifa_next;
}
freeifaddrs(addrs);
}
}
|
of course ignore the "&NBSP;"s !
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
|
» Online Users: 167 |
| 13 members and 154 guests |
| aki, Alexman, atsd, BostonMerlin, bret, dejuan, lepetitapps, Neverever, P-atr1k, Raphy, Sekharbethalam, Slecorne, _mubashir |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 8,174
Threads: 20,132
Posts: 89,979
Top Poster: RickMaddy (2,121)
|
| Welcome to our newest member, bret |
|