Some changes in the 'vnet' networking module.

- Enable packet logging in text format if file name is specified with the
  "script" parameter.
- Don't start RX timer if vnet server returns 0.
- Added TCP header structure for future extensions.
This commit is contained in:
Volker Ruppert 2020-05-02 21:21:53 +00:00
parent d30dcfdd3c
commit 9b844fc341
6 changed files with 95 additions and 43 deletions

View File

@ -1037,8 +1037,8 @@ speaker: enabled=1, mode=sound
# as first parameter.
# The 'slirp' module uses this parameter to specify a config file for
# setting up an alternative IP configuration or additional features.
# The 'vnet' module uses this parameter to specify an alternative
# log file name.
# The 'vnet' module uses this parameter to specify a file name for logging
# packets in text format.
#
# BOOTROM: The bootrom value is optional, and is the name of the ROM image
# to load. Note that this feature is only implemented for the PCI version of

View File

@ -11,13 +11,17 @@ Changes after 2.6.11:
- Add more symbol lookups to disasm methods
- I/O Devices
- Added "multiple NICs" support to the NE2000 and E1000 devices. Up to 4 devices
per model are supported. Use the zero-based "card" parameter to specify device.
- Added log file support to 'bxhub' utility (networking module 'socket').
- VGA: Removed lfb_enabled switch from Bochs VBE code. Now banked and LFB writes
to VRAM are always valid. Fixes GRUB bootloader menu when using Bochs VBE.
- VGA DDC: Added "ddc" parameter to the "vga" option to make it possible
either to disable the DDC feature or to read the monitor EDID from file.
- Networking
- Added "multiple NICs" support to the NE2000 and E1000 devices. Up to 4 devices
per model are supported. Use the zero-based "card" parameter to specify device.
- Added log file support to 'bxhub' utility (networking module 'socket').
- Enable 'vnet' packet logging in text format if file name is specified with the
"script" parameter.
- VGA
- Removed lfb_enabled switch from Bochs VBE code. Now banked and LFB writes
to VRAM are always valid. Fixes GRUB bootloader menu when using Bochs VBE.
- DDC: Added "ddc" parameter to the "vga" option to make it possible
either to disable the DDC feature or to read the monitor EDID from file.
-------------------------------------------------------------------------
Changes in 2.6.11 (January 5, 2020):

View File

@ -4736,7 +4736,10 @@ is executed after bochs initialize the network interface. You can use
this script to configure this network interface, or enable masquerading.
This is mainly useful for the tun/tap devices that only exist during
Bochs execution. The network interface name is supplied to the script
as first parameter.
as first parameter. The 'slirp' module uses this parameter to specify a config
file for setting up an alternative IP configuration or additional features.
The 'vnet' module uses this parameter to specify a file name for logging
packets in text format.
BOOTROM: The bootrom value is optional, and is the name of the ROM image
to load. Note that this feature is only implemented for the PCI version of

View File

@ -1,5 +1,5 @@
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
.TH bochsrc 5 "22 Mar 2020" "bochsrc" "The Bochs Project"
.TH bochsrc 5 "2 May 2020" "bochsrc" "The Bochs Project"
.\"SKIP_SECTION"
.SH NAME
bochsrc \- Configuration file for Bochs.
@ -1175,8 +1175,8 @@ This is mainly useful for the tun/tap devices that only exist during
Bochs execution. The network interface name is supplied to the script
as first parameter. The 'slirp' module uses this parameter to specify
a config file for setting up an alternative IP configuration or additional
features. The 'vnet' module uses this parameter to specify an alternative
log file name.
features. The 'vnet' module uses this parameter to specify a file name for
logging packets in text format.
BOOTROM:
The bootrom value is optional, and is the name of the ROM image

View File

@ -59,7 +59,6 @@ void CDECL libvnet_net_plugin_fini(void)
#define LOG_THIS netdev->
#define BX_ETH_VNET_LOGGING 1
#define BX_ETH_VNET_PCAP_LOGGING 0
#if BX_ETH_VNET_PCAP_LOGGING
@ -100,9 +99,8 @@ private:
unsigned netdev_speed;
unsigned tx_time;
#if BX_ETH_VNET_LOGGING
bx_bool vnet_logging;
FILE *pktlog_txt;
#endif // BX_ETH_VNET_LOGGING
#if BX_ETH_VNET_PCAP_LOGGING
pcap_t *pcapp;
pcap_dumper_t *pktlog_pcap;
@ -159,25 +157,25 @@ void bx_vnet_pktmover_c::pktmover_init(
BX_INFO(("'vnet' network driver initialized"));
bx_vnet_instances++;
#if BX_ETH_VNET_LOGGING
if ((strlen(script) > 0) && (strcmp(script, "none"))) {
pktlog_txt = fopen(script, "wb");
vnet_logging = (pktlog_txt != NULL);
} else {
pktlog_txt = fopen("vnet-pktlog.txt", "wb");
vnet_logging = 0;
}
if (vnet_logging) {
fprintf(pktlog_txt, "vnet packetmover readable log file\n");
fprintf(pktlog_txt, "TFTP root = %s\n", netif);
fprintf(pktlog_txt, "host MAC address = ");
int i;
for (i=0; i<6; i++)
fprintf(pktlog_txt, "%02x%s", 0xff & dhcp.host_macaddr[i], i<5?":" : "\n");
fprintf(pktlog_txt, "guest MAC address = ");
for (i=0; i<6; i++)
fprintf(pktlog_txt, "%02x%s", 0xff & macaddr[i], i<5?":" : "\n");
fprintf(pktlog_txt, "--\n");
fflush(pktlog_txt);
}
if (!pktlog_txt) BX_PANIC(("vnet-pktlog.txt failed"));
fprintf(pktlog_txt, "vnet packetmover readable log file\n");
fprintf(pktlog_txt, "TFTP root = %s\n", netif);
fprintf(pktlog_txt, "host MAC address = ");
int i;
for (i=0; i<6; i++)
fprintf(pktlog_txt, "%02x%s", 0xff & dhcp.host_macaddr[i], i<5?":" : "\n");
fprintf(pktlog_txt, "guest MAC address = ");
for (i=0; i<6; i++)
fprintf(pktlog_txt, "%02x%s", 0xff & macaddr[i], i<5?":" : "\n");
fprintf(pktlog_txt, "--\n");
fflush(pktlog_txt);
#endif
#if BX_ETH_VNET_PCAP_LOGGING
pcapp = pcap_open_dead(DLT_EN10MB, BX_PACKET_BUFSIZE);
pktlog_pcap = pcap_dump_open(pcapp, "vnet-pktlog.pcap");
@ -187,9 +185,9 @@ void bx_vnet_pktmover_c::pktmover_init(
bx_vnet_pktmover_c::~bx_vnet_pktmover_c()
{
#if BX_ETH_VNET_LOGGING
fclose(pktlog_txt);
#endif
if (vnet_logging) {
fclose(pktlog_txt);
}
bx_vnet_instances--;
}
@ -200,9 +198,9 @@ void bx_vnet_pktmover_c::sendpkt(void *buf, unsigned io_len)
void bx_vnet_pktmover_c::guest_to_host(const Bit8u *buf, unsigned io_len)
{
#if BX_ETH_VNET_LOGGING
write_pktlog_txt(pktlog_txt, buf, io_len, 0);
#endif
if (vnet_logging) {
write_pktlog_txt(pktlog_txt, buf, io_len, 0);
}
#if BX_ETH_VNET_PCAP_LOGGING
if (pktlog_pcap && !ferror((FILE *)pktlog_pcap)) {
Bit64u time = bx_pc_system.time_usec();
@ -217,9 +215,11 @@ void bx_vnet_pktmover_c::guest_to_host(const Bit8u *buf, unsigned io_len)
this->tx_time = (64 + 96 + 4 * 8 + io_len * 8) / this->netdev_speed;
packet_len = vnet_server.handle_packet(buf, io_len, packet_buffer);
// host-to-guest
unsigned rx_time = (64 + 96 + 4 * 8 + io_len * 8) / this->netdev_speed;
bx_pc_system.activate_timer(this->rx_timer_index, this->tx_time + rx_time + 100, 0);
if (packet_len > 0) {
// host-to-guest
unsigned rx_time = (64 + 96 + 4 * 8 + io_len * 8) / this->netdev_speed;
bx_pc_system.activate_timer(this->rx_timer_index, this->tx_time + rx_time + 100, 0);
}
}
// The receive poll process
@ -234,9 +234,9 @@ void bx_vnet_pktmover_c::rx_timer(void)
{
if (this->rxstat(this->netdev) & BX_NETDEV_RXREADY) {
this->rxh(this->netdev, (void *)packet_buffer, packet_len);
#if BX_ETH_VNET_LOGGING
write_pktlog_txt(pktlog_txt, packet_buffer, packet_len, 1);
#endif
if (vnet_logging) {
write_pktlog_txt(pktlog_txt, packet_buffer, packet_len, 1);
}
#if BX_ETH_VNET_PCAP_LOGGING
if (pktlog_pcap && !ferror((FILE *)pktlog_pcap)) {
Bit64u time = bx_pc_system.time_usec();

View File

@ -104,6 +104,51 @@ typedef struct udp_header {
#endif
udp_header_t;
typedef struct tcp_header {
#if defined(_MSC_VER) && (_MSC_VER>=1300)
__declspec(align(1))
#endif
Bit16u src_port;
Bit16u dst_port;
Bit32u seq_num;
Bit32u ack_num;
#ifdef BX_LITTLE_ENDIAN
Bit8u reserved : 4;
Bit8u data_offset : 4;
#else
Bit8u data_offset : 4;
Bit8u reserved : 4;
#endif
struct {
#ifdef BX_LITTLE_ENDIAN
Bit8u fin : 1;
Bit8u syn : 1;
Bit8u rst : 1;
Bit8u psh : 1;
Bit8u ack : 1;
Bit8u urg : 1;
Bit8u ece : 1;
Bit8u cwr : 1;
#else
Bit8u cwr : 1;
Bit8u ece : 1;
Bit8u urg : 1;
Bit8u ack : 1;
Bit8u psh : 1;
Bit8u rst : 1;
Bit8u syn : 1;
Bit8u fin : 1;
#endif
} flags;
Bit16u window;
Bit16u checksum;
Bit16u urgent_ptr;
}
#if !defined(_MSC_VER)
GCC_ATTRIBUTE((packed))
#endif
tcp_header_t;
#if defined(_MSC_VER)
#pragma pack(pop)
#elif defined(__MWERKS__) && defined(macintosh)