diff -urNp v6eval-2.2b6/CHANGELOG.v6eval v6eval-2.2b6-linux/CHANGELOG.v6eval --- v6eval-2.2b6/CHANGELOG.v6eval 2003-12-26 22:25:00.000000000 +0900 +++ v6eval-2.2b6-linux/CHANGELOG.v6eval 2004-01-26 14:45:33.000000000 +0900 @@ -3,6 +3,8 @@ $Date: 2004/11/03 17:48:26 $ +2004/01/07 by Kazuo Hiekata + (Experimental) Support RedHat 9 and UnitedLinux 1.0 as TN 2003/12/26 Release 2.2b6 Official beta release diff -urNp v6eval-2.2b6/INSTALL.linux v6eval-2.2b6-linux/INSTALL.linux --- v6eval-2.2b6/INSTALL.linux 1970-01-01 09:00:00.000000000 +0900 +++ v6eval-2.2b6-linux/INSTALL.linux 2004-01-26 14:45:33.000000000 +0900 @@ -0,0 +1,176 @@ +# Copyright (C) IBM Corporation 2004. +# All rights reserved. +# +# Redistribution and use of this software in source and binary forms, with +# or without modification, are permitted provided that the following +# conditions and disclaimer are agreed and accepted by the user: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the names of the copyrighters, the name of the project which +# is related to this software (hereinafter referred to as "project") nor +# the names of the contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# 4. No merchantable use may be permitted without prior written +# notification to the copyrighters. However, using this software for the +# purpose of testing or evaluating any products including merchantable +# products may be permitted without any notification to the copyrighters. +# +# +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTERS, THE PROJECT AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING +# BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHTERS, THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT,STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. +# INTAP(Interoperability Technology Association for Information +# Processing, Japan) , IPA (Information-technology Promotion Agency,Japan) +# All rights reserved. +# +# Redistribution and use of this software in source and binary forms, with +# or without modification, are permitted provided that the following +# conditions and disclaimer are agreed and accepted by the user: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the names of the copyrighters, the name of the project which +# is related to this software (hereinafter referred to as "project") nor +# the names of the contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# 4. No merchantable use may be permitted without prior written +# notification to the copyrighters. However, using this software for the +# purpose of testing or evaluating any products including merchantable +# products may be permitted without any notification to the copyrighters. +# +# +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTERS, THE PROJECT AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING +# BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHTERS, THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT,STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +# THE POSSIBILITY OF SUCH DAMAGE. +# +# Author: Kazuo Hiekata +# + + +Installing the package onto TN (the case of RedHat 9/UnitedLinux 1.0) +================================================================ + +0. Install RedHat 9 or UnitedLinux 1.0 + +1. Extracting the package + + % cd $SOMEWHERE + % tar zxvf v6eval-X.X.tar.gz + +2. Installing perl-related modules + + The package requires the below-listed perl5 modules. + + - Expect v1.15 + - IO-Tty v1.02 + + These packages are available on the web. + http://sourceforge.net/project/showfiles.php?group_id=6894 + + $ tar zxvf IO-Tty-1.02.tar.gz + $ cd IO-Tty-1.02 + $ perl Makefile.PL + $ make + $ make test + # make install + + $ tar zxvf Expect-1.15.tar.gz + $ cd Expect-1.15 + $ perl Makefile.PL + $ make + $ make test + # make install + + +3. Checking the environment + + Make sure that "libpcap" and "tcpdump" are already + installed on your TN. + These packages are available on the Install CD-ROM. + And "pmake" is also needed and is available only on RedHat 9 CD-ROM. + If you're using UnitedLinux 1.0, get RedHat 9 CD-ROM and pick up + pmake package from it. + + To compile TAHI, perl5 and lorder are needed but Linux doesn't + have those. + + i. perl5 + Just create a symbolic link to /usr/bin/perl + + # ln -s /usr/bin/perl /usr/bin/perl5 + ii. lorder + This package contains "lorder" only for TAHI compilation on Linux. + + # cd $SOMEWHERE/v6eval-X.X + # cp lorder /usr/bin/lorder + + +4. Compiling & installing the tool + + Install the Tool in /usr/local/v6eval directory. + + % cd $SOMEWHERE/v6eval-X.X + % pmake + # pmake install + + +4. Configure serial line + + Make sure that "uucp" is installed on your system + And change the permission of the serial line device. + + # chmod 777 /dev/ttyS0 + +5. Interface configuration + + At least, one interface used in testing, must be 'up' status. + + +6. Back to the "Configuration of TN" section in INSTALL.v6eval. + + + * As for ct installation, pmake must be used anywhere instead of make. + Be careful when reading INSTALL.ct. + + % su - + # cd ct-X.X + # pmake install + + * "(iii) Customizing tn.def" in INSTALL.v6eval refer to "filter ipv6", + but Linux TAHI doesn't support this feature. + + + [end of INSTALL.linux] diff -urNp v6eval-2.2b6/INSTALL.v6eval v6eval-2.2b6-linux/INSTALL.v6eval --- v6eval-2.2b6/INSTALL.v6eval 2003-12-22 16:28:36.000000000 +0900 +++ v6eval-2.2b6-linux/INSTALL.v6eval 2004-01-26 14:45:33.000000000 +0900 @@ -34,7 +34,7 @@ Prerequisites Prerequisites for TN: - The package supports FreeBSD 4.6 or higher and FreeBSD 5.1 or lower. - The package can also coexist with FreeBSD 4.X version of KAME. - + - If you use RedHat 9 and UnitedLinux 1.0 as TN, consult INSTALL.linux, too Installing the package onto TN (the case of FreeBSD 4.X-RELEASE) diff -urNp v6eval-2.2b6/bin/Makefile.inc v6eval-2.2b6-linux/bin/Makefile.inc --- v6eval-2.2b6/bin/Makefile.inc 2002-12-02 21:31:27.000000000 +0900 +++ v6eval-2.2b6-linux/bin/Makefile.inc 2004-01-26 14:45:33.000000000 +0900 @@ -1,5 +1,5 @@ BINDIR?= /usr/local/v6eval/bin -MANDIR= /usr/local/v6eval/man/man +MANDIR= /usr/local/v6eval/man l=../../lib Cm=$l/Cm Pz=$l/Pz diff -urNp v6eval-2.2b6/bin/checker/Makefile v6eval-2.2b6-linux/bin/checker/Makefile --- v6eval-2.2b6/bin/checker/Makefile 2003-02-03 23:05:04.000000000 +0900 +++ v6eval-2.2b6-linux/bin/checker/Makefile 2004-01-26 14:45:33.000000000 +0900 @@ -1,3 +1,4 @@ +CC=c++ CXXFLAGS+= -I${Cm} -I${Pz} -I${pkt} -I/usr/local/include LDFLAGS += -L${Cm} -L${Pz} -L${pkt} -L/usr/local/lib LDADD += -lPkt -lPz -lCm -lcrypto diff -urNp v6eval-2.2b6/bin/dhcomp/Makefile v6eval-2.2b6-linux/bin/dhcomp/Makefile --- v6eval-2.2b6/bin/dhcomp/Makefile 2003-12-04 13:59:47.000000000 +0900 +++ v6eval-2.2b6-linux/bin/dhcomp/Makefile 2004-01-26 15:02:26.000000000 +0900 @@ -42,6 +42,7 @@ # ###################################################################### +CC = c++ CXXFLAGS+= -I/usr/local/include LDFLAGS += -L/usr/local/lib LDADD += -lcrypto diff -urNp v6eval-2.2b6/bin/dhgen/Makefile v6eval-2.2b6-linux/bin/dhgen/Makefile --- v6eval-2.2b6/bin/dhgen/Makefile 2003-12-04 13:59:47.000000000 +0900 +++ v6eval-2.2b6-linux/bin/dhgen/Makefile 2004-01-29 16:19:02.000000000 +0900 @@ -42,6 +42,7 @@ # ###################################################################### +CC=c++ CXXFLAGS+= -I/usr/local/include LDFLAGS += -L/usr/local/lib LDADD += -lcrypto diff -urNp v6eval-2.2b6/bin/pktbuf/Makefile v6eval-2.2b6-linux/bin/pktbuf/Makefile --- v6eval-2.2b6/bin/pktbuf/Makefile 2003-02-03 23:05:04.000000000 +0900 +++ v6eval-2.2b6-linux/bin/pktbuf/Makefile 2004-01-26 14:45:33.000000000 +0900 @@ -1,3 +1,4 @@ +CC=c++ CXXFLAGS+= -I${Cm} -I${Pz} -I${pkt} -I/usr/local/include LDFLAGS += -L${Cm} -L${Pz} -L${pkt} -L/usr/local/lib LDADD += -lPkt -lPz -lCm -lcrypto diff -urNp v6eval-2.2b6/bin/pktctl/Makefile v6eval-2.2b6-linux/bin/pktctl/Makefile --- v6eval-2.2b6/bin/pktctl/Makefile 2003-02-03 23:05:04.000000000 +0900 +++ v6eval-2.2b6-linux/bin/pktctl/Makefile 2004-01-26 14:45:33.000000000 +0900 @@ -1,3 +1,4 @@ +CC=c++ CXXFLAGS+= -I${Cm} -I${Pz} -I${pkt} -I/usr/local/include LDFLAGS += -L${Cm} -L${Pz} -L${pkt} -L/usr/local/lib LDADD += -lPkt -lPz -lCm -lcrypto diff -urNp v6eval-2.2b6/bin/pktrecv/Makefile v6eval-2.2b6-linux/bin/pktrecv/Makefile --- v6eval-2.2b6/bin/pktrecv/Makefile 2003-02-03 23:05:04.000000000 +0900 +++ v6eval-2.2b6-linux/bin/pktrecv/Makefile 2004-01-26 14:45:33.000000000 +0900 @@ -1,3 +1,4 @@ +CC=c++ CXXFLAGS+= -I${Cm} -I${Pz} -I${pkt} -I/usr/local/include LDFLAGS += -L${Cm} -L${Pz} -L${pkt} -L/usr/local/lib LDADD += -lPkt -lPz -lCm -lcrypto diff -urNp v6eval-2.2b6/bin/pktsend/Makefile v6eval-2.2b6-linux/bin/pktsend/Makefile --- v6eval-2.2b6/bin/pktsend/Makefile 2003-02-03 23:05:04.000000000 +0900 +++ v6eval-2.2b6-linux/bin/pktsend/Makefile 2004-01-26 14:45:33.000000000 +0900 @@ -1,3 +1,4 @@ +CC=c++ CXXFLAGS+= -I${Cm} -I${Pz} -I${pkt} -I/usr/local/include LDFLAGS += -L${Cm} -L${Pz} -L${pkt} -L/usr/local/lib LDADD += -lPkt -lPz -lCm -lcrypto diff -urNp v6eval-2.2b6/lib/Cm/CmSocket.h v6eval-2.2b6-linux/lib/Cm/CmSocket.h --- v6eval-2.2b6/lib/Cm/CmSocket.h 2003-10-23 13:37:30.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Cm/CmSocket.h 2004-01-26 14:45:33.000000000 +0900 @@ -54,6 +54,7 @@ #include "CmTypes.h" #if !defined(__KAME__) +#if !defined(__linux__) struct in6_addr { union { uint8_t u6_addr8[16]; @@ -68,9 +69,14 @@ struct sockaddr_in6 { uint32_t sin6_scope_id; /* intface scope id */ }; #define s6_addr u6_addr.u6_addr8 +#endif #define getipnodebyname(a,b,c,d)0 #endif +#if defined(__linux__) +#define SO_REUSEPORT 15 +#endif + #ifndef IN6_IS_ADDR_LINKLOCAL #define IN6_IS_ADDR_LINKLOCAL(a)\ (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) diff -urNp v6eval-2.2b6/lib/Cm/CmTypes.h v6eval-2.2b6-linux/lib/Cm/CmTypes.h --- v6eval-2.2b6/lib/Cm/CmTypes.h 2001-10-12 13:56:14.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Cm/CmTypes.h 2004-01-26 14:45:33.000000000 +0900 @@ -48,16 +48,18 @@ #include typedef char *STR; typedef const char *CSTR; -#if defined(__FreeBSD__) || defined(__bsdi__) +#if defined(__FreeBSD__) || defined(__bsdi__) || defined(__linux__) typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; typedef u_int32_t uint32_t; typedef u_int64_t uint64_t; #endif #if (__FreeBSD__ <= 3) || defined(__bsdi__) || defined(__hpux) +#if !defined(__linux__) typedef int socklen_t; #endif -#if defined(__hpux) +#endif +#if defined(__hpux) || defined(__linux__) #define SETPGRP(a,b)setpgrp() #else #define SETPGRP(a,b)setpgrp(a,b) diff -urNp v6eval-2.2b6/lib/Cm/Makefile v6eval-2.2b6-linux/lib/Cm/Makefile --- v6eval-2.2b6/lib/Cm/Makefile 2000-04-19 18:45:20.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Cm/Makefile 2004-01-29 16:29:48.000000000 +0900 @@ -9,4 +9,5 @@ SRCS = \ CXXFLAGS+= -I. +MKLINT=no .include "bsd.lib.mk" diff -urNp v6eval-2.2b6/lib/Pz/Makefile v6eval-2.2b6-linux/lib/Pz/Makefile --- v6eval-2.2b6/lib/Pz/Makefile 2003-12-05 17:51:57.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Pz/Makefile 2004-01-29 16:30:20.000000000 +0900 @@ -57,4 +57,5 @@ CFLAGS+= -I$(Cm) -I. #CXXFLAGS+= -DNOT_USE_IGMPV3_QUERY +MKLINT=no .include "bsd.lib.mk" diff -urNp v6eval-2.2b6/lib/Pz/MfAlgorithm.cc v6eval-2.2b6-linux/lib/Pz/MfAlgorithm.cc --- v6eval-2.2b6/lib/Pz/MfAlgorithm.cc 2003-10-23 13:37:30.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Pz/MfAlgorithm.cc 2004-01-26 14:45:33.000000000 +0900 @@ -205,6 +205,7 @@ void MfBLOWFISH::decrypt(OCTSTR os,OCTST scheduleKeys(key,schd); BF_cbc_encrypt(is,os,l,&schd,iv,DES_DECRYPT);} +#if ! defined(__linux__) #include //---------------------------------------------------------------------- // RC5 CRYPT ALGORITHM @@ -222,6 +223,7 @@ void MfRC5::decrypt(OCTSTR os,OCTSTR is, RC5_32_KEY schd; scheduleKeys(key,schd); RC5_32_cbc_encrypt(is,os,l,&schd,iv,DES_DECRYPT);} +#endif #include //---------------------------------------------------------------------- @@ -431,8 +433,10 @@ MfDESCBC::MfDESCBC(CSTR s,uint8_t k,uint MfDESCBC::~MfDESCBC() {} MfBLOWFISH::MfBLOWFISH(CSTR s,uint8_t k,uint8_t i,uint8_t a):MfCryptKey(s,k,i,a) {} MfBLOWFISH::~MfBLOWFISH() {} +#if ! defined(__linux__) MfRC5::MfRC5(CSTR s,uint8_t k,uint8_t i,uint8_t a):MfCryptKey(s,k,i,a) {} MfRC5::~MfRC5() {} +#endif MfCAST128::MfCAST128(CSTR s,uint8_t k,uint8_t i,uint8_t a):MfCryptKey(s,k,i,a) {} MfCAST128::~MfCAST128() {} MfDES3CBC::MfDES3CBC(CSTR s,uint8_t k,uint8_t i,uint8_t a):MfCryptKey(s,k,i,a) {} diff -urNp v6eval-2.2b6/lib/Pz/MfAlgorithm.h v6eval-2.2b6-linux/lib/Pz/MfAlgorithm.h --- v6eval-2.2b6/lib/Pz/MfAlgorithm.h 2003-04-16 18:40:59.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Pz/MfAlgorithm.h 2004-01-26 14:45:33.000000000 +0900 @@ -47,7 +47,9 @@ #include #include #include +#if ! defined(__linux__) #include +#endif #include class PFunction; @@ -214,6 +216,7 @@ virtual void decrypt(OCTSTR,OCTSTR,uint3 }; //---------------------------------------------------------------------- +#if ! defined(__linux__) class MfRC5:public MfCryptKey { public: MfRC5(CSTR,uint8_t,uint8_t,uint8_t); @@ -222,6 +225,7 @@ virtual ~MfRC5(); virtual void encrypt(OCTSTR,OCTSTR,uint32_t,const PObject*,OCTSTR) const; virtual void decrypt(OCTSTR,OCTSTR,uint32_t,const PObject*,OCTSTR) const; }; +#endif //---------------------------------------------------------------------- class MfCAST128:public MfCryptKey { diff -urNp v6eval-2.2b6/lib/Pz/PvOctets.cc v6eval-2.2b6-linux/lib/Pz/PvOctets.cc --- v6eval-2.2b6/lib/Pz/PvOctets.cc 2003-12-04 13:59:47.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Pz/PvOctets.cc 2004-01-26 14:45:33.000000000 +0900 @@ -66,6 +66,9 @@ int ether_line __P((const char *, struct } */ #endif +#if defined(__linux__) +#include +#endif #include PvOctets::~PvOctets() { @@ -122,7 +125,11 @@ PvObject* PvEther::shallowCopy() const { bool PvEther::pton(CSTR p) { if(p==0) {return false;} struct ether_addr *n=ether_aton((char*)p); +#if defined(__linux__) + if(n!=0) {set(length(),n->ether_addr_octet);} +#else if(n!=0) {set(length(),n->octet);} +#endif return (n!=0);} PvEther::PvEther(const PvV6Addr& v6,OCTSTR o):PvOctets(sizeof(etheraddr),o) { multicast(v6);} diff -urNp v6eval-2.2b6/lib/Pz/crypto/sha2/sha2.c v6eval-2.2b6-linux/lib/Pz/crypto/sha2/sha2.c --- v6eval-2.2b6/lib/Pz/crypto/sha2/sha2.c 2003-04-18 19:46:37.000000000 +0900 +++ v6eval-2.2b6-linux/lib/Pz/crypto/sha2/sha2.c 2004-01-26 14:45:33.000000000 +0900 @@ -39,7 +39,11 @@ #include #include +#if defined(__linux__) +#include +#else #include +#endif #include #include diff -urNp v6eval-2.2b6/lib/pkt/BpfAgent.cc v6eval-2.2b6-linux/lib/pkt/BpfAgent.cc --- v6eval-2.2b6/lib/pkt/BpfAgent.cc 2002-05-27 18:56:21.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/BpfAgent.cc 2004-01-26 14:45:33.000000000 +0900 @@ -134,7 +134,7 @@ bufStat BpfAgent::stat() const{ return rc;} void BpfAgent::clear() { -#if 1 +#if ! defined(__linux__) /* In rare case, clear() function is called before filterd out all sent packets. So need to wait all sent packets filtered diff -urNp v6eval-2.2b6/lib/pkt/Bpfilter.cc v6eval-2.2b6-linux/lib/pkt/Bpfilter.cc --- v6eval-2.2b6/lib/pkt/Bpfilter.cc 2001-10-29 10:41:34.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/Bpfilter.cc 2004-01-26 14:45:33.000000000 +0900 @@ -53,7 +53,21 @@ #include #include +#if defined(__linux__) +#include /* for the glibc version number */ +#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1 +#include +#include /* the L2 protocols */ +#else +#include +#include +#include /* The L2 protocols */ +#endif +#include +#endif + Bpfilter::Bpfilter(CSTR n):fd_(-1),bufsize_(0) { +#if !defined(__linux__) int i, fd=-1; char dev[32]; struct ifreq ifr; @@ -91,67 +105,159 @@ Bpfilter::Bpfilter(CSTR n):fd_(-1),bufsi ::close(fd); return;} fd_=fd;} +#else + int i, fd=-1; + char dev[32]; + struct sockaddr_ll sll; + + fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + if(fd<0) { + perror("err:open"); + return;} + memset(&sll, 0xff, sizeof(sll)); + sll.sll_family = AF_PACKET; + sll.sll_protocol = htons(ETH_P_ALL); + ifindex_ = if_nametoindex(n); + if(ifindex_<0) { + perror("err:if_nametoindex()"); + return;} + sll.sll_ifindex = ifindex_; + int rc = bind(fd, (struct sockaddr *)&sll, sizeof(sll)); + if(rc<0) { + perror("err:bind"); + return;} + bufsize_=BPF_MAXBUFSIZE; + fd_=fd;} +#endif int Bpfilter::setfilter(struct bpf_program *filter) const { +#if !defined(__linux__) int fd=fileDesc(); if(fd<0) return -1; int rc = ioctl(fd,BIOCSETF,filter); if(rc<0){perror("err:ioctl(BIOCSETF)");} return rc; } +#else + /* xxx: For Linux, "filter ipv6" in tn.def is NOT supported */ + return 0; +} +#endif int Bpfilter::promiscuous() const { int fd=fileDesc(); if(fd<0) return -1; +#if !defined(__linux__) int rc=ioctl(fd,BIOCPROMISC,NULL); if(rc<0) {perror("err:ioctl(BIOCPROMISC)");} return rc;} +#else + struct ifreq ifr; + int rc=ioctl(fd,SIOCGIFFLAGS,&ifr); + if(rc<0) {perror("err:ioctl(SIOCGIFFLAGS)");} + ifr.ifr_flags = ifr.ifr_flags | IFF_PROMISC; + rc=ioctl(fd,SIOCSIFFLAGS,&ifr); + if(rc<0) {perror("err:ioctl(SIOCSIFFLAGS)");} + return 0;} +#endif int Bpfilter::flush() const { int fd=fileDesc(); if(fd<0) return -1; +#if !defined(__linux__) int rc=ioctl(fd,BIOCFLUSH,NULL); if(rc<0) {perror("err:ioctl(BIOCFLUSH)");} return rc;} +#else + unsigned char buf[2048]; + int i=0; + do { + fd_set fds; + struct timeval t; + FD_ZERO(&fds); + FD_SET(fd, &fds); + memset(&t, 0, sizeof(t)); + i = select(FD_SETSIZE, &fds, NULL, NULL, &t); + if (i > 0) + recv(fd, buf, i, 0); + } while (i); + return 0;} +#endif int Bpfilter::immediate(uint32_t n) const { +#if !defined(__linux__) int fd=fileDesc(); if(fd<0) return -1; int rc=ioctl(fd,BIOCIMMEDIATE,&n); if(rc<0) {perror("err:ioctl(BIOCIMMEDIATE)");} return rc;} +#else + /* xxx: For Linux, tahi works only in immediate=true mode */ + return 0;} +#endif int Bpfilter::statistics(uint32_t& recv,uint32_t& drop) const { struct bpf_stat stat; int fd=fileDesc(); recv=0; drop=0; if(fd<0) return -1; +#if !defined(__linux__) int rc=ioctl(fd,BIOCGSTATS,(caddr_t)&stat); if(rc<0) {perror("err:ioctl(BIOCGSTATS)");} else {recv=stat.bs_recv; drop=stat.bs_drop;} return rc;} +#else + /* xxx: Linux cannot get per-socket statistics */ + return 0;} +#endif int Bpfilter::receive(caddr_t p) const { int fd=fileDesc(); if(fd<0) return -1; uint32_t l=bufferSize(); +#if !defined(__linux__) int rc=::read(fd,p,l); if(rc<0) {perror("err:read");} return rc;} +#else +#define SIZEOF_BPF_HDR 18 + int rc =recv(fd, (p+SIZEOF_BPF_HDR), (l-SIZEOF_BPF_HDR), 0); + gettimeofday( &((struct bpf_hdr *)p)->bh_tstamp, 0) ; + ((struct bpf_hdr *)p)->bh_caplen = rc; + ((struct bpf_hdr *)p)->bh_datalen =rc + SIZEOF_BPF_HDR; + ((struct bpf_hdr *)p)->bh_hdrlen = SIZEOF_BPF_HDR; + if(rc<0) { + perror("err:recv"); + return rc;} + return (rc+SIZEOF_BPF_HDR);} +#undef SIZEOF_BPF_HDR +#endif int Bpfilter::send(caddr_t p, uint32_t l) const { int fd=fileDesc(); if(fd<0) return -1; if(l>bufferSize()){perror("err:send packet too long");return -1;}; +#if !defined(__linux__) int rc=::write(fd,p,l); +#else + struct sockaddr_ll sll; + memset(&sll, 0, sizeof(sll)); + sll.sll_ifindex = ifindex_; + int rc = sendto(fd, p, l, 0, (struct sockaddr *)&sll, sizeof(sll)); +#endif if(rc<0) {perror("err:write");} return rc;} uint32_t Bpfilter::getDLT() const { int fd=fileDesc(); if(fd<0) return 0xffff; /* xxx */ +#if !defined(__linux__) uint32_t dlt; int rc=ioctl(fd,BIOCGDLT,&dlt); if(rc<0) {perror("err:ioctl(BIOCGSTATS)");} return dlt;} +#else + /* Linux assumes ethernet */ + return DLT_EN10MB;} +#endif diff -urNp v6eval-2.2b6/lib/pkt/Bpfilter.h v6eval-2.2b6-linux/lib/pkt/Bpfilter.h --- v6eval-2.2b6/lib/pkt/Bpfilter.h 2001-10-05 20:41:19.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/Bpfilter.h 2004-01-26 14:45:33.000000000 +0900 @@ -51,6 +51,9 @@ struct Bpfilter { private: int fd_; uint32_t bufsize_; +#if defined(__linux__) + int ifindex_; +#endif public: Bpfilter(CSTR); int fileDesc() const; diff -urNp v6eval-2.2b6/lib/pkt/LxLexer.cc v6eval-2.2b6-linux/lib/pkt/LxLexer.cc --- v6eval-2.2b6/lib/pkt/LxLexer.cc 2003-10-23 13:37:30.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/LxLexer.cc 2004-01-26 14:45:33.000000000 +0900 @@ -262,7 +262,9 @@ void LxLexer::initialize() { function(new MfCrypt("null_crypt",0,0,1)); function(new MfDESCBC("descbc",8,8,8)); function(new MfBLOWFISH("blowfish",8,8,8)); +#if ! defined(__linux__) function(new MfRC5("rc5",8,8,8)); +#endif function(new MfCAST128("cast128",8,8,8)); function(new MfDES3CBC("des3cbc",8*3,8,8)); function(new MfRIJNDAEL("rijndael_128",16,16,16)); diff -urNp v6eval-2.2b6/lib/pkt/Makefile v6eval-2.2b6-linux/lib/pkt/Makefile --- v6eval-2.2b6/lib/pkt/Makefile 2000-07-28 16:25:18.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/Makefile 2004-01-29 16:29:55.000000000 +0900 @@ -10,4 +10,5 @@ CXXFLAGS+= -I. -I$(Cm) -I$(Pz) -DHAVE_BP CLEANFILES+=PzParse.h +MKLINT=no .include "bsd.lib.mk" diff -urNp v6eval-2.2b6/lib/pkt/PzParse.y v6eval-2.2b6-linux/lib/pkt/PzParse.y --- v6eval-2.2b6/lib/pkt/PzParse.y 2003-01-27 14:55:23.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/PzParse.y 2004-01-26 14:45:33.000000000 +0900 @@ -175,7 +175,11 @@ #define YYPARSE_PARAM_TYPE LxLexer& #define yyparse(lex)parse(lex) #else +#if ! defined(__linux__) #define yyparse()parse(LxLexer& lexer) +#else +#define yyparse(void)parse(LxLexer& lexer) +#endif #endif #define yylex()lexer.lex(compound_) #define yyerror lexer.yaccError diff -urNp v6eval-2.2b6/lib/pkt/RunEnv.cc v6eval-2.2b6-linux/lib/pkt/RunEnv.cc --- v6eval-2.2b6/lib/pkt/RunEnv.cc 2003-10-23 13:37:31.000000000 +0900 +++ v6eval-2.2b6-linux/lib/pkt/RunEnv.cc 2004-01-26 14:45:33.000000000 +0900 @@ -51,6 +51,9 @@ #include #include #include +#if defined(__linux__) +#include +#endif IfName::IfName(CSTR n,CSTR i,CSTR e):CmCString(n),interface_(i),ether_(e) {} IfName::~IfName() {} IfName* IfName::create(CSTR n,CSTR i,CSTR m,CSTR file,uint32_t line) { diff -urNp v6eval-2.2b6/lorder v6eval-2.2b6-linux/lorder --- v6eval-2.2b6/lorder 1970-01-01 09:00:00.000000000 +0900 +++ v6eval-2.2b6-linux/lorder 2004-01-29 16:34:20.000000000 +0900 @@ -0,0 +1,6 @@ +#!/bin/sh +# +# *** This is a dummy lorder only for compiling TAHI on Linux *** +# +while [ $1 ]; do echo $1; shift; done; +exit 0;