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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

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

Reply
 
LinkBack Thread Tools Display Modes
Old 06-29-2010, 10:56 AM   #1 (permalink)
el guaje
 
kevinyide's Avatar
 
Join Date: Jun 2010
Posts: 243
kevinyide is on a distinguished road
Send a message via Yahoo to kevinyide
Unhappy Programmatically get WiFi Gateway, DNS info

I am able to get the wifi IP address information to which my iPhone is connected from the following code that i found online:
Code:
- (NSString *)getIPAddress
{ 
    NSString *address = @"error";
    struct ifaddrs *interfaces = NULL;
    struct ifaddrs *temp_addr = NULL;
    int success = 0; // retrieve the current interfaces - returns 0 on success  
    
    success = getifaddrs(&interfaces); 
    if (success == 0) 
    { 
        // Loop through linked list of interfaces  
        temp_addr = interfaces; 
        while(temp_addr != NULL) 
        { 
            if(temp_addr->ifa_addr->sa_family == AF_INET) 
            { 
                // Check if interface is en0 which is the wifi connection on the iPhone  
                if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"])  
                { 
                    // Get NSString from C String  
                    address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
                } 
            } 
        temp_addr = temp_addr->ifa_next; 
        } 
    } 
    
    // Free memory  
    freeifaddrs(interfaces);
    return address; 
}
Is it possible to identify the DNS & gateway information as well?
Any code that does it?
Thanks,
Kevin
kevinyide is offline   Reply With Quote
Old 07-01-2010, 01:51 AM   #2 (permalink)
el guaje
 
kevinyide's Avatar
 
Join Date: Jun 2010
Posts: 243
kevinyide is on a distinguished road
Send a message via Yahoo to kevinyide
Exclamation Update

figured that
Code:
temp_addr->ifa_netmask
temp_addr->ifa_dstaddr
would get me the subnet mask & broadcast address.
Anyone knowing how to get the DNS info or Gateway address?
kevinyide is offline   Reply With Quote
Old 11-23-2010, 10:57 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 1
eyalbern is on a distinguished road
Default

any luck in finding the DNS ?
eyalbern is offline   Reply With Quote
Reply

Bookmarks

Tags
dns, gateway., iphone, wifi

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: 327
7 members and 320 guests
anothermine, Chickenrig, Domele, givensur, michaelhansen, PixelInteractive, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0