- cleaned up config.h symbols of networking modules. Now always using name format

BX_NETMOD_xxx and set them in configure script
This commit is contained in:
Volker Ruppert 2011-02-26 20:10:06 +00:00
parent c6e6b579e7
commit ac61b38825
11 changed files with 74 additions and 87 deletions

View File

@ -1416,25 +1416,25 @@ void bx_init_options()
// ne2k & pnic options
static const char *eth_module_list[] = {
"null",
#if defined(ETH_LINUX)
#if BX_NETMOD_LINUX
"linux",
#endif
#if HAVE_ETHERTAP
#if BX_NETMOD_TAP
"tap",
#endif
#if HAVE_TUNTAP
#if BX_NETMOD_TUNTAP
"tuntap",
#endif
#if defined(ETH_WIN32)
#if BX_NETMOD_WIN32
"win32",
#endif
#if defined(ETH_FBSD)
#if BX_NETMOD_FBSD
"fbsd",
#endif
#ifdef ETH_ARPBACK
#if BX_NETMOD_ARPBACK
"arpback",
#endif
#if HAVE_VDE
#if BX_NETMOD_VDE
"vde",
#endif
"vnet",

View File

@ -845,36 +845,18 @@ typedef
// this enables the lowlevel stuff below if one of the NICs is present
#define BX_NETWORKING 0
#define BX_ETH_NULL_LOGGING 1
#define BX_ETH_FBSD_LOGGING 1
// determine which NE2K packet mover modules will be enabled
// (this was moved from iodev/eth.h)
#define ETH_NULL 1
#ifdef BX_USE_ETH_ARPBACK
# define ETH_ARPBACK 1
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__NetBSD_kernel__) || defined(__APPLE__)
#define ETH_FBSD 1
#endif
#if defined(linux)
#define ETH_LINUX 1
#endif
#if defined(WIN32)
#define ETH_WIN32 1
#endif
// this enables Ethertap packet mover; determined by configure script
#define HAVE_ETHERTAP 0
// this enables TUN/TAP packet mover; determined by configure script
#define HAVE_TUNTAP 0
// this enables VDE packet mover; determined by configure script
#define HAVE_VDE 0
// which networking modules will be enabled
// determined by configure script
#define BX_NETMOD_ARPBACK 0
#define BX_NETMOD_FBSD 0
#define BX_NETMOD_LINUX 0
#define BX_NETMOD_WIN32 0
#define BX_NETMOD_TAP 0
#define BX_NETMOD_TUNTAP 0
#define BX_NETMOD_VDE 0
// I/O Interface to debug
// I/O Interface to debugger
#define BX_SUPPORT_IODEBUG 0
#ifdef WIN32

View File

@ -808,15 +808,22 @@ AC_ARG_ENABLE(pnic,
NETLOW_OBJS=''
if test "$networking" = yes; then
NETLOW_OBJS='eth.o eth_null.o eth_vnet.o'
AC_CHECK_HEADER(net/bpf.h, NETLOW_OBJS="$NETLOW_OBJS eth_fbsd.o")
AC_CHECK_HEADER(netpacket/packet.h, NETLOW_OBJS="$NETLOW_OBJS eth_linux.o")
AC_CHECK_HEADER(net/bpf.h, [
NETLOW_OBJS="$NETLOW_OBJS eth_fbsd.o"
AC_DEFINE(BX_NETMOD_FBSD, 1)
])
AC_CHECK_HEADER(netpacket/packet.h, [
NETLOW_OBJS="$NETLOW_OBJS eth_linux.o"
AC_DEFINE(BX_NETMOD_LINUX, 1)
])
case "$target" in
*-pc-windows* | *-pc-winnt* | *-pc-cygwin* | *-pc-mingw32*)
NETLOW_OBJS="$NETLOW_OBJS eth_win32.o"
AC_DEFINE(BX_NETMOD_WIN32, 1)
;;
*-macosx* | *-darwin*)
NETLOW_OBJS="$NETLOW_OBJS eth_tuntap.o"
AC_DEFINE(HAVE_TUNTAP, 1)
AC_DEFINE(BX_NETMOD_TUNTAP, 1)
;;
*)
AC_CHECK_HEADER(net/if.h, [
@ -837,8 +844,8 @@ if test "$networking" = yes; then
if test "$use_ethertap" = yes; then
NETLOW_OBJS="$NETLOW_OBJS eth_tap.o eth_vde.o"
AC_DEFINE(HAVE_ETHERTAP, 1)
AC_DEFINE(HAVE_VDE, 1)
AC_DEFINE(BX_NETMOD_TAP, 1)
AC_DEFINE(BX_NETMOD_VDE, 1)
fi
AC_CHECK_HEADER(net/if_tun.h, [
@ -858,7 +865,7 @@ if test "$networking" = yes; then
])
if test "$use_tuntap" = yes; then
NETLOW_OBJS="$NETLOW_OBJS eth_tuntap.o"
AC_DEFINE(HAVE_TUNTAP, 1)
AC_DEFINE(BX_NETMOD_TUNTAP, 1)
fi
;;

View File

@ -50,28 +50,26 @@ eth_locator_c::eth_locator_c(const char *type)
this->type = type;
}
#ifdef ETH_NULL
extern class bx_null_locator_c bx_null_match;
#endif
#ifdef ETH_FBSD
#if BX_NETMOD_FBSD
extern class bx_fbsd_locator_c bx_fbsd_match;
#endif
#ifdef ETH_LINUX
#if BX_NETMOD_LINUX
extern class bx_linux_locator_c bx_linux_match;
#endif
#ifdef ETH_WIN32
#if BX_NETMOD_WIN32
extern class bx_win32_locator_c bx_win32_match;
#endif
#if HAVE_ETHERTAP
#if BX_NETMOD_TAP
extern class bx_tap_locator_c bx_tap_match;
#endif
#if HAVE_TUNTAP
#if BX_NETMOD_TUNTAP
extern class bx_tuntap_locator_c bx_tuntap_match;
#endif
#if HAVE_VDE
#if BX_NETMOD_VDE
extern class bx_vde_locator_c bx_vde_match;
#endif
#ifdef ETH_ARPBACK
#if BX_NETMOD_ARPBACK
extern class bx_arpback_locator_c bx_arpback_match;
#endif
extern class bx_vnet_locator_c bx_vnet_match;
@ -94,66 +92,63 @@ eth_locator_c::create(const char *type, const char *netif,
#else
eth_locator_c *ptr = 0;
#ifdef ETH_ARPBACK
if (!strcmp(type, "null")) {
ptr = (eth_locator_c *) &bx_null_match;
}
#if BX_NETMOD_ARPBACK
{
if (!strcmp(type, "arpback"))
ptr = (eth_locator_c *) &bx_arpback_match;
}
#endif
#ifdef ETH_NULL
{
if (!strcmp(type, "null"))
ptr = (eth_locator_c *) &bx_null_match;
}
#endif
#ifdef ETH_FBSD
#if BX_NETMOD_FBSD
{
if (!strcmp(type, "fbsd"))
ptr = (eth_locator_c *) &bx_fbsd_match;
}
#endif
#ifdef ETH_LINUX
#if BX_NETMOD_LINUX
{
if (!strcmp(type, "linux"))
ptr = (eth_locator_c *) &bx_linux_match;
}
#endif
#if HAVE_TUNTAP
#if BX_NETMOD_TUNTAP
{
if (!strcmp(type, "tuntap"))
ptr = (eth_locator_c *) &bx_tuntap_match;
}
#endif
#if HAVE_VDE
#if BX_NETMOD_VDE
{
if (!strcmp(type, "vde"))
ptr = (eth_locator_c *) &bx_vde_match;
}
#endif
#if HAVE_ETHERTAP
#if BX_NETMOD_TAP
{
if (!strcmp(type, "tap"))
ptr = (eth_locator_c *) &bx_tap_match;
}
#endif
#ifdef ETH_WIN32
#if BX_NETMOD_WIN32
{
if(!strcmp(type, "win32"))
ptr = (eth_locator_c *) &bx_win32_match;
}
#endif
{
if (!strcmp(type, "vnet"))
ptr = (eth_locator_c *) &bx_vnet_match;
if (!strcmp(type, "vnet")) {
ptr = (eth_locator_c *) &bx_vnet_match;
}
if (ptr)
if (ptr) {
return (ptr->allocate(netif, macaddr, rxh, dev, script));
}
#endif
return (NULL);
}
#if (HAVE_ETHERTAP==1) || (HAVE_TUNTAP==1) || (HAVE_VDE==1)
#if (BX_NETMOD_TAP==1) || (BX_NETMOD_TUNTAP==1) || (BX_NETMOD_VDE==1)
extern "C" {
#include <sys/wait.h>
@ -190,7 +185,7 @@ int execute_script(bx_devmodel_c *netdev, const char* scriptname, char* arg1)
return WEXITSTATUS(status);
}
#endif // (HAVE_ETHERTAP==1) || (HAVE_TUNTAP==1)
#endif
void write_pktlog_txt(FILE *pktlog_txt, const Bit8u *buf, unsigned len, bx_bool host_to_guest)
{

View File

@ -33,13 +33,15 @@
#include "iodev.h"
#if BX_NETWORKING && defined(ETH_ARPBACK)
#if BX_NETWORKING && BX_NETMOD_ARPBACK
#include "eth.h"
#include "crc32.h"
#include "eth_packetmaker.h"
#define LOG_THIS netdev->
#define BX_ETH_ARPBACK_LOGGING 1
//static const Bit8u external_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00};
//static const Bit8u internal_mac[]={0xB0, 0xC4, 0x20, 0x00, 0x00, 0x00, 0x00};
@ -104,7 +106,7 @@ bx_arpback_pktmover_c::bx_arpback_pktmover_c(const char *netif,
this->rxh = rxh;
//bufvalid=0;
packetmaker.init();
#if BX_ETH_NULL_LOGGING
#if BX_ETH_ARPBACK_LOGGING
// Start the rx poll
// eventually Bryce wants txlog to dump in pcap format so that
// tcpdump -r FILE can read it and interpret packets.
@ -150,7 +152,7 @@ bx_arpback_pktmover_c::sendpkt(void *buf, unsigned io_len)
}
*/
}
#if BX_ETH_NULL_LOGGING
#if BX_ETH_ARPBACK_LOGGING
BX_DEBUG(("sendpkt length %u", io_len));
// dump raw bytes to a file, eventually dump in pcap format so that
// tcpdump -r FILE can interpret them for us.
@ -165,7 +167,7 @@ bx_arpback_pktmover_c::sendpkt(void *buf, unsigned io_len)
void bx_arpback_pktmover_c::rx_timer_handler (void * this_ptr)
{
#if BX_ETH_NULL_LOGGING
#if BX_ETH_ARPBACK_LOGGING
BX_DEBUG(("rx_timer_handler"));
#endif
bx_arpback_pktmover_c *class_ptr = ((bx_arpback_pktmover_c *)this_ptr);
@ -178,11 +180,11 @@ void bx_arpback_pktmover_c::rx_timer (void)
eth_packet rubble;
if (packetmaker.getpacket(rubble)) {
#if BX_ETH_NULL_LOGGING
#if BX_ETH_ARPBACK_LOGGING
write_pktlog_txt(pktlog_txt, rubble.buf, rubble.len, 1);
#endif
(*rxh)(this->netdev, rubble.buf, rubble.len);
}
}
#endif /* if BX_NETWORKING && defined(ETH_ARPBACK) */
#endif /* if BX_NETWORKING && BX_NETMOD_ARPBACK */

View File

@ -50,12 +50,14 @@
#include "iodev.h"
#if BX_NETWORKING && defined(ETH_FBSD)
#if BX_NETWORKING && BX_NETMOD_FBSD
#include "eth.h"
#define LOG_THIS netdev->
#define BX_ETH_FBSD_LOGGING 0
extern "C" {
#include <fcntl.h>
#include <sys/ioctl.h>
@ -369,5 +371,4 @@ bx_fbsd_pktmover_c::rx_timer(void)
}
}
#endif /* if BX_NETWORKING && defined(ETH_FBSD) */
#endif /* if BX_NETWORKING && BX_NETMOD_FBSD */

View File

@ -42,7 +42,7 @@
#include "iodev.h"
#if BX_NETWORKING && defined (ETH_LINUX)
#if BX_NETWORKING && BX_NETMOD_LINUX
#include "eth.h"
@ -281,4 +281,4 @@ bx_linux_pktmover_c::rx_timer(void)
(*rxh)(netdev, rxbuf, nbytes);
// }
}
#endif /* if BX_NETWORKING && defined ETH_LINUX */
#endif /* if BX_NETWORKING && BX_NETMOD_LINUX */

View File

@ -39,6 +39,7 @@
#define LOG_THIS netdev->
#define BX_ETH_NULL_LOGGING 1
//
// Define the class. This is private to this module

View File

@ -25,7 +25,7 @@
#include "iodev.h"
#if BX_NETWORKING && defined(ETH_ARPBACK)
#if BX_NETWORKING && BX_NETMOD_ARPBACK
#include "eth_packetmaker.h"
@ -199,4 +199,4 @@ bx_bool eth_ARPmaker::sendpacket(const eth_packet& outpacket)
}
}
#endif /* if BX_NETWORKING && defined(ETH_ARPBACK) */
#endif /* if BX_NETWORKING && BX_NETMOD_ARPBACK */

View File

@ -21,7 +21,7 @@
#ifndef _ETH_PACKETMAKER_H_
#define _ETH_PACKETMAKER_H_
#ifdef ETH_ARPBACK
#if BX_NETMOD_ARPBACK
static const Bit8u internal_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00};
static const Bit8u external_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00};
@ -141,6 +141,5 @@ private:
};
#endif // ETH_ARPBACK
#endif // BX_NETMOD_ARPBACK
#endif // _ETH_PACKETMAKER_H_

View File

@ -39,7 +39,7 @@
#include "iodev.h"
#if BX_NETWORKING && defined(ETH_WIN32)
#if BX_NETWORKING && BX_NETMOD_WIN32
#include "eth.h"
@ -383,4 +383,4 @@ void bx_win32_pktmover_c::rx_timer(void)
}
}
}
#endif /* if BX_NETWORKING && defined ETH_WIN32 */
#endif /* if BX_NETWORKING && BX_NETMOD_WIN32 */