ppp and ndis

来源:互联网 发布:网络流行伤感歌曲大全 编辑:程序博客网 时间:2024/04/28 12:32

转http://blog.csdn.net/opencpu/article/details/8050139

3g wcdma

http://wenku.baidu.com/view/9811fcfcf705cc17552709c6.html
http://wenku.baidu.com/view/27a345fcf705cc1755270970.html
http://blog.csdn.net/hens007/article/details/7255488

2g gprs
http://wenku.baidu.com/view/acffc7ebf8c75fbfc77db2ec.html

基本情况:
内核需支持ppp协议,也要支持这个usb设备,
ppp client调用pppd进行拨号,pppd会调用chat程序与远程的ppp server会话。

tiny6410 e261上网卡拨号流程:

首先配置驱动:
[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. 3g设备驱动支持  
  2. Device Drivers  --->  
  3.  [*] USB support  --->  
  4.  <*>   USB Serial Converter support  --->    
  5.  [*]   USB Generic Serial Driver   
  6.  <*>   USB driver for GSM and CDMA modems     
  7. ppp协议支持  
  8. [*] Network device support  --->  
  9. <*>   PPP (point-to-point protocol) support   
  10. [*]     PPP multilink support (EXPERIMENTAL)   
  11. [*]     PPP filtering  
  12. <*>     PPP support for async serial ports   
  13. <*>     PPP support for sync tty ports  
  14. <*>     PPP Deflate compression   


假设3g模块(或上网卡)插在板子上已经被识别成了/dev/ttyUSBx了,进行pppd拨号的程序如下
1.编译pppd源码,将生产的pppd,chat搞到板子的/usr/sbin下
2.在/etc下创建ppp目录
3.ppp下创建pap-chat文件,和peers目录

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. [root@hemei]# cat pap-secrets   
  2. cmnet   *       cmnet *  

4.在peers目录下创建
wcdma和chat-wcdma-connect和chat-wcdma-disconnect//用于联通3g的拨号脚本
cdma2000和chat-cdma2000-connect和chat-cdma2000-disconnect//电信3g
tdscdma和chat-tdscdma-connect 和chat-tdscdma-disconnect//移动3g
内容如下:

联通3g

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. [root@hemei]# cat wcdma   
  2. nodetach  
  3. lock  
  4. /dev/ttyUSB0  
  5. 921600  
  6. user "card"  
  7. password "card"  
  8. crtscts  
  9. show-password  
  10. usepeerdns  
  11. noauth  
  12. noipdefault  
  13. novj  
  14. novjccomp  
  15. noccp  
  16. defaultroute  
  17. ipcp-accept-local  
  18. ipcp-accept-remote  
  19. connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-wcdma-connect'  
  20. disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-wcdma-disconnect'  
  21.   
  22. [root@hemei]# cat chat-wcdma-connect   
  23. ABORT 'NO CARRIER'  
  24. ABORT 'ERROR'  
  25. ABORT 'NO DIALTONE'  
  26. ABORT 'BUSY'  
  27. ABORT 'NO ANSWER'  
  28. '' AT  
  29. OK ATZ  
  30. OK AT+CGDCONT=1,\"IP\",\"3gnet\",,0,0  
  31. OK AT+CFUN=1  
  32. OK ATDT*99#  
  33. CONNECT ''  
  34.   
  35. [root@hemei]# cat chat-wcdma-disconnect   
  36. ABORT  OK  
  37. ABORT  BUSY  
  38. ABORT  DELAYED  
  39. ABORT  "NO ANSWER"  
  40. ABORT  "NO CARRIER"  
  41. ABORT  "NO DIALTONE"  
  42. ABORT  VOICE  
  43. ABORT  ERROR  
  44. ABORT  RINGING  
  45. TIMEOUT  12  
  46. ""  \K  
  47. ""  \K  
  48. ""  \K  
  49. ""  +++ATH  
  50. ""  +++ATH  
  51. ""  +++ATH  
  52. ""  ATZ  
  53. SAY "\nGoodbay\n"  
  54. [root@hemei]#   

电信3g
[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. [root@hemei]# cat cdma2000   
  2. nodetach  
  3. lock  
  4. /dev/ttyUSB0  
  5. 921600  
  6. user "ctnet@mycdma.cn"  
  7. password "vnet.mobi"  
  8. crtscts  
  9. hide-password  
  10. usepeerdns  
  11. noauth  
  12. noipdefault  
  13. novj  
  14. novjccomp  
  15. noccp  
  16. defaultroute  
  17. ipcp-accept-local  
  18. ipcp-accept-remote  
  19. connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-cdma2000-connect'  
  20. disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-cdma2000-disconnect'  
  21. [root@hemei]#   
  22. [root@hemei]# cat chat-cdma2000-connect   
  23. ABORT 'NO CARRIER'  
  24. ABORT 'ERROR'  
  25. ABORT 'NO DIALTONE'  
  26. ABORT 'BUSY'  
  27. ABORT 'NO ANSWER'  
  28. '' AT  
  29. OK ATZ  
  30. OK AT+CFUN=1  
  31. OK ATDT#777  
  32. CONNECT ''   
  33. [root@hemei]#   
  34. [root@hemei]# cat chat-cdma2000-disconnect   
  35. ABORT  OK  
  36. ABORT  BUSY  
  37. ABORT  DELAYED  
  38. ABORT  "NO ANSWER"  
  39. ABORT  "NO CARRIER"  
  40. ABORT  "NO DIALTONE"  
  41. ABORT  VOICE  
  42. ABORT  ERROR  
  43. ABORT  RINGING  
  44. TIMEOUT  12  
  45. ""  \K  
  46. ""  \K  
  47. ""  \K  
  48. ""  +++ATH  
  49. ""  +++ATH  
  50. ""  +++ATH  
  51. ""  ATZ  
  52. SAY "\nGoodbay\n"  
  53. [root@hemei]#   

移动3g
[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. [root@hemei]# cat tdscdma   
  2. nodetach  
  3. lock  
  4. /dev/ttyUSB0  
  5. 460800  
  6. user "cmnet"  
  7. crtscts  
  8. modem  
  9. hide-password  
  10. usepeerdns  
  11. noauth  
  12. noipdefault  
  13. novj  
  14. novjccomp  
  15. noccp  
  16. defaultroute  
  17. ipcp-accept-local  
  18. ipcp-accept-remote  
  19. connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-tdscdma-connect'  
  20. disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-tdscdma-disconnect'  
  21. [root@hemei]#   
  22. [root@hemei]# cat chat-tdscdma-connect   
  23. ABORT 'NO CARRIER'  
  24. ABORT 'ERROR'  
  25. ABORT 'NO DIALTONE'  
  26. ABORT 'BUSY'  
  27. ABORT 'NO ANSWER'  
  28. '' AT  
  29. OK ATZ  
  30. OK ATE0V1  
  31. OK ATS0=0  
  32. OK AT+CGDCONT=1,\"IP\",\"cmnet\"  
  33. OK AT+CFUN=1  
  34. OK ATDT*99***1#  
  35. CONNECT  
  36. [root@hemei]#   
  37. [root@hemei]# cat chat-tdscdma-disconnect   
  38. ABORT  OK  
  39. ABORT  BUSY  
  40. ABORT  DELAYED  
  41. ABORT  "NO ANSWER"  
  42. ABORT  "NO CARRIER"  
  43. ABORT  "NO DIALTONE"  
  44. ABORT  VOICE  
  45. ABORT  ERROR  
  46. ABORT  RINGING  
  47. TIMEOUT  12  
  48. ""  \K  
  49. ""  \K  
  50. ""  \K  
  51. ""  +++ATH  
  52. ""  +++ATH  
  53. ""  +++ATH  
  54. ""  ATZ  
  55. SAY "\nGoodbay\n"  

5.拨号
pppd call wcdma

进入目录/var/run/,查看是否产出文件 ppp0-ok,如果有,则表示已拨号成功,ppp0-ok文件内会存储IP地址和DNS。
/etc下新建resolv.conf文件,将分配到的两个DNS服务器地址,添加到此文件中,内容如下:
nameserver 210.22.70.3
nameserver 211.95.1.97

ifconfig有信息

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. [root@hemei]# ifconfig   
  2. ppp0      Link encap:Point-to-Point Protocol    
  3.           inet addr:10.45.210.114  P-t-P:10.64.64.64  Mask:255.255.255.255  
  4.           UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1  
  5.           RX packets:9 errors:0 dropped:0 overruns:0 frame:0  
  6.           TX packets:9 errors:0 dropped:0 overruns:0 carrier:0  
  7.           collisions:0 txqueuelen:3   
  8.           RX bytes:180 (180.0 B)  TX bytes:216 (216.0 B)  


6.使用如下命令切断连接
ppp-off 
kill -9 pppd进程ID 

如果3g设备插在板子上没有自动出现/dev/ttyUSBx:

使用如下命令将e261由cdrom模式转换成modem模式,此时会生成/dev/ttyUSB0-5
3g-ppp /etc/3g-modem/12d1.1446.12d1.1001
usb_modeswitch



ndis上网


1.
配置内核生成usbnet.ko (drivers/net/usb/)

Device Drivers  --->     
[*] Network device support  --->      
USB Network Adapters  ---> 
<M> Multi-purpose USB Networking Framework

编译希姆通厂家7100等模块的ndis驱动GobiNet,ko

2.
搞到板子上加载
insmod usbnet.ko 
insmod GobiNet,ko

3.
模块插在班子上,会出现
/de/qcqmi0

ifconfig -a
有usb0接口出现

4.拨号
ndismanager  /dev/qcqmi0

进入菜单进行拨号





at 原始命令拨号

模块的拨号需要相关的网络at命令的支持
比如AT+TCPCLIENT="www.baidu.com",80
0 0