Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any private api to monitor network traffic on iPhone?

I need to implement an app that monitors inbound/outbound connections by different apps on iPhone. my app is going to run in background using apple's background multitasking feature for voip and navigators. I can use private api as my client doesn't need this app on appstore.

Thanks.

like image 485
virata Avatar asked Dec 18 '12 12:12

virata


1 Answers

I got through this.

I didn't need any private Api to get information of inbound/outbound active connections. Its just you need to know basic C programming and some patience.

I wrote to apple dev forums regarding this,and got response as-

From my perspective most of what I have to say about this issue is covered in the post referenced below.

<https://devforums.apple.com/message/748272#748272>>

The way to make progress on this is to:

o grab the relevant headers from the Mac OS X SDK

o look at the Darwin source for netstat to see how the pieces fit together

WARNING: There are serious compatibility risks associated with shipping an app that uses this technique; it's fine to use this for debugging and so on, but I recommend against shipping code like this to end users.

What I did step by step is -

1)downloaded code of netstat from BSD opensource -

2)add this to your new iphone project.

3)see,some header files are not present in ios sdk so you need take it copied from opensource.apple.com and add those in your iphone sdk at relevant path under-

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include

My xcode version is 4.5.2. so this is path relevent to my xcode. you can have different path according to versions of xcodes.Anyway. and remember to add those headers in both iosSdk & iOSSimulatorSdk both so that code will work on device as well as on simulator.

4)you may find some minor errors in netstat code relating not finding definitions of some structures in header files.e.g " struct xunpcb64 " .dont wory. definitions are present there.you need to comment some "#if !TARGET_OS_EMBEDDED" #else in those header files so that ios sdk can reach in those if condition and access the definition.(need some try and error.be patient.)

5)finally you will be abe to compile your code.Cheers!!

like image 70
virata Avatar answered Nov 02 '22 23:11

virata