I'd like to be able to automatically create a socks tunnel from my ipad through my iphone to a remote server. I'm looking for leads on how to do this.

Ideally, the ipad would automatically create an ssh connection over bluetooth to the iphone. The iphone would then automatically ssh to the host machine over 3G. I also need someway of routing the network traffic of the ipad through this tunnel.

Ideas on how to do this?