HowTO use DUN on arm-xscale

来源:互联网 发布:淘宝光威鱼竿有假的吗 编辑:程序博客网 时间:2024/06/05 04:59

1. Precondition
1.1)pppd and chat have been cross compiled and been placed in the /usr/sbin/ of the target(arm) file system.
         
1.2) Dial-up related script should be existing in the /etc/ppp/ of the
         target(arm) file system(I modifed ppp-2.4.4/scripts/ppp-on ppp-on-dialer ppp-off)
        
[File ppp-on]        
#!/bin/sh
#
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command.  However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=*99***1/#  # The telephone number for the connection
ACCOUNT=  # The account name for logon (as in 'George Burns')
PASSWORD=  # The password for this account (and 'Gracie Allen')
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
#
# Export them so that they will be available at 'ppp-on-dialer' time.
export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in.  Please use the absolute file name as the $PATH variable is not
# used on the connect option.  (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/etc/ppp/dialer.script
#
# Initiate the connection
#
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#
 /usr/sbin/pppd debug lock modem crtscts $1 115200 /
 asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP /
 noipdefault netmask $NETMASK defaultroute usepeerdns connect $DIALER_SCRIPT
 
 
[File ppp-on-dialer]
#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#

 #OK      'AT+CGACT=1,1'     /
exec chat -v         /
 TIMEOUT  25        /
 ABORT  '/nBUSY/r'      /
 ABORT  '/nNO ANSWER/r'     /
 ABORT  '/nRINGING/r/n/r/nRINGING/r' /
 ''  /rAT      /
 'OK-+++/c-OK' ATH0    /
 TIMEOUT  40      /
 OK      'AT+CGDCONT=1,"IP","CMNET"' /
 OK  ATDT$TELEPHONE    /
 CONNECT  ''      /
 ogin:  $ACCOUNT    /
 assword: $PASSWORD  
 
[File ppp-off]
这个脚本不用修改.
 1.3) 需要将ppp协议相关的module 编译进内核 分别是
 slhc.ko ppp_generic.ko crc-ccitt.ko zlib_deflate.ko ppp_synctty.ko ppp_deflate.ko ppp_async.ko bsd_comp.ko

 

2. run bluetooth dun on arm-xscale

#mknod /dev/ppp c 108 0
#chmod guo+rwx /dev/ppp
#insmod slhc.ko
#insmod ppp_generic.ko
#insmod crc-ccitt.ko
#insmod zlib_deflate.ko
#insmod ppp_synctty.ko
#insmod ppp_deflate.ko
#insmod ppp_async.ko
#insmod bsd_comp.ko

接下来建立Bluetooth DUN 连接
现在所用的协议栈非BlueZ, 没有/dev/RFCOMM0 设备,所以建立Bluetooth DUN 连接的时候还必须建立一个Linux伪终端(Pseudo Terminal),供pppd脚本使用
#...
蓝牙DUN连接建立后就可以拨号
#/etc/ppp/ppp-on /dev/pts/X    <-- 这里/dev/pts/X 相当于BlueZ的 /dev/RFCOMM0
拨号成功可以看到

#ifconfig

ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.60.172.137  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:58 (58.0 B)  TX bytes:128 (128.0 B)
         

接下来还需要设置dns,修改/etc/resolv.conf
nameserver 211.136.112.50
nameserver 211.136.20.203

 

# ping www.sina.com.cn
PING hydra.sina.com.cn (218.30.108.184): 56 data bytes
64 bytes from 218.30.108.184: icmp_seq=0 ttl=51 time=726.6 ms
64 bytes from 218.30.108.184: icmp_seq=1 ttl=51 time=731.9 ms
64 bytes from 218.30.108.184: icmp_seq=2 ttl=51 time=901.9 ms


这样有浏览器的话就可以上网了。

原创粉丝点击