Home News Forum Social Networking Support Us Advertise

Spanish Lesson 1 ($1.99)

aWake!Gently ($1.99)

The Bird & The Snail - Knock Knock - Deluxe ($4.99)

Match-It Trains ($0.99)

Tangled ($0.99)

iFlatter ($0.99)

The 15 puzzle ($0.99)

Tap Forms Database ($8.99)

Higher or Lower Card Game (Hi Lo) ($0.99)

Red Pixel ($0.99)

Time-Shift Radio ($0.99)

Want your application advertised here? Only $10/week!

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-10-2008, 04:57 AM   #1 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
md582 is on a distinguished road
Question 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...
md582 is offline   Reply With Quote
Old 10-10-2008, 08:02 AM   #2 (permalink)
Senior Member
 
Join Date: Sep 2008
Posts: 279
Rep Power: 1
Kenrik is on a distinguished road
Default

Quote:
Originally Posted by md582 View Post
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?
Kenrik is offline   Reply With Quote
Old 10-10-2008, 06:45 PM   #3 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
md582 is on a distinguished road
Default

yes, programatically !!!
i see it @*preferences > general > info ! But i need it in my program !!!
md582 is offline   Reply With Quote
Old 10-10-2008, 07:07 PM   #4 (permalink)
Senior Member
 
Join Date: Sep 2008
Posts: 1,431
Rep Power: 2
PhoneyDeveloper is on a distinguished road
Default

I think it's buried deep in some network data structures. Look at the code in this post. It will run under the SDK. I think you can find the MAC address in the data structures that it queries.

How to get IPv6 address using getifaddrs and which version of glibc supports
PhoneyDeveloper is offline   Reply With Quote
Old 10-12-2008, 06:43 AM   #5 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
md582 is on a distinguished road
Default

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" !!
md582 is offline   Reply With Quote
Old 10-12-2008, 10:44 AM   #6 (permalink)
Senior Member
 
Join Date: Sep 2008
Posts: 1,431
Rep Power: 2
PhoneyDeveloper is on a distinguished road
Default

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.
PhoneyDeveloper is offline   Reply With Quote
Old 10-12-2008, 12:18 PM   #7 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
md582 is on a distinguished road
Default

i have downloaded this and it seems that it uses "ioctl" for this....

but i can't get it working...
md582 is offline   Reply With Quote
Old 10-12-2008, 01:07 PM   #8 (permalink)
Senior Member
 
Join Date: Sep 2008
Posts: 1,431
Rep Power: 2
PhoneyDeveloper is on a distinguished road
Default

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.
PhoneyDeveloper is offline   Reply With Quote
Old 10-25-2008, 12:59 PM   #9 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
md582 is on a distinguished road
Default 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; &nbsp ; 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 !
md582 is offline   Reply With Quote
Reply

Bookmarks

Tags
address, iphone, mac, wifi, wlan

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0