Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-25-2008, 01:59 PM   #9 (permalink)
md582
Registered Member
 
Join Date: Oct 2008
Posts: 6
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
 

» Advertisements
» Stats
Members: 158,848
Threads: 89,214
Posts: 380,662
Top Poster: BrianSlick (7,129)
Welcome to our newest member, somple3ahian
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:41 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.