From 31e4cb1feeb2c5ec66ac7fb3973bafd6d521db4d Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 7 Oct 2004 17:38:03 +0000 Subject: [PATCH] - dependencies between NE2k and PCI Pseudo-NIC removed from the config interface - menu and option names for the network configuration fixed - NIC init code passes script name to ethernet module init code - VDE module added to the list of ethernet modules - constant BX_PACKET_BUFSIZE moved to eth.h --- bochs/config.cc | 9 +++++---- bochs/gui/textconfig.cc | 4 ++-- bochs/iodev/eth.cc | 8 ++++---- bochs/iodev/eth.h | 10 +++++++--- bochs/iodev/eth_arpback.cc | 12 ++++++------ bochs/iodev/eth_fbsd.cc | 17 ++++++++--------- bochs/iodev/eth_linux.cc | 16 ++++++++-------- bochs/iodev/eth_null.cc | 11 ++++++----- bochs/iodev/eth_packetmaker.h | 5 ++--- bochs/iodev/eth_tap.cc | 27 +++++++++++++-------------- bochs/iodev/eth_tuntap.cc | 27 +++++++++++++-------------- bochs/iodev/eth_vde.cc | 25 ++++++++++++------------- bochs/iodev/eth_vnet.cc | 17 ++++++++--------- bochs/iodev/eth_win32.cc | 13 ++++++++----- bochs/iodev/ne2k.cc | 9 +++++---- bochs/iodev/pcipnic.cc | 11 ++++------- 16 files changed, 111 insertions(+), 110 deletions(-) diff --git a/bochs/config.cc b/bochs/config.cc index d5399145e..1561a3b97 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.12 2004-09-28 17:37:52 vruppert Exp $ +// $Id: config.cc,v 1.13 2004-10-07 17:38:02 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -1292,6 +1292,9 @@ void bx_init_options () #endif #ifdef ETH_ARPBACK "arpback", +#endif +#if HAVE_VDE + "vde", #endif "vnet", NULL @@ -1378,17 +1381,15 @@ void bx_init_options () bx_options.ne2k.Oethmod, bx_options.ne2k.Oethdev, bx_options.ne2k.Oscript, - bx_options.pnic.Oenabled, NULL }; - menu = new bx_list_c (BXP_NE2K, "NE2K Configuration", "", netdev_init_list); + menu = new bx_list_c (BXP_NE2K, "Network Configuration", "", netdev_init_list); menu->get_options ()->set (menu->SHOW_PARENT); bx_options.ne2k.Opresent->set_dependent_list ( new bx_list_c (BXP_NULL, "", "", ne2k_deps_list)); bx_param_c **pnic_dependent_list = &netdev_init_list[8]; bx_options.pnic.Oenabled->set_dependent_list ( new bx_list_c (BXP_NULL, "", "", pnic_dependent_list)); - bx_options.ne2k.Opresent->set (0); // SB16 options bx_options.sb16.Opresent = new bx_param_bool_c (BXP_SB16_PRESENT, diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index c6c29cefe..a907e5f5a 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.26 2004-07-10 11:05:29 vruppert Exp $ +// $Id: textconfig.cc,v 1.27 2004-10-07 17:38:02 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interface. Note that this file @@ -267,7 +267,7 @@ static char *startup_options_prompt = "8. Disk options\n" "9. Serial or Parallel port options\n" "10. Sound Blaster 16 options\n" -"11. NE2000 network card options\n" +"11. Network card options\n" "12. Keyboard options\n" "13. PCI options\n" "14. Other options\n" diff --git a/bochs/iodev/eth.cc b/bochs/iodev/eth.cc index 834670fe0..c93e34c7b 100644 --- a/bochs/iodev/eth.cc +++ b/bochs/iodev/eth.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth.cc,v 1.22 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth.cc,v 1.23 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -87,12 +87,12 @@ extern class bx_vnet_locator_c bx_vnet_match; eth_pktmover_c * eth_locator_c::create(const char *type, const char *netif, const char *macaddr, - eth_rx_handler_t rxh, void *rxarg) + eth_rx_handler_t rxh, void *rxarg, char *script) { #ifdef eth_static_constructors for (eth_locator_c *p = all; p != NULL; p = p->next) { if (strcmp(type, p->type) == 0) - return (p->allocate(netif, macaddr, rxh, rxarg)); + return (p->allocate(netif, macaddr, rxh, rxarg, script)); } #else eth_locator_c *ptr = 0; @@ -150,7 +150,7 @@ eth_locator_c::create(const char *type, const char *netif, ptr = (eth_locator_c *) &bx_vnet_match; } if (ptr) - return (ptr->allocate(netif, macaddr, rxh, rxarg)); + return (ptr->allocate(netif, macaddr, rxh, rxarg, script)); #endif return (NULL); diff --git a/bochs/iodev/eth.h b/bochs/iodev/eth.h index e5300024a..5ecd44582 100644 --- a/bochs/iodev/eth.h +++ b/bochs/iodev/eth.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth.h,v 1.14 2004-10-03 19:30:36 sshwarts Exp $ +// $Id: eth.h,v 1.15 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -32,6 +32,8 @@ #ifndef BX_ETH_H #define BX_ETH_H +#define BX_PACKET_BUFSIZE 2048 // Enough for an ether frame + typedef void (*eth_rx_handler_t)(void *arg, const void *buf, unsigned len); static const Bit8u broadcast_macaddr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; @@ -66,13 +68,15 @@ public: static eth_pktmover_c *create(const char *type, const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg); + void *rxarg, + char *script); protected: eth_locator_c(const char *type); virtual eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) = 0; + void *rxarg, + char *script) = 0; private: static eth_locator_c *all; eth_locator_c *next; diff --git a/bochs/iodev/eth_arpback.cc b/bochs/iodev/eth_arpback.cc index ecaa5556a..ea011c63c 100644 --- a/bochs/iodev/eth_arpback.cc +++ b/bochs/iodev/eth_arpback.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_arpback.cc,v 1.16 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_arpback.cc,v 1.17 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -51,7 +51,6 @@ //static const Bit8u external_ip[]={ 192, 168, 0, 2, 0x00 }; //static const Bit8u ethtype_arp[]={0x08, 0x06, 0x00}; -#define MAX_FRAME_SIZE 2048 // // Define the class. This is private to this module @@ -85,8 +84,8 @@ public: protected: eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { - return (new bx_arpback_pktmover_c(netif, macaddr, rxh, rxarg)); + void *rxarg, char *script) { + return (new bx_arpback_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_arpback_match; @@ -99,7 +98,8 @@ protected: bx_arpback_pktmover_c::bx_arpback_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { this->rx_timer_index = bx_pc_system.register_timer(this, this->rx_timer_handler, 1000, @@ -129,7 +129,7 @@ bx_arpback_pktmover_c::bx_arpback_pktmover_c(const char *netif, void bx_arpback_pktmover_c::sendpkt(void *buf, unsigned io_len) { - if(io_lenbpf_fd, BIOCSBLEN, (caddr_t)&v) < 0) { BX_PANIC(("eth_freebsd: could not set buffer size: %s", strerror(errno))); close(this->bpf_fd); @@ -327,7 +326,7 @@ void bx_fbsd_pktmover_c::rx_timer(void) { int nbytes = 0; - unsigned char rxbuf[BX_BPF_BUFSIZ]; + unsigned char rxbuf[BX_PACKET_BUFSIZE]; struct bpf_hdr *bhdr; struct bpf_stat bstat; static struct bpf_stat previous_bstat; diff --git a/bochs/iodev/eth_linux.cc b/bochs/iodev/eth_linux.cc index 4c61b9fcc..3a2ba4ed0 100644 --- a/bochs/iodev/eth_linux.cc +++ b/bochs/iodev/eth_linux.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_linux.cc,v 1.19 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_linux.cc,v 1.20 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -68,8 +68,6 @@ extern "C" { #define BX_PACKET_POLL 1000 // Poll for a frame every 1000 usecs -#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame - // template filter for a unicast mac address and all // multicast/broadcast frames static const struct sock_filter macfilter[] = { @@ -99,7 +97,8 @@ public: bx_linux_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg); + void *rxarg, + char *script); void sendpkt(void *buf, unsigned io_len); private: @@ -124,8 +123,8 @@ protected: eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { - return (new bx_linux_pktmover_c(netif, macaddr, rxh, rxarg)); + void *rxarg, char *script) { + return (new bx_linux_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_linux_match; @@ -139,7 +138,8 @@ protected: bx_linux_pktmover_c::bx_linux_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { struct sockaddr_ll sll; struct packet_mreq mr; @@ -259,7 +259,7 @@ void bx_linux_pktmover_c::rx_timer(void) { int nbytes = 0; - Bit8u rxbuf[BX_PACKET_BUFSIZ]; + Bit8u rxbuf[BX_PACKET_BUFSIZE]; struct sockaddr_ll sll; socklen_t fromlen; diff --git a/bochs/iodev/eth_null.cc b/bochs/iodev/eth_null.cc index c31c3a5eb..8d53913f8 100644 --- a/bochs/iodev/eth_null.cc +++ b/bochs/iodev/eth_null.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_null.cc,v 1.17 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_null.cc,v 1.18 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -51,7 +51,7 @@ class bx_null_pktmover_c : public eth_pktmover_c { public: bx_null_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg); + void *rxarg, char *script); void sendpkt(void *buf, unsigned io_len); private: int rx_timer_index; @@ -70,8 +70,8 @@ public: protected: eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { - return (new bx_null_pktmover_c(netif, macaddr, rxh, rxarg)); + void *rxarg, char *script) { + return (new bx_null_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_null_match; @@ -84,7 +84,8 @@ protected: bx_null_pktmover_c::bx_null_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { #if BX_ETH_NULL_LOGGING // Start the rx poll diff --git a/bochs/iodev/eth_packetmaker.h b/bochs/iodev/eth_packetmaker.h index caec0d578..07c4ab210 100644 --- a/bochs/iodev/eth_packetmaker.h +++ b/bochs/iodev/eth_packetmaker.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_packetmaker.h,v 1.7 2004-09-18 12:35:13 vruppert Exp $ +// $Id: eth_packetmaker.h,v 1.8 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // @@ -10,7 +10,6 @@ #ifdef ETH_ARPBACK -#define PACKET_BUF_SIZE 2048 static const Bit8u internal_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00}; static const Bit8u external_mac[]={0xB0, 0xC4, 0x20, 0x20, 0x00, 0x00, 0x00}; static const Bit8u external_ip[]={ 192, 168, 0, 2, 0x00 }; @@ -22,7 +21,7 @@ static const Bit8u prot_tcp=6; class eth_packet { public: - Bit8u buf[PACKET_BUF_SIZE]; + Bit8u buf[BX_PACKET_BUFSIZE]; Bit32u len; }; diff --git a/bochs/iodev/eth_tap.cc b/bochs/iodev/eth_tap.cc index b0413f47d..d060486fd 100644 --- a/bochs/iodev/eth_tap.cc +++ b/bochs/iodev/eth_tap.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_tap.cc,v 1.23 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_tap.cc,v 1.24 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -114,7 +114,6 @@ #include #define BX_ETH_TAP_LOGGING 0 -#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame // // Define the class. This is private to this module @@ -123,7 +122,7 @@ class bx_tap_pktmover_c : public eth_pktmover_c { public: bx_tap_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg); + void *rxarg, char *script); void sendpkt(void *buf, unsigned io_len); private: int fd; @@ -146,8 +145,8 @@ public: protected: eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { - return (new bx_tap_pktmover_c(netif, macaddr, rxh, rxarg)); + void *rxarg, char *script) { + return (new bx_tap_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_tap_match; @@ -160,7 +159,8 @@ protected: bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { int flags; char filename[BX_PATHNAME_LEN]; @@ -222,12 +222,11 @@ bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif, /* Execute the configuration script */ char intname[IFNAMSIZ]; strcpy(intname,netif); - char *scriptname=bx_options.ne2k.Oscript->getptr(); - if((scriptname != NULL) - &&(strcmp(scriptname, "") != 0) - &&(strcmp(scriptname, "none") != 0)) { - if (execute_script(scriptname, intname) < 0) - BX_ERROR (("execute script '%s' on %s failed", scriptname, intname)); + if((script != NULL) + &&(strcmp(script, "") != 0) + &&(strcmp(script, "none") != 0)) { + if (execute_script(script, intname) < 0) + BX_ERROR (("execute script '%s' on %s failed", script, intname)); } // Start the rx poll @@ -269,7 +268,7 @@ bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif, void bx_tap_pktmover_c::sendpkt(void *buf, unsigned io_len) { - Bit8u txbuf[BX_PACKET_BUFSIZ]; + Bit8u txbuf[BX_PACKET_BUFSIZE]; txbuf[0] = 0; txbuf[1] = 0; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) // Should be fixed for other *BSD @@ -315,7 +314,7 @@ void bx_tap_pktmover_c::rx_timer_handler (void *this_ptr) void bx_tap_pktmover_c::rx_timer () { int nbytes; - Bit8u buf[BX_PACKET_BUFSIZ]; + Bit8u buf[BX_PACKET_BUFSIZE]; Bit8u *rxbuf; if (fd<0) return; nbytes = read (fd, buf, sizeof(buf)); diff --git a/bochs/iodev/eth_tuntap.cc b/bochs/iodev/eth_tuntap.cc index c972ec988..733c3d810 100644 --- a/bochs/iodev/eth_tuntap.cc +++ b/bochs/iodev/eth_tuntap.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_tuntap.cc,v 1.18 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_tuntap.cc,v 1.19 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -67,7 +67,6 @@ #include #define BX_ETH_TUNTAP_LOGGING 0 -#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame int tun_alloc(char *dev); @@ -78,7 +77,7 @@ class bx_tuntap_pktmover_c : public eth_pktmover_c { public: bx_tuntap_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg); + void *rxarg, char *script); void sendpkt(void *buf, unsigned io_len); private: int fd; @@ -101,8 +100,8 @@ public: protected: eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { - return (new bx_tuntap_pktmover_c(netif, macaddr, rxh, rxarg)); + void *rxarg, char *script) { + return (new bx_tuntap_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_tuntap_match; @@ -115,7 +114,8 @@ protected: bx_tuntap_pktmover_c::bx_tuntap_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { int flags; @@ -179,12 +179,11 @@ bx_tuntap_pktmover_c::bx_tuntap_pktmover_c(const char *netif, BX_INFO (("eth_tuntap: opened %s device", netif)); /* Execute the configuration script */ - char *scriptname=bx_options.ne2k.Oscript->getptr(); - if((scriptname != NULL) - &&(strcmp(scriptname, "") != 0) - &&(strcmp(scriptname, "none") != 0)) { - if (execute_script(scriptname, intname) < 0) - BX_ERROR (("execute script '%s' on %s failed", scriptname, intname)); + if((script != NULL) + &&(strcmp(script, "") != 0) + &&(strcmp(script, "none") != 0)) { + if (execute_script(script, intname) < 0) + BX_ERROR (("execute script '%s' on %s failed", script, intname)); } // Start the rx poll @@ -234,7 +233,7 @@ bx_tuntap_pktmover_c::sendpkt(void *buf, unsigned io_len) BX_DEBUG (("wrote %d bytes on tuntap - 14 bytes Ethernet header", io_len)); } #elif NEVERDEF - Bit8u txbuf[BX_PACKET_BUFSIZ]; + Bit8u txbuf[BX_PACKET_BUFSIZE]; txbuf[0] = 0; txbuf[1] = 0; memcpy (txbuf+2, buf, io_len); @@ -282,7 +281,7 @@ void bx_tuntap_pktmover_c::rx_timer_handler (void *this_ptr) void bx_tuntap_pktmover_c::rx_timer () { int nbytes; - Bit8u buf[BX_PACKET_BUFSIZ]; + Bit8u buf[BX_PACKET_BUFSIZE]; Bit8u *rxbuf; if (fd<0) return; diff --git a/bochs/iodev/eth_vde.cc b/bochs/iodev/eth_vde.cc index 71549f6a1..a6f5328d1 100644 --- a/bochs/iodev/eth_vde.cc +++ b/bochs/iodev/eth_vde.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_vde.cc,v 1.7 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_vde.cc,v 1.8 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2003 Renzo Davoli @@ -55,7 +55,6 @@ #define SWITCH_MAGIC 0xfeedface #define BX_ETH_VDE_LOGGING 0 -#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame int vde_alloc(char *dev,int *fdp,struct sockaddr_un *pdataout); @@ -66,7 +65,7 @@ class bx_vde_pktmover_c : public eth_pktmover_c { public: bx_vde_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg); + void *rxarg, char *script); void sendpkt(void *buf, unsigned io_len); private: int fd; @@ -89,8 +88,8 @@ public: protected: eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { - return (new bx_vde_pktmover_c(netif, macaddr, rxh, rxarg)); + void *rxarg, char *script) { + return (new bx_vde_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_vde_match; @@ -103,7 +102,8 @@ protected: bx_vde_pktmover_c::bx_vde_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { int flags; //if (strncmp (netif, "vde", 3) != 0) { @@ -132,12 +132,11 @@ bx_vde_pktmover_c::bx_vde_pktmover_c(const char *netif, BX_INFO (("eth_vde: opened %s device", netif)); /* Execute the configuration script */ - char *scriptname=bx_options.ne2k.Oscript->getptr(); - if((scriptname != NULL) - &&(strcmp(scriptname, "") != 0) - &&(strcmp(scriptname, "none") != 0)) { - if (execute_script(scriptname, intname) < 0) - BX_ERROR (("execute script '%s' on %s failed", scriptname, intname)); + if((script != NULL) + &&(strcmp(script, "") != 0) + &&(strcmp(script, "none") != 0)) { + if (execute_script(script, intname) < 0) + BX_ERROR (("execute script '%s' on %s failed", script, intname)); } // Start the rx poll @@ -218,7 +217,7 @@ void bx_vde_pktmover_c::rx_timer_handler (void *this_ptr) void bx_vde_pktmover_c::rx_timer () { int nbytes; - Bit8u buf[BX_PACKET_BUFSIZ]; + Bit8u buf[BX_PACKET_BUFSIZE]; Bit8u *rxbuf; struct sockaddr_un datain; socklen_t datainsize; diff --git a/bochs/iodev/eth_vnet.cc b/bochs/iodev/eth_vnet.cc index 99d468b5f..b4a399b7f 100644 --- a/bochs/iodev/eth_vnet.cc +++ b/bochs/iodev/eth_vnet.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_vnet.cc,v 1.9 2004-10-03 20:02:09 vruppert Exp $ +// $Id: eth_vnet.cc,v 1.10 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // virtual Ethernet locator @@ -40,11 +40,10 @@ static const Bit8u broadcast_ipv4addr[3][4] = {192,168, 10,255}, }; -#define IPPACKET_MAX 2048 #define ICMP_ECHO_PACKET_MAX 128 #define LAYER4_LISTEN_MAX 128 -static Bit8u packet_buffer[IPPACKET_MAX]; +static Bit8u packet_buffer[BX_PACKET_BUFSIZE]; static unsigned packet_len; typedef void (*layer4_handler_t)( @@ -110,7 +109,7 @@ public: bx_vnet_pktmover_c(); void pktmover_init( const char *netif, const char *macaddr, - eth_rx_handler_t rxh, void *rxarg); + eth_rx_handler_t rxh, void *rxarg, char *script); void sendpkt(void *buf, unsigned io_len); private: void guest_to_host(const Bit8u *buf, unsigned io_len); @@ -183,10 +182,10 @@ protected: eth_pktmover_c *allocate( const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) { + void *rxarg, char *script) { bx_vnet_pktmover_c *pktmover; pktmover = new bx_vnet_pktmover_c(); - pktmover->pktmover_init(netif, macaddr, rxh, rxarg); + pktmover->pktmover_init(netif, macaddr, rxh, rxarg, script); return pktmover; } } bx_vnet_match; @@ -246,7 +245,7 @@ bx_vnet_pktmover_c::bx_vnet_pktmover_c() void bx_vnet_pktmover_c::pktmover_init( const char *netif, const char *macaddr, - eth_rx_handler_t rxh, void *rxarg) + eth_rx_handler_t rxh, void *rxarg, char *script) { BX_INFO(("ne2k vnet driver")); this->rxh = rxh; @@ -678,9 +677,9 @@ bx_vnet_pktmover_c::host_to_guest_udpipv4_packet( unsigned target_port, unsigned source_port, const Bit8u *udpdata, unsigned udpdata_len) { - Bit8u ipbuf[IPPACKET_MAX]; + Bit8u ipbuf[BX_PACKET_BUFSIZE]; - if ((udpdata_len + 42U) > IPPACKET_MAX) { + if ((udpdata_len + 42U) > BX_PACKET_BUFSIZE) { BX_PANIC(("generated udp data is too long")); return; } diff --git a/bochs/iodev/eth_win32.cc b/bochs/iodev/eth_win32.cc index ab59a2964..9d34994bf 100644 --- a/bochs/iodev/eth_win32.cc +++ b/bochs/iodev/eth_win32.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: eth_win32.cc,v 1.23 2004-10-03 20:02:10 vruppert Exp $ +// $Id: eth_win32.cc,v 1.24 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -207,7 +207,7 @@ static const struct bpf_insn macfilter[] = { class bx_win32_pktmover_c : public eth_pktmover_c { public: bx_win32_pktmover_c(const char *netif, const char *macaddr, - eth_rx_handler_t rxh, void *rxarg); + eth_rx_handler_t rxh, void *rxarg, char *script); void sendpkt(void *buf, unsigned io_len); private: struct bpf_insn filter[8]; @@ -223,8 +223,10 @@ class bx_win32_locator_c : public eth_locator_c { public: bx_win32_locator_c(void) : eth_locator_c("win32") {} protected: - eth_pktmover_c *allocate(const char *netif, const char *macaddr, eth_rx_handler_t rxh, void *rxarg) { - return (new bx_win32_pktmover_c(netif, macaddr, rxh, rxarg)); + eth_pktmover_c *allocate(const char *netif, const char *macaddr, + eth_rx_handler_t rxh, + void *rxarg, char *script) { + return (new bx_win32_pktmover_c(netif, macaddr, rxh, rxarg, script)); } } bx_win32_match; @@ -236,7 +238,8 @@ protected: bx_win32_pktmover_c::bx_win32_pktmover_c(const char *netif, const char *macaddr, eth_rx_handler_t rxh, - void *rxarg) + void *rxarg, + char *script) { // Open Packet Driver Here. DWORD dwVersion; diff --git a/bochs/iodev/ne2k.cc b/bochs/iodev/ne2k.cc index b2bb4fc97..3f94dbd87 100644 --- a/bochs/iodev/ne2k.cc +++ b/bochs/iodev/ne2k.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: ne2k.cc,v 1.70 2004-09-25 22:15:02 vruppert Exp $ +// $Id: ne2k.cc,v 1.71 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -1302,7 +1302,7 @@ bx_ne2k_c::init(void) { char devname[16]; - BX_DEBUG(("Init $Id: ne2k.cc,v 1.70 2004-09-25 22:15:02 vruppert Exp $")); + BX_DEBUG(("Init $Id: ne2k.cc,v 1.71 2004-10-07 17:38:03 vruppert Exp $")); // Read in values from config file memcpy(BX_NE2K_THIS s.physaddr, bx_options.ne2k.Omacaddr->getptr (), 6); @@ -1402,7 +1402,8 @@ bx_ne2k_c::init(void) bx_options.ne2k.Oethdev->getptr (), (const char *) bx_options.ne2k.Omacaddr->getptr (), rx_handler, - this); + this, + bx_options.ne2k.Oscript->getptr ()); if (BX_NE2K_THIS ethdev == NULL) { BX_PANIC(("could not find eth module %s", ethmod)); @@ -1412,7 +1413,7 @@ bx_ne2k_c::init(void) BX_NE2K_THIS ethdev = eth_locator_c::create("null", NULL, (const char *) bx_options.ne2k.Omacaddr->getptr (), rx_handler, - this); + this, ""); if (BX_NE2K_THIS ethdev == NULL) BX_PANIC(("could not locate null module")); } diff --git a/bochs/iodev/pcipnic.cc b/bochs/iodev/pcipnic.cc index 6d7a16dca..4681b9a14 100644 --- a/bochs/iodev/pcipnic.cc +++ b/bochs/iodev/pcipnic.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pcipnic.cc,v 1.11 2004-10-03 20:02:10 vruppert Exp $ +// $Id: pcipnic.cc,v 1.12 2004-10-07 17:38:03 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2003 Fen Systems Ltd. @@ -87,15 +87,12 @@ bx_pcipnic_c::init(void) // This code ripped wholesale from ne2k.cc: // Attach to the simulated ethernet dev char *ethmod = bx_options.pnic.Oethmod->get_choice(bx_options.pnic.Oethmod->get()); - // - // FIXME: eth_tuntap.cc rips script straight from ne2k options... - // - bx_options.ne2k.Oscript->set ( bx_options.pnic.Oscript->getptr() ); BX_PNIC_THIS ethdev = eth_locator_c::create(ethmod, bx_options.pnic.Oethdev->getptr (), (const char *) bx_options.pnic.Omacaddr->getptr (), rx_handler, - this); + this, + bx_options.pnic.Oscript->getptr ()); if (BX_PNIC_THIS ethdev == NULL) { BX_PANIC(("could not find eth module %s", ethmod)); @@ -105,7 +102,7 @@ bx_pcipnic_c::init(void) BX_PNIC_THIS ethdev = eth_locator_c::create("null", NULL, (const char *) bx_options.pnic.Omacaddr->getptr (), rx_handler, - this); + this, ""); if (BX_PNIC_THIS ethdev == NULL) BX_PANIC(("could not locate null module")); }