Commit graph

76 commits

Author SHA1 Message Date
Mark Pizzolato
06c696385f SCP: Coverity inspired changes 2022-03-06 02:11:57 -08:00
Mark Pizzolato
d8e41d64a3 SOCK: Properly avoid mixing char * and const char * references 2022-02-06 18:22:49 -08:00
Mark Pizzolato
10e561767f SOCK: Add support for parsing and evaluating Access Control Lists 2022-02-04 07:58:09 -08:00
Mark Pizzolato
c5cd38afbf SCP, makefile: Rename build conditional HAVE_DLOPEN to SIM_HAVE_DLOPEN
Some dependent packages on some platforms may also define HAVE_DLOPEN
and that definition may have different syntax or semantics.  This change
avoids the potential symbol conflict.

As reported in #1098
2021-12-04 17:44:57 -08:00
Mark Pizzolato
6af7a8a434 SOCK: Remove duplicate nonblocking code in sim_connect_sock_ex 2020-04-11 13:04:53 -07:00
Mark Pizzolato
16e7ffa901 SOCK: Fix issues in IPv6 emulation routines used when IPv6 isn't available.
Also provide a way to build so that the IPv6 fallback stubs can be tested on
systems with native IPv6 support when compiled with TEST_INFO_STUBS
defined.
2020-03-31 09:06:09 -07:00
Mark Pizzolato
89cd649c77 SOCKET: Implement missing non-blocking for TCP sockets opened with connect
Outbound connections are rare and most may have wanted explicit blocking
behavior, so no one noticed the missing non-blocking case.

Any place which did do outbound connects have explicitly added
SIM_SOCK_OPT_BLOCKING so that the prior behavior is preserved.

The SIM_SOCK_OPT_BLOCKING flag is no honored as it was originally
intended to be.
2020-03-18 00:47:48 -07:00
Mark Pizzolato
bdc677b748 SOCK: Properly implement getaddrinfo when the host OS doesn't have it.
As reported in #767
2019-11-14 13:14:14 -08:00
Mark Pizzolato
82d897712c SCP: Avoid noisy compiles on some Cygwin builds
Some from suggestion in #760 with extra condition consistent with other
conditionals already present.
2019-10-30 20:35:24 -07:00
Mark Pizzolato
064c8e54a8 SCP: Silence Coverity warnings 2017-03-31 18:54:18 -07:00
Mark Pizzolato
64716dad74 makefile: Fix MinGW build to allow C++ compiles 2016-05-16 16:17:22 -07:00
Mark Pizzolato
5531ccb175 ALL: Massive 'const' cleanup
These changes facilitate more robust parameter type checking and helps
to identify unexpected coding errors.

Most simulators can now also be compiled with a C++ compiler without
warnings.

Additionally, these changes have also been configured to facilitate easier
backporting of simulator and device simulation modules to run under the
simh v3.9+ SCP framework.
2016-05-15 15:25:33 -07:00
Mark Pizzolato
d8f2647f93 SCP: general const cleanups and const change to sim_vm_parse_addr. 2016-01-24 08:27:08 -08:00
Mark Pizzolato
636b8c9dec SOCKET: remove dependence on timerclear() 2015-11-02 03:56:20 -08:00
Mark Pizzolato
e69c3adf5f SOCKETS: Suppress expected read error message on close of a blocking socket. 2015-02-15 12:06:53 -08:00
Mark Pizzolato
ef9d1adce1 PDP10, PDP11, VAX: const cleanup 2015-02-13 06:18:24 -08:00
Mark Pizzolato
4c8e1631b5 FRONTPANEL: Cleanup for building as C++. Add initial support for device panels concurrently on a simulator. Added an API to set a register value. 2015-02-12 14:59:24 -08:00
Mark Pizzolato
bc9e79a266 SOCKETS: Fixed error suppression when connecting a blocking mode TCP socket 2015-02-11 13:47:54 -08:00
Mark Pizzolato
1fb209c275 SOCKETS: Cleanup, simplify and extend the sim_sock API set.
Cleanup/Simplification by:
	1) removing irrelevant master flag variable from sim_close_sock and thus sim_err_sock
	2) change previous boolean feature arguments (datagram, nodelay, reuseaddr) to flag bits in a single option argument.  This allows for features to be added by new flag bits which don't change the calling signatures.
	3) changed all status returns to be int (vs t_stat) with success being 0 and error being -1
	4) removed unneeded simh specific type references to allow sim_sock to be used by n
Extended API by providing flags to influence socket setup/behavior:
	SIM_SOCK_OPT_REUSEADDR	Retains prior behavior when sim_switches had -U set
	SIM_SOCK_OPT_DATAGRAM	UDP socket setup provided for when prior datagram argument was specified
	SIM_SOCK_OPT_NODELAY		TCP Nagle disable provided for when prior nodelay argument was specified
	SIM_SOCK_OPT_BLOCKING	Blocking socket mode (detault is non blocking)
2015-02-11 09:41:18 -08:00
Mark Pizzolato
f2674766ca SOCK: Add TCP keepalive support to all incoming and outgoing TCP sockets.
This allows detection of network failures when there is no traffic across established circuits,
2015-02-06 14:52:09 -08:00
Mark Pizzolato
c083b45c14 TMXR, SOCK: Properly declare as const string input only arguments. 2014-12-06 03:50:45 -08:00
François Revol
b2aaec0b3e Haiku has socklen_t 2014-08-31 22:31:30 +02:00
Mark Pizzolato
c15c0058f4 ETHER: Made LAN connections more robust under failing network conditions.
Avoid permanent network network hangs when a network transport starts to return errors for various reasons.
These hangs also result in at least one thread in a CPU bound loop attempting to read on a pcap connection which will never be useful again.

When transmit or receive errors occur, the invoking thread sleeps for 1 second and subsequent operations proceed.  When the total of read + write errors reaches a multiple of ETH_ERROR_REOPEN_THRESHOLD the current transport connection (usually pcap) is closed and re-opened after a ETH_ERROR_REOPEN_PAUSE second delay.  If the open succeeds, we're happy.  If it fails, then the link behaves as if it were never attached until some subsequent operator intervention is performed.

Activities which are known to induce this problems include (but are not limited to) when a simulator is running in a Windows Virtual Machine on a Hyper-V host system and the Hyper-V host system performs a SAVE and a subsequent Restart of the Guest Windows Virtual Machine.  This operation can occur due to specific operator requests or merely when the Hyper-V host system reboots.
2014-06-10 10:20:02 -07:00
Mark Pizzolato
6ce8d99cd8 SCP: Added generic output routine sim_printf to output to stdout and sim_log (and sim_deb when enabled)
The goals here being to simplify calling code while getting consistent output delivered everywhere it may be useful.

Modified most places which explicitly used sim_log or merely called printf to now avoid doing that and merely call sim_printf().
2014-03-28 08:20:05 -07:00
Mark Pizzolato
02cb5c2d88 Compiler suggested cleanups.
Mostly silencing noise warnings, but bugs were found in sim_console.c and pdp11_dmc.c
2014-02-14 17:07:45 -08:00
Mark Pizzolato
c8991a4084 SOCK: avoid calling strcpy with overlapping arguments when converting IPv4-mapped address strings. Fixes issue #111 2014-02-12 03:40:10 -08:00
Mark Pizzolato
9ab6c4d1c1 SOCKET: Extended TMXR packet capabilities to disable the Nagle algorithm when TCP packets transports are used. 2014-01-23 09:31:05 -08:00
Mark Pizzolato
86e342501d SCP: One more static analyzer potential issue from Peter Schorn. 2013-12-28 05:31:07 -08:00
Mark Pizzolato
2bb502ee64 SCP: Static Analyzer cleanups suggested by Peter Schorn 2013-12-27 07:08:17 -08:00
Mark Pizzolato
834e986eaf ETHER,VAX,PDP11: Added UDP as a link type for Ethernet packet connectivity.
This will allow a single simulator to directly connect to HECnet systems without needing an external bridge program.
2013-12-05 11:58:58 -08:00
Mark Pizzolato
c9f73eac90 H316: Rewrote h316_udp to use TMXR lines for UDP transport of data. Changed h316_mi to leverage built-in loopback mode in TMXR.
This gives UDP transport on all simh host platforms.
2013-11-26 13:30:11 -08:00
Mark Pizzolato
beac643acb SCP/SOCKET: Apply default host more reasonably when parsing host:port strings 2013-11-26 11:07:21 -08:00
Mark Pizzolato
4259b3c83a TMXR: Added option to use UDP transport for packet transport 2013-11-25 04:36:21 -08:00
Mark Pizzolato
2e85e74699 SCP: Various cleanups.
- Avoid assignments of void * values.  Cast all memory allocation return values to appropriate types.
- Add output to sim_log where missing in various places.
- Fixed issue with lost file positions after a restore for devices which leverage the UNIT_SEQ flag.
2013-11-20 09:13:27 -08:00
Mark Pizzolato
43f85d1f3a SCP/TMXR: Fix to socket writes to return 0 bytes written as an expected condition when the output socket is full (EAGAIN or EWOULDBLOCK). 2013-11-04 05:21:58 -08:00
Mark Pizzolato
c22063c431 sim_sock.c allow validation address to match various forms of literal localhost addresses. 2013-08-27 10:41:49 -07:00
Mark Pizzolato
8d1a1344f0 Added sim_getnames_sock to get a printable form of the endpoints of a socket 2013-05-15 13:47:40 -07:00
Mark Pizzolato
0b1fe53943 Use generic message routine for sim_accept_conn and sim_read_sock and don't emit a message if a read fails due to ECONNRESET (this is expected). 2013-05-14 17:10:51 -07:00
Mark Pizzolato
9faef6ea89 Added separate debugging ability to trace line connect/disconnect activities to better debug virtual null modem cable activities. 2013-05-06 07:50:09 -07:00
Mark Pizzolato
60695d3647 Missing change for issue #48 2013-04-23 12:53:35 -07:00
Mark Pizzolato
b04b7ae5b1 Fixed socket creation issue which happens on some IPv6 capable systems which don't have IPv6 enabled but return IPv6 family addresses with getaddrinfo. This is issue #48 2013-04-23 12:27:16 -07:00
Mark Pizzolato
34ad155854 Compiler suggested cleanups 2013-04-13 05:25:25 -07:00
Mark Pizzolato
6fd3e5f498 Added an message text for additional socket error which can be expected to happen on windows 2013-04-12 12:58:08 -07:00
Mark Pizzolato
6f44a394e6 Added option to create listen sockets with SO_REUSEADDR if attach is done with -U switch set. Requested by Michael Mondy 2013-04-12 12:40:56 -07:00
Mark Pizzolato
b125da77cc Fixed prior logic in sim_check_conn to return error conditions prior to read/write checks and to validate the peer's address on both read and write connection checks. 2013-03-31 20:32:41 -07:00
Mark Pizzolato
d308a234e2 Fixed sim_check_conn to return error status if the socket being checked is writable and no peer name exists (i.e. when a connect has failed). Suggested by Paul Koning 2013-03-31 10:44:17 -07:00
Mark Pizzolato
1e515d8357 HP-UX socket fixes from Mikulas Patocka.
1. getaddrinfo returns IPv6 address even if IPv6 is not configured.
The socket syscalls fails to create IPv6 socket. This is fixed by retrying for all possible addresses returned by getaddrinfo.

2. On HP-UX EAGAIN is used, not EWOULDBLOCK.
2013-03-18 06:07:27 -07:00
Mark Pizzolato
eb101e3881 HP-UX port supplied by Mikulas Patocka 2013-03-05 13:29:38 -08:00
Mark Pizzolato
4ff56d6c15 Changed all internal #ifdef's which were conditional on __linux to be conditional on either __linux or __linux__. Some platforms (PPC) don't define __linux when gcc is invoked with -std=c99. 2013-02-20 21:57:02 -08:00
Mark Pizzolato
e6eae9194f Fixed last change which only still worked if the OS returned the IPv6 socket first and now failed completely if not. 2013-01-23 15:12:35 -08:00