Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130888
  • 博文数量: 14
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 633
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-05 11:44
文章存档

2014年(14)

我的朋友

分类: LINUX

2014-08-31 23:58:12

一、配置内核支持PPP
1、进入内核源码根目录
# cd kernel

2、配置内核
# make menuconfig
进入菜单,选中一下选项
Device Drivers  ---> 
    -*- Network device support  --->                                              
        {*}   PPP (point-to-point protocol) support                                        
        [*]     PPP multilink support (EXPERIMENTAL)                                       
        [*]     PPP filtering                                                           
        <*>     PPP support for async serial ports                                   
        <*>     PPP support for sync tty ports                                              
        <*>     PPP Deflate compression                                                  
        <*>     PPP BSD-Compress compression                                            
        <*>     PPP MPPE compression (encryption) (EXPERIMENTAL)                        
        <*>     PPP over Ethernet (EXPERIMENTAL)                                         
        <*>     PPP over ATM                                                             
        <*>     PPP on L2TP Access Concentrator (NEW)                               
        <*>     PPP on PPTP Network Server (NEW)                                        
        <*>   SLIP (serial line) support                                              
        [*]     CSLIP compressed headers

3、重新编译内核
# make uImage

二、移植ppp
1、下载ppp源码
ftp://ftp.samba.org/pub/ppp/

2、解压ppp源码
# tar -xvf ppp-2.4.7.tar.gz

3、进入ppp源码
# cd ppp-2.4.7

4、执行配置脚本
# ./configure

5、编译源码
# make CC=arm-linux-gcc

6、复制文件到开发板
将./chat/chat复制到开发板的/usr/bin目录
将./pppd/pppd复制到开发板的/usr/bin目录
将./pppdump/pppdump复制到开发板的/usr/bin目录
将./pppstats/pppstats复制到开发板的/usr/bin目录

7、在开发板中建立ppp设备
# mknod /dev/ppp c 108 0
c:代表字符设备
108:主设备号
0:次设备号
# chmod 600 /dev/ppp

8、编辑开发板/etc/modules.conf文档
增加一行options ppp_async flag_time=0 

9、编辑开发板/etc/resolv.conf添加域名解析服务器地址
nameserver 211.136.17.107
211.136.17.107为GPRS域名解析服务器DNS地址

10、检查开发板/etc/host.conf脚本,确保有order hosts,bind

11、在开发板/etc/ppp/peers中建立gprs文件
#/etc/ppp/peers/gprs
# Usage:   root>pppd call gprs
/dev/s3c2410_serial1   #改成自己的端口名
115200    #改成自己串口波特率
nocrtscts #使用硬件流控制使用RTS和CTS信号
modem   #这个参数使得pppd进程将等待模块发回的CD (Carrier Detect)信号,与local真好相反
#noauth #不需要ISP认证本身
debug #把调试信息输出到/var/log/messages,在调试成功后去掉它,以减少垃圾的产生。
nodetach
#hide-password
usepeerdns #以下的3个参数一般不可少
noipdefault
defaultroute #通过PPP链路添加默认网络路由
user smsong #设置接入的用户名,在chap-secrets或者pap-secets中使用
0.0.0.0:0.0.0.0 #本地和远端的ip都设为0使得接入的isp分配本地的ip地址
ipcp-accept-local #要求peer也就是isp给自己非配动态的IP地址
#ipcp-accept-remote
#lcp-echo-failure 12
#lcp-echo-interval 3
noccp #不需要压缩控制协议,有可能对端不需要,根据自己的isp的情况
#novj
#novjccomp
persist #保证在连接断开的情况下不退出,并尝试重新打开连接
connect '/usr/sbin/chat -s -v -f /etc/ppp/gprs-connect-chat'
#pppd调用chat会话进程接入对端isp,启动对端的pppd,然后本地pppd与对端的pppd一起进行协
#商网络参数和chap/pap认证,成功后,再进行ncp层的ip的分配。

12、在开发板/etc/ppp中建立gprs-connect-chat文件
gprs-connect-chat文件是在ppp 底层会话的时候给chat进程的参数每行是一个“期望/发送”的组合序列
#!/bin/sh
#
# File:
# /etc/ppp/gprs-connect-chat
#命令字说明
#TIMEOUT:超时时间,
#SAY:输出内容,如:SAY "/n内容/n"

# The actual chat script:

exec chat /
TIMEOUT 5 /
ECHO ON /
ABORT '/nBUSY/r' /
ABORT '/nERROR/r' /
ABORT '/nNO ANSWER/r' /
ABORT '/nNO CARRIER/r' /
ABORT '/nNO DIALTONE/r' /
ABORT '/nRINGING/r/n/r/nRINGING/r' /
'' AT /
TIMEOUT 12 /
SAY "Press CTRL-C to close the connection at any stage!" /
SAY "/ndefining PDP context.../n" /
OK AT+CGATT? / #这些都是标准的at命令,建议查看随模块的at命令手册
OK AT+CGATT=1 /
OK AT+CGATT? /
OK 'AT+CGDCONT=1,"IP"' / #设置isp接入网关为中国移动的cmnet
OK AT+CGQREQ=1,0,0,3,0,0 /
OK AT+CGACT=1,1 /
OK ATDT*99***1# / #中国移动gprs的接入号吗
TIMEOUT 120 /
SAY "/nwaiting up to 2 mintues for connect.../n"/
CONNECT "" /
SAY "/nConnected. now logging in.../n" /
SAY "/nIf the following ppp negotiations fail,/n" /
SAY "try restarting the phone./n"
# NOTE: PDP context可能会因你的猫不同而有所区别,查它的手册来写吧 

13、在开发板/etc/ppp中建立gprs-disconnect-chat文件
#!/bin/sh
#
# File:
# /etc/ppp/gprs-disconnect-chat
#
# send break
exec /usr/sbin/chat -V -s -S /
ABORT "BUSY" /
ABORT "ERROR" /
ABORT "NO DIALTONE" /
SAY "/nSending break to the modem/n" /
"" "/K" /
"" "+++ATH" /
SAY "/nPDP context detached/n" 

14、在开发板/etc/ppp中建立chap-secrets文件
# File:
# /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
####### redhat-config-network will overwrite this part!!! (begin) ##########
####### redhat-config-network will overwrite this part!!! (end) ############ 
smsong * 123456 *

15、在开发板/etc/ppp中建立pap-secrets文件
# File:
#/etc/ppp/pap-secrets
# Secrets for authentication using PAP
# client server secret IP addresses
####### redhat-config-network will overwrite this part!!! (begin) ##########
####### redhat-config-network will overwrite this part!!! (end) ############
smsong * "" * 

16、在开发板中运行ppp
# pppd call gprs

17、查看日志
# tail -f /var/log/messages






阅读(3440) | 评论(0) | 转发(0) |
1

上一篇:samba移植

下一篇:linux网络编程基础

给主人留下些什么吧!~~