开发者

How to use "adb ppp"?

I am trying to connect from my Android device to the host using usb and ppp.

There seems to be an option "adb ppp " that can be used. But I can't find an explanation on how to use it. There is an old discussion here. But they ended patching adb. I can't believe this hasn't being fixed by now.

http://forum.xda-developers.com/showthread.php?p=4537323

开发者_JAVA百科

This is the explanation of the adb command, and that is all the documentation I have been able to find.

networking:
  adb ppp  [parameters]   - Run PPP over USB.
 Note: you should not automatically start a PPP connection.
  refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
 [parameters] - Eg. defaultroute debug dump local notty usepeerdns

I am not clear on what the tty argument. Looking at the sources it seems to be a service such as "shell", "host:version", etc. Or it could be (as the doc says) dev:/dev/* but I don't know which to use.

Also, the command seems to fork a ppp in the host. But, I don't know how it runs on the android device.


PTY/TTY is basically a serial line tunnel using file handles. Just like sockets, the PTY is the server side and the TTY the client.

Below an example command that could work.

adb ppp "shell:pppd nodetach noauth noipdefault /dev/tty" nodetach noauth noipdefault notty <local-ip>:<remote-ip>


Ok and to use this to f.e. make a backup of your system partition (alternative to unpacking a nandroid backup with unyaffs2):

  1. connect device with USB debugging enabled
  2. start an SSH server (via app or deb s with debian-kit set up)
  3. for password-less login transfer host key to device f.e. via

    adb push /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
    
  4. setup network bridge between host (10.0.0.1) and device (10.0.0.2):

    adb ppp "shell:pppd nodetach noauth noipdefault /dev/tty" \
    nodetach noauth noipdefault notty 10.0.0.1:10.0.0.2
    
  5. backup system partition (needs rsync executable on device, i.e. full debian or custom busybox build):

    rsync -vaiuhhP 10.0.0.2:/system /where/to/backup/

    -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
    -P                          same as --partial --progress
        --partial               keep partially transferred files
        --progress              show progress during transfer
    -u, --update                skip files that are newer on the receiver
    -i, --itemize-changes       output a change-summary for all updates
    -v, --verbose               increase verbosity
    -h, --human-readable        output numbers in a human-readable format
                               (if the option is repeated, the
                                units are powers of 1024 instead of 1000.)
    -z, --compress              compress file data during the transfer
    

Comes down to about 9 minutes for my xperia mini pro with Android 4.04/RealICS custom firmware:

sent 27.94K bytes received 215.94M bytes 413.75K bytes/sec total size is 321.52M speedup is 1.49


adb's ppp option is not working for me. Here's how I got around it...

You may need to install busybox on the device to get the "nc" command.

In one window, type in...

adb shell
su
nc -ll -p 7001 -e pppd notty defaultroute nodetach

In another window type in...

adb forward tcp:7001 tcp:7001
sudo /usr/sbin/pppd nodetach 10.0.1.1:10.0.1.2 pty "nc localhost 7001"

Now there's networking from the device to the computer. Run "ifconfig" to check.

If you want the device to get normal internet you'll need to set up some SNAT routing on the host machine.


If adb ppp fail on your device, and you have root permission, try this:

    adb ppp "shell:su -c 'pppd nodetach noauth noipdefault /dev/tty'" \
nodetach noauth noipdefault notty 10.0.0.1:10.0.0.2
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜