Commit Graph

179 Commits

Author SHA1 Message Date
Volker Ruppert
9c356c4f2e Enable slirp IPv6 support by default.
Added slirp config option "ipv6_prefix".
2024-05-23 19:01:40 +02:00
Volker Ruppert
b76ead90ed Builtin slirp: several fixes and additions.
The slirplog object must exist before calling slirp_new().
Function slirplog_error() can handle arguments now.
Most of the fprintf() calls replaced by slirplog_error().
Added IPv6 host forwarding feature (not yet used by Bochs).
Added stubs for slirp_connection_info() and slirp_neighbor_info().
Fixed some warnings.
2024-05-18 23:14:45 +02:00
Volker Ruppert
9e9e1f5e28 Some additions for the builtin slirp support.
Started implementing slirp debug message support. For now DEBUG_CALL messages
can be sent to log file by setting new option 'debug_switches' to 1.
Moved function slirp_warning() to slirp.cc (TODO: change fprintf() to slirp_warning()).
Updated some tcp_emu() stuff from libslirp (not yet used by Bochs).
2024-05-17 20:00:53 +02:00
Volker Ruppert
e4978addd1 bximage: added simple partition table viewer to the info function.
The code is based on parts of the SF patch "bxmount".
2024-04-14 18:15:52 +02:00
Volker Ruppert
5376f129ee Some work on the slirp networking code.
- Added support for optional TFTP server name in builtin slirp and libslirp.
- Added default domain name for libslirp.
2024-04-14 11:04:01 +02:00
Volker Ruppert
155fc74d30 Some work on the libslirp networking support.
- Added capability to turn on IPv6 support with slirp.conf option (using default
  QEMU settings for now / non-Windows platforms only).
- Added some basic timer code required by IPv6 based on example code.
2024-04-13 10:18:38 +02:00
Biswapriyo Nath
e1d67d9ce0
Fix checking Android platform with __ANDROID__ macro (#299)
This change fixes compiler errors in Android as following.
    
../../../iodev/sound/soundoss.cc:43:10: fatal error: 'sys/soundcard.h'
file not found
       43 | #include <sys/soundcard.h>
          |          ^~~~~~~~~~~~~~~~~
../../../iodev/network/slirp/misc.cc:195:12: error: use of undeclared
identifier 'getdtablesize'; did you mean 'getpagesize'?
      195 |                 for (s = getdtablesize() - 1; s >= 3; s--)
          |                          ^~~~~~~~~~~~~
          |                          getpagesize
/data/data/com.termux/files/usr/include/unistd.h:356:5: note:
'getpagesize' declared here
      356 | int getpagesize(void) __INTRODUCED_IN(21);
          |     ^
    
The official documentation also suggests to use __ANDROID__ macro which
is defined by the compiler irrespective of included headers and build
system.
https://android.googlesource.com/platform/bionic/+/HEAD/docs/defines.md
2024-04-06 23:18:01 +02:00
rofl0r
fb8fc563ab
bximage: flush stdout after asking a question (#251)
otherwise the question may not even arrive there, depending on the
implementation-defined behaviour of stdio buffering.
fixes display of questions with musl libc.
2024-02-01 22:54:31 +02:00
Saulius Krasuckas
f221984d89
Fix niclist.exe crash when writing to string returned by PACKET.DLL (#179)
Seemingly Npcap returns a read-only string and `niclist.exe` tries to
modify (tokenize) it using `strtrok()`.
That results in the crash: #161

Probably related to
https://github.com/the-tcpdump-group/libpcap/pull/949.

Here is my try at fixing this.
For successful modification I propose to use a stack-allocated copy
instead of the original (const) version string.

Now
[packetWin7/Dll/Packet32.cpp#L159](https://github.com/nmap/npcap/blob/a41bc6a/packetWin7/Dll/Packet32.cpp#L159)
seems to initialize `const char PacketLibraryVersion[]` from the define
`WINPCAP_VER_STRING`, which seems to be of arbitrary length:
```
__declspec(dllexport) const char PacketLibraryVersion[] = WINPCAP_VER_STRING; 
```

Let's search for the longest string present in their repo:
```
$ git log -u version.h | awk 'BEGIN { FPAT="(([^ \t]+)?(\"[^\"]+\")?)+" } /^.*define.+WINPCAP_VER_STRING.+[0-9]/ { gsub(/"/, "", $NF); print $NF }' | sort -Vu | while read; do printf "%4s    %s\n" ${#REPLY} "${REPLY}"; done | sort -n
   4    0.01
   4    0.03
   4    0.04
   4    0.05
   4    0.06
   4    0.07
   4    0.08
   4    0.09
   4    0.10
   4    0.11
   4    0.78
   4    0.80
   4    0.81
   4    0.82
   4    0.83
   4    0.84
   4    0.85
   4    0.86
   4    0.90
   4    0.91
   4    0.92
   4    0.93
   4    0.94
   4    0.95
   4    0.96
   4    0.97
   4    0.98
   4    1.00
   4    1.10
   4    1.20
   4    1.30
   4    1.31
   4    1.40
   4    1.50
   4    1.55
   4    1.60
   4    1.70
   4    1.71
   4    1.72
   4    1.73
   4    1.74
   4    1.75
   4    1.76
   4    1.77
   4    1.78
   5    0.991
   5    0.992
   5    0.993
   5    0.994
   5    0.995
   5    0.996
   5    0.997
   6    0.9981
   6    0.9982
   6    0.9983
   6    0.9984
   6    0.9985
   6    0.9986
   6    0.9987
   6    0.9988
   6    0.9989
   6    0.9990
   6    0.9991
   6    0.9992
   6    0.9993
   6    0.9994
   6    0.9995
   6    0.9996
   6    0.9997
   7    0.08 r8
   7    0.08 r9
   7    0.09 r2
   7    0.09 r3
   7    0.09 r4
   7    0.09 r5
   7    0.09 r6
   7    0.09 r7
   7    0.09 r8
   7    0.09 r9
   7    0.10 r2
   7    0.10 r3
   7    0.10 r4
   7    0.10 r5
   7    0.10 r6
   7    0.10 r7
   7    0.10 r8
   7    0.10 r9
   7    0.78 r2
   7    0.78 r3
   7    0.78 r4
   7    0.78 r5
   7    0.99-r1
   7    0.99-r2
   7    0.99-r3
   7    0.99-r4
   7    0.99-r5
   7    0.99-r6
   7    0.99-r7
   7    0.99-r8
   7    0.99-r9
   8    0.08 r10
   8    0.09 r10
   8    0.09 r11
   8    0.09 r12
   8    0.09 r13
   8    0.10 r10
   8    0.10 r11
   8    0.10 r12
   8    0.10 r13
   8    0.10 r14
   8    0.10 r15
   8    0.10 r16
   8    0.10 r17
   8    0.10 r18
  10    4.1.0.2980
  10    4.1.0.3001
```

So it's 10 characters. (Sorry for the long Bash one-liner)

Also I visited the older code from WinPcap, and it seems it used a
64-byte long string:
[packetNtx/Dll/Packet32.c#L105](https://github.com/wireshark/winpcap/blob/267327e/packetNtx/Dll/Packet32.c#L105)
```
char PacketLibraryVersion[64]; 
```

So I assumed it's safe to allocate the same on stack.
2023-12-18 13:00:59 +02:00
Volker Ruppert
bb477316f1 Some small bximage quiet mode changes.
- Show error message if a parameter is missing for quiet mode.
- Show defaults in help message.
- Added quiet mode example in manual page.
2023-12-10 11:17:21 +01:00
Volker Ruppert
52b0000db7 Applied two patches from Debian.
- Apply standard flags from environment everywhere (SF patch #546).
- Allow overriding ld and objcopy for building bios on non-x86 platforms.
2021-09-10 15:33:22 +00:00
Stanislav Shwartsman
fcb85bebe3 remove code duplication and extract all bswap functions from bochs.h to misc/bswap.h 2021-01-30 20:33:22 +00:00
Stanislav Shwartsman
abac80801f more bx_bool -> bool also fixing bxhub.cc case where bx_bool were assigned integer -1 value 2021-01-30 17:37:42 +00:00
Volker Ruppert
d61e3eca9b Moved image creation code for sparse, growing, vmware4 and vpc mode images from
the main bximage code to the device_image_t class / file it belongs to (enabled
in the BXIMAGE case only).
2021-01-16 12:47:02 +00:00
Volker Ruppert
38a04afe8e Some work on the bximage utility.
- The selected / detected disk image mode is now stored as a string constant to
  simplify code (same as Bochs core).
- Changed command line option to select operation mode to "-func=X" to avoid
  confusion with disk image mode.
- Documentation updates.
2021-01-09 16:51:52 +00:00
Volker Ruppert
3602ec1cd7 Added support for converting VDI images to another format with bximage. 2021-01-08 13:19:08 +00:00
Volker Ruppert
7c8748a661 Removed stub for the "external" disk image mode. It was designed for
implementing disk image support with an external C++ class. With the new code
it's now easier to implement support for additional disk images formats, so we
don't need the old stub anymore.
2021-01-07 20:50:34 +00:00
Volker Ruppert
5ffb319df1 Rewrite of the disk image mode handling. Disk image modes are now stored as
string constants instead of hardcoded values. Available modes are detected at
Bochs startup and stored in a string array before initializing options. In the
plugins case additional modes are read from the plugins list. If plugins are
off, the hdimage_locator_c registry is used. Related changes in all parts of
Bochs that need the hdimage stuff.
TODO #1: Network and sound drivers could be handled in a similar way.
TODO #2: Make disk image mode detection work again in plugins mode.
2021-01-05 21:57:13 +00:00
Volker Ruppert
c99bd49f34 Some work on the hdimage plugin support.
- Renamed vpc-img.* files to vpc.* and removed hack for image mode name conversion.
- Added suffix "_img" to all disk image mode plugin base names. This is important
  for the future implementation of a plugin enumeration at Bochs startup.
2020-12-30 17:56:27 +00:00
Volker Ruppert
bdb7954732 Some small changes for the vnet server support.
- bxhub: initialize DHCP "net" IP address.
- DHCP: increase lease time to 24 hours.
- DHCP: simplified broadcast IP address handling.
2020-09-05 08:39:25 +00:00
Volker Ruppert
a16a4a0886 Some improvements for the vnet config file support.
- Added options "net" for the IP address space and "ftp" for the FTP server.
- Added some sanity checks for the IP address configuration.
- Added sample config file.
2020-09-03 14:23:06 +00:00
Volker Ruppert
600228148d Fixed some gcc 9.3 warnings. 2020-09-01 20:13:56 +00:00
Volker Ruppert
b558f19338 Prepared vnet server for setting up client hostname from config. 2020-08-24 11:22:37 +00:00
Volker Ruppert
28de72b0ea Added support for setting up the network bootfile in the bxhub utility.
TODO: Implement configurable bootfile in the vnet module.
2020-08-09 17:24:08 +00:00
Volker Ruppert
79156f6b2f Added support for setting up the vnet FTP service with a different IPv4 address.
The 'vnet' networking module now uses 192.168.10.3 and bxhub is setting up the
slirp compatible IP 10.0.2.4 for additional services. Added host name "vnet-ftp"
in the DNS code to translate it to the new IP address.
2020-06-12 06:31:09 +00:00
Volker Ruppert
a4bf5843f0 Some work on the vnet server code.
- FTP: handle the hidden flag on Windows the same way as on other platforms.
- TCP/IP: fixed some gcc 9 warnings (checked with Cygwin gcc 9.3).
- DHCP: changed the way to set up the default client IPv4 address.
2020-06-11 14:26:34 +00:00
Volker Ruppert
08386c771e Some work on the vnet FTP support and documentation.
- Reset FTP session state in case of login failure.
- Improved FTP server status output.
- Added special error messages for 2 unimplemented commands.
- Updated vnet / socket / slirp networking module infos in source and docs.
2020-06-04 16:08:03 +00:00
Volker Ruppert
f378ca5418 Added some core functions to the vnet FTP service and some fixes.
- FTP: added support for renaming file, create and remove directory.
- FTP: added FTP server status report and fixed SYST reply.
- bxhub fix: send all pending packets one after the other.
- TCP fix: when connecting, return default MSS option value 1460.
- TCP fix: handle the case when FIN is set in final data packet.
2020-05-30 14:44:53 +00:00
Volker Ruppert
2b79641f3a Added support for deleting files in the vnet FTP support and some cleanups. 2020-05-29 09:02:14 +00:00
Volker Ruppert
548f9456e8 Packet logging in text format now controlled by option "pktlog" in slirp config. 2020-05-19 17:55:15 +00:00
Volker Ruppert
9c3a99856e Added basic TCP handling and FTP server stub for testing.
- Partly re-implemented host_to_guest methods from legacy eth_vnet.cc.
- Added two dynamic packet buffers for vnet server replies.
- TFTP and FTP servers are only available if root directory is configured.
- Added TCP port handler methods similar to the UDP ones.
- Added basic TCP connection management and 3-way handshake.
- Added FTP server stub for testing TCP (only login/logout for now).
2020-05-12 20:51:26 +00:00
Volker Ruppert
d30dcfdd3c Added log file support to the 'bxhub' utility. Log output can be sent to file
specified with command line option, otherwise stderr is used.
2020-04-13 19:35:56 +00:00
Volker Ruppert
451b60b8a2 Rewrite of the 'vnet' server code used by the vnet networking mode and the bxhub
utility to get rid of code duplication. New class vnet_server_c now contains all
of the network emulation including the DNS code from bxhub.cc.
2020-04-12 09:14:01 +00:00
Volker Ruppert
9eb1cf233c Fixes for compiling on MacOS (bxhub and eth_socket / patch by Yasser Rathore). 2020-02-17 20:49:10 +00:00
Stanislav Shwartsman
96e2c50bef applying SF patch #545 Speling fixes 2019-12-09 16:29:23 +00:00
Volker Ruppert
445bf01b2a Removed deprecated function GetVersion() from eth_win32.cc and niclist.c.
Since the presence of UNICODE or ANSI format only depends on the PACKET.DLL
version, no Windows version check is necessary.
2019-12-08 18:14:30 +00:00
Volker Ruppert
1855f22d2b Added sector size option in bximage for creating flat, sparse and growing mode
images. TODO: using ATA disk images with big sectors requires BIOS support.
2018-03-30 21:04:04 +00:00
Volker Ruppert
0d7c32c6b5 Minor fixes and cleanups in the bxhub code.
TODO: rewrite of the vnet server code to reduce code duplication.
2017-07-04 18:53:33 +00:00
Volker Ruppert
851e9a084c Fixed compilation on MSVC (Bochs always defines stricmp). 2017-06-23 19:44:30 +00:00
Volker Ruppert
d22cdbdbf7 Some work on the bxhub utility.
- Added DNS service support for the server "vnet" and connected clients.
- Added command line option "-loglev=" to control whether or not there is
  BX_ERROR, BX_INFO or BX_DEBUG output. Default value is 1 (BX_ERROR only).
2017-06-17 12:40:13 +00:00
Volker Ruppert
2fb6263102 Compilation fixes for Cygwin.
NOTE: networking still fails when compiled with Cygwin ('socket' mode fails
to set up non-blocking i/o / 'slirp' doesn't complain, but fails to connect
the internet).
2017-04-18 20:45:28 +00:00
Volker Ruppert
8c310f68e1 Documentation updates.
- Added section about the 'socket' networking module.
- Updated and sorted lists of installed files on Windows and Linux.
- Fixed bxhub help message.
2017-03-19 19:08:15 +00:00
Volker Ruppert
758f4de4d4 Rewrite of the network driver plugin code.
- Removed "pseudo device plugin" containing common code and specific drivers.
- Moved network module base classes and module handling to the Bochs core.
  Now loading network driver plugins in netmod.cc.
- Moved shared networking code used by the 'vnet' driver and 'bxhub' from
  netmod.cc/.h to new files netutil.cc/.h.
- Created separate plugins for each network driver implementation.
- Modified Bochs plugin system to support new plugin type PLUGTYPE_NETWORK.
2017-03-12 07:48:08 +00:00
Volker Ruppert
30a20ba50f Fixed compilation errors on Windows. 2017-03-08 22:09:50 +00:00
Volker Ruppert
a037c74071 Added support for connecting the 'bxhub' utility running on another machine.
The format of the 'ethdev' string must be 'host:port' to use this feature.
Using the port number only for connecting 'bxhub' on the same machine is still
supported.
2017-03-07 19:20:35 +00:00
Volker Ruppert
e67493c58e Some work on the bxhub code.
- Prepared bxhub for connections from other machines.
- Added missing WSACleanup() for Windows.
- TODO: Support for other machines in eth_socket.cc.
2017-03-06 19:00:52 +00:00
Volker Ruppert
c756fed13e Fixed and simplified default IP address generation. 2017-03-04 13:32:41 +00:00
Volker Ruppert
112e9016c2 Some changes in bxhub and related code.
- Increase maximum number of Bochs client sessions to 6.
- Define bx_devmodel_c to 'void' for the bxhub case to simplify netmod code.
- Minor cleanups in bxhub and related vnet code.
2017-03-03 09:56:18 +00:00
Volker Ruppert
06511be14d Added support for up to 4 connections to Bochs sessions (same machine only). 2017-03-02 10:21:14 +00:00
Volker Ruppert
0011092ddb Some work on the eth_vnet and bxhub code to reduce code duplication. Moved some
shared functions to netmod.cc and modified ARP, IPv4 and ICMP code.
2017-03-01 16:53:57 +00:00