赞
踩
早年写的笔记,压箱底了,翻出来晒晒
目 录
加入打印信息__FUNCTION__,__FILE__,__LINE__.17
u IXDP425 266Mhz 64M ram16M flash
u FC4: kernel 2.6.11-1.1369_FC4smp(FC6 也行),安装在虚拟机上
u arm-linux-tools-20051123.tar.gz: gcc 3.4.4编译器
u snapgear-3.5.0.tar.gz:snapgear 发布的uClinux 包
u snapgear-modules-20071004.sh: snapgear 发布的uClinux 包
u Kernel files in /home/linuxuser/snapgear
u 编译器在/home/linuxuser/usr/
u rp-pppoe-3.10.tar.gz
u ppp-2.4.4.tar.gz
u RASPPPOE_098B.ZIP
先按照前面几章的内容配置内核,需要加上以太网的支持。在此基础上添加ppp的选项。uclinux2.4和uclinux2.6的配置非常的类似,下面的实验以uclinux2.6为例。
1. 选择Kernel/Library/Defaults Selection ---> Customize Kernel Settings (NEW)
2. 选择Device Drivers --->Network device support --->PPP(point-to-point protocol) support --->PPP (point-to-point protocol) support。选中之后会出现很多ppp的选项,在此全部选中就行了。
选择好以后编译内核就行了,得到ramdisk和zImage。
在snapgear-3.5.0.tar.gz的uclinux里面,本来是自带了pppd和ra-pppoe的,但是版本非常的老旧,在做模拟实验的过程中,经常有pppoe选项不支持。最新版的uclinux里面带的这两个程序是比较新的版本,但是这里以snapgear-3.5.0.tar.gz作为基础进行实验。
1. 解压ppp-2.4.4.tar.gz到/home/linuxuser/pppoe/ppp-2.4.4good
2. 进入/home/linuxuser/pppoe/ppp-2.4.4good目录,执行
./configure --host=arm-linux--build=i686-pc-linux-gnu --target=arm-linux
3. 修改makefile
利用configure生成的makefile都不适用于交叉编译。所以需要作出修改。
如果需要全部编译的话,一共有9个makefile文件需要修改,虽然最后实际上只需要pppd文件和chat文件。
ppp-2.4.4good/
ppp-2.4.4good/chat
ppp-2.4.4good/pppd/plugins
ppp-2.4.4good/pppd/plugins/rp-pppoe
ppp-2.4.4good/pppd/plugins/radius
ppp-2.4.4good/pppd/plugins/pppoatm
ppp-2.4.4good/pppd
ppp-2.4.4good/pppstats
ppp-2.4.4good/pppdump
修改的方法非常简单,就是在每个makefile里面加入以下语句
C_FLAGS +=-mbig-endian -Wall -Wstrict-prototypes-O -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32-D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps
CC=/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc
CC+=$(C_FLAGS)
需要注意的是,一般情况下将这段语句复制到makefile最前面,但是如果在makefile里面发现C_FLAGS=或者CC的定义,那么必须将这段话复制到这些定义的后面。因为这些定义会把新加入的语句覆盖掉。
4. 编译
执行下面两个命令
#cd /home/linuxuser/pppoe/ppp-2.4.4good
#make
编译完之后会在ppp-2.4.4good/chat/下生成chat,在ppp-2.4.4good/pppd/下面得到pppd。
1. 解压rp-pppoe-3.10.tar.gz到/home/linuxuser/pppoe/rp-pppoe-3.10good
2. 进入/home/linuxuser/pppoe/rp-pppoe-3.10good/src目录,执行
./configure --host=arm-linux--build=i686-pc-linux-gnu --target=arm-linux
3. 修改makefile:
一共有两个makefile需要修改,分别在
/rp-pppoe-3.10good/src/libevent
/rp-pppoe-3.10good/src
在/rp-pppoe-3.10good/src/makefile会发现下面的指令
pppoe: pppoe.o if.o debug.o common.o ppp.odiscovery.o
gcc-o pppoe pppoe.o if.o debug.o common.o ppp.o discovery.o
将两个makefile里所有的类似的语句里的gcc全部替换成$(CC)。
然后加入下面的语句:
C_FLAGS +=-mbig-endian -Wall -Wstrict-prototypes-O -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32-D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps
CC=/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc
CC+=$(C_FLAGS)
注意的事项和pppd的一样,一般情况下将这段语句复制到makefile最前面,但是如果在makefile里面发现C_FLAGS=或者CC的定义,那么必须将这段话复制到这些定义的后面。因为这些定义会把新加入的语句覆盖掉。
编译完之后在/rp-pppoe-3.10good/src会得到chat文件。
配置文件包括chap-secrets, options,pap-secrets, resolv.conf。在此假设拨号的用户名和密码都是ucppp
1. 在/home/linuxuser/pppoe/ppp-2.4.4good/etc.ppp会发现chap-secrets, options,pap-secrets三个文件。打开chap-secrets和pap-secrets,在两个文件的最后面加上"ucppp" *"ucppp"。
两个文件的内容应该如下
chap-secrets:
/********************************************/
# Secrets forauthentication using CHAP
# client server secret IP addresses
"ucppp"* "ucppp"
/********************************************/
pap-secrets
/********************************************/
# Secrets forauthentication using PAP
# client server secret IP addresses
"ucppp"* "ucppp"
/********************************************/
2. 新建resolv.conf,内容如下
/********************************************/
#MADE-BY-RP-PPPOE
nameserver202.106.46.151
/********************************************/
202.106.46.151是DNS的地址,要根据实际的情况修改。
经过上面的步骤,得到了三个可执行文件pppd, chat, pppoe。需要对这些文件进行strip以节省空间。还有一些配置文件,也需要放到ramdisk里。
1.执行以下命令:
#cd /home/linuxuser/pppoe/ppp-2.4.4good/
#mkdir prepare_ramdisk
#mkdir 244bin
#cp /home/linuxuser/pppoe/rp-pppoe-3.10good/src/pppoe/home/linuxuser/pppoe/ppp-2.4.4good/244bin/pppoe
2. 将resolv.conf复制到/home/linuxuser/pppoe/ppp-2.4.4good/prepare_ramdisk。
3. 在/home/linuxuser/pppoe/ppp-2.4.4good/prepare_ramdisk新建rc文件,内容如下:
/********************************************/
hostname IXDP425
mount -t procproc /proc
mount -oremount,rw /dev/root /
ifconfig lo127.0.0.1
insmod/lib/modules/2.6.19-uc1/kernel/ixp425/ixp400-2.4/ixp400.ko
cat/etc/IxNpeMicrocode.dat > /dev/ixNpe
insmod/lib/modules/2.6.19-uc1/kernel/ixp425/net-2.4/ixp400_eth.ko
ifconfig ixp0 up
#ifconfig eth0192.168.1.220 broadcast 192.168.1.255 netmask 255.255.255.0
#ifconfig ixp0192.168.1.220 broadcast 192.168.1.255 netmask 255.255.255.0
route add -net127.0.0.0 netmask 255.255.255.0 lo
#dhcpcd &
cat /etc/motd
/********************************************/
4. 复制/home/linuxuser/pppoe/ppp-2.4.4good/etc.ppp文件夹到/home/linuxuser/pppoe/ppp-2.4.4good/prepare_ramdisk
经过以上的步骤,ramdisk和zImage都已经在/tftpboot里了。
在/home/linuxuser/pppoe/ppp-2.4.4good/新建pppramdisk文件,内容如下:
/********************************************/
umount tmp
rm -rframdisk.gz
rm -rf ramdisk
make clean
make
rm -rf tmp
mkdir tmp
cp -f/tftpboot/ramdisk.gz ramdisk.gz
gunzip ramdisk
mount -o loopramdisk tmp
rm -rf./prepare_ramdisk/stripped
mkdir./prepare_ramdisk/stripped
cp -rf./chat/chat ./prepare_ramdisk/stripped/chat
cp -rf./pppd/pppd ./prepare_ramdisk/stripped/pppd
cp -rf./244bin/pppoe ./prepare_ramdisk/stripped/pppoe
/home/linuxuser/usr/local/arm-linux/bin/strip./prepare_ramdisk/stripped/*
/home/linuxuser/usr/local/arm-linux/bin/strip-R .comment -R .note ./prepare_ramdisk/stripped/*
cp -rf./prepare_ramdisk/stripped/* ./tmp/bin/
cp -rf./prepare_ramdisk/ppp ./tmp/etc/
cp -rf./prepare_ramdisk/rc ./tmp/etc/rc
cp -rf./prepare_ramdisk/resolv.conf ./tmp/etc/resolv.conf
chmod +x./tmp/etc/rc
umount tmp
gzip ramdisk
cp -rframdisk.gz /tftpboot/ramdisktest.gz
rm -rf tmp
/********************************************/
执行pppramdisk之后,新的ramdisk就是/tftpboot/ramdisktest.gz。将ramdisktest.gz和zImage用一下命令下载到板子上。
load -r -v -b0x00800000 ramdisktest.gz
load -r -v -b0x01600000 zImage
exec
将IXDP425的以太网口接上ADSLmodem,设置modem为bridge模式, 启动IXDP425后在IXDP425上执行如下命令。
#/bin/pppdpty '/bin/pppoe -I ixp0' user ucpppdebug defaultroute&
这里ucppp是用户名,一定要用运营商提供的正确的用户名替代,否则认证会出问题。chap-secrets和pap-secrets的相应配置也一定要正确。
正确启动之后,会出现ppp0的设备。使用ifconfig命令,结果应该如下:
ixp0 Link encap:Ethernet HWaddr 00:02:B3:01:01:01
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1983 errors:0 dropped:0overruns:0 frame:0
TX packets:1569 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:256
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0overruns:0 frame:0
TX packets:0 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:0
ppp0 Link encap:Point-to-Point Protocol
inet addr:x.x.x.x P-t-P: x.x.x.x Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARPMULTICAST MTU:1492 Metric:1
RX packets:1952 errors:0 dropped:0 overruns:0frame:0
TX packets:1528 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:3
inet addr:x.x.x.x就是运营商给盒子分配的IP地址,P-t-P: x.x.x.x是对端的IP地址这个会根据实际的情况有所不同。这个时候应该已经可以上网了。
用windowXP建立一个PPPOE服务器,然后使用直连线目标板和XP服务器连接起来,在目标板上对XP进行拨号测试。拨号成功后,我们再使用modern拨ISP。当然拨XP服务器和拨ISP的方法基本上是一样的。
1 下载RASPPPOE_098B组件
2 右击网上邻居,选属性,点安装,选择协议,添加,从磁盘安装,然后选择RASPPPOE_098B的目录
安装好组件后,你便可以在本地连接中看到ppp oever ethernet prototal
3, 建立一个基于ppp的传入连接(我们的目标板拨号连接XP的pppoe服务器,靠的就是这个连接)
1)新建网络连接->选择设置高级连接->接受传入的连接->选择REALTEK ....(这是windows网卡,各台机器不同)->允许虚拟连接
2)在这里你可以选择或新建一个用户用来被客户端拨号使用
3)一路next。
Windows里指定IP分配。
右键点击incomingconnections->properties.
注意,建立pppoeserver的机器最好只有一张网卡启用,否则可能会造成错误。
因为uclinux自带pppoe所以选中了pppd,ra-pppoe,chat。然后选上了Kernel Settings-->Device Drivers ---> Network device support --->PPP (point-to-point protocol) support --->PPP (point-to-point protocol) support的一些选项。
准备了chap-secrets, pap-secrets, options集成在ramdisk根目录下。这个是当时受了说明的误导,后面再解释。chap-secrets和pap-secrets中的用户名和密码都是ucppp。
编译完下载到板子上运行。出错Couldn't set tty to PPP discipline: Invalid argument。
这是在内核里需要有一个pppoe的tty选项选上。选上之后编译,执行/bin/pppd出现乱码,说明成功移植了。
执行/bin/pppd pty '/bin/pppoe' user ucppp.
系统中有syslogd运行,可以通过cat /var/log/message来查看出错信息。
错误如下:
pppoe usesobsolete (PF_INET,SOCK_PACKET)
5>Jan 1 00:01:12 pppd[21]: pppd 2.3.8started by (unknown), uid 0
<6>Jan 1 00:01:12 pppd[21]: Using interface ppp0
<5>Jan 1 00:01:12 pppd[21]: pppd create pidfile/var/run/ppp0.pid
<5>Jan 1 00:01:12 pppd[21]: Connect: ppp0 <-->/dev/ttyp0
<6>Jan 1 00:01:12 kernel: pppoe uses obsolete(PF_INET,SOCK_PACKET)
<3>Jan 1 00:01:12 pppoe[22]: ioctl(SIOCGIFHWADDR):No such device
<4>Jan 1 00:01:12 pppd[21]: Will not do PAP for userucppp
<4>Jan 1 00:01:12 pppd[21]: Will not do CHAP foruser ucppp
<5>Jan 1 00:01:12 pppd[21]: Modem hangup
<5>Jan 1 00:01:12 pppd[21]: Connection terminated.
<6>Jan 1 00:01:12 pppd[21]: Exit.
网卡找不到,先打开IXP网卡,还是出错。.
<5>Jan 1 00:01:40 pppd[37]: pppd 2.3.8started by (unknown), uid 0
<3>Jan 1 00:01:40 pppoe[38]: ioctl(SIOCGIFHWADDR):No such device
<3>Jan 1 00:01:40 pppd[37]: Couldn't get channelnumber: Input/output error
<3>Jan 1 00:01:40 pppd[37]: ioctl(PPPIOCGFLAGS): Badfile descriptor
<6>Jan 1 00:01:40 pppd[37]: Exit.
想起来pppoe可以指定用于拨号的网卡,可能默认的是eth0而不是ixp0。执行命令:
/bin/pppdpty '/bin/pppoe -I ixp0' user ucppp&
出现如下信息:
<5>Jan 1 00:06:39 pppd[52]: pppd 2.3.8started by (unknown), uid 0
<6>Jan 1 00:06:39 pppd[52]: Using interface ppp0
<5>Jan 1 00:06:39 pppd[52]: pppd create pidfile/var/run/ppp0.pid
<5>Jan 1 00:06:39 pppd[52]: Connect: ppp0 <-->/dev/ttyp0
<7>Jan 1 00:06:39 pppoe[53]: PADS: Service-Name: ''
<7>Jan 1 00:06:39 pppoe[53]: PPP session is 15
<4>Jan 1 00:06:40 pppd[52]: Will not do PAP for userucppp
<4>Jan 1 00:06:40 pppd[52]: Will not do CHAP foruser ucppp
<6>Jan 1 00:06:40 pppoe[53]: Session terminated --received PADT from peer
<5>Jan 1 00:06:40 pppd[52]: Modem hangup
<5>Jan 1 00:06:40 pppd[52]: Connection terminated.
<6>Jan 1 00:06:40 pppd[52]: Exit.
没有什么头绪,发现pppoe有debug选项,打开再看看。输入
/bin/pppdpty '/bin/pppoe -I ixp0' user ucpppdebug&
错误信息如下:
<7>Jan 1 02:33:40 pppd[46]: sent [LCP ConfReq id=0x1<mru 1492> <asyncmap 0x0> <magic 0x37689ca6> <pcomp><accomp>]
<7>Jan 1 02:33:40 pppd[46]: rcvd [LCP ConfReq id=0x0<mru 1492> <auth chap 81> <magic 0x76bd6a17> < 0d 03 06> < 11 04 06 4e><
<7>Jan 1 02:33:40 pppd[46]: lcp_reqci: rcvd unknownoption 13
<7>Jan 1 02:33:40 pppd[46]: lcp_reqci: rcvd unknownoption 17
<7>Jan 1 02:33:40 pppd[46]: lcp_reqci: rcvd unknownoption 19
<7>Jan 1 02:33:40 pppd[46]: lcp_reqci: rcvd unknownoption 23
<7>Jan 1 02:33:40 pppd[46]: lcp_reqci: returningCONFREJ.
<7>Jan 1 02:33:40 pppd[46]: sent [LCP ConfRej id=0x0<auth chap 81> < 0d 03 06> < 11 04 06 4e> < 13 17 01 02 93fe c4 24 eb 4a
<7>Jan 1 02:33:40 pppd[46]: rcvd [LCP ConfRej id=0x1<pcomp> <accomp>]
<7>Jan 1 02:33:40 pppd[46]: sent [LCP ConfReq id=0x2<mru 1492> <asyncmap 0x0> <magic 0x37689ca6>]
<7>Jan 1 02:33:40 pppd[46]: rcvd [LCP TermReq id=0x1"v\275j\027\000<\315t\000\000\003\227"]
<7>Jan 1 02:33:40 pppd[46]: sent [LCP TermAckid=0x1]
<6>Jan 1 02:33:40 pppoe[47]: Session terminated --received PADT from peer
<5>Jan 1 02:33:40 pppd[46]: Modem hangup
<5>Jan 1 02:33:40 pppd[46]: Connection terminated.
<6>Jan 1 02:33:40 pppd[46]: Exit
发现是有几个field程序无法识别,估计是版本太低或者编译的时候出的问题。
通过wireshark抓包看到这几个选项的含义。
option 13:callback
option 17:stac electronics LZS
option 19:multilink endpoint discriminator
option 23:link discriminator for BACP
查看snapgear里的pppd源码,lcp.h里面有定义,只支持以下的选项:
#define CI_MRU 1 /*Maximum Receive Unit */
#defineCI_ASYNCMAP 2 /* Async Control Character Map */
#defineCI_AUTHTYPE 3 /* Authentication Type */
#defineCI_QUALITY 4 /* Quality Protocol */
#defineCI_MAGICNUMBER 5 /* Magic Number */
#defineCI_PCOMPRESSION 7 /* Protocol Field Compression */
#defineCI_ACCOMPRESSION 8 /* Address/ControlField Compression */
#defineCI_CALLBACK 13 /* callback */
所以根本不可能握手,支持的协议有差别,options13, 17, 19, 23根本不支持,而且也不是配置的问题了。
检查最新的uclinux,发现有最新版的pppd2.4。也许这个能支持新的option. 先检查源码。另外rp-pppoe也有版本的问题.
而在uclinux2007里面,发现了lcp.h的定义
#defineCI_VENDOR 0 /* Vendor Specific */
#define CI_MRU 1 /*Maximum Receive Unit */
#define CI_ASYNCMAP 2 /*Async Control Character Map */
#defineCI_AUTHTYPE 3 /* Authentication Type */
#defineCI_QUALITY 4 /* Quality Protocol */
#defineCI_MAGICNUMBER 5 /* Magic Number */
#defineCI_PCOMPRESSION 7 /* Protocol Field Compression */
#define CI_ACCOMPRESSION8 /* Address/Control Field Compression */
#defineCI_FCSALTERN 9 /* FCS-Alternatives */
#define CI_SDP 10 /*Self-Describing-Pad */
#defineCI_NUMBERED 11 /* Numbered-Mode */
#defineCI_CALLBACK 13 /* callback */
#define CI_MRRU 17 /*max reconstructed receive unit; multilink */
#define CI_SSNHF 18 /*short sequence numbers for multilink */
#defineCI_EPDISC 19 /* endpoint discriminator */
#defineCI_MPPLUS 22 /* Multi-Link-Plus-Procedure */
#define CI_LDISC 23 /*Link-Discriminator */
#define CI_LCPAUTH 24 /* LCPAuthentication */
#define CI_COBS 25 /*Consistent Overhead Byte Stuffing */
#defineCI_PREFELIS 26 /* Prefix Elision */
#defineCI_MPHDRFMT 27 /* MP Header Format */
#define CI_I18N 28 /*Internationalization */
#define CI_SDL 29 /*Simple Data Link */
所以这个版本应该是支持的。尝试直接编译这个新版的pppd。
投机取巧的方法,在uclinx-dist-20080808下,打了uclinx-dist-20080808-20090302.patch补丁的情况下编译了全部的代码。从ramdisk里面提取了pppd, pppoe, chat可执行文件。尝试一下. 程序崩溃,应该是uclibc不一致的原因。看来必须独立编译了.
将uclinx-dist-20080808的pppd复制出来编译。修改makefile
CFLAG = -mbig-endian-I/home/linuxuser/snapgear/linux-2.6.x/include -Wall -Wstrict-prototypes -O -fno-strict-aliasing -fno-common -Uarm-fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale-malignment-traps
执行
make CC=/home/linuxuser/snapgear/tools/ucfront-gcc\\arm-linux-gcc
因为使用uclibc库的原因,ucfront-gcc和arm-linux-gcc有空格,必须用\ \才行。
make[1]:Entering directory `/home/linuxuser/pppoe/ppp2311/pppd/build/pppd'
/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc -mbig-endian -I/home/linuxuser/snapgear/linux-2.6.x/include -Wall -Wstrict-prototypes -O-fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32-D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP-I../include '-DDESTDIR="/usr/local"' -DCHAPMS=1 -DHAVE_CRYPT_H=1-DUSE_CRYPT=1 -DHAVE_MULTILINK -DUSE_TDB=1 -DPLUGIN -DMAXOCTETS -DUSE_LASTLOG-mbig-endian -I/home/linuxuser/snapgear/linux-2.6.x/include -Wall -Wstrict-prototypes -O-fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32-D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP-I../include '-DDESTDIR="/usr/local"' -DCHAPMS=1 -DHAVE_CRYPT_H=1-DUSE_CRYPT=1 -DHAVE_MULTILINK -DUSE_TDB=1 -DPLUGIN -DMAXOCTETS-DUSE_LASTLOG -c -o sys-linux.osys-linux.c
In file includedfrom /home/linuxuser/snapgear/include/include-linux/linux/netdevice.h:28,
from/home/linuxuser/snapgear/linux-2.6.x/include/net/dst.h:11,
from/home/linuxuser/snapgear/linux-2.6.x/include/net/route.h:27,
from sys-linux.c:109:
/home/linuxuser/snapgear/include/include-linux/linux/if.h:26:1:warning: "IFNAMSIZ" redefined
In file includedfrom sys-linux.c:107:
/home/linuxuser/snapgear/uClibc/include/net/if.h:130:1:warning: this is the location of the previous definition
In file includedfrom /home/linuxuser/snapgear/include/include-linux/linux/netd
原因在于,应用程序根本不应该include kernel的文件。实际上sys-linux.c想-I../include而已,刚好有个文件和kernel的一个include文件相同。因为CFLAGS也是复制过来,没有仔细检查。make的时候会建立build文件夹。因为担心uclinx-dist-20080808对pppd做了修改以编译集成编译,而且pppd的readme也讲到独立源码包的编译方法,所以从pppoe的官方网站上下了了最新的稳定版本ppp-2.4.4.tar.gz。http://ppp.samba.org/ppp/download.html。
结果对比发现,源码和uclinx-dist-20080808打了补丁后的一样。但是uclinx-dist-20080808修改了配置,编译器起来很不方便,决定采用ppp-2.4.4.tar.gz。
uclinx-dist-20080808里包含的pppd编译的时候会先生成build文件夹,实际的编译在这里面完成。而下载的源码包不会这样。顶层的makefile文件里${Mflag}也没有任何内容,不能向各个makefile传递编译参数,所以直接修改了各个层次的makefile。
pppd下自带了rp-pppoe。问题在于rp-pppoe的编译,按照正常编译完只能生成pppoe-discovery,并不能生成pppoe文件。怀疑是uclinux编译的时候仅仅改了名字而已,但是对比ramdisk里的和rp-pppoe下面的这个两个文件,发现大小不一样,不能确认。也许是strip的原因。
strip经常用来去除目标文件中的一些符号表、调试符号表信息,以减小程序的大小,在rpmbuild包的最后就用到。无论是静态库(libcmp.a)还是动态库(libcmp.so)还是可执行文件(test),去掉一些符号信息后都减小了很多,但如果这时再链接 这两个库的话是编不过的,因此,如果不是指定特殊的strip选项的话,还是尽量不要对库文件strip,只对链接后的可执行文件strip就可以了(如果也不调试)。
使用file命令将ramdisk下编译的文件和/home/linuxuser/snapgear/user进行对比,发现如下差别:
#from ramdisk
./new/chat: ELF 32-bit MSB executable, ARM, version 1(ARM), dynamically linked (uses shared libs), stripped
./new/pppd: ELF 32-bit MSB executable, ARM, version 1(ARM), dynamically linked (uses shared libs), stripped
./new/pppoe: ELF32-bit MSB executable, ARM, version 1 (ARM), dynamically linked (uses sharedlibs), stripped
#from build folder
/home/linuxuser/pppoe/uc07ppd/buildbin/chat: ELF 32-bit MSB executable, ARM,version 1 (ARM), dynamically linked (uses shared libs), not stripped
/home/linuxuser/pppoe/uc07ppd/buildbin/pppd: ELF 32-bit MSB executable, ARM,version 1 (ARM), dynamically linked (uses shared libs), not stripped
/home/linuxuser/pppoe/uc07ppd/buildbin/pppoe-discovery:ELF 32-bit MSB executable, ARM, version 1 (ARM), dynamically linked (usesshared libs), not stripped
交叉编译中注意的是,交叉编译器有sttrip,host系统也有,所以注意使用arm-linux-strip或者使用/home/linuxuser/usr/local/arm-linux/bin/strip来指定。
在编译uclinux的时候发现打印信息:
make[2]:Entering directory `/home/linuxuser/skyeye/uClinux-dist/user/rp-pppoe'
romfs-inst.sh /bin/pppoe
原来系统使用的pppoe并不是从/home/linuxuser/skyeye/uClinux-dist/user/rp-pppoe里面拿到的,而是单独的有rp-pppoe目录。找到/rp-pppoe/changes和rp-pppoe.spec文件检查版本显示为2.3.。官方网站的链接也有。在其他一些网站上找到的有3.5,3.7和3.8版本。到sourceforge上去找最新的rp-pppoe.。最新的版本为3.1,并且有官方网站的链接证明。决定先使用3.1版本的试试。
执行:
./configure--host=arm-linux --build=i686-pc-linux-gnu --target=arm-linux
修改rp-pppoe-3.10good/src下的makefile。gcc全部替换成$(CC)。然后加入下面的语句:
C_FLAGS +=-mbig-endian -Wall -Wstrict-prototypes-O -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32-D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps
CC=/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc
CC+=$(C_FLAGS)
之后编译发现如下错误:
make[1]:Entering directory `/home/linuxuser/pppoe/rp-pppoe-3.10/src/libevent'
gcc -g -O2 -Wall-Wstrict-prototypes -I.. -c -o event.oevent.c
gcc -g -O2 -Wall-Wstrict-prototypes -I.. -c -oevent_tcp.o event_tcp.c
gcc -g -O2 -Wall-Wstrict-prototypes -I.. -c -o hash.ohash.c
gcc -g -O2 -Wall-Wstrict-prototypes -I.. -c -oevent_sig.o event_sig.c
rm -f libevent.a
ar -cqlibevent.a event.o event_tcp.o hash.o event_sig.o
ranlib libevent.a
make[1]: Leavingdirectory `/home/linuxuser/pppoe/rp-pppoe-3.10/src/libevent'
/home/linuxuser/snapgear/tools/ucfront-gccarm-linux-gcc -mbig-endian -Wall-Wstrict-prototypes -O -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe-mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps-o pppoe-server pppoe-server.o if.odebug.o common.o md5.o -Llibevent-levent
/home/linuxuser/skyeye/usr/local/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:skipping incompatible libevent/libevent.a when searching for -levent
/home/linuxuser/skyeye/usr/local/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:cannot find -levent
collect2: ldreturned 1 exit status
make: ***[pppoe-server] Error 1
makefile has notbeen changed.
原来在src下还有一个子目录libevent,那里面也有一个makefile,一起修改完之后就编译通过。
运行是发生如下错误。
<5>Jan 100:02:43 pppd[38]: pppd 2.4.4 started by root, uid 0
<7>Jan 100:02:43 pppd[38]: using channel 1
<6>Jan 100:02:43 pppd[38]: Using interface ppp0
<5>Jan 100:02:43 pppd[38]: Connect: ppp0 <--> /dev/ttyp0
<7>Jan 100:02:43 pppoe[39]: PADS: Service-Name: ''
<6>Jan 100:02:43 pppoe[39]: PPP session is 13 (0xd)
<7>Jan 100:02:44 pppd[38]: sent [LCP ConfReq id=0x1 <mru 1492> <asyncmap0x0> <magic 0xbfd31e15> <pcomp> <accomp>]
<7>Jan 100:02:44 pppd[38]: rcvd [LCP ConfReq id=0x0 <mru 1492> <auth chapMS-v2> <magic 0x1ece5b17> <callback CBCP> <mrru 1614><endpoint [local:21.ea.01.40.37.ca.42.35.99.a2.a4.ef.b8.80.b9.f9.00.00.00.00]>< 17 04 00 05>]
<7>Jan 100:02:44 pppd[38]: No auth is possible
<7>Jan 100:02:44 pppd[38]: sent [LCP ConfRej id=0x0 <auth chap MS-v2><callback CBCP> <mrru 1614> < 17 04 00 05>]
<7>Jan 100:02:44 pppd[38]: rcvd [LCP ConfRej id=0x1 <pcomp> <accomp>]
<7>Jan 100:02:44 pppd[38]: sent [LCP ConfReq id=0x2 <mru 1492> <asyncmap0x0> <magic 0xbfd31e15>]
<7>Jan 100:02:44 pppd[38]: rcvd [LCP TermReq id=0x1 1e ce 5b 17 00 3c cd 74 00 00 0397]
<7>Jan 100:02:44 pppd[38]: sent [LCP TermAck id=0x1]
<6>Jan 100:02:44 pppoe[39]: Session 13 terminated -- received PADT from peer
<6>Jan 100:02:44 pppoe[39]: Sent PADT
<5>Jan 100:02:44 pppd[38]: Modem hangup
<5>Jan 100:02:44 pppd[38]: Connection terminated.
<7>Jan 100:02:44 pppd[38]: Script /bin/pppoe finished (pid 39), status = 0x0
<6>Jan 100:02:44 pppd[38]: Exit.
对比发现,有一个理解错误。
mrru 1614.而在协议上显示,而在omnipeek上看到的是stac electronics LZS
auth chap MS-v2, 这个可能是reject的关键原因。
No auth is possible.
那么开启auth。还有[LCPConfRej id=0x1 <pcomp> <accomp>],使用nopcomp noaccomp。重新执行:
/bin/pppdpty '/bin/pppoe' user ucppp mtu 1492 mru1492 debug nopcomp noaccomp&
果然,rcvd [LCPConfAck id=0x1 <mru 1492> <asyncmap 0x0> <magic 0x909e2063>]。
说明板子送给服务器的request已经被ack。唯一的问题就在于auth.
加入receive-all, 还是同样的错误。
看到源码里面
ao->neg_chap = 1;
ao->chap_mdtype = chap_mdtype_all;
ao->neg_upap = 1;
ao->neg_eap = 1;
还有一处:
case CI_AUTHTYPE:
if(cilen < CILEN_SHORT ||
!(ao->neg_upap || ao->neg_chap ||ao->neg_eap)) {
/*
*Reject the option if we're not willing to authenticate.
*/
dbglog("No auth is possible");
orc = CONFREJ;
break;
}
另外一处发现
//Length of eachtype of configuration option (in octets)
#defineCILEN_SHORT 4 /* CILEN_VOID + 2 */.
所以可能的原因有两个,ao->neg_upap,ao->neg_chap,ao->neg_eap在初始化的时候已经赋值为1,那么cilen的问题了。
在源码里面加入打印语句。使用__FUNCTION__,__FILE__,__LINE__来帮助显示。__FUNCTION__,__FILE__,__LINE__在LINUX下的C/C++编程中,这3个变量分别为当前函数名(char *),当前文件(char *),当前行号(int)。
打印显示结果:
<7>Jan 1 00:02:22 pppd[36]: No auth is possible
<7>Jan 1 00:02:22 pppd[36]: ln 1597 cilen:5, neg_upap= 0, neg_chap = 0, neg_eap = 0。
说明不是cilen的问题,不知道为什么auth的赋值都没有打开。
可以使用cat null>/var/log/messages清空syslogd,让后面的信息更加明显。
最后只能猜测,也许是配置文件放的位置不对,因为这个是最后一个和auth相关的。查阅man手册,看到如下语句:
Pppd storessecrets for use in authentication in secrets files (/etc/ppp/pap-secrets forPAP, /etc/ppp/chap-secrets for CHAP, MS-CHAP, MS-CHAPv2, and EAP MD5-Challenge,and /etc/ppp/srp-secrets for EAP SRP-SHA1).
将ppp文件夹从ramdisk根目录移动到/etc/ppp,全部运行正常。
/bin/pppd pty '/bin/pppoe -I ixp0' user xxx mtu 1492 mru 1492debug&
xxx这里是实际的ADSL用户名。
# cat/var/log/messages
<7>Jan 1 00:11:22 pppd[59]: rcvd [LCP EchoReq id=0x3magic=0x2005401]
<7>Jan 1 00:11:22 pppd[59]: sent [LCP EchoRep id=0x3magic=0xc9901b9d]
<7>Jan 1 00:11:32 pppd[59]: rcvd [LCP EchoReq id=0x4magic=0x2005401]
<7>Jan 1 00:11:32 pppd[59]: sent [LCP EchoRep id=0x4magic=0xc9901b9d]
<7>Jan 1 00:11:42 pppd[59]: rcvd [LCP EchoReq id=0x5magic=0x2005401]
<7>Jan 1 00:11:42 pppd[59]: sent [LCP EchoRep id=0x5magic=0xc9901b9d]
<7>Jan 1 00:11:52 pppd[59]: rcvd [LCP EchoReq id=0x6magic=0x2005401]
<7>Jan 1 00:11:52 pppd[59]: sent [LCP EchoRep id=0x6magic=0xc9901b9d]
<5>Jan 1 00:11:57 pppd[68]: pppd 2.4.4 started byroot, uid 0
<7>Jan 1 00:11:58 pppd[68]: using channel 3
<6>Jan 1 00:11:58 pppd[68]: Using interface ppp1
<5>Jan 1 00:11:58 pppd[68]: Connect: ppp1 <-->/dev/ttyp1
<7>Jan 1 00:11:58 pppoe[69]: PADS: Service-Name: ''
<6>Jan 1 00:11:58 pppoe[69]: PPP session is 8526(0x214e)
<7>Jan 1 00:11:58 pppd[59]: rcvd [LCP ConfReq id=0x0<mru 1492> <auth pap> <magic 0x2004922>]
<4>Jan 1 00:11:58 pppd[59]: Warning - secret file/etc/ppp/pap-secrets has world and/or group access
<7>Jan 1 00:11:58 pppd[59]: sent [LCP ConfReq id=0x3<mru 1492> <asyncmap 0x0> <magic 0x2ddcec01> <pcomp><accomp>]
<7>Jan 1 00:11:58 pppd[59]: lcp_reqci, ln10:f->unit = 0
<7>Jan 1 00:11:58 pppd[59]: ln 1544 cilen:4
<7>Jan 1 00:11:58 pppd[59]: sent [LCP ConfNak id=0x0<auth eap>]
<7>Jan 1 00:11:58 pppd[68]: rcvd [LCP ConfReq id=0x0<mru 1492> <auth pap> <magic 0x2004922>]
<4>Jan 1 00:11:58 pppd[68]: Warning - secret file/etc/ppp/pap-secrets has world and/or group access
<7>Jan 1 00:11:58 pppd[68]: sent [LCP ConfReq id=0x1<mru 1492> <asyncmap 0x0> <magic 0x2851e7e> <pcomp> <accomp>]
<7>Jan 1 00:11:58 pppd[68]: lcp_reqci, ln10:f->unit = 0
<7>Jan 1 00:11:58 pppd[68]: ln 1544 cilen:4
<7>Jan 1 00:11:58 pppd[68]: sent [LCP ConfNak id=0x0<auth eap>]
<7>Jan 1 00:11:58 pppd[59]: rcvd [LCP ConfRej id=0x3<asyncmap 0x0> <pcomp> <accomp>]
<7>Jan 1 00:11:58 pppd[59]: sent [LCP ConfReq id=0x4<mru 1492> <magic 0x2ddcec01>]
<7>Jan 1 00:11:58 pppd[68]: rcvd [LCP ConfRej id=0x3<asyncmap 0x0> <pcomp> <accomp>]
<7>Jan 1 00:11:58 pppd[59]: rcvd [LCP ConfReq id=0x1<mru 1492> <magic 0x2004922>]
<7>Jan 1 00:11:58 pppd[59]: lcp_reqci, ln10:f->unit = 0
<7>Jan 1 00:11:58 pppd[59]: ln 1544 cilen:4
<7>Jan 1 00:11:58 pppd[59]: sent [LCP ConfAck id=0x1<mru 1492> <magic 0x2004922>]
<7>Jan 1 00:11:58 pppd[68]: rcvd [LCP ConfReq id=0x1<mru 1492> <magic 0x2004922>]
<7>Jan 1 00:11:58 pppd[68]: lcp_reqci, ln10:f->unit = 0
<7>Jan 1 00:11:58 pppd[68]: ln 1544 cilen:4
<7>Jan 1 00:11:58 pppd[68]: sent [LCP ConfAck id=0x1<mru 1492> <magic 0x2004922>]
<7>Jan 1 00:11:58 pppd[59]: rcvd [LCP ConfRej id=0x1<asyncmap 0x0> <pcomp> <accomp>]
<7>Jan 1 00:11:58 pppd[59]: rcvd [LCP ConfAck id=0x4<mru 1492> <magic 0x2ddcec01>]
<7>Jan 1 00:11:58 pppd[59]: sent [CCP ConfReq id=0x2<deflate 15> <deflate(old#) 15> <bsd v1 15>]
<7>Jan 1 00:11:58 pppd[59]: sent [IPCP ConfReqid=0x2 <compress VJ 0f 01> <addr 0.0.0.0>]
<7>Jan 1 00:11:58 pppd[68]: rcvd [LCP ConfRej id=0x1<asyncmap 0x0> <pcomp> <accomp>]
<7>Jan 1 00:11:58 pppd[68]: sent [LCP ConfReq id=0x2<mru 1492> <magic 0x2851e7e>]
<7>Jan 1 00:11:58 pppd[68]: rcvd [LCP ConfAck id=0x4<mru 1492> <magic 0x2ddcec01>]
<7>Jan 1 00:11:58 pppd[59]: rcvd [LCP ConfReq id=0x2<mru 1492> <auth pap> <magic 0x2004922>]
<4>Jan 1 00:11:58 pppd[59]: Warning - secret file/etc/ppp/pap-secrets has world and/or group access
<7>Jan 1 00:11:58 pppd[59]: sent [LCP ConfReq id=0x5<mru 1492> <asyncmap 0x0> <magic 0x6965ba9e> <pcomp><accomp>]
<7>Jan 1 00:11:58 pppd[59]: lcp_reqci, ln10:f->unit = 0
<7>Jan 1 00:11:58 pppd[59]: ln 1544 cilen:4
<7>Jan 1 00:11:58 pppd[59]: sent [LCP ConfNak id=0x2<auth eap>]
<7>Jan 1 00:11:58 pppd[68]: rcvd [LCP ConfReq id=0x2<mru 1492> <auth pap> <magic 0x2004922>]
<7>Jan 1 00:11:58 pppd[68]: lcp_reqci, ln10:f->unit = 0
<7>Jan 1 00:11:58 pppd[68]: ln 1544 cilen:4
<7>Jan 1 00:11:58 pppd[68]: sent [LCP ConfNak id=0x2<auth eap>]
<6>Jan 1 00:11:58 pppoe[60]: Session 8526 terminated-- received PADT from peer
<6>Jan 1 00:11:58 pppoe[60]: Sent PADT
<5>Jan 1 00:11:58 pppd[59]: Modem hangup
<5>Jan 1 00:11:58 pppd[59]: Connection terminated.
<6>Jan 1 00:11:58 pppoe[69]: Session 8526 terminated-- received PADT from peer
<6>Jan 1 00:11:58 pppoe[69]: Sent PADT
<5>Jan 1 00:11:58 pppd[68]: Modem hangup
<5>Jan 1 00:11:58 pppd[68]: Connection terminated.
<7>Jan 1 00:11:58 pppd[59]: Script /bin/pppoe -Iixp0 finished (pid 60), status = 0x0
<6>Jan 1 00:11:58 pppd[59]: Exit.
<7>Jan 1 00:11:58 pppd[68]: Script /bin/pppoe -Iixp0 finished (pid 69), status = 0x0
<6>Jan 1 00:11:58 pppd[68]: Exit.
错误点的出现
rcvd [LCP ConfReq id=0x0<mru 1492> <auth pap> <magic 0x2004922>]
对方一直坚持使用PAP,而不是windows实验用的chap,而在pap-secrets里没有写入账户名,所以修改一下.将ADSL密码写入到pap-secrets。重试之后链接成功。
Ifconfig结果
ppp0 Link encap:Point-to-Point Protocol
inet addr:xxxxxxxxxxxx P-t-P:114.240.64.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
但是此时发现不能ping通别的IP,查看route发现没有defaultgateway。也没有DNS。
Ping以下网址不通
64.233.189.104
202.108.33.32.
以下是windows下的拨号信息,作为参考。
PPP adapter cnc:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : WAN(PPP/SLIP) Interface
Physical Address. . . . . . . . . :
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . :xxxxxxxxx
Subnet Mask . . . . . . . . . . . :255.255.255.255
Default Gateway . . . . . . . . . :125.33.19.65
DNS Servers . . . . . . . . . . . :202.106.195.68
202.106.46.151
NetBIOS over Tcpip. . . . . . . . : Disabled
查到要使用defaultroute参数。另外需要在ramdisk里添加/etc/resolve,内容如下
#MADE-BY-RP-PPPOE
nameserver202.106.46.151
在盒子上启动
# /bin/pppd pty '/bin/pppoe -I ixp0' user username debugdefaultroute&
启动之后没有问题。查看route如下
# route
Kernel IProuting table
Destination Gateway Genmask Flags Metric Ref Use Iface
125.33.0.1 * 255.255.255.255 UH 0 0 0 ppp0
127.0.0.0 * 255.255.255.0 U 0 0 0lo
172.17.0.0 * 255.255.0.0 U 0 0 0 ath1
default * 0.0.0.0 U 0 0 0 ppp0
连接外网正常:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。