分享

linux ppp GPRS拨号问题

 XeonGate 2015-11-12
我3,4年前在一块ARM板子上弄通过,由于嵌入式上很多要自己做,redhat上会更简单,也更容易,如果做嵌入式,你应该先在PC上弄通,在移植到目标板上,大致给你说说,希望对你有所帮助
1. 配置kernel使它支持如下PPP选项:
PPP(point-to-point) support
PPP multilink support(EXPERIMENTAL)
PPP support for async serial prots
PPP support for sync tty ports
PPP Deflate compression
PPP BSD-Compress compression
2.编译交叉编译ppp-2.4.1,将./pppd/pppd, ,/chat/chat, ./pppdump/pppdump, ./pppstats/pppstats四个文件拷贝到嵌入式文件系统的/usr/sbin目录下,并将他们的文件属性改为755.
3.在嵌入式文件系统中:
a、 建立一个ppp设备: mknod /dev/ppp c 108 0 并改变/etc/ppp文件夹的属性:chmod 600 /etc/ppp.
b、 编辑/etc/modules.conf文档,增加一行:
options ppp_async flag_time=0
c、 编辑/etc/resolv.conf,加入一行:
nameserver 211.136.17.107(注释:这是爱立信的GPRS域名解析服务器DNS地址,当时GPRS没现在普及,为了这个地址狂打了几天电信的技术支持,但很多support好水啊,不懂装懂(借机损一下那些拿高工资又比较水的telecomer,嘿嘿,不要板砖拍我啊,怕怕的,我),最后终于问到一个帅哥,告诉了我这个。)
d、 检查/etc/host.conf脚本,确保有order hosts,bind
4.e、 /etc/ppp目录下建立如下文件(这里怎么贴附件?真晕,要我挨个贴啊,辛苦是辛苦了点,好在今天心情好,就一并贴了吧,呵呵。为了好看清楚,每个文件用“#------#”分隔,各个它们都要有可执行权限哦):
#------------------------------------------------#
# File:
# /etc/ppp/gprs
#
# Description:
# This file holds the serial cable and IrDA pppd options for GPRS phones

# Tell the ppp-daemon to accept mangled data
receive-all

# Give some debug info
debug
kdebug 7

# Print out all the option values which have been set.
dump

# Serial device to which terminal is connected;
# with serial port (COM1 in Windows) use /dev/ttyS0
# and with IrDA use /dev/ircomm0.
#/dev/ircomm0 # IrDA
/dev/ttyAM1 # serial cable (NOTE: 这个地方你要改为真正的你用的串口,比如/dev/ttyS0)


# Serial port line speed
115200

# Turn off waiting of carrier detect or flow control signal
# With IrDA it should be disabled with nocrtscts option.
-crtscts # serial cable
#nocrtscts # IrDA
# Ignore carrier detect signal from the modem
local

# To keep pppd on the terminal
nodetach

# Accept the peer's idea of our local IP address
ipcp-accept-local
# Accept the peer's idea of its (remote) IP address
ipcp-accept-remote

# IP addresses:
# - accept peers idea of our local address and set address peer as 10.0.0.1
# (any address would do, since IPCP gives 0.0.0.0 to it)
# - if you use the 10. network at home or something and pppd rejects it,
# change the address to something else
0.0.0.0:0.0.0.0

-chap
#-pap

# pppd must not propose any IP address to the peer!
#noipdefault

# No ppp compression
novj
novjccomp

papcrypt
nodeflate

#No ppp magic number
nomagic

# no asyn cmap
asyncmap 0

# Add default route
defaultroute

# Connect script
connect /etc/ppp/gprs-connect-chat

# Disconnect script
disconnect /etc/ppp/gprs-disconnect-chat

#------------------------------------------------#
# File:
# /etc/ppp/options
#
receive-all
nopcomp
noaccomp
nomagic
debug
# Mobile is connected to the first serial port
/dev/ttyAM1 (NOTE: 这个地方你要改为真正的你用的串口,比如/dev/ttyS0)
115200
connect '/usr/sbin/chat -e -f /etc/ppp/gprs-connect-chat -v'
disconnect '/usr/sbin/chat -e -f /etc/ppp/chat-disconnect -v'
modem
noauth
noccp
novj
novjccomp
defaultroute
noipdefault
user foo (NOTE:这个很重要,当时搞的我好痛苦,嘿嘿。windows下拨号可以不用用户名,但Linux不行,所以我们骗linux一下,设一个假的好了,另外,还要参见/etc/pap-secrets,呵呵)
lock

#------------------------------------------------#
#!/bin/sh
#
# File:
# /etc/ppp/chat-gprs-connect
#
# Description:
# chat script to open Sonera GPRS service with GPRS phones. If ppp
# negotiation stalls, try restarting the phone. To try with other GPRS
# operator setting, change the PDP contex setting. The settings work with
# all Ericsson models, but Nokia 8310 does not suppor QoS parameters with
# AT commands, so just delete those lines and it'll work.
#
# Set PDP context CID=1, protocol=IP, APN=internet:
# AT+CGDCONT=1,"IP","internet","",0,0
#
# Set CID=1 QoS requirements from the network, not supported by 8310:
# AT+CGQREQ=1,0,0,0,0,0
#
# Set CID=1 minimum acceptable QoS parameters, not supported by 8310:
# AT+CGQMIN=1,0,0,0,0,0
#
# 'Call' CID=1 (activate PDP context one, perform GPRS attach):
# ATD*99***1#
#
# ogin:-BREAK-ogin: /
# TIMEOUT 5 /
# assword: /
# SAY "/nLogged in OK.../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? /
OK AT+CGATT=1 /
OK AT+CGATT? /
OK 'AT+CGDCONT=1,"IP"' /
OK AT+CGQREQ=1,0,0,3,0,0 /
OK AT+CGACT=1,1 /
OK ATDT*99***1# /
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可能会因你的猫不同而有所区别,查它的手册来写吧

#------------------------------------------------#

#!/bin/sh
#
# File:
# /etc/ppp/chat-gprs-disconnect
#
# 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"
#------------------------------------------------#
# 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) ############
#------------------------------------------------#
# 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) ############
foo * "" *
剩下的文件就是那些关于ip-down,ip-up,ip-down.ipv6to4,ip-up.ipv6to4了,没啥好说的了,
最后只有祝你good luck了 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多