This will probably also work for iPod/iPad also, but i don't have those.
Enable "tethering" (don't you just love these web2.0 yuppie words? pfff...) in your device. Go to settings, network, internet tethering, and activate it.
1. Kernel iPhone USB ethernet support
There's a kernel module if_ipheth.ko in FreeBSD 8-STABLE (8.2-PRERELEASE as of writing this text), i'm not sure about earlier versions. I had the file in 8.1-RELEASE, but i can't say would it work because i haven't completed the whole procedure under 8.1-RELEASE.
So just kldload that file and/or include it in your /boot/loader.conf
2. USB libraries needed for communication
We'll need libimobiledevice, libplist, usbmuxd and ipheth_pair. usbmuxd will establish connection to iPhone, and it needs libimobiledevice as a main dependency. libplist comes as libimobiledevice dependency. ipheth_pair will do actual pairing, communicating with device via usbmuxd. Before that happens we can't use iPhone as gateway.
If all goes ok, you'll have a functioning usbmuxd under /usr/local/sbin/usbmuxd. Now we need to take care of pairing program;
Forget the Makefile and just run this;
3. Running / testing procedure
Hook up your iPhone to USB port, and you should see something like this from your kernel output;
Now, run usbmuxd as root in foreground mode, so we see it's output
This output indicates that communication to device has been established;
OK, let's now recheck kernel output via dmesg, kernel driver should now be able to create an ethernet device for iPhone's gateway connection;
So the device ue0 is created, but until we pair we won't have connectivity. Go back to the directory where you compiled ipheth-pair and run it. If all goes well it'll just drop you back to prompt without error message, and the blue title "Internet Tethering" will start blinking below the status bar of your iPhone.
Just poll the device via DHCP and you're good to go.
Note : for some reason, DHCP client does not push default gateway to my routing table and DNS server entry into resolv.conf. Default gw is the address you'll get your lease from (in my case 172.10.20.1), but the DNS server isn't, in my case it's 10.48.65.30 (note it's still private scope). I had to connect my phone to Windows machine to see what kind of address USB<->ETH adapter over there gets.
I haven't had time to check stability of this mechanism.
Enable "tethering" (don't you just love these web2.0 yuppie words? pfff...) in your device. Go to settings, network, internet tethering, and activate it.
1. Kernel iPhone USB ethernet support
There's a kernel module if_ipheth.ko in FreeBSD 8-STABLE (8.2-PRERELEASE as of writing this text), i'm not sure about earlier versions. I had the file in 8.1-RELEASE, but i can't say would it work because i haven't completed the whole procedure under 8.1-RELEASE.
So just kldload that file and/or include it in your /boot/loader.conf
2. USB libraries needed for communication
We'll need libimobiledevice, libplist, usbmuxd and ipheth_pair. usbmuxd will establish connection to iPhone, and it needs libimobiledevice as a main dependency. libplist comes as libimobiledevice dependency. ipheth_pair will do actual pairing, communicating with device via usbmuxd. Before that happens we can't use iPhone as gateway.
$ wget --no-check-certificate [url=http://github.com/downloads/JonathanBeck/libplist/libplist-1.3.tar.bz2]http://github.com/downloads/JonathanBec ... .3.tar.bz2[/url]
$ tar xvfj libplist-1.3.tar.bz2 && cd libplist-1.3
$ mkdir build && cd build && cmake ..
$ su
# make install
$ http://www.libimobiledevice.org/downloads/libimobiledevice-1.0.4.tar.bz2
$ tar xvfj libimobiledevice-1.0.4.tar.bz2 && cd libimobiledevice-1.0.4
$ ./configure LDFLAGS="-L/usr/local/lib/"
$ su
# make install
$ wget [url=http://marcansoft.com/uploads/usbmuxd/usbmuxd-1.0.6.tar.bz2]http://marcansoft.com/uploads/usbmuxd/u ... .6.tar.bz2[/url]
$ tar xvfj usbmuxd-1.0.6.tar.bz2 && cd usbmuxd-1.0.6
$ mkdir build && cd build && cmake ..
$ su
# make install
If all goes ok, you'll have a functioning usbmuxd under /usr/local/sbin/usbmuxd. Now we need to take care of pairing program;
$ git clone [url=git://github.com/dgiagio/ipheth.git]git://github.com/dgiagio/ipheth.git[/url]
$ cd ipheth/ipheth-pair
Forget the Makefile and just run this;
$ cc -Wall -O2 ipheth-pair.c -o ipheth-pair -L/usr/local/lib -I/usr/local/include -limobiledevice
3. Running / testing procedure
Hook up your iPhone to USB port, and you should see something like this from your kernel output;
Code:
ugen7.2: <Apple Inc.> at usbus7
Now, run usbmuxd as root in foreground mode, so we see it's output
# /usr/local/sbin/usbmuxd -U root -f
This output indicates that communication to device has been established;
Code:
[14:33:13.113][3] usbmuxd v1.0.6 starting up
[14:33:13.119][3] Could not check kernel ownership of interface 0 for device 7-2: -99
[14:33:13.170][3] Connecting to new device on location 0x70002 as ID 1
[14:33:13.170][3] Initialization complete
[14:33:13.171][3] Connected to v1.0 device 1 on location 0x70002 with serial number 37edfec09f8b80ea839ddbf01cf44030d942551b
OK, let's now recheck kernel output via dmesg, kernel driver should now be able to create an ethernet device for iPhone's gateway connection;
Code:
ipheth0: <Apple Inc. iPhone, class 0/0, rev 2.00/0.01, addr 2> on usbus7
ue0: <USB Ethernet> on ipheth0
ue0: Ethernet address: 78:ca:39:75:f8:ab
So the device ue0 is created, but until we pair we won't have connectivity. Go back to the directory where you compiled ipheth-pair and run it. If all goes well it'll just drop you back to prompt without error message, and the blue title "Internet Tethering" will start blinking below the status bar of your iPhone.
Just poll the device via DHCP and you're good to go.
# dhclient ue0
Note : for some reason, DHCP client does not push default gateway to my routing table and DNS server entry into resolv.conf. Default gw is the address you'll get your lease from (in my case 172.10.20.1), but the DNS server isn't, in my case it's 10.48.65.30 (note it's still private scope). I had to connect my phone to Windows machine to see what kind of address USB<->ETH adapter over there gets.
I haven't had time to check stability of this mechanism.