Mercurial > ecos
changeset 352:1f5fe8f482d9
Only support I/O through the ethertap device if running a sufficiently
recent Linux kernel
| author | bartv |
|---|---|
| date | Wed, 25 Sep 2002 19:53:54 +0000 |
| parents | 58836890b2a0 |
| children | 9c7f9b4dfb2f |
| files | packages/devs/eth/synth/ecosynth/current/ChangeLog packages/devs/eth/synth/ecosynth/current/doc/devs-eth-synth-ecosynth.html packages/devs/eth/synth/ecosynth/current/doc/syntheth.sgml packages/devs/eth/synth/ecosynth/current/host/configure packages/devs/eth/synth/ecosynth/current/host/configure.in packages/devs/eth/synth/ecosynth/current/host/rawether.c |
| diffstat | 6 files changed, 255 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/devs/eth/synth/ecosynth/current/ChangeLog +++ b/packages/devs/eth/synth/ecosynth/current/ChangeLog @@ -1,3 +1,8 @@ +2002-09-25 Bart Veer <bartv@ecoscentric.com> + + * host/configure.in, host/rawether.c, doc/syntheth.sgml: + Only support the tap device if running a recent Linux kernel + 2002-09-22 Bart Veer <bartv@ecoscentric.com> * host/configure.in:
--- a/packages/devs/eth/synth/ecosynth/current/doc/devs-eth-synth-ecosynth.html +++ b/packages/devs/eth/synth/ecosynth/current/doc/devs-eth-synth-ecosynth.html @@ -3,9 +3,6 @@ <!-- and conditions set forth in the Open Publication License, v1.0 --> <!-- or later (the latest version is presently available at --> <!-- http://www.opencontent.org/openpub/). --> -<!-- Distribution of substantively modified versions of this --> -<!-- document is prohibited without the explicit permission of the --> -<!-- copyright holder. --> <!-- Distribution of the work or derivative of the work in any --> <!-- standard (paper) book form is prohibited unless prior --> <!-- permission is obtained from the copyright holder. --> @@ -428,6 +425,25 @@ documentation should be consulted, for e CLASS="FILENAME" >/usr/src/linux-2.4/Documentation/networking/tuntap.txt</TT >. +If you are using an old Linux kernel then the ethertap functionality +may be missing completely. When the <B +CLASS="COMMAND" +>rawether</B +> +program is configured and built, the <B +CLASS="COMMAND" +>configure</B +> +script will check for a file <TT +CLASS="FILENAME" +>/usr/include/linux/if_tun.h</TT +>. If that +file is missing then <B +CLASS="COMMAND" +>rawether</B +> will be built without +ethertap functionality, and only real ethernet interfaces will be +supported. </P ><P >The target definition file is used to map eCos network devices on to
--- a/packages/devs/eth/synth/ecosynth/current/doc/syntheth.sgml +++ b/packages/devs/eth/synth/ecosynth/current/doc/syntheth.sgml @@ -237,6 +237,14 @@ your system does not have a device <file or a module <filename>tun.o</filename> then the appropriate kernel documentation should be consulted, for example <filename>/usr/src/linux-2.4/Documentation/networking/tuntap.txt</filename>. +If you are using an old Linux kernel then the ethertap functionality +may be missing completely. When the <command>rawether</command> +program is configured and built, the <command>configure</command> +script will check for a file <filename +class="headerfile">/usr/include/linux/if_tun.h</filename>. If that +file is missing then <command>rawether</command> will be built without +ethertap functionality, and only real ethernet interfaces will be +supported. </para> <para> The target definition file is used to map eCos network devices on to
--- a/packages/devs/eth/synth/ecosynth/current/host/configure +++ b/packages/devs/eth/synth/ecosynth/current/host/configure @@ -844,12 +844,15 @@ case "${host}" in i[34567]86-*-linux-gnu* ) SUPPORTED="yes";; * ) SUPPORTED="no" esac +if test "${SUPPORTED}" = "no" ; then + echo "configure: warning: Synthetic target ethernet support is only available on x86 Linux hosts" 1>&2 +fi if test "${SUPPORTED}" = "yes" ; then # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:853: checking for $ac_word" >&5 +echo "configure:856: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -879,7 +882,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:883: checking for $ac_word" >&5 +echo "configure:886: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -930,7 +933,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:934: checking for $ac_word" >&5 +echo "configure:937: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -962,7 +965,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:966: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:969: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -973,12 +976,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 977 "configure" +#line 980 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1004,12 +1007,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1008: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1011: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1013: checking whether we are using GNU C" >&5 +echo "configure:1016: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1018,7 +1021,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1025: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1037,7 +1040,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1041: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1044: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1073,7 +1076,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1077: checking for $ac_word" >&5 +echo "configure:1080: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1105,7 +1108,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1109: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1112: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1116,12 +1119,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1120 "configure" +#line 1123 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1125: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1147,12 +1150,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1151: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1154: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1156: checking whether we are using GNU C++" >&5 +echo "configure:1159: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1161,7 +1164,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1168: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1180,7 +1183,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}" ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1184: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1187: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1221,7 +1224,7 @@ for ac_declaration in \ 'void exit (int);' do cat > conftest.$ac_ext <<EOF -#line 1225 "configure" +#line 1228 "configure" #include "confdefs.h" #include <stdlib.h> $ac_declaration @@ -1229,7 +1232,7 @@ int main() { exit (42); ; return 0; } EOF -if { (eval echo configure:1233: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 @@ -1239,14 +1242,14 @@ else fi rm -f conftest* cat > conftest.$ac_ext <<EOF -#line 1243 "configure" +#line 1246 "configure" #include "confdefs.h" $ac_declaration int main() { exit (42); ; return 0; } EOF -if { (eval echo configure:1250: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1253: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* break else @@ -1263,13 +1266,13 @@ fi echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1267: checking for object suffix" >&5 +echo "configure:1270: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1273: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1276: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1287,12 +1290,12 @@ OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1291: checking for Cygwin environment" >&5 +echo "configure:1294: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1296 "configure" +#line 1299 "configure" #include "confdefs.h" int main() { @@ -1303,7 +1306,7 @@ int main() { return __CYGWIN__; ; return 0; } EOF -if { (eval echo configure:1307: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1310: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1320,19 +1323,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1324: checking for mingw32 environment" >&5 +echo "configure:1327: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1329 "configure" +#line 1332 "configure" #include "confdefs.h" int main() { return __MINGW32__; ; return 0; } EOF -if { (eval echo configure:1336: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1339: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1351,7 +1354,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=y echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1355: checking for executable suffix" >&5 +echo "configure:1358: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1361,7 +1364,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1368: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -1399,7 +1402,7 @@ ac_exeext=$EXEEXT echo $ac_n "checking "for Visual C++"""... $ac_c" 1>&6 -echo "configure:1403: checking "for Visual C++"" >&5 +echo "configure:1406: checking "for Visual C++"" >&5 MSVC="no"; if test "${CC}" = "cl" ; then MSVC="yes" @@ -1438,7 +1441,7 @@ fi echo $ac_n "checking "the default compiler flags"""... $ac_c" 1>&6 -echo "configure:1442: checking "the default compiler flags"" >&5 +echo "configure:1445: checking "the default compiler flags"" >&5 ecosflags_enable_debug="no" # Check whether --enable-debug or --disable-debug was given. @@ -1531,6 +1534,135 @@ fi + + echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1540: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 1555 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1561: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 1572 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1578: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 1589 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1595: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_hdr in "linux/if_tun.h" +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1623: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1628 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1633: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + TAP_SUPPORTED="yes" +else + echo "$ac_t""no" 1>&6 +TAP_SUPPORTED="no" +fi +done + + if test "${TAP_SUPPORTED}" = "no" ; then + echo "configure: warning: No <linux/if_tun.h> header, ethertap support disabled." 1>&2 + fi +fi + +if test "${SUPPORTED}" = "no" ; then + echo "configure: warning: The synthetic ethernet support cannot be built on this platform." 1>&2 fi @@ -1724,6 +1856,7 @@ s%@ECOS_REPOSITORY@%$ECOS_REPOSITORY%g s%@PACKAGE_DIR@%$PACKAGE_DIR%g s%@PACKAGE_VERSION@%$PACKAGE_VERSION%g s%@PACKAGE_INSTALL@%$PACKAGE_INSTALL%g +s%@CPP@%$CPP%g s%@SUPPORTED_TRUE@%$SUPPORTED_TRUE%g s%@SUPPORTED_FALSE@%$SUPPORTED_FALSE%g
--- a/packages/devs/eth/synth/ecosynth/current/host/configure.in +++ b/packages/devs/eth/synth/ecosynth/current/host/configure.in @@ -62,6 +62,9 @@ case "${host}" in i[[34567]]86-*-linux-gnu* ) SUPPORTED="yes";; * ) SUPPORTED="no" esac +if test "${SUPPORTED}" = "no" ; then + AC_MSG_WARN([Synthetic target ethernet support is only available on x86 Linux hosts]) +fi if test "${SUPPORTED}" = "yes" ; then AC_PROG_CC @@ -71,6 +74,17 @@ if test "${SUPPORTED}" = "yes" ; then ECOS_PROG_MSVC ECOS_PROG_STANDARD_COMPILER_FLAGS ECOS_PACKAGE_DIRS + + dnl Old kernels may not have tun/tap support. rawether can + dnl still operate via a spare ethernet interface. + AC_CHECK_HEADERS("linux/if_tun.h",TAP_SUPPORTED="yes",TAP_SUPPORTED="no") + if test "${TAP_SUPPORTED}" = "no" ; then + AC_MSG_WARN([No <linux/if_tun.h> header, ethertap support disabled.]) + fi +fi + +if test "${SUPPORTED}" = "no" ; then + AC_MSG_WARN([The synthetic ethernet support cannot be built on this platform.]) fi AM_CONDITIONAL(SUPPORTED, test "${SUPPORTED}" = "yes")
--- a/packages/devs/eth/synth/ecosynth/current/host/rawether.c +++ b/packages/devs/eth/synth/ecosynth/current/host/rawether.c @@ -63,7 +63,9 @@ #include <netinet/if_ether.h> #include <linux/if_packet.h> #include <linux/if_ether.h> -#include <linux/if_tun.h> +#ifdef HAVE_LINUX_IF_TUN_H +# include <linux/if_tun.h> +#endif // The protocol between host and target is defined by a private // target-side header. @@ -98,6 +100,14 @@ static int up = 0; static unsigned char tx_buffer[MTU]; static unsigned char rx_buffer[MTU+4]; +// Indirect to get to the actual implementation functions. +static void (*tx_fn)(unsigned char*, int); +static void (*rx_fn)(void); +static void (*start_fn)(int); +static void (*stop_fn)(void); +static void (*multicast_fn)(int); + + // ---------------------------------------------------------------------------- // A utility buffer for messages. #define MSG_SIZE 256 @@ -304,6 +314,12 @@ real_init(char* devname) { struct sockaddr_ll addr; struct ifreq request; + + tx_fn = &real_handle_tx; + rx_fn = &real_handle_rx; + start_fn = &real_handle_start; + stop_fn = &real_handle_stop; + multicast_fn = &real_handle_multiall; if (strlen(devname) >= IFNAMSIZ) { snprintf(msg, MSG_SIZE, "Invalid real network device name \"%s\", too long.\n", devname); @@ -402,6 +418,10 @@ real_init(char* devname) // The Linux kernel will invent a MAC address for its interface. An // additional one is needed for eCos. This is either invented or // specified in the target definition file. +// +// Old Linux kernels may not have the required support. This is detected +// by an autoconf test for <linux/if_tun.h> +#ifdef HAVE_LINUX_IF_TUN_H static void tap_handle_tx(unsigned char* buffer, int size) @@ -500,11 +520,18 @@ tap_handle_multiall(int on) { } -static void tap_init(int argc, char** argv) +static void +tap_init(int argc, char** argv) { char* devname = NULL; struct ifreq ifr; + tx_fn = &tap_handle_tx; + rx_fn = &tap_handle_rx; + start_fn = &tap_handle_start; + stop_fn = &tap_handle_stop; + multicast_fn = &tap_handle_multiall; + // Which device? By default let the system pick one, but the user // can override this. if (0 != argc) { @@ -561,6 +588,14 @@ static void tap_init(int argc, char** ar // All done. } +#else +static void +tap_init(int argc, char** argv) +{ + snprintf(msg, MSG_SIZE, "Ethertap support was not available when the host-side support was built\n"); + report_error(msg); +} +#endif // HAVE_LINUX_IF_TUN_H // ---------------------------------------------------------------------------- // Receive a single request from ecosynth. This consists of a four-byte @@ -640,40 +675,24 @@ handle_ecosynth_request(void) exit(1); } - if (real_ether) { - real_handle_tx(tx_buffer, size); - } else if (ethertap) { - tap_handle_tx(tx_buffer, size); - } + (*tx_fn)(tx_buffer, size); break; } case SYNTH_ETH_START: { - if (real_ether) { - real_handle_start(arg); - } else if (ethertap) { - tap_handle_start(arg); - } + (*start_fn)(arg); break; } case SYNTH_ETH_STOP: { - if (real_ether) { - real_handle_stop(); - } else if (ethertap) { - tap_handle_stop(); - } + (*stop_fn)(); break; } case SYNTH_ETH_MULTIALL: { - if (real_ether) { - real_handle_multiall(arg); - } else if (ethertap) { - tap_handle_multiall(arg); - } + (*multicast_fn)(arg); break; } @@ -713,11 +732,7 @@ mainloop(void) if (FD_ISSET(0, &read_set)) { handle_ecosynth_request(); } else if (FD_ISSET(ether_fd, &read_set)) { - if (real_ether) { - real_handle_rx(); - } else { - tap_handle_rx(); - } + (*rx_fn)(); } } }
