Titanium

[TIMOB-647] add subnet and external ip to platform API

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:53:48.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.3.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:33:38.000+0000
Updated2011-04-17T01:53:48.000+0000

Description

from ticket:

http://helpdesk.appcelerator.net/tickets/1653">http://helpdesk.appcelerator.net/tickets/1653

i believe these are available - see:

http://stackoverflow.com/questions/2023592/iphone-wifi-subnet-mask-and-router-address"> http://stackoverflow.com/questions/2023592/iphone-wifi-subnet-mask-...

Comments

  1. Stephen Tramer 2011-04-15

    Need more information. Does 'external ip' refer to the IP assigned to the phone, or the IP of the router?

  2. Stephen Tramer 2011-04-15

    I've gathered that this is what the user wants:

    • Local IP address (address assigned by network)
    • Local subnet (retrieve netmask & figure out how to apply it to local IP, or just retrieve netmask and let the user do it)
    • External IP address (address visible to the world)

    1 & 2 are possible. Getting the external IP address is much harder, unless it refers to the EDGE/3G address assigned to the phone.

    Some more notes which I'll update as time goes on, germane to using getifaddrs:

    en0: wifi
    pdp_ip0: data network
    lo0: loopback (127.0.0.1)

    Note that this code will use getifaddrs() directly, which may or may not be considered "legal" under the iPhone guidelines since it's a BSD function. This is the only way to get the information; as with sockets, the system configuration framework is crippled on iPhone.

  3. Jeff Haynie 2011-04-15

    (from [b46736df8d8bbcebfe3d9c5820a7ea681db0343b]) Closes #647: 'address' now works right, 'dataAddress' and 'netmask' properties added to Platform. http://github.com/appcelerator/titanium_mobile/commit/b46736df8d8bbcebfe3d9c5820a7ea681db0343b"> http://github.com/appcelerator/titanium_mobile/commit/b46736df8d8bb...

  4. Stephen Tramer 2011-04-15

    Very important note on this fix: It's only been tested on a 2G phone. You will need to test it across a broad spectrum of devices (any model of iPod touch, 3G, 3GS) before this can be absolutely confirmed. I've closed the bug anyway.

    There's no way to get a phone's external address (beyond data) simply because the phone will always reside behind a router on wifi.

  5. Stephen Tramer 2011-04-15

    Works on my 2G, but apparently not Nolan's 3GS. Rolled back the fix and reopened until we can perform some diagnostics on all platforms and add in some emulation for simulation (since right now network information doesn't work under the simulator in most cases).

    Devices tested so far: 2G.

  6. Jeff Haynie 2011-04-15

    (from [1519d4247c4f8b88b966ca28b1cb38282411eb85]) Closes #647. Confirmed to work by me, matches information about other devices provided by Blain (thanks Blain). Comment on the bug again if netmask issues persist. http://github.com/appcelerator/titanium_mobile/commit/1519d4247c4f8b88b966ca28b1cb38282411eb85"> http://github.com/appcelerator/titanium_mobile/commit/1519d4247c4f8...

JSON Source